From 26d1e3868ae87accd05ef324fd2d2f9f93a241a5 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Tue, 15 Dec 2009 05:41:34 +0000 Subject: [PATCH] Some more atari driver shuffling. Added atarigen_init() function which allocates all timers and registers for save states. Updated all drivers to call it. Converted some drivers to use device timers. --- src/mame/drivers/arcadecl.c | 7 + src/mame/drivers/atarig1.c | 1 + src/mame/drivers/atarig42.c | 15 +- src/mame/drivers/atarigt.c | 7 + src/mame/drivers/atarigx2.c | 7 + src/mame/drivers/atarisy1.c | 34 +++-- src/mame/drivers/atarisy2.c | 2 + src/mame/drivers/badlands.c | 10 ++ src/mame/drivers/batman.c | 13 +- src/mame/drivers/beathead.c | 21 ++- src/mame/drivers/blstroid.c | 7 + src/mame/drivers/cyberbal.c | 16 ++ src/mame/drivers/eprom.c | 22 +-- src/mame/drivers/foodf.c | 13 +- src/mame/drivers/gauntlet.c | 19 +-- src/mame/drivers/klax.c | 8 + src/mame/drivers/offtwall.c | 7 + src/mame/drivers/rampart.c | 7 + src/mame/drivers/relief.c | 7 + src/mame/drivers/shuuz.c | 7 + src/mame/drivers/skullxbo.c | 7 + src/mame/drivers/thunderj.c | 10 ++ src/mame/drivers/toobin.c | 7 + src/mame/drivers/vindictr.c | 7 + src/mame/drivers/xybots.c | 7 + src/mame/includes/atarisy1.h | 12 +- src/mame/includes/beathead.h | 7 + src/mame/includes/foodf.h | 1 - src/mame/includes/xybots.h | 2 +- src/mame/machine/atarigen.c | 287 ++++++++++++----------------------- src/mame/machine/atarigen.h | 36 +++-- src/mame/machine/harddriv.c | 2 + src/mame/video/atarig42.c | 15 +- src/mame/video/atarigt.c | 8 + src/mame/video/atarigx2.c | 7 + src/mame/video/atarisy1.c | 38 ++--- src/mame/video/badlands.c | 3 + src/mame/video/beathead.c | 51 +++---- src/mame/video/cyberbal.c | 6 + src/mame/video/eprom.c | 8 + src/mame/video/gauntlet.c | 4 + src/mame/video/toobin.c | 2 + src/mame/video/vindictr.c | 5 + 43 files changed, 451 insertions(+), 311 deletions(-) diff --git a/src/mame/drivers/arcadecl.c b/src/mame/drivers/arcadecl.c index d8d0b5a4a34..8006a7b9c8a 100644 --- a/src/mame/drivers/arcadecl.c +++ b/src/mame/drivers/arcadecl.c @@ -103,6 +103,12 @@ static void scanline_update(const device_config *screen, int scanline) * *************************************/ +static MACHINE_START( arcadecl ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( arcadecl ) { rampart_state *state = (rampart_state *)machine->driver_data; @@ -324,6 +330,7 @@ static MACHINE_DRIVER_START( arcadecl ) MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(arcadecl) MDRV_MACHINE_RESET(arcadecl) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/atarig1.c b/src/mame/drivers/atarig1.c index ae215e2ed34..cd90ae8ce95 100644 --- a/src/mame/drivers/atarig1.c +++ b/src/mame/drivers/atarig1.c @@ -43,6 +43,7 @@ static void update_interrupts(running_machine *machine) static MACHINE_START( atarig1 ) { atarig1_state *state = (atarig1_state *)machine->driver_data; + atarigen_init(machine); state_save_register_global(machine, state->which_input); } diff --git a/src/mame/drivers/atarig42.c b/src/mame/drivers/atarig42.c index 6c07dc2ca68..4ccc048ab46 100644 --- a/src/mame/drivers/atarig42.c +++ b/src/mame/drivers/atarig42.c @@ -17,7 +17,6 @@ ***************************************************************************/ - #include "driver.h" #include "cpu/m68000/m68000.h" #include "machine/asic65.h" @@ -40,6 +39,19 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( atarig42 ) +{ + atarig42_state *state = (atarig42_state *)machine->driver_data; + atarigen_init(machine); + + state_save_register_global(machine, state->analog_data); + state_save_register_global(machine, state->sloop_bank); + state_save_register_global(machine, state->sloop_next_bank); + state_save_register_global(machine, state->sloop_offset); + state_save_register_global(machine, state->sloop_state); +} + + static MACHINE_RESET( atarig42 ) { atarig42_state *state = (atarig42_state *)machine->driver_data; @@ -511,6 +523,7 @@ static MACHINE_DRIVER_START( atarig42 ) /* ASIC65 */ MDRV_IMPORT_FROM(asic65) + MDRV_MACHINE_START(atarig42) MDRV_MACHINE_RESET(atarig42) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/atarigt.c b/src/mame/drivers/atarigt.c index 7277169b546..6450375c5de 100644 --- a/src/mame/drivers/atarigt.c +++ b/src/mame/drivers/atarigt.c @@ -56,6 +56,12 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( atarigt ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( atarigt ) { atarigt_state *state = (atarigt_state *)machine->driver_data; @@ -793,6 +799,7 @@ static MACHINE_DRIVER_START( atarigt ) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) MDRV_CPU_PERIODIC_INT(atarigen_scanline_int_gen, 250) + MDRV_MACHINE_START(atarigt) MDRV_MACHINE_RESET(atarigt) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/atarigx2.c b/src/mame/drivers/atarigx2.c index e307664e4d1..bbd0f0554d6 100644 --- a/src/mame/drivers/atarigx2.c +++ b/src/mame/drivers/atarigx2.c @@ -41,6 +41,12 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( atarigx2 ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( atarigx2 ) { atarigx2_state *state = (atarigx2_state *)machine->driver_data; @@ -1392,6 +1398,7 @@ static MACHINE_DRIVER_START( atarigx2 ) MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(atarigx2) MDRV_MACHINE_RESET(atarigx2) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/atarisy1.c b/src/mame/drivers/atarisy1.c index bc786eeda4d..96d1f56d2c8 100644 --- a/src/mame/drivers/atarisy1.c +++ b/src/mame/drivers/atarisy1.c @@ -180,10 +180,6 @@ -static TIMER_CALLBACK( delayed_joystick_int ); - - - /************************************* * * Initialization & interrupts @@ -200,6 +196,20 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( atarisy1 ) +{ + atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarigen_init(machine); + + state_save_register_global(machine, state->joystick_int); + state_save_register_global(machine, state->joystick_int_enable); + state_save_register_global(machine, state->joystick_value); + state_save_register_global(machine, state->tms5220_out_data); + state_save_register_global(machine, state->tms5220_in_data); + state_save_register_global(machine, state->tms5220_ctl); +} + + static MACHINE_RESET( atarisy1 ) { atarisy1_state *state = (atarisy1_state *)machine->driver_data; @@ -212,7 +222,7 @@ static MACHINE_RESET( atarisy1 ) /* reset the joystick parameters */ state->joystick_value = 0; - state->joystick_timer = timer_alloc(machine, delayed_joystick_int, NULL); + state->joystick_timer = devtag_get_device(machine, "joystick_timer"); state->joystick_int = 0; state->joystick_int_enable = 0; } @@ -225,12 +235,12 @@ static MACHINE_RESET( atarisy1 ) * *************************************/ -static TIMER_CALLBACK( delayed_joystick_int ) +static TIMER_DEVICE_CALLBACK( delayed_joystick_int ) { - atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data; state->joystick_value = param; state->joystick_int = 1; - atarigen_update_interrupts(machine); + atarigen_update_interrupts(timer->machine); } @@ -257,7 +267,7 @@ static READ16_HANDLER( joystick_r ) /* clear any existing interrupt and set a timer for a new one */ state->joystick_int = 0; - timer_adjust_oneshot(state->joystick_timer, ATTOTIME_IN_USEC(50), newval); + timer_device_adjust_oneshot(state->joystick_timer, ATTOTIME_IN_USEC(50), newval); atarigen_update_interrupts(space->machine); return state->joystick_value; @@ -753,8 +763,14 @@ static MACHINE_DRIVER_START( atarisy1 ) MDRV_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8) MDRV_CPU_PROGRAM_MAP(sound_map) + MDRV_MACHINE_START(atarisy1) MDRV_MACHINE_RESET(atarisy1) MDRV_NVRAM_HANDLER(atarigen) + + MDRV_TIMER_ADD("joystick_timer", delayed_joystick_int) + MDRV_TIMER_ADD("scan_timer", atarisy1_int3_callback) + MDRV_TIMER_ADD("int3off_timer", atarisy1_int3off_callback) + MDRV_TIMER_ADD("yreset_timer", atarisy1_reset_yscroll_callback) /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) diff --git a/src/mame/drivers/atarisy2.c b/src/mame/drivers/atarisy2.c index e6f9638bdc0..746f98280c0 100644 --- a/src/mame/drivers/atarisy2.c +++ b/src/mame/drivers/atarisy2.c @@ -225,6 +225,8 @@ static DIRECT_UPDATE_HANDLER( atarisy2_direct_handler ) static MACHINE_START( atarisy2 ) { atarisy2_state *state = (atarisy2_state *)machine->driver_data; + atarigen_init(machine); + state_save_register_global(machine, state->interrupt_enable); state_save_register_global(machine, state->tms5220_data); state_save_register_global(machine, state->tms5220_data_strobe); diff --git a/src/mame/drivers/badlands.c b/src/mame/drivers/badlands.c index ffd02e58b8d..dd84a02994b 100644 --- a/src/mame/drivers/badlands.c +++ b/src/mame/drivers/badlands.c @@ -196,6 +196,12 @@ static void scanline_update(const device_config *screen, int scanline) } +static MACHINE_START( badlands ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( badlands ) { badlands_state *state = (badlands_state *)machine->driver_data; @@ -208,6 +214,8 @@ static MACHINE_RESET( badlands ) atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu")); memcpy(state->bank_base, &state->bank_source_data[0x0000], 0x1000); + + state_save_register_global_array(machine, state->pedal_value); } @@ -504,6 +512,7 @@ static MACHINE_DRIVER_START( badlands ) MDRV_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8) MDRV_CPU_PROGRAM_MAP(audio_map) + MDRV_MACHINE_START(badlands) MDRV_MACHINE_RESET(badlands) MDRV_NVRAM_HANDLER(atarigen) @@ -713,6 +722,7 @@ static MACHINE_DRIVER_START( badlandb ) // MDRV_CPU_ADD("audiocpu", Z80, 2800000/8) // MDRV_CPU_PROGRAM_MAP(bootleg_soundmap) + MDRV_MACHINE_START(badlands) MDRV_MACHINE_RESET(badlandb) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/batman.c b/src/mame/drivers/batman.c index ccc00e2f476..81b44ce9888 100644 --- a/src/mame/drivers/batman.c +++ b/src/mame/drivers/batman.c @@ -38,6 +38,16 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( batman ) +{ + batman_state *state = (batman_state *)machine->driver_data; + atarigen_init(machine); + + state_save_register_global(machine, state->latch_data); + state_save_register_global(machine, state->alpha_tile_bank); +} + + static MACHINE_RESET( batman ) { batman_state *state = (batman_state *)machine->driver_data; @@ -47,8 +57,6 @@ static MACHINE_RESET( batman ) atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2); atarigen_scanline_timer_reset(machine->primary_screen, batman_scanline_update, 8); atarijsa_reset(); - atarigen_init_save_state(machine); - state_save_register_global(machine, state->latch_data); } @@ -231,6 +239,7 @@ static MACHINE_DRIVER_START( batman ) MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz) MDRV_CPU_PROGRAM_MAP(main_map) + MDRV_MACHINE_START(batman) MDRV_MACHINE_RESET(batman) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/beathead.c b/src/mame/drivers/beathead.c index d4c676673ad..33c75431464 100644 --- a/src/mame/drivers/beathead.c +++ b/src/mame/drivers/beathead.c @@ -135,16 +135,16 @@ static UINT8 eeprom_enabled; static void update_interrupts(running_machine *machine); -static TIMER_CALLBACK( scanline_callback ) +static TIMER_DEVICE_CALLBACK( scanline_callback ) { int scanline = param; /* update the video */ - video_screen_update_now(machine->primary_screen); + video_screen_update_now(timer->machine->primary_screen); /* on scanline zero, clear any halt condition */ if (scanline == 0) - cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE); + cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE); /* wrap around at 262 */ scanline++; @@ -153,10 +153,16 @@ static TIMER_CALLBACK( scanline_callback ) /* set the scanline IRQ */ irq_state[2] = 1; - update_interrupts(machine); + update_interrupts(timer->machine); /* set the timer for the next one */ - timer_set(machine, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, scanline, 0)) - hblank_offset), NULL, scanline, scanline_callback); + timer_device_adjust_oneshot(timer, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0)) - hblank_offset), scanline); +} + + +static MACHINE_START( beathead ) +{ + atarigen_init(machine); } @@ -175,7 +181,7 @@ static MACHINE_RESET( beathead ) /* compute the timing of the HBLANK interrupt and set the first timer */ hblank_offset = attotime_to_double(video_screen_get_scan_period(machine->primary_screen)) * ((455. - 336. - 25.) / 455.); - timer_set(machine, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, 0, 0)) - hblank_offset), NULL, 0, scanline_callback); + timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, 0, 0)) - hblank_offset), 0); /* reset IRQs */ irq_line_state = CLEAR_LINE; @@ -416,8 +422,11 @@ static MACHINE_DRIVER_START( beathead ) MDRV_CPU_ADD("maincpu", ASAP, ATARI_CLOCK_14MHz) MDRV_CPU_PROGRAM_MAP(main_map) + MDRV_MACHINE_START(beathead) MDRV_MACHINE_RESET(beathead) MDRV_NVRAM_HANDLER(generic_1fill) + + MDRV_TIMER_ADD("scan_timer", scanline_callback) /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) diff --git a/src/mame/drivers/blstroid.c b/src/mame/drivers/blstroid.c index 92fe6698ba0..90b6ee92f92 100644 --- a/src/mame/drivers/blstroid.c +++ b/src/mame/drivers/blstroid.c @@ -46,6 +46,12 @@ static WRITE16_HANDLER( blstroid_halt_until_hblank_0_w ) } +static MACHINE_START( blstroid ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( blstroid ) { blstroid_state *state = (blstroid_state *)machine->driver_data; @@ -202,6 +208,7 @@ static MACHINE_DRIVER_START( blstroid ) MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(blstroid) MDRV_MACHINE_RESET(blstroid) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/cyberbal.c b/src/mame/drivers/cyberbal.c index eb24f73a4ac..8a441c1d83b 100644 --- a/src/mame/drivers/cyberbal.c +++ b/src/mame/drivers/cyberbal.c @@ -43,6 +43,20 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( cyberbal ) +{ + cyberbal_state *state = (cyberbal_state *)machine->driver_data; + atarigen_init(machine); + + state_save_register_global(machine, state->fast_68k_int); + state_save_register_global(machine, state->io_68k_int); + state_save_register_global(machine, state->sound_data_from_68k); + state_save_register_global(machine, state->sound_data_from_6502); + state_save_register_global(machine, state->sound_data_from_68k_ready); + state_save_register_global(machine, state->sound_data_from_6502_ready); +} + + static MACHINE_RESET( cyberbal ) { cyberbal_state *state = (cyberbal_state *)machine->driver_data; @@ -436,6 +450,7 @@ static MACHINE_DRIVER_START( cyberbal ) MDRV_QUANTUM_TIME(HZ(600)) + MDRV_MACHINE_START(cyberbal) MDRV_MACHINE_RESET(cyberbal) MDRV_NVRAM_HANDLER(atarigen) @@ -483,6 +498,7 @@ static MACHINE_DRIVER_START( cyberb2p ) MDRV_CPU_PROGRAM_MAP(cyberb2p_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(cyberbal) MDRV_MACHINE_RESET(cyberb2p) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/eprom.c b/src/mame/drivers/eprom.c index f1a140b80cd..c9d4cedf479 100644 --- a/src/mame/drivers/eprom.c +++ b/src/mame/drivers/eprom.c @@ -49,7 +49,13 @@ static void update_interrupts(running_machine *machine) } -static MACHINE_RESET( klaxp ) +static MACHINE_START( eprom ) +{ + atarigen_init(machine); +} + + +static MACHINE_RESET( eprom ) { eprom_state *state = (eprom_state *)machine->driver_data; @@ -57,15 +63,6 @@ static MACHINE_RESET( klaxp ) atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_scanline_timer_reset(machine->primary_screen, eprom_scanline_update, 8); atarijsa_reset(); - atarigen_init_save_state(machine); -} - - -static MACHINE_RESET( eprom ) -{ - eprom_state *state = (eprom_state *)machine->driver_data; - MACHINE_RESET_CALL(klaxp); - state_save_register_global_pointer(machine, state->sync_data, 2); } @@ -422,6 +419,7 @@ static MACHINE_DRIVER_START( eprom ) MDRV_QUANTUM_TIME(HZ(6000)) + MDRV_MACHINE_START(eprom) MDRV_MACHINE_RESET(eprom) MDRV_NVRAM_HANDLER(atarigen) @@ -454,7 +452,8 @@ static MACHINE_DRIVER_START( klaxp ) MDRV_QUANTUM_TIME(HZ(600)) - MDRV_MACHINE_RESET(klaxp) + MDRV_MACHINE_START(eprom) + MDRV_MACHINE_RESET(eprom) MDRV_NVRAM_HANDLER(atarigen) /* video hardware */ @@ -486,6 +485,7 @@ static MACHINE_DRIVER_START( guts ) MDRV_QUANTUM_TIME(HZ(600)) + MDRV_MACHINE_START(eprom) MDRV_MACHINE_RESET(eprom) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/foodf.c b/src/mame/drivers/foodf.c index fc742d3cc5a..fd695e2fdc4 100644 --- a/src/mame/drivers/foodf.c +++ b/src/mame/drivers/foodf.c @@ -111,9 +111,8 @@ static void update_interrupts(running_machine *machine) } -static TIMER_CALLBACK( scanline_update ) +static TIMER_DEVICE_CALLBACK( scanline_update ) { - foodf_state *state = (foodf_state *)machine->driver_data; int scanline = param; /* WARNING: the timing of this is not perfectly accurate; it should fire on @@ -122,7 +121,7 @@ static TIMER_CALLBACK( scanline_update ) mystery yet */ /* INT 1 is on 32V */ - atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu")); + atarigen_scanline_int_gen(cputag_get_cpu(timer->machine, "maincpu")); /* advance to the next interrupt */ scanline += 64; @@ -130,15 +129,15 @@ static TIMER_CALLBACK( scanline_update ) scanline = 0; /* set a timer for it */ - timer_adjust_oneshot(state->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); } static MACHINE_START( foodf ) { foodf_state *state = (foodf_state *)machine->driver_data; + atarigen_init(machine); state_save_register_global(machine, state->whichport); - state->scanline_timer = timer_alloc(machine, scanline_update, NULL); } @@ -146,7 +145,7 @@ static MACHINE_RESET( foodf ) { foodf_state *state = (foodf_state *)machine->driver_data; atarigen_interrupt_reset(&state->atarigen, update_interrupts); - timer_adjust_oneshot(state->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); } @@ -365,6 +364,8 @@ static MACHINE_DRIVER_START( foodf ) MDRV_MACHINE_RESET(foodf) MDRV_NVRAM_HANDLER(generic_1fill) MDRV_WATCHDOG_VBLANK_INIT(8) + + MDRV_TIMER_ADD("scan_timer", scanline_update) /* video hardware */ MDRV_GFXDECODE(foodf) diff --git a/src/mame/drivers/gauntlet.c b/src/mame/drivers/gauntlet.c index 05049bd4eb7..1b0b19d3cba 100644 --- a/src/mame/drivers/gauntlet.c +++ b/src/mame/drivers/gauntlet.c @@ -128,15 +128,6 @@ -/************************************* - * - * Statics - * - *************************************/ - - - - /************************************* * * Initialization & interrupts @@ -163,6 +154,15 @@ static void scanline_update(const device_config *screen, int scanline) } +static MACHINE_START( gauntlet ) +{ + gauntlet_state *state = (gauntlet_state *)machine->driver_data; + atarigen_init(machine); + + state_save_register_global(machine, state->sound_reset_val); +} + + static MACHINE_RESET( gauntlet ) { gauntlet_state *state = (gauntlet_state *)machine->driver_data; @@ -514,6 +514,7 @@ static MACHINE_DRIVER_START( gauntlet ) MDRV_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8) MDRV_CPU_PROGRAM_MAP(sound_map) + MDRV_MACHINE_START(gauntlet) MDRV_MACHINE_RESET(gauntlet) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/klax.c b/src/mame/drivers/klax.c index 2e574e278ed..dca9d1417ff 100644 --- a/src/mame/drivers/klax.c +++ b/src/mame/drivers/klax.c @@ -59,6 +59,12 @@ static WRITE16_HANDLER( interrupt_ack_w ) * *************************************/ +static MACHINE_START( klax ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( klax ) { klax_state *state = (klax_state *)machine->driver_data; @@ -94,6 +100,7 @@ static ADDRESS_MAP_START( klax_map, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_END + /************************************* * * Port definitions @@ -165,6 +172,7 @@ static MACHINE_DRIVER_START( klax ) MDRV_CPU_PROGRAM_MAP(klax_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(klax) MDRV_MACHINE_RESET(klax) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/offtwall.c b/src/mame/drivers/offtwall.c index 0f5756ec608..dad33a4087c 100644 --- a/src/mame/drivers/offtwall.c +++ b/src/mame/drivers/offtwall.c @@ -45,6 +45,12 @@ static void update_interrupts(running_machine *machine) * *************************************/ +static MACHINE_START( offtwall ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( offtwall ) { offtwall_state *state = (offtwall_state *)machine->driver_data; @@ -404,6 +410,7 @@ static MACHINE_DRIVER_START( offtwall ) MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) MDRV_CPU_PROGRAM_MAP(main_map) + MDRV_MACHINE_START(offtwall) MDRV_MACHINE_RESET(offtwall) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/rampart.c b/src/mame/drivers/rampart.c index 2720345601e..1d5287a1c34 100644 --- a/src/mame/drivers/rampart.c +++ b/src/mame/drivers/rampart.c @@ -60,6 +60,12 @@ static void scanline_update(const device_config *screen, int scanline) * *************************************/ +static MACHINE_START( rampart ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( rampart ) { rampart_state *state = (rampart_state *)machine->driver_data; @@ -343,6 +349,7 @@ static MACHINE_DRIVER_START( rampart ) MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(rampart) MDRV_MACHINE_RESET(rampart) MDRV_NVRAM_HANDLER(atarigen) MDRV_WATCHDOG_VBLANK_INIT(8) diff --git a/src/mame/drivers/relief.c b/src/mame/drivers/relief.c index d40b6405ac2..2b45da979a4 100644 --- a/src/mame/drivers/relief.c +++ b/src/mame/drivers/relief.c @@ -64,6 +64,12 @@ static WRITE16_HANDLER( relief_atarivc_w ) * *************************************/ +static MACHINE_START( relief ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( relief ) { relief_state *state = (relief_state *)machine->driver_data; @@ -293,6 +299,7 @@ static MACHINE_DRIVER_START( relief ) MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) MDRV_CPU_PROGRAM_MAP(main_map) + MDRV_MACHINE_START(relief) MDRV_MACHINE_RESET(relief) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/shuuz.c b/src/mame/drivers/shuuz.c index 0e66a3e2316..c7a313e11ba 100644 --- a/src/mame/drivers/shuuz.c +++ b/src/mame/drivers/shuuz.c @@ -63,6 +63,12 @@ static WRITE16_HANDLER( shuuz_atarivc_w ) * *************************************/ +static MACHINE_START( shuuz ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( shuuz ) { shuuz_state *state = (shuuz_state *)machine->driver_data; @@ -259,6 +265,7 @@ static MACHINE_DRIVER_START( shuuz ) MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2) MDRV_CPU_PROGRAM_MAP(main_map) + MDRV_MACHINE_START(shuuz) MDRV_MACHINE_RESET(shuuz) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/skullxbo.c b/src/mame/drivers/skullxbo.c index e2f174a9c43..4308615a88f 100644 --- a/src/mame/drivers/skullxbo.c +++ b/src/mame/drivers/skullxbo.c @@ -70,6 +70,12 @@ static WRITE16_HANDLER( skullxbo_halt_until_hblank_0_w ) } +static MACHINE_START( skullxbo ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( skullxbo ) { skullxbo_state *state = (skullxbo_state *)machine->driver_data; @@ -255,6 +261,7 @@ static MACHINE_DRIVER_START( skullxbo ) MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(skullxbo) MDRV_MACHINE_RESET(skullxbo) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/thunderj.c b/src/mame/drivers/thunderj.c index e101053646c..25bb01a2513 100644 --- a/src/mame/drivers/thunderj.c +++ b/src/mame/drivers/thunderj.c @@ -40,6 +40,15 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( thunderj ) +{ + thunderj_state *state = (thunderj_state *)machine->driver_data; + atarigen_init(machine); + + state_save_register_global(machine, state->alpha_tile_bank); +} + + static MACHINE_RESET( thunderj ) { thunderj_state *state = (thunderj_state *)machine->driver_data; @@ -284,6 +293,7 @@ static MACHINE_DRIVER_START( thunderj ) MDRV_CPU_ADD("extra", M68000, ATARI_CLOCK_14MHz/2) MDRV_CPU_PROGRAM_MAP(extra_map) + MDRV_MACHINE_START(thunderj) MDRV_MACHINE_RESET(thunderj) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/toobin.c b/src/mame/drivers/toobin.c index c8b056c165e..8d4ccc1fe33 100644 --- a/src/mame/drivers/toobin.c +++ b/src/mame/drivers/toobin.c @@ -42,6 +42,12 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( toobin ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( toobin ) { toobin_state *state = (toobin_state *)machine->driver_data; @@ -224,6 +230,7 @@ static MACHINE_DRIVER_START( toobin ) MDRV_CPU_ADD("maincpu", M68010, MASTER_CLOCK/4) MDRV_CPU_PROGRAM_MAP(main_map) + MDRV_MACHINE_START(toobin) MDRV_MACHINE_RESET(toobin) MDRV_NVRAM_HANDLER(atarigen) MDRV_WATCHDOG_VBLANK_INIT(8) diff --git a/src/mame/drivers/vindictr.c b/src/mame/drivers/vindictr.c index 7b6f8f70561..5619c1232e4 100644 --- a/src/mame/drivers/vindictr.c +++ b/src/mame/drivers/vindictr.c @@ -38,6 +38,12 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( vindictr ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( vindictr ) { vindictr_state *state = (vindictr_state *)machine->driver_data; @@ -194,6 +200,7 @@ static MACHINE_DRIVER_START( vindictr ) MDRV_CPU_ADD("maincpu", M68010, ATARI_CLOCK_14MHz/2) MDRV_CPU_PROGRAM_MAP(main_map) + MDRV_MACHINE_START(vindictr) MDRV_MACHINE_RESET(vindictr) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/drivers/xybots.c b/src/mame/drivers/xybots.c index 55e4f868433..2ddcf69b250 100644 --- a/src/mame/drivers/xybots.c +++ b/src/mame/drivers/xybots.c @@ -39,6 +39,12 @@ static void update_interrupts(running_machine *machine) } +static MACHINE_START( xybots ) +{ + atarigen_init(machine); +} + + static MACHINE_RESET( xybots ) { xybots_state *state = (xybots_state *)machine->driver_data; @@ -193,6 +199,7 @@ static MACHINE_DRIVER_START( xybots ) MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen) + MDRV_MACHINE_START(xybots) MDRV_MACHINE_RESET(xybots) MDRV_NVRAM_HANDLER(atarigen) diff --git a/src/mame/includes/atarisy1.h b/src/mame/includes/atarisy1.h index baeb2245238..628dd478b17 100644 --- a/src/mame/includes/atarisy1.h +++ b/src/mame/includes/atarisy1.h @@ -16,7 +16,7 @@ struct _atarisy1_state UINT8 joystick_type; UINT8 trackball_type; - emu_timer * joystick_timer; + const device_config *joystick_timer; UINT8 joystick_int; UINT8 joystick_int_enable; UINT8 joystick_value; @@ -29,12 +29,12 @@ struct _atarisy1_state UINT16 playfield_lookup[256]; UINT8 playfield_tile_bank; UINT16 playfield_priority_pens; - emu_timer * yscroll_reset_timer; + const device_config *yscroll_reset_timer; /* INT3 tracking */ int next_timer_scanline; - emu_timer * scanline_timer; - emu_timer * int3off_timer; + const device_config *scanline_timer; + const device_config *int3off_timer; /* graphics bank tracking */ UINT8 bank_gfx[3][8]; @@ -44,6 +44,10 @@ struct _atarisy1_state /*----------- defined in video/atarisy1.c -----------*/ +TIMER_DEVICE_CALLBACK( atarisy1_int3_callback ); +TIMER_DEVICE_CALLBACK( atarisy1_int3off_callback ); +TIMER_DEVICE_CALLBACK( atarisy1_reset_yscroll_callback ); + READ16_HANDLER( atarisy1_int3state_r ); WRITE16_HANDLER( atarisy1_spriteram_w ); diff --git a/src/mame/includes/beathead.h b/src/mame/includes/beathead.h index e5498e0b02b..fdd2307cfec 100644 --- a/src/mame/includes/beathead.h +++ b/src/mame/includes/beathead.h @@ -13,6 +13,13 @@ struct _beathead_state UINT32 * vram_bulk_latch; UINT32 * palette_select; + + UINT32 finescroll; + offs_t vram_latch_offset; + + offs_t hsyncram_offset; + offs_t hsyncram_start; + UINT8 hsyncram[0x800]; }; diff --git a/src/mame/includes/foodf.h b/src/mame/includes/foodf.h index 6c4d42efea0..0428e13635c 100644 --- a/src/mame/includes/foodf.h +++ b/src/mame/includes/foodf.h @@ -16,7 +16,6 @@ struct _foodf_state double bweights[2]; UINT8 playfield_flip; - emu_timer * scanline_timer; UINT8 whichport; }; diff --git a/src/mame/includes/xybots.h b/src/mame/includes/xybots.h index f2086e1de41..37aac1e7d8f 100644 --- a/src/mame/includes/xybots.h +++ b/src/mame/includes/xybots.h @@ -11,7 +11,7 @@ struct _xybots_state { atarigen_state atarigen; - int h256; + UINT16 h256; }; diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c index 224e7bf0356..5191644d9c1 100644 --- a/src/mame/machine/atarigen.c +++ b/src/mame/machine/atarigen.c @@ -32,6 +32,8 @@ STATIC FUNCTION DECLARATIONS ***************************************************************************/ +static STATE_POSTLOAD( slapstic_postload ); + static TIMER_CALLBACK( scanline_interrupt_callback ); static void decompress_eeprom_word(UINT16 *dest, const UINT16 *data); @@ -54,6 +56,92 @@ static TIMER_CALLBACK( atarivc_eof_update ); +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ + +INLINE const atarigen_screen_timer *get_screen_timer(const device_config *screen) +{ + atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + int i; + + /* find the index of the timer that matches the screen */ + for (i = 0; i < ARRAY_LENGTH(state->screen_timer); i++) + if (state->screen_timer[i].screen == screen) + return &state->screen_timer[i]; + + fatalerror("Unexpected: no atarivc_eof_update_timer for screen '%s'\n", screen->tag); + return NULL; +} + + + +/*************************************************************************** + OVERALL INIT +***************************************************************************/ + +void atarigen_init(running_machine *machine) +{ + atarigen_state *state = (atarigen_state *)machine->driver_data; + const device_config *screen; + int i; + + /* allocate timers for all screens */ + assert(video_screen_count(machine->config) <= ARRAY_LENGTH(state->screen_timer)); + for (i = 0, screen = video_screen_first(machine->config); screen != NULL; i++, screen = video_screen_next(screen)) + { + state->screen_timer[i].screen = screen; + state->screen_timer[i].scanline_interrupt_timer = timer_alloc(machine, scanline_interrupt_callback, (void *)screen); + state->screen_timer[i].scanline_timer = timer_alloc(machine, scanline_timer_callback, (void *)screen); + state->screen_timer[i].atarivc_eof_update_timer = timer_alloc(machine, atarivc_eof_update, (void *)screen); + } + + state_save_register_global(machine, state->scanline_int_state); + state_save_register_global(machine, state->sound_int_state); + state_save_register_global(machine, state->video_int_state); + + state_save_register_global(machine, state->cpu_to_sound_ready); + state_save_register_global(machine, state->sound_to_cpu_ready); + + state_save_register_global(machine, state->atarivc_state.latch1); /* latch #1 value (-1 means disabled) */ + state_save_register_global(machine, state->atarivc_state.latch2); /* latch #2 value (-1 means disabled) */ + state_save_register_global(machine, state->atarivc_state.rowscroll_enable); /* true if row-scrolling is enabled */ + state_save_register_global(machine, state->atarivc_state.palette_bank); /* which palette bank is enabled */ + state_save_register_global(machine, state->atarivc_state.pf0_xscroll); /* playfield 1 xscroll */ + state_save_register_global(machine, state->atarivc_state.pf0_xscroll_raw); /* playfield 1 xscroll raw value */ + state_save_register_global(machine, state->atarivc_state.pf0_yscroll); /* playfield 1 yscroll */ + state_save_register_global(machine, state->atarivc_state.pf1_xscroll); /* playfield 2 xscroll */ + state_save_register_global(machine, state->atarivc_state.pf1_xscroll_raw); /* playfield 2 xscroll raw value */ + state_save_register_global(machine, state->atarivc_state.pf1_yscroll); /* playfield 2 yscroll */ + state_save_register_global(machine, state->atarivc_state.mo_xscroll); /* sprite xscroll */ + state_save_register_global(machine, state->atarivc_state.mo_yscroll); /* sprite xscroll */ + + state_save_register_global(machine, state->eeprom_unlocked); + + state_save_register_global(machine, state->slapstic_num); + state_save_register_global(machine, state->slapstic_bank); + state_save_register_global(machine, state->slapstic_last_pc); + state_save_register_global(machine, state->slapstic_last_address); + + state_save_register_global(machine, state->cpu_to_sound); + state_save_register_global(machine, state->sound_to_cpu); + state_save_register_global(machine, state->timed_int); + state_save_register_global(machine, state->ym2151_int); + + state_save_register_global(machine, state->scanlines_per_callback); + + state_save_register_global(machine, state->actual_vc_latch0); + state_save_register_global(machine, state->actual_vc_latch1); + + state_save_register_global(machine, state->playfield_latch); + state_save_register_global(machine, state->playfield2_latch); + + /* need a postload to reset the state */ + state_save_register_postload(machine, slapstic_postload, NULL); +} + + + /*************************************************************************** INTERRUPT HANDLING ***************************************************************************/ @@ -65,22 +153,11 @@ static TIMER_CALLBACK( atarivc_eof_update ); void atarigen_interrupt_reset(atarigen_state *state, atarigen_int_func update_int) { - int i; - /* set the callback */ state->update_int_callback = update_int; /* reset the interrupt states */ state->video_int_state = state->sound_int_state = state->scanline_int_state = 0; - - /* clear the timers */ - for (i = 0; i < ATARIMO_MAX; i++) - { - state->scanline_interrupt_timer_screens[i] = NULL; - state->scanline_interrupt_timers[i] = NULL; - state->scanline_timer_screens[i] = NULL; - state->scanline_timers[i] = NULL; - } } @@ -97,43 +174,6 @@ void atarigen_update_interrupts(running_machine *machine) } -/*--------------------------------------------------------------- - get_scanline_interrupt_timer_for_screen: Retrieves or - creates a scanline interrupt timer. ----------------------------------------------------------------*/ - -static emu_timer *get_scanline_interrupt_timer_for_screen(const device_config *screen) -{ - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; - int i; - - /* find the index of the timer that matches the screen */ - for (i = 0; i < ATARIMO_MAX; i++) - { - /* matching */ - if (state->scanline_interrupt_timer_screens[i] == screen) - break; - - /* no more */ - if (state->scanline_interrupt_timer_screens[i] == NULL) - break; - } - - /* check that we still have room */ - assert(i != ATARIMO_MAX); - - /* need to create? */ - if (state->scanline_interrupt_timer_screens[i] == NULL) - { - state->scanline_interrupt_timer_screens[i] = screen; - state->scanline_interrupt_timers[i] = timer_alloc(screen->machine, scanline_interrupt_callback, (void *)screen); - } - - /* found it */ - return state->scanline_interrupt_timers[i]; -} - - /*--------------------------------------------------------------- atarigen_scanline_int_set: Sets the scanline when the next scanline interrupt should be generated. @@ -141,7 +181,7 @@ static emu_timer *get_scanline_interrupt_timer_for_screen(const device_config *s void atarigen_scanline_int_set(const device_config *screen, int scanline) { - emu_timer *timer = get_scanline_interrupt_timer_for_screen(screen); + emu_timer *timer = get_screen_timer(screen)->scanline_interrupt_timer; timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, scanline, 0), 0); } @@ -252,7 +292,7 @@ WRITE32_HANDLER( atarigen_video_int_ack32_w ) static TIMER_CALLBACK( scanline_interrupt_callback ) { const device_config *screen = (const device_config *)ptr; - emu_timer *timer = get_scanline_interrupt_timer_for_screen(screen); + emu_timer *timer = get_screen_timer(screen)->scanline_interrupt_timer; /* generate the interrupt */ atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu")); @@ -879,43 +919,6 @@ void atarigen_set_oki6295_vol(running_machine *machine, int volume) SCANLINE TIMING ***************************************************************************/ -/*--------------------------------------------------------------- - get_scanline_timer_for_screen: Retrieves or - creates the the scanline timer. ----------------------------------------------------------------*/ - -static emu_timer *get_scanline_timer_for_screen(const device_config *screen) -{ - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; - int i; - - /* find the index of the timer that matches the screen */ - for (i = 0; i < ATARIMO_MAX; i++) - { - /* matching */ - if (state->scanline_timer_screens[i] == screen) - break; - - /* no more */ - if (state->scanline_timer_screens[i] == NULL) - break; - } - - /* check that we still have room */ - assert(i != ATARIMO_MAX); - - /* need to create? */ - if (state->scanline_timer_screens[i] == NULL) - { - state->scanline_timer_screens[i] = screen; - state->scanline_timers[i] = timer_alloc(screen->machine, scanline_timer_callback, (void *)screen); - } - - /* found it */ - return state->scanline_timers[i]; -} - - /*--------------------------------------------------------------- atarigen_scanline_timer_reset: Sets up the scanline timer. ---------------------------------------------------------------*/ @@ -931,13 +934,9 @@ void atarigen_scanline_timer_reset(const device_config *screen, atarigen_scanlin /* set a timer to go off at scanline 0 */ if (state->scanline_callback != NULL) { - emu_timer *timer = get_scanline_timer_for_screen(screen); + emu_timer *timer = get_screen_timer(screen)->scanline_timer; timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); } - - /* implicitly allocate a scanline interrupt timer */ - get_scanline_interrupt_timer_for_screen(screen); - } @@ -961,7 +960,7 @@ static TIMER_CALLBACK( scanline_timer_callback ) scanline += state->scanlines_per_callback; if (scanline >= video_screen_get_height(screen)) scanline = 0; - timer_adjust_oneshot(get_scanline_timer_for_screen(screen), video_screen_get_time_until_pos(screen, scanline, 0), scanline); + timer_adjust_oneshot(get_screen_timer(screen)->scanline_timer, video_screen_get_time_until_pos(screen, scanline, 0), scanline); } } @@ -971,43 +970,6 @@ static TIMER_CALLBACK( scanline_timer_callback ) VIDEO CONTROLLER ***************************************************************************/ -/*--------------------------------------------------------------- - get_scanline_timer_for_screen: Retrieves or - creates the the scanline timer. ----------------------------------------------------------------*/ - -static emu_timer *get_atarivc_eof_update_timer_for_screen(const device_config *screen) -{ - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; - int i; - - /* find the index of the timer that matches the screen */ - for (i = 0; i < ATARIMO_MAX; i++) - { - /* matching */ - if (state->atarivc_eof_update_timer_screens[i] == screen) - break; - - /* no more */ - if (state->atarivc_eof_update_timer_screens[i] == NULL) - break; - } - - /* check that we still have room */ - assert(i != ATARIMO_MAX); - - /* need to create? */ - if (state->atarivc_eof_update_timer_screens[i] == NULL) - { - state->atarivc_eof_update_timer_screens[i] = screen; - state->atarivc_eof_update_timers[i] = timer_alloc(screen->machine, atarivc_eof_update, (void *)screen); - } - - /* found it */ - return state->atarivc_eof_update_timers[i]; -} - - /*--------------------------------------------------------------- atarivc_eof_update: Callback that slurps up data and feeds it into the video controller registers every refresh. @@ -1017,7 +979,7 @@ static TIMER_CALLBACK( atarivc_eof_update ) { atarigen_state *state = (atarigen_state *)machine->driver_data; const device_config *screen = (const device_config *)ptr; - emu_timer *timer = get_atarivc_eof_update_timer_for_screen(screen); + emu_timer *timer = get_screen_timer(screen)->atarivc_eof_update_timer; int i; /* echo all the commands to the video controller */ @@ -1063,7 +1025,6 @@ static TIMER_CALLBACK( atarivc_eof_update ) void atarivc_reset(const device_config *screen, UINT16 *eof_data, int playfields) { atarigen_state *state = (atarigen_state *)screen->machine->driver_data; - int i; /* this allows us to manually reset eof_data to NULL if it's not used */ state->atarivc_eof_data = eof_data; @@ -1077,17 +1038,10 @@ void atarivc_reset(const device_config *screen, UINT16 *eof_data, int playfields state->atarivc_state.latch1 = state->atarivc_state.latch2 = -1; state->actual_vc_latch0 = state->actual_vc_latch1 = -1; - /* clear the timers */ - for (i = 0; i < ATARIMO_MAX; i++) - { - state->atarivc_eof_update_timer_screens[i] = NULL; - state->atarivc_eof_update_timers[i] = NULL; - } - /* start a timer to go off a little before scanline 0 */ if (state->atarivc_eof_data) { - emu_timer *timer = get_atarivc_eof_update_timer_for_screen(screen); + emu_timer *timer = get_screen_timer(screen)->atarivc_eof_update_timer; timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); } } @@ -1637,56 +1591,3 @@ void atarigen_blend_gfx(running_machine *machine, int gfx0, int gfx1, int mask0, /* make the assembled data our new source data */ gfx_element_set_source(gx0, srcdata); } - - -/*************************************************************************** - SAVE STATE -***************************************************************************/ - -void atarigen_init_save_state(running_machine *machine) -{ - atarigen_state *state = (atarigen_state *)machine->driver_data; - - state_save_register_global(machine, state->scanline_int_state); - state_save_register_global(machine, state->sound_int_state); - state_save_register_global(machine, state->video_int_state); - - state_save_register_global(machine, state->cpu_to_sound_ready); - state_save_register_global(machine, state->sound_to_cpu_ready); - - state_save_register_global(machine, state->atarivc_state.latch1); /* latch #1 value (-1 means disabled) */ - state_save_register_global(machine, state->atarivc_state.latch2); /* latch #2 value (-1 means disabled) */ - state_save_register_global(machine, state->atarivc_state.rowscroll_enable); /* true if row-scrolling is enabled */ - state_save_register_global(machine, state->atarivc_state.palette_bank); /* which palette bank is enabled */ - state_save_register_global(machine, state->atarivc_state.pf0_xscroll); /* playfield 1 xscroll */ - state_save_register_global(machine, state->atarivc_state.pf0_xscroll_raw); /* playfield 1 xscroll raw value */ - state_save_register_global(machine, state->atarivc_state.pf0_yscroll); /* playfield 1 yscroll */ - state_save_register_global(machine, state->atarivc_state.pf1_xscroll); /* playfield 2 xscroll */ - state_save_register_global(machine, state->atarivc_state.pf1_xscroll_raw); /* playfield 2 xscroll raw value */ - state_save_register_global(machine, state->atarivc_state.pf1_yscroll); /* playfield 2 yscroll */ - state_save_register_global(machine, state->atarivc_state.mo_xscroll); /* sprite xscroll */ - state_save_register_global(machine, state->atarivc_state.mo_yscroll); /* sprite xscroll */ - - state_save_register_global(machine, state->eeprom_unlocked); - - state_save_register_global(machine, state->slapstic_num); - state_save_register_global(machine, state->slapstic_bank); - state_save_register_global(machine, state->slapstic_last_pc); - state_save_register_global(machine, state->slapstic_last_address); - - state_save_register_global(machine, state->cpu_to_sound); - state_save_register_global(machine, state->sound_to_cpu); - state_save_register_global(machine, state->timed_int); - state_save_register_global(machine, state->ym2151_int); - - state_save_register_global(machine, state->scanlines_per_callback); - - state_save_register_global(machine, state->actual_vc_latch0); - state_save_register_global(machine, state->actual_vc_latch1); - - state_save_register_global(machine, state->playfield_latch); - state_save_register_global(machine, state->playfield2_latch); - - /* need a postload to reset the state */ - state_save_register_postload(machine, slapstic_postload, NULL); -} diff --git a/src/mame/machine/atarigen.h b/src/mame/machine/atarigen.h index faf1187028f..9bedc2b6b7b 100644 --- a/src/mame/machine/atarigen.h +++ b/src/mame/machine/atarigen.h @@ -32,7 +32,8 @@ typedef void (*atarigen_int_func)(running_machine *machine); typedef void (*atarigen_scanline_func)(const device_config *screen, int scanline); -struct atarivc_state_desc +typedef struct _atarivc_state_desc atarivc_state_desc; +struct _atarivc_state_desc { UINT32 latch1; /* latch #1 value (-1 means disabled) */ UINT32 latch2; /* latch #2 value (-1 means disabled) */ @@ -49,6 +50,16 @@ struct atarivc_state_desc }; +typedef struct _atarigen_screen_timer atarigen_screen_timer; +struct _atarigen_screen_timer +{ + const device_config *screen; + emu_timer * scanline_interrupt_timer; + emu_timer * scanline_timer; + emu_timer * atarivc_eof_update_timer; +}; + + typedef struct _atarigen_state atarigen_state; struct _atarigen_state { @@ -81,7 +92,7 @@ struct _atarigen_state UINT16 * atarivc_data; UINT16 * atarivc_eof_data; - struct atarivc_state_desc atarivc_state; + atarivc_state_desc atarivc_state; /* internal state */ atarigen_int_func update_int_callback; @@ -113,14 +124,7 @@ struct _atarigen_state UINT32 playfield_latch; UINT32 playfield2_latch; - const device_config * scanline_interrupt_timer_screens[ATARIMO_MAX]; - emu_timer * scanline_interrupt_timers[ATARIMO_MAX]; - - const device_config * scanline_timer_screens[ATARIMO_MAX]; - emu_timer * scanline_timers[ATARIMO_MAX]; - - const device_config * atarivc_eof_update_timer_screens[ATARIMO_MAX]; - emu_timer * atarivc_eof_update_timers[ATARIMO_MAX]; + atarigen_screen_timer screen_timer[2]; }; @@ -129,6 +133,13 @@ struct _atarigen_state FUNCTION PROTOTYPES ***************************************************************************/ +/*--------------------------------------------------------------- + OVERALL INIT +---------------------------------------------------------------*/ + +void atarigen_init(running_machine *machine); + + /*--------------------------------------------------------------- INTERRUPT HANDLING ---------------------------------------------------------------*/ @@ -272,11 +283,6 @@ void atarigen_swap_mem(void *ptr1, void *ptr2, int bytes); void atarigen_blend_gfx(running_machine *machine, int gfx0, int gfx1, int mask0, int mask1); -/*--------------------------------------------------------------- - STATE SAVE ----------------------------------------------------------------*/ - -void atarigen_init_save_state(running_machine *machine); /*************************************************************************** GENERAL ATARI NOTES diff --git a/src/mame/machine/harddriv.c b/src/mame/machine/harddriv.c index 4799000921c..a1f238d9bd3 100644 --- a/src/mame/machine/harddriv.c +++ b/src/mame/machine/harddriv.c @@ -55,6 +55,8 @@ static void hd68k_update_interrupts(running_machine *machine); MACHINE_START( harddriv ) { harddriv_state *state = (harddriv_state *)machine->driver_data; + + atarigen_init(machine); /* predetermine memory regions */ state->sim_memory = (UINT16 *)memory_region(machine, "user1"); diff --git a/src/mame/video/atarig42.c b/src/mame/video/atarig42.c index 3d3888228da..22d942dd748 100644 --- a/src/mame/video/atarig42.c +++ b/src/mame/video/atarig42.c @@ -25,14 +25,6 @@ -/************************************* - * - * Statics - * - *************************************/ - - - /************************************* * * Tilemap callbacks @@ -116,6 +108,13 @@ VIDEO_START( atarig42 ) /* initialize the alphanumerics */ state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); + + /* save states */ + state_save_register_global(machine, state->current_control); + state_save_register_global(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->playfield_color_bank); + state_save_register_global(machine, state->playfield_xscroll); + state_save_register_global(machine, state->playfield_yscroll); } diff --git a/src/mame/video/atarigt.c b/src/mame/video/atarigt.c index d97e7695778..a0067d6b902 100644 --- a/src/mame/video/atarigt.c +++ b/src/mame/video/atarigt.c @@ -130,6 +130,14 @@ VIDEO_START( atarigt ) /* reset statics */ memset(state->colorram, 0, 0x80000); + + /* save states */ + state_save_register_global(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->playfield_color_bank); + state_save_register_global(machine, state->playfield_xscroll); + state_save_register_global(machine, state->playfield_yscroll); + state_save_register_global(machine, state->tram_checksum); + state_save_register_global_array(machine, state->expanded_mram); } diff --git a/src/mame/video/atarigx2.c b/src/mame/video/atarigx2.c index ea4b5cfc940..140e92cee63 100644 --- a/src/mame/video/atarigx2.c +++ b/src/mame/video/atarigx2.c @@ -108,6 +108,13 @@ VIDEO_START( atarigx2 ) /* initialize the alphanumerics */ state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); + + /* save states */ + state_save_register_global(machine, state->current_control); + state_save_register_global(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->playfield_color_bank); + state_save_register_global(machine, state->playfield_xscroll); + state_save_register_global(machine, state->playfield_yscroll); } diff --git a/src/mame/video/atarisy1.c b/src/mame/video/atarisy1.c index cf1a1ddceb0..7cd8127aa9d 100644 --- a/src/mame/video/atarisy1.c +++ b/src/mame/video/atarisy1.c @@ -82,9 +82,6 @@ static const gfx_layout objlayout_6bpp = static void update_timers(running_machine *machine, int scanline); static void decode_gfx(running_machine *machine, UINT16 *pflookup, UINT16 *molookup); static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp); -static TIMER_CALLBACK( int3_callback ); -static TIMER_CALLBACK( int3off_callback ); -static TIMER_CALLBACK( reset_yscroll_callback ); @@ -199,9 +196,14 @@ VIDEO_START( atarisy1 ) /* reset the statics */ atarimo_set_yscroll(0, 256); state->next_timer_scanline = -1; - state->scanline_timer = timer_alloc(machine, int3_callback, NULL); - state->int3off_timer = timer_alloc(machine, int3off_callback, NULL); - state->yscroll_reset_timer = timer_alloc(machine, reset_yscroll_callback, NULL); + state->scanline_timer = devtag_get_device(machine, "scan_timer"); + state->int3off_timer = devtag_get_device(machine, "int3off_timer"); + state->yscroll_reset_timer = devtag_get_device(machine, "yreset_timer"); + + /* save state */ + state_save_register_global(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->playfield_priority_pens); + state_save_register_global(machine, state->next_timer_scanline); } @@ -304,9 +306,9 @@ WRITE16_HANDLER( atarisy1_xscroll_w ) * *************************************/ -static TIMER_CALLBACK( reset_yscroll_callback ) +TIMER_DEVICE_CALLBACK( atarisy1_reset_yscroll_callback ) { - atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data; tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, param); } @@ -332,7 +334,7 @@ WRITE16_HANDLER( atarisy1_yscroll_w ) /* but since we've adjusted it, we must reset it to the normal value once we hit scanline 0 again */ - timer_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll); + timer_device_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll); /* update the data */ *state->atarigen.yscroll = newscroll; @@ -385,29 +387,29 @@ WRITE16_HANDLER( atarisy1_spriteram_w ) * *************************************/ -static TIMER_CALLBACK( int3off_callback ) +TIMER_DEVICE_CALLBACK( atarisy1_int3off_callback ) { - const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); + const address_space *space = cputag_get_address_space(timer->machine, "maincpu", ADDRESS_SPACE_PROGRAM); /* clear the state */ atarigen_scanline_int_ack_w(space, 0, 0, 0xffff); } -static TIMER_CALLBACK( int3_callback ) +TIMER_DEVICE_CALLBACK( atarisy1_int3_callback ) { - atarisy1_state *state = (atarisy1_state *)machine->driver_data; + atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data; int scanline = param; /* update the state */ - atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu")); + atarigen_scanline_int_gen(cputag_get_cpu(timer->machine, "maincpu")); /* set a timer to turn it off */ - timer_adjust_oneshot(state->int3off_timer, video_screen_get_scan_period(machine->primary_screen), 0); + timer_device_adjust_oneshot(state->int3off_timer, video_screen_get_scan_period(timer->machine->primary_screen), 0); /* determine the time of the next one */ state->next_timer_scanline = -1; - update_timers(machine, scanline); + update_timers(timer->machine, scanline); } @@ -484,9 +486,9 @@ static void update_timers(running_machine *machine, int scanline) /* set a new one */ if (best != -1) - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, best, 0), best); + timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, best, 0), best); else - timer_adjust_oneshot(state->scanline_timer, attotime_never, 0); + timer_device_adjust_oneshot(state->scanline_timer, attotime_never, 0); } } diff --git a/src/mame/video/badlands.c b/src/mame/video/badlands.c index 5a95b987810..fd2d0346fff 100644 --- a/src/mame/video/badlands.c +++ b/src/mame/video/badlands.c @@ -77,6 +77,9 @@ VIDEO_START( badlands ) /* initialize the motion objects */ atarimo_init(machine, 0, &modesc); + + /* save states */ + state_save_register_global(machine, state->playfield_tile_bank); } diff --git a/src/mame/video/beathead.c b/src/mame/video/beathead.c index 217ab5b85f4..dac8bd8d474 100644 --- a/src/mame/video/beathead.c +++ b/src/mame/video/beathead.c @@ -9,21 +9,6 @@ -/************************************* - * - * Statics - * - *************************************/ - -static UINT32 finescroll; -static offs_t vram_latch_offset; - -static offs_t hsyncram_offset; -static offs_t hsyncram_start; -static UINT8 * hsyncram; - - - /************************************* * * Video start/stop @@ -32,7 +17,12 @@ static UINT8 * hsyncram; VIDEO_START( beathead ) { - hsyncram = auto_alloc_array(machine, UINT8, 0x800); + beathead_state *state = (beathead_state *)machine->driver_data; + state_save_register_global(machine, state->finescroll); + state_save_register_global(machine, state->vram_latch_offset); + state_save_register_global(machine, state->hsyncram_offset); + state_save_register_global(machine, state->hsyncram_start); + state_save_register_global_array(machine, state->hsyncram); } @@ -77,15 +67,17 @@ WRITE32_HANDLER( beathead_vram_bulk_w ) WRITE32_HANDLER( beathead_vram_latch_w ) { /* latch the address */ - vram_latch_offset = (4 * offset) & 0x7ffff; + beathead_state *state = (beathead_state *)space->machine->driver_data; + state->vram_latch_offset = (4 * offset) & 0x7ffff; } WRITE32_HANDLER( beathead_vram_copy_w ) { /* copy from VRAM to VRAM, for 1024 bytes */ + beathead_state *state = (beathead_state *)space->machine->driver_data; offs_t dest_offset = (4 * offset) & 0x7ffff; - memcpy(&space->machine->generic.videoram.u32[dest_offset / 4], &space->machine->generic.videoram.u32[vram_latch_offset / 4], 0x400); + memcpy(&space->machine->generic.videoram.u32[dest_offset / 4], &space->machine->generic.videoram.u32[state->vram_latch_offset / 4], 0x400); } @@ -98,8 +90,9 @@ WRITE32_HANDLER( beathead_vram_copy_w ) WRITE32_HANDLER( beathead_finescroll_w ) { - UINT32 oldword = finescroll; - UINT32 newword = COMBINE_DATA(&finescroll); + beathead_state *state = (beathead_state *)space->machine->driver_data; + UINT32 oldword = state->finescroll; + UINT32 newword = COMBINE_DATA(&state->finescroll); /* if VBLANK is going off on a scanline other than the last, suspend time */ if ((oldword & 8) && !(newword & 8) && video_screen_get_vpos(space->machine->primary_screen) != 261) @@ -136,30 +129,34 @@ WRITE32_HANDLER( beathead_palette_w ) READ32_HANDLER( beathead_hsync_ram_r ) { + beathead_state *state = (beathead_state *)space->machine->driver_data; + /* offset 0 is probably write-only */ if (offset == 0) logerror("%08X:Unexpected HSYNC RAM read at offset 0\n", cpu_get_previouspc(space->cpu)); /* offset 1 reads the data */ else - return hsyncram[hsyncram_offset]; + return state->hsyncram[state->hsyncram_offset]; return 0; } WRITE32_HANDLER( beathead_hsync_ram_w ) { + beathead_state *state = (beathead_state *)space->machine->driver_data; + /* offset 0 selects the address, and can specify the start address */ if (offset == 0) { - COMBINE_DATA(&hsyncram_offset); - if (hsyncram_offset & 0x800) - hsyncram_start = hsyncram_offset & 0x7ff; + COMBINE_DATA(&state->hsyncram_offset); + if (state->hsyncram_offset & 0x800) + state->hsyncram_start = state->hsyncram_offset & 0x7ff; } /* offset 1 writes the data */ else - COMBINE_DATA(&hsyncram[hsyncram_offset]); + COMBINE_DATA(&state->hsyncram[state->hsyncram_offset]); } @@ -183,14 +180,14 @@ VIDEO_UPDATE( beathead ) UINT16 scanline[336]; /* blanking */ - if (finescroll & 8) + if (state->finescroll & 8) for (x = cliprect->min_x; x <= cliprect->max_x; x++) scanline[x] = pen_base; /* non-blanking */ else { - offs_t scanline_offset = vram_latch_offset + (finescroll & 3); + offs_t scanline_offset = state->vram_latch_offset + (state->finescroll & 3); offs_t src = scanline_offset + cliprect->min_x; /* unswizzle the scanline first */ diff --git a/src/mame/video/cyberbal.c b/src/mame/video/cyberbal.c index 129c61acf6d..479492ae49b 100644 --- a/src/mame/video/cyberbal.c +++ b/src/mame/video/cyberbal.c @@ -172,6 +172,12 @@ static void video_start_cyberbal_common(running_machine* machine, int screens) tilemap_set_scrollx(state->atarigen.alpha2_tilemap, 0, 0); tilemap_set_transparent_pen(state->atarigen.alpha2_tilemap, 0); } + + /* save states */ + state_save_register_global_array(machine, state->current_slip); + state_save_register_global_array(machine, state->playfield_palette_bank); + state_save_register_global_array(machine, state->playfield_xscroll); + state_save_register_global_array(machine, state->playfield_yscroll); } diff --git a/src/mame/video/eprom.c b/src/mame/video/eprom.c index 3cf16c50c98..f33840b19dd 100644 --- a/src/mame/video/eprom.c +++ b/src/mame/video/eprom.c @@ -140,6 +140,10 @@ VIDEO_START( eprom ) /* initialize the alphanumerics */ state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); + + /* save states */ + state_save_register_global(machine, state->screen_intensity); + state_save_register_global(machine, state->video_disable); } @@ -192,6 +196,10 @@ VIDEO_START( guts ) /* initialize the alphanumerics */ state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); + + /* save states */ + state_save_register_global(machine, state->screen_intensity); + state_save_register_global(machine, state->video_disable); } diff --git a/src/mame/video/gauntlet.c b/src/mame/video/gauntlet.c index ab83bad37e7..62841ee5131 100644 --- a/src/mame/video/gauntlet.c +++ b/src/mame/video/gauntlet.c @@ -104,6 +104,10 @@ VIDEO_START( gauntlet ) /* set up the base color for the playfield */ state->playfield_color_bank = state->vindctr2_screen_refresh ? 0 : 1; + + /* save states */ + state_save_register_global(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->playfield_color_bank); } diff --git a/src/mame/video/toobin.c b/src/mame/video/toobin.c index 32d43543f4d..c910c1bfdb2 100644 --- a/src/mame/video/toobin.c +++ b/src/mame/video/toobin.c @@ -97,6 +97,8 @@ VIDEO_START( toobin ) /* allocate a playfield bitmap for rendering */ state->pfbitmap = auto_bitmap_alloc(machine, video_screen_get_width(machine->primary_screen), video_screen_get_height(machine->primary_screen), BITMAP_FORMAT_INDEXED16); + + state_save_register_global(machine, state->brightness); } diff --git a/src/mame/video/vindictr.c b/src/mame/video/vindictr.c index 412f4a9a89d..938893c5d31 100644 --- a/src/mame/video/vindictr.c +++ b/src/mame/video/vindictr.c @@ -93,6 +93,11 @@ VIDEO_START( vindictr ) /* initialize the alphanumerics */ state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); + + /* save states */ + state_save_register_global(machine, state->playfield_tile_bank); + state_save_register_global(machine, state->playfield_xscroll); + state_save_register_global(machine, state->playfield_yscroll); }