src/mess/drivers/e01.c
| r8169 | r8170 | |
| 37 | 37 | |
| 38 | 38 | TODO: |
| 39 | 39 | |
| 40 | | - front flap status |
| 40 | - RTC interrupts (rewrite mc146818) |
| 41 | - ADLC interrupts |
| 42 | - ECONET device |
| 43 | - printer |
| 41 | 44 | - artwork |
| 42 | | - RTC interrupts (rewrite mc146818) |
| 43 | | - ECONET |
| 44 | 45 | - hard disk |
| 45 | 46 | |
| 46 | 47 | */ |
| r8169 | r8170 | |
| 58 | 59 | #include "e01.lh" |
| 59 | 60 | |
| 60 | 61 | /*************************************************************************** |
| 61 | | READ/WRITE HANDLERS |
| 62 | INTERRUPT HANDLING |
| 62 | 63 | ***************************************************************************/ |
| 63 | 64 | |
| 64 | | static READ8_HANDLER( rtc_address_r ) |
| 65 | /*------------------------------------------------- |
| 66 | update_interrupts - update interrupt state |
| 67 | -------------------------------------------------*/ |
| 68 | |
| 69 | static void update_interrupts(running_machine *machine) |
| 65 | 70 | { |
| 66 | | return mc146818_port_r(space, 0); |
| 71 | e01_state *state = (e01_state *)machine->driver_data; |
| 72 | |
| 73 | cputag_set_input_line(machine, R65C102_TAG, INPUT_LINE_IRQ0, (state->via_irq || (state->hdc_ie & state->hdc_irq) || state->rtc_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 74 | cputag_set_input_line(machine, R65C102_TAG, INPUT_LINE_NMI, (state->fdc_drq || (state->adlc_ie & state->adlc_irq)) ? ASSERT_LINE : CLEAR_LINE); |
| 67 | 75 | } |
| 68 | 76 | |
| 69 | | static WRITE8_HANDLER( rtc_address_w ) |
| 77 | /*------------------------------------------------- |
| 78 | network_irq_enable - network interrupt enable |
| 79 | -------------------------------------------------*/ |
| 80 | |
| 81 | static void network_irq_enable(running_machine *machine, int enabled) |
| 70 | 82 | { |
| 71 | | mc146818_port_w(space, 0, data); |
| 83 | e01_state *state = (e01_state *)machine->driver_data; |
| 84 | |
| 85 | state->adlc_ie = enabled; |
| 86 | |
| 87 | update_interrupts(machine); |
| 72 | 88 | } |
| 73 | 89 | |
| 74 | | static READ8_HANDLER( rtc_data_r ) |
| 90 | /*------------------------------------------------- |
| 91 | hdc_irq_enable - hard disk interrupt enable |
| 92 | -------------------------------------------------*/ |
| 93 | |
| 94 | static void hdc_irq_enable(running_machine *machine, int enabled) |
| 75 | 95 | { |
| 76 | | return mc146818_port_r(space, 1); |
| 77 | | } |
| 96 | e01_state *state = (e01_state *)machine->driver_data; |
| 78 | 97 | |
| 79 | | static WRITE8_HANDLER( rtc_data_w ) |
| 80 | | { |
| 81 | | mc146818_port_w(space, 1, data); |
| 98 | state->hdc_ie = enabled; |
| 99 | |
| 100 | update_interrupts(machine); |
| 82 | 101 | } |
| 83 | 102 | |
| 103 | /*************************************************************************** |
| 104 | READ/WRITE HANDLERS |
| 105 | ***************************************************************************/ |
| 106 | |
| 84 | 107 | /*------------------------------------------------- |
| 85 | 108 | eprom_r - ROM/RAM select read |
| 86 | 109 | -------------------------------------------------*/ |
| r8169 | r8170 | |
| 147 | 170 | |
| 148 | 171 | static READ8_HANDLER( network_irq_disable_r ) |
| 149 | 172 | { |
| 150 | | e01_state *state = (e01_state *)space->machine->driver_data; |
| 173 | network_irq_enable(space->machine, 0); |
| 151 | 174 | |
| 152 | | state->network_irq_enabled = false; |
| 153 | | |
| 154 | 175 | return 0; |
| 155 | 176 | } |
| 156 | 177 | |
| 157 | 178 | static WRITE8_HANDLER( network_irq_disable_w ) |
| 158 | 179 | { |
| 159 | | e01_state *state = (e01_state *)space->machine->driver_data; |
| 160 | | |
| 161 | | state->network_irq_enabled = false; |
| 180 | network_irq_enable(space->machine, 0); |
| 162 | 181 | } |
| 163 | 182 | |
| 164 | 183 | static READ8_HANDLER( network_irq_enable_r ) |
| 165 | 184 | { |
| 166 | | e01_state *state = (e01_state *)space->machine->driver_data; |
| 185 | network_irq_enable(space->machine, 1); |
| 167 | 186 | |
| 168 | | state->network_irq_enabled = true; |
| 169 | | |
| 170 | 187 | return 0; |
| 171 | 188 | } |
| 172 | 189 | |
| 173 | 190 | static WRITE8_HANDLER( network_irq_enable_w ) |
| 174 | 191 | { |
| 175 | | e01_state *state = (e01_state *)space->machine->driver_data; |
| 192 | network_irq_enable(space->machine, 1); |
| 193 | } |
| 176 | 194 | |
| 177 | | state->network_irq_enabled = true; |
| 195 | static WRITE8_HANDLER( hdc_irq_enable_w ) |
| 196 | { |
| 197 | hdc_irq_enable(space->machine, BIT(data, 0)); |
| 198 | } |
| 178 | 199 | |
| 200 | static READ8_HANDLER( rtc_address_r ) |
| 201 | { |
| 202 | return mc146818_port_r(space, 0); |
| 203 | } |
| 204 | |
| 205 | static WRITE8_HANDLER( rtc_address_w ) |
| 206 | { |
| 207 | mc146818_port_w(space, 0, data); |
| 208 | } |
| 209 | |
| 210 | static READ8_HANDLER( rtc_data_r ) |
| 211 | { |
| 212 | return mc146818_port_r(space, 1); |
| 213 | } |
| 214 | |
| 215 | static WRITE8_HANDLER( rtc_data_w ) |
| 216 | { |
| 179 | 217 | mc146818_port_w(space, 1, data); |
| 180 | 218 | } |
| 181 | 219 | |
| r8169 | r8170 | |
| 197 | 235 | AM_RANGE(0xfc20, 0xfc23) AM_MIRROR(0x00c0) AM_DEVREADWRITE(MC6854_TAG, mc6854_r, mc6854_w) |
| 198 | 236 | AM_RANGE(0xfc24, 0xfc24) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_disable_r, network_irq_disable_w) |
| 199 | 237 | AM_RANGE(0xfc28, 0xfc28) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_enable_r, network_irq_enable_w) |
| 200 | | // AM_RANGE(0xfc2c, 0xfc2c) AM_MIRROR(0x00c3) front flap status, SW3 |
| 238 | AM_RANGE(0xfc2c, 0xfc2c) AM_MIRROR(0x00c3) AM_READ_PORT("FLAP") |
| 201 | 239 | // AM_RANGE(0xfc30, 0xfc30) AM_MIRROR(0x00c0) HD data |
| 202 | 240 | // AM_RANGE(0xfc31, 0xfc31) AM_MIRROR(0x00c0) HD status |
| 203 | 241 | // AM_RANGE(0xfc32, 0xfc32) AM_MIRROR(0x00c0) HD select |
| 204 | | // AM_RANGE(0xfc33, 0xfc33) AM_MIRROR(0x00c0) HD interrupt enable |
| 242 | AM_RANGE(0xfc33, 0xfc33) AM_MIRROR(0x00c0) AM_WRITE(hdc_irq_enable_w) |
| 205 | 243 | AM_RANGE(0xfd00, 0xffff) AM_READ_BANK("bank3") AM_WRITE_BANK("bank4") |
| 206 | 244 | ADDRESS_MAP_END |
| 207 | 245 | |
| r8169 | r8170 | |
| 214 | 252 | -------------------------------------------------*/ |
| 215 | 253 | |
| 216 | 254 | static INPUT_PORTS_START( e01 ) |
| 255 | PORT_START("FLAP") |
| 256 | PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 257 | PORT_CONFNAME( 0x40, 0x00, "Front Flap") |
| 258 | PORT_CONFSETTING( 0x00, "Closed" ) |
| 259 | PORT_CONFSETTING( 0x40, "Open" ) |
| 260 | PORT_DIPNAME( 0x80, 0x00, "SW3") |
| 261 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 262 | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) |
| 217 | 263 | INPUT_PORTS_END |
| 218 | 264 | |
| 219 | 265 | /*************************************************************************** |
| 220 | 266 | DEVICE CONFIGURATION |
| 221 | 267 | ***************************************************************************/ |
| 222 | 268 | |
| 269 | /*------------------------------------------------- |
| 270 | mc6854_interface adlc_intf |
| 271 | -------------------------------------------------*/ |
| 272 | /* |
| 273 | static WRITE_LINE_DEVICE_HANDLER( adlc_irq_w ) |
| 274 | { |
| 275 | e01_state *driver_state = (e01_state *)device->machine->driver_data; |
| 276 | |
| 277 | driver_state->adlc_irq = state; |
| 278 | |
| 279 | update_interrupts(device->machine); |
| 280 | } |
| 281 | */ |
| 223 | 282 | static const mc6854_interface adlc_intf = |
| 224 | 283 | { |
| 225 | 284 | NULL, |
| r8169 | r8170 | |
| 232 | 291 | via6522_interface via_intf |
| 233 | 292 | -------------------------------------------------*/ |
| 234 | 293 | |
| 294 | static WRITE_LINE_DEVICE_HANDLER( via_irq_w ) |
| 295 | { |
| 296 | e01_state *driver_state = (e01_state *)device->machine->driver_data; |
| 297 | |
| 298 | driver_state->via_irq = state; |
| 299 | |
| 300 | update_interrupts(device->machine); |
| 301 | } |
| 302 | |
| 235 | 303 | static const via6522_interface via_intf = |
| 236 | 304 | { |
| 237 | 305 | DEVCB_NULL, |
| r8169 | r8170 | |
| 246 | 314 | DEVCB_NULL, |
| 247 | 315 | DEVCB_NULL, |
| 248 | 316 | DEVCB_NULL, |
| 249 | | DEVCB_NULL |
| 317 | DEVCB_LINE(via_irq_w) |
| 250 | 318 | }; |
| 251 | 319 | |
| 252 | 320 | /*------------------------------------------------- |
| r8169 | r8170 | |
| 269 | 337 | wd17xx_interface fdc_intf |
| 270 | 338 | -------------------------------------------------*/ |
| 271 | 339 | |
| 340 | static WRITE_LINE_DEVICE_HANDLER( fdc_drq_w ) |
| 341 | { |
| 342 | e01_state *driver_state = (e01_state *)device->machine->driver_data; |
| 343 | |
| 344 | driver_state->fdc_drq = state; |
| 345 | |
| 346 | update_interrupts(device->machine); |
| 347 | } |
| 348 | |
| 272 | 349 | static const wd17xx_interface fdc_intf = |
| 273 | 350 | { |
| 274 | 351 | DEVCB_NULL, |
| 275 | 352 | DEVCB_NULL, |
| 276 | | DEVCB_NULL, |
| 353 | DEVCB_LINE( fdc_drq_w ), |
| 277 | 354 | { FLOPPY_0, FLOPPY_1, NULL, NULL } |
| 278 | 355 | }; |
| 279 | 356 | |
| r8169 | r8170 | |
| 311 | 388 | mc146818_init(machine, MC146818_STANDARD); |
| 312 | 389 | |
| 313 | 390 | /* register for state saving */ |
| 314 | | state_save_register_global(machine, state->network_irq_enabled); |
| 391 | state_save_register_global(machine, state->adlc_ie); |
| 392 | state_save_register_global(machine, state->hdc_ie); |
| 393 | state_save_register_global(machine, state->rtc_irq); |
| 394 | state_save_register_global(machine, state->via_irq); |
| 395 | state_save_register_global(machine, state->hdc_irq); |
| 396 | state_save_register_global(machine, state->fdc_drq); |
| 397 | state_save_register_global(machine, state->adlc_irq); |
| 315 | 398 | } |
| 316 | 399 | |
| 317 | 400 | /*------------------------------------------------- |
| r8169 | r8170 | |
| 324 | 407 | memory_set_bank(machine, "bank3", 1); |
| 325 | 408 | } |
| 326 | 409 | |
| 410 | static int irq; |
| 411 | static TIMER_DEVICE_CALLBACK( rtc_irq_hack ) |
| 412 | { |
| 413 | cputag_set_input_line(timer->machine, R65C102_TAG, INPUT_LINE_IRQ0, irq ? CLEAR_LINE : ASSERT_LINE); |
| 414 | irq = !irq; |
| 415 | } |
| 416 | |
| 327 | 417 | /*************************************************************************** |
| 328 | 418 | MACHINE DRIVERS |
| 329 | 419 | ***************************************************************************/ |
| r8169 | r8170 | |
| 344 | 434 | |
| 345 | 435 | MDRV_NVRAM_HANDLER(mc146818) |
| 346 | 436 | |
| 437 | MDRV_TIMER_ADD_PERIODIC("rtc", rtc_irq_hack, HZ(2)) // HACK! |
| 438 | |
| 347 | 439 | /* video hardware */ |
| 348 | 440 | MDRV_DEFAULT_LAYOUT( layout_e01 ) |
| 349 | 441 | |