Previous 15994 Revisions Next

r4580 Tuesday 28th April, 2009 at 17:15:44 UTC by Wilbert Pol
[NGP,NGPC] Moved last variable to the driver state. Moved device references into the driver state.
[src/mess/drivers]ngp.c

src/mess/drivers/ngp.c
r4579r4580
121121typedef struct _ngp_state ngp_state;
122122struct _ngp_state {
123123   UINT8 io_reg[0x40];
124   UINT8 old_to3;
124125   emu_timer* seconds_timer;
125126
126127   struct {
r4579r4580
132133      int      state;
133134      UINT8   command[2];
134135   } 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;
135143};
136144
137145
r4579r4580
200208   case 0x21:      /* t6w28 "left" */
201209      if ( state->io_reg[0x38] == 0x55 && state->io_reg[0x39] == 0xAA )
202210      {
203         t6w28_w( devtag_get_device( space->machine, "t6w28" ), 0, data );
211         t6w28_w( state->t6w28, 0, data );
204212      }
205213      break;
206214
207215   case 0x22:      /* DAC right */
208      dac_w( devtag_get_device( space->machine, "dac_r" ), 0, data );
216      dac_w( state->dac_r, 0, data );
209217      break;
210218   case 0x23:      /* DAC left */
211      dac_w( devtag_get_device( space->machine, "dac_l" ), 0, data );
219      dac_w( state->dac_l, 0, data );
212220      break;
213221
214222   /* Internal eeprom related? */
r4579r4580
229237      switch( data )
230238      {
231239      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 );
235243         break;
236244      case 0xAA:      /* Disable Z80 */
237         cputag_suspend( space->machine, "soundcpu", SUSPEND_REASON_HALT, 1 );
245         cpu_suspend( state->z80, SUSPEND_REASON_HALT, 1 );
238246         break;
239247      }
240248      break;
241249
242250   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 );
244252      break;
245253   }
246254   state->io_reg[offset] = data;
r4579r4580
504512
505513static WRITE8_HANDLER( ngp_z80_signal_main_w )
506514{
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 );
508518}
509519
510520
r4579r4580
518528
519529static WRITE8_HANDLER( ngp_z80_clear_irq )
520530{
521   cputag_set_input_line( space->machine, "soundcpu", 0, CLEAR_LINE );
531   ngp_state *state = space->machine->driver_data;
522532
533   cpu_set_input_line( state->z80, 0, CLEAR_LINE );
534
523535   /* 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 );
525537}
526538
527539
r4579r4580
536548
537549   if ( state->io_reg[0x33] & 0x04 )
538550   {
539      cputag_set_input_line( field->port->machine, "maincpu", TLCS900_NMI,
551      cpu_set_input_line( state->tlcs900, TLCS900_NMI,
540552         (input_port_read(field->port->machine, "Power") & 0x01 ) ? CLEAR_LINE : ASSERT_LINE );
541553   }
542554}
r4579r4580
560572
561573static WRITE8_DEVICE_HANDLER( ngp_vblank_pin_w )
562574{
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 );
564578}
565579
566580
567581static WRITE8_DEVICE_HANDLER( ngp_hblank_pin_w )
568582{
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 );
570586}
571587
572588
573static UINT8 old_to3;
574
575589static WRITE8_DEVICE_HANDLER( ngp_tlcs900_to3 )
576590{
577   if ( data && ! old_to3 )
578      cputag_set_input_line( device->machine, "soundcpu", 0, ASSERT_LINE );
591   ngp_state * state = device->machine->driver_data;
579592
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;
581597}
582598
583599
r4579r4580
592608
593609static MACHINE_RESET( ngp )
594610{
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 );
597623}
598624
599625
600626static VIDEO_UPDATE( ngp )
601627{
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 );
603631   return 0;
604632}
605633

Previous 15994 Revisions Next


© 1998-2018 The MESS Team