diff --git a/src/mame/drivers/toaplan1.c b/src/mame/drivers/toaplan1.c index 4f9cafd7458..b136f9fa375 100644 --- a/src/mame/drivers/toaplan1.c +++ b/src/mame/drivers/toaplan1.c @@ -353,7 +353,7 @@ static ADDRESS_MAP_START( rallybik_main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x00ffff) AM_ROM AM_RANGE(0x040000, 0x07ffff) AM_ROM AM_RANGE(0x080000, 0x083fff) AM_RAM - AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM AM_BASE_SIZE_MEMBER(toaplan1_state, spriteram, spriteram_size) AM_RANGE(0x100000, 0x100001) AM_WRITE(rallybik_bcu_flipscreen_w) AM_RANGE(0x100002, 0x100003) AM_READWRITE(toaplan1_tileram_offs_r, toaplan1_tileram_offs_w) AM_RANGE(0x100004, 0x100007) AM_READWRITE(rallybik_tileram16_r, toaplan1_tileram16_w) @@ -362,8 +362,8 @@ static ADDRESS_MAP_START( rallybik_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x140000, 0x140001) AM_WRITE(?? video frame related ??) AM_RANGE(0x140002, 0x140003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x140008, 0x14000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x144000, 0x1447ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x146000, 0x1467ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x144000, 0x1447ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x146000, 0x1467ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x180000, 0x180fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w) AM_RANGE(0x1c0000, 0x1c0003) AM_WRITE(toaplan1_tile_offsets_w) AM_RANGE(0x1c8000, 0x1c8001) AM_WRITE(toaplan1_reset_sound) @@ -384,8 +384,8 @@ static ADDRESS_MAP_START( truxton_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x140000, 0x140001) AM_WRITE(?? video frame related ??) AM_RANGE(0x140002, 0x140003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x140008, 0x14000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x144000, 0x1447ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x146000, 0x1467ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x144000, 0x1447ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x146000, 0x1467ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x180000, 0x180fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w) AM_RANGE(0x1c0000, 0x1c0003) AM_WRITE(toaplan1_tile_offsets_w) AM_RANGE(0x1c0006, 0x1c0007) AM_WRITE(toaplan1_fcu_flipscreen_w) @@ -399,8 +399,8 @@ static ADDRESS_MAP_START( hellfire_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x080000, 0x080001) AM_WRITE(?? video frame related ??) AM_RANGE(0x080002, 0x080003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x080008, 0x08000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x084000, 0x0847ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x086000, 0x0867ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x084000, 0x0847ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x086000, 0x0867ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x0c0000, 0x0c0fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w) AM_RANGE(0x100000, 0x100001) AM_WRITE(toaplan1_bcu_flipscreen_w) AM_RANGE(0x100002, 0x100003) AM_READWRITE(toaplan1_tileram_offs_r, toaplan1_tileram_offs_w) @@ -425,8 +425,8 @@ static ADDRESS_MAP_START( zerowing_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x400000, 0x400001) AM_WRITE(?? video frame related ??) AM_RANGE(0x400002, 0x400003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x400008, 0x40000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x440000, 0x440fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w) AM_RANGE(0x480000, 0x480001) AM_WRITE(toaplan1_bcu_flipscreen_w) AM_RANGE(0x480002, 0x480003) AM_READWRITE(toaplan1_tileram_offs_r, toaplan1_tileram_offs_w) @@ -444,8 +444,8 @@ static ADDRESS_MAP_START( demonwld_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x400000, 0x400001) AM_WRITE(?? video frame related ??) AM_RANGE(0x400002, 0x400003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x400008, 0x40000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x600000, 0x600fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w) AM_RANGE(0x800000, 0x800001) AM_WRITE(toaplan1_bcu_flipscreen_w) AM_RANGE(0x800002, 0x800003) AM_READWRITE(toaplan1_tileram_offs_r, toaplan1_tileram_offs_w) @@ -472,8 +472,8 @@ static ADDRESS_MAP_START( samesame_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x100000, 0x100001) AM_WRITE(?? video frame related ??) AM_RANGE(0x100002, 0x100003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x100008, 0x10000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x104000, 0x1047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x106000, 0x1067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x104000, 0x1047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x106000, 0x1067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x140000, 0x140001) AM_READ_PORT("P1") AM_RANGE(0x140002, 0x140003) AM_READ_PORT("P2") AM_RANGE(0x140004, 0x140005) AM_READ_PORT("DSWA") @@ -509,8 +509,8 @@ static ADDRESS_MAP_START( outzone_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x300000, 0x300001) AM_WRITE(?? video frame related ??) AM_RANGE(0x300002, 0x300003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x300008, 0x30000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x304000, 0x3047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x306000, 0x3067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x304000, 0x3047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x306000, 0x3067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x340000, 0x340003) AM_WRITE(toaplan1_tile_offsets_w) AM_RANGE(0x340006, 0x340007) AM_WRITE(toaplan1_fcu_flipscreen_w) ADDRESS_MAP_END @@ -527,8 +527,8 @@ static ADDRESS_MAP_START( vimana_main_map, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x400000, 0x400001) AM_WRITE(?? video frame related ??) AM_RANGE(0x400002, 0x400003) AM_WRITE(toaplan1_intenable_w) AM_RANGE(0x400008, 0x40000f) AM_WRITE(toaplan1_bcu_control_w) - AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE(&toaplan1_colorram1) AM_SIZE(&toaplan1_colorram1_size) - AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE(&toaplan1_colorram2) AM_SIZE(&toaplan1_colorram2_size) + AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram1, colorram1_size) + AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_BASE_SIZE_MEMBER(toaplan1_state, colorram2, colorram2_size) AM_RANGE(0x440000, 0x440005) AM_READWRITE(vimana_mcu_r, vimana_mcu_w) /* shared memory from 0x440000 to 0x44ffff ? */ AM_RANGE(0x440006, 0x440007) AM_READ_PORT("DSWA") AM_RANGE(0x440008, 0x440009) AM_READ(vimana_system_port_r) /* "SYSTEM" + coinage simulation */ @@ -548,7 +548,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( toaplan1_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE(&toaplan1_sharedram) + AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE_MEMBER(toaplan1_state, sharedram) ADDRESS_MAP_END static ADDRESS_MAP_START( rallybik_sound_io_map, ADDRESS_SPACE_IO, 8 ) @@ -1512,6 +1512,8 @@ static const ym3812_interface ym3812_config = static MACHINE_DRIVER_START( rallybik ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) MDRV_CPU_PROGRAM_MAP(rallybik_main_map) @@ -1526,7 +1528,7 @@ static MACHINE_DRIVER_START( rallybik ) MDRV_MACHINE_RESET(toaplan1) /* video hardware */ - MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_BUFFERS_SPRITERAM) + MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(55.14) /* verified on pcb */ @@ -1552,6 +1554,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( truxton ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) MDRV_CPU_PROGRAM_MAP(truxton_main_map) @@ -1592,6 +1596,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( hellfire ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) MDRV_CPU_PROGRAM_MAP(hellfire_main_map) @@ -1632,6 +1638,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( zerowing ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) MDRV_CPU_PROGRAM_MAP(zerowing_main_map) @@ -1672,6 +1680,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( demonwld ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) MDRV_CPU_PROGRAM_MAP(demonwld_main_map) @@ -1716,6 +1726,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( samesame ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) MDRV_CPU_PROGRAM_MAP(samesame_main_map) @@ -1754,6 +1766,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( outzone ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) MDRV_CPU_PROGRAM_MAP(outzone_main_map) @@ -1794,6 +1808,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( vimana ) + MDRV_DRIVER_DATA( toaplan1_state ) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(vimana_main_map) diff --git a/src/mame/drivers/toaplan2.c b/src/mame/drivers/toaplan2.c index 692d65c7798..1476b43267c 100644 --- a/src/mame/drivers/toaplan2.c +++ b/src/mame/drivers/toaplan2.c @@ -262,31 +262,6 @@ To Do / Unknowns: #include "includes/toaplan2.h" #include "rendlay.h" -/************ Machine RAM related values ************/ -static UINT8 *z80_shared_ram; -static UINT16 *toaplan2_shared_ram16; /* Really 8bit RAM connected to Z180 */ -#ifndef USE_ENCRYPTED_V25S -static UINT16 *V25_shared_ram; /* Really 8bit RAM connected to Z180 */ -#endif - -static UINT8* batsugun_share; -#ifdef USE_ENCRYPTED_V25S -static UINT8* batsugun_share2; -#endif - -/********** Status related values **********/ -int toaplan2_sub_cpu = 0; -static running_device *sub_cpu = NULL; - -static UINT16 mcu_data = 0; -static UINT16 video_status; -static INT8 old_p1_paddle_h; /* For Ghox */ -static INT8 old_p2_paddle_h; -static INT8 current_bank; /* Z80 bank used in Battle Garegga and Batrider */ -static int raizing_sndirq_line; /* IRQ4 for batrider, IRQ2 for bbakraid */ -static UINT16 raizing_Z80_busreq; -static int bbakraid_unlimited_ver; - static MACHINE_RESET(batsugun); static READ16_HANDLER( batsugun_share_r ); static WRITE16_HANDLER( batsugun_share_w ); @@ -301,14 +276,17 @@ static WRITE16_HANDLER( batsugun_share2_w ); static void toaplan2_reset(running_device *device) { - if (sub_cpu != NULL) - cpu_set_input_line(sub_cpu, INPUT_LINE_RESET, PULSE_LINE); -} + toaplan2_state *state = device->machine->driver_data(); + if (state->sub_cpu != NULL) + cpu_set_input_line(state->sub_cpu, INPUT_LINE_RESET, PULSE_LINE); +} static MACHINE_RESET( toaplan2 ) { - mcu_data = 0x00; + toaplan2_state *state = machine->driver_data(); + + state->mcu_data = 0x00; /* All games execute a RESET instruction on init, presumably to reset the sound CPU. @@ -320,29 +298,36 @@ static MACHINE_RESET( toaplan2 ) static MACHINE_RESET( ghox ) { + toaplan2_state *state = machine->driver_data(); + MACHINE_RESET_CALL(toaplan2); - old_p1_paddle_h = 0; - old_p2_paddle_h = 0; + state->old_p1_paddle_h = 0; + state->old_p2_paddle_h = 0; } static MACHINE_RESET( dogyuun ) { + toaplan2_state *state = machine->driver_data(); + MACHINE_RESET_CALL(batsugun); - mcu_data = 0xffaa; + state->mcu_data = 0xffaa; } static MACHINE_RESET( vfive ) { + toaplan2_state *state = machine->driver_data(); + MACHINE_RESET_CALL(batsugun); - mcu_data = 0xffaa; + state->mcu_data = 0xffaa; } static MACHINE_RESET( bgaregga ) { + toaplan2_state *state = machine->driver_data(); UINT8 *Z80 = (UINT8 *)memory_region(machine, "audiocpu"); // Set Z80 bank switch - default bank is 2 - current_bank = 4; + state->current_bank = 4; memory_configure_bank(machine, "bank1", 0, 16, Z80, 0x4000); memory_set_bank(machine, "bank1", 4); @@ -351,49 +336,61 @@ static MACHINE_RESET( bgaregga ) static void register_state_save(running_machine *machine) { - state_save_register_global(machine, mcu_data); - state_save_register_global(machine, video_status); - state_save_register_global(machine, old_p1_paddle_h); - state_save_register_global(machine, old_p2_paddle_h); - state_save_register_global(machine, current_bank); - state_save_register_global(machine, raizing_Z80_busreq); + toaplan2_state *state = machine->driver_data(); + + state_save_register_global(machine, state->mcu_data); + state_save_register_global(machine, state->video_status); + state_save_register_global(machine, state->old_p1_paddle_h); + state_save_register_global(machine, state->old_p2_paddle_h); + state_save_register_global(machine, state->current_bank); + state_save_register_global(machine, state->z80_busreq); } static DRIVER_INIT( T2_Z80 ) /* init_t2_Z80(); */ { - toaplan2_sub_cpu = CPU_2_Z80; - sub_cpu = machine->device("audiocpu"); + toaplan2_state *state = machine->driver_data(); + + state->sub_cpu_type = CPU_2_Z80; + state->sub_cpu = machine->device("audiocpu"); register_state_save(machine); } static DRIVER_INIT( T2_Z180 ) { - toaplan2_sub_cpu = CPU_2_HD647180; - sub_cpu = machine->device("mcu"); + toaplan2_state *state = machine->driver_data(); + + state->sub_cpu_type = CPU_2_HD647180; + state->sub_cpu = machine->device("mcu"); register_state_save(machine); } static DRIVER_INIT( T2_V25 ) { - toaplan2_sub_cpu = CPU_2_V25; + toaplan2_state *state = machine->driver_data(); + + state->sub_cpu_type = CPU_2_V25; if (machine->device("mcu") != NULL) - sub_cpu = machine->device("mcu"); + state->sub_cpu = machine->device("mcu"); else if (machine->device("audiocpu") != NULL) - sub_cpu = machine->device("audiocpu"); + state->sub_cpu = machine->device("audiocpu"); register_state_save(machine); } static DRIVER_INIT( T2_noZ80 ) { - toaplan2_sub_cpu = CPU_2_NONE; - sub_cpu = NULL; + toaplan2_state *state = machine->driver_data(); + + state->sub_cpu_type = CPU_2_NONE; + state->sub_cpu = NULL; register_state_save(machine); } static DRIVER_INIT( fixeight ) { - toaplan2_sub_cpu = CPU_2_V25; - sub_cpu = machine->device("audiocpu"); + toaplan2_state *state = machine->driver_data(); + + state->sub_cpu_type = CPU_2_V25; + state->sub_cpu = machine->device("audiocpu"); memory_install_ram(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x28f002, 0x28fbff, 0, 0, NULL); @@ -402,19 +399,20 @@ static DRIVER_INIT( fixeight ) static DRIVER_INIT( fixeighb ) { + toaplan2_state *state = machine->driver_data(); UINT16 *bgdata = (UINT16 *)memory_region(machine, "maincpu"); - memory_set_bankptr(machine, "bank1", &bgdata[0x40000]); /* $80000 - $fffff */ - toaplan2_sub_cpu = CPU_2_NONE; - sub_cpu = NULL; + memory_set_bankptr(machine, "bank1", &bgdata[0x40000]); /* $80000 - $fffff */ + state->sub_cpu_type = CPU_2_NONE; + state->sub_cpu = NULL; register_state_save(machine); } static DRIVER_INIT( pipibibi ) { + toaplan2_state *state = machine->driver_data(); int A; int oldword, newword; - UINT16 *pipibibi_68k_rom = (UINT16 *)(memory_region(machine, "maincpu")); /* unscramble the 68K ROM data. */ @@ -488,34 +486,40 @@ static DRIVER_INIT( pipibibi ) pipibibi_68k_rom[A+3] = newword; } - toaplan2_sub_cpu = CPU_2_Z80; - sub_cpu = machine->device("audiocpu"); + state->sub_cpu_type = CPU_2_Z80; + state->sub_cpu = machine->device("audiocpu"); register_state_save(machine); } static DRIVER_INIT( batrider ) { - raizing_sndirq_line = 4; - toaplan2_sub_cpu = CPU_2_Z80; - sub_cpu = machine->device("audiocpu"); + toaplan2_state *state = machine->driver_data(); + + state->sndirq_line = 4; + state->sub_cpu_type = CPU_2_Z80; + state->sub_cpu = machine->device("audiocpu"); register_state_save(machine); } static DRIVER_INIT( bbakraid ) { - bbakraid_unlimited_ver = 0; - raizing_sndirq_line = 2; - toaplan2_sub_cpu = CPU_2_Z80; - sub_cpu = machine->device("audiocpu"); + toaplan2_state *state = machine->driver_data(); + + state->unlimited_ver = 0; + state->sndirq_line = 2; + state->sub_cpu_type = CPU_2_Z80; + state->sub_cpu = machine->device("audiocpu"); register_state_save(machine); } static DRIVER_INIT( bbakradu ) { - bbakraid_unlimited_ver = 1; - raizing_sndirq_line = 2; - toaplan2_sub_cpu = CPU_2_Z80; - sub_cpu = machine->device("audiocpu"); + toaplan2_state *state = machine->driver_data(); + + state->unlimited_ver = 1; + state->sndirq_line = 2; + state->sub_cpu_type = CPU_2_Z80; + state->sub_cpu = machine->device("audiocpu"); register_state_save(machine); } @@ -550,26 +554,28 @@ static READ16_HANDLER( video_count_r ) /* +---------+---------+--------+---------------------------+ */ /*************** Control Signals are active low ***************/ + toaplan2_state *state = space->machine->driver_data(); int hpos = space->machine->primary_screen->hpos(); int vpos = space->machine->primary_screen->vpos(); - video_status = 0xff00; /* Set signals inactive */ + + state->video_status = 0xff00; /* Set signals inactive */ vpos = (vpos + 15) % 262; if ((hpos > 325) && (hpos < 380)) - video_status &= ~0x8000; + state->video_status &= ~0x8000; if ((vpos >= 247) && (vpos <= 250)) - video_status &= ~0x4000; + state->video_status &= ~0x4000; if (vpos >= 245) - video_status &= ~0x0100; + state->video_status &= ~0x0100; if (vpos < 256) - video_status |= (vpos & 0xff); + state->video_status |= (vpos & 0xff); else - video_status |= 0xff; + state->video_status |= 0xff; // logerror("VC: vpos=%04x hpos=%04x VBL=%04x\n",vpos,hpos,space->machine->primary_screen->vblank()); - return video_status; + return state->video_status; } static WRITE8_HANDLER( toaplan2_coin_w ) @@ -613,12 +619,16 @@ static WRITE16_HANDLER( toaplan2_v25_coin_word_w ) if (ACCESSING_BITS_0_7) { + #ifdef USE_ENCRYPTED_V25S + toaplan2_state *state = space->machine->driver_data(); + #endif + toaplan2_coin_w(space, offset, data & 0x0f); #ifdef USE_ENCRYPTED_V25S /* only the ram-based V25 based games access the following bits */ - //cpu_set_input_line(sub_cpu, INPUT_LINE_RESET, (data & 0x0020) ? CLEAR_LINE : ASSERT_LINE ); - cpu_set_input_line(sub_cpu, INPUT_LINE_HALT, (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE); + //cpu_set_input_line(state->sub_cpu, INPUT_LINE_RESET, (data & 0x0020) ? CLEAR_LINE : ASSERT_LINE ); + cpu_set_input_line(state->sub_cpu, INPUT_LINE_HALT, (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE); #endif } @@ -634,10 +644,12 @@ static WRITE16_HANDLER( toaplan2_v25_batsugun_coin_word_w ) if (ACCESSING_BITS_0_7) { + toaplan2_state *state = space->machine->driver_data(); + toaplan2_coin_w(space, offset, data & 0x0f); /* only the ram-based V25 based games access the following bits */ - //cpu_set_input_line(sub_cpu, INPUT_LINE_RESET, (data & 0x0020) ? CLEAR_LINE : ASSERT_LINE ); - cpu_set_input_line(sub_cpu, INPUT_LINE_HALT, (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE); + //cpu_set_input_line(state->sub_cpu, INPUT_LINE_RESET, (data & 0x0020) ? CLEAR_LINE : ASSERT_LINE ); + cpu_set_input_line(state->sub_cpu, INPUT_LINE_HALT, (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE); } if (ACCESSING_BITS_8_15 && (data & 0xff00) ) { @@ -660,14 +672,18 @@ static WRITE16_HANDLER( shippumd_coin_word_w ) static READ16_HANDLER( z80_shared_r ) { - return z80_shared_ram[offset] & 0xff; + toaplan2_state *state = space->machine->driver_data(); + + return state->z80_shared_ram[offset] & 0xff; } static WRITE16_HANDLER( z80_shared_w ) { if (ACCESSING_BITS_0_7) { - z80_shared_ram[offset] = data & 0xff; + toaplan2_state *state = space->machine->driver_data(); + + state->z80_shared_ram[offset] = data & 0xff; } } @@ -678,52 +694,58 @@ static WRITE16_HANDLER( toaplan2_hd647180_cpu_w ) if (ACCESSING_BITS_0_7) { - if (toaplan2_sub_cpu == CPU_2_Z80) /* Whoopee */ + toaplan2_state *state = space->machine->driver_data(); + + if (state->sub_cpu_type == CPU_2_Z80) /* Whoopee */ { - z80_shared_ram[0] = data & 0xff; + state->z80_shared_ram[0] = data & 0xff; } else /* Teki Paki */ { - mcu_data = data & 0xff; - logerror("PC:%08x Writing command (%04x) to secondary CPU shared port\n",cpu_get_previouspc(space->cpu),mcu_data); + state->mcu_data = data & 0xff; + logerror("PC:%08x Writing command (%04x) to secondary CPU shared port\n", cpu_get_previouspc(space->cpu), state->mcu_data); } } } static CUSTOM_INPUT( c2map_r ) { + toaplan2_state *state = field->port->machine->driver_data(); + /* For Teki Paki hardware */ /* bit 4 high signifies secondary CPU is ready */ /* bit 5 is tested low before V-Blank bit ??? */ - switch (toaplan2_sub_cpu) + switch (state->sub_cpu_type) { - case CPU_2_Z80: mcu_data = z80_shared_ram[0]; break; /* Whoopee */ - case CPU_2_HD647180: mcu_data = 0xff; break; /* Teki Paki */ - default: mcu_data = 0x00; break; + case CPU_2_Z80: state->mcu_data = state->z80_shared_ram[0]; break; /* Whoopee */ + case CPU_2_HD647180: state->mcu_data = 0xff; break; /* Teki Paki */ + default: state->mcu_data = 0x00; break; } - return (mcu_data == 0xff) ? 0x01 : 0x00; + return (state->mcu_data == 0xff) ? 0x01 : 0x00; } static READ16_HANDLER( ghox_p1_h_analog_r ) { + toaplan2_state *state = space->machine->driver_data(); INT8 value, new_value; new_value = input_port_read(space->machine, "PAD1"); - if (new_value == old_p1_paddle_h) return 0; - value = new_value - old_p1_paddle_h; - old_p1_paddle_h = new_value; + if (new_value == state->old_p1_paddle_h) return 0; + value = new_value - state->old_p1_paddle_h; + state->old_p1_paddle_h = new_value; return value; } static READ16_HANDLER( ghox_p2_h_analog_r ) { + toaplan2_state *state = space->machine->driver_data(); INT8 value, new_value; new_value = input_port_read(space->machine, "PAD2"); - if (new_value == old_p2_paddle_h) return 0; - value = new_value - old_p2_paddle_h; - old_p2_paddle_h = new_value; + if (new_value == state->old_p2_paddle_h) return 0; + value = new_value - state->old_p2_paddle_h; + state->old_p2_paddle_h = new_value; return value; } @@ -736,7 +758,10 @@ static WRITE16_HANDLER( ghox_mcu_w ) { if (ACCESSING_BITS_0_7) { - mcu_data = data; + toaplan2_state *state = space->machine->driver_data(); + UINT16 *toaplan2_shared_ram16 = state->shared_ram16; + + state->mcu_data = data; if ((data >= 0xd0) && (data < 0xe0)) { offset = ((data & 0x0f) * 2) + (0x38 / 2); @@ -745,7 +770,7 @@ static WRITE16_HANDLER( ghox_mcu_w ) } else { - logerror("PC:%08x Writing %08x to HD647180 cpu shared ram status port\n",cpu_get_previouspc(space->cpu),mcu_data); + logerror("PC:%08x Writing %08x to HD647180 cpu shared ram status port\n", cpu_get_previouspc(space->cpu), state->mcu_data); } toaplan2_shared_ram16[0x56 / 2] = 0x004e; /* Return a RTS instruction */ toaplan2_shared_ram16[0x58 / 2] = 0x0075; @@ -788,14 +813,18 @@ static READ16_HANDLER( ghox_shared_ram_r ) Offset $48 and $46 are accessed from around PC:06776 */ - return toaplan2_shared_ram16[offset] & 0xff; + toaplan2_state *state = space->machine->driver_data(); + + return state->shared_ram16[offset] & 0xff; } static WRITE16_HANDLER( ghox_shared_ram_w ) { if (ACCESSING_BITS_0_7) { - toaplan2_shared_ram16[offset] = data & 0xff; + toaplan2_state *state = space->machine->driver_data(); + + state->shared_ram16[offset] = data & 0xff; } } @@ -806,13 +835,17 @@ static READ16_HANDLER( shared_ram_r ) the 68000 and the V25+ CPU. The 68000 reads the status of the V25+ via a location of the shared memory. */ - return toaplan2_shared_ram16[offset] & 0xff; + toaplan2_state *state = space->machine->driver_data(); + + return state->shared_ram16[offset] & 0xff; } static WRITE16_HANDLER( shared_ram_w ) { if (ACCESSING_BITS_0_7) { + toaplan2_state *state = space->machine->driver_data(); + data &= 0xff; switch (offset * 2) { @@ -821,14 +854,14 @@ static WRITE16_HANDLER( shared_ram_w ) case 0x9f0: case 0xcf0: case 0xcf8: - case 0xff8: toaplan2_shared_ram16[offset + 1] = data; /* Dogyuun */ - toaplan2_shared_ram16[offset + 2] = data; /* FixEight */ + case 0xff8: state->shared_ram16[offset + 1] = data; /* Dogyuun */ + state->shared_ram16[offset + 2] = data; /* FixEight */ logerror("PC:%08x Writing (%04x) to shared RAM at %04x\n",cpu_get_previouspc(space->cpu),data,(offset*2)); if (data == 0x81) data = 0x0001; break; default: break; } - toaplan2_shared_ram16[offset] = data; + state->shared_ram16[offset] = data; } } @@ -837,13 +870,14 @@ static READ16_HANDLER( toaplan2_snd_cpu_r ) /*** Status port includes NEC V25+ CPU POST codes. ************ *** This is actually a part of the 68000/V25+ Shared RAM */ + toaplan2_state *state = space->machine->driver_data(); int response = 0xffff; /* Provide successful POST responses */ - if (mcu_data == 0xffaa) /* Dogyuun */ + if (state->mcu_data == 0xffaa) /* Dogyuun */ { response = 0xffaa; - mcu_data = 0xffff; + state->mcu_data = 0xffff; } logerror("PC:%06x reading status %08x from the NEC V25+ secondary CPU port\n",cpu_get_previouspc(space->cpu),response); @@ -852,12 +886,14 @@ static READ16_HANDLER( toaplan2_snd_cpu_r ) static WRITE16_HANDLER( dogyuun_snd_cpu_w ) { + toaplan2_state *state = space->machine->driver_data(); + if (ACCESSING_BITS_0_7) { - mcu_data = data; + state->mcu_data = data; dogyuun_okisnd_w(space->machine->device("oki"), data); } - logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port\n",cpu_get_previouspc(space->cpu),mcu_data); + logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port\n", cpu_get_previouspc(space->cpu), state->mcu_data); } @@ -866,21 +902,22 @@ static READ16_HANDLER( fixeight_sec_cpu_r ) /*** Status port includes NEC V25+ CPU POST codes. ************ *** This is actually a part of the 68000/V25+ Shared RAM */ + toaplan2_state *state = space->machine->driver_data(); int response = 0xffff; - if ((mcu_data & 0xffff) == 0x0faa) + if ((state->mcu_data & 0xffff) == 0x0faa) { - mcu_data = 0xffff; + state->mcu_data = 0xffff; response = 0xffaa; } - if ((mcu_data & 0xffff) == 0xff00) + if ((state->mcu_data & 0xffff) == 0xff00) { - mcu_data = 0x0faa; + state->mcu_data = 0x0faa; response = 0xffaa; /* Second CPU passed POST response */ } - if ((mcu_data & 0xff00) == 0x0000) + if ((state->mcu_data & 0xff00) == 0x0000) { - response = mcu_data; /* Return the shared RAM data during POST */ + response = state->mcu_data; /* Return the shared RAM data during POST */ } logerror("PC:%06x reading status %08x from the NEC V25+ secondary CPU port\n",cpu_get_previouspc(space->cpu),response); return response; @@ -888,14 +925,16 @@ static READ16_HANDLER( fixeight_sec_cpu_r ) static WRITE16_HANDLER( fixeight_sec_cpu_w ) { + toaplan2_state *state = space->machine->driver_data(); + if (ACCESSING_BITS_0_7) { - if (mcu_data & 0xff00) + if (state->mcu_data & 0xff00) { - mcu_data = (mcu_data & 0xff00) | (data & 0xff); + state->mcu_data = (state->mcu_data & 0xff00) | (data & 0xff); fixeight_okisnd_w(space->machine->device("oki"), data); } - else if (mcu_data == 0xff00) + else if (state->mcu_data == 0xff00) { #if 0 /* check the 37B6 code */ /* copy nvram data to shared ram after post is complete */ @@ -912,45 +951,53 @@ static WRITE16_HANDLER( fixeight_sec_cpu_w ) memory_install_read_port(space, 0x28f006, 0x28f007, 0, 0, "DSWB"); /* Dip Switch B - Wrong !!! */ memory_install_read_port(space, 0x28f008, 0x28f009, 0, 0, "JMPR"); /* Territory Jumper block - Wrong !!! */ - mcu_data = data; + state->mcu_data = data; } else { - mcu_data = data; + state->mcu_data = data; } } - logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port\n",cpu_get_previouspc(space->cpu),mcu_data); + logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port\n", cpu_get_previouspc(space->cpu), state->mcu_data); } static WRITE16_HANDLER( vfive_snd_cpu_w ) { + toaplan2_state *state = space->machine->driver_data(); + if (ACCESSING_BITS_0_7) { - mcu_data = data; + state->mcu_data = data; } - logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port\n",cpu_get_previouspc(space->cpu),mcu_data); + logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port\n", cpu_get_previouspc(space->cpu), state->mcu_data); } static WRITE16_HANDLER( batsugun_snd_cpu_w ) { + toaplan2_state *state = space->machine->driver_data(); + if (ACCESSING_BITS_0_7) { - mcu_data = data; + state->mcu_data = data; batsugun_okisnd_w(space->machine->device("oki"), data); } - logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port %02x\n",cpu_get_previouspc(space->cpu),mcu_data,(offset*2)); + logerror("PC:%06x Writing command (%04x) to the NEC V25+ secondary CPU port %02x\n", cpu_get_previouspc(space->cpu), state->mcu_data, (offset*2)); } static READ16_HANDLER( V25_sharedram_r ) { - return V25_shared_ram[offset] & 0xff; + toaplan2_state *state = space->machine->driver_data(); + + return state->V25_shared_ram[offset] & 0xff; } static WRITE16_HANDLER( V25_sharedram_w ) { if (ACCESSING_BITS_0_7) { - V25_shared_ram[offset] = data & 0xff; + toaplan2_state *state = space->machine->driver_data(); + + state->V25_shared_ram[offset] = data & 0xff; } } #endif @@ -1006,8 +1053,10 @@ static WRITE16_HANDLER( bgaregga_soundlatch_w ) { if (ACCESSING_BITS_0_7) { + toaplan2_state *state = space->machine->driver_data(); + soundlatch_w(space, offset, data & 0xff); - cpu_set_input_line(sub_cpu, 0, HOLD_LINE); + cpu_set_input_line(state->sub_cpu, 0, HOLD_LINE); } } @@ -1031,11 +1080,12 @@ static WRITE8_HANDLER( bgaregga_E00C_w ) static WRITE8_HANDLER( bgaregga_bankswitch_w ) { + toaplan2_state *state = space->machine->driver_data(); int bank = (data & 0x0f) - 10 + 4; - if (bank != current_bank) + if (bank != state->current_bank) { - current_bank = bank; + state->current_bank = bank; memory_set_bank(space->machine, "bank1", bank); } } @@ -1081,12 +1131,14 @@ static WRITE8_HANDLER( raizing_okim6295_bankselect_3 ) static WRITE8_HANDLER( batrider_bankswitch_w ) { + toaplan2_state *state = space->machine->driver_data(); int bank = data & 0x0f; + bank = (bank > 1) ? bank + 2 : bank; - if (bank != current_bank) + if (bank != state->current_bank) { - current_bank = bank; + state->current_bank = bank; memory_set_bank(space->machine, "bank1", bank); } } @@ -1100,7 +1152,9 @@ static READ16_HANDLER( batrider_z80_busack_r ) ROM code. Failure to return the correct status incurrs a Sound Error. */ - return raizing_Z80_busreq; /* Loop BUSRQ to BUSAK */ + toaplan2_state *state = space->machine->driver_data(); + + return state->z80_busreq; /* Loop BUSRQ to BUSAK */ } @@ -1108,7 +1162,9 @@ static WRITE16_HANDLER( batrider_z80_busreq_w ) { if (ACCESSING_BITS_0_7) { - raizing_Z80_busreq = (data & 0xff); + toaplan2_state *state = space->machine->driver_data(); + + state->z80_busreq = (data & 0xff); } } @@ -1129,8 +1185,10 @@ static WRITE16_HANDLER( batrider_soundlatch_w ) { if (ACCESSING_BITS_0_7) { + toaplan2_state *state = space->machine->driver_data(); + soundlatch_w(space, offset, data & 0xff); - cpu_set_input_line(sub_cpu, INPUT_LINE_NMI, ASSERT_LINE); + cpu_set_input_line(state->sub_cpu, INPUT_LINE_NMI, ASSERT_LINE); } } @@ -1139,8 +1197,10 @@ static WRITE16_HANDLER( batrider_soundlatch2_w ) { if (ACCESSING_BITS_0_7) { + toaplan2_state *state = space->machine->driver_data(); + soundlatch2_w(space, offset, data & 0xff); - cpu_set_input_line(sub_cpu, INPUT_LINE_NMI, ASSERT_LINE); + cpu_set_input_line(state->sub_cpu, INPUT_LINE_NMI, ASSERT_LINE); } } @@ -1154,22 +1214,28 @@ static WRITE16_HANDLER( raizing_unknown_w ) static WRITE16_HANDLER( raizing_clear_sndirq_w ) { + toaplan2_state *state = space->machine->driver_data(); + // not sure whether this is correct // the 68K writes here during the sound IRQ handler, and nowhere else... - cputag_set_input_line(space->machine, "maincpu", raizing_sndirq_line, CLEAR_LINE); + cputag_set_input_line(space->machine, "maincpu", state->sndirq_line, CLEAR_LINE); } static WRITE8_HANDLER( raizing_sndirq_w ) { + toaplan2_state *state = space->machine->driver_data(); + // if raizing_clear_sndirq_w() is correct, should this be ASSERT_LINE? - cputag_set_input_line(space->machine, "maincpu", raizing_sndirq_line, HOLD_LINE); + cputag_set_input_line(space->machine, "maincpu", state->sndirq_line, HOLD_LINE); } static WRITE8_HANDLER( raizing_clear_nmi_w ) { - cpu_set_input_line(sub_cpu, INPUT_LINE_NMI, CLEAR_LINE); + toaplan2_state *state = space->machine->driver_data(); + + cpu_set_input_line(state->sub_cpu, INPUT_LINE_NMI, CLEAR_LINE); } @@ -1231,6 +1297,7 @@ static const eeprom_interface bbakraid_93C66_intf = static READ16_HANDLER( bbakraid_nvram_r ) { + toaplan2_state *state = space->machine->driver_data(); eeprom_device *eeprom = space->machine->device("eeprom"); /* Bit 1 returns the status of BUSAK from the Z80. @@ -1241,7 +1308,7 @@ static READ16_HANDLER( bbakraid_nvram_r ) int data; data = ((eeprom_read_bit(eeprom) & 0x01) << 4); - data |= ((raizing_Z80_busreq >> 4) & 0x01); /* Loop BUSRQ to BUSAK */ + data |= ((state->z80_busreq >> 4) & 0x01); /* Loop BUSRQ to BUSAK */ return data; } @@ -1249,13 +1316,15 @@ static READ16_HANDLER( bbakraid_nvram_r ) static WRITE16_HANDLER( bbakraid_nvram_w ) { + toaplan2_state *state = space->machine->driver_data(); + if (data & ~0x001f) logerror("CPU #0 PC:%06X - Unknown EEPROM data being written %04X\n",cpu_get_pc(space->cpu),data); if ( ACCESSING_BITS_0_7 ) input_port_write(space->machine, "EEPROMOUT", data, 0xff); - raizing_Z80_busreq = data & 0x10; /* see bbakraid_nvram_r above */ + state->z80_busreq = data & 0x10; /* see bbakraid_nvram_r above */ } @@ -1303,7 +1372,7 @@ static ADDRESS_MAP_START( ghox_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x180010, 0x180011) AM_READ_PORT("SYS") AM_RANGE(0x18000c, 0x18000d) AM_READ_PORT("IN1") AM_RANGE(0x18000e, 0x18000f) AM_READ_PORT("IN2") - AM_RANGE(0x180500, 0x180fff) AM_READWRITE(ghox_shared_ram_r, ghox_shared_ram_w) AM_BASE(&toaplan2_shared_ram16) + AM_RANGE(0x180500, 0x180fff) AM_READWRITE(ghox_shared_ram_r, ghox_shared_ram_w) AM_BASE_MEMBER(toaplan2_state, shared_ram16) AM_RANGE(0x181000, 0x181001) AM_WRITE(toaplan2_coin_word_w) AM_RANGE(0x18100c, 0x18100d) AM_READ_PORT("JMPR") ADDRESS_MAP_END @@ -1317,17 +1386,17 @@ static ADDRESS_MAP_START( dogyuun_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200018, 0x200019) AM_READ_PORT("SYS") AM_RANGE(0x20001c, 0x20001d) AM_WRITE(toaplan2_v25_coin_word_w) #ifdef USE_ENCRYPTED_V25S -// AM_RANGE(0x21e000, 0x21fbff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE(&toaplan2_shared_ram16) /* $21f000 status port */ -// AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ + //AM_RANGE(0x21e000, 0x21fbff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE_MEMBER(toaplan2_state, shared_ram16) /* $21f000 status port */ + //AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE_MEMBER(toaplan2_state, V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ AM_RANGE(0x210000, 0x21efff) AM_READWRITE( batsugun_share2_r, batsugun_share2_w ) AM_RANGE(0x21f000, 0x21ffff) AM_READWRITE( batsugun_share_r, batsugun_share_w ) #else - AM_RANGE(0x21e000, 0x21efff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE(&toaplan2_shared_ram16) + AM_RANGE(0x21e000, 0x21efff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE_MEMBER(toaplan2_state, shared_ram16) AM_RANGE(0x21f000, 0x21f001) AM_READWRITE(toaplan2_snd_cpu_r, dogyuun_snd_cpu_w) /* V25+ status/command port */ AM_RANGE(0x21f004, 0x21f005) AM_READ_PORT("DSWA") AM_RANGE(0x21f006, 0x21f007) AM_READ_PORT("DSWB") AM_RANGE(0x21f008, 0x21f009) AM_READ_PORT("JMPR") - AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ + AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE_MEMBER(toaplan2_state, V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ #endif /***** The following locations in 0x30000x are for video controller 1 ******/ AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) @@ -1382,12 +1451,12 @@ static ADDRESS_MAP_START( truxton2_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_RANGE(0x200000, 0x20000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x300000, 0x300fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x400000, 0x401fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) - AM_RANGE(0x402000, 0x4021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) + AM_RANGE(0x400000, 0x401fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) + AM_RANGE(0x402000, 0x4021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) AM_RANGE(0x402200, 0x402fff) AM_RAM - AM_RANGE(0x403000, 0x4031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) + AM_RANGE(0x403000, 0x4031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) AM_RANGE(0x403200, 0x403fff) AM_RAM - AM_RANGE(0x500000, 0x50ffff) AM_READWRITE(toaplan2_tx_gfxram16_r, toaplan2_tx_gfxram16_w) AM_BASE(&toaplan2_tx_gfxram16) + AM_RANGE(0x500000, 0x50ffff) AM_READWRITE(toaplan2_tx_gfxram16_r, toaplan2_tx_gfxram16_w) AM_BASE_MEMBER(toaplan2_state, tx_gfxram16) AM_RANGE(0x600000, 0x600001) AM_READ(video_count_r) AM_RANGE(0x700000, 0x700001) AM_READ_PORT("DSWA") AM_RANGE(0x700002, 0x700003) AM_READ_PORT("DSWB") @@ -1425,8 +1494,8 @@ static ADDRESS_MAP_START( pipibibi_bootleg_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x083800, 0x087fff) AM_RAM /* SpriteRAM (unused) */ AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x120000, 0x120fff) AM_RAM /* Copy of SpriteRAM ? */ -// AM_RANGE(0x13f000, 0x13f001) AM_WRITENOP /* ??? */ - AM_RANGE(0x180000, 0x182fff) AM_DEVREADWRITE("gp9001vdp0", pipibibi_bootleg_videoram16_r, pipibibi_bootleg_videoram16_w ) /* TileRAM */ + //AM_RANGE(0x13f000, 0x13f001) AM_WRITENOP /* ??? */ + AM_RANGE(0x180000, 0x182fff) AM_DEVREADWRITE("gp9001vdp0", pipibibi_bootleg_videoram16_r, pipibibi_bootleg_videoram16_w) /* TileRAM */ AM_RANGE(0x188000, 0x18800f) AM_DEVWRITE("gp9001vdp0", pipibibi_bootleg_scroll_w) AM_RANGE(0x190002, 0x190003) AM_READ(z80_shared_r) /* Z80 ready ? */ AM_RANGE(0x190010, 0x190011) AM_WRITE(z80_shared_w) /* Z80 task to perform */ @@ -1458,28 +1527,28 @@ static ADDRESS_MAP_START( fixeight_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200010, 0x200011) AM_READ_PORT("SYS") AM_RANGE(0x20001c, 0x20001d) AM_WRITE(toaplan2_coin_word_w) /* Coin count/lock */ #ifdef USE_ENCRYPTED_V25S -// AM_RANGE(0x28e000, 0x28fbff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE(&toaplan2_shared_ram16) /* $28f000 status port */ -// AM_RANGE(0x28fc00, 0x28ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ + //AM_RANGE(0x28e000, 0x28fbff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE_MEMBER(toaplan2_state, shared_ram16) /* $28f000 status port */ + //AM_RANGE(0x28fc00, 0x28ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE_MEMBER(toaplan2_state, V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ AM_RANGE(0x280000, 0x28efff) AM_READWRITE( batsugun_share2_r, batsugun_share2_w ) AM_RANGE(0x28f000, 0x28ffff) AM_READWRITE( batsugun_share_r, batsugun_share_w ) AM_RANGE(0x700000, 0x700001) AM_WRITE(fixeight_subcpu_ctrl) // guess!!! #else AM_RANGE(0x280000, 0x28dfff) AM_RAM /* part of shared ram ? */ - AM_RANGE(0x28e000, 0x28efff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE(&toaplan2_shared_ram16) + AM_RANGE(0x28e000, 0x28efff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE_MEMBER(toaplan2_state, shared_ram16) AM_RANGE(0x28f000, 0x28f001) AM_READWRITE(fixeight_sec_cpu_r, fixeight_sec_cpu_w) /* V25+ Command/Status port */ -// AM_RANGE(0x28f002, 0x28f003) AM_READONLY /* part of shared ram */ -// AM_RANGE(0x28f004, 0x28f005) AM_READ_PORT("DSWA") /* Dip Switch A - Wrong !!! */ -// AM_RANGE(0x28f006, 0x28f007) AM_READ_PORT("DSWB") /* Dip Switch B - Wrong !!! */ -// AM_RANGE(0x28f008, 0x28f009) AM_READ_PORT("JMPR") /* Territory Jumper block - Wrong !!! */ -// AM_RANGE(0x28f00a, 0x28fbff) AM_READONLY /* part of shared ram */ - AM_RANGE(0x28fc00, 0x28ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ + //AM_RANGE(0x28f002, 0x28f003) AM_READONLY /* part of shared ram */ + //AM_RANGE(0x28f004, 0x28f005) AM_READ_PORT("DSWA") /* Dip Switch A - Wrong !!! */ + //AM_RANGE(0x28f006, 0x28f007) AM_READ_PORT("DSWB") /* Dip Switch B - Wrong !!! */ + //AM_RANGE(0x28f008, 0x28f009) AM_READ_PORT("JMPR") /* Territory Jumper block - Wrong !!! */ + //AM_RANGE(0x28f00a, 0x28fbff) AM_READONLY /* part of shared ram */ + AM_RANGE(0x28fc00, 0x28ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE_MEMBER(toaplan2_state, V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ #endif AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) - AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) - AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) - AM_RANGE(0x600000, 0x60ffff) AM_READWRITE(toaplan2_tx_gfxram16_r, toaplan2_tx_gfxram16_w) AM_BASE(&toaplan2_tx_gfxram16) + AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) + AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) + AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) + AM_RANGE(0x600000, 0x60ffff) AM_READWRITE(toaplan2_tx_gfxram16_r, toaplan2_tx_gfxram16_w) AM_BASE_MEMBER(toaplan2_state, tx_gfxram16) AM_RANGE(0x800000, 0x800001) AM_READ(video_count_r) ADDRESS_MAP_END @@ -1497,9 +1566,9 @@ static ADDRESS_MAP_START( fixeighb_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x20001c, 0x20001d) AM_READ_PORT("DSWA") AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) - AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) - AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) + AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) + AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) + AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) AM_RANGE(0x700000, 0x700001) AM_READ(video_count_r) AM_RANGE(0x800000, 0x87ffff) AM_ROMBANK("bank1") ADDRESS_MAP_END @@ -1514,17 +1583,17 @@ static ADDRESS_MAP_START( vfive_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200018, 0x200019) AM_READ_PORT("SYS") AM_RANGE(0x20001c, 0x20001d) AM_WRITE(toaplan2_v25_coin_word_w) /* Coin count/lock */ #ifdef USE_ENCRYPTED_V25S -// AM_RANGE(0x21e000, 0x21fbff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE(&toaplan2_shared_ram16) /* $21f000 status port */ -// AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ + //AM_RANGE(0x21e000, 0x21fbff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE_MEMBER(toaplan2_state, shared_ram16) /* $21f000 status port */ + //AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE_MEMBER(toaplan2_state, V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ AM_RANGE(0x210000, 0x21efff) AM_READWRITE( batsugun_share2_r, batsugun_share2_w ) AM_RANGE(0x21f000, 0x21ffff) AM_READWRITE( batsugun_share_r, batsugun_share_w ) #else - AM_RANGE(0x21e000, 0x21efff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE(&toaplan2_shared_ram16) + AM_RANGE(0x21e000, 0x21efff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE_MEMBER(toaplan2_state, shared_ram16) AM_RANGE(0x21f000, 0x21f001) AM_READWRITE(toaplan2_snd_cpu_r, vfive_snd_cpu_w) /* V25+ Command/Status port */ AM_RANGE(0x21f004, 0x21f005) AM_READ_PORT("DSWA") AM_RANGE(0x21f006, 0x21f007) AM_READ_PORT("DSWB") AM_RANGE(0x21f008, 0x21f009) AM_READ_PORT("JMPR") - AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ + AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE_MEMBER(toaplan2_state, V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ #endif AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) @@ -1534,8 +1603,9 @@ ADDRESS_MAP_END static READ16_HANDLER( batsugun_share_r ) { - return batsugun_share[offset] | batsugun_share[offset]<<8; + toaplan2_state *state = space->machine->driver_data(); + return state->batsugun_share[offset] | state->batsugun_share[offset]<<8; } static WRITE16_HANDLER( batsugun_share_w ) @@ -1543,13 +1613,17 @@ static WRITE16_HANDLER( batsugun_share_w ) #if 0 if (ACCESSING_BITS_8_15) { - batsugun_share[offset] = data >> 8; + toaplan2_state *state = space->machine->driver_data(); + + state->batsugun_share[offset] = data >> 8; } #endif if (ACCESSING_BITS_0_7) { - batsugun_share[offset] = data; + toaplan2_state *state = space->machine->driver_data(); + + state->batsugun_share[offset] = data; } } @@ -1557,6 +1631,8 @@ static WRITE16_HANDLER( batsugun_share_w ) /* To be removed... */ static READ16_HANDLER( batsugun_share2_r ) { + toaplan2_state *state = space->machine->driver_data(); + return batsugun_share2[offset] | batsugun_share2[offset]<<8; } @@ -1565,13 +1641,17 @@ static WRITE16_HANDLER( batsugun_share2_w ) #if 0 if (ACCESSING_BITS_8_15) { - batsugun_share2[offset] = data >> 8; + toaplan2_state *state = space->machine->driver_data(); + + state->batsugun_share2[offset] = data >> 8; } #endif if (ACCESSING_BITS_0_7) { - batsugun_share2[offset] = data; + toaplan2_state *state = space->machine->driver_data(); + + state->batsugun_share2[offset] = data; } } #endif @@ -1638,10 +1718,10 @@ static ADDRESS_MAP_START( mahoudai_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x401000, 0x4017ff) AM_RAM /* Unused PaletteRAM */ - AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) - AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) + AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) + AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) AM_RANGE(0x502200, 0x502fff) AM_RAM - AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) + AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) AM_RANGE(0x503200, 0x503fff) AM_RAM ADDRESS_MAP_END @@ -1662,10 +1742,10 @@ static ADDRESS_MAP_START( shippumd_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x401000, 0x4017ff) AM_RAM /* Unused PaletteRAM */ - AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) - AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) + AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) + AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) AM_RANGE(0x502200, 0x502fff) AM_RAM - AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) + AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) AM_RANGE(0x503200, 0x503fff) AM_RAM ADDRESS_MAP_END @@ -1684,10 +1764,10 @@ static ADDRESS_MAP_START( bgaregga_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x21c03c, 0x21c03d) AM_READ(video_count_r) AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) - AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) + AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) + AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) AM_RANGE(0x502200, 0x502fff) AM_RAM - AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) + AM_RANGE(0x503000, 0x5031ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) AM_RANGE(0x503200, 0x503fff) AM_RAM AM_RANGE(0x600000, 0x600001) AM_WRITE(bgaregga_soundlatch_w) ADDRESS_MAP_END @@ -1695,11 +1775,11 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( batrider_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x1fffff) AM_ROM - AM_RANGE(0x200000, 0x201fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) /* Text VideoRAM */ - AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_SIZE(&batrider_paletteram16_size) - AM_RANGE(0x203000, 0x2031ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) - AM_RANGE(0x203200, 0x2033ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) - AM_RANGE(0x203400, 0x207fff) AM_READWRITE(raizing_tx_gfxram16_r, raizing_tx_gfxram16_w) /* Main RAM actually */ + AM_RANGE(0x200000, 0x201fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) /* Text VideoRAM */ + AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_SIZE_MEMBER(toaplan2_state, paletteram16_size) + AM_RANGE(0x203000, 0x2031ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) + AM_RANGE(0x203200, 0x2033ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) + AM_RANGE(0x203400, 0x207fff) AM_READWRITE(raizing_tx_gfxram16_r, raizing_tx_gfxram16_w) /* Main RAM actually */ AM_RANGE(0x208000, 0x20ffff) AM_RAM AM_RANGE(0x300000, 0x37ffff) AM_READ(raizing_z80rom_r) AM_RANGE(0x400000, 0x40000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_alt_r, gp9001_vdp_alt_w) @@ -1723,10 +1803,10 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( bbakraid_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x1fffff) AM_ROM - AM_RANGE(0x200000, 0x201fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) /* Text VideoRAM */ - AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_SIZE(&batrider_paletteram16_size) - AM_RANGE(0x203000, 0x2031ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) - AM_RANGE(0x203200, 0x2033ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE(&toaplan2_txscrollram16) AM_SIZE(&toaplan2_tx_scroll_vram_size) + AM_RANGE(0x200000, 0x201fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16, tx_vram_size) /* Text VideoRAM */ + AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_SIZE_MEMBER(toaplan2_state, paletteram16_size) + AM_RANGE(0x203000, 0x2031ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txvideoram16_offs, tx_offs_vram_size) + AM_RANGE(0x203200, 0x2033ff) AM_READWRITE(toaplan2_txscrollram16_r, toaplan2_txscrollram16_w) AM_BASE_SIZE_MEMBER(toaplan2_state, txscrollram16, tx_scroll_vram_size) AM_RANGE(0x203400, 0x207fff) AM_READWRITE(raizing_tx_gfxram16_r, raizing_tx_gfxram16_w) /* Main RAM actually */ AM_RANGE(0x208000, 0x20ffff) AM_RAM AM_RANGE(0x300000, 0x33ffff) AM_READ(raizing_z80rom_r) @@ -1752,14 +1832,14 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( pipibibs_sound_z80_mem, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&z80_shared_ram) + AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_MEMBER(toaplan2_state, z80_shared_ram) AM_RANGE(0xe000, 0xe001) AM_DEVREADWRITE("ymsnd", ym3812_r, ym3812_w) ADDRESS_MAP_END static ADDRESS_MAP_START( raizing_sound_z80_mem, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0xbfff) AM_ROM - AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE(&z80_shared_ram) + AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_MEMBER(toaplan2_state, z80_shared_ram) AM_RANGE(0xe000, 0xe001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w) AM_RANGE(0xe004, 0xe004) AM_DEVREADWRITE("oki", okim6295_r, okim6295_w) AM_RANGE(0xe00e, 0xe00e) AM_WRITE(toaplan2_coin_w) @@ -1769,7 +1849,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( bgaregga_sound_z80_mem, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") - AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE(&z80_shared_ram) + AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_MEMBER(toaplan2_state, z80_shared_ram) AM_RANGE(0xe000, 0xe001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w) AM_RANGE(0xe004, 0xe004) AM_DEVREADWRITE("oki", okim6295_r, okim6295_w) AM_RANGE(0xe006, 0xe006) AM_WRITE(raizing_okim6295_bankselect_0) @@ -2283,7 +2363,7 @@ static READ8_HANDLER( kludge_r ) static ADDRESS_MAP_START( V25_rambased_mem, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x00000, 0x00001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w) - AM_RANGE(0x00000, 0x07fff) AM_RAM AM_SHARE("share6") AM_BASE(&batsugun_share) + AM_RANGE(0x00000, 0x07fff) AM_RAM AM_SHARE("share6") AM_BASE_MEMBER(toaplan2_state, batsugun_share) // AM_RANGE(0x40000, 0x477ff) AM_RAM AM_SHARE("share7") AM_RANGE(0x40e00, 0x40eff) AM_RAM //internal V25 RAM @@ -3669,8 +3749,10 @@ GFXDECODE_END static void irqhandler(running_device *device, int linestate) { - if (sub_cpu != NULL) // wouldn't tekipaki have problem without this? "mcu" is not generally added - cpu_set_input_line(sub_cpu, 0, linestate); + toaplan2_state *state = device->machine->driver_data(); + + if (state->sub_cpu != NULL) // wouldn't tekipaki have problem without this? "mcu" is not generally added + cpu_set_input_line(state->sub_cpu, 0, linestate); } static const ym3812_interface ym3812_config = @@ -3894,7 +3976,9 @@ static const nec_config ts004dash_config ={ ts004dash_decryption_table, }; static MACHINE_RESET(kbash) { #ifndef USE_ENCRYPTED_V25S - cpu_set_input_line(sub_cpu, INPUT_LINE_HALT, ASSERT_LINE); + toaplan2_state *state = machine->driver_data(); + + cpu_set_input_line(state->sub_cpu, INPUT_LINE_HALT, ASSERT_LINE); #endif } @@ -4349,7 +4433,9 @@ MACHINE_DRIVER_END static MACHINE_RESET(batsugun) { - cpu_set_input_line(sub_cpu, INPUT_LINE_HALT, ASSERT_LINE); + toaplan2_state *state = machine->driver_data(); + + cpu_set_input_line(state->sub_cpu, INPUT_LINE_HALT, ASSERT_LINE); } diff --git a/src/mame/includes/toaplan1.h b/src/mame/includes/toaplan1.h index fea97c02e21..a45d07eab08 100644 --- a/src/mame/includes/toaplan1.h +++ b/src/mame/includes/toaplan1.h @@ -4,6 +4,85 @@ ****************************************************************************/ +class toaplan1_state : public driver_data_t +{ +public: + static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, toaplan1_state(machine)); } + + toaplan1_state(running_machine &machine) + : driver_data_t(machine) { } + + int unk_reset_port; + UINT16 *colorram1; + UINT16 *colorram2; + size_t colorram1_size; + size_t colorram2_size; + + UINT8 *sharedram; + + int coin_count; /* coin count increments on startup ? , so dont count it */ + int intenable; + + /* Demon world */ + int dsp_on; + int dsp_BIO; + int dsp_execute; + UINT32 dsp_addr_w; + UINT32 main_ram_seg; + + UINT8 vimana_coins[2]; + UINT8 vimana_credits; + UINT8 vimana_latch; + + UINT16 *pf4_tilevram16; /* || Drawn in this order */ + UINT16 *pf3_tilevram16; /* || */ + UINT16 *pf2_tilevram16; /* \||/ */ + UINT16 *pf1_tilevram16; /* \/ */ + + size_t spriteram_size; + UINT16 *spriteram; + UINT16 *buffered_spriteram; + UINT16 *spritesizeram16; + UINT16 *buffered_spritesizeram16; + + INT32 bcu_flipscreen; /* Tile controller flip flag */ + INT32 fcu_flipscreen; /* Sprite controller flip flag */ + + INT32 pf_voffs; + INT32 spriteram_offs; + + INT32 pf1_scrollx; + INT32 pf1_scrolly; + INT32 pf2_scrollx; + INT32 pf2_scrolly; + INT32 pf3_scrollx; + INT32 pf3_scrolly; + INT32 pf4_scrollx; + INT32 pf4_scrolly; + INT32 scrollx_offs1; + INT32 scrollx_offs2; + INT32 scrollx_offs3; + INT32 scrollx_offs4; + INT32 scrolly_offs; + + +#ifdef MAME_DEBUG + int display_pf1; + int display_pf2; + int display_pf3; + int display_pf4; + int displog; +#endif + + INT32 tiles_offsetx; + INT32 tiles_offsety; + + int reset; /* Hack! See toaplan1_bcu_control below */ + + tilemap_t *pf1_tilemap, *pf2_tilemap, *pf3_tilemap, *pf4_tilemap; +}; + + /*----------- defined in machine/toaplan1.c -----------*/ INTERRUPT_GEN( toaplan1_interrupt ); @@ -31,15 +110,9 @@ MACHINE_RESET( demonwld ); MACHINE_RESET( vimana ); MACHINE_RESET( zerowing ); /* hack for ZeroWing/OutZone. See video */ -extern void toaplan1_driver_savestate(running_machine *machine); -extern void demonwld_driver_savestate(running_machine *machine); -extern void vimana_driver_savestate(running_machine *machine); - - -extern int toaplan1_unk_reset_port; - -extern UINT8 *toaplan1_sharedram; - +void toaplan1_driver_savestate(running_machine *machine); +void demonwld_driver_savestate(running_machine *machine); +void vimana_driver_savestate(running_machine *machine); /*----------- defined in video/toaplan1.c -----------*/ @@ -78,9 +151,3 @@ VIDEO_START( toaplan1 ); VIDEO_UPDATE( rallybik ); VIDEO_UPDATE( toaplan1 ); VIDEO_UPDATE( demonwld ); - - -extern UINT16 *toaplan1_colorram1; -extern UINT16 *toaplan1_colorram2; -extern size_t toaplan1_colorram1_size; -extern size_t toaplan1_colorram2_size; diff --git a/src/mame/includes/toaplan2.h b/src/mame/includes/toaplan2.h index 98855ea6558..9a79538651d 100644 --- a/src/mame/includes/toaplan2.h +++ b/src/mame/includes/toaplan2.h @@ -30,6 +30,48 @@ public: gp9001vdp_device* vdp0; gp9001vdp_device* vdp1; + + UINT8 *z80_shared_ram; + UINT16 *shared_ram16; /* Really 8bit RAM connected to Z180 */ + +#ifndef USE_ENCRYPTED_V25S + UINT16 *V25_shared_ram; /* Really 8bit RAM connected to Z180 */ +#endif + UINT8* batsugun_share; +#ifdef USE_ENCRYPTED_V25S + UINT8* batsugun_share2; +#endif + + int sub_cpu_type; + running_device *sub_cpu; + + UINT16 mcu_data; + UINT16 video_status; + INT8 old_p1_paddle_h; /* For Ghox */ + INT8 old_p2_paddle_h; + INT8 current_bank; /* Z80 bank used in Battle Garegga and Batrider */ + + int sndirq_line; /* IRQ4 for batrider, IRQ2 for bbakraid */ + UINT16 z80_busreq; + int unlimited_ver; + + UINT16 *txvideoram16; + UINT16 *txvideoram16_offs; + UINT16 *txscrollram16; + UINT16 *tx_gfxram16; + + size_t tx_vram_size; + size_t tx_offs_vram_size; + size_t tx_scroll_vram_size; + size_t paletteram16_size; + + bitmap_t* custom_priority_bitmap; + bitmap_t* secondary_render_bitmap; + + tilemap_t *tx_tilemap; /* Tilemap for extra-text-layer */ + UINT8 tx_flip; + int display_tx; + int displog; }; @@ -40,22 +82,9 @@ void kbash_okisnd_w(running_device *device, int data); void fixeight_okisnd_w(running_device *device, int data); void batsugun_okisnd_w(running_device *device, int data); -/*----------- defined in drivers/toaplan2.c -----------*/ - -extern int toaplan2_sub_cpu; /*----------- defined in video/toaplan2.c -----------*/ -extern UINT16 *toaplan2_txvideoram16; -extern UINT16 *toaplan2_txvideoram16_offs; -extern UINT16 *toaplan2_txscrollram16; -extern UINT16 *toaplan2_tx_gfxram16; - -extern size_t toaplan2_tx_vram_size; -extern size_t toaplan2_tx_offs_vram_size; -extern size_t toaplan2_tx_scroll_vram_size; -extern size_t batrider_paletteram16_size; - VIDEO_EOF( toaplan2 ); VIDEO_START( toaplan2 ); VIDEO_START( truxton2 ); diff --git a/src/mame/machine/toaplan1.c b/src/mame/machine/toaplan1.c index c8e4549c43d..12a297b8518 100644 --- a/src/mame/machine/toaplan1.c +++ b/src/mame/machine/toaplan1.c @@ -38,28 +38,12 @@ static const UINT8 toaplan1_credits_for_coin[TOAPLAN1_REGION_OTHER+1][2][4] = { { 1, 1, 1, 1 }, { 1, 1, 1, 1 } }, /* TOAPLAN1_REGION_OTHER */ }; -static int toaplan1_coin_count; /* coin count increments on startup ? , so dont count it */ -static int toaplan1_intenable; - -static int demonwld_dsp_on; -static int demonwld_dsp_BIO; -static int dsp_execute; /* Demon world */ -static UINT32 dsp_addr_w, main_ram_seg; /* Demon world */ - -static UINT8 vimana_coins[2]; -static UINT8 vimana_credits; -static UINT8 vimana_latch; - - -int toaplan1_unk_reset_port; - -UINT8 *toaplan1_sharedram; - - INTERRUPT_GEN( toaplan1_interrupt ) { - if (toaplan1_intenable) + toaplan1_state *state = device->machine->driver_data(); + + if (state->intenable) cpu_set_input_line(device, 4, HOLD_LINE); } @@ -67,13 +51,16 @@ WRITE16_HANDLER( toaplan1_intenable_w ) { if (ACCESSING_BITS_0_7) { - toaplan1_intenable = data & 0xff; + toaplan1_state *state = space->machine->driver_data(); + state->intenable = data & 0xff; } } WRITE16_HANDLER( demonwld_dsp_addrsel_w ) { + toaplan1_state *state = space->machine->driver_data(); + /* This sets the main CPU RAM address the DSP should */ /* read/write, via the DSP IO port 0 */ /* Top three bits of data need to be shifted left 9 places */ @@ -82,41 +69,44 @@ WRITE16_HANDLER( demonwld_dsp_addrsel_w ) /* Lower thirteen bits of this data is shifted left one position */ /* to move it to an even address word boundary */ - main_ram_seg = ((data & 0xe000) << 9); - dsp_addr_w = ((data & 0x1fff) << 1); - logerror("DSP PC:%04x IO write %04x (%08x) at port 0\n",cpu_get_previouspc(space->cpu),data,main_ram_seg + dsp_addr_w); + state->main_ram_seg = ((data & 0xe000) << 9); + state->dsp_addr_w = ((data & 0x1fff) << 1); + logerror("DSP PC:%04x IO write %04x (%08x) at port 0\n", cpu_get_previouspc(space->cpu), data, state->main_ram_seg + state->dsp_addr_w); } READ16_HANDLER( demonwld_dsp_r ) { /* DSP can read data from main CPU RAM via DSP IO port 1 */ + toaplan1_state *state = space->machine->driver_data(); address_space *mainspace; UINT16 input_data = 0; - switch (main_ram_seg) { + + switch (state->main_ram_seg) { case 0xc00000: mainspace = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); - input_data = mainspace->read_word(main_ram_seg + dsp_addr_w); + input_data = mainspace->read_word(state->main_ram_seg + state->dsp_addr_w); break; - default: logerror("DSP PC:%04x Warning !!! IO reading from %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); + default: logerror("DSP PC:%04x Warning !!! IO reading from %08x (port 1)\n", cpu_get_previouspc(space->cpu), state->main_ram_seg + state->dsp_addr_w); } - logerror("DSP PC:%04x IO read %04x at %08x (port 1)\n",cpu_get_previouspc(space->cpu),input_data,main_ram_seg + dsp_addr_w); + logerror("DSP PC:%04x IO read %04x at %08x (port 1)\n", cpu_get_previouspc(space->cpu), input_data, state->main_ram_seg + state->dsp_addr_w); return input_data; } WRITE16_HANDLER( demonwld_dsp_w ) { + toaplan1_state *state = space->machine->driver_data(); address_space *mainspace; /* Data written to main CPU RAM via DSP IO port 1 */ - dsp_execute = 0; - switch (main_ram_seg) { - case 0xc00000: if ((dsp_addr_w < 3) && (data == 0)) dsp_execute = 1; + state->dsp_execute = 0; + switch (state->main_ram_seg) { + case 0xc00000: if ((state->dsp_addr_w < 3) && (data == 0)) state->dsp_execute = 1; mainspace = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); - mainspace->write_word(main_ram_seg + dsp_addr_w, data); + mainspace->write_word(state->main_ram_seg + state->dsp_addr_w, data); break; - default: logerror("DSP PC:%04x Warning !!! IO writing to %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); + default: logerror("DSP PC:%04x Warning !!! IO writing to %08x (port 1)\n", cpu_get_previouspc(space->cpu), state->main_ram_seg + state->dsp_addr_w); } - logerror("DSP PC:%04x IO write %04x at %08x (port 1)\n",cpu_get_previouspc(space->cpu),data,main_ram_seg + dsp_addr_w); + logerror("DSP PC:%04x IO write %04x at %08x (port 1)\n", cpu_get_previouspc(space->cpu), data, state->main_ram_seg + state->dsp_addr_w); } WRITE16_HANDLER( demonwld_dsp_bio_w ) @@ -126,29 +116,36 @@ WRITE16_HANDLER( demonwld_dsp_bio_w ) /* Actually only DSP data bit 15 controls this */ /* data 0x0000 means set DSP BIO line active and disable */ /* communication to main processor*/ - logerror("DSP PC:%04x IO write %04x at port 3\n",cpu_get_previouspc(space->cpu),data); + + toaplan1_state *state = space->machine->driver_data(); + + logerror("DSP PC:%04x IO write %04x at port 3\n", cpu_get_previouspc(space->cpu), data); if (data & 0x8000) { - demonwld_dsp_BIO = CLEAR_LINE; + state->dsp_BIO = CLEAR_LINE; } if (data == 0) { - if (dsp_execute) { + if (state->dsp_execute) { logerror("Turning 68000 on\n"); cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE); - dsp_execute = 0; + state->dsp_execute = 0; } - demonwld_dsp_BIO = ASSERT_LINE; + state->dsp_BIO = ASSERT_LINE; } } READ16_HANDLER ( demonwld_BIO_r ) { - return demonwld_dsp_BIO; + toaplan1_state *state = space->machine->driver_data(); + + return state->dsp_BIO; } static void demonwld_dsp(running_machine *machine, int enable) { - demonwld_dsp_on = enable; + toaplan1_state *state = machine->driver_data(); + + state->dsp_on = enable; if (enable) { logerror("Turning DSP on and 68000 off\n"); @@ -166,7 +163,8 @@ static void demonwld_dsp(running_machine *machine, int enable) static STATE_POSTLOAD( demonwld_restore_dsp ) { - demonwld_dsp(machine, demonwld_dsp_on); + toaplan1_state *state = machine->driver_data(); + demonwld_dsp(machine, state->dsp_on); } WRITE16_HANDLER( demonwld_dsp_ctrl_w ) @@ -207,32 +205,34 @@ READ16_HANDLER ( vimana_system_port_r ) TOAPLAN1_REGION_JAPAN, TOAPLAN1_REGION_OTHER, TOAPLAN1_REGION_OTHER, TOAPLAN1_REGION_OTHER, TOAPLAN1_REGION_OTHER, TOAPLAN1_REGION_OTHER, TOAPLAN1_REGION_OTHER, TOAPLAN1_REGION_JAPAN }; + + toaplan1_state *state = space->machine->driver_data(); int data, p, r, d, slot, reg, dsw; slot = -1; d = input_port_read(space->machine, "DSWA"); r = input_port_read(space->machine, "TJUMP"); p = input_port_read(space->machine, "SYSTEM"); - vimana_latch ^= p; - data = (vimana_latch & p); + state->vimana_latch ^= p; + data = (state->vimana_latch & p); /* simulate the mcu keeping track of credits based on region and coinage settings */ /* latch so it doesn't add more than one coin per keypress */ if (d & 0x04) /* "test mode" ON */ { - vimana_coins[0] = vimana_coins[1] = 0; - vimana_credits = 0; + state->vimana_coins[0] = state->vimana_coins[1] = 0; + state->vimana_credits = 0; } else /* "test mode" OFF */ { if (data & 0x02) /* TILT */ { - vimana_coins[0] = vimana_coins[1] = 0; - vimana_credits = 0; + state->vimana_coins[0] = state->vimana_coins[1] = 0; + state->vimana_credits = 0; } if (data & 0x01) /* SERVICE1 */ { - vimana_credits++ ; + state->vimana_credits++ ; } if (data & 0x08) /* COIN1 */ { @@ -247,23 +247,23 @@ READ16_HANDLER ( vimana_system_port_r ) { reg = vimana_region[r]; dsw = (d & 0xf0) >> (4 + 2 * slot); - vimana_coins[slot]++; - if (vimana_coins[slot] >= toaplan1_coins_for_credit[reg][slot][dsw]) + state->vimana_coins[slot]++; + if (state->vimana_coins[slot] >= toaplan1_coins_for_credit[reg][slot][dsw]) { - vimana_credits += toaplan1_credits_for_coin[reg][slot][dsw]; - vimana_coins[slot] -= toaplan1_coins_for_credit[reg][slot][dsw]; + state->vimana_credits += toaplan1_credits_for_coin[reg][slot][dsw]; + state->vimana_coins[slot] -= toaplan1_coins_for_credit[reg][slot][dsw]; } coin_counter_w(space->machine, slot, 1); coin_counter_w(space->machine, slot, 0); } - if (vimana_credits >= 9) - vimana_credits = 9; + if (state->vimana_credits >= 9) + state->vimana_credits = 9; } - coin_lockout_global_w(space->machine, (vimana_credits >= 9)); + coin_lockout_global_w(space->machine, (state->vimana_credits >= 9)); - vimana_latch = p; + state->vimana_latch = p; return p & 0xffff; } @@ -275,7 +275,12 @@ READ16_HANDLER( vimana_mcu_r ) { case 0: data = 0xff; break; case 1: data = 0x00; break; - case 2: data = vimana_credits; break; + case 2: + { + toaplan1_state *state = space->machine->driver_data(); + data = state->vimana_credits; + break; + } } return data & 0xff; } @@ -286,25 +291,29 @@ WRITE16_HANDLER( vimana_mcu_w ) { case 0: break; case 1: break; - case 2: if (ACCESSING_BITS_0_7) - { - vimana_credits = data & 0xff; - coin_lockout_global_w(space->machine, (vimana_credits >= 9)); - } - break; + case 2: + if (ACCESSING_BITS_0_7) + { + toaplan1_state *state = space->machine->driver_data(); + state->vimana_credits = data & 0xff; + coin_lockout_global_w(space->machine, (state->vimana_credits >= 9)); + } + break; } } READ16_HANDLER( toaplan1_shared_r ) { - return toaplan1_sharedram[offset] & 0xff; + toaplan1_state *state = space->machine->driver_data(); + return state->sharedram[offset] & 0xff; } WRITE16_HANDLER( toaplan1_shared_w ) { if (ACCESSING_BITS_0_7) { - toaplan1_sharedram[offset] = data & 0xff; + toaplan1_state *state = space->machine->driver_data(); + state->sharedram[offset] = data & 0xff; } } @@ -326,15 +335,17 @@ WRITE16_HANDLER( toaplan1_reset_sound ) WRITE8_HANDLER( rallybik_coin_w ) { + toaplan1_state *state = space->machine->driver_data(); + switch (data) { - case 0x08: if (toaplan1_coin_count) { coin_counter_w(space->machine, 0,1); coin_counter_w(space->machine, 0,0); } break; - case 0x09: if (toaplan1_coin_count) { coin_counter_w(space->machine, 2,1); coin_counter_w(space->machine, 2,0); } break; - case 0x0a: if (toaplan1_coin_count) { coin_counter_w(space->machine, 1,1); coin_counter_w(space->machine, 1,0); } break; - case 0x0b: if (toaplan1_coin_count) { coin_counter_w(space->machine, 3,1); coin_counter_w(space->machine, 3,0); } break; - case 0x0c: coin_lockout_w(space->machine, 0,1); coin_lockout_w(space->machine, 2,1); break; - case 0x0d: coin_lockout_w(space->machine, 0,0); coin_lockout_w(space->machine, 2,0); break; - case 0x0e: coin_lockout_w(space->machine, 1,1); coin_lockout_w(space->machine, 3,1); break; - case 0x0f: coin_lockout_w(space->machine, 1,0); coin_lockout_w(space->machine, 3,0); toaplan1_coin_count=1; break; + case 0x08: if (state->coin_count) { coin_counter_w(space->machine, 0, 1); coin_counter_w(space->machine, 0, 0); } break; + case 0x09: if (state->coin_count) { coin_counter_w(space->machine, 2, 1); coin_counter_w(space->machine, 2, 0); } break; + case 0x0a: if (state->coin_count) { coin_counter_w(space->machine, 1, 1); coin_counter_w(space->machine, 1, 0); } break; + case 0x0b: if (state->coin_count) { coin_counter_w(space->machine, 3, 1); coin_counter_w(space->machine, 3, 0); } break; + case 0x0c: coin_lockout_w(space->machine, 0, 1); coin_lockout_w(space->machine, 2, 1); break; + case 0x0d: coin_lockout_w(space->machine, 0, 0); coin_lockout_w(space->machine, 2, 0); break; + case 0x0e: coin_lockout_w(space->machine, 1, 1); coin_lockout_w(space->machine, 3, 1); break; + case 0x0f: coin_lockout_w(space->machine, 1, 0); coin_lockout_w(space->machine, 3, 0); state->coin_count=1; break; default: logerror("PC:%04x Writing unknown data (%04x) to coin count/lockout port\n",cpu_get_previouspc(space->cpu),data); break; } } @@ -384,55 +395,69 @@ WRITE16_HANDLER( samesame_coin_w ) MACHINE_RESET( toaplan1 ) { - toaplan1_intenable = 0; - toaplan1_coin_count = 0; - toaplan1_unk_reset_port = 0; + toaplan1_state *state = machine->driver_data(); + + state->intenable = 0; + state->coin_count = 0; + state->unk_reset_port = 0; coin_lockout_global_w(machine, 0); } void toaplan1_driver_savestate(running_machine *machine) { - state_save_register_global(machine, toaplan1_intenable); - state_save_register_global(machine, toaplan1_coin_count); - state_save_register_global(machine, toaplan1_unk_reset_port); + toaplan1_state *state = machine->driver_data(); + + state_save_register_global(machine, state->intenable); + state_save_register_global(machine, state->coin_count); + state_save_register_global(machine, state->unk_reset_port); } MACHINE_RESET( zerowing ) /* Hack for ZeroWing and OutZone. See the video driver */ { + toaplan1_state *state = machine->driver_data(); + MACHINE_RESET_CALL(toaplan1); - toaplan1_unk_reset_port = 1; + state->unk_reset_port = 1; } MACHINE_RESET( demonwld ) { + toaplan1_state *state = machine->driver_data(); + MACHINE_RESET_CALL(toaplan1); - dsp_addr_w = 0; - main_ram_seg = 0; - dsp_execute = 0; + state->dsp_addr_w = 0; + state->main_ram_seg = 0; + state->dsp_execute = 0; } void demonwld_driver_savestate(running_machine *machine) { - state_save_register_global(machine, demonwld_dsp_on); - state_save_register_global(machine, dsp_addr_w); - state_save_register_global(machine, main_ram_seg); - state_save_register_global(machine, demonwld_dsp_BIO); - state_save_register_global(machine, dsp_execute); + toaplan1_state *state = machine->driver_data(); + + state_save_register_global(machine, state->dsp_on); + state_save_register_global(machine, state->dsp_addr_w); + state_save_register_global(machine, state->main_ram_seg); + state_save_register_global(machine, state->dsp_BIO); + state_save_register_global(machine, state->dsp_execute); state_save_register_postload(machine, demonwld_restore_dsp, NULL); } MACHINE_RESET( vimana ) { + toaplan1_state *state = machine->driver_data(); + MACHINE_RESET_CALL(toaplan1); - vimana_coins[0] = vimana_coins[1] = 0; - vimana_credits = 0; - vimana_latch = 0; + state->vimana_coins[0] = state->vimana_coins[1] = 0; + state->vimana_credits = 0; + state->vimana_latch = 0; } void vimana_driver_savestate(running_machine *machine) { - state_save_register_global(machine, vimana_coins[0]); - state_save_register_global(machine, vimana_coins[1]); - state_save_register_global(machine, vimana_credits); - state_save_register_global(machine, vimana_latch); + toaplan1_state *state = machine->driver_data(); + + state_save_register_global(machine, state->vimana_coins[0]); + state_save_register_global(machine, state->vimana_coins[1]); + state_save_register_global(machine, state->vimana_credits); + state_save_register_global(machine, state->vimana_latch); } diff --git a/src/mame/video/gp9001.c b/src/mame/video/gp9001.c index 160cfcb33c4..54819443087 100644 --- a/src/mame/video/gp9001.c +++ b/src/mame/video/gp9001.c @@ -128,11 +128,6 @@ Pipi & Bibis | Fix Eight | V-Five | Snow Bros. 2 | #include "emu.h" #include "gp9001.h" -bitmap_t* gp9001_custom_priority_bitmap; -bitmap_t* gp9001_secondary_render_bitmap; - -int gp9001_displog = 0; - static WRITE16_DEVICE_HANDLER( gp9001_bg_tilemap_w ) { gp9001vdp_device *vdp = (gp9001vdp_device*)device; @@ -995,10 +990,10 @@ void gp9001_log_vram(gp9001vdp_device* vdp, running_machine *machine) if ( input_code_pressed_once(machine, KEYCODE_E) ) { - gp9001_displog += 1; - gp9001_displog &= 1; + *vdp->displog += 1; + *vdp->displog &= 1; } - if (gp9001_displog) + if (*vdp->displog) { logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); @@ -1176,7 +1171,7 @@ void gp9001vdp_device::draw_sprites( running_machine *machine, bitmap_t *bitmap, { UINT8 pix = srcdata[count]; UINT16* dstptr = BITMAP_ADDR16(bitmap,drawyy,drawxx); - UINT8* dstpri = BITMAP_ADDR8(gp9001_custom_priority_bitmap, drawyy, drawxx); + UINT8* dstpri = BITMAP_ADDR8(this->custom_priority_bitmap, drawyy, drawxx); if (priority >= dstpri[0]) { @@ -1228,7 +1223,7 @@ void gp9001vdp_device::gp9001_draw_custom_tilemap(running_machine* machine, bitm srcptr = BITMAP_ADDR16(tmb, realy, 0); dstptr = BITMAP_ADDR16(bitmap, y, 0); - dstpriptr = BITMAP_ADDR8(gp9001_custom_priority_bitmap, y, 0); + dstpriptr = BITMAP_ADDR8(this->custom_priority_bitmap, y, 0); for (x=0;xdriver_data(); int color, tile_number, attrib; - tile_number = pf1_tilevram16[2*tile_index+1] & 0x7fff; - attrib = pf1_tilevram16[2*tile_index]; + tile_number = state->pf1_tilevram16[2*tile_index+1] & 0x7fff; + attrib = state->pf1_tilevram16[2*tile_index]; color = attrib & 0x3f; SET_TILE_INFO( 0, tile_number, color, 0); - if (pf1_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; + if (state->pf1_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; else tileinfo->category = (attrib & 0xf000) >> 12; } static TILE_GET_INFO( get_pf2_tile_info ) { + toaplan1_state *state = machine->driver_data(); int color, tile_number, attrib; - tile_number = pf2_tilevram16[2*tile_index+1] & 0x7fff; - attrib = pf2_tilevram16[2*tile_index]; + tile_number = state->pf2_tilevram16[2*tile_index+1] & 0x7fff; + attrib = state->pf2_tilevram16[2*tile_index]; color = attrib & 0x3f; SET_TILE_INFO( 0, tile_number, color, 0); - if (pf2_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; + if (state->pf2_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; else tileinfo->category = (attrib & 0xf000) >> 12; } static TILE_GET_INFO( get_pf3_tile_info ) { + toaplan1_state *state = machine->driver_data(); int color, tile_number, attrib; - tile_number = pf3_tilevram16[2*tile_index+1] & 0x7fff; - attrib = pf3_tilevram16[2*tile_index]; + tile_number = state->pf3_tilevram16[2*tile_index+1] & 0x7fff; + attrib = state->pf3_tilevram16[2*tile_index]; color = attrib & 0x3f; SET_TILE_INFO( 0, tile_number, color, 0); - if (pf3_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; + if (state->pf3_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; else tileinfo->category = (attrib & 0xf000) >> 12; } static TILE_GET_INFO( get_pf4_tile_info ) { + toaplan1_state *state = machine->driver_data(); int color, tile_number, attrib; - tile_number = pf4_tilevram16[2*tile_index+1] & 0x7fff; - attrib = pf4_tilevram16[2*tile_index]; + tile_number = state->pf4_tilevram16[2*tile_index+1] & 0x7fff; + attrib = state->pf4_tilevram16[2*tile_index]; color = attrib & 0x3f; SET_TILE_INFO( 0, tile_number, color, 0); - if (pf4_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; + if (state->pf4_tilevram16[2*tile_index+1] & 0x8000) tileinfo->category = 0; else tileinfo->category = (attrib & 0xf000) >> 12; } @@ -257,163 +212,175 @@ static TILE_GET_INFO( get_pf4_tile_info ) static void toaplan1_create_tilemaps(running_machine *machine) { - pf1_tilemap = tilemap_create(machine, get_pf1_tile_info,tilemap_scan_rows,8,8,64,64); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info,tilemap_scan_rows,8,8,64,64); - pf3_tilemap = tilemap_create(machine, get_pf3_tile_info,tilemap_scan_rows,8,8,64,64); - pf4_tilemap = tilemap_create(machine, get_pf4_tile_info,tilemap_scan_rows,8,8,64,64); + toaplan1_state *state = machine->driver_data(); - tilemap_set_transparent_pen(pf1_tilemap,0); - tilemap_set_transparent_pen(pf2_tilemap,0); - tilemap_set_transparent_pen(pf3_tilemap,0); - tilemap_set_transparent_pen(pf4_tilemap,0); + state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8, 64, 64); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, tilemap_scan_rows, 8, 8, 64, 64); + state->pf3_tilemap = tilemap_create(machine, get_pf3_tile_info, tilemap_scan_rows, 8, 8, 64, 64); + state->pf4_tilemap = tilemap_create(machine, get_pf4_tile_info, tilemap_scan_rows, 8, 8, 64, 64); + + tilemap_set_transparent_pen(state->pf1_tilemap, 0); + tilemap_set_transparent_pen(state->pf2_tilemap, 0); + tilemap_set_transparent_pen(state->pf3_tilemap, 0); + tilemap_set_transparent_pen(state->pf4_tilemap, 0); } static void toaplan1_paletteram_alloc(running_machine *machine) { - machine->generic.paletteram.u16 = auto_alloc_array(machine, UINT16, (toaplan1_colorram1_size + toaplan1_colorram2_size)/2); + toaplan1_state *state = machine->driver_data(); + + machine->generic.paletteram.u16 = auto_alloc_array(machine, UINT16, (state->colorram1_size + state->colorram2_size)/2); + + state_save_register_global_pointer(machine, machine->generic.paletteram.u16, (state->colorram1_size + state->colorram2_size)/2); } static void toaplan1_vram_alloc(running_machine *machine) { - pf1_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); - pf2_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); - pf3_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); - pf4_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); + toaplan1_state *state = machine->driver_data(); + + state->pf1_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); + state->pf2_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); + state->pf3_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); + state->pf4_tilevram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_TILEVRAM_SIZE/2); + + state_save_register_global_pointer(machine, state->pf1_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); + state_save_register_global_pointer(machine, state->pf2_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); + state_save_register_global_pointer(machine, state->pf3_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); + state_save_register_global_pointer(machine, state->pf4_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); #ifdef MAME_DEBUG - display_pf1 = 1; - display_pf2 = 1; - display_pf3 = 1; - display_pf4 = 1; - displog = 0; + state->display_pf1 = 1; + state->display_pf2 = 1; + state->display_pf3 = 1; + state->display_pf4 = 1; + state->displog = 0; #endif } static void toaplan1_spritevram_alloc(running_machine *machine) { - machine->generic.spriteram.u16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITERAM_SIZE/2); - machine->generic.buffered_spriteram.u16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITERAM_SIZE/2); - toaplan1_spritesizeram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2); - toaplan1_buffered_spritesizeram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2); + toaplan1_state *state = machine->driver_data(); - machine->generic.spriteram_size = TOAPLAN1_SPRITERAM_SIZE; + state->spriteram = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITERAM_SIZE/2); + state->buffered_spriteram = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITERAM_SIZE/2); + state->spritesizeram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2); + state->buffered_spritesizeram16 = auto_alloc_array_clear(machine, UINT16, TOAPLAN1_SPRITESIZERAM_SIZE/2); + + state_save_register_global_pointer(machine, state->spriteram, TOAPLAN1_SPRITERAM_SIZE/2); + state_save_register_global_pointer(machine, state->buffered_spriteram, TOAPLAN1_SPRITERAM_SIZE/2); + state_save_register_global_pointer(machine, state->spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE/2); + state_save_register_global_pointer(machine, state->buffered_spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE/2); + + state->spriteram_size = TOAPLAN1_SPRITERAM_SIZE; } -static void toaplan1_set_scrolls(void) +static void toaplan1_set_scrolls(running_machine *machine) { - tilemap_set_scrollx(pf1_tilemap,0,(pf1_scrollx >> 7) - (tiles_offsetx - scrollx_offs1)); - tilemap_set_scrollx(pf2_tilemap,0,(pf2_scrollx >> 7) - (tiles_offsetx - scrollx_offs2)); - tilemap_set_scrollx(pf3_tilemap,0,(pf3_scrollx >> 7) - (tiles_offsetx - scrollx_offs3)); - tilemap_set_scrollx(pf4_tilemap,0,(pf4_scrollx >> 7) - (tiles_offsetx - scrollx_offs4)); - tilemap_set_scrolly(pf1_tilemap,0,(pf1_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf2_tilemap,0,(pf2_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf3_tilemap,0,(pf3_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf4_tilemap,0,(pf4_scrolly >> 7) - (tiles_offsety - scrolly_offs)); + toaplan1_state *state = machine->driver_data(); + + tilemap_set_scrollx(state->pf1_tilemap, 0, (state->pf1_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs1)); + tilemap_set_scrollx(state->pf2_tilemap, 0, (state->pf2_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs2)); + tilemap_set_scrollx(state->pf3_tilemap, 0, (state->pf3_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs3)); + tilemap_set_scrollx(state->pf4_tilemap, 0, (state->pf4_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs4)); + tilemap_set_scrolly(state->pf1_tilemap, 0, (state->pf1_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf2_tilemap, 0, (state->pf2_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf3_tilemap, 0, (state->pf3_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf4_tilemap, 0, (state->pf4_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); } static STATE_POSTLOAD( rallybik_flipscreen ) { + toaplan1_state *state = machine->driver_data(); address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - rallybik_bcu_flipscreen_w(space, 0, bcu_flipscreen, 0xffff); + + rallybik_bcu_flipscreen_w(space, 0, state->bcu_flipscreen, 0xffff); } static STATE_POSTLOAD( toaplan1_flipscreen ) { + toaplan1_state *state = machine->driver_data(); address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - toaplan1_bcu_flipscreen_w(space, 0, bcu_flipscreen, 0xffff); + + toaplan1_bcu_flipscreen_w(space, 0, state->bcu_flipscreen, 0xffff); +} + +static void register_common(running_machine *machine) +{ + toaplan1_state *state = machine->driver_data(); + + state_save_register_global(machine, state->scrollx_offs1); + state_save_register_global(machine, state->scrollx_offs2); + state_save_register_global(machine, state->scrollx_offs3); + state_save_register_global(machine, state->scrollx_offs4); + state_save_register_global(machine, state->scrolly_offs); + + state_save_register_global(machine, state->bcu_flipscreen); + state_save_register_global(machine, state->fcu_flipscreen); + state_save_register_global(machine, state->reset); + + state_save_register_global(machine, state->pf1_scrollx); + state_save_register_global(machine, state->pf1_scrolly); + state_save_register_global(machine, state->pf2_scrollx); + state_save_register_global(machine, state->pf2_scrolly); + state_save_register_global(machine, state->pf3_scrollx); + state_save_register_global(machine, state->pf3_scrolly); + state_save_register_global(machine, state->pf4_scrollx); + state_save_register_global(machine, state->pf4_scrolly); + + state_save_register_global(machine, state->tiles_offsetx); + state_save_register_global(machine, state->tiles_offsety); + state_save_register_global(machine, state->pf_voffs); + state_save_register_global(machine, state->spriteram_offs); } VIDEO_START( rallybik ) { + toaplan1_state *state = machine->driver_data(); + toaplan1_create_tilemaps(machine); toaplan1_paletteram_alloc(machine); toaplan1_vram_alloc(machine); - scrollx_offs1 = 0x00d + 6; - scrollx_offs2 = 0x00d + 4; - scrollx_offs3 = 0x00d + 2; - scrollx_offs4 = 0x00d + 0; - scrolly_offs = 0x111; + state->buffered_spriteram = auto_alloc_array_clear(machine, UINT16, state->spriteram_size/2); + state_save_register_global_pointer(machine, state->buffered_spriteram, state->spriteram_size/2); - bcu_flipscreen = -1; - toaplan1_reset = 0; + state->scrollx_offs1 = 0x00d + 6; + state->scrollx_offs2 = 0x00d + 4; + state->scrollx_offs3 = 0x00d + 2; + state->scrollx_offs4 = 0x00d + 0; + state->scrolly_offs = 0x111; - state_save_register_global_pointer(machine, machine->generic.paletteram.u16, (toaplan1_colorram1_size + toaplan1_colorram2_size)/2); - state_save_register_global_pointer(machine, pf1_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); - state_save_register_global_pointer(machine, pf2_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); - state_save_register_global_pointer(machine, pf3_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); - state_save_register_global_pointer(machine, pf4_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); + state->bcu_flipscreen = -1; + state->fcu_flipscreen = 0; + state->reset = 0; - state_save_register_global(machine, scrollx_offs1); - state_save_register_global(machine, scrollx_offs2); - state_save_register_global(machine, scrollx_offs3); - state_save_register_global(machine, scrollx_offs4); - state_save_register_global(machine, scrolly_offs); - state_save_register_global(machine, bcu_flipscreen); - state_save_register_global(machine, pf1_scrollx); - state_save_register_global(machine, pf1_scrolly); - state_save_register_global(machine, pf2_scrollx); - state_save_register_global(machine, pf2_scrolly); - state_save_register_global(machine, pf3_scrollx); - state_save_register_global(machine, pf3_scrolly); - state_save_register_global(machine, pf4_scrollx); - state_save_register_global(machine, pf4_scrolly); - state_save_register_global(machine, tiles_offsetx); - state_save_register_global(machine, tiles_offsety); - state_save_register_global(machine, pf_voffs); - state_save_register_global(machine, spriteram_offs); + register_common(machine); state_save_register_postload(machine, rallybik_flipscreen, NULL); } VIDEO_START( toaplan1 ) { + toaplan1_state *state = machine->driver_data(); + toaplan1_create_tilemaps(machine); toaplan1_paletteram_alloc(machine); toaplan1_vram_alloc(machine); toaplan1_spritevram_alloc(machine); - scrollx_offs1 = 0x1ef + 6; - scrollx_offs2 = 0x1ef + 4; - scrollx_offs3 = 0x1ef + 2; - scrollx_offs4 = 0x1ef + 0; - scrolly_offs = 0x101; + state->scrollx_offs1 = 0x1ef + 6; + state->scrollx_offs2 = 0x1ef + 4; + state->scrollx_offs3 = 0x1ef + 2; + state->scrollx_offs4 = 0x1ef + 0; + state->scrolly_offs = 0x101; - bcu_flipscreen = -1; - fcu_flipscreen = 0; - toaplan1_reset = 1; + state->bcu_flipscreen = -1; + state->fcu_flipscreen = 0; + state->reset = 1; - state_save_register_global_pointer(machine, machine->generic.paletteram.u16, (toaplan1_colorram1_size + toaplan1_colorram2_size)/2); - state_save_register_global_pointer(machine, pf1_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); - state_save_register_global_pointer(machine, pf2_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); - state_save_register_global_pointer(machine, pf3_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); - state_save_register_global_pointer(machine, pf4_tilevram16, TOAPLAN1_TILEVRAM_SIZE/2); - state_save_register_global_pointer(machine, machine->generic.spriteram.u16, TOAPLAN1_SPRITERAM_SIZE/2); - state_save_register_global_pointer(machine, machine->generic.buffered_spriteram.u16, TOAPLAN1_SPRITERAM_SIZE/2); - state_save_register_global_pointer(machine, toaplan1_spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE/2); - state_save_register_global_pointer(machine, toaplan1_buffered_spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE/2); - - state_save_register_global(machine, scrollx_offs1); - state_save_register_global(machine, scrollx_offs2); - state_save_register_global(machine, scrollx_offs3); - state_save_register_global(machine, scrollx_offs4); - state_save_register_global(machine, scrolly_offs); - state_save_register_global(machine, bcu_flipscreen); - state_save_register_global(machine, fcu_flipscreen); - state_save_register_global(machine, pf1_scrollx); - state_save_register_global(machine, pf1_scrolly); - state_save_register_global(machine, pf2_scrolly); - state_save_register_global(machine, pf2_scrollx); - state_save_register_global(machine, pf3_scrollx); - state_save_register_global(machine, pf3_scrolly); - state_save_register_global(machine, pf4_scrollx); - state_save_register_global(machine, pf4_scrolly); - state_save_register_global(machine, tiles_offsetx); - state_save_register_global(machine, tiles_offsety); - state_save_register_global(machine, pf_voffs); - state_save_register_global(machine, spriteram_offs); + register_common(machine); state_save_register_postload(machine, toaplan1_flipscreen, NULL); } @@ -432,74 +399,80 @@ READ16_HANDLER( toaplan1_frame_done_r ) WRITE16_HANDLER( toaplan1_tile_offsets_w ) { + toaplan1_state *state = space->machine->driver_data(); + if ( offset == 0 ) { - COMBINE_DATA(&tiles_offsetx); - logerror("Tiles_offsetx now = %08x\n",tiles_offsetx); + COMBINE_DATA(&state->tiles_offsetx); + logerror("Tiles_offsetx now = %08x\n", state->tiles_offsetx); } else { - COMBINE_DATA(&tiles_offsety); - logerror("Tiles_offsety now = %08x\n",tiles_offsety); + COMBINE_DATA(&state->tiles_offsety); + logerror("Tiles_offsety now = %08x\n", state->tiles_offsety); } - toaplan1_reset = 1; - toaplan1_set_scrolls(); + state->reset = 1; + toaplan1_set_scrolls(space->machine); } WRITE16_HANDLER( rallybik_bcu_flipscreen_w ) { - if (ACCESSING_BITS_0_7 && (data != bcu_flipscreen)) + toaplan1_state *state = space->machine->driver_data(); + + if (ACCESSING_BITS_0_7 && (data != state->bcu_flipscreen)) { logerror("Setting BCU controller flipscreen port to %04x\n",data); - bcu_flipscreen = data & 0x01; /* 0x0001 = flip, 0x0000 = no flip */ + state->bcu_flipscreen = data & 0x01; /* 0x0001 = flip, 0x0000 = no flip */ tilemap_set_flip_all(space->machine, (data ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0)); - if (bcu_flipscreen) + if (state->bcu_flipscreen) { - scrollx_offs1 = 0x1c0 - 6; - scrollx_offs2 = 0x1c0 - 4; - scrollx_offs3 = 0x1c0 - 2; - scrollx_offs4 = 0x1c0 - 0; - scrolly_offs = 0x0e8; + state->scrollx_offs1 = 0x1c0 - 6; + state->scrollx_offs2 = 0x1c0 - 4; + state->scrollx_offs3 = 0x1c0 - 2; + state->scrollx_offs4 = 0x1c0 - 0; + state->scrolly_offs = 0x0e8; } else { - scrollx_offs1 = 0x00d + 6; - scrollx_offs2 = 0x00d + 4; - scrollx_offs3 = 0x00d + 2; - scrollx_offs4 = 0x00d + 0; - scrolly_offs = 0x111; + state->scrollx_offs1 = 0x00d + 6; + state->scrollx_offs2 = 0x00d + 4; + state->scrollx_offs3 = 0x00d + 2; + state->scrollx_offs4 = 0x00d + 0; + state->scrolly_offs = 0x111; } - toaplan1_set_scrolls(); + toaplan1_set_scrolls(space->machine); } } WRITE16_HANDLER( toaplan1_bcu_flipscreen_w ) { - if (ACCESSING_BITS_0_7 && (data != bcu_flipscreen)) + toaplan1_state *state = space->machine->driver_data(); + + if (ACCESSING_BITS_0_7 && (data != state->bcu_flipscreen)) { logerror("Setting BCU controller flipscreen port to %04x\n",data); - bcu_flipscreen = data & 0x01; /* 0x0001 = flip, 0x0000 = no flip */ + state->bcu_flipscreen = data & 0x01; /* 0x0001 = flip, 0x0000 = no flip */ tilemap_set_flip_all(space->machine, (data ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0)); - if (bcu_flipscreen) + if (state->bcu_flipscreen) { const rectangle &visarea = space->machine->primary_screen->visible_area(); - scrollx_offs1 = 0x151 - 6; - scrollx_offs2 = 0x151 - 4; - scrollx_offs3 = 0x151 - 2; - scrollx_offs4 = 0x151 - 0; - scrolly_offs = 0x1ef; - scrolly_offs += ((visarea.max_y + 1) - ((visarea.max_y + 1) - visarea.min_y)) * 2; /* Horizontal games are offset so adjust by +0x20 */ + state->scrollx_offs1 = 0x151 - 6; + state->scrollx_offs2 = 0x151 - 4; + state->scrollx_offs3 = 0x151 - 2; + state->scrollx_offs4 = 0x151 - 0; + state->scrolly_offs = 0x1ef; + state->scrolly_offs += ((visarea.max_y + 1) - ((visarea.max_y + 1) - visarea.min_y)) * 2; /* Horizontal games are offset so adjust by +0x20 */ } else { - scrollx_offs1 = 0x1ef + 6; - scrollx_offs2 = 0x1ef + 4; - scrollx_offs3 = 0x1ef + 2; - scrollx_offs4 = 0x1ef + 0; - scrolly_offs = 0x101; + state->scrollx_offs1 = 0x1ef + 6; + state->scrollx_offs2 = 0x1ef + 4; + state->scrollx_offs3 = 0x1ef + 2; + state->scrollx_offs4 = 0x1ef + 0; + state->scrolly_offs = 0x101; } - toaplan1_set_scrolls(); + toaplan1_set_scrolls(space->machine); } } @@ -507,141 +480,170 @@ WRITE16_HANDLER( toaplan1_fcu_flipscreen_w ) { if (ACCESSING_BITS_8_15) { + toaplan1_state *state = space->machine->driver_data(); + logerror("Setting FCU controller flipscreen port to %04x\n",data); - fcu_flipscreen = data & 0x8000; /* 0x8000 = flip, 0x0000 = no flip */ + state->fcu_flipscreen = data & 0x8000; /* 0x8000 = flip, 0x0000 = no flip */ } } READ16_HANDLER( toaplan1_spriteram_offs_r ) /// this aint really needed ? { - return spriteram_offs; + toaplan1_state *state = space->machine->driver_data(); + + return state->spriteram_offs; } WRITE16_HANDLER( toaplan1_spriteram_offs_w ) { - COMBINE_DATA(&spriteram_offs); + toaplan1_state *state = space->machine->driver_data(); + + COMBINE_DATA(&state->spriteram_offs); } /* tile palette */ READ16_HANDLER( toaplan1_colorram1_r ) { - return toaplan1_colorram1[offset]; + toaplan1_state *state = space->machine->driver_data(); + + return state->colorram1[offset]; } WRITE16_HANDLER( toaplan1_colorram1_w ) { - COMBINE_DATA(&toaplan1_colorram1[offset]); - paletteram16_xBBBBBGGGGGRRRRR_word_w(space,offset, data, mem_mask); + toaplan1_state *state = space->machine->driver_data(); + + COMBINE_DATA(&state->colorram1[offset]); + paletteram16_xBBBBBGGGGGRRRRR_word_w(space, offset, data, mem_mask); } /* sprite palette */ READ16_HANDLER( toaplan1_colorram2_r ) { - return toaplan1_colorram2[offset]; + toaplan1_state *state = space->machine->driver_data(); + + return state->colorram2[offset]; } WRITE16_HANDLER( toaplan1_colorram2_w ) { - COMBINE_DATA(&toaplan1_colorram2[offset]); - paletteram16_xBBBBBGGGGGRRRRR_word_w(space,offset+(toaplan1_colorram1_size/2), data, mem_mask); + toaplan1_state *state = space->machine->driver_data(); + + COMBINE_DATA(&state->colorram2[offset]); + paletteram16_xBBBBBGGGGGRRRRR_word_w(space, offset+(state->colorram1_size/2), data, mem_mask); } READ16_HANDLER( toaplan1_spriteram16_r ) { - return space->machine->generic.spriteram.u16[spriteram_offs & ((TOAPLAN1_SPRITERAM_SIZE/2)-1)]; + toaplan1_state *state = space->machine->driver_data(); + + return state->spriteram[state->spriteram_offs & ((TOAPLAN1_SPRITERAM_SIZE/2)-1)]; } WRITE16_HANDLER( toaplan1_spriteram16_w ) { - COMBINE_DATA(&space->machine->generic.spriteram.u16[spriteram_offs & ((TOAPLAN1_SPRITERAM_SIZE/2)-1)]); + toaplan1_state *state = space->machine->driver_data(); + + COMBINE_DATA(&state->spriteram[state->spriteram_offs & ((TOAPLAN1_SPRITERAM_SIZE/2)-1)]); #ifdef MAME_DEBUG - if (spriteram_offs >= (TOAPLAN1_SPRITERAM_SIZE/2)) + if (state->spriteram_offs >= (TOAPLAN1_SPRITERAM_SIZE/2)) { - logerror("Sprite_RAM_word_w, %08x out of range !\n", spriteram_offs); + logerror("Sprite_RAM_word_w, %08x out of range !\n", state->spriteram_offs); return; } #endif - spriteram_offs++; + state->spriteram_offs++; } READ16_HANDLER( toaplan1_spritesizeram16_r ) { - return toaplan1_spritesizeram16[spriteram_offs & ((TOAPLAN1_SPRITESIZERAM_SIZE/2)-1)]; + toaplan1_state *state = space->machine->driver_data(); + + return state->spritesizeram16[state->spriteram_offs & ((TOAPLAN1_SPRITESIZERAM_SIZE/2)-1)]; } WRITE16_HANDLER( toaplan1_spritesizeram16_w ) { - COMBINE_DATA(&toaplan1_spritesizeram16[spriteram_offs & ((TOAPLAN1_SPRITESIZERAM_SIZE/2)-1)]); + toaplan1_state *state = space->machine->driver_data(); + + COMBINE_DATA(&state->spritesizeram16[state->spriteram_offs & ((TOAPLAN1_SPRITESIZERAM_SIZE/2)-1)]); #ifdef MAME_DEBUG - if (spriteram_offs >= (TOAPLAN1_SPRITESIZERAM_SIZE/2)) + if (state->spriteram_offs >= (TOAPLAN1_SPRITESIZERAM_SIZE/2)) { - logerror("Sprite_Size_RAM_word_w, %08x out of range !\n", spriteram_offs); + logerror("Sprite_Size_RAM_word_w, %08x out of range !\n", state->spriteram_offs); return; } #endif - spriteram_offs++; /// really ? shouldn't happen on the sizeram + state->spriteram_offs++; /// really ? shouldn't happen on the sizeram } WRITE16_HANDLER( toaplan1_bcu_control_w ) { + toaplan1_state *state = space->machine->driver_data(); + logerror("BCU tile controller register:%02x now = %04x\n",offset,data); /*** Hack for Zero Wing and OutZone, to reset the sound system on */ /*** soft resets. These two games don't have a sound reset port, */ /*** unlike the other games */ - if (toaplan1_unk_reset_port && toaplan1_reset) + if (state->unk_reset_port && state->reset) { - toaplan1_reset = 0; + state->reset = 0; toaplan1_reset_sound(space,0,0,0); } } READ16_HANDLER( toaplan1_tileram_offs_r ) { - return pf_voffs; + toaplan1_state *state = space->machine->driver_data(); + + return state->pf_voffs; } WRITE16_HANDLER( toaplan1_tileram_offs_w ) { + toaplan1_state *state = space->machine->driver_data(); + if (data >= 0x4000) logerror("Hmmm, unknown video layer being selected (%08x)\n",data); - COMBINE_DATA(&pf_voffs); + COMBINE_DATA(&state->pf_voffs); } READ16_HANDLER( toaplan1_tileram16_r ) { + toaplan1_state *state = space->machine->driver_data(); offs_t vram_offset; UINT16 video_data = 0; - switch (pf_voffs & 0xf000) /* Locate Layer (PlayField) */ + switch (state->pf_voffs & 0xf000) /* Locate Layer (PlayField) */ { case 0x0000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - video_data = pf1_tilevram16[vram_offset]; + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + video_data = state->pf1_tilevram16[vram_offset]; break; case 0x1000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - video_data = pf2_tilevram16[vram_offset]; + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + video_data = state->pf2_tilevram16[vram_offset]; break; case 0x2000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - video_data = pf3_tilevram16[vram_offset]; + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + video_data = state->pf3_tilevram16[vram_offset]; break; case 0x3000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - video_data = pf4_tilevram16[vram_offset]; + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + video_data = state->pf4_tilevram16[vram_offset]; break; default: - logerror("Hmmm, reading %04x from unknown playfield layer address %06x Offset:%01x !!!\n",video_data,pf_voffs,offset); + logerror("Hmmm, reading %04x from unknown playfield layer address %06x Offset:%01x !!!\n", video_data, state->pf_voffs, offset); break; } @@ -662,32 +664,33 @@ READ16_HANDLER( rallybik_tileram16_r ) WRITE16_HANDLER( toaplan1_tileram16_w ) { + toaplan1_state *state = space->machine->driver_data(); offs_t vram_offset; - switch (pf_voffs & 0xf000) /* Locate Layer (PlayField) */ + switch (state->pf_voffs & 0xf000) /* Locate Layer (PlayField) */ { case 0x0000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - COMBINE_DATA(&pf1_tilevram16[vram_offset]); - tilemap_mark_tile_dirty(pf1_tilemap,vram_offset/2); + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + COMBINE_DATA(&state->pf1_tilevram16[vram_offset]); + tilemap_mark_tile_dirty(state->pf1_tilemap, vram_offset/2); break; case 0x1000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - COMBINE_DATA(&pf2_tilevram16[vram_offset]); - tilemap_mark_tile_dirty(pf2_tilemap,vram_offset/2); + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + COMBINE_DATA(&state->pf2_tilevram16[vram_offset]); + tilemap_mark_tile_dirty(state->pf2_tilemap, vram_offset/2); break; case 0x2000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - COMBINE_DATA(&pf3_tilevram16[vram_offset]); - tilemap_mark_tile_dirty(pf3_tilemap,vram_offset/2); + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + COMBINE_DATA(&state->pf3_tilevram16[vram_offset]); + tilemap_mark_tile_dirty(state->pf3_tilemap, vram_offset/2); break; case 0x3000: - vram_offset = ((pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); - COMBINE_DATA(&pf4_tilevram16[vram_offset]); - tilemap_mark_tile_dirty(pf4_tilemap,vram_offset/2); + vram_offset = ((state->pf_voffs * 2) + offset) & ((TOAPLAN1_TILEVRAM_SIZE/2)-1); + COMBINE_DATA(&state->pf4_tilevram16[vram_offset]); + tilemap_mark_tile_dirty(state->pf4_tilemap, vram_offset/2); break; default: - logerror("Hmmm, writing %04x to unknown playfield layer address %06x Offset:%01x\n",data,pf_voffs,offset); + logerror("Hmmm, writing %04x to unknown playfield layer address %06x Offset:%01x\n", data, state->pf_voffs, offset); break; } } @@ -696,18 +699,19 @@ WRITE16_HANDLER( toaplan1_tileram16_w ) READ16_HANDLER( toaplan1_scroll_regs_r ) { + toaplan1_state *state = space->machine->driver_data(); UINT16 scroll = 0; switch(offset) { - case 00: scroll = pf1_scrollx; break; - case 01: scroll = pf1_scrolly; break; - case 02: scroll = pf2_scrollx; break; - case 03: scroll = pf2_scrolly; break; - case 04: scroll = pf3_scrollx; break; - case 05: scroll = pf3_scrolly; break; - case 06: scroll = pf4_scrollx; break; - case 07: scroll = pf4_scrolly; break; + case 00: scroll = state->pf1_scrollx; break; + case 01: scroll = state->pf1_scrolly; break; + case 02: scroll = state->pf2_scrollx; break; + case 03: scroll = state->pf2_scrolly; break; + case 04: scroll = state->pf3_scrollx; break; + case 05: scroll = state->pf3_scrolly; break; + case 06: scroll = state->pf4_scrollx; break; + case 07: scroll = state->pf4_scrolly; break; default: logerror("Hmmm, reading unknown video scroll register (%08x) !!!\n",offset); break; } @@ -717,31 +721,33 @@ READ16_HANDLER( toaplan1_scroll_regs_r ) WRITE16_HANDLER( toaplan1_scroll_regs_w ) { + toaplan1_state *state = space->machine->driver_data(); + switch(offset) { - case 00: COMBINE_DATA(&pf1_scrollx); /* 1D3h */ - tilemap_set_scrollx(pf1_tilemap,0,(pf1_scrollx >> 7) - (tiles_offsetx - scrollx_offs1)); + case 00: COMBINE_DATA(&state->pf1_scrollx); /* 1D3h */ + tilemap_set_scrollx(state->pf1_tilemap, 0, (state->pf1_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs1)); break; - case 01: COMBINE_DATA(&pf1_scrolly); /* 1EBh */ - tilemap_set_scrolly(pf1_tilemap,0,(pf1_scrolly >> 7) - (tiles_offsety - scrolly_offs)); + case 01: COMBINE_DATA(&state->pf1_scrolly); /* 1EBh */ + tilemap_set_scrolly(state->pf1_tilemap, 0, (state->pf1_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); break; - case 02: COMBINE_DATA(&pf2_scrollx); /* 1D5h */ - tilemap_set_scrollx(pf2_tilemap,0,(pf2_scrollx >> 7) - (tiles_offsetx - scrollx_offs2)); + case 02: COMBINE_DATA(&state->pf2_scrollx); /* 1D5h */ + tilemap_set_scrollx(state->pf2_tilemap, 0, (state->pf2_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs2)); break; - case 03: COMBINE_DATA(&pf2_scrolly); /* 1EBh */ - tilemap_set_scrolly(pf2_tilemap,0,(pf2_scrolly >> 7) - (tiles_offsety - scrolly_offs)); + case 03: COMBINE_DATA(&state->pf2_scrolly); /* 1EBh */ + tilemap_set_scrolly(state->pf2_tilemap, 0, (state->pf2_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); break; - case 04: COMBINE_DATA(&pf3_scrollx); /* 1D7h */ - tilemap_set_scrollx(pf3_tilemap,0,(pf3_scrollx >> 7) - (tiles_offsetx - scrollx_offs3)); + case 04: COMBINE_DATA(&state->pf3_scrollx); /* 1D7h */ + tilemap_set_scrollx(state->pf3_tilemap, 0, (state->pf3_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs3)); break; - case 05: COMBINE_DATA(&pf3_scrolly); /* 1EBh */ - tilemap_set_scrolly(pf3_tilemap,0,(pf3_scrolly >> 7) - (tiles_offsety - scrolly_offs)); + case 05: COMBINE_DATA(&state->pf3_scrolly); /* 1EBh */ + tilemap_set_scrolly(state->pf3_tilemap, 0, (state->pf3_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); break; - case 06: COMBINE_DATA(&pf4_scrollx); /* 1D9h */ - tilemap_set_scrollx(pf4_tilemap,0,(pf4_scrollx >> 7) - (tiles_offsetx - scrollx_offs4)); + case 06: COMBINE_DATA(&state->pf4_scrollx); /* 1D9h */ + tilemap_set_scrollx(state->pf4_tilemap, 0, (state->pf4_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs4)); break; - case 07: COMBINE_DATA(&pf4_scrolly); /* 1EBh */ - tilemap_set_scrolly(pf4_tilemap,0,(pf4_scrolly >> 7) - (tiles_offsety - scrolly_offs)); + case 07: COMBINE_DATA(&state->pf4_scrolly); /* 1EBh */ + tilemap_set_scrolly(state->pf4_tilemap, 0, (state->pf4_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); break; default: logerror("Hmmm, writing %08x to unknown video scroll register (%08x) !!!\n",data ,offset); break; @@ -754,20 +760,23 @@ WRITE16_HANDLER( toaplan1_scroll_regs_w ) static void toaplan1_log_vram(running_machine *machine) { #ifdef MAME_DEBUG + toaplan1_state *state = machine->driver_data(); + if ( input_code_pressed(machine, KEYCODE_M) ) { - UINT16 *spriteram16 = machine->generic.spriteram.u16; - UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16; + UINT16 *spriteram16 = state->spriteram; + UINT16 *buffered_spriteram16 = state->buffered_spriteram; offs_t sprite_voffs; while (input_code_pressed(machine, KEYCODE_M)) ; - if (toaplan1_spritesizeram16) /* FCU controller */ + if (state->spritesizeram16) /* FCU controller */ { int schar,sattr,sxpos,sypos,bschar,bsattr,bsxpos,bsypos; - UINT16 *size = (UINT16 *)(toaplan1_spritesizeram16); - UINT16 *bsize = (UINT16 *)(toaplan1_buffered_spritesizeram16); + UINT16 *size = (UINT16 *)(state->spritesizeram16); + UINT16 *bsize = (UINT16 *)(state->buffered_spritesizeram16); logerror("Scrolls PF1-X PF1-Y PF2-X PF2-Y PF3-X PF3-Y PF4-X PF4-Y\n"); - logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n",pf1_scrollx,pf1_scrolly,pf2_scrollx,pf2_scrolly,pf3_scrollx,pf3_scrolly,pf4_scrollx,pf4_scrolly); - for ( sprite_voffs = 0; sprite_voffs < (machine->generic.spriteram_size/2); sprite_voffs += 4 ) + logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n", + state->pf1_scrollx, state->pf1_scrolly, state->pf2_scrollx, state->pf2_scrolly, state->pf3_scrollx, state->pf3_scrolly, state->pf4_scrollx, state->pf4_scrolly); + for ( sprite_voffs = 0; sprite_voffs < state->spriteram_size/2; sprite_voffs += 4 ) { bschar = buffered_spriteram16[sprite_voffs]; bsattr = buffered_spriteram16[sprite_voffs + 1]; @@ -786,8 +795,9 @@ static void toaplan1_log_vram(running_machine *machine) { int schar,sattr,sxpos,sypos,bschar,bsattr,bsxpos,bsypos; logerror("Scrolls PF1-X PF1-Y PF2-X PF2-Y PF3-X PF3-Y PF4-X PF4-Y\n"); - logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n",pf1_scrollx,pf1_scrolly,pf2_scrollx,pf2_scrolly,pf3_scrollx,pf3_scrolly,pf4_scrollx,pf4_scrolly); - for ( sprite_voffs = 0; sprite_voffs < (machine->generic.spriteram_size/2); sprite_voffs += 4 ) + logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n", + state->pf1_scrollx, state->pf1_scrolly, state->pf2_scrollx, state->pf2_scrolly, state->pf3_scrollx, state->pf3_scrolly, state->pf4_scrollx, state->pf4_scrolly); + for ( sprite_voffs = 0; sprite_voffs < state->spriteram_size/2; sprite_voffs += 4 ) { bschar = buffered_spriteram16[sprite_voffs]; bsattr = buffered_spriteram16[sprite_voffs + 1]; @@ -806,14 +816,15 @@ static void toaplan1_log_vram(running_machine *machine) if ( input_code_pressed(machine, KEYCODE_SLASH) ) { - UINT16 *size = (UINT16 *)(toaplan1_spritesizeram16); - UINT16 *bsize = (UINT16 *)(toaplan1_buffered_spritesizeram16); + UINT16 *size = (UINT16 *)(state->spritesizeram16); + UINT16 *bsize = (UINT16 *)(state->buffered_spritesizeram16); offs_t offs; while (input_code_pressed(machine, KEYCODE_SLASH)) ; - if (toaplan1_spritesizeram16) /* FCU controller */ + if (state->spritesizeram16) /* FCU controller */ { logerror("Scrolls PF1-X PF1-Y PF2-X PF2-Y PF3-X PF3-Y PF4-X PF4-Y\n"); - logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n",pf1_scrollx,pf1_scrolly,pf2_scrollx,pf2_scrolly,pf3_scrollx,pf3_scrolly,pf4_scrollx,pf4_scrolly); + logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n", + state->pf1_scrollx, state->pf1_scrolly, state->pf2_scrollx, state->pf2_scrolly, state->pf3_scrollx, state->pf3_scrolly, state->pf4_scrollx, state->pf4_scrolly); for ( offs = 0; offs < (TOAPLAN1_SPRITESIZERAM_SIZE/2); offs +=4 ) { logerror("SizeOffs:%04x now:%04x %04x %04x %04x next: %04x %04x %04x %04x\n", offs, @@ -831,17 +842,18 @@ static void toaplan1_log_vram(running_machine *machine) int tchar[5], tattr[5]; while (input_code_pressed(machine, KEYCODE_N)) ; /* BCU controller */ logerror("Scrolls PF1-X PF1-Y PF2-X PF2-Y PF3-X PF3-Y PF4-X PF4-Y\n"); - logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n",pf1_scrollx,pf1_scrolly,pf2_scrollx,pf2_scrolly,pf3_scrollx,pf3_scrolly,pf4_scrollx,pf4_scrolly); + logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n", + state->pf1_scrollx, state->pf1_scrolly, state->pf2_scrollx, state->pf2_scrolly, state->pf3_scrollx, state->pf3_scrolly, state->pf4_scrollx, state->pf4_scrolly); for ( tile_voffs = 0; tile_voffs < (TOAPLAN1_TILEVRAM_SIZE/2); tile_voffs += 2 ) { - tchar[1] = pf1_tilevram16[tile_voffs + 1]; - tattr[1] = pf1_tilevram16[tile_voffs]; - tchar[2] = pf2_tilevram16[tile_voffs + 1]; - tattr[2] = pf2_tilevram16[tile_voffs]; - tchar[3] = pf3_tilevram16[tile_voffs + 1]; - tattr[3] = pf3_tilevram16[tile_voffs]; - tchar[4] = pf4_tilevram16[tile_voffs + 1]; - tattr[4] = pf4_tilevram16[tile_voffs]; + tchar[1] = state->pf1_tilevram16[tile_voffs + 1]; + tattr[1] = state->pf1_tilevram16[tile_voffs]; + tchar[2] = state->pf2_tilevram16[tile_voffs + 1]; + tattr[2] = state->pf2_tilevram16[tile_voffs]; + tchar[3] = state->pf3_tilevram16[tile_voffs + 1]; + tattr[3] = state->pf3_tilevram16[tile_voffs]; + tchar[4] = state->pf4_tilevram16[tile_voffs + 1]; + tattr[4] = state->pf4_tilevram16[tile_voffs]; // logerror("PF3 offs:%04x Tile:%04x Attr:%04x\n", tile_voffs, tchar, tattr); logerror("$(%04x) Attr-Tile PF1:%04x-%04x PF2:%04x-%04x PF3:%04x-%04x PF4:%04x-%04x\n", tile_voffs, tattr[1], tchar[1], tattr[2], tchar[2], @@ -857,82 +869,83 @@ static void toaplan1_log_vram(running_machine *machine) if ( input_code_pressed(machine, KEYCODE_E) ) { while (input_code_pressed(machine, KEYCODE_E)) ; - displog += 1; - displog &= 1; + state->displog += 1; + state->displog &= 1; } - if (displog) + if (state->displog) { logerror("Scrolls PF1-X PF1-Y PF2-X PF2-Y PF3-X PF3-Y PF4-X PF4-Y\n"); - logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n",pf1_scrollx,pf1_scrolly,pf2_scrollx,pf2_scrolly,pf3_scrollx,pf3_scrolly,pf4_scrollx,pf4_scrolly); + logerror("------> #%04x #%04x #%04x #%04x #%04x #%04x #%04x #%04x\n", + state->pf1_scrollx, state->pf1_scrolly, state->pf2_scrollx, state->pf2_scrolly, state->pf3_scrollx, state->pf3_scrolly, state->pf4_scrollx, state->pf4_scrolly); } if ( input_code_pressed(machine, KEYCODE_B) ) { // while (input_code_pressed(machine, KEYCODE_B)) ; - scrollx_offs1 += 0x1; scrollx_offs2 += 0x1; scrollx_offs3 += 0x1; scrollx_offs4 += 0x1; - logerror("Scrollx_offs now = %08x\n",scrollx_offs4); - tilemap_set_scrollx(pf1_tilemap,0,(pf1_scrollx >> 7) - (tiles_offsetx - scrollx_offs1)); - tilemap_set_scrollx(pf2_tilemap,0,(pf2_scrollx >> 7) - (tiles_offsetx - scrollx_offs2)); - tilemap_set_scrollx(pf3_tilemap,0,(pf3_scrollx >> 7) - (tiles_offsetx - scrollx_offs3)); - tilemap_set_scrollx(pf4_tilemap,0,(pf4_scrollx >> 7) - (tiles_offsetx - scrollx_offs4)); + state->scrollx_offs1 += 0x1; state->scrollx_offs2 += 0x1; state->scrollx_offs3 += 0x1; state->scrollx_offs4 += 0x1; + logerror("Scrollx_offs now = %08x\n", state->scrollx_offs4); + tilemap_set_scrollx(state->pf1_tilemap, 0, (state->pf1_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs1)); + tilemap_set_scrollx(state->pf2_tilemap, 0, (state->pf2_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs2)); + tilemap_set_scrollx(state->pf3_tilemap, 0, (state->pf3_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs3)); + tilemap_set_scrollx(state->pf4_tilemap, 0, (state->pf4_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs4)); } if ( input_code_pressed(machine, KEYCODE_V) ) { // while (input_code_pressed(machine, KEYCODE_V)) ; - scrollx_offs1 -= 0x1; scrollx_offs2 -= 0x1; scrollx_offs3 -= 0x1; scrollx_offs4 -= 0x1; - logerror("Scrollx_offs now = %08x\n",scrollx_offs4); - tilemap_set_scrollx(pf1_tilemap,0,(pf1_scrollx >> 7) - (tiles_offsetx - scrollx_offs1)); - tilemap_set_scrollx(pf2_tilemap,0,(pf2_scrollx >> 7) - (tiles_offsetx - scrollx_offs2)); - tilemap_set_scrollx(pf3_tilemap,0,(pf3_scrollx >> 7) - (tiles_offsetx - scrollx_offs3)); - tilemap_set_scrollx(pf4_tilemap,0,(pf4_scrollx >> 7) - (tiles_offsetx - scrollx_offs4)); + state->scrollx_offs1 -= 0x1; state->scrollx_offs2 -= 0x1; state->scrollx_offs3 -= 0x1; state->scrollx_offs4 -= 0x1; + logerror("Scrollx_offs now = %08x\n", state->scrollx_offs4); + tilemap_set_scrollx(state->pf1_tilemap, 0, (state->pf1_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs1)); + tilemap_set_scrollx(state->pf2_tilemap, 0, (state->pf2_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs2)); + tilemap_set_scrollx(state->pf3_tilemap, 0, (state->pf3_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs3)); + tilemap_set_scrollx(state->pf4_tilemap, 0, (state->pf4_scrollx >> 7) - (state->tiles_offsetx - state->scrollx_offs4)); } if ( input_code_pressed(machine, KEYCODE_C) ) { // while (input_code_pressed(machine, KEYCODE_C)) ; - scrolly_offs += 0x1; - logerror("Scrolly_offs now = %08x\n",scrolly_offs); - tilemap_set_scrolly(pf1_tilemap,0,(pf1_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf2_tilemap,0,(pf2_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf3_tilemap,0,(pf3_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf4_tilemap,0,(pf4_scrolly >> 7) - (tiles_offsety - scrolly_offs)); + state->scrolly_offs += 0x1; + logerror("Scrolly_offs now = %08x\n", state->scrolly_offs); + tilemap_set_scrolly(state->pf1_tilemap, 0, (state->pf1_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf2_tilemap, 0, (state->pf2_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf3_tilemap, 0, (state->pf3_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf4_tilemap, 0, (state->pf4_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); } if ( input_code_pressed(machine, KEYCODE_X) ) { // while (input_code_pressed(machine, KEYCODE_X)) ; - scrolly_offs -= 0x1; - logerror("Scrolly_offs now = %08x\n",scrolly_offs); - tilemap_set_scrolly(pf1_tilemap,0,(pf1_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf2_tilemap,0,(pf2_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf3_tilemap,0,(pf3_scrolly >> 7) - (tiles_offsety - scrolly_offs)); - tilemap_set_scrolly(pf4_tilemap,0,(pf4_scrolly >> 7) - (tiles_offsety - scrolly_offs)); + state->scrolly_offs -= 0x1; + logerror("Scrolly_offs now = %08x\n", state->scrolly_offs); + tilemap_set_scrolly(state->pf1_tilemap, 0, (state->pf1_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf2_tilemap, 0, (state->pf2_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf3_tilemap, 0, (state->pf3_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); + tilemap_set_scrolly(state->pf4_tilemap, 0, (state->pf4_scrolly >> 7) - (state->tiles_offsety - state->scrolly_offs)); } if ( input_code_pressed(machine, KEYCODE_L) ) /* Turn Playfield 4 on/off */ { while (input_code_pressed(machine, KEYCODE_L)) ; - display_pf4 += 1; - display_pf4 &= 1; - tilemap_set_enable(pf4_tilemap, display_pf4); + state->display_pf4 += 1; + state->display_pf4 &= 1; + tilemap_set_enable(state->pf4_tilemap, state->display_pf4); } if ( input_code_pressed(machine, KEYCODE_K) ) /* Turn Playfield 3 on/off */ { while (input_code_pressed(machine, KEYCODE_K)) ; - display_pf3 += 1; - display_pf3 &= 1; - tilemap_set_enable(pf3_tilemap, display_pf3); + state->display_pf3 += 1; + state->display_pf3 &= 1; + tilemap_set_enable(state->pf3_tilemap, state->display_pf3); } if ( input_code_pressed(machine, KEYCODE_J) ) /* Turn Playfield 2 on/off */ { while (input_code_pressed(machine, KEYCODE_J)) ; - display_pf2 += 1; - display_pf2 &= 1; - tilemap_set_enable(pf2_tilemap, display_pf2); + state->display_pf2 += 1; + state->display_pf2 &= 1; + tilemap_set_enable(state->pf2_tilemap, state->display_pf2); } if ( input_code_pressed(machine, KEYCODE_H) ) /* Turn Playfield 1 on/off */ { while (input_code_pressed(machine, KEYCODE_H)) ; - display_pf1 += 1; - display_pf1 &= 1; - tilemap_set_enable(pf1_tilemap, display_pf1); + state->display_pf1 += 1; + state->display_pf1 &= 1; + tilemap_set_enable(state->pf1_tilemap, state->display_pf1); } #endif } @@ -1045,12 +1058,13 @@ static void toaplan1_draw_sprite_custom(bitmap_t *dest_bmp,const rectangle *clip static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { - UINT16 *source = (UINT16 *)(machine->generic.buffered_spriteram.u16); - UINT16 *size = (UINT16 *)(toaplan1_buffered_spritesizeram16); - + toaplan1_state *state = machine->driver_data(); + UINT16 *source = (UINT16 *)state->buffered_spriteram; + UINT16 *size = (UINT16 *)state->buffered_spritesizeram16; + int fcu_flipscreen = state->fcu_flipscreen; int offs; - for (offs = machine->generic.spriteram_size/2 - 4; offs >= 0; offs -= 4) + for (offs = state->spriteram_size/2 - 4; offs >= 0; offs -= 4) { if (!(source[offs] & 0x8000)) { @@ -1112,10 +1126,11 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta static void rallybik_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority ) { - UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16; + toaplan1_state *state = machine->driver_data(); + UINT16 *buffered_spriteram16 = state->buffered_spriteram; int offs; - for (offs = 0; offs < (machine->generic.spriteram_size/2); offs += 4) + for (offs = 0; offs < state->spriteram_size/2; offs += 4) { int attrib, sx, sy, flipx, flipy; int sprite, color; @@ -1149,21 +1164,22 @@ static void rallybik_draw_sprites(running_machine *machine, bitmap_t *bitmap, co VIDEO_UPDATE( rallybik ) { + toaplan1_state *state = screen->machine->driver_data(); int priority; toaplan1_log_vram(screen->machine); bitmap_fill(bitmap,cliprect,0); - tilemap_draw(bitmap,cliprect,pf1_tilemap,TILEMAP_DRAW_OPAQUE | 0,0); - tilemap_draw(bitmap,cliprect,pf1_tilemap,TILEMAP_DRAW_OPAQUE | 1,0); + tilemap_draw(bitmap, cliprect, state->pf1_tilemap, TILEMAP_DRAW_OPAQUE | 0, 0); + tilemap_draw(bitmap, cliprect, state->pf1_tilemap, TILEMAP_DRAW_OPAQUE | 1, 0); for (priority = 1; priority < 16; priority++) { - tilemap_draw(bitmap,cliprect,pf4_tilemap,priority,0); - tilemap_draw(bitmap,cliprect,pf3_tilemap,priority,0); - tilemap_draw(bitmap,cliprect,pf2_tilemap,priority,0); - tilemap_draw(bitmap,cliprect,pf1_tilemap,priority,0); + tilemap_draw(bitmap, cliprect, state->pf4_tilemap, priority, 0); + tilemap_draw(bitmap, cliprect, state->pf3_tilemap, priority, 0); + tilemap_draw(bitmap, cliprect, state->pf2_tilemap, priority, 0); + tilemap_draw(bitmap, cliprect, state->pf1_tilemap, priority, 0); rallybik_draw_sprites(screen->machine, bitmap,cliprect,priority << 8); } return 0; @@ -1171,6 +1187,7 @@ VIDEO_UPDATE( rallybik ) VIDEO_UPDATE( toaplan1 ) { + toaplan1_state *state = screen->machine->driver_data(); int priority; toaplan1_log_vram(screen->machine); @@ -1178,16 +1195,16 @@ VIDEO_UPDATE( toaplan1 ) bitmap_fill(screen->machine->priority_bitmap,cliprect,0); bitmap_fill(bitmap,cliprect,0x120); - tilemap_draw(bitmap,cliprect,pf4_tilemap,TILEMAP_DRAW_OPAQUE,0); + tilemap_draw(bitmap, cliprect, state->pf4_tilemap, TILEMAP_DRAW_OPAQUE, 0); for (priority = 8; priority < 16; priority++) - tilemap_draw(bitmap,cliprect,pf1_tilemap,TILEMAP_DRAW_OPAQUE | priority,0); + tilemap_draw(bitmap, cliprect, state->pf1_tilemap, TILEMAP_DRAW_OPAQUE | priority, 0); for (priority = 1; priority < 16; priority++) { - tilemap_draw_primask(bitmap,cliprect,pf4_tilemap,priority,priority,0); - tilemap_draw_primask(bitmap,cliprect,pf3_tilemap,priority,priority,0); - tilemap_draw_primask(bitmap,cliprect,pf2_tilemap,priority,priority,0); - tilemap_draw_primask(bitmap,cliprect,pf1_tilemap,priority,priority,0); + tilemap_draw_primask(bitmap, cliprect, state->pf4_tilemap, priority, priority, 0); + tilemap_draw_primask(bitmap, cliprect, state->pf3_tilemap, priority, priority, 0); + tilemap_draw_primask(bitmap, cliprect, state->pf2_tilemap, priority, priority, 0); + tilemap_draw_primask(bitmap, cliprect, state->pf1_tilemap, priority, priority, 0); } draw_sprites(screen->machine, bitmap,cliprect); @@ -1196,6 +1213,7 @@ VIDEO_UPDATE( toaplan1 ) VIDEO_UPDATE( demonwld ) { + toaplan1_state *state = screen->machine->driver_data(); int priority; toaplan1_log_vram(screen->machine); @@ -1203,15 +1221,15 @@ VIDEO_UPDATE( demonwld ) bitmap_fill(screen->machine->priority_bitmap,cliprect,0); bitmap_fill(bitmap,cliprect,0x120); - tilemap_draw(bitmap,cliprect,pf1_tilemap,TILEMAP_DRAW_OPAQUE | 0,0); - tilemap_draw(bitmap,cliprect,pf1_tilemap,TILEMAP_DRAW_OPAQUE | 1,0); + tilemap_draw(bitmap, cliprect, state->pf1_tilemap, TILEMAP_DRAW_OPAQUE | 0, 0); + tilemap_draw(bitmap, cliprect, state->pf1_tilemap, TILEMAP_DRAW_OPAQUE | 1, 0); for (priority = 1; priority < 16; priority++) { - tilemap_draw_primask(bitmap,cliprect,pf4_tilemap,priority,priority,0); - tilemap_draw_primask(bitmap,cliprect,pf3_tilemap,priority,priority,0); - tilemap_draw_primask(bitmap,cliprect,pf2_tilemap,priority,priority,0); - tilemap_draw_primask(bitmap,cliprect,pf1_tilemap,priority,priority,0); + tilemap_draw_primask(bitmap, cliprect, state->pf4_tilemap, priority, priority, 0); + tilemap_draw_primask(bitmap, cliprect, state->pf3_tilemap, priority, priority, 0); + tilemap_draw_primask(bitmap, cliprect, state->pf2_tilemap, priority, priority, 0); + tilemap_draw_primask(bitmap, cliprect, state->pf1_tilemap, priority, priority, 0); } draw_sprites(screen->machine, bitmap,cliprect); @@ -1227,21 +1245,24 @@ VIDEO_UPDATE( demonwld ) VIDEO_EOF( rallybik ) { - address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - buffer_spriteram16_w(space, 0, 0, 0xffff); + toaplan1_state *state = machine->driver_data(); + + memcpy(state->buffered_spriteram, state->spriteram, state->spriteram_size); } VIDEO_EOF( toaplan1 ) { - address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - buffer_spriteram16_w(space, 0, 0, 0xffff); - memcpy(toaplan1_buffered_spritesizeram16, toaplan1_spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE); + toaplan1_state *state = machine->driver_data(); + + memcpy(state->buffered_spriteram, state->spriteram, state->spriteram_size); + memcpy(state->buffered_spritesizeram16, state->spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE); } VIDEO_EOF( samesame ) { - address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - buffer_spriteram16_w(space, 0, 0, 0xffff); - memcpy(toaplan1_buffered_spritesizeram16, toaplan1_spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE); + toaplan1_state *state = machine->driver_data(); + + memcpy(state->buffered_spriteram, state->spriteram, state->spriteram_size); + memcpy(state->buffered_spritesizeram16, state->spritesizeram16, TOAPLAN1_SPRITESIZERAM_SIZE); cputag_set_input_line(machine, "maincpu", M68K_IRQ_2, HOLD_LINE); /* Frame done */ } diff --git a/src/mame/video/toaplan2.c b/src/mame/video/toaplan2.c index be8dc361525..ed68e79c71d 100644 --- a/src/mame/video/toaplan2.c +++ b/src/mame/video/toaplan2.c @@ -30,23 +30,6 @@ -UINT16 *toaplan2_txvideoram16; /* Video ram for extra text layer */ -UINT16 *toaplan2_txvideoram16_offs; /* Text layer tile flip and positon ? */ -UINT16 *toaplan2_txscrollram16; /* Text layer scroll ? */ -UINT16 *toaplan2_tx_gfxram16; /* Text Layer RAM based tiles */ - -size_t toaplan2_tx_vram_size; /* 0x2000 Text layer RAM size */ -size_t toaplan2_tx_offs_vram_size; /* 0x200 Text layer tile flip and positon ? */ -size_t toaplan2_tx_scroll_vram_size; /* 0x200 Text layer scroll ? */ -size_t batrider_paletteram16_size; - - - -static int display_tx; -static UINT8 tx_flip = 0; - -static tilemap_t *tx_tilemap; /* Tilemap for extra-text-layer */ - /*************************************************************************** Callbacks for the TileMap code @@ -55,9 +38,10 @@ static tilemap_t *tx_tilemap; /* Tilemap for extra-text-layer */ static TILE_GET_INFO( get_text_tile_info ) { + toaplan2_state *state = machine->driver_data(); int color, tile_number, attrib; - attrib = toaplan2_txvideoram16[tile_index]; + attrib = state->txvideoram16[tile_index]; tile_number = attrib & 0x3ff; color = ((attrib >> 10) | 0x40) & 0x7f; SET_TILE_INFO( @@ -76,50 +60,66 @@ static TILE_GET_INFO( get_text_tile_info ) static void truxton2_create_tx_tilemap(running_machine *machine) { - tx_tilemap = tilemap_create(machine, get_text_tile_info,tilemap_scan_rows,8,8,64,32); - tilemap_set_scroll_rows(tx_tilemap,8*32); /* line scrolling */ - tilemap_set_scroll_cols(tx_tilemap,1); - tilemap_set_transparent_pen(tx_tilemap,0); + toaplan2_state *state = machine->driver_data(); + + state->tx_tilemap = tilemap_create(machine, get_text_tile_info, tilemap_scan_rows, 8, 8, 64, 32); + tilemap_set_scroll_rows(state->tx_tilemap, 8*32); /* line scrolling */ + tilemap_set_scroll_cols(state->tx_tilemap, 1); + tilemap_set_transparent_pen(state->tx_tilemap, 0); } static void register_state_save(running_machine *machine) { - state_save_register_global(machine, tx_flip); + toaplan2_state *state = machine->driver_data(); + + state_save_register_global(machine, state->tx_flip); } VIDEO_START( toaplan2 ) { + toaplan2_state *state = machine->driver_data(); int width = machine->primary_screen->width(); int height = machine->primary_screen->height(); /* cache the VDP device */ - toaplan2_state *state = machine->driver_data(); state->vdp0 = machine->device("gp9001vdp0"); state->vdp1 = machine->device("gp9001vdp1"); /* our current VDP implementation needs this bitmap to work with */ - gp9001_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); + state->custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); + state->displog = 0; // debug flag - if (state->vdp1) - gp9001_secondary_render_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); + if (state->vdp0 != NULL) + { + state->secondary_render_bitmap = NULL; + state->vdp0->custom_priority_bitmap = state->custom_priority_bitmap; + state->vdp0->displog = &state->displog; + } - gp9001_displog = 0; // debug flag + if (state->vdp1 != NULL) + { + state->secondary_render_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); + state->vdp1->custom_priority_bitmap = state->custom_priority_bitmap; + state->vdp1->displog = &state->displog; + } - display_tx = 1; + state->display_tx = 1; register_state_save(machine); } VIDEO_START( truxton2 ) { + toaplan2_state *state = machine->driver_data(); + VIDEO_START_CALL( toaplan2 ); /* Create the Text tilemap for this game */ truxton2_create_tx_tilemap(machine); if (machine->gfx[2]->srcdata == NULL) - gfx_element_set_source(machine->gfx[2], (UINT8 *)toaplan2_tx_gfxram16); - tilemap_set_scrolldx(tx_tilemap, 0x1d4 +1, 0x2a); + gfx_element_set_source(machine->gfx[2], (UINT8 *)state->tx_gfxram16); + tilemap_set_scrolldx(state->tx_tilemap, 0x1d4 +1, 0x2a); } VIDEO_START( fixeighb ) @@ -139,16 +139,18 @@ VIDEO_START( fixeighb ) state->vdp0->extra_yoffset[2]=-15; state->vdp0->extra_yoffset[3]=8; - tilemap_set_scrolldx(tx_tilemap, 0, 0); + tilemap_set_scrolldx(state->tx_tilemap, 0, 0); } VIDEO_START( bgaregga ) { + toaplan2_state *state = machine->driver_data(); + VIDEO_START_CALL( toaplan2 ); /* Create the Text tilemap for this game */ truxton2_create_tx_tilemap(machine); - tilemap_set_scrolldx(tx_tilemap, 0x1d4, 0x2a); + tilemap_set_scrolldx(state->tx_tilemap, 0x1d4, 0x2a); } VIDEO_START( batrider ) @@ -159,11 +161,11 @@ VIDEO_START( batrider ) state->vdp0->spriteram16_n = state->vdp0->spriteram16_new; /* Create the Text tilemap for this game */ - toaplan2_tx_gfxram16 = auto_alloc_array_clear(machine, UINT16, RAIZING_TX_GFXRAM_SIZE/2); - state_save_register_global_pointer(machine, toaplan2_tx_gfxram16, RAIZING_TX_GFXRAM_SIZE/2); - gfx_element_set_source(machine->gfx[2], (UINT8 *)toaplan2_tx_gfxram16); + state->tx_gfxram16 = auto_alloc_array_clear(machine, UINT16, RAIZING_TX_GFXRAM_SIZE/2); + state_save_register_global_pointer(machine, state->tx_gfxram16, RAIZING_TX_GFXRAM_SIZE/2); + gfx_element_set_source(machine->gfx[2], (UINT8 *)state->tx_gfxram16); truxton2_create_tx_tilemap(machine); - tilemap_set_scrolldx(tx_tilemap, 0x1d4, 0x2a); + tilemap_set_scrolldx(state->tx_tilemap, 0x1d4, 0x2a); /* Has special banking */ state->vdp0->gp9001_gfxrom_is_banked = 1; @@ -171,20 +173,27 @@ VIDEO_START( batrider ) READ16_HANDLER( toaplan2_txvideoram16_r ) { - return toaplan2_txvideoram16[offset]; + toaplan2_state *state = space->machine->driver_data(); + + return state->txvideoram16[offset]; } WRITE16_HANDLER( toaplan2_txvideoram16_w ) { - COMBINE_DATA(&toaplan2_txvideoram16[offset]); - if (offset < (toaplan2_tx_vram_size/4)) - tilemap_mark_tile_dirty(tx_tilemap,offset); + toaplan2_state *state = space->machine->driver_data(); + + COMBINE_DATA(&state->txvideoram16[offset]); + if (offset < (state->tx_vram_size/4)) + tilemap_mark_tile_dirty(state->tx_tilemap, offset); } READ16_HANDLER( toaplan2_txvideoram16_offs_r ) { - return toaplan2_txvideoram16_offs[offset]; + toaplan2_state *state = space->machine->driver_data(); + + return state->txvideoram16_offs[offset]; } + WRITE16_HANDLER( toaplan2_txvideoram16_offs_w ) { /* Besides containing flip, function of this RAM is still unknown */ @@ -192,7 +201,8 @@ WRITE16_HANDLER( toaplan2_txvideoram16_offs_w ) /* Maybe specifies which line to draw text info (line number data is */ /* opposite when flip bits are on) */ - UINT16 oldword = toaplan2_txvideoram16_offs[offset]; + toaplan2_state *state = space->machine->driver_data(); + UINT16 oldword = state->txvideoram16_offs[offset]; if (oldword != data) { @@ -200,73 +210,84 @@ WRITE16_HANDLER( toaplan2_txvideoram16_offs_w ) { if (data & 0x8000) /* Flip off */ { - tx_flip = 0; - tilemap_set_flip(tx_tilemap, tx_flip); - tilemap_set_scrolly(tx_tilemap, 0, 0); + state->tx_flip = 0; + tilemap_set_flip(state->tx_tilemap, state->tx_flip); + tilemap_set_scrolly(state->tx_tilemap, 0, 0); } else /* Flip on */ { - tx_flip = (TILEMAP_FLIPY | TILEMAP_FLIPX); - tilemap_set_flip(tx_tilemap, tx_flip); - tilemap_set_scrolly(tx_tilemap, 0, -16); + state->tx_flip = (TILEMAP_FLIPY | TILEMAP_FLIPX); + tilemap_set_flip(state->tx_tilemap, state->tx_flip); + tilemap_set_scrolly(state->tx_tilemap, 0, -16); } } - COMBINE_DATA(&toaplan2_txvideoram16_offs[offset]); + COMBINE_DATA(&state->txvideoram16_offs[offset]); } // logerror("Writing %04x to text offs RAM offset %04x\n",data,offset); } READ16_HANDLER( toaplan2_txscrollram16_r ) { - return toaplan2_txscrollram16[offset]; + toaplan2_state *state = space->machine->driver_data(); + + return state->txscrollram16[offset]; } + WRITE16_HANDLER( toaplan2_txscrollram16_w ) { /*** Line-Scroll RAM for Text Layer ***/ + toaplan2_state *state = space->machine->driver_data(); int data_tx = data; - tilemap_set_scrollx(tx_tilemap, offset, data_tx); + tilemap_set_scrollx(state->tx_tilemap, offset, data_tx); // logerror("Writing %04x to text scroll RAM offset %04x\n",data,offset); - COMBINE_DATA(&toaplan2_txscrollram16[offset]); + COMBINE_DATA(&state->txscrollram16[offset]); } READ16_HANDLER( toaplan2_tx_gfxram16_r ) { - return toaplan2_tx_gfxram16[offset]; + toaplan2_state *state = space->machine->driver_data(); + + return state->tx_gfxram16[offset]; } WRITE16_HANDLER( toaplan2_tx_gfxram16_w ) { /*** Dynamic GFX decoding for Truxton 2 / FixEight ***/ - UINT16 oldword = toaplan2_tx_gfxram16[offset]; + toaplan2_state *state = space->machine->driver_data(); + UINT16 oldword = state->tx_gfxram16[offset]; if (oldword != data) { int code = offset/32; - COMBINE_DATA(&toaplan2_tx_gfxram16[offset]); + COMBINE_DATA(&state->tx_gfxram16[offset]); gfx_element_mark_dirty(space->machine->gfx[2], code); } } READ16_HANDLER( raizing_tx_gfxram16_r ) { + toaplan2_state *state = space->machine->driver_data(); + offset += 0x3400/2; - return toaplan2_tx_gfxram16[offset]; + return state->tx_gfxram16[offset]; } + WRITE16_HANDLER( raizing_tx_gfxram16_w ) { /*** Dynamic Text GFX decoding for Batrider ***/ + toaplan2_state *state = space->machine->driver_data(); UINT16 oldword; offset += 0x3400/2; - oldword = toaplan2_tx_gfxram16[offset]; + oldword = state->tx_gfxram16[offset]; if (oldword != data) { - COMBINE_DATA(&toaplan2_tx_gfxram16[offset]); + COMBINE_DATA(&state->tx_gfxram16[offset]); } } @@ -275,16 +296,17 @@ WRITE16_HANDLER( batrider_textdata_decode ) /*** Dynamic Text GFX decoding for Batrider ***/ /*** Only done once during start-up ***/ + toaplan2_state *state = space->machine->driver_data(); int code; - UINT16 *dest = (UINT16 *)toaplan2_tx_gfxram16; + UINT16 *dest = (UINT16 *)state->tx_gfxram16; - memcpy(dest, toaplan2_txvideoram16, toaplan2_tx_vram_size); - dest += (toaplan2_tx_vram_size/2); - memcpy(dest, space->machine->generic.paletteram.u16, batrider_paletteram16_size); - dest += (batrider_paletteram16_size/2); - memcpy(dest, toaplan2_txvideoram16_offs, toaplan2_tx_offs_vram_size); - dest += (toaplan2_tx_offs_vram_size/2); - memcpy(dest, toaplan2_txscrollram16, toaplan2_tx_scroll_vram_size); + memcpy(dest, state->txvideoram16, state->tx_vram_size); + dest += (state->tx_vram_size/2); + memcpy(dest, space->machine->generic.paletteram.u16, state->paletteram16_size); + dest += (state->paletteram16_size/2); + memcpy(dest, state->txvideoram16_offs, state->tx_offs_vram_size); + dest += (state->tx_offs_vram_size/2); + memcpy(dest, state->txscrollram16, state->tx_scroll_vram_size); /* Decode text characters; force them to update immediately */ for (code = 0; code < 1024; code++) @@ -316,7 +338,7 @@ VIDEO_UPDATE( toaplan2_dual ) gp9001_log_vram(state->vdp1, screen->machine); bitmap_fill(bitmap,cliprect,0); - bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + bitmap_fill(state->custom_priority_bitmap, cliprect, 0); state->vdp1->gp9001_render_vdp(screen->machine, bitmap, cliprect); } if (state->vdp0) @@ -324,7 +346,7 @@ VIDEO_UPDATE( toaplan2_dual ) gp9001_log_vram(state->vdp0, screen->machine); // bitmap_fill(bitmap,cliprect,0); - bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + bitmap_fill(state->custom_priority_bitmap, cliprect, 0); state->vdp0->gp9001_render_vdp(screen->machine, bitmap, cliprect); } @@ -346,16 +368,16 @@ VIDEO_UPDATE( toaplan2_mixed ) gp9001_log_vram(state->vdp0, screen->machine); bitmap_fill(bitmap,cliprect,0); - bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + bitmap_fill(state->custom_priority_bitmap, cliprect, 0); state->vdp0->gp9001_render_vdp(screen->machine, bitmap, cliprect); } if (state->vdp1) { gp9001_log_vram(state->vdp1, screen->machine); - bitmap_fill(gp9001_secondary_render_bitmap,cliprect,0); - bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); - state->vdp1->gp9001_render_vdp(screen->machine, gp9001_secondary_render_bitmap, cliprect); + bitmap_fill(state->secondary_render_bitmap,cliprect,0); + bitmap_fill(state->custom_priority_bitmap, cliprect, 0); + state->vdp1->gp9001_render_vdp(screen->machine, state->secondary_render_bitmap, cliprect); } @@ -381,7 +403,7 @@ VIDEO_UPDATE( toaplan2_mixed ) for (y=0;ysecondary_render_bitmap, y, 0); for (x=0;xmachine->driver_data(); - if (state->vdp0) { running_device *screen1 = screen->machine->device("screen"); @@ -452,7 +473,7 @@ VIDEO_UPDATE( toaplan2 ) if (screen == screen1) { bitmap_fill(bitmap,cliprect,0); - bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + bitmap_fill(state->custom_priority_bitmap, cliprect, 0); state->vdp0->gp9001_render_vdp(screen->machine, bitmap, cliprect); } } @@ -468,7 +489,7 @@ VIDEO_UPDATE( toaplan2 ) if (screen == screen2) { bitmap_fill(bitmap,cliprect,0); - bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + bitmap_fill(state->custom_priority_bitmap, cliprect, 0); state->vdp1->gp9001_render_vdp(screen->machine, bitmap, cliprect); } } @@ -479,14 +500,18 @@ VIDEO_UPDATE( toaplan2 ) VIDEO_UPDATE( truxton2 ) { + toaplan2_state *state = screen->machine->driver_data(); + VIDEO_UPDATE_CALL(toaplan2); - tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); + tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0); return 0; } VIDEO_UPDATE( batrider ) { + toaplan2_state *state = screen->machine->driver_data(); + VIDEO_UPDATE_CALL( toaplan2 ); int line; @@ -502,8 +527,8 @@ VIDEO_UPDATE( batrider ) for (line = 0; line < 256;line++) { clip.min_y = clip.max_y = line; - tilemap_set_scrolly(tx_tilemap,0,toaplan2_txvideoram16_offs[line&0xff]-line); - tilemap_draw(bitmap,&clip,tx_tilemap,0,0); + tilemap_set_scrolly(state->tx_tilemap, 0, state->txvideoram16_offs[line&0xff] - line); + tilemap_draw(bitmap, &clip, state->tx_tilemap, 0, 0); } return 0; }