src/mess/machine/vic1010.c
| r0 | r14231 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Commodore VIC-1010 Expansion Module emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "vic1010.h" |
| 11 | |
| 12 | |
| 13 | |
| 14 | //************************************************************************** |
| 15 | // DEVICE DEFINITIONS |
| 16 | //************************************************************************** |
| 17 | |
| 18 | const device_type VIC1010 = &device_creator<vic1010_device>; |
| 19 | |
| 20 | |
| 21 | //------------------------------------------------- |
| 22 | // VIC20_EXPANSION_INTERFACE( expansion_intf ) |
| 23 | //------------------------------------------------- |
| 24 | |
| 25 | WRITE_LINE_MEMBER( vic1010_device::irq_w ) |
| 26 | { |
| 27 | m_slot->irq_w(state); |
| 28 | } |
| 29 | |
| 30 | WRITE_LINE_MEMBER( vic1010_device::nmi_w ) |
| 31 | { |
| 32 | m_slot->nmi_w(state); |
| 33 | } |
| 34 | |
| 35 | WRITE_LINE_MEMBER( vic1010_device::res_w ) |
| 36 | { |
| 37 | m_slot->res_w(state); |
| 38 | } |
| 39 | |
| 40 | static VIC20_EXPANSION_INTERFACE( expansion_intf ) |
| 41 | { |
| 42 | DEVCB_LINE_MEMBER(vic1010_device, irq_w), |
| 43 | DEVCB_LINE_MEMBER(vic1010_device, nmi_w), |
| 44 | DEVCB_LINE_MEMBER(vic1010_device, res_w) |
| 45 | }; |
| 46 | |
| 47 | |
| 48 | //------------------------------------------------- |
| 49 | // MACHINE_DRIVER( vic1010 ) |
| 50 | //------------------------------------------------- |
| 51 | |
| 52 | static MACHINE_CONFIG_FRAGMENT( vic1010 ) |
| 53 | MCFG_VIC20_EXPANSION_SLOT_ADD("slot1", expansion_intf, vic20_expansion_cards, NULL, NULL) |
| 54 | MCFG_VIC20_EXPANSION_SLOT_ADD("slot2", expansion_intf, vic20_expansion_cards, NULL, NULL) |
| 55 | MCFG_VIC20_EXPANSION_SLOT_ADD("slot3", expansion_intf, vic20_expansion_cards, NULL, NULL) |
| 56 | MCFG_VIC20_EXPANSION_SLOT_ADD("slot4", expansion_intf, vic20_expansion_cards, NULL, NULL) |
| 57 | MCFG_VIC20_EXPANSION_SLOT_ADD("slot5", expansion_intf, vic20_expansion_cards, NULL, NULL) |
| 58 | MCFG_VIC20_EXPANSION_SLOT_ADD("slot6", expansion_intf, vic20_expansion_cards, NULL, NULL) |
| 59 | MACHINE_CONFIG_END |
| 60 | |
| 61 | |
| 62 | //------------------------------------------------- |
| 63 | // machine_config_additions - device-specific |
| 64 | // machine configurations |
| 65 | //------------------------------------------------- |
| 66 | |
| 67 | machine_config_constructor vic1010_device::device_mconfig_additions() const |
| 68 | { |
| 69 | return MACHINE_CONFIG_NAME( vic1010 ); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | |
| 74 | //************************************************************************** |
| 75 | // LIVE DEVICE |
| 76 | //************************************************************************** |
| 77 | |
| 78 | //------------------------------------------------- |
| 79 | // vic1010_device - constructor |
| 80 | //------------------------------------------------- |
| 81 | |
| 82 | vic1010_device::vic1010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 83 | : device_t(mconfig, VIC1010, "VIC1010", tag, owner, clock), |
| 84 | device_vic20_expansion_card_interface(mconfig, *this) |
| 85 | { |
| 86 | } |
| 87 | |
| 88 | |
| 89 | //------------------------------------------------- |
| 90 | // device_start - device-specific startup |
| 91 | //------------------------------------------------- |
| 92 | |
| 93 | void vic1010_device::device_start() |
| 94 | { |
| 95 | // find devices |
| 96 | m_expansion_slot[0] = dynamic_cast<vic20_expansion_slot_device *>(subdevice("slot1")); |
| 97 | m_expansion_slot[1] = dynamic_cast<vic20_expansion_slot_device *>(subdevice("slot2")); |
| 98 | m_expansion_slot[2] = dynamic_cast<vic20_expansion_slot_device *>(subdevice("slot3")); |
| 99 | m_expansion_slot[3] = dynamic_cast<vic20_expansion_slot_device *>(subdevice("slot4")); |
| 100 | m_expansion_slot[4] = dynamic_cast<vic20_expansion_slot_device *>(subdevice("slot5")); |
| 101 | m_expansion_slot[5] = dynamic_cast<vic20_expansion_slot_device *>(subdevice("slot6")); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | //------------------------------------------------- |
| 106 | // vic20_ram1_r - RAM 1 read |
| 107 | //------------------------------------------------- |
| 108 | |
| 109 | UINT8 vic1010_device::vic20_ram1_r(address_space &space, offs_t offset) |
| 110 | { |
| 111 | UINT8 data = 0; |
| 112 | |
| 113 | for (int i = 0; i < MAX_SLOTS; i++) |
| 114 | { |
| 115 | data |= m_expansion_slot[i]->ram1_r(space, offset); |
| 116 | } |
| 117 | |
| 118 | return data; |
| 119 | } |
| 120 | |
| 121 | |
| 122 | //------------------------------------------------- |
| 123 | // vic20_ram1_w - RAM 1 write |
| 124 | //------------------------------------------------- |
| 125 | |
| 126 | void vic1010_device::vic20_ram1_w(address_space &space, offs_t offset, UINT8 data) |
| 127 | { |
| 128 | for (int i = 0; i < MAX_SLOTS; i++) |
| 129 | { |
| 130 | m_expansion_slot[i]->ram1_w(space, offset, data); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | |
| 135 | //------------------------------------------------- |
| 136 | // vic20_ram2_r - RAM 2 read |
| 137 | //------------------------------------------------- |
| 138 | |
| 139 | UINT8 vic1010_device::vic20_ram2_r(address_space &space, offs_t offset) |
| 140 | { |
| 141 | UINT8 data = 0; |
| 142 | |
| 143 | for (int i = 0; i < MAX_SLOTS; i++) |
| 144 | { |
| 145 | data |= m_expansion_slot[i]->ram2_r(space, offset); |
| 146 | } |
| 147 | |
| 148 | return data; |
| 149 | } |
| 150 | |
| 151 | |
| 152 | //------------------------------------------------- |
| 153 | // vic20_ram2_w - RAM 2 write |
| 154 | //------------------------------------------------- |
| 155 | |
| 156 | void vic1010_device::vic20_ram2_w(address_space &space, offs_t offset, UINT8 data) |
| 157 | { |
| 158 | for (int i = 0; i < MAX_SLOTS; i++) |
| 159 | { |
| 160 | m_expansion_slot[i]->ram2_w(space, offset, data); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | |
| 165 | //------------------------------------------------- |
| 166 | // vic20_ram3_r - RAM 3 read |
| 167 | //------------------------------------------------- |
| 168 | |
| 169 | UINT8 vic1010_device::vic20_ram3_r(address_space &space, offs_t offset) |
| 170 | { |
| 171 | UINT8 data = 0; |
| 172 | |
| 173 | for (int i = 0; i < MAX_SLOTS; i++) |
| 174 | { |
| 175 | data |= m_expansion_slot[i]->ram3_r(space, offset); |
| 176 | } |
| 177 | |
| 178 | return data; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | //------------------------------------------------- |
| 183 | // vic20_ram3_w - RAM 3 write |
| 184 | //------------------------------------------------- |
| 185 | |
| 186 | void vic1010_device::vic20_ram3_w(address_space &space, offs_t offset, UINT8 data) |
| 187 | { |
| 188 | for (int i = 0; i < MAX_SLOTS; i++) |
| 189 | { |
| 190 | m_expansion_slot[i]->ram3_w(space, offset, data); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | |
| 195 | //------------------------------------------------- |
| 196 | // vic20_blk1_r - block 1 read |
| 197 | //------------------------------------------------- |
| 198 | |
| 199 | UINT8 vic1010_device::vic20_blk1_r(address_space &space, offs_t offset) |
| 200 | { |
| 201 | UINT8 data = 0; |
| 202 | |
| 203 | for (int i = 0; i < MAX_SLOTS; i++) |
| 204 | { |
| 205 | data |= m_expansion_slot[i]->blk1_r(space, offset); |
| 206 | } |
| 207 | |
| 208 | return data; |
| 209 | } |
| 210 | |
| 211 | |
| 212 | //------------------------------------------------- |
| 213 | // vic20_blk1_w - block 1 write |
| 214 | //------------------------------------------------- |
| 215 | |
| 216 | void vic1010_device::vic20_blk1_w(address_space &space, offs_t offset, UINT8 data) |
| 217 | { |
| 218 | for (int i = 0; i < MAX_SLOTS; i++) |
| 219 | { |
| 220 | m_expansion_slot[i]->blk1_w(space, offset, data); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | |
| 225 | //------------------------------------------------- |
| 226 | // vic20_blk2_r - block 2 read |
| 227 | //------------------------------------------------- |
| 228 | |
| 229 | UINT8 vic1010_device::vic20_blk2_r(address_space &space, offs_t offset) |
| 230 | { |
| 231 | UINT8 data = 0; |
| 232 | |
| 233 | for (int i = 0; i < MAX_SLOTS; i++) |
| 234 | { |
| 235 | data |= m_expansion_slot[i]->blk2_r(space, offset); |
| 236 | } |
| 237 | |
| 238 | return data; |
| 239 | } |
| 240 | |
| 241 | |
| 242 | //------------------------------------------------- |
| 243 | // vic20_blk2_w - block 2 write |
| 244 | //------------------------------------------------- |
| 245 | |
| 246 | void vic1010_device::vic20_blk2_w(address_space &space, offs_t offset, UINT8 data) |
| 247 | { |
| 248 | for (int i = 0; i < MAX_SLOTS; i++) |
| 249 | { |
| 250 | m_expansion_slot[i]->blk2_w(space, offset, data); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | |
| 255 | //------------------------------------------------- |
| 256 | // vic20_blk3_r - block 3 read |
| 257 | //------------------------------------------------- |
| 258 | |
| 259 | UINT8 vic1010_device::vic20_blk3_r(address_space &space, offs_t offset) |
| 260 | { |
| 261 | UINT8 data = 0; |
| 262 | |
| 263 | for (int i = 0; i < MAX_SLOTS; i++) |
| 264 | { |
| 265 | data |= m_expansion_slot[i]->blk3_r(space, offset); |
| 266 | } |
| 267 | |
| 268 | return data; |
| 269 | } |
| 270 | |
| 271 | |
| 272 | //------------------------------------------------- |
| 273 | // vic20_blk3_w - block 3 write |
| 274 | //------------------------------------------------- |
| 275 | |
| 276 | void vic1010_device::vic20_blk3_w(address_space &space, offs_t offset, UINT8 data) |
| 277 | { |
| 278 | for (int i = 0; i < MAX_SLOTS; i++) |
| 279 | { |
| 280 | m_expansion_slot[i]->blk3_w(space, offset, data); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | |
| 285 | //------------------------------------------------- |
| 286 | // vic20_blk5_r - block 5 read |
| 287 | //------------------------------------------------- |
| 288 | |
| 289 | UINT8 vic1010_device::vic20_blk5_r(address_space &space, offs_t offset) |
| 290 | { |
| 291 | UINT8 data = 0; |
| 292 | |
| 293 | for (int i = 0; i < MAX_SLOTS; i++) |
| 294 | { |
| 295 | data |= m_expansion_slot[i]->blk5_r(space, offset); |
| 296 | } |
| 297 | |
| 298 | return data; |
| 299 | } |
| 300 | |
| 301 | |
| 302 | //------------------------------------------------- |
| 303 | // vic20_blk5_w - block 5 write |
| 304 | //------------------------------------------------- |
| 305 | |
| 306 | void vic1010_device::vic20_blk5_w(address_space &space, offs_t offset, UINT8 data) |
| 307 | { |
| 308 | for (int i = 0; i < MAX_SLOTS; i++) |
| 309 | { |
| 310 | m_expansion_slot[i]->blk5_w(space, offset, data); |
| 311 | } |
| 312 | } |
src/mess/machine/vic1010.h
| r0 | r14231 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Commodore VIC-1010 Expansion Module emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #pragma once |
| 11 | |
| 12 | #ifndef __VIC1010__ |
| 13 | #define __VIC1010__ |
| 14 | |
| 15 | #define ADDRESS_MAP_MODERN |
| 16 | |
| 17 | #include "emu.h" |
| 18 | #include "machine/cbmipt.h" |
| 19 | #include "machine/vic20exp.h" |
| 20 | |
| 21 | |
| 22 | |
| 23 | //************************************************************************** |
| 24 | // MACROS/CONSTANTS |
| 25 | //************************************************************************** |
| 26 | |
| 27 | #define MAX_SLOTS 6 |
| 28 | |
| 29 | |
| 30 | |
| 31 | //************************************************************************** |
| 32 | // TYPE DEFINITIONS |
| 33 | //************************************************************************** |
| 34 | |
| 35 | // ======================> vic1010_device |
| 36 | |
| 37 | class vic1010_device : public device_t, |
| 38 | public device_vic20_expansion_card_interface |
| 39 | { |
| 40 | public: |
| 41 | // construction/destruction |
| 42 | vic1010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 43 | |
| 44 | // not really public |
| 45 | DECLARE_WRITE_LINE_MEMBER( irq_w ); |
| 46 | DECLARE_WRITE_LINE_MEMBER( nmi_w ); |
| 47 | DECLARE_WRITE_LINE_MEMBER( res_w ); |
| 48 | |
| 49 | protected: |
| 50 | // device-level overrides |
| 51 | virtual void device_start(); |
| 52 | |
| 53 | // optional information overrides |
| 54 | virtual machine_config_constructor device_mconfig_additions() const; |
| 55 | |
| 56 | // device_vic20_expansion_card_interface overrides |
| 57 | virtual UINT8 vic20_ram1_r(address_space &space, offs_t offset); |
| 58 | virtual void vic20_ram1_w(address_space &space, offs_t offset, UINT8 data); |
| 59 | virtual UINT8 vic20_ram2_r(address_space &space, offs_t offset); |
| 60 | virtual void vic20_ram2_w(address_space &space, offs_t offset, UINT8 data); |
| 61 | virtual UINT8 vic20_ram3_r(address_space &space, offs_t offset); |
| 62 | virtual void vic20_ram3_w(address_space &space, offs_t offset, UINT8 data); |
| 63 | virtual UINT8 vic20_blk1_r(address_space &space, offs_t offset); |
| 64 | virtual void vic20_blk1_w(address_space &space, offs_t offset, UINT8 data); |
| 65 | virtual UINT8 vic20_blk2_r(address_space &space, offs_t offset); |
| 66 | virtual void vic20_blk2_w(address_space &space, offs_t offset, UINT8 data); |
| 67 | virtual UINT8 vic20_blk3_r(address_space &space, offs_t offset); |
| 68 | virtual void vic20_blk3_w(address_space &space, offs_t offset, UINT8 data); |
| 69 | virtual UINT8 vic20_blk5_r(address_space &space, offs_t offset); |
| 70 | virtual void vic20_blk5_w(address_space &space, offs_t offset, UINT8 data); |
| 71 | |
| 72 | private: |
| 73 | vic20_expansion_slot_device *m_expansion_slot[MAX_SLOTS]; |
| 74 | }; |
| 75 | |
| 76 | |
| 77 | // device type definition |
| 78 | extern const device_type VIC1010; |
| 79 | |
| 80 | |
| 81 | |
| 82 | #endif |