diff --git a/src/mame/drivers/megadriv.c b/src/mame/drivers/megadriv.c index 31d68990770..bf025c00671 100644 --- a/src/mame/drivers/megadriv.c +++ b/src/mame/drivers/megadriv.c @@ -1431,7 +1431,6 @@ static void init_megadri6_io(running_machine *machine) for (i=0; i<3; i++) { io_timeout[i] = timer_alloc(machine, io_timeout_timer_callback, (void*)(FPTR)i); - io_stage[i] = -1; } } @@ -1650,6 +1649,17 @@ static void megadrive_init_io(running_machine *machine) { const input_port_token *ipt = machine->gamedrv->ipt; + if (ipt == INPUT_PORTS_NAME(megadri6)) + init_megadri6_io(machine); + + if (ipt == INPUT_PORTS_NAME(ssf2ghw)) + init_megadri6_io(machine); +} + +static void megadrive_reset_io(running_machine *machine) +{ + int i; + megadrive_io_data_regs[0] = 0x7f; megadrive_io_data_regs[1] = 0x7f; megadrive_io_data_regs[2] = 0x7f; @@ -1660,11 +1670,10 @@ static void megadrive_init_io(running_machine *machine) megadrive_io_tx_regs[1] = 0xff; megadrive_io_tx_regs[2] = 0xff; - if (ipt == INPUT_PORTS_NAME(megadri6)) - init_megadri6_io(machine); - - if (ipt == INPUT_PORTS_NAME(ssf2ghw)) - init_megadri6_io(machine); + for (i=0; i<3; i++) + { + io_stage[i] = -1; + } } /************* 6 buttons version **************************/ @@ -5803,6 +5812,11 @@ static int hazemdchoice_megadrive_region_export; static int hazemdchoice_megadrive_region_pal; static int hazemdchoice_megadriv_framerate; +MACHINE_START( megadriv ) +{ + megadrive_init_io(machine); +} + MACHINE_RESET( megadriv ) { /* default state of z80 = reset, with bus */ @@ -5853,7 +5867,7 @@ MACHINE_RESET( megadriv ) megadrive_imode = 0; - megadrive_init_io(machine); + megadrive_reset_io(machine); frame_timer = devtag_get_device(machine, "frame_timer"); scanline_timer = devtag_get_device(machine, "scanline_timer"); @@ -6064,6 +6078,7 @@ MACHINE_DRIVER_START( megadriv ) MDRV_CPU_IO_MAP(megadriv_z80_io_map) /* IRQ handled via the timers */ + MDRV_MACHINE_START(megadriv) MDRV_MACHINE_RESET(megadriv) MDRV_TIMER_ADD("frame_timer", frame_timer_callback) @@ -6114,6 +6129,7 @@ MACHINE_DRIVER_START( megadpal ) MDRV_CPU_IO_MAP(megadriv_z80_io_map) /* IRQ handled via the timers */ + MDRV_MACHINE_START(megadriv) MDRV_MACHINE_RESET(megadriv) MDRV_TIMER_ADD("frame_timer", frame_timer_callback) diff --git a/src/mame/drivers/megadriv.h b/src/mame/drivers/megadriv.h index 24f26ed90f2..9e1b76dd53f 100644 --- a/src/mame/drivers/megadriv.h +++ b/src/mame/drivers/megadriv.h @@ -53,6 +53,7 @@ extern void (*megadrive_io_write_data_port_ptr)(running_machine *machine, int of extern UINT8 megadrive_io_data_regs[3]; extern UINT8 megadrive_io_ctrl_regs[3]; +MACHINE_START( megadriv ); MACHINE_RESET( megadriv ); VIDEO_START( megadriv ); VIDEO_UPDATE( megadriv ); diff --git a/src/mame/drivers/seta.c b/src/mame/drivers/seta.c index 556e6905ba6..c7ed1ee874d 100644 --- a/src/mame/drivers/seta.c +++ b/src/mame/drivers/seta.c @@ -7455,7 +7455,7 @@ static INTERRUPT_GEN( wrofaero_interrupt ) cpu_set_input_line(device, 2, HOLD_LINE ); } -static MACHINE_RESET( wrofaero ) { uPD71054_timer_init(machine); } +static MACHINE_START( wrofaero ) { uPD71054_timer_init(machine); } #endif // __uPD71054_TIMER @@ -7479,7 +7479,7 @@ static MACHINE_DRIVER_START( gundhara ) #endif // __uPD71054_TIMER #if __uPD71054_TIMER - MDRV_MACHINE_RESET( wrofaero ) + MDRV_MACHINE_START( wrofaero ) #endif // __uPD71054_TIMER /* video hardware */ @@ -7590,7 +7590,7 @@ static MACHINE_DRIVER_START( kamenrid ) MDRV_CPU_VBLANK_INT("screen", wrofaero_interrupt) #if __uPD71054_TIMER - MDRV_MACHINE_RESET( wrofaero ) + MDRV_MACHINE_START( wrofaero ) #endif // __uPD71054_TIMER /* video hardware */ @@ -7738,7 +7738,7 @@ static MACHINE_DRIVER_START( madshark ) MDRV_CPU_VBLANK_INT("screen", wrofaero_interrupt) #if __uPD71054_TIMER - MDRV_MACHINE_RESET( wrofaero ) + MDRV_MACHINE_START( wrofaero ) #endif // __uPD71054_TIMER /* video hardware */ @@ -7784,7 +7784,7 @@ static MACHINE_DRIVER_START( msgundam ) #endif // __uPD71054_TIMER #if __uPD71054_TIMER - MDRV_MACHINE_RESET( wrofaero ) + MDRV_MACHINE_START( wrofaero ) #endif // __uPD71054_TIMER /* video hardware */ @@ -8154,7 +8154,7 @@ static MACHINE_DRIVER_START( wrofaero ) #endif // __uPD71054_TIMER #if __uPD71054_TIMER - MDRV_MACHINE_RESET( wrofaero ) + MDRV_MACHINE_START( wrofaero ) #endif // __uPD71054_TIMER /* video hardware */ diff --git a/src/mame/drivers/sms.c b/src/mame/drivers/sms.c index 0b106594fec..4ed6e3652e6 100644 --- a/src/mame/drivers/sms.c +++ b/src/mame/drivers/sms.c @@ -516,18 +516,20 @@ ADDRESS_MAP_END static MACHINE_START( sms ) { memory_configure_bank(machine, "bank1", 0, 16, memory_region(machine, "questions"), 0x4000); + + state_save_register_global(machine, communication_port_status); + state_save_register_global_array(machine, communication_port); } static MACHINE_START( sureshot ) { + state_save_register_global(machine, communication_port_status); + state_save_register_global_array(machine, communication_port); } static MACHINE_RESET( sms ) { communication_port_status = 0; - - state_save_register_global(machine, communication_port_status); - state_save_register_global_array(machine, communication_port); } static MACHINE_DRIVER_START( sms ) diff --git a/src/mame/drivers/sprint8.c b/src/mame/drivers/sprint8.c index d3b5cfcef0a..c77a06672cf 100644 --- a/src/mame/drivers/sprint8.c +++ b/src/mame/drivers/sprint8.c @@ -26,7 +26,7 @@ void sprint8_set_collision(running_machine *machine, int n) } -static TIMER_CALLBACK( input_callback ) +static TIMER_DEVICE_CALLBACK( input_callback ) { static UINT8 dial[8]; static const char *const dialnames[] = { "DIAL1", "DIAL2", "DIAL3", "DIAL4", "DIAL5", "DIAL6", "DIAL7", "DIAL8" }; @@ -35,7 +35,7 @@ static TIMER_CALLBACK( input_callback ) for (i = 0; i < 8; i++) { - UINT8 val = input_port_read(machine, dialnames[i]) >> 4; + UINT8 val = input_port_read(timer->machine, dialnames[i]) >> 4; signed char delta = (val - dial[i]) & 15; @@ -59,8 +59,6 @@ static MACHINE_RESET( sprint8 ) { collision_reset = 0; collision_index = 0; - - timer_pulse(machine, video_screen_get_frame_period(machine->primary_screen), NULL, 0, input_callback); } @@ -462,6 +460,8 @@ static MACHINE_DRIVER_START( sprint8 ) MDRV_MACHINE_RESET(sprint8) + MDRV_TIMER_ADD_PERIODIC("input_timer", input_callback, HZ(60)) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) diff --git a/src/mame/drivers/stv.c b/src/mame/drivers/stv.c index b2753fee818..e596a8ff7a4 100644 --- a/src/mame/drivers/stv.c +++ b/src/mame/drivers/stv.c @@ -2574,7 +2574,7 @@ SCU register[40] is for IRQ masking. /* to do, update bios idle skips so they work better with this arrangement.. */ -static emu_timer *vblank_out_timer,*scan_timer,*t1_timer; +static const device_config *vblank_out_timer,*scan_timer,*t1_timer; static int h_sync,v_sync; static int cur_scan; @@ -2582,7 +2582,7 @@ static int cur_scan; timer_0 = 0; \ { \ /*if(LOG_IRQ) logerror ("Interrupt: VBlank-OUT Vector 0x41 Level 0x0e\n");*/ \ - cputag_set_input_line_and_vector(machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ + cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ } \ #define VBLANK_IN_IRQ \ @@ -2595,14 +2595,14 @@ timer_0 = 0; \ timer_1 = stv_scu[37] & 0x1ff; \ { \ /*if(LOG_IRQ) logerror ("Interrupt: HBlank-In at scanline %04x, Vector 0x42 Level 0x0d\n",scanline);*/ \ - cputag_set_input_line_and_vector(machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ + cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ } \ #define TIMER_0_IRQ \ if(timer_0 == (stv_scu[36] & 0x3ff)) \ { \ /*if(LOG_IRQ) logerror ("Interrupt: Timer 0 at scanline %04x, Vector 0x43 Level 0x0c\n",scanline);*/ \ - cputag_set_input_line_and_vector(machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ + cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ } \ #define TIMER_1_IRQ \ @@ -2611,14 +2611,14 @@ if((stv_scu[38] & 1)) \ if(!(stv_scu[38] & 0x80)) \ { \ /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ - cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ + cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ } \ else \ { \ if((timer_0) == (stv_scu[36] & 0x3ff)) \ { \ /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ - cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ + cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ } \ } \ } \ @@ -2628,12 +2628,12 @@ if((stv_scu[38] & 1)) \ cputag_set_input_line_and_vector(machine, "maincpu", 2, (stv_irq.vdp1_end) ? HOLD_LINE : CLEAR_LINE, 0x4d); \ } \ -static TIMER_CALLBACK( hblank_in_irq ) +static TIMER_DEVICE_CALLBACK( hblank_in_irq ) { int scanline = param; -// h = video_screen_get_height(machine->primary_screen); -// w = video_screen_get_width(machine->primary_screen); +// h = video_screen_get_height(timer->machine->primary_screen); +// w = video_screen_get_width(timer->machine->primary_screen); HBLANK_IN_IRQ; TIMER_0_IRQ; @@ -2641,24 +2641,24 @@ static TIMER_CALLBACK( hblank_in_irq ) if(scanline+1 < v_sync) { if(stv_irq.hblank_in || stv_irq.timer_0) - timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, h_sync), scanline+1); + timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, h_sync), scanline+1); /*set the first Timer-1 event*/ cur_scan = scanline+1; if(stv_irq.timer_1) - timer_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, timer_1), scanline+1); + timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, timer_1), scanline+1); } timer_0++; } -static TIMER_CALLBACK( timer1_irq ) +static TIMER_DEVICE_CALLBACK( timer1_irq ) { int scanline = param; TIMER_1_IRQ; if(stv_irq.timer_1) - timer_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, timer_1), scanline+1); + timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, timer_1), scanline+1); } static TIMER_CALLBACK( vdp1_irq ) @@ -2666,7 +2666,7 @@ static TIMER_CALLBACK( vdp1_irq ) VDP1_IRQ; } -static TIMER_CALLBACK( vblank_out_irq ) +static TIMER_DEVICE_CALLBACK( vblank_out_irq ) { VBLANK_OUT_IRQ; } @@ -2684,10 +2684,10 @@ static INTERRUPT_GEN( stv_interrupt ) /*Next V-Blank-OUT event*/ if(stv_irq.vblank_out) - timer_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), 0); + timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), 0); /*Set the first Hblank-IN event*/ if(stv_irq.hblank_in || stv_irq.timer_0 || stv_irq.timer_1) - timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 0, h_sync), 0); + timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 0, h_sync), 0); /*TODO: timing of this one (related to the VDP1 speed)*/ /* (NOTE: value shouldn't be at h_sync/v_sync position (will break shienryu))*/ @@ -2717,11 +2717,11 @@ static MACHINE_RESET( stv ) stvcd_reset(machine); /* set the first scanline 0 timer to go off */ - scan_timer = timer_alloc(machine, hblank_in_irq, NULL); - t1_timer = timer_alloc(machine, timer1_irq,NULL); - vblank_out_timer = timer_alloc(machine, vblank_out_irq,NULL); - timer_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); - timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 224, 352), 0); + scan_timer = devtag_get_device(machine, "scan_timer"); + t1_timer = devtag_get_device(machine, "t1_timer"); + vblank_out_timer = devtag_get_device(machine, "vbout_timer"); + timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 224, 352), 0); } @@ -2744,6 +2744,11 @@ static MACHINE_DRIVER_START( stv ) MDRV_MACHINE_RESET(stv) MDRV_NVRAM_HANDLER(stv) /* Actually 93c45 */ + MDRV_TIMER_ADD("scan_timer", hblank_in_irq) + MDRV_TIMER_ADD("t1_timer", timer1_irq) + MDRV_TIMER_ADD("vbout_timer", vblank_out_irq) + MDRV_TIMER_ADD("sector_timer", stv_sector_cb) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK) diff --git a/src/mame/drivers/suprnova.c b/src/mame/drivers/suprnova.c index 4086a0ce882..b269dbe4471 100644 --- a/src/mame/drivers/suprnova.c +++ b/src/mame/drivers/suprnova.c @@ -449,17 +449,13 @@ static READ32_HANDLER( skns_hit_r ) /* start old driver code */ -static TIMER_CALLBACK( interrupt_callback ) +static TIMER_DEVICE_CALLBACK( interrupt_callback ) { - cputag_set_input_line(machine, "maincpu", param, HOLD_LINE); + cputag_set_input_line(timer->machine, "maincpu", param, HOLD_LINE); } static MACHINE_RESET(skns) { - timer_pulse(machine, ATTOTIME_IN_MSEC(2), NULL, 15, interrupt_callback); - timer_pulse(machine, ATTOTIME_IN_MSEC(8), NULL, 11, interrupt_callback); - timer_pulse(machine, cputag_clocks_to_attotime(machine, "maincpu", 1824), NULL, 9, interrupt_callback); - memory_set_bankptr(machine, "bank1",memory_region(machine, "user1")); } @@ -842,6 +838,13 @@ static MACHINE_DRIVER_START(skns) MDRV_MACHINE_RESET(skns) MDRV_NVRAM_HANDLER(generic_1fill) + MDRV_TIMER_ADD_PERIODIC("int15_timer", interrupt_callback, MSEC(2)) + MDRV_TIMER_PARAM(15) + MDRV_TIMER_ADD_PERIODIC("int11_timer", interrupt_callback, MSEC(8)) + MDRV_TIMER_PARAM(11) + MDRV_TIMER_ADD_PERIODIC("int9_timer", interrupt_callback, HZ(28638000/1824)) + MDRV_TIMER_PARAM(9) + MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE) MDRV_SCREEN_ADD("screen", RASTER) diff --git a/src/mame/drivers/vertigo.c b/src/mame/drivers/vertigo.c index ebda3cefd69..28a51ccf114 100644 --- a/src/mame/drivers/vertigo.c +++ b/src/mame/drivers/vertigo.c @@ -122,6 +122,7 @@ static MACHINE_DRIVER_START( vertigo ) MDRV_CPU_ADD("motor", M6805, 1000000) MDRV_CPU_PROGRAM_MAP(vertigo_motor) */ + MDRV_MACHINE_START(vertigo) MDRV_MACHINE_RESET(vertigo) MDRV_NVRAM_HANDLER(generic_0fill) diff --git a/src/mame/drivers/wheelfir.c b/src/mame/drivers/wheelfir.c index 207b731b29b..5f00b7f2b52 100644 --- a/src/mame/drivers/wheelfir.c +++ b/src/mame/drivers/wheelfir.c @@ -540,10 +540,10 @@ static INPUT_PORTS_START( wheelfir ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) INPUT_PORTS_END -static emu_timer* frame_timer; -static emu_timer* scanline_timer; +static const device_config* frame_timer; +static const device_config* scanline_timer; -static TIMER_CALLBACK( frame_timer_callback ) +static TIMER_DEVICE_CALLBACK( frame_timer_callback ) { /* callback */ } @@ -570,15 +570,15 @@ static void render_background_to_render_buffer(int scanline) } -static TIMER_CALLBACK( scanline_timer_callback ) +static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) { - timer_call_after_resynch(machine, NULL, 0, 0); + timer_call_after_resynch(timer->machine, NULL, 0, 0); if (scanline_counter != (total_scanlines - 1)) { scanline_counter++; - cputag_set_input_line(machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road - timer_adjust_oneshot(scanline_timer, attotime_div(ATTOTIME_IN_HZ(60), total_scanlines), 0); + cputag_set_input_line(timer->machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road + timer_device_adjust_oneshot(timer, attotime_div(ATTOTIME_IN_HZ(60), total_scanlines), 0); if (scanline_counter < 256) { @@ -587,7 +587,7 @@ static TIMER_CALLBACK( scanline_timer_callback ) if (scanline_counter == 256) { - cputag_set_input_line(machine, "maincpu", 3, HOLD_LINE); // vblank IRQ? + cputag_set_input_line(timer->machine, "maincpu", 3, HOLD_LINE); // vblank IRQ? toggle_bit = 0x8000; // must toggle.. } @@ -609,16 +609,16 @@ static VIDEO_EOF( wheelfir ) scanline_counter = -1; bitmap_fill(wheelfir_tmp_bitmap[0], video_screen_get_visible_area(machine->primary_screen),0); - timer_adjust_oneshot(frame_timer, attotime_zero, 0); - timer_adjust_oneshot(scanline_timer, attotime_zero, 0); + timer_device_adjust_oneshot(frame_timer, attotime_zero, 0); + timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0); } static MACHINE_RESET(wheelfir) { - frame_timer = timer_alloc(machine, frame_timer_callback, NULL); - scanline_timer = timer_alloc(machine, scanline_timer_callback, NULL); - timer_adjust_oneshot(frame_timer, attotime_zero, 0); - timer_adjust_oneshot(scanline_timer, attotime_zero, 0); + frame_timer = devtag_get_device(machine, "frame_timer"); + scanline_timer = devtag_get_device(machine, "scan_timer"); + timer_device_adjust_oneshot(frame_timer, attotime_zero, 0); + timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0); scanline_counter = -1; } @@ -640,6 +640,8 @@ static MACHINE_DRIVER_START( wheelfir ) MDRV_MACHINE_RESET (wheelfir) + MDRV_TIMER_ADD("frame_timer", frame_timer_callback) + MDRV_TIMER_ADD("scan_timer", scanline_timer_callback) MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) diff --git a/src/mame/drivers/williams.c b/src/mame/drivers/williams.c index b493ccacea4..65813151620 100644 --- a/src/mame/drivers/williams.c +++ b/src/mame/drivers/williams.c @@ -1435,9 +1435,13 @@ static MACHINE_DRIVER_START( defender ) MDRV_CPU_ADD("soundcpu", M6808, SOUND_CLOCK) MDRV_CPU_PROGRAM_MAP(defender_sound_map) + MDRV_MACHINE_START(defender) MDRV_MACHINE_RESET(defender) MDRV_NVRAM_HANDLER(generic_0fill) + MDRV_TIMER_ADD("scan_timer", williams_va11_callback) + MDRV_TIMER_ADD("240_timer", williams_count240_callback) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE) @@ -1480,6 +1484,7 @@ static MACHINE_DRIVER_START( williams ) MDRV_CPU_MODIFY("soundcpu") MDRV_CPU_PROGRAM_MAP(sound_map) + MDRV_MACHINE_START(williams) MDRV_MACHINE_RESET(williams) MDRV_SCREEN_MODIFY("screen") MDRV_SCREEN_VISIBLE_AREA(6, 298-1, 7, 247-1) @@ -1535,6 +1540,7 @@ static MACHINE_DRIVER_START( alienar ) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(williams_map) + MDRV_MACHINE_START(williams) MDRV_MACHINE_RESET(williams) MDRV_SCREEN_MODIFY("screen") MDRV_SCREEN_VISIBLE_AREA(6, 298-1, 7, 247-1) @@ -1586,6 +1592,7 @@ static MACHINE_DRIVER_START( blaster ) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(blaster_map) + MDRV_MACHINE_START(blaster) MDRV_MACHINE_RESET(blaster) /* video hardware */ @@ -1616,9 +1623,13 @@ static MACHINE_DRIVER_START( williams2 ) MDRV_CPU_ADD("soundcpu", M6808, MASTER_CLOCK/3) /* yes, this is different from the older games */ MDRV_CPU_PROGRAM_MAP(williams2_sound_map) + MDRV_MACHINE_START(williams2) MDRV_MACHINE_RESET(williams2) MDRV_NVRAM_HANDLER(generic_0fill) + MDRV_TIMER_ADD("scan_timer", williams2_va11_callback) + MDRV_TIMER_ADD("254_timer", williams2_endscreen_callback) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE) MDRV_PALETTE_LENGTH(1024) diff --git a/src/mame/includes/vertigo.h b/src/mame/includes/vertigo.h index 9a8550e240f..ff8b7bcecbd 100644 --- a/src/mame/includes/vertigo.h +++ b/src/mame/includes/vertigo.h @@ -19,6 +19,7 @@ WRITE16_HANDLER( vertigo_motor_w ); WRITE16_HANDLER( vertigo_wsot_w ); INTERRUPT_GEN( vertigo_interrupt ); +MACHINE_START( vertigo ); MACHINE_RESET( vertigo ); /*----------- defined in video/vertigo.c -----------*/ @@ -26,5 +27,6 @@ MACHINE_RESET( vertigo ); extern UINT16 *vertigo_vectorram; void vertigo_vproc_init(running_machine *machine); +void vertigo_vproc_reset(running_machine *machine); void vertigo_vproc(int cycles, int irq4); diff --git a/src/mame/includes/williams.h b/src/mame/includes/williams.h index 063162f364a..c1a05038f3c 100644 --- a/src/mame/includes/williams.h +++ b/src/mame/includes/williams.h @@ -41,10 +41,20 @@ extern const pia6821_interface tshoot_pia_1_intf; extern const pia6821_interface tshoot_snd_pia_intf; extern const pia6821_interface joust2_pia_1_intf; +/* timer callbacks */ +TIMER_DEVICE_CALLBACK( williams_va11_callback ); +TIMER_DEVICE_CALLBACK( williams_count240_callback ); +TIMER_DEVICE_CALLBACK( williams2_va11_callback ); +TIMER_DEVICE_CALLBACK( williams2_endscreen_callback ); + /* initialization */ +MACHINE_START( defender ); MACHINE_RESET( defender ); +MACHINE_START( williams ); MACHINE_RESET( williams ); +MACHINE_START( blaster ); MACHINE_RESET( blaster ); +MACHINE_START( williams2 ); MACHINE_RESET( williams2 ); MACHINE_START( joust2 ); MACHINE_RESET( joust2 ); diff --git a/src/mame/machine/stvcd.c b/src/mame/machine/stvcd.c index 15e24e0088a..b8fe3b0a4e3 100644 --- a/src/mame/machine/stvcd.c +++ b/src/mame/machine/stvcd.c @@ -106,7 +106,7 @@ typedef enum } trans32T; // local variables -static emu_timer *sector_timer; +static const device_config *sector_timer; static partitionT partitions[MAX_FILTERS]; static partitionT *transpart; @@ -182,7 +182,7 @@ static int firstfile; // first non-directory file #define CD_STAT_WAIT 0x8000 // waiting for command if set, else executed immediately #define CD_STAT_REJECT 0xff00 // ultra-fatal error. -static TIMER_CALLBACK( sector_cb ) +TIMER_DEVICE_CALLBACK( stv_sector_cb ) { if (fadstoplay) { @@ -199,7 +199,7 @@ static TIMER_CALLBACK( sector_cb ) cr3 = (cd_curfad>>16)&0xff; cr4 = cd_curfad; - timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); + timer_device_adjust_oneshot(timer, ATTOTIME_IN_HZ(150), 0); } // global functions @@ -274,8 +274,8 @@ void stvcd_reset(running_machine *machine) cd_stat = CD_STAT_OPEN; } - sector_timer = timer_alloc(machine, sector_cb, NULL); - timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second + sector_timer = devtag_get_device(machine, "sector_timer"); + timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second } static blockT *cd_alloc_block(UINT8 *blknum) @@ -766,8 +766,8 @@ static void cd_writeWord(UINT32 addr, UINT16 data) // and do the disc I/O // make sure it doesn't come in too early - timer_adjust_oneshot(sector_timer, attotime_never, 0); - timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second + timer_device_adjust_oneshot(sector_timer, attotime_never, 0); + timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second break; case 0x1100: // disk seek @@ -1275,7 +1275,7 @@ static void cd_writeWord(UINT32 addr, UINT16 data) playtype = 1; // and do the disc I/O -// timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second +// timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second break; case 0x7500: diff --git a/src/mame/machine/stvcd.h b/src/mame/machine/stvcd.h index 37f02024860..d9a8a2cb87d 100644 --- a/src/mame/machine/stvcd.h +++ b/src/mame/machine/stvcd.h @@ -12,6 +12,8 @@ void stvcd_reset(running_machine* machine); void stvcd_exit(running_machine* machine); +TIMER_DEVICE_CALLBACK( stv_sector_cb ); + READ32_HANDLER( stvcd_r ); WRITE32_HANDLER( stvcd_w ); diff --git a/src/mame/machine/vertigo.c b/src/mame/machine/vertigo.c index 6f6868e18bc..5339573446f 100644 --- a/src/mame/machine/vertigo.c +++ b/src/mame/machine/vertigo.c @@ -203,6 +203,16 @@ READ16_HANDLER( vertigo_sio_r ) * *************************************/ +MACHINE_START( vertigo ) +{ + state_save_register_global(machine, irq_state); + state_save_register_global(machine, adc_result); + state_save_register_global(machine, irq4_time.seconds); + state_save_register_global(machine, irq4_time.attoseconds); + + vertigo_vproc_init(machine); +} + MACHINE_RESET( vertigo ) { int i; @@ -214,15 +224,10 @@ MACHINE_RESET( vertigo ) ttl74148_input_line_w(ttl74148, i, 1); ttl74148_update(ttl74148); - vertigo_vproc_init(machine); + vertigo_vproc_reset(machine); irq4_time = timer_get_time(machine); irq_state = 7; - - state_save_register_global(machine, irq_state); - state_save_register_global(machine, adc_result); - state_save_register_global(machine, irq4_time.seconds); - state_save_register_global(machine, irq4_time.attoseconds); } diff --git a/src/mame/machine/williams.c b/src/mame/machine/williams.c index b162a0016c0..e087db951af 100644 --- a/src/mame/machine/williams.c +++ b/src/mame/machine/williams.c @@ -15,11 +15,6 @@ #include "sound/hc55516.h" -/* timers */ -static emu_timer *scanline_timer; -static emu_timer *scan240_timer; -static emu_timer *scan254_timer; - /* banking addresses set by the drivers */ UINT8 *mayday_protection; @@ -253,9 +248,9 @@ const pia6821_interface joust2_pia_1_intf = * *************************************/ -static TIMER_CALLBACK( williams_va11_callback ) +TIMER_DEVICE_CALLBACK( williams_va11_callback ) { - const device_config *pia_1 = devtag_get_device(machine, "pia_1"); + const device_config *pia_1 = devtag_get_device(timer->machine, "pia_1"); int scanline = param; /* the IRQ signal comes into CB1, and is set to VA11 */ @@ -264,7 +259,7 @@ static TIMER_CALLBACK( williams_va11_callback ) /* set a timer for the next update */ scanline += 0x20; if (scanline >= 256) scanline = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline); } @@ -277,18 +272,18 @@ static TIMER_CALLBACK( williams_count240_off_callback ) } -static TIMER_CALLBACK( williams_count240_callback ) +TIMER_DEVICE_CALLBACK( williams_count240_callback ) { - const device_config *pia_1 = devtag_get_device(machine, "pia_1"); + const device_config *pia_1 = devtag_get_device(timer->machine, "pia_1"); /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */ pia6821_ca1_w(pia_1, 0, 1); /* set a timer to turn it off once the scanline counter resets */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, williams_count240_off_callback); + timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, 0, 0), NULL, 0, williams_count240_off_callback); /* set a timer for next frame */ - timer_adjust_oneshot(scan240_timer, video_screen_get_time_until_pos(machine->primary_screen, 240, 0), 0); + timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 240, 0), 0); } @@ -355,27 +350,35 @@ static void tshoot_main_irq(const device_config *device, int state) * *************************************/ +static MACHINE_START( williams_common ) +{ + /* configure the memory bank */ + memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0); + memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, "maincpu") + 0x10000, 0); + + state_save_register_global(machine, vram_bank); +} + + static MACHINE_RESET( williams_common ) { /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */ - scanline_timer = timer_alloc(machine, williams_va11_callback, NULL); - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); /* also set a timer to go off on scanline 240 */ - scan240_timer = timer_alloc(machine, williams_count240_callback, NULL); - timer_adjust_oneshot(scan240_timer, video_screen_get_time_until_pos(machine->primary_screen, 240, 0), 0); + timer_device_adjust_oneshot(devtag_get_device(machine, "240_timer"), video_screen_get_time_until_pos(machine->primary_screen, 240, 0), 0); +} - state_save_register_global(machine, vram_bank); + +MACHINE_START( williams ) +{ + MACHINE_START_CALL(williams_common); } MACHINE_RESET( williams ) { MACHINE_RESET_CALL(williams_common); - - /* configure the memory bank */ - memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0); - memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, "maincpu") + 0x10000, 0); } @@ -386,10 +389,10 @@ MACHINE_RESET( williams ) * *************************************/ -static TIMER_CALLBACK( williams2_va11_callback ) +TIMER_DEVICE_CALLBACK( williams2_va11_callback ) { - const device_config *pia_0 = devtag_get_device(machine, "pia_0"); - const device_config *pia_1 = devtag_get_device(machine, "pia_1"); + const device_config *pia_0 = devtag_get_device(timer->machine, "pia_0"); + const device_config *pia_1 = devtag_get_device(timer->machine, "pia_1"); int scanline = param; /* the IRQ signal comes into CB1, and is set to VA11 */ @@ -399,7 +402,7 @@ static TIMER_CALLBACK( williams2_va11_callback ) /* set a timer for the next update */ scanline += 0x20; if (scanline >= 256) scanline = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline); } @@ -412,18 +415,18 @@ static TIMER_CALLBACK( williams2_endscreen_off_callback ) } -static TIMER_CALLBACK( williams2_endscreen_callback ) +TIMER_DEVICE_CALLBACK( williams2_endscreen_callback ) { - const device_config *pia_0 = devtag_get_device(machine, "pia_0"); + const device_config *pia_0 = devtag_get_device(timer->machine, "pia_0"); /* the /ENDSCREEN signal comes into CA1 */ pia6821_ca1_w(pia_0, 0, 0); /* set a timer to turn it off once the scanline counter resets */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 8, 0), NULL, 0, williams2_endscreen_off_callback); + timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, 8, 0), NULL, 0, williams2_endscreen_off_callback); /* set a timer for next frame */ - timer_adjust_oneshot(scan254_timer, video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0); + timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 254, 0), 0); } @@ -441,27 +444,30 @@ static STATE_POSTLOAD( williams2_postload ) } -MACHINE_RESET( williams2 ) +MACHINE_START( williams2 ) { - const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - /* configure memory banks */ memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0); memory_configure_bank(machine, "bank1", 1, 4, memory_region(machine, "maincpu") + 0x10000, 0x10000); + /* register for save states */ + state_save_register_global(machine, vram_bank); + state_save_register_postload(machine, williams2_postload, NULL); +} + + +MACHINE_RESET( williams2 ) +{ + const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); + /* make sure our banking is reset */ williams2_bank_select_w(space, 0, 0); /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */ - scanline_timer = timer_alloc(machine, williams2_va11_callback, NULL); - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); /* also set a timer to go off on scanline 254 */ - scan254_timer = timer_alloc(machine, williams2_endscreen_callback, NULL); - timer_adjust_oneshot(scan254_timer, video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0); - - state_save_register_global(machine, vram_bank); - state_save_register_postload(machine, williams2_postload, NULL); + timer_device_adjust_oneshot(devtag_get_device(machine, "254_timer"), video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0); } @@ -720,17 +726,24 @@ static STATE_POSTLOAD( defender_postload ) } +MACHINE_START( defender ) +{ + MACHINE_START_CALL(williams_common); + + /* configure the banking and make sure it is reset to 0 */ + memory_configure_bank(machine, "bank1", 0, 9, &memory_region(machine, "maincpu")[0x10000], 0x1000); + + state_save_register_postload(machine, defender_postload, NULL); +} + + MACHINE_RESET( defender ) { const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); MACHINE_RESET_CALL(williams_common); - /* configure the banking and make sure it is reset to 0 */ - memory_configure_bank(machine, "bank1", 0, 9, &memory_region(machine, "maincpu")[0x10000], 0x1000); defender_bank_select_w(space, 0, 0); - - state_save_register_postload(machine, defender_postload, NULL); } @@ -817,9 +830,9 @@ WRITE8_HANDLER( sinistar_vram_select_w ) * *************************************/ -MACHINE_RESET( blaster ) +MACHINE_START( blaster ) { - MACHINE_RESET_CALL(williams_common); + MACHINE_START_CALL(williams_common); /* banking is different for blaster */ memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0); @@ -832,6 +845,12 @@ MACHINE_RESET( blaster ) } +MACHINE_RESET( blaster ) +{ + MACHINE_RESET_CALL(williams_common); +} + + INLINE void update_blaster_banking(running_machine *machine) { memory_set_bank(machine, "bank1", vram_bank * (blaster_bank + 1)); @@ -934,7 +953,9 @@ static WRITE8_DEVICE_HANDLER( tshoot_lamp_w ) MACHINE_START( joust2 ) { + MACHINE_START_CALL(williams2); williams_cvsd_init(machine); + state_save_register_global(machine, joust2_current_sound_data); } @@ -945,7 +966,6 @@ MACHINE_RESET( joust2 ) /* standard init */ MACHINE_RESET_CALL(williams2); pia6821_ca1_w(pia_3, 0, 1); - state_save_register_global(machine, joust2_current_sound_data); } diff --git a/src/mame/video/vertigo.c b/src/mame/video/vertigo.c index 0d8e28397ca..a7ac3514d74 100644 --- a/src/mame/video/vertigo.c +++ b/src/mame/video/vertigo.c @@ -212,6 +212,41 @@ static microcode mc[MC_LENGTH]; *************************************/ void vertigo_vproc_init(running_machine *machine) +{ + state_save_register_item_array(machine, "vector_proc", NULL, 0, vs.sram); + state_save_register_item(machine, "vector_proc", NULL, 0, vs.ramlatch); + state_save_register_item(machine, "vector_proc", NULL, 0, vs.rom_adr); + state_save_register_item(machine, "vector_proc", NULL, 0, vs.pc); + state_save_register_item(machine, "vector_proc", NULL, 0, vs.ret); + + state_save_register_item_array(machine, "vector_proc", NULL, 0, bsp.ram); + state_save_register_item(machine, "vector_proc", NULL, 0, bsp.d); + state_save_register_item(machine, "vector_proc", NULL, 0, bsp.q); + state_save_register_item(machine, "vector_proc", NULL, 0, bsp.f); + state_save_register_item(machine, "vector_proc", NULL, 0, bsp.y); + + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.sreg); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l1); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l2); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_v); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_h); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_l); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_s); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_a); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.color); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.intensity); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.brez); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vfin); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud1); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud2); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud1); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud2); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hc1); + state_save_register_item(machine, "vector_proc", NULL, 0, vgen.ven); +} + + +void vertigo_vproc_reset(running_machine *machine) { int i; UINT64 *mcode; @@ -244,37 +279,6 @@ void vertigo_vproc_init(running_machine *machine) memset(&bsp, 0, sizeof(bsp)); memset(&vgen, 0, sizeof(vgen)); vgen.machine = machine; - - state_save_register_item_array(machine, "vector_proc", NULL, 0, vs.sram); - state_save_register_item(machine, "vector_proc", NULL, 0, vs.ramlatch); - state_save_register_item(machine, "vector_proc", NULL, 0, vs.rom_adr); - state_save_register_item(machine, "vector_proc", NULL, 0, vs.pc); - state_save_register_item(machine, "vector_proc", NULL, 0, vs.ret); - - state_save_register_item_array(machine, "vector_proc", NULL, 0, bsp.ram); - state_save_register_item(machine, "vector_proc", NULL, 0, bsp.d); - state_save_register_item(machine, "vector_proc", NULL, 0, bsp.q); - state_save_register_item(machine, "vector_proc", NULL, 0, bsp.f); - state_save_register_item(machine, "vector_proc", NULL, 0, bsp.y); - - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.sreg); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l1); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l2); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_v); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_h); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_l); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_s); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_a); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.color); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.intensity); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.brez); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vfin); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud1); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud2); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud1); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud2); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hc1); - state_save_register_item(machine, "vector_proc", NULL, 0, vgen.ven); }