src/mess/machine/coco_multi.c
| r0 | r12082 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | coco_multi.c |
| 4 | |
| 5 | Code for emulating CoCo Multi PAK |
| 6 | |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | #include "emu.h" |
| 10 | #include "coco_multi.h" |
| 11 | #include "coco_232.h" |
| 12 | #include "coco_orch90.h" |
| 13 | #include "coco_pak.h" |
| 14 | #include "coco_fdc.h" |
| 15 | |
| 16 | #define SLOT1_TAG "slot1" |
| 17 | #define SLOT2_TAG "slot2" |
| 18 | #define SLOT3_TAG "slot3" |
| 19 | #define SLOT4_TAG "slot4" |
| 20 | |
| 21 | /*************************************************************************** |
| 22 | IMPLEMENTATION |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | static SLOT_INTERFACE_START(coco_cart_slot1_3) |
| 26 | SLOT_INTERFACE("rs232", COCO_232) |
| 27 | SLOT_INTERFACE("orch90", COCO_ORCH90) |
| 28 | SLOT_INTERFACE("banked_16k", COCO_PAK_BANKED) |
| 29 | SLOT_INTERFACE("pak", COCO_PAK) |
| 30 | SLOT_INTERFACE_END |
| 31 | static SLOT_INTERFACE_START(coco_cart_slot4) |
| 32 | SLOT_INTERFACE("fdcv11", COCO_FDC_V11) |
| 33 | SLOT_INTERFACE("rs232", COCO_232) |
| 34 | SLOT_INTERFACE("orch90", COCO_ORCH90) |
| 35 | SLOT_INTERFACE("banked_16k", COCO_PAK_BANKED) |
| 36 | SLOT_INTERFACE("pak", COCO_PAK) |
| 37 | SLOT_INTERFACE_END |
| 38 | |
| 39 | WRITE_LINE_DEVICE_HANDLER(multi_cart_w) |
| 40 | { |
| 41 | cococart_slot_device *cart = dynamic_cast<cococart_slot_device *>(device->owner()->owner()); |
| 42 | cart->m_cart_callback.writeline(device,state); |
| 43 | } |
| 44 | |
| 45 | WRITE_LINE_DEVICE_HANDLER(multi_nmi_w) |
| 46 | { |
| 47 | cococart_slot_device *cart = dynamic_cast<cococart_slot_device *>(device->owner()->owner()); |
| 48 | cart->m_nmi_callback.writeline(device,state); |
| 49 | } |
| 50 | |
| 51 | WRITE_LINE_DEVICE_HANDLER(multi_halt_w) |
| 52 | { |
| 53 | cococart_slot_device *cart = dynamic_cast<cococart_slot_device *>(device->owner()->owner()); |
| 54 | cart->m_halt_callback.writeline(device,state); |
| 55 | } |
| 56 | |
| 57 | static const cococart_interface multi_cococart_interface = |
| 58 | { |
| 59 | DEVCB_LINE(multi_cart_w), |
| 60 | DEVCB_LINE(multi_nmi_w), |
| 61 | DEVCB_LINE(multi_halt_w) |
| 62 | }; |
| 63 | |
| 64 | static MACHINE_CONFIG_FRAGMENT(coco_multi) |
| 65 | MCFG_COCO_CARTRIDGE_ADD(SLOT1_TAG, multi_cococart_interface, coco_cart_slot1_3, NULL) |
| 66 | MCFG_COCO_CARTRIDGE_ADD(SLOT2_TAG, multi_cococart_interface, coco_cart_slot1_3, NULL) |
| 67 | MCFG_COCO_CARTRIDGE_ADD(SLOT3_TAG, multi_cococart_interface, coco_cart_slot1_3, NULL) |
| 68 | MCFG_COCO_CARTRIDGE_ADD(SLOT4_TAG, multi_cococart_interface, coco_cart_slot4, "fdcv11") |
| 69 | MACHINE_CONFIG_END |
| 70 | |
| 71 | //************************************************************************** |
| 72 | // GLOBAL VARIABLES |
| 73 | //************************************************************************** |
| 74 | |
| 75 | const device_type COCO_MULTIPAK = &device_creator<coco_multipak_device>; |
| 76 | |
| 77 | //************************************************************************** |
| 78 | // LIVE DEVICE |
| 79 | //************************************************************************** |
| 80 | |
| 81 | //------------------------------------------------- |
| 82 | // coco_multipak_device - constructor |
| 83 | //------------------------------------------------- |
| 84 | coco_multipak_device::coco_multipak_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 85 | : device_t(mconfig, COCO_MULTIPAK, "CoCo Multi PAK", tag, owner, clock), |
| 86 | device_cococart_interface( mconfig, *this ), |
| 87 | device_slot_card_interface(mconfig, *this) |
| 88 | { |
| 89 | } |
| 90 | |
| 91 | //------------------------------------------------- |
| 92 | // device_start - device-specific startup |
| 93 | //------------------------------------------------- |
| 94 | |
| 95 | void coco_multipak_device::device_start() |
| 96 | { |
| 97 | m_slot1 = dynamic_cast<cococart_slot_device *>(subdevice(SLOT1_TAG)); |
| 98 | m_slot2 = dynamic_cast<cococart_slot_device *>(subdevice(SLOT2_TAG)); |
| 99 | m_slot3 = dynamic_cast<cococart_slot_device *>(subdevice(SLOT3_TAG)); |
| 100 | m_slot4 = dynamic_cast<cococart_slot_device *>(subdevice(SLOT4_TAG)); |
| 101 | m_owner = dynamic_cast<cococart_slot_device *>(owner()); |
| 102 | |
| 103 | m_active = m_slot4; |
| 104 | } |
| 105 | |
| 106 | //------------------------------------------------- |
| 107 | // machine_config_additions - device-specific |
| 108 | // machine configurations |
| 109 | //------------------------------------------------- |
| 110 | |
| 111 | machine_config_constructor coco_multipak_device::device_mconfig_additions() const |
| 112 | { |
| 113 | return MACHINE_CONFIG_NAME( coco_multi ); |
| 114 | } |
| 115 | |
| 116 | /*------------------------------------------------- |
| 117 | get_cart_base |
| 118 | -------------------------------------------------*/ |
| 119 | |
| 120 | UINT8* coco_multipak_device::get_cart_base() |
| 121 | { |
| 122 | return m_active->get_cart_base(); |
| 123 | } |
| 124 | |
| 125 | /*------------------------------------------------- |
| 126 | read |
| 127 | -------------------------------------------------*/ |
| 128 | |
| 129 | READ8_MEMBER(coco_multipak_device::read) |
| 130 | { |
| 131 | return m_active->read(space,offset); |
| 132 | } |
| 133 | |
| 134 | /*------------------------------------------------- |
| 135 | write |
| 136 | -------------------------------------------------*/ |
| 137 | |
| 138 | WRITE8_MEMBER(coco_multipak_device::write) |
| 139 | { |
| 140 | m_active->write(space,offset,data); |
| 141 | } |
src/mess/machine/coco_multi.h
| r0 | r12082 | |
| 1 | #pragma once |
| 2 | |
| 3 | #ifndef __COCO_MULTI_H__ |
| 4 | #define __COCO_MULTI_H__ |
| 5 | |
| 6 | #include "emu.h" |
| 7 | #include "machine/cococart.h" |
| 8 | |
| 9 | //************************************************************************** |
| 10 | // TYPE DEFINITIONS |
| 11 | //************************************************************************** |
| 12 | |
| 13 | // ======================> coco_multipak_device |
| 14 | |
| 15 | class coco_multipak_device : |
| 16 | public device_t, |
| 17 | public device_cococart_interface, |
| 18 | public device_slot_card_interface |
| 19 | { |
| 20 | public: |
| 21 | // construction/destruction |
| 22 | coco_multipak_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 23 | |
| 24 | // optional information overrides |
| 25 | virtual machine_config_constructor device_mconfig_additions() const; |
| 26 | |
| 27 | virtual UINT8* get_cart_base(); |
| 28 | protected: |
| 29 | // device-level overrides |
| 30 | virtual void device_start(); |
| 31 | virtual DECLARE_READ8_MEMBER(read); |
| 32 | virtual DECLARE_WRITE8_MEMBER(write); |
| 33 | |
| 34 | // internal state |
| 35 | cococart_slot_device *m_owner; |
| 36 | |
| 37 | cococart_slot_device *m_slot1; |
| 38 | cococart_slot_device *m_slot2; |
| 39 | cococart_slot_device *m_slot3; |
| 40 | cococart_slot_device *m_slot4; |
| 41 | |
| 42 | cococart_slot_device *m_active; |
| 43 | }; |
| 44 | |
| 45 | |
| 46 | // device type definition |
| 47 | extern const device_type COCO_MULTIPAK; |
| 48 | |
| 49 | #endif /* __COCO_MULTI_H__ */ |