src/mess/machine/vic1112.c
| r11184 | r11185 | |
| 1 | | /********************************************************************** |
| 1 | #include "vic1112.h" |
| 2 | 2 | |
| 3 | | Commodore VIC-1112 IEEE-488 cartridge emulation |
| 4 | 3 | |
| 5 | | Copyright MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | 4 | |
| 8 | | **********************************************************************/ |
| 5 | //************************************************************************** |
| 6 | // MACROS / CONSTANTS |
| 7 | //************************************************************************** |
| 9 | 8 | |
| 10 | | #include "emu.h" |
| 11 | | #include "vic1112.h" |
| 12 | | #include "cpu/m6502/m6502.h" |
| 13 | | #include "machine/6522via.h" |
| 14 | | #include "machine/ieee488.h" |
| 15 | | |
| 16 | | /*************************************************************************** |
| 17 | | PARAMETERS |
| 18 | | ***************************************************************************/ |
| 19 | | |
| 20 | 9 | #define M6522_0_TAG "u4" |
| 21 | 10 | #define M6522_1_TAG "u5" |
| 22 | 11 | |
| 23 | | /*************************************************************************** |
| 24 | | TYPE DEFINITIONS |
| 25 | | ***************************************************************************/ |
| 26 | 12 | |
| 27 | | typedef struct _vic1112_t vic1112_t; |
| 28 | | struct _vic1112_t |
| 29 | | { |
| 30 | | int via0_irq; /* VIA #0 interrupt request */ |
| 31 | | int via1_irq; /* VIA #1 interrupt request */ |
| 32 | 13 | |
| 33 | | /* devices */ |
| 34 | | via6522_device *via0; |
| 35 | | via6522_device *via1; |
| 36 | | via6522_device *bus; |
| 37 | | }; |
| 14 | //************************************************************************** |
| 15 | // DEVICE DEFINITIONS |
| 16 | //************************************************************************** |
| 38 | 17 | |
| 39 | | /*************************************************************************** |
| 40 | | INLINE FUNCTIONS |
| 41 | | ***************************************************************************/ |
| 18 | const device_type VIC1112 = vic1112_device_config::static_alloc_device_config; |
| 42 | 19 | |
| 43 | | INLINE vic1112_t *get_safe_token(device_t *device) |
| 44 | | { |
| 45 | | assert(device != NULL); |
| 46 | | assert(device->type() == VIC1112); |
| 47 | | return (vic1112_t *)downcast<legacy_device_base *>(device)->token(); |
| 48 | | } |
| 49 | 20 | |
| 50 | | INLINE vic1112_config *get_safe_config(device_t *device) |
| 51 | | { |
| 52 | | assert(device != NULL); |
| 53 | | assert(device->type() == VIC1112); |
| 54 | | return (vic1112_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config(); |
| 55 | | } |
| 56 | 21 | |
| 57 | | /*************************************************************************** |
| 58 | | IMPLEMENTATION |
| 59 | | ***************************************************************************/ |
| 22 | //************************************************************************** |
| 23 | // DEVICE CONFIGURATION |
| 24 | //************************************************************************** |
| 60 | 25 | |
| 61 | | /*------------------------------------------------- |
| 62 | | vic1112_ieee488_srq_w - IEEE-488 service |
| 63 | | request |
| 64 | | -------------------------------------------------*/ |
| 26 | GENERIC_DEVICE_CONFIG_SETUP(vic1112, "VIC-1112") |
| 65 | 27 | |
| 66 | | WRITE_LINE_DEVICE_HANDLER( vic1112_ieee488_srq_w ) |
| 28 | |
| 29 | //------------------------------------------------- |
| 30 | // device_config_complete - perform any |
| 31 | // operations now that the configuration is |
| 32 | // complete |
| 33 | //------------------------------------------------- |
| 34 | |
| 35 | void vic1112_device_config::device_config_complete() |
| 67 | 36 | { |
| 68 | | vic1112_t *vic1112 = get_safe_token(device); |
| 37 | // inherit a copy of the static data |
| 38 | const vic1112_interface *intf = reinterpret_cast<const vic1112_interface *>(static_config()); |
| 39 | if (intf != NULL) |
| 40 | *static_cast<vic1112_interface *>(this) = *intf; |
| 69 | 41 | |
| 70 | | vic1112->bus->write_cb1(state); |
| 42 | // or initialize to defaults if none provided |
| 43 | else |
| 44 | { |
| 45 | fatalerror("Interface not provided!"); |
| 46 | } |
| 47 | |
| 48 | m_bus_tag = intf->m_bus_tag; |
| 49 | |
| 50 | m_shortname = "vic1112"; |
| 71 | 51 | } |
| 72 | 52 | |
| 73 | | /*------------------------------------------------- |
| 74 | | via6522_interface vic1112_via0_intf |
| 75 | | -------------------------------------------------*/ |
| 76 | 53 | |
| 77 | | static WRITE_LINE_DEVICE_HANDLER( via0_irq_w ) |
| 54 | //------------------------------------------------- |
| 55 | // ROM( vic1112 ) |
| 56 | //------------------------------------------------- |
| 57 | |
| 58 | ROM_START( vic1112 ) |
| 59 | ROM_REGION( 0x800, VIC1112_TAG, 0 ) |
| 60 | ROM_LOAD( "325329-03.u2", 0x000, 0x800, CRC(d37b6335) SHA1(828c965829d21c60e8c2d083caee045c639a270f) ) |
| 61 | ROM_END |
| 62 | |
| 63 | |
| 64 | //------------------------------------------------- |
| 65 | // rom_region - device-specific ROM region |
| 66 | //------------------------------------------------- |
| 67 | |
| 68 | const rom_entry *vic1112_device_config::device_rom_region() const |
| 78 | 69 | { |
| 79 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 70 | return ROM_NAME( vic1112 ); |
| 71 | } |
| 80 | 72 | |
| 81 | | vic1112->via0_irq = state; |
| 82 | 73 | |
| 83 | | device_set_input_line(device->machine().firstcpu, M6502_IRQ_LINE, (vic1112->via0_irq | vic1112->via1_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 74 | //------------------------------------------------- |
| 75 | // via6522_interface via0_intf |
| 76 | //------------------------------------------------- |
| 77 | |
| 78 | WRITE_LINE_MEMBER( vic1112_device::via0_irq_w ) |
| 79 | { |
| 80 | m_via0_irq = state; |
| 81 | |
| 82 | device_set_input_line(m_machine.firstcpu, M6502_IRQ_LINE, (m_via0_irq | m_via1_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | | static READ8_DEVICE_HANDLER( via0_pb_r ) |
| 85 | |
| 86 | READ8_MEMBER( vic1112_device::via0_pb_r ) |
| 87 | 87 | { |
| 88 | 88 | /* |
| 89 | 89 | |
| r11184 | r11185 | |
| 100 | 100 | |
| 101 | 101 | */ |
| 102 | 102 | |
| 103 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 104 | 103 | UINT8 data = 0; |
| 105 | 104 | |
| 106 | 105 | /* end or identify */ |
| 107 | | data |= ieee488_eoi_r(vic1112->bus) << 3; |
| 106 | data |= ieee488_eoi_r(m_bus) << 3; |
| 108 | 107 | |
| 109 | 108 | /* data valid in */ |
| 110 | | data |= ieee488_dav_r(vic1112->bus) << 4; |
| 109 | data |= ieee488_dav_r(m_bus) << 4; |
| 111 | 110 | |
| 112 | 111 | /* not ready for data in */ |
| 113 | | data |= ieee488_nrfd_r(vic1112->bus) << 5; |
| 112 | data |= ieee488_nrfd_r(m_bus) << 5; |
| 114 | 113 | |
| 115 | 114 | /* not data accepted in */ |
| 116 | | data |= ieee488_ndac_r(vic1112->bus) << 6; |
| 115 | data |= ieee488_ndac_r(m_bus) << 6; |
| 117 | 116 | |
| 118 | 117 | /* attention in */ |
| 119 | | data |= ieee488_atn_r(vic1112->bus) << 7; |
| 118 | data |= ieee488_atn_r(m_bus) << 7; |
| 120 | 119 | |
| 121 | 120 | return data; |
| 122 | 121 | } |
| 123 | 122 | |
| 124 | | static WRITE8_DEVICE_HANDLER( via0_pb_w ) |
| 123 | |
| 124 | WRITE8_MEMBER( vic1112_device::via0_pb_w ) |
| 125 | 125 | { |
| 126 | 126 | /* |
| 127 | 127 | |
| r11184 | r11185 | |
| 138 | 138 | |
| 139 | 139 | */ |
| 140 | 140 | |
| 141 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 142 | | |
| 143 | 141 | /* data valid out */ |
| 144 | | ieee488_dav_w(vic1112->bus, device->owner(), BIT(data, 0)); |
| 142 | ieee488_dav_w(m_bus, this, BIT(data, 0)); |
| 145 | 143 | |
| 146 | 144 | /* not ready for data out */ |
| 147 | | ieee488_nrfd_w(vic1112->bus, device->owner(), BIT(data, 1)); |
| 145 | ieee488_nrfd_w(m_bus, this, BIT(data, 1)); |
| 148 | 146 | |
| 149 | 147 | /* not data accepted out */ |
| 150 | | ieee488_ndac_w(vic1112->bus, device->owner(), BIT(data, 2)); |
| 148 | ieee488_ndac_w(m_bus, this, BIT(data, 2)); |
| 151 | 149 | } |
| 152 | 150 | |
| 153 | | static const via6522_interface vic1112_via0_intf = |
| 151 | |
| 152 | static const via6522_interface via0_intf = |
| 154 | 153 | { |
| 155 | 154 | DEVCB_NULL, |
| 156 | | DEVCB_HANDLER(via0_pb_r), |
| 155 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, via0_pb_r), |
| 157 | 156 | DEVCB_NULL, |
| 158 | 157 | DEVCB_NULL, |
| 159 | 158 | DEVCB_NULL, |
| 160 | 159 | DEVCB_NULL, |
| 161 | 160 | |
| 162 | 161 | DEVCB_NULL, |
| 163 | | DEVCB_HANDLER(via0_pb_w), |
| 162 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, via0_pb_w), |
| 164 | 163 | DEVCB_NULL, |
| 165 | 164 | DEVCB_NULL, |
| 166 | 165 | DEVCB_NULL, |
| 167 | 166 | DEVCB_NULL, |
| 168 | 167 | |
| 169 | | DEVCB_LINE(via0_irq_w) |
| 168 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, via0_irq_w) |
| 170 | 169 | }; |
| 171 | 170 | |
| 172 | | /*------------------------------------------------- |
| 173 | | via6522_interface vic1112_via1_intf |
| 174 | | -------------------------------------------------*/ |
| 175 | 171 | |
| 176 | | static WRITE_LINE_DEVICE_HANDLER( via1_irq_w ) |
| 172 | //------------------------------------------------- |
| 173 | // via6522_interface via1_intf |
| 174 | //------------------------------------------------- |
| 175 | |
| 176 | WRITE_LINE_MEMBER( vic1112_device::via1_irq_w ) |
| 177 | 177 | { |
| 178 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 178 | m_via1_irq = state; |
| 179 | 179 | |
| 180 | | vic1112->via1_irq = state; |
| 181 | | |
| 182 | | device_set_input_line(device->machine().firstcpu, M6502_IRQ_LINE, (vic1112->via0_irq | vic1112->via1_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 180 | device_set_input_line(m_machine.firstcpu, M6502_IRQ_LINE, (m_via0_irq | m_via1_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 183 | 181 | } |
| 184 | 182 | |
| 185 | | static READ8_DEVICE_HANDLER( dio_r ) |
| 183 | READ8_MEMBER( vic1112_device::dio_r ) |
| 186 | 184 | { |
| 187 | 185 | /* |
| 188 | 186 | |
| r11184 | r11185 | |
| 199 | 197 | |
| 200 | 198 | */ |
| 201 | 199 | |
| 202 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 203 | | |
| 204 | | return ieee488_dio_r(vic1112->bus, 0); |
| 200 | return ieee488_dio_r(m_bus, 0); |
| 205 | 201 | } |
| 206 | 202 | |
| 207 | | static WRITE8_DEVICE_HANDLER( dio_w ) |
| 203 | |
| 204 | WRITE8_MEMBER( vic1112_device::dio_w ) |
| 208 | 205 | { |
| 209 | 206 | /* |
| 210 | 207 | |
| r11184 | r11185 | |
| 221 | 218 | |
| 222 | 219 | */ |
| 223 | 220 | |
| 224 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 225 | | |
| 226 | | ieee488_dio_w(vic1112->bus, device->owner(), data); |
| 221 | ieee488_dio_w(m_bus, this, data); |
| 227 | 222 | } |
| 228 | 223 | |
| 229 | | static WRITE_LINE_DEVICE_HANDLER( atn_w ) |
| 230 | | { |
| 231 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 232 | 224 | |
| 225 | WRITE_LINE_MEMBER( vic1112_device::atn_w ) |
| 226 | { |
| 233 | 227 | /* attention out */ |
| 234 | | ieee488_atn_w(vic1112->bus, device->owner(), state); |
| 228 | ieee488_atn_w(m_bus, this, state); |
| 235 | 229 | } |
| 236 | 230 | |
| 237 | | static READ_LINE_DEVICE_HANDLER( srq_r ) |
| 238 | | { |
| 239 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 240 | 231 | |
| 232 | READ_LINE_MEMBER( vic1112_device::srq_r ) |
| 233 | { |
| 241 | 234 | /* service request in */ |
| 242 | | return ieee488_srq_r(vic1112->bus); |
| 235 | return ieee488_srq_r(m_bus); |
| 243 | 236 | } |
| 244 | 237 | |
| 245 | | static WRITE_LINE_DEVICE_HANDLER( eoi_w ) |
| 246 | | { |
| 247 | | vic1112_t *vic1112 = get_safe_token(device->owner()); |
| 248 | 238 | |
| 239 | WRITE_LINE_MEMBER( vic1112_device::eoi_w ) |
| 240 | { |
| 249 | 241 | /* end or identify out */ |
| 250 | | ieee488_eoi_w(vic1112->bus, device->owner(), state); |
| 242 | ieee488_eoi_w(m_bus, this, state); |
| 251 | 243 | } |
| 252 | 244 | |
| 253 | | static const via6522_interface vic1112_via1_intf = |
| 245 | |
| 246 | static const via6522_interface via1_intf = |
| 254 | 247 | { |
| 255 | 248 | DEVCB_NULL, |
| 256 | | DEVCB_HANDLER(dio_r), |
| 249 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, dio_r), |
| 257 | 250 | DEVCB_NULL, |
| 258 | | DEVCB_LINE(srq_r), |
| 251 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, srq_r), |
| 259 | 252 | DEVCB_NULL, |
| 260 | 253 | DEVCB_NULL, |
| 261 | 254 | |
| 262 | | DEVCB_HANDLER(dio_w), |
| 255 | DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, dio_w), |
| 263 | 256 | DEVCB_NULL, |
| 264 | 257 | DEVCB_NULL, |
| 265 | 258 | DEVCB_NULL, |
| 266 | | DEVCB_LINE(atn_w), |
| 267 | | DEVCB_LINE(eoi_w), |
| 259 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, atn_w), |
| 260 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, eoi_w), |
| 268 | 261 | |
| 269 | | DEVCB_LINE(via1_irq_w) |
| 262 | DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, vic1112_device, via1_irq_w) |
| 270 | 263 | }; |
| 271 | 264 | |
| 272 | | /*------------------------------------------------- |
| 273 | | MACHINE_DRIVER( vic1112 ) |
| 274 | | -------------------------------------------------*/ |
| 275 | 265 | |
| 266 | //------------------------------------------------- |
| 267 | // MACHINE_DRIVER( vic1112 ) |
| 268 | //------------------------------------------------- |
| 269 | |
| 276 | 270 | static MACHINE_CONFIG_FRAGMENT( vic1112 ) |
| 277 | | MCFG_VIA6522_ADD(M6522_0_TAG, 0, vic1112_via0_intf) |
| 278 | | MCFG_VIA6522_ADD(M6522_1_TAG, 0, vic1112_via1_intf) |
| 271 | MCFG_VIA6522_ADD(M6522_0_TAG, 0, via0_intf) |
| 272 | MCFG_VIA6522_ADD(M6522_1_TAG, 0, via1_intf) |
| 279 | 273 | MACHINE_CONFIG_END |
| 280 | 274 | |
| 281 | | /*------------------------------------------------- |
| 282 | | ROM( vic1112 ) |
| 283 | | -------------------------------------------------*/ |
| 284 | 275 | |
| 285 | | ROM_START( vic1112 ) |
| 286 | | ROM_REGION( 0x800, VIC1112_TAG, ROMREGION_LOADBYNAME ) |
| 287 | | ROM_LOAD( "325329-03.u2", 0x000, 0x800, CRC(d37b6335) SHA1(828c965829d21c60e8c2d083caee045c639a270f) ) |
| 288 | | ROM_END |
| 276 | //------------------------------------------------- |
| 277 | // machine_config_additions - device-specific |
| 278 | // machine configurations |
| 279 | //------------------------------------------------- |
| 289 | 280 | |
| 290 | | /*------------------------------------------------- |
| 291 | | DEVICE_START( vic1112 ) |
| 292 | | -------------------------------------------------*/ |
| 293 | | |
| 294 | | static DEVICE_START( vic1112 ) |
| 281 | machine_config_constructor vic1112_device_config::device_mconfig_additions() const |
| 295 | 282 | { |
| 296 | | vic1112_t *vic1112 = get_safe_token(device); |
| 297 | | const vic1112_config *config = get_safe_config(device); |
| 298 | | address_space *program = device->machine().firstcpu->memory().space(AS_PROGRAM); |
| 283 | return MACHINE_CONFIG_NAME( vic1112 ); |
| 284 | } |
| 299 | 285 | |
| 300 | | /* find devices */ |
| 301 | | vic1112->via0 = device->subdevice<via6522_device>(M6522_0_TAG); |
| 302 | | vic1112->via1 = device->subdevice<via6522_device>(M6522_1_TAG); |
| 303 | | vic1112->bus = device->machine().device<via6522_device>(config->bus_tag); |
| 304 | 286 | |
| 305 | | /* set VIA clocks */ |
| 306 | | vic1112->via0->set_unscaled_clock(device->machine().firstcpu->unscaled_clock()); |
| 307 | | vic1112->via1->set_unscaled_clock(device->machine().firstcpu->unscaled_clock()); |
| 308 | 287 | |
| 309 | | /* map VIAs to memory */ |
| 310 | | program->install_readwrite_handler(0x9800, 0x980f, 0, 0, read8_delegate_create(via6522_device, read, *vic1112->via0), write8_delegate_create(via6522_device, write, *vic1112->via0)); |
| 311 | | program->install_readwrite_handler(0x9810, 0x981f, 0, 0, read8_delegate_create(via6522_device, read, *vic1112->via1), write8_delegate_create(via6522_device, write, *vic1112->via1)); |
| 288 | //************************************************************************** |
| 289 | // LIVE DEVICE |
| 290 | //************************************************************************** |
| 312 | 291 | |
| 313 | | /* map ROM to memory */ |
| 314 | | program->install_rom(0xb000, 0xb7ff, device->machine().region("vic1112:vic1112")->base()); |
| 292 | //------------------------------------------------- |
| 293 | // vic1112_device - constructor |
| 294 | //------------------------------------------------- |
| 315 | 295 | |
| 316 | | /* ground REN */ |
| 317 | | ieee488_ren_w(vic1112->bus, device, 0); |
| 318 | | |
| 319 | | /* register for state saving */ |
| 320 | | device->save_item(NAME(vic1112->via0_irq)); |
| 321 | | device->save_item(NAME(vic1112->via1_irq)); |
| 296 | vic1112_device::vic1112_device(running_machine &_machine, const vic1112_device_config &_config) |
| 297 | : device_t(_machine, _config), |
| 298 | m_via0(*this, M6522_0_TAG), |
| 299 | m_via1(*this, M6522_1_TAG), |
| 300 | m_bus(m_machine.device(_config.m_bus_tag)), |
| 301 | m_config(_config) |
| 302 | { |
| 322 | 303 | } |
| 323 | 304 | |
| 324 | | /*------------------------------------------------- |
| 325 | | DEVICE_RESET( vic1112 ) |
| 326 | | -------------------------------------------------*/ |
| 327 | 305 | |
| 328 | | static DEVICE_RESET( vic1112 ) |
| 306 | //------------------------------------------------- |
| 307 | // device_start - device-specific startup |
| 308 | //------------------------------------------------- |
| 309 | |
| 310 | void vic1112_device::device_start() |
| 329 | 311 | { |
| 330 | | vic1112_t *vic1112 = get_safe_token(device); |
| 312 | address_space *program = m_machine.firstcpu->memory().space(AS_PROGRAM); |
| 331 | 313 | |
| 332 | | /* reset VIAs */ |
| 333 | | vic1112->via0->reset(); |
| 334 | | vic1112->via1->reset(); |
| 314 | // map VIAs to VIC-20 address space |
| 315 | program->install_readwrite_handler(0x9800, 0x980f, 0, 0, read8_delegate_create(via6522_device, read, *m_via0), write8_delegate_create(via6522_device, write, *m_via0)); |
| 316 | program->install_readwrite_handler(0x9810, 0x981f, 0, 0, read8_delegate_create(via6522_device, read, *m_via1), write8_delegate_create(via6522_device, write, *m_via1)); |
| 335 | 317 | |
| 336 | | /* _IFC */ |
| 337 | | ieee488_ifc_w(vic1112->bus, device, 0); |
| 338 | | ieee488_ifc_w(vic1112->bus, device, 1); |
| 318 | // map ROM to VIC-20 address space |
| 319 | program->install_rom(0xb000, 0xb7ff, subregion(VIC1112_TAG)->base()); |
| 320 | |
| 321 | // state saving |
| 322 | save_item(NAME(m_via0_irq)); |
| 323 | save_item(NAME(m_via1_irq)); |
| 339 | 324 | } |
| 340 | 325 | |
| 341 | | /*------------------------------------------------- |
| 342 | | DEVICE_GET_INFO( vic1112 ) |
| 343 | | -------------------------------------------------*/ |
| 344 | 326 | |
| 345 | | DEVICE_GET_INFO( vic1112 ) |
| 327 | //------------------------------------------------- |
| 328 | // device_reset - device-specific reset |
| 329 | //------------------------------------------------- |
| 330 | |
| 331 | void vic1112_device::device_reset() |
| 346 | 332 | { |
| 347 | | switch (state) |
| 348 | | { |
| 349 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 350 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(vic1112_t); break; |
| 351 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(vic1112_config); break; |
| 333 | ieee488_ifc_w(m_bus, this, 0); |
| 334 | ieee488_ifc_w(m_bus, this, 1); |
| 335 | } |
| 352 | 336 | |
| 353 | | /* --- the following bits of info are returned as pointers --- */ |
| 354 | | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(vic1112); break; |
| 355 | | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_CONFIG_NAME(vic1112); break; |
| 356 | 337 | |
| 357 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 358 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(vic1112); break; |
| 359 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 360 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(vic1112); break; |
| 338 | //------------------------------------------------- |
| 339 | // srq_w - |
| 340 | //------------------------------------------------- |
| 361 | 341 | |
| 362 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 363 | | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore VIC-1112"); break; |
| 364 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Commodore VIC-20"); break; |
| 365 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 366 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 367 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 368 | | } |
| 342 | WRITE_LINE_MEMBER( vic1112_device::srq_w ) |
| 343 | { |
| 344 | m_via1->write_cb1(state); |
| 369 | 345 | } |
| 370 | | |
| 371 | | DEFINE_LEGACY_DEVICE(VIC1112, vic1112); |
src/mess/machine/vic1112.h
| r11184 | r11185 | |
| 9 | 9 | |
| 10 | 10 | **********************************************************************/ |
| 11 | 11 | |
| 12 | #pragma once |
| 13 | |
| 12 | 14 | #ifndef __VIC1112__ |
| 13 | 15 | #define __VIC1112__ |
| 14 | 16 | |
| 17 | #define ADDRESS_MAP_MODERN |
| 18 | |
| 15 | 19 | #include "emu.h" |
| 20 | #include "cpu/m6502/m6502.h" |
| 21 | #include "machine/6522via.h" |
| 22 | #include "machine/ieee488.h" |
| 23 | #include "machine/devhelpr.h" |
| 16 | 24 | |
| 17 | | /*************************************************************************** |
| 18 | | MACROS / CONSTANTS |
| 19 | | ***************************************************************************/ |
| 20 | 25 | |
| 26 | |
| 27 | //************************************************************************** |
| 28 | // MACROS / CONSTANTS |
| 29 | //************************************************************************** |
| 30 | |
| 21 | 31 | #define VIC1112_TAG "vic1112" |
| 22 | 32 | |
| 23 | | DECLARE_LEGACY_DEVICE(VIC1112, vic1112); |
| 24 | 33 | |
| 25 | | #define MCFG_VIC1112_ADD(_bus_tag) \ |
| 26 | | MCFG_DEVICE_ADD(VIC1112_TAG, VIC1112, 0) \ |
| 27 | | MCFG_DEVICE_CONFIG_DATAPTR(vic1112_config, bus_tag, _bus_tag) \ |
| 28 | 34 | |
| 35 | //************************************************************************** |
| 36 | // INTERFACE CONFIGURATION MACROS |
| 37 | //************************************************************************** |
| 38 | |
| 39 | #define MCFG_VIC1112_ADD(_config) \ |
| 40 | MCFG_DEVICE_ADD(VIC1112_TAG, VIC1112, 0) \ |
| 41 | MCFG_DEVICE_CONFIG(_config) |
| 42 | |
| 43 | |
| 44 | #define VIC1112_INTERFACE(name) \ |
| 45 | const vic1112_interface (name) = |
| 46 | |
| 47 | |
| 29 | 48 | #define VIC1112_IEEE488 \ |
| 30 | | VIC1112_TAG, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_LINE(VIC1112_TAG, vic1112_ieee488_srq_w), DEVCB_NULL, DEVCB_NULL |
| 49 | VIC1112_TAG, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, \ |
| 50 | DEVCB_DEVICE_LINE_MEMBER(VIC1112_TAG, vic1112_device, srq_w), DEVCB_NULL, DEVCB_NULL |
| 31 | 51 | |
| 32 | | /*************************************************************************** |
| 33 | | TYPE DEFINITIONS |
| 34 | | ***************************************************************************/ |
| 35 | 52 | |
| 36 | | typedef struct _vic1112_config vic1112_config; |
| 37 | | struct _vic1112_config |
| 53 | //************************************************************************** |
| 54 | // TYPE DEFINITIONS |
| 55 | //************************************************************************** |
| 56 | |
| 57 | // ======================> vic1112_interface |
| 58 | |
| 59 | struct vic1112_interface |
| 38 | 60 | { |
| 39 | | const char *bus_tag; /* bus device */ |
| 61 | const char *m_bus_tag; |
| 40 | 62 | }; |
| 41 | 63 | |
| 42 | | /*************************************************************************** |
| 43 | | PROTOTYPES |
| 44 | | ***************************************************************************/ |
| 45 | | /* IEEE-488 interface */ |
| 46 | | WRITE_LINE_DEVICE_HANDLER( vic1112_ieee488_srq_w ); |
| 47 | 64 | |
| 65 | // ======================> vic1112_device_config |
| 66 | |
| 67 | class vic1112_device_config : public device_config, |
| 68 | public vic1112_interface |
| 69 | { |
| 70 | friend class vic1112_device; |
| 71 | |
| 72 | // construction/destruction |
| 73 | vic1112_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 74 | |
| 75 | public: |
| 76 | // allocators |
| 77 | static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 78 | virtual device_t *alloc_device(running_machine &machine) const; |
| 79 | |
| 80 | // optional information overrides |
| 81 | virtual const rom_entry *device_rom_region() const; |
| 82 | virtual machine_config_constructor device_mconfig_additions() const; |
| 83 | |
| 84 | protected: |
| 85 | // device_config overrides |
| 86 | virtual void device_config_complete(); |
| 87 | |
| 88 | private: |
| 89 | const char *m_bus_tag; |
| 90 | }; |
| 91 | |
| 92 | |
| 93 | // ======================> vic1112_device |
| 94 | |
| 95 | class vic1112_device : public device_t |
| 96 | { |
| 97 | friend class vic1112_device_config; |
| 98 | |
| 99 | // construction/destruction |
| 100 | vic1112_device(running_machine &_machine, const vic1112_device_config &_config); |
| 101 | |
| 102 | public: |
| 103 | DECLARE_WRITE_LINE_MEMBER( srq_w ); |
| 104 | |
| 105 | // not really public, but won't compile otherwise |
| 106 | DECLARE_WRITE_LINE_MEMBER( via0_irq_w ); |
| 107 | DECLARE_READ8_MEMBER( via0_pb_r ); |
| 108 | DECLARE_WRITE8_MEMBER( via0_pb_w ); |
| 109 | DECLARE_WRITE_LINE_MEMBER( via1_irq_w ); |
| 110 | DECLARE_READ8_MEMBER( dio_r ); |
| 111 | DECLARE_WRITE8_MEMBER( dio_w ); |
| 112 | DECLARE_WRITE_LINE_MEMBER( atn_w ); |
| 113 | DECLARE_READ_LINE_MEMBER( srq_r ); |
| 114 | DECLARE_WRITE_LINE_MEMBER( eoi_w ); |
| 115 | |
| 116 | protected: |
| 117 | // device-level overrides |
| 118 | virtual void device_start(); |
| 119 | virtual void device_reset(); |
| 120 | |
| 121 | private: |
| 122 | required_device<via6522_device> m_via0; |
| 123 | required_device<via6522_device> m_via1; |
| 124 | device_t *m_bus; |
| 125 | |
| 126 | int m_via0_irq; |
| 127 | int m_via1_irq; |
| 128 | |
| 129 | const vic1112_device_config &m_config; |
| 130 | }; |
| 131 | |
| 132 | |
| 133 | // device type definition |
| 134 | extern const device_type VIC1112; |
| 135 | |
| 136 | |
| 137 | |
| 48 | 138 | #endif |