src/mess/drivers/ngp.c
| r4579 | r4580 | |
| 121 | 121 | typedef struct _ngp_state ngp_state; |
| 122 | 122 | struct _ngp_state { |
| 123 | 123 | UINT8 io_reg[0x40]; |
| 124 | UINT8 old_to3; |
| 124 | 125 | emu_timer* seconds_timer; |
| 125 | 126 | |
| 126 | 127 | struct { |
| r4579 | r4580 | |
| 132 | 133 | int state; |
| 133 | 134 | UINT8 command[2]; |
| 134 | 135 | } flash_chip[2]; |
| 136 | |
| 137 | const device_config *tlcs900; |
| 138 | const device_config *z80; |
| 139 | const device_config *t6w28; |
| 140 | const device_config *dac_l; |
| 141 | const device_config *dac_r; |
| 142 | const device_config *k1ge; |
| 135 | 143 | }; |
| 136 | 144 | |
| 137 | 145 | |
| r4579 | r4580 | |
| 200 | 208 | case 0x21: /* t6w28 "left" */ |
| 201 | 209 | if ( state->io_reg[0x38] == 0x55 && state->io_reg[0x39] == 0xAA ) |
| 202 | 210 | { |
| 203 | | t6w28_w( devtag_get_device( space->machine, "t6w28" ), 0, data ); |
| 211 | t6w28_w( state->t6w28, 0, data ); |
| 204 | 212 | } |
| 205 | 213 | break; |
| 206 | 214 | |
| 207 | 215 | case 0x22: /* DAC right */ |
| 208 | | dac_w( devtag_get_device( space->machine, "dac_r" ), 0, data ); |
| 216 | dac_w( state->dac_r, 0, data ); |
| 209 | 217 | break; |
| 210 | 218 | case 0x23: /* DAC left */ |
| 211 | | dac_w( devtag_get_device( space->machine, "dac_l" ), 0, data ); |
| 219 | dac_w( state->dac_l, 0, data ); |
| 212 | 220 | break; |
| 213 | 221 | |
| 214 | 222 | /* Internal eeprom related? */ |
| r4579 | r4580 | |
| 229 | 237 | switch( data ) |
| 230 | 238 | { |
| 231 | 239 | case 0x55: /* Enable Z80 */ |
| 232 | | cputag_resume( space->machine, "soundcpu", SUSPEND_REASON_HALT ); |
| 233 | | cputag_reset( space->machine, "soundcpu" ); |
| 234 | | cputag_set_input_line( space->machine, "soundcpu", 0, CLEAR_LINE ); |
| 240 | cpu_resume( state->z80, SUSPEND_REASON_HALT ); |
| 241 | device_reset( state->z80 ); |
| 242 | cpu_set_input_line( state->z80, 0, CLEAR_LINE ); |
| 235 | 243 | break; |
| 236 | 244 | case 0xAA: /* Disable Z80 */ |
| 237 | | cputag_suspend( space->machine, "soundcpu", SUSPEND_REASON_HALT, 1 ); |
| 245 | cpu_suspend( state->z80, SUSPEND_REASON_HALT, 1 ); |
| 238 | 246 | break; |
| 239 | 247 | } |
| 240 | 248 | break; |
| 241 | 249 | |
| 242 | 250 | case 0x3a: /* Trigger Z80 NMI */ |
| 243 | | cputag_set_input_line( space->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE ); |
| 251 | cpu_set_input_line( state->z80, INPUT_LINE_NMI, PULSE_LINE ); |
| 244 | 252 | break; |
| 245 | 253 | } |
| 246 | 254 | state->io_reg[offset] = data; |
| r4579 | r4580 | |
| 504 | 512 | |
| 505 | 513 | static WRITE8_HANDLER( ngp_z80_signal_main_w ) |
| 506 | 514 | { |
| 507 | | cputag_set_input_line( space->machine, "maincpu", TLCS900_INT5, ASSERT_LINE ); |
| 515 | ngp_state *state = space->machine->driver_data; |
| 516 | |
| 517 | cpu_set_input_line( state->tlcs900, TLCS900_INT5, ASSERT_LINE ); |
| 508 | 518 | } |
| 509 | 519 | |
| 510 | 520 | |
| r4579 | r4580 | |
| 518 | 528 | |
| 519 | 529 | static WRITE8_HANDLER( ngp_z80_clear_irq ) |
| 520 | 530 | { |
| 521 | | cputag_set_input_line( space->machine, "soundcpu", 0, CLEAR_LINE ); |
| 531 | ngp_state *state = space->machine->driver_data; |
| 522 | 532 | |
| 533 | cpu_set_input_line( state->z80, 0, CLEAR_LINE ); |
| 534 | |
| 523 | 535 | /* I am not exactly sure what causes the maincpu INT5 signal to be cleared. This will do for now. */ |
| 524 | | cputag_set_input_line( space->machine, "maincpu", TLCS900_INT5, CLEAR_LINE ); |
| 536 | cpu_set_input_line( state->tlcs900, TLCS900_INT5, CLEAR_LINE ); |
| 525 | 537 | } |
| 526 | 538 | |
| 527 | 539 | |
| r4579 | r4580 | |
| 536 | 548 | |
| 537 | 549 | if ( state->io_reg[0x33] & 0x04 ) |
| 538 | 550 | { |
| 539 | | cputag_set_input_line( field->port->machine, "maincpu", TLCS900_NMI, |
| 551 | cpu_set_input_line( state->tlcs900, TLCS900_NMI, |
| 540 | 552 | (input_port_read(field->port->machine, "Power") & 0x01 ) ? CLEAR_LINE : ASSERT_LINE ); |
| 541 | 553 | } |
| 542 | 554 | } |
| r4579 | r4580 | |
| 560 | 572 | |
| 561 | 573 | static WRITE8_DEVICE_HANDLER( ngp_vblank_pin_w ) |
| 562 | 574 | { |
| 563 | | cputag_set_input_line( device->machine, "maincpu", TLCS900_INT4, data ? ASSERT_LINE : CLEAR_LINE ); |
| 575 | ngp_state *state = device->machine->driver_data; |
| 576 | |
| 577 | cpu_set_input_line( state->tlcs900, TLCS900_INT4, data ? ASSERT_LINE : CLEAR_LINE ); |
| 564 | 578 | } |
| 565 | 579 | |
| 566 | 580 | |
| 567 | 581 | static WRITE8_DEVICE_HANDLER( ngp_hblank_pin_w ) |
| 568 | 582 | { |
| 569 | | cputag_set_input_line( device->machine, "maincpu", TLCS900_TIO, data ? ASSERT_LINE : CLEAR_LINE ); |
| 583 | ngp_state *state = device->machine->driver_data; |
| 584 | |
| 585 | cpu_set_input_line( state->tlcs900, TLCS900_TIO, data ? ASSERT_LINE : CLEAR_LINE ); |
| 570 | 586 | } |
| 571 | 587 | |
| 572 | 588 | |
| 573 | | static UINT8 old_to3; |
| 574 | | |
| 575 | 589 | static WRITE8_DEVICE_HANDLER( ngp_tlcs900_to3 ) |
| 576 | 590 | { |
| 577 | | if ( data && ! old_to3 ) |
| 578 | | cputag_set_input_line( device->machine, "soundcpu", 0, ASSERT_LINE ); |
| 591 | ngp_state * state = device->machine->driver_data; |
| 579 | 592 | |
| 580 | | old_to3 = data; |
| 593 | if ( data && ! state->old_to3 ) |
| 594 | cpu_set_input_line( state->z80, 0, ASSERT_LINE ); |
| 595 | |
| 596 | state->old_to3 = data; |
| 581 | 597 | } |
| 582 | 598 | |
| 583 | 599 | |
| r4579 | r4580 | |
| 592 | 608 | |
| 593 | 609 | static MACHINE_RESET( ngp ) |
| 594 | 610 | { |
| 595 | | cputag_suspend( machine, "soundcpu", SUSPEND_REASON_HALT, 1 ); |
| 596 | | cputag_set_input_line( machine, "soundcpu", 0, CLEAR_LINE ); |
| 611 | ngp_state *state = machine->driver_data; |
| 612 | |
| 613 | state->old_to3 = 0; |
| 614 | state->tlcs900 = devtag_get_device( machine, "maincpu" ); |
| 615 | state->z80 = devtag_get_device( machine, "soundcpu" ); |
| 616 | state->t6w28 = devtag_get_device( machine, "t8w28" ); |
| 617 | state->dac_l = devtag_get_device( machine, "dac_l" ); |
| 618 | state->dac_r = devtag_get_device( machine, "dac_r" ); |
| 619 | state->k1ge = devtag_get_device( machine, "k1ge" ); |
| 620 | |
| 621 | cpu_suspend( state->z80, SUSPEND_REASON_HALT, 1 ); |
| 622 | cpu_set_input_line( state->z80, 0, CLEAR_LINE ); |
| 597 | 623 | } |
| 598 | 624 | |
| 599 | 625 | |
| 600 | 626 | static VIDEO_UPDATE( ngp ) |
| 601 | 627 | { |
| 602 | | k1ge_update( devtag_get_device( screen->machine, "k1ge" ), bitmap, cliprect ); |
| 628 | ngp_state *state = screen->machine->driver_data; |
| 629 | |
| 630 | k1ge_update( state->k1ge, bitmap, cliprect ); |
| 603 | 631 | return 0; |
| 604 | 632 | } |
| 605 | 633 | |