summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/coco/cococart.cpp
blob: 2c385890311ecd4eaafeafae9b7c9c0049f1b184 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/*********************************************************************

    cococart.cpp

    CoCo/Dragon cartridge slot - typically used for "Program Paks"
    (which are simple ROMs) but in practice is the main extensibility
    mechanism for CoCo hardware

    CoCo and Dragon pinout listing
       ---  -------            ---  -------
         1  -12V                21  A2
         2  +12V                22  A3
         3  HALT                23  A4
         4  NMI                 24  A5
         5  RESET               25  A6
         6  EIN                 26  A7
         7  QIN                 27  A8
         8  CART                28  A9
         9  +5V                 29  A10
        10  D0                  30  A11
        11  D1                  31  A12
        12  D2                  32  CTS
        13  D3                  33  GND
        14  D4                  34  GND
        15  D5                  35  SND
        16  D6                  36  SCS
        17  D7                  37  A13
        18  R/!W                38  A14
        19  A0                  39  A15
        20  A1                  40  SLENB

    Notes:
        CTS - ROM read $C000-$FEFF ($FDFF on CoCo 3)
        SCS - Spare Chip Select:  IO space between $FF40-5F

*********************************************************************/

#include "emu.h"
#include "cococart.h"
#include "formats/rpk.h"

#include "coco_dcmodem.h"
#include "coco_fdc.h"
#include "coco_gmc.h"
#include "coco_ide.h"
#include "coco_max.h"
#include "coco_midi.h"
#include "coco_multi.h"
#include "coco_orch90.h"
#include "coco_pak.h"
#include "coco_psg.h"
#include "coco_ram.h"
#include "coco_rs232.h"
#include "coco_ssc.h"
#include "coco_stecomp.h"
#include "coco_sym12.h"
#include "coco_wpk.h"
#include "coco_wpk2p.h"

#include "dragon_amtor.h"
#include "dragon_claw.h"
#include "dragon_fdc.h"
#include "dragon_jcbsnd.h"
#include "dragon_jcbspch.h"
#include "dragon_msx2.h"
#include "dragon_serial.h"
#include "dragon_sprites.h"


/***************************************************************************
    PARAMETERS
***************************************************************************/

#define LOG_CART (1U << 1) // shows cart line changes
#define LOG_NMI  (1U << 2) // shows switch changes
#define LOG_HALT (1U << 3) // shows switch changes
// #define VERBOSE (LOG_CART)

#include "logmacro.h"

#define LOGCART(...) LOGMASKED(LOG_CART,  __VA_ARGS__)
#define LOGNMI(...)  LOGMASKED(LOG_NMI,  __VA_ARGS__)
#define LOGHALT(...) LOGMASKED(LOG_HALT,  __VA_ARGS__)


/***************************************************************************
    CONSTANTS
***************************************************************************/

// definitions of RPK PCBs in layout.xml
static const char *coco_rpk_pcbdefs[] =
{
	"standard",
	"paged16k",
	nullptr
};


// ...and their mappings to "default card slots"
static const char *coco_rpk_cardslottypes[] =
{
	"pak",
	"banked_16k"
};


//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DEFINE_DEVICE_TYPE(COCOCART_SLOT, cococart_slot_device, "cococart_slot", "CoCo Cartridge Slot")


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

ALLOW_SAVE_TYPE(cococart_slot_device::line_value);

//-------------------------------------------------
//  cococart_slot_device - constructor
//-------------------------------------------------
cococart_slot_device::cococart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
	device_t(mconfig, COCOCART_SLOT, tag, owner, clock),
	device_single_card_slot_interface<device_cococart_interface>(mconfig, *this),
	device_cartrom_image_interface(mconfig, *this),
	m_cart_callback(*this),
	m_nmi_callback(*this),
	m_halt_callback(*this), m_cart(nullptr)
{
}



//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void cococart_slot_device::device_start()
{
	for(int i=0; i < TIMER_POOL; i++ )
	{
		m_cart_line.timer[i]    = timer_alloc(FUNC(cococart_slot_device::cart_line_timer_tick), this);
		m_nmi_line.timer[i]     = timer_alloc(FUNC(cococart_slot_device::nmi_line_timer_tick), this);
		m_halt_line.timer[i]    = timer_alloc(FUNC(cococart_slot_device::halt_line_timer_tick), this);
	}

	m_cart_line.timer_index     = 0;
	m_cart_line.delay           = 0;
	m_cart_line.value           = line_value::CLEAR;
	m_cart_line.line            = 0;
	m_cart_line.q_count         = 0;
	m_cart_line.callback = &m_cart_callback;

	m_nmi_line.timer_index      = 0;
	m_nmi_line.delay            = 0;
	m_nmi_line.value            = line_value::CLEAR;
	m_nmi_line.line             = 0;
	m_nmi_line.q_count          = 0;
	m_nmi_line.callback = &m_nmi_callback;

	m_halt_line.timer_index     = 0;
	m_halt_line.delay           = 0;
	m_halt_line.value           = line_value::CLEAR;
	m_halt_line.line            = 0;
	m_halt_line.q_count         = 0;
	m_halt_line.callback = &m_halt_callback;

	m_cart = get_card_device();

	save_item(STRUCT_MEMBER(m_cart_line, timer_index));
	save_item(STRUCT_MEMBER(m_cart_line, delay));
	save_item(STRUCT_MEMBER(m_cart_line, value));
	save_item(STRUCT_MEMBER(m_cart_line, line));
	save_item(STRUCT_MEMBER(m_cart_line, q_count));

	save_item(STRUCT_MEMBER(m_nmi_line, timer_index));
	save_item(STRUCT_MEMBER(m_nmi_line, delay));
	save_item(STRUCT_MEMBER(m_nmi_line, value));
	save_item(STRUCT_MEMBER(m_nmi_line, line));
	save_item(STRUCT_MEMBER(m_nmi_line, q_count));

	save_item(STRUCT_MEMBER(m_halt_line, timer_index));
	save_item(STRUCT_MEMBER(m_halt_line, delay));
	save_item(STRUCT_MEMBER(m_halt_line, value));
	save_item(STRUCT_MEMBER(m_halt_line, line));
	save_item(STRUCT_MEMBER(m_halt_line, q_count));
}



//-------------------------------------------------
//  cart_line_timer_tick - update the output
//  value for the cart's line to PIA1 CB1
//-------------------------------------------------

TIMER_CALLBACK_MEMBER(cococart_slot_device::cart_line_timer_tick)
{
	set_line(line::CART, m_cart_line, (line_value) param);
}

//-------------------------------------------------
//  nmi_line_timer_tick - update the output
//  value sent to the CPU's NMI line
//-------------------------------------------------

TIMER_CALLBACK_MEMBER(cococart_slot_device::nmi_line_timer_tick)
{
	set_line(line::NMI, m_nmi_line, (line_value) param);
}

//-------------------------------------------------
//  halt_line_timer_tick - update the output
//  value sent to the CPU's HALT line
//-------------------------------------------------

TIMER_CALLBACK_MEMBER(cococart_slot_device::halt_line_timer_tick)
{
	set_line(line::HALT, m_halt_line, (line_value) param);
}



//-------------------------------------------------
//  cts_read
//-------------------------------------------------

u8 cococart_slot_device::cts_read(offs_t offset)
{
	u8 result = 0x00;
	if (m_cart)
		result = m_cart->cts_read(offset);
	return result;
}


//-------------------------------------------------
//  cts_write
//-------------------------------------------------

void cococart_slot_device::cts_write(offs_t offset, u8 data)
{
	if (m_cart)
		m_cart->cts_write(offset, data);
}


//-------------------------------------------------
//  scs_read
//-------------------------------------------------

u8 cococart_slot_device::scs_read(offs_t offset)
{
	u8 result = 0x00;
	if (m_cart)
		result = m_cart->scs_read(offset);
	return result;
}


//-------------------------------------------------
//  scs_write
//-------------------------------------------------

void cococart_slot_device::scs_write(offs_t offset, u8 data)
{
	if (m_cart)
		m_cart->scs_write(offset, data);
}



//-------------------------------------------------
//  line_value_string
//-------------------------------------------------

const char *cococart_slot_device::line_value_string(line_value value)
{
	const char *s;
	switch(value)
	{
		case line_value::CLEAR:
			s = "CLEAR";
			break;
		case line_value::ASSERT:
			s = "ASSERT";
			break;
		case line_value::Q:
			s = "Q";
			break;
		default:
			throw false && "Invalid value";
	}
	return s;
}


//-------------------------------------------------
//  set_line
//-------------------------------------------------

void cococart_slot_device::set_line(line ln, coco_cartridge_line &line, cococart_slot_device::line_value value)
{
	if ((line.value != value) || (value == line_value::Q))
	{
		line.value = value;

		switch (ln)
		{
		case line::CART:
			LOGCART( "set_line: CART, value: %s\n", line_value_string(value));
			break;
		case line::NMI:
			LOGNMI( "set_line: NMI, value: %s\n", line_value_string(value));
			break;
		case line::HALT:
			LOGHALT( "set_line: HALT, value: %s\n", line_value_string(value));
			break;
		case line::SOUND_ENABLE:
			break;
		}

		// engage in a bit of gymnastics for this odious 'Q' value
		switch(line.value)
		{
			case line_value::CLEAR:
				line.line = 0x00;
				line.q_count = 0;
				break;

			case line_value::ASSERT:
				line.line = 0x01;
				line.q_count = 0;
				break;

			case line_value::Q:
				line.line = line.line ? 0x00 : 0x01;
				if (line.q_count++ < 4)
					set_line_timer(line, value);
				break;
		}

		/* invoke the callback */
		(*line.callback)(line.line);
	}
}


//-------------------------------------------------
//  set_line_timer
//-------------------------------------------------

void cococart_slot_device::set_line_timer(coco_cartridge_line &line, cococart_slot_device::line_value value)
{
	// calculate delay; delay dependant on cycles per second
	attotime delay = (line.delay != 0)
			? clocks_to_attotime(line.delay)
			: attotime::zero;

	line.timer[line.timer_index]->adjust(delay, (int) value);
	line.timer_index = (line.timer_index + 1) % TIMER_POOL;
}


//-------------------------------------------------
//  twiddle_line_if_q
//-------------------------------------------------

void cococart_slot_device::twiddle_line_if_q(coco_cartridge_line &line)
{
	if (line.value == line_value::Q)
	{
		line.q_count = 0;
		set_line_timer(line, line_value::Q);
	}
}


//-------------------------------------------------
//  twiddle_q_lines - hack to support twiddling the
//  Q line
//-------------------------------------------------

void cococart_slot_device::twiddle_q_lines()
{
	twiddle_line_if_q(m_cart_line);
	twiddle_line_if_q(m_nmi_line);
	twiddle_line_if_q(m_halt_line);
}


//-------------------------------------------------
//  set_line_value
//-------------------------------------------------

void cococart_slot_device::set_line_value(cococart_slot_device::line which, cococart_slot_device::line_value value)
{
	switch (which)
	{
	case cococart_slot_device::line::CART:
		set_line_timer(m_cart_line, value);
		break;

	case cococart_slot_device::line::NMI:
		set_line_timer(m_nmi_line, value);
		break;

	case cococart_slot_device::line::HALT:
		set_line_timer(m_halt_line, value);
		break;

	case cococart_slot_device::line::SOUND_ENABLE:
		if (m_cart)
			m_cart->set_sound_enable(value != cococart_slot_device::line_value::CLEAR);
		break;
	}
}


//-------------------------------------------------
//  set_line_delay
//-------------------------------------------------

void cococart_slot_device::set_line_delay(cococart_slot_device::line which, int cycles)
{
	switch (which)
	{
	case cococart_slot_device::line::CART:
		m_cart_line.delay = cycles;
		break;

	case cococart_slot_device::line::NMI:
		m_nmi_line.delay = cycles;
		break;

	case cococart_slot_device::line::HALT:
		m_halt_line.delay = cycles;
		break;

	default:
		throw false;
	}
}


//-------------------------------------------------
//  get_line_value
//-------------------------------------------------

cococart_slot_device::line_value cococart_slot_device::get_line_value(cococart_slot_device::line which) const
{
	line_value result;
	switch (which)
	{
	case cococart_slot_device::line::CART:
		result = m_cart_line.value;
		break;

	case cococart_slot_device::line::NMI:
		result = m_nmi_line.value;
		break;

	case cococart_slot_device::line::HALT:
		result = m_halt_line.value;
		break;

	default:
		result = line_value::CLEAR;
		break;
	}
	return result;
}


//-------------------------------------------------
//  get_cart_base
//-------------------------------------------------

u8 *cococart_slot_device::get_cart_base()
{
	if (m_cart != nullptr)
		return m_cart->get_cart_base();
	return nullptr;
}


//-------------------------------------------------
//  get_cart_size
//-------------------------------------------------

u32 cococart_slot_device::get_cart_size()
{
	if (m_cart != nullptr)
		return m_cart->get_cart_size();

	return 0x8000;
}

//-------------------------------------------------
//  set_cart_base_update
//-------------------------------------------------

void cococart_slot_device::set_cart_base_update(cococart_base_update_delegate update)
{
	if (m_cart)
		m_cart->set_cart_base_update(update);
}


//-------------------------------------------------
//  read_coco_rpk
//-------------------------------------------------

static std::error_condition read_coco_rpk(std::unique_ptr<util::random_read> &&stream, rpk_file::ptr &result)
{
	// sanity checks
	static_assert(std::size(coco_rpk_pcbdefs) - 1 == std::size(coco_rpk_cardslottypes));

	// set up the RPK reader
	rpk_reader reader(coco_rpk_pcbdefs, false);

	// and read the RPK file
	return reader.read(std::move(stream), result);
}


//-------------------------------------------------
//  read_coco_rpk
//-------------------------------------------------

static std::error_condition read_coco_rpk(std::unique_ptr<util::random_read> &&stream, u8 *mem, offs_t cart_length, offs_t &actual_length)
{
	actual_length = 0;

	// open the RPK
	rpk_file::ptr file;
	std::error_condition err = read_coco_rpk(std::move(stream), file);
	if (err)
		return err;

	// for now, we are just going to load all sockets into the contiguous block of memory
	// that cartridges use
	offs_t pos = 0;
	for (const rpk_socket &socket : file->sockets())
	{
		// only ROM supported for now; if we see anything else it should have been caught in the RPK code
		assert(socket.type() == rpk_socket::socket_type::ROM);

		// read all bytes
		std::vector<uint8_t> contents;
		err = socket.read_file(contents);
		if (err)
			return err;

		// copy the bytes
		offs_t size = (offs_t) std::min(contents.size(), (size_t)cart_length - pos);
		memcpy(&mem[pos], &contents[0], size);
		pos += size;
	}

	// we're done!
	actual_length = pos;
	return std::error_condition();
}


//-------------------------------------------------
//  call_load
//-------------------------------------------------

std::pair<std::error_condition, std::string> cococart_slot_device::call_load()
{
	if (m_cart)
	{
		memory_region *cart_mem = m_cart->get_cart_memregion();
		u8 *base = cart_mem->base();
		offs_t read_length, cart_length = cart_mem->bytes();

		if (loaded_through_softlist())
		{
			// loaded through softlist
			read_length = get_software_region_length("rom");
			memcpy(base, get_software_region("rom"), read_length);
		}
		else if (is_filetype("rpk"))
		{
			// RPK file
			util::core_file::ptr proxy;
			std::error_condition err = util::core_file::open_proxy(image_core_file(), proxy);
			if (!err)
				err = read_coco_rpk(std::move(proxy), base, cart_length, read_length);
			if (err)
				return std::make_pair(err, std::string());
		}
		else
		{
			// conventional ROM image
			read_length = fread(base, cart_length);
		}

		while (read_length < cart_length)
		{
			offs_t len = std::min(read_length, cart_length - read_length);
			memcpy(base + read_length, base, len);
			read_length += len;
		}
	}
	return std::make_pair(std::error_condition(), std::string());
}


//-------------------------------------------------
//  get_default_card_software
//-------------------------------------------------

std::string cococart_slot_device::get_default_card_software(get_default_card_software_hook &hook) const
{
	// this is the default for anything not in an RPK file
	int pcb_type = 0;

	// is this an RPK?
	if (hook.is_filetype("rpk"))
	{
		// RPK file
		rpk_file::ptr file;
		util::core_file::ptr proxy;
		std::error_condition err = util::core_file::open_proxy(*hook.image_file(), proxy);
		if (!err)
			err = read_coco_rpk(std::move(proxy), file);
		if (!err)
			pcb_type = file->pcb_type();
	}

	// lookup the default slot
	return software_get_default_slot(coco_rpk_cardslottypes[pcb_type]);
}


//**************************************************************************
//  DEVICE COCO CART INTERFACE - Implemented by devices that plug into
//  CoCo cartridge slots
//**************************************************************************

template class device_finder<device_cococart_interface, false>;
template class device_finder<device_cococart_interface, true>;

//-------------------------------------------------
//  device_cococart_interface - constructor
//-------------------------------------------------

device_cococart_interface::device_cococart_interface(const machine_config &mconfig, device_t &device)
	: device_interface(device, "cococart")
	, m_owning_slot(dynamic_cast<cococart_slot_device *>(device.owner()))
	, m_host(nullptr)
{
}


//-------------------------------------------------
//  ~device_cococart_interface - destructor
//-------------------------------------------------

device_cococart_interface::~device_cococart_interface()
{
}


//-------------------------------------------------
//  interface_config_complete
//-------------------------------------------------

void device_cococart_interface::interface_config_complete()
{
	m_host = m_owning_slot
			? dynamic_cast<device_cococart_host_interface *>(m_owning_slot->owner())
			: nullptr;
}


//-------------------------------------------------
//  interface_pre_start
//-------------------------------------------------

void device_cococart_interface::interface_pre_start()
{
	if (!m_owning_slot)
		throw emu_fatalerror("Expected device().owner() to be of type cococart_slot_device");
	if (!m_host)
		throw emu_fatalerror("Expected m_owning_slot->owner() to be of type device_cococart_host_interface");
}


//-------------------------------------------------
//  cts_read - Signifies a read where the CTS pin
//  on the cartridge slot was asserted ($C000-FFEF)
//-------------------------------------------------

u8 device_cococart_interface::cts_read(offs_t offset)
{
	return 0x00;
}


//-------------------------------------------------
//  cts_write - Signifies a write where the CTS pin
//  on the cartridge slot was asserted ($C000-FFEF)
//-------------------------------------------------

void device_cococart_interface::cts_write(offs_t offset, u8 data)
{
}


//-------------------------------------------------
//  scs_read - Signifies a read where the SCS pin
//  on the cartridge slot was asserted ($FF40-5F)
//-------------------------------------------------

u8 device_cococart_interface::scs_read(offs_t offset)
{
	return 0x00;
}


//-------------------------------------------------
//  scs_write - Signifies a write where the SCS pin
//  on the cartridge slot was asserted ($FF40-5F)
//-------------------------------------------------

void device_cococart_interface::scs_write(offs_t offset, u8 data)
{
}


//-------------------------------------------------
//  set_sound_enable
//-------------------------------------------------

void device_cococart_interface::set_sound_enable(bool sound_enable)
{
}


//-------------------------------------------------
//  get_cart_base
//-------------------------------------------------

u8 *device_cococart_interface::get_cart_base()
{
	return nullptr;
}


//-------------------------------------------------
//  get_cart_size
//-------------------------------------------------

u32 device_cococart_interface::get_cart_size()
{
	return 0x8000;
}


//-------------------------------------------------
//  set_cart_base_update
//-------------------------------------------------

void device_cococart_interface::set_cart_base_update(cococart_base_update_delegate update)
{
	m_update = update;
}


//-------------------------------------------------
//  cart_base_changed
//-------------------------------------------------

void device_cococart_interface::cart_base_changed(void)
{
	if (!m_update.isnull())
		m_update(get_cart_base());
	else
	{
		// propagate up to host interface
		device_cococart_interface *host = dynamic_cast<device_cococart_interface*>(m_host);
		host->cart_base_changed();
	}
}

/*-------------------------------------------------
    get_cart_memregion
-------------------------------------------------*/

memory_region *device_cococart_interface::get_cart_memregion()
{
	return 0;
}

//-------------------------------------------------
//  cartridge_space
//-------------------------------------------------

address_space &device_cococart_interface::cartridge_space()
{
	return host().cartridge_space();
}


//-------------------------------------------------
//  set_line_value
//-------------------------------------------------

void device_cococart_interface::set_line_value(cococart_slot_device::line line, cococart_slot_device::line_value value)
{
	owning_slot().set_line_value(line, value);
}


//-------------------------------------------------
//  coco_cart_add_basic_devices
//-------------------------------------------------

void coco_cart_add_basic_devices(device_slot_interface &device)
{
	// basic devices, on both the main slot and the Multi-Pak interface
	device.option_add_internal("banked_16k", COCO_PAK_BANKED);
	device.option_add_internal("pak", COCO_PAK);
	device.option_add("ccpsg", COCO_PSG);
	device.option_add("dcmodem", COCO_DCMODEM);
	device.option_add("gmc", COCO_PAK_GMC);
	device.option_add("ide", COCO_IDE);
	device.option_add("max", COCO_PAK_MAX);
	device.option_add("midi", COCO_MIDI);
	device.option_add("orch90", COCO_ORCH90);
	device.option_add("ram", COCO_PAK_RAM);
	device.option_add("rs232", COCO_RS232);
	device.option_add("ssc", COCO_SSC);
	device.option_add("ssfm", DRAGON_MSX2);
	device.option_add("stecomp", COCO_STEREO_COMPOSER);
	device.option_add("sym12", COCO_SYM12);
	device.option_add("wpk", COCO_WPK);
	device.option_add("wpk2", COCO_WPK2);
	device.option_add("wpkrs", COCO_WPKRS);
	device.option_add("wpk2p", COCO_WPK2P);
}


//-------------------------------------------------
//  coco_cart_add_fdcs
//-------------------------------------------------

void coco_cart_add_fdcs(device_slot_interface &device)
{
	// FDCs are optional because if they are on a Multi-Pak interface, they must
	// be on Slot 4
	device.option_add("cd6809_fdc", CD6809_FDC);
	device.option_add("cp450_fdc", CP450_FDC);
	device.option_add("fdc", COCO_FDC);
	device.option_add("scii", COCO_SCII);
}


//-------------------------------------------------
//  coco_cart_add_multi_pak
//-------------------------------------------------

void coco_cart_add_multi_pak(device_slot_interface &device)
{
	// and the Multi-Pak itself is optional because they cannot be daisy chained
	device.option_add("multi", COCO_MULTIPAK);
}


//-------------------------------------------------
//  dragon_cart_add_basic_devices
//-------------------------------------------------

void dragon_cart_add_basic_devices(device_slot_interface &device)
{
	device.option_add_internal("amtor", DRAGON_AMTOR);
	device.option_add("ccpsg", COCO_PSG);
	device.option_add("claw", DRAGON_CLAW);
	device.option_add("gmc", COCO_PAK_GMC);
	device.option_add("jcbsnd", DRAGON_JCBSND);
	device.option_add("jcbspch", DRAGON_JCBSPCH);
	device.option_add("max", COCO_PAK_MAX);
	device.option_add("midi", DRAGON_MIDI);
	device.option_add("orch90", COCO_ORCH90);
	device.option_add("pak", COCO_PAK);
	device.option_add("serial", DRAGON_SERIAL);
	device.option_add("ram", COCO_PAK_RAM);
	device.option_add("sprites", DRAGON_SPRITES);
	device.option_add("ssc", COCO_SSC);
	device.option_add("ssfm", DRAGON_MSX2);
	device.option_add("stecomp", COCO_STEREO_COMPOSER);
	device.option_add("sym12", COCO_SYM12);
	device.option_add("wpk2p", COCO_WPK2P);
}


//-------------------------------------------------
//  dragon_cart_add_fdcs
//-------------------------------------------------

void dragon_cart_add_fdcs(device_slot_interface &device)
{
	device.option_add("dragon_fdc", DRAGON_FDC);
	device.option_add("premier_fdc", PREMIER_FDC);
	device.option_add("sdtandy_fdc", SDTANDY_FDC);
}


//-------------------------------------------------
//  dragon_cart_add_multi_pak
//-------------------------------------------------

void dragon_cart_add_multi_pak(device_slot_interface &device)
{
	device.option_add("multi", DRAGON_MULTIPAK);
}