diff --git a/.gitattributes b/.gitattributes index 445ce5e6c35..1f0ed397c2c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2453,12 +2453,14 @@ src/mame/includes/exterm.h svneol=native#text/plain src/mame/includes/f1gp.h svneol=native#text/plain src/mame/includes/fantland.h svneol=native#text/plain src/mame/includes/fastfred.h svneol=native#text/plain +src/mame/includes/fastlane.h svneol=native#text/plain src/mame/includes/fcombat.h svneol=native#text/plain src/mame/includes/fgoal.h svneol=native#text/plain src/mame/includes/finalizr.h svneol=native#text/plain src/mame/includes/firetrap.h svneol=native#text/plain src/mame/includes/firetrk.h svneol=native#text/plain src/mame/includes/fitfight.h svneol=native#text/plain +src/mame/includes/flkatck.h svneol=native#text/plain src/mame/includes/flower.h svneol=native#text/plain src/mame/includes/flstory.h svneol=native#text/plain src/mame/includes/foodf.h svneol=native#text/plain @@ -2503,6 +2505,7 @@ src/mame/includes/gunsmoke.h svneol=native#text/plain src/mame/includes/gyruss.h svneol=native#text/plain src/mame/includes/hanaawas.h svneol=native#text/plain src/mame/includes/harddriv.h svneol=native#text/plain +src/mame/includes/hcastle.h svneol=native#text/plain src/mame/includes/hexa.h svneol=native#text/plain src/mame/includes/higemaru.h svneol=native#text/plain src/mame/includes/himesiki.h svneol=native#text/plain @@ -2541,6 +2544,7 @@ src/mame/includes/konamipt.h svneol=native#text/plain src/mame/includes/kopunch.h svneol=native#text/plain src/mame/includes/ksayakyu.h svneol=native#text/plain src/mame/includes/kyugo.h svneol=native#text/plain +src/mame/includes/labyrunr.h svneol=native#text/plain src/mame/includes/ladybug.h svneol=native#text/plain src/mame/includes/ladyfrog.h svneol=native#text/plain src/mame/includes/laserbat.h svneol=native#text/plain @@ -2677,6 +2681,7 @@ src/mame/includes/subs.h svneol=native#text/plain src/mame/includes/suna8.h svneol=native#text/plain src/mame/includes/suprnova.h svneol=native#text/plain src/mame/includes/suprridr.h svneol=native#text/plain +src/mame/includes/suprslam.h svneol=native#text/plain src/mame/includes/system16.h svneol=native#text/plain src/mame/includes/taito_b.h svneol=native#text/plain src/mame/includes/taito_f2.h svneol=native#text/plain diff --git a/src/mame/drivers/f1gp.c b/src/mame/drivers/f1gp.c index 821bd2e61a9..db035c359f3 100644 --- a/src/mame/drivers/f1gp.c +++ b/src/mame/drivers/f1gp.c @@ -1,21 +1,21 @@ /*************************************************************************** -F-1 Grand Prix (c) 1991 Video System Co. + F-1 Grand Prix (c) 1991 Video System Co. -driver by Nicola Salmoria + driver by Nicola Salmoria -Notes: -- The ROZ layer generator is a Konami 053936. -- f1gp2's hardware is very similar to Lethal Crash Race, main difference - being an extra 68000. + Notes: + - The ROZ layer generator is a Konami 053936. + - f1gp2's hardware is very similar to Lethal Crash Race, main difference + being an extra 68000. -TODO: -f1gp: -- gfxctrl register not understood - handling of fg/sprite priority to fix - "continue" screen is just a kludge. -f1gp2: -- sprite lag noticeable in the animation at the end of a race (the wheels - of the car are sprites while the car is the fg tilemap) + TODO: + f1gp: + - gfxctrl register not understood - handling of fg/sprite priority to fix + "continue" screen is just a kludge. + f1gp2: + - sprite lag noticeable in the animation at the end of a race (the wheels + of the car are sprites while the car is the fg tilemap) ***************************************************************************/ @@ -28,16 +28,16 @@ f1gp2: #include "includes/f1gp.h" -static UINT16 *sharedram; - static READ16_HANDLER( sharedram_r ) { - return sharedram[offset]; + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + return state->sharedram[offset]; } static WRITE16_HANDLER( sharedram_w ) { - COMBINE_DATA(&sharedram[offset]); + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + COMBINE_DATA(&state->sharedram[offset]); } static READ16_HANDLER( extrarom_r ) @@ -46,7 +46,7 @@ static READ16_HANDLER( extrarom_r ) offset *= 2; - return rom[offset] | (rom[offset+1] << 8); + return rom[offset] | (rom[offset + 1] << 8); } static READ16_HANDLER( extrarom2_r ) @@ -55,57 +55,56 @@ static READ16_HANDLER( extrarom2_r ) offset *= 2; - return rom[offset] | (rom[offset+1] << 8); + return rom[offset] | (rom[offset + 1] << 8); } static WRITE8_HANDLER( f1gp_sh_bankswitch_w ) { - UINT8 *rom = memory_region(space->machine, "audiocpu") + 0x10000; - - memory_set_bankptr(space->machine, "bank1",rom + (data & 0x01) * 0x8000); + memory_set_bank(space->machine, "bank1", data & 0x01); } -static int pending_command; - static WRITE16_HANDLER( sound_command_w ) { + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) { - pending_command = 1; + state->pending_command = 1; soundlatch_w(space, offset, data & 0xff); - cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); + cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE); } } static READ16_HANDLER( command_pending_r ) { - return (pending_command ? 0xff : 0); + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + return (state->pending_command ? 0xff : 0); } static WRITE8_HANDLER( pending_command_clear_w ) { - pending_command = 0; + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + state->pending_command = 0; } - static ADDRESS_MAP_START( f1gp_cpu1_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x100000, 0x2fffff) AM_READ(extrarom_r) AM_RANGE(0xa00000, 0xbfffff) AM_READ(extrarom2_r) AM_RANGE(0xc00000, 0xc3ffff) AM_READWRITE(f1gp_zoomdata_r, f1gp_zoomdata_w) - AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) - AM_RANGE(0xd02000, 0xd03fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) /* mirror */ - AM_RANGE(0xd04000, 0xd05fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) /* mirror */ - AM_RANGE(0xd06000, 0xd07fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) /* mirror */ - AM_RANGE(0xe00000, 0xe03fff) AM_RAM AM_BASE(&f1gp_spr1cgram) AM_SIZE(&f1gp_spr1cgram_size) // SPR-1 CG RAM - AM_RANGE(0xe04000, 0xe07fff) AM_RAM AM_BASE(&f1gp_spr2cgram) AM_SIZE(&f1gp_spr2cgram_size) // SPR-2 CG RAM - AM_RANGE(0xf00000, 0xf003ff) AM_RAM AM_BASE(&f1gp_spr1vram) // SPR-1 VRAM - AM_RANGE(0xf10000, 0xf103ff) AM_RAM AM_BASE(&f1gp_spr2vram) // SPR-2 VRAM - AM_RANGE(0xff8000, 0xffbfff) AM_RAM // WORK RAM-1 - AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE(&sharedram) // DUAL RAM - AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE(&f1gp_fgvideoram) // CHARACTER + AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE_MEMBER(f1gp_state, rozvideoram) + AM_RANGE(0xd02000, 0xd03fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) /* mirror */ + AM_RANGE(0xd04000, 0xd05fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) /* mirror */ + AM_RANGE(0xd06000, 0xd07fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) /* mirror */ + AM_RANGE(0xe00000, 0xe03fff) AM_RAM AM_BASE_SIZE_MEMBER(f1gp_state, spr1cgram, spr1cgram_size) // SPR-1 CG RAM + AM_RANGE(0xe04000, 0xe07fff) AM_RAM AM_BASE_SIZE_MEMBER(f1gp_state, spr2cgram, spr2cgram_size) // SPR-2 CG RAM + AM_RANGE(0xf00000, 0xf003ff) AM_RAM AM_BASE_MEMBER(f1gp_state, spr1vram) // SPR-1 VRAM + AM_RANGE(0xf10000, 0xf103ff) AM_RAM AM_BASE_MEMBER(f1gp_state, spr2vram) // SPR-2 VRAM + AM_RANGE(0xff8000, 0xffbfff) AM_RAM // WORK RAM-1 + AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE_MEMBER(f1gp_state, sharedram) // DUAL RAM + AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE_MEMBER(f1gp_state, fgvideoram) // CHARACTER AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) // PALETTE AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("INPUTS") AM_RANGE(0xfff000, 0xfff001) AM_WRITE(f1gp_gfxctrl_w) @@ -122,12 +121,12 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( f1gp2_cpu1_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x100000, 0x2fffff) AM_READ(extrarom_r) - AM_RANGE(0xa00000, 0xa07fff) AM_RAM AM_BASE(&f1gp2_sprcgram) // SPR-1 CG RAM + SPR-2 CG RAM - AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) // BACK VRAM - AM_RANGE(0xe00000, 0xe00fff) AM_RAM AM_BASE(&f1gp2_spritelist) // not checked + SPR-1 VRAM + SPR-2 VRAM - AM_RANGE(0xff8000, 0xffbfff) AM_RAM // WORK RAM-1 - AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE(&sharedram) // DUAL RAM - AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE(&f1gp_fgvideoram) // CHARACTER + AM_RANGE(0xa00000, 0xa07fff) AM_RAM AM_BASE_MEMBER(f1gp_state, sprcgram) // SPR-1 CG RAM + SPR-2 CG RAM + AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE_MEMBER(f1gp_state, rozvideoram) // BACK VRAM + AM_RANGE(0xe00000, 0xe00fff) AM_RAM AM_BASE_MEMBER(f1gp_state, spritelist) // not checked + SPR-1 VRAM + SPR-2 VRAM + AM_RANGE(0xff8000, 0xffbfff) AM_RAM // WORK RAM-1 + AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE_MEMBER(f1gp_state, sharedram) // DUAL RAM + AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE_MEMBER(f1gp_state, fgvideoram) // CHARACTER AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) // PALETTE AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("INPUTS") AM_WRITE(f1gp2_gfxctrl_w) // AM_RANGE(0xfff002, 0xfff003) analog wheel? @@ -188,9 +187,9 @@ static ADDRESS_MAP_START( f1gpb_cpu1_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x100000, 0x2fffff) AM_READ(extrarom_r) AM_RANGE(0xa00000, 0xbfffff) AM_READ(extrarom2_r) - AM_RANGE(0x800000, 0x801fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x800000, 0x801fff) AM_RAM AM_BASE_SIZE_MEMBER(f1gp_state, spriteram, spriteram_size) AM_RANGE(0xc00000, 0xc3ffff) AM_READWRITE(f1gp_zoomdata_r, f1gp_zoomdata_w) - AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) + AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE_MEMBER(f1gp_state, rozvideoram) AM_RANGE(0xd02000, 0xd03fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) /* mirror */ AM_RANGE(0xd04000, 0xd05fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) /* mirror */ AM_RANGE(0xd06000, 0xd07fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) /* mirror */ @@ -199,21 +198,21 @@ static ADDRESS_MAP_START( f1gpb_cpu1_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xf00000, 0xf003ff) AM_RAM //unused AM_RANGE(0xf10000, 0xf103ff) AM_RAM //unused AM_RANGE(0xff8000, 0xffbfff) AM_RAM - AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE(&sharedram) - AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE(&f1gp_fgvideoram) + AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE_MEMBER(f1gp_state, sharedram) + AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE_MEMBER(f1gp_state, fgvideoram) AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("INPUTS") AM_RANGE(0xfff004, 0xfff005) AM_READ_PORT("DSW1") AM_RANGE(0xfff006, 0xfff007) AM_READ_PORT("DSW2") AM_RANGE(0xfff008, 0xfff009) AM_READNOP //? AM_RANGE(0xfff006, 0xfff007) AM_WRITENOP - AM_RANGE(0xfff00a, 0xfff00b) AM_RAM AM_BASE(&f1gpb_fgregs) + AM_RANGE(0xfff00a, 0xfff00b) AM_RAM AM_BASE_MEMBER(f1gp_state, fgregs) AM_RANGE(0xfff00e, 0xfff00f) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0xfff00c, 0xfff00d) AM_WRITE(f1gpb_misc_w) AM_RANGE(0xfff010, 0xfff011) AM_WRITENOP AM_RANGE(0xfff020, 0xfff023) AM_RAM //? AM_RANGE(0xfff050, 0xfff051) AM_READ_PORT("DSW3") - AM_RANGE(0xfff800, 0xfff809) AM_RAM AM_BASE(&f1gpb_rozregs) + AM_RANGE(0xfff800, 0xfff809) AM_RAM AM_BASE_MEMBER(f1gp_state, rozregs) ADDRESS_MAP_END static ADDRESS_MAP_START( f1gpb_cpu2_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -410,9 +409,10 @@ GFXDECODE_END -static void irqhandler(const device_config *device, int irq) +static void irqhandler( const device_config *device, int irq ) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + f1gp_state *state = (f1gp_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -433,8 +433,47 @@ static const k053936_interface f1gp2_k053936_intf = }; +static MACHINE_START( f1gpb ) +{ + f1gp_state *state = (f1gp_state *)machine->driver_data; + + state_save_register_global(machine, state->pending_command); + state_save_register_global(machine, state->roz_bank); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->gfxctrl); + state_save_register_global_array(machine, state->scroll); +} + +static MACHINE_START( f1gp ) +{ + f1gp_state *state = (f1gp_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "audiocpu"); + + memory_configure_bank(machine, "bank1", 0, 2, &ROM[0x10000], 0x8000); + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k053936 = devtag_get_device(machine, "k053936"); + + MACHINE_START_CALL(f1gpb); +} + +static MACHINE_RESET( f1gp ) +{ + f1gp_state *state = (f1gp_state *)machine->driver_data; + + state->pending_command = 0; + state->roz_bank = 0; + state->flipscreen = 0; + state->gfxctrl = 0; + state->scroll[0] = 0; + state->scroll[1] = 0; +} + static MACHINE_DRIVER_START( f1gp ) + /* driver data */ + MDRV_DRIVER_DATA(f1gp_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu",M68000,XTAL_20MHz/2) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(f1gp_cpu1_map) @@ -450,6 +489,9 @@ static MACHINE_DRIVER_START( f1gp ) MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slices per frame */ + MDRV_MACHINE_START(f1gp) + MDRV_MACHINE_RESET(f1gp) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -479,6 +521,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( f1gpb ) + /* driver data */ + MDRV_DRIVER_DATA(f1gp_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu",M68000,10000000) /* 10 MHz ??? */ MDRV_CPU_PROGRAM_MAP(f1gpb_cpu1_map) @@ -491,6 +536,9 @@ static MACHINE_DRIVER_START( f1gpb ) /* NO sound CPU */ MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slices per frame */ + MDRV_MACHINE_START(f1gpb) + MDRV_MACHINE_RESET(f1gp) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -680,8 +728,7 @@ ROM_START( f1gp2 ) ROM_END -GAME( 1991, f1gp, 0, f1gp, f1gp, 0, ROT90, "Video System Co.", "F-1 Grand Prix", GAME_NO_COCKTAIL ) -GAME( 1991, f1gpb, f1gp, f1gpb, f1gp, 0, ROT90, "[Video System Co.] (Playmark bootleg)", "F-1 Grand Prix (Playmark bootleg)", GAME_NOT_WORKING ) // PCB marked 'Super Formula II', manufactured by Playmark. - -GAME( 1992, f1gp2, 0, f1gp2, f1gp2, 0, ROT90, "Video System Co.", "F-1 Grand Prix Part II", GAME_NO_COCKTAIL ) +GAME( 1991, f1gp, 0, f1gp, f1gp, 0, ROT90, "Video System Co.", "F-1 Grand Prix", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) +GAME( 1991, f1gpb, f1gp, f1gpb, f1gp, 0, ROT90, "[Video System Co.] (Playmark bootleg)", "F-1 Grand Prix (Playmark bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // PCB marked 'Super Formula II', manufactured by Playmark. +GAME( 1992, f1gp2, 0, f1gp2, f1gp2, 0, ROT90, "Video System Co.", "F-1 Grand Prix Part II", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/fastlane.c b/src/mame/drivers/fastlane.c index 7ae98d678bf..946950ca863 100644 --- a/src/mame/drivers/fastlane.c +++ b/src/mame/drivers/fastlane.c @@ -1,12 +1,12 @@ /*************************************************************************** -Fast Lane(GX752) (c) 1987 Konami + Fast Lane (GX752) (c) 1987 Konami -Driver by Manuel Abadia + Driver by Manuel Abadia -TODO: -- colors don't seem 100% accurate. -- verify that sound is correct (volume and bank switching) + TODO: + - colors don't seem 100% accurate. + - verify that sound is correct (volume and bank switching) ***************************************************************************/ @@ -14,57 +14,49 @@ TODO: #include "deprecat.h" #include "cpu/hd6309/hd6309.h" #include "sound/k007232.h" -#include "includes/konamipt.h" #include "video/konicdev.h" - -/* from video/fastlane.c */ -extern UINT8 *fastlane_k007121_regs,*fastlane_videoram1,*fastlane_videoram2; -WRITE8_HANDLER( fastlane_vram1_w ); -WRITE8_HANDLER( fastlane_vram2_w ); -PALETTE_INIT( fastlane ); -VIDEO_START( fastlane ); -VIDEO_UPDATE( fastlane ); +#include "includes/konamipt.h" +#include "includes/fastlane.h" static INTERRUPT_GEN( fastlane_interrupt ) { - const device_config *k007121 = devtag_get_device(device->machine, "k007121"); + fastlane_state *state = (fastlane_state *)device->machine->driver_data; + if (cpu_getiloops(device) == 0) { - if (k007121_ctrlram_r(k007121, 7) & 0x02) + if (k007121_ctrlram_r(state->k007121, 7) & 0x02) cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE); } else if (cpu_getiloops(device) % 2) { - if (k007121_ctrlram_r(k007121, 7) & 0x01) + if (k007121_ctrlram_r(state->k007121, 7) & 0x01) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); } } static WRITE8_HANDLER( k007121_registers_w ) { - const device_config *k007121 = devtag_get_device(space->machine, "k007121"); + fastlane_state *state = (fastlane_state *)space->machine->driver_data; if (offset < 8) - k007121_ctrl_w(k007121, offset, data); + k007121_ctrl_w(state->k007121, offset, data); else /* scroll registers */ - fastlane_k007121_regs[offset] = data; + state->k007121_regs[offset] = data; } static WRITE8_HANDLER( fastlane_bankswitch_w ) { - int bankaddress; - UINT8 *RAM = memory_region(space->machine, "maincpu"); + fastlane_state *state = (fastlane_state *)space->machine->driver_data; /* bits 0 & 1 coin counters */ coin_counter_w(space->machine, 0,data & 0x01); coin_counter_w(space->machine, 1,data & 0x02); /* bits 2 & 3 = bank number */ - bankaddress = 0x10000 + ((data & 0x0c) >> 2) * 0x4000; - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + memory_set_bank(space->machine, "bank1", (data & 0x0c) >> 2); /* bit 4: bank # for the 007232 (chip 2) */ - k007232_set_bank(devtag_get_device(space->machine, "konami2"),0 + ((data & 0x10) >> 4),2 + ((data & 0x10) >> 4)); + k007232_set_bank(state->konami2, 0 + ((data & 0x10) >> 4), 2 + ((data & 0x10) >> 4)); /* other bits seems to be unused */ } @@ -76,15 +68,15 @@ static READ8_DEVICE_HANDLER( fastlane_k007232_r ) { return k007232_r(device, offset ^ 1); } + static WRITE8_DEVICE_HANDLER( fastlane_k007232_w ) { k007232_w(device, offset ^ 1, data); } - static ADDRESS_MAP_START( fastlane_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x005f) AM_RAM_WRITE(k007121_registers_w) AM_BASE(&fastlane_k007121_regs) /* 007121 registers */ + AM_RANGE(0x0000, 0x005f) AM_RAM_WRITE(k007121_registers_w) AM_BASE_MEMBER(fastlane_state, k007121_regs) /* 007121 registers */ AM_RANGE(0x0800, 0x0800) AM_READ_PORT("DSW3") AM_RANGE(0x0801, 0x0801) AM_READ_PORT("P2") AM_RANGE(0x0802, 0x0802) AM_READ_PORT("P1") @@ -96,11 +88,11 @@ static ADDRESS_MAP_START( fastlane_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0d00, 0x0d0d) AM_DEVREADWRITE("konami1", fastlane_k007232_r, fastlane_k007232_w) /* 007232 registers (chip 1) */ AM_RANGE(0x0e00, 0x0e0d) AM_DEVREADWRITE("konami2", fastlane_k007232_r, fastlane_k007232_w) /* 007232 registers (chip 2) */ AM_RANGE(0x0f00, 0x0f1f) AM_DEVREADWRITE("k051733", k051733_r, k051733_w) /* 051733 (protection) */ - AM_RANGE(0x1000, 0x17ff) AM_RAM AM_BASE_GENERIC(paletteram) /* Palette RAM */ + AM_RANGE(0x1000, 0x17ff) AM_RAM AM_BASE_MEMBER(fastlane_state, paletteram) /* Palette RAM */ AM_RANGE(0x1800, 0x1fff) AM_RAM /* Work RAM */ - AM_RANGE(0x2000, 0x27ff) AM_RAM_WRITE(fastlane_vram1_w) AM_BASE(&fastlane_videoram1) /* Video RAM (chip 1) */ - AM_RANGE(0x2800, 0x2fff) AM_RAM_WRITE(fastlane_vram2_w) AM_BASE(&fastlane_videoram2) /* Video RAM (chip 2) */ - AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprite RAM */ + AM_RANGE(0x2000, 0x27ff) AM_RAM_WRITE(fastlane_vram1_w) AM_BASE_MEMBER(fastlane_state, videoram1) /* Video RAM (chip 1) */ + AM_RANGE(0x2800, 0x2fff) AM_RAM_WRITE(fastlane_vram2_w) AM_BASE_MEMBER(fastlane_state, videoram2) /* Video RAM (chip 2) */ + AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE_MEMBER(fastlane_state, spriteram) /* Sprite RAM */ AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1") /* banked ROM */ AM_RANGE(0x8000, 0xffff) AM_ROM /* ROM */ ADDRESS_MAP_END @@ -186,14 +178,14 @@ GFXDECODE_END static void volume_callback0(const device_config *device, int v) { - k007232_set_volume(device,0,(v >> 4) * 0x11,0); - k007232_set_volume(device,1,0,(v & 0x0f) * 0x11); + k007232_set_volume(device, 0, (v >> 4) * 0x11, 0); + k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11); } static void volume_callback1(const device_config *device, int v) { - k007232_set_volume(device,0,(v >> 4) * 0x11,0); - k007232_set_volume(device,1,0,(v & 0x0f) * 0x11); + k007232_set_volume(device, 0, (v >> 4) * 0x11, 0); + k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11); } static const k007232_interface k007232_interface_1 = @@ -206,13 +198,29 @@ static const k007232_interface k007232_interface_2 = volume_callback1 }; +static MACHINE_START( fastlane ) +{ + fastlane_state *state = (fastlane_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x4000); + + state->konami2 = devtag_get_device(machine, "konami2"); + state->k007121 = devtag_get_device(machine, "k007121"); +} + static MACHINE_DRIVER_START( fastlane ) + /* driver data */ + MDRV_DRIVER_DATA(fastlane_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309, 3000000*4) /* 24MHz/8? */ MDRV_CPU_PROGRAM_MAP(fastlane_map) MDRV_CPU_VBLANK_INT_HACK(fastlane_interrupt,16) /* 1 IRQ + ??? NMI (generated by the 007121) */ + MDRV_MACHINE_START(fastlane) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -271,4 +279,4 @@ ROM_START( fastlane ) ROM_END -GAME( 1987, fastlane, 0, fastlane, fastlane, 0, ROT90, "Konami", "Fast Lane", GAME_IMPERFECT_COLORS ) +GAME( 1987, fastlane, 0, fastlane, fastlane, 0, ROT90, "Konami", "Fast Lane", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/flkatck.c b/src/mame/drivers/flkatck.c index cdde12a999f..60d720d1672 100644 --- a/src/mame/drivers/flkatck.c +++ b/src/mame/drivers/flkatck.c @@ -1,12 +1,12 @@ /*************************************************************************** -Flak Attack/MX5000 (Konami GX669) + Flak Attack / MX5000 (Konami GX669) -Driver by: - Manuel Abadia + Driver by: + Manuel Abadia -TO DO: - -What does 0x900X do? (Z80) + TO DO: + -What does 0x900X do? (Z80) ***************************************************************************/ @@ -17,51 +17,34 @@ TO DO: #include "sound/k007232.h" #include "video/konicdev.h" #include "includes/konamipt.h" +#include "includes/flkatck.h" -/* from video/flkatck.c */ -VIDEO_START( flkatck ); -VIDEO_UPDATE( flkatck ); -WRITE8_HANDLER( flkatck_k007121_w ); -WRITE8_HANDLER( flkatck_k007121_regs_w ); - -extern UINT8 *k007121_ram; -extern int flkatck_irq_enabled; - -static int multiply_reg[2]; - -/***************************************************************************/ - -static MACHINE_RESET( flkatck ) -{ - k007232_set_bank( devtag_get_device(machine, "konami"), 0, 1 ); -} static INTERRUPT_GEN( flkatck_interrupt ) { - if (flkatck_irq_enabled) + flkatck_state *state = (flkatck_state *)device->machine->driver_data; + + if (state->irq_enabled) cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE); } static WRITE8_HANDLER( flkatck_bankswitch_w ) { - UINT8 *RAM = memory_region(space->machine, "maincpu"); - int bankaddress = 0; - /* bits 3-4: coin counters */ - coin_counter_w(space->machine, 0,data & 0x08); - coin_counter_w(space->machine, 1,data & 0x10); + coin_counter_w(space->machine, 0, data & 0x08); + coin_counter_w(space->machine, 1, data & 0x10); /* bits 0-1: bank # */ - bankaddress += 0x10000 + (data & 0x03)*0x2000; if ((data & 0x03) != 0x03) /* for safety */ - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + memory_set_bank(space->machine, "bank1", data & 0x03); } static READ8_HANDLER( flkatck_ls138_r ) { int data = 0; - switch ((offset & 0x1c) >> 2){ + switch ((offset & 0x1c) >> 2) + { case 0x00: if (offset & 0x02) data = input_port_read(space->machine, (offset & 0x01) ? "COIN" : "DSW3"); @@ -79,7 +62,10 @@ static READ8_HANDLER( flkatck_ls138_r ) static WRITE8_HANDLER( flkatck_ls138_w ) { - switch ((offset & 0x1c) >> 2){ + flkatck_state *state = (flkatck_state *)space->machine->driver_data; + + switch ((offset & 0x1c) >> 2) + { case 0x04: /* bankswitch */ flkatck_bankswitch_w(space, 0, data); break; @@ -87,7 +73,7 @@ static WRITE8_HANDLER( flkatck_ls138_w ) soundlatch_w(space, 0, data); break; case 0x06: /* Cause interrupt on audio CPU */ - cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE); + cpu_set_input_line(state->audiocpu, 0, HOLD_LINE); break; case 0x07: /* watchdog reset */ watchdog_reset_w(space, 0, data); @@ -98,12 +84,14 @@ static WRITE8_HANDLER( flkatck_ls138_w ) /* Protection - an external multiplyer connected to the sound CPU */ static READ8_HANDLER( multiply_r ) { - return (multiply_reg[0] * multiply_reg[1]) & 0xFF; + flkatck_state *state = (flkatck_state *)space->machine->driver_data; + return (state->multiply_reg[0] * state->multiply_reg[1]) & 0xff; } static WRITE8_HANDLER( multiply_w ) { - multiply_reg[offset] = data; + flkatck_state *state = (flkatck_state *)space->machine->driver_data; + state->multiply_reg[offset] = data; } @@ -113,7 +101,7 @@ static ADDRESS_MAP_START( flkatck_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0400, 0x041f) AM_READWRITE(flkatck_ls138_r, flkatck_ls138_w) /* inputs, DIPS, bankswitch, counters, sound command */ AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_le_w) AM_BASE_GENERIC(paletteram) /* palette */ AM_RANGE(0x1000, 0x1fff) AM_RAM /* RAM */ - AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(flkatck_k007121_w) AM_BASE(&k007121_ram) /* Video RAM (007121) */ + AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(flkatck_k007121_w) AM_BASE_MEMBER(flkatck_state, k007121_ram) /* Video RAM (007121) */ AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank1") /* banked ROM */ AM_RANGE(0x6000, 0xffff) AM_ROM /* ROM */ ADDRESS_MAP_END @@ -197,8 +185,8 @@ GFXDECODE_END static void volume_callback0(const device_config *device, int v) { - k007232_set_volume(device,0,(v >> 4) * 0x11,0); - k007232_set_volume(device,1,0,(v & 0x0f) * 0x11); + k007232_set_volume(device, 0, (v >> 4) * 0x11, 0); + k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11); } static const k007232_interface k007232_config = @@ -207,8 +195,38 @@ static const k007232_interface k007232_config = }; +static MACHINE_START( flkatck ) +{ + flkatck_state *state = (flkatck_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 3, &ROM[0x10000], 0x2000); + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k007121 = devtag_get_device(machine, "k007121"); + + state_save_register_global(machine, state->irq_enabled); + state_save_register_global_array(machine, state->multiply_reg); + state_save_register_global(machine, state->flipscreen); +} + +static MACHINE_RESET( flkatck ) +{ + flkatck_state *state = (flkatck_state *)machine->driver_data; + + k007232_set_bank(devtag_get_device(machine, "konami"), 0, 1); + + state->irq_enabled = 0; + state->multiply_reg[0] = 0; + state->multiply_reg[1] = 0; + state->flipscreen = 0; +} + static MACHINE_DRIVER_START( flkatck ) + /* driver data */ + MDRV_DRIVER_DATA(flkatck_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309,3000000*4) /* HD63C09EP, 24/8 MHz */ MDRV_CPU_PROGRAM_MAP(flkatck_map) @@ -219,6 +237,7 @@ static MACHINE_DRIVER_START( flkatck ) MDRV_QUANTUM_TIME(HZ(600)) + MDRV_MACHINE_START(flkatck) MDRV_MACHINE_RESET(flkatck) /* video hardware */ @@ -286,5 +305,5 @@ ROM_END -GAME( 1987, mx5000, 0, flkatck, flkatck, 0, ROT90, "Konami", "MX5000", 0 ) -GAME( 1987, flkatck, mx5000, flkatck, flkatck, 0, ROT90, "Konami", "Flak Attack (Japan)", 0 ) +GAME( 1987, mx5000, 0, flkatck, flkatck, 0, ROT90, "Konami", "MX5000", GAME_SUPPORTS_SAVE ) +GAME( 1987, flkatck, mx5000, flkatck, flkatck, 0, ROT90, "Konami", "Flak Attack (Japan)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/hcastle.c b/src/mame/drivers/hcastle.c index 8d109904b0b..b960cab1956 100644 --- a/src/mame/drivers/hcastle.c +++ b/src/mame/drivers/hcastle.c @@ -14,38 +14,24 @@ #include "sound/k051649.h" #include "video/konicdev.h" #include "includes/konamipt.h" +#include "includes/hcastle.h" -PALETTE_INIT( hcastle ); -VIDEO_UPDATE( hcastle ); -VIDEO_START( hcastle ); - -extern UINT8 *hcastle_pf1_videoram,*hcastle_pf2_videoram; - -WRITE8_HANDLER( hcastle_pf1_video_w ); -WRITE8_HANDLER( hcastle_pf2_video_w ); -READ8_HANDLER( hcastle_gfxbank_r ); -WRITE8_HANDLER( hcastle_gfxbank_w ); -WRITE8_HANDLER( hcastle_pf1_control_w ); -WRITE8_HANDLER( hcastle_pf2_control_w ); static WRITE8_HANDLER( hcastle_bankswitch_w ) { - UINT8 *RAM = memory_region(space->machine, "maincpu"); - int bankaddress; - - bankaddress = 0x10000 + (data & 0x1f) * 0x2000; - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + memory_set_bank(space->machine, "bank1", data & 0x1f); } static WRITE8_HANDLER( hcastle_soundirq_w ) { - cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE ); + hcastle_state *state = (hcastle_state *)space->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, HOLD_LINE); } static WRITE8_HANDLER( hcastle_coin_w ) { - coin_counter_w(space->machine, 0,data & 0x40); - coin_counter_w(space->machine, 1,data & 0x80); + coin_counter_w(space->machine, 0, data & 0x40); + coin_counter_w(space->machine, 1, data & 0x80); } @@ -66,11 +52,11 @@ static ADDRESS_MAP_START( hcastle_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0414, 0x0414) AM_READ_PORT("DSW1") AM_RANGE(0x0415, 0x0415) AM_READ_PORT("DSW2") AM_RANGE(0x0418, 0x0418) AM_READWRITE(hcastle_gfxbank_r, hcastle_gfxbank_w) - AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_GENERIC(paletteram) + AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_MEMBER(hcastle_state, paletteram) AM_RANGE(0x0700, 0x1fff) AM_RAM - AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(hcastle_pf1_video_w) AM_BASE(&hcastle_pf1_videoram) + AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(hcastle_pf1_video_w) AM_BASE_MEMBER(hcastle_state, pf1_videoram) AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) - AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(hcastle_pf2_video_w) AM_BASE(&hcastle_pf2_videoram) + AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(hcastle_pf2_video_w) AM_BASE_MEMBER(hcastle_state, pf2_videoram) AM_RANGE(0x5000, 0x5fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2) AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1") AM_RANGE(0x8000, 0xffff) AM_ROM @@ -170,13 +156,14 @@ GFXDECODE_END static void irqhandler(const device_config *device, int linestate) { -// cputag_set_input_line(device->machine, "audiocpu", 0, linestate); +// hcastle_state *state = (hcastle_state *)device->machine->driver_data; +// cputag_set_input_line(state->audiocpu, 0, linestate); } static void volume_callback(const device_config *device, int v) { - k007232_set_volume(device,0,(v >> 4) * 0x11,0); - k007232_set_volume(device,1,0,(v & 0x0f) * 0x11); + k007232_set_volume(device, 0, (v >> 4) * 0x11, 0); + k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11); } static const k007232_interface k007232_config = @@ -189,8 +176,40 @@ static const ym3812_interface ym3812_config = irqhandler }; +static MACHINE_START( hcastle ) +{ + hcastle_state *state = (hcastle_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 16, &ROM[0x10000], 0x2000); + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k007121_1 = devtag_get_device(machine, "k007121_1"); + state->k007121_2 = devtag_get_device(machine, "k007121_2"); + + state_save_register_global(machine, state->pf2_bankbase); + state_save_register_global(machine, state->pf1_bankbase); + state_save_register_global(machine, state->gfx_bank); + state_save_register_global(machine, state->old_pf1); + state_save_register_global(machine, state->old_pf2); +} + +static MACHINE_RESET( hcastle ) +{ + hcastle_state *state = (hcastle_state *)machine->driver_data; + + state->pf2_bankbase = 0; + state->pf1_bankbase = 0; + state->gfx_bank = 0; + state->old_pf1 = -1; + state->old_pf2 = -1; +} + static MACHINE_DRIVER_START( hcastle ) + /* driver data */ + MDRV_DRIVER_DATA(hcastle_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", KONAMI, 3000000) /* Derived from 24 MHz clock */ MDRV_CPU_PROGRAM_MAP(hcastle_map) @@ -199,6 +218,9 @@ static MACHINE_DRIVER_START( hcastle ) MDRV_CPU_ADD("audiocpu", Z80, 3579545) MDRV_CPU_PROGRAM_MAP(sound_map) + MDRV_MACHINE_START(hcastle) + MDRV_MACHINE_RESET(hcastle) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -347,7 +369,7 @@ ROM_END -GAME( 1988, hcastle, 0, hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version M)", 0 ) -GAME( 1988, hcastleo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version K)", 0 ) -GAME( 1988, hcastlej, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version P)", 0 ) -GAME( 1988, hcastljo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version N)", 0 ) +GAME( 1988, hcastle, 0, hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version M)", GAME_SUPPORTS_SAVE ) +GAME( 1988, hcastleo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version K)", GAME_SUPPORTS_SAVE ) +GAME( 1988, hcastlej, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version P)", GAME_SUPPORTS_SAVE ) +GAME( 1988, hcastljo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version N)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/labyrunr.c b/src/mame/drivers/labyrunr.c index 2b504200745..f7d015020f8 100644 --- a/src/mame/drivers/labyrunr.c +++ b/src/mame/drivers/labyrunr.c @@ -1,10 +1,10 @@ /*************************************************************************** -Labyrinth Runner (GX771) (c) 1987 Konami + Labyrinth Runner (GX771) (c) 1987 Konami -similar to Fast Lane + similar to Fast Lane -Driver by Nicola Salmoria + Driver by Nicola Salmoria ***************************************************************************/ @@ -14,50 +14,40 @@ Driver by Nicola Salmoria #include "sound/2203intf.h" #include "video/konicdev.h" #include "includes/konamipt.h" +#include "includes/labyrunr.h" -/* from video/labyrunr.c */ -extern UINT8 *labyrunr_videoram1,*labyrunr_videoram2,*labyrunr_scrollram; -PALETTE_INIT( labyrunr ); -WRITE8_HANDLER( labyrunr_vram1_w ); -WRITE8_HANDLER( labyrunr_vram2_w ); -VIDEO_START( labyrunr ); -VIDEO_UPDATE( labyrunr ); static INTERRUPT_GEN( labyrunr_interrupt ) { - const device_config *k007121 = devtag_get_device(device->machine, "k007121"); + labyrunr_state *state = (labyrunr_state *)device->machine->driver_data; if (cpu_getiloops(device) == 0) { - if (k007121_ctrlram_r(k007121, 7) & 0x02) + if (k007121_ctrlram_r(state->k007121, 7) & 0x02) cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE); } else if (cpu_getiloops(device) % 2) { - if (k007121_ctrlram_r(k007121, 7) & 0x01) + if (k007121_ctrlram_r(state->k007121, 7) & 0x01) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); } } static WRITE8_HANDLER( labyrunr_bankswitch_w ) { - int bankaddress; - UINT8 *RAM = memory_region(space->machine, "maincpu"); - -if (data & 0xe0) popmessage("bankswitch %02x",data); + if (data & 0xe0) popmessage("bankswitch %02x", data); /* bits 0-2 = bank number */ - bankaddress = 0x10000 + (data & 0x07) * 0x4000; - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + memory_set_bank(space->machine, "bank1", data & 0x07); // shall we check if data&7 > #banks? /* bits 3 and 4 are coin counters */ - coin_counter_w(space->machine, 0,data & 0x08); - coin_counter_w(space->machine, 1,data & 0x10); + coin_counter_w(space->machine, 0, data & 0x08); + coin_counter_w(space->machine, 1, data & 0x10); } static ADDRESS_MAP_START( labyrunr_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x0007) AM_DEVWRITE("k007121", k007121_ctrl_w) - AM_RANGE(0x0020, 0x005f) AM_RAM AM_BASE(&labyrunr_scrollram) + AM_RANGE(0x0020, 0x005f) AM_RAM AM_BASE_MEMBER(labyrunr_state, scrollram) AM_RANGE(0x0800, 0x0800) AM_DEVREADWRITE("ym1", ym2203_read_port_r, ym2203_write_port_w) AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("ym1", ym2203_status_port_r, ym2203_control_port_w) AM_RANGE(0x0900, 0x0900) AM_DEVREADWRITE("ym2", ym2203_read_port_r, ym2203_write_port_w) @@ -68,11 +58,11 @@ static ADDRESS_MAP_START( labyrunr_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0c00, 0x0c00) AM_WRITE(labyrunr_bankswitch_w) AM_RANGE(0x0d00, 0x0d1f) AM_DEVREADWRITE("k051733", k051733_r, k051733_w) AM_RANGE(0x0e00, 0x0e00) AM_WRITE(watchdog_reset_w) - AM_RANGE(0x1000, 0x10ff) AM_RAM AM_BASE_GENERIC(paletteram) + AM_RANGE(0x1000, 0x10ff) AM_RAM AM_BASE_MEMBER(labyrunr_state, paletteram) AM_RANGE(0x1800, 0x1fff) AM_RAM - AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_GENERIC(spriteram) - AM_RANGE(0x3000, 0x37ff) AM_RAM_WRITE(labyrunr_vram1_w) AM_BASE(&labyrunr_videoram1) - AM_RANGE(0x3800, 0x3fff) AM_RAM_WRITE(labyrunr_vram2_w) AM_BASE(&labyrunr_videoram2) + AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_MEMBER(labyrunr_state, spriteram) + AM_RANGE(0x3000, 0x37ff) AM_RAM_WRITE(labyrunr_vram1_w) AM_BASE_MEMBER(labyrunr_state, videoram1) + AM_RANGE(0x3800, 0x3fff) AM_RAM_WRITE(labyrunr_vram2_w) AM_BASE_MEMBER(labyrunr_state, videoram2) AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1") AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -193,13 +183,28 @@ static const ym2203_interface ym2203_interface_2 = +static MACHINE_START( labyrunr ) +{ + labyrunr_state *state = (labyrunr_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 6, &ROM[0x10000], 0x4000); + + state->k007121 = devtag_get_device(machine, "k007121"); +} + static MACHINE_DRIVER_START( labyrunr ) + /* driver data */ + MDRV_DRIVER_DATA(labyrunr_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309, 3000000*4) /* 24MHz/8? */ MDRV_CPU_PROGRAM_MAP(labyrunr_map) MDRV_CPU_VBLANK_INT_HACK(labyrunr_interrupt,8) /* 1 IRQ + 4 NMI (generated by 007121) */ + MDRV_MACHINE_START(labyrunr) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -292,6 +297,6 @@ ROM_START( labyrunrk ) ROM_END -GAME( 1987, tricktrp, 0, labyrunr, labyrunr, 0, ROT90, "Konami", "Trick Trap (World?)", 0 ) -GAME( 1987, labyrunr, tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (Japan)", 0 ) -GAME( 1987, labyrunrk,tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (World Ver. K)", 0 ) +GAME( 1987, tricktrp, 0, labyrunr, labyrunr, 0, ROT90, "Konami", "Trick Trap (World?)", GAME_SUPPORTS_SAVE ) +GAME( 1987, labyrunr, tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1987, labyrunrk,tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (World Ver. K)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/rockrage.c b/src/mame/drivers/rockrage.c index 57dcf2a5783..8bff40bda1d 100644 --- a/src/mame/drivers/rockrage.c +++ b/src/mame/drivers/rockrage.c @@ -65,12 +65,8 @@ static INTERRUPT_GEN( rockrage_interrupt ) static WRITE8_HANDLER( rockrage_bankswitch_w ) { - int bankaddress; - UINT8 *RAM = memory_region(space->machine, "maincpu"); - /* bits 4-6 = bank number */ - bankaddress = 0x10000 + ((data & 0x70) >> 4) * 0x2000; - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + memory_set_bank(space->machine, "bank1", (data & 0x70) >> 4); /* bits 0 & 1 = coin counters */ coin_counter_w(space->machine, 0,data & 0x01); @@ -278,6 +274,9 @@ static const k007420_interface rockrage_k007420_intf = static MACHINE_START( rockrage ) { rockrage_state *state = (rockrage_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x2000); state->audiocpu = devtag_get_device(machine, "audiocpu"); state->k007342 = devtag_get_device(machine, "k007342"); @@ -432,6 +431,6 @@ ROM_END ***************************************************************************/ -GAME( 1986, rockrage, 0, rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (World)", 0 ) -GAME( 1986, rockragea,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (Prototype?)", 0 ) -GAME( 1986, rockragej,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Koi no Hotrock (Japan)", 0 ) +GAME( 1986, rockrage, 0, rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (World)", GAME_SUPPORTS_SAVE ) +GAME( 1986, rockragea,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (Prototype?)", GAME_SUPPORTS_SAVE ) +GAME( 1986, rockragej,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Koi no Hotrock (Japan)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/suprslam.c b/src/mame/drivers/suprslam.c index 1651e5a1baa..3e2628295e5 100644 --- a/src/mame/drivers/suprslam.c +++ b/src/mame/drivers/suprslam.c @@ -85,43 +85,34 @@ EB26IC73.BIN 27C240 / Main Program #include "cpu/m68000/m68000.h" #include "video/konicdev.h" #include "sound/2610intf.h" - - -extern UINT16 *suprslam_screen_videoram, *suprslam_bg_videoram,*suprslam_sp_videoram, *suprslam_spriteram; - -/* in video */ - -WRITE16_HANDLER( suprslam_screen_videoram_w ); -WRITE16_HANDLER( suprslam_bg_videoram_w ); -VIDEO_START( suprslam ); -VIDEO_UPDATE( suprslam ); -WRITE16_HANDLER (suprslam_bank_w); +#include "includes/suprslam.h" /*** SOUND *******************************************************************/ -static int pending_command; - static WRITE16_HANDLER( sound_command_w ) { + suprslam_state *state = (suprslam_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - pending_command = 1; + state->pending_command = 1; soundlatch_w(space, offset, data & 0xff); - cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); + cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE); } } #if 0 static READ16_HANDLER( pending_command_r ) { + suprslam_state *state = (suprslam_state *)space->machine->driver_data; return pending_command; } #endif static WRITE8_HANDLER( pending_command_clear_w ) { - pending_command = 0; + suprslam_state *state = (suprslam_state *)space->machine->driver_data; + state->pending_command = 0; } static WRITE8_HANDLER( suprslam_sh_bankswitch_w ) @@ -137,11 +128,11 @@ static WRITE8_HANDLER( suprslam_sh_bankswitch_w ) static ADDRESS_MAP_START( suprslam_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0xfb0000, 0xfb1fff) AM_RAM AM_BASE(&suprslam_spriteram) - AM_RANGE(0xfc0000, 0xfcffff) AM_RAM AM_BASE(&suprslam_sp_videoram) + AM_RANGE(0xfb0000, 0xfb1fff) AM_RAM AM_BASE_MEMBER(suprslam_state, spriteram) + AM_RANGE(0xfc0000, 0xfcffff) AM_RAM AM_BASE_MEMBER(suprslam_state, sp_videoram) AM_RANGE(0xfd0000, 0xfdffff) AM_RAM - AM_RANGE(0xfe0000, 0xfe0fff) AM_RAM_WRITE(suprslam_screen_videoram_w) AM_BASE(&suprslam_screen_videoram) - AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(suprslam_bg_videoram_w) AM_BASE(&suprslam_bg_videoram) + AM_RANGE(0xfe0000, 0xfe0fff) AM_RAM_WRITE(suprslam_screen_videoram_w) AM_BASE_MEMBER(suprslam_state, screen_videoram) + AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(suprslam_bg_videoram_w) AM_BASE_MEMBER(suprslam_state, bg_videoram) // AM_RANGE(0xff2000, 0xff203f) AM_RAM /* ?? */ AM_RANGE(0xff8000, 0xff8fff) AM_DEVREADWRITE("k053936", k053936_linectrl_r, k053936_linectrl_w) AM_RANGE(0xff9000, 0xff9001) AM_WRITE(sound_command_w) @@ -287,7 +278,8 @@ GFXDECODE_END static void irqhandler(const device_config *device, int irq) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + suprslam_state *state = (suprslam_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -303,7 +295,30 @@ static const k053936_interface suprslam_k053936_intf = 0x1000 /* linectrl_size */ }; +static MACHINE_START( suprslam ) +{ + suprslam_state *state = (suprslam_state *)machine->driver_data; + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k053936 = devtag_get_device(machine, "k053936"); + + state_save_register_global(machine, state->screen_bank); + state_save_register_global(machine, state->bg_bank); + state_save_register_global(machine, state->pending_command); +} + +static MACHINE_RESET( suprslam ) +{ + suprslam_state *state = (suprslam_state *)machine->driver_data; + + state->screen_bank = 0; + state->bg_bank = 0; + state->pending_command = 0; +} + static MACHINE_DRIVER_START( suprslam ) + MDRV_DRIVER_DATA(suprslam_state) + MDRV_CPU_ADD("maincpu", M68000, 16000000) MDRV_CPU_PROGRAM_MAP(suprslam_map) MDRV_CPU_VBLANK_INT("screen", irq1_line_hold) @@ -312,6 +327,9 @@ static MACHINE_DRIVER_START( suprslam ) MDRV_CPU_PROGRAM_MAP(sound_map) MDRV_CPU_IO_MAP(sound_io_map) + MDRV_MACHINE_START(suprslam) + MDRV_MACHINE_RESET(suprslam) + MDRV_GFXDECODE(suprslam) MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK) @@ -373,4 +391,4 @@ ROM_END /*** GAME DRIVERS ************************************************************/ -GAME( 1995, suprslam, 0, suprslam, suprslam, 0, ROT0, "Banpresto / Toei Animation", "Super Slams", GAME_IMPERFECT_GRAPHICS ) +GAME( 1995, suprslam, 0, suprslam, suprslam, 0, ROT0, "Banpresto / Toei Animation", "Super Slams", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/f1gp.h b/src/mame/includes/f1gp.h index 2bc057d5577..9218bdb6535 100644 --- a/src/mame/includes/f1gp.h +++ b/src/mame/includes/f1gp.h @@ -1,19 +1,40 @@ + +typedef struct _f1gp_state f1gp_state; +struct _f1gp_state +{ + /* memory pointers */ + UINT16 * sharedram; + UINT16 * spr1vram; + UINT16 * spr2vram; + UINT16 * spr1cgram; + UINT16 * spr2cgram; + UINT16 * fgvideoram; + UINT16 * rozvideoram; + UINT16 * sprcgram; + UINT16 * spritelist; + UINT16 * spriteram; + UINT16 * fgregs; + UINT16 * rozregs; + UINT16 * zoomdata; +// UINT16 * paletteram; // currently this uses generic palette handling + size_t spr1cgram_size, spr2cgram_size; + size_t spriteram_size; + + /* video-related */ + tilemap *fg_tilemap, *roz_tilemap; + int roz_bank, flipscreen, gfxctrl; + int scroll[2]; + + /* misc */ + int pending_command; + + /* devices */ + const device_config *audiocpu; + const device_config *k053936; +}; + /*----------- defined in video/f1gp.c -----------*/ -extern UINT16 *f1gp_spr1vram,*f1gp_spr2vram,*f1gp_spr1cgram,*f1gp_spr2cgram; -extern UINT16 *f1gp_fgvideoram,*f1gp_rozvideoram; -extern UINT16 *f1gp2_sprcgram,*f1gp2_spritelist; -extern UINT16 *f1gpb_rozregs, *f1gpb_fgregs; -extern size_t f1gp_spr1cgram_size,f1gp_spr2cgram_size; - - -VIDEO_START( f1gp ); -VIDEO_START( f1gpb ); -VIDEO_START( f1gp2 ); -VIDEO_UPDATE( f1gp ); -VIDEO_UPDATE( f1gpb ); -VIDEO_UPDATE( f1gp2 ); - READ16_HANDLER( f1gp_zoomdata_r ); WRITE16_HANDLER( f1gp_zoomdata_w ); READ16_HANDLER( f1gp_rozvideoram_r ); @@ -22,3 +43,10 @@ WRITE16_HANDLER( f1gp_fgvideoram_w ); WRITE16_HANDLER( f1gp_fgscroll_w ); WRITE16_HANDLER( f1gp_gfxctrl_w ); WRITE16_HANDLER( f1gp2_gfxctrl_w ); + +VIDEO_START( f1gp ); +VIDEO_START( f1gpb ); +VIDEO_START( f1gp2 ); +VIDEO_UPDATE( f1gp ); +VIDEO_UPDATE( f1gpb ); +VIDEO_UPDATE( f1gp2 ); diff --git a/src/mame/includes/fastlane.h b/src/mame/includes/fastlane.h new file mode 100644 index 00000000000..76514cbc5f2 --- /dev/null +++ b/src/mame/includes/fastlane.h @@ -0,0 +1,36 @@ +/************************************************************************* + + Fast Lane + +*************************************************************************/ + +typedef struct _fastlane_state fastlane_state; +struct _fastlane_state +{ + /* memory pointers */ + UINT8 * videoram1; + UINT8 * videoram2; + UINT8 * paletteram; + UINT8 * spriteram; + UINT8 * k007121_regs; + + /* video-related */ + tilemap *layer0, *layer1; + rectangle clip0, clip1; + + /* devices */ + const device_config *konami2; + const device_config *k007121; +}; + + + + +/*----------- defined in video/fastlane.c -----------*/ + +WRITE8_HANDLER( fastlane_vram1_w ); +WRITE8_HANDLER( fastlane_vram2_w ); + +PALETTE_INIT( fastlane ); +VIDEO_START( fastlane ); +VIDEO_UPDATE( fastlane ); diff --git a/src/mame/includes/flkatck.h b/src/mame/includes/flkatck.h new file mode 100644 index 00000000000..76c79d7c3e8 --- /dev/null +++ b/src/mame/includes/flkatck.h @@ -0,0 +1,37 @@ +/************************************************************************* + + Flak Attack / MX5000 + +*************************************************************************/ + +typedef struct _flkatck_state flkatck_state; +struct _flkatck_state +{ + /* memory pointers */ + UINT8 * k007121_ram; +// UINT8 * paletteram; // this currently uses generic palette handling + + /* video-related */ + tilemap *k007121_tilemap[2]; + int flipscreen; + + /* misc */ + int irq_enabled; + int multiply_reg[2]; + + /* devices */ + const device_config *audiocpu; + const device_config *k007121; +}; + + +//static rectangle k007121_clip[2]; + + +/*----------- defined in video/flkatck.c -----------*/ + +WRITE8_HANDLER( flkatck_k007121_w ); +WRITE8_HANDLER( flkatck_k007121_regs_w ); + +VIDEO_START( flkatck ); +VIDEO_UPDATE( flkatck ); diff --git a/src/mame/includes/hcastle.h b/src/mame/includes/hcastle.h new file mode 100644 index 00000000000..9d02ac9f6b1 --- /dev/null +++ b/src/mame/includes/hcastle.h @@ -0,0 +1,41 @@ +/************************************************************************* + + Haunted Castle + +*************************************************************************/ + +typedef struct _hcastle_state hcastle_state; +struct _hcastle_state +{ + /* memory pointers */ + UINT8 * pf1_videoram; + UINT8 * pf2_videoram; + UINT8 * paletteram; +// UINT8 * spriteram; +// UINT8 * spriteram2; + + /* video-related */ + tilemap *fg_tilemap, *bg_tilemap; + int pf2_bankbase, pf1_bankbase; + int old_pf1, old_pf2; + int gfx_bank; + + /* devices */ + const device_config *audiocpu; + const device_config *k007121_1; + const device_config *k007121_2; +}; + + +/*----------- defined in video/hcastle.c -----------*/ + +WRITE8_HANDLER( hcastle_pf1_video_w ); +WRITE8_HANDLER( hcastle_pf2_video_w ); +READ8_HANDLER( hcastle_gfxbank_r ); +WRITE8_HANDLER( hcastle_gfxbank_w ); +WRITE8_HANDLER( hcastle_pf1_control_w ); +WRITE8_HANDLER( hcastle_pf2_control_w ); + +PALETTE_INIT( hcastle ); +VIDEO_UPDATE( hcastle ); +VIDEO_START( hcastle ); diff --git a/src/mame/includes/labyrunr.h b/src/mame/includes/labyrunr.h new file mode 100644 index 00000000000..39592cec37b --- /dev/null +++ b/src/mame/includes/labyrunr.h @@ -0,0 +1,34 @@ +/************************************************************************* + + Labyrinth Runner + +*************************************************************************/ + +typedef struct _labyrunr_state labyrunr_state; +struct _labyrunr_state +{ + /* memory pointers */ + UINT8 * videoram1; + UINT8 * videoram2; + UINT8 * scrollram; + UINT8 * spriteram; + UINT8 * paletteram; + + /* video-related */ + tilemap *layer0, *layer1; + rectangle clip0, clip1; + + /* devices */ + const device_config *k007121; +}; + + +/*----------- defined in video/labyrunr.c -----------*/ + + +WRITE8_HANDLER( labyrunr_vram1_w ); +WRITE8_HANDLER( labyrunr_vram2_w ); + +PALETTE_INIT( labyrunr ); +VIDEO_START( labyrunr ); +VIDEO_UPDATE( labyrunr ); diff --git a/src/mame/includes/suprslam.h b/src/mame/includes/suprslam.h new file mode 100644 index 00000000000..b11a121a58e --- /dev/null +++ b/src/mame/includes/suprslam.h @@ -0,0 +1,37 @@ +/************************************************************************* + + Super Slams + +*************************************************************************/ + +typedef struct _suprslam_state suprslam_state; +struct _suprslam_state +{ + /* memory pointers */ + UINT16 * screen_videoram; + UINT16 * bg_videoram; + UINT16 * sp_videoram; + UINT16 * spriteram; +// UINT16 * paletteram; // this currently uses generic palette handling + + /* video-related */ + tilemap *screen_tilemap, *bg_tilemap; + UINT16 screen_bank, bg_bank; + + /* misc */ + int pending_command; + + /* devices */ + const device_config *audiocpu; + const device_config *k053936; +}; + + +/*----------- defined in video/suprslam.c -----------*/ + +WRITE16_HANDLER( suprslam_screen_videoram_w ); +WRITE16_HANDLER( suprslam_bg_videoram_w ); +WRITE16_HANDLER( suprslam_bank_w ); + +VIDEO_START( suprslam ); +VIDEO_UPDATE( suprslam ); diff --git a/src/mame/video/f1gp.c b/src/mame/video/f1gp.c index 05728e3d17a..a7eb6d89c0e 100644 --- a/src/mame/video/f1gp.c +++ b/src/mame/video/f1gp.c @@ -1,22 +1,10 @@ #include "driver.h" #include "video/konicdev.h" -#include "f1gp.h" +#include "includes/f1gp.h" -UINT16 *f1gp_spr1vram,*f1gp_spr2vram,*f1gp_spr1cgram,*f1gp_spr2cgram; -UINT16 *f1gp_fgvideoram,*f1gp_rozvideoram; -UINT16 *f1gp2_sprcgram,*f1gp2_spritelist; -UINT16 *f1gpb_rozregs, *f1gpb_fgregs; -size_t f1gp_spr1cgram_size,f1gp_spr2cgram_size; - -static UINT16 *zoomdata; -static int flipscreen,gfxctrl; - #define TOTAL_CHARS 0x800 -static tilemap *fg_tilemap,*roz_tilemap; -static int f1gp2_roz_bank; - /*************************************************************************** @@ -26,23 +14,26 @@ static int f1gp2_roz_bank; static TILE_GET_INFO( f1gp_get_roz_tile_info ) { - int code = f1gp_rozvideoram[tile_index]; + f1gp_state *state = (f1gp_state *)machine->driver_data; + int code = state->rozvideoram[tile_index]; - SET_TILE_INFO(3,code & 0x7ff,code >> 12,0); + SET_TILE_INFO(3, code & 0x7ff, code >> 12, 0); } static TILE_GET_INFO( f1gp2_get_roz_tile_info ) { - int code = f1gp_rozvideoram[tile_index]; + f1gp_state *state = (f1gp_state *)machine->driver_data; + int code = state->rozvideoram[tile_index]; - SET_TILE_INFO(2,(code & 0x7ff) + (f1gp2_roz_bank << 11),code >> 12,0); + SET_TILE_INFO(2, (code & 0x7ff) + (state->roz_bank << 11), code >> 12, 0); } static TILE_GET_INFO( get_fg_tile_info ) { - int code = f1gp_fgvideoram[tile_index]; + f1gp_state *state = (f1gp_state *)machine->driver_data; + int code = state->fgvideoram[tile_index]; - SET_TILE_INFO(0,code & 0x7fff,0,(code & 0x8000)?TILE_FLIPY:0); + SET_TILE_INFO(0, code & 0x7fff, 0, (code & 0x8000) ? TILE_FLIPY : 0); } @@ -54,37 +45,47 @@ static TILE_GET_INFO( get_fg_tile_info ) VIDEO_START( f1gp ) { - roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64); - fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); + f1gp_state *state = (f1gp_state *)machine->driver_data; - tilemap_set_transparent_pen(fg_tilemap, 0xff); + state->roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); - zoomdata = (UINT16 *)memory_region(machine, "gfx4"); - gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata); + tilemap_set_transparent_pen(state->fg_tilemap, 0xff); + + state->zoomdata = (UINT16 *)memory_region(machine, "gfx4"); + gfx_element_set_source(machine->gfx[3], (UINT8 *)state->zoomdata); + +// state_save_register_global_pointer(machine, state->zoomdata, memory_region_length(machine, "gfx4")); } VIDEO_START( f1gpb ) { - roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info,tilemap_scan_rows,16,16,64,64); - fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,64,32); + f1gp_state *state = (f1gp_state *)machine->driver_data; - tilemap_set_transparent_pen(fg_tilemap,0xff); + state->roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); - zoomdata = (UINT16 *)memory_region(machine, "gfx4"); - gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata); + tilemap_set_transparent_pen(state->fg_tilemap, 0xff); + + state->zoomdata = (UINT16 *)memory_region(machine, "gfx4"); + gfx_element_set_source(machine->gfx[3], (UINT8 *)state->zoomdata); + +// state_save_register_global_pointer(machine, state->zoomdata, memory_region_length(machine, "gfx4")); } VIDEO_START( f1gp2 ) { - roz_tilemap = tilemap_create(machine, f1gp2_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64); - fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); + f1gp_state *state = (f1gp_state *)machine->driver_data; - tilemap_set_transparent_pen(fg_tilemap, 0xff); - tilemap_set_transparent_pen(roz_tilemap, 0x0f); + state->roz_tilemap = tilemap_create(machine, f1gp2_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); - tilemap_set_scrolldx(fg_tilemap, -80, 0); - tilemap_set_scrolldy(fg_tilemap, -26, 0); + tilemap_set_transparent_pen(state->fg_tilemap, 0xff); + tilemap_set_transparent_pen(state->roz_tilemap, 0x0f); + + tilemap_set_scrolldx(state->fg_tilemap, -80, 0); + tilemap_set_scrolldy(state->fg_tilemap, -26, 0); } @@ -96,69 +97,75 @@ VIDEO_START( f1gp2 ) READ16_HANDLER( f1gp_zoomdata_r ) { - return zoomdata[offset]; + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + return state->zoomdata[offset]; } WRITE16_HANDLER( f1gp_zoomdata_w ) { - COMBINE_DATA(&zoomdata[offset]); + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + COMBINE_DATA(&state->zoomdata[offset]); gfx_element_mark_dirty(space->machine->gfx[3], offset / 64); } READ16_HANDLER( f1gp_rozvideoram_r ) { - return f1gp_rozvideoram[offset]; + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + return state->rozvideoram[offset]; } WRITE16_HANDLER( f1gp_rozvideoram_w ) { - COMBINE_DATA(&f1gp_rozvideoram[offset]); - tilemap_mark_tile_dirty(roz_tilemap,offset); + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + COMBINE_DATA(&state->rozvideoram[offset]); + tilemap_mark_tile_dirty(state->roz_tilemap, offset); } WRITE16_HANDLER( f1gp_fgvideoram_w ) { - COMBINE_DATA(&f1gp_fgvideoram[offset]); - tilemap_mark_tile_dirty(fg_tilemap,offset); + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + COMBINE_DATA(&state->fgvideoram[offset]); + tilemap_mark_tile_dirty(state->fg_tilemap, offset); } WRITE16_HANDLER( f1gp_fgscroll_w ) { - static int scroll[2]; + f1gp_state *state = (f1gp_state *)space->machine->driver_data; + COMBINE_DATA(&state->scroll[offset]); - COMBINE_DATA(&scroll[offset]); - - tilemap_set_scrollx(fg_tilemap,0,scroll[0]); - tilemap_set_scrolly(fg_tilemap,0,scroll[1]); + tilemap_set_scrollx(state->fg_tilemap, 0, state->scroll[0]); + tilemap_set_scrolly(state->fg_tilemap, 0, state->scroll[1]); } WRITE16_HANDLER( f1gp_gfxctrl_w ) { + f1gp_state *state = (f1gp_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - flipscreen = data & 0x20; - gfxctrl = data & 0xdf; + state->flipscreen = data & 0x20; + state->gfxctrl = data & 0xdf; } } WRITE16_HANDLER( f1gp2_gfxctrl_w ) { + f1gp_state *state = (f1gp_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - flipscreen = data & 0x20; + state->flipscreen = data & 0x20; /* bit 0/1 = fg/sprite/roz priority */ /* bit 2 = blank screen */ - gfxctrl = data & 0xdf; + state->gfxctrl = data & 0xdf; } if (ACCESSING_BITS_8_15) { - if (f1gp2_roz_bank != (data >> 8)) + if (state->roz_bank != (data >> 8)) { - f1gp2_roz_bank = (data >> 8); - tilemap_mark_all_tiles_dirty(roz_tilemap); + state->roz_bank = (data >> 8); + tilemap_mark_all_tiles_dirty(state->roz_tilemap); } } } @@ -170,17 +177,18 @@ WRITE16_HANDLER( f1gp2_gfxctrl_w ) ***************************************************************************/ -static void f1gp_draw_sprites(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int chip,int primask) +static void f1gp_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int chip, int primask ) { - int attr_start,first; - UINT16 *spram = chip ? f1gp_spr2vram : f1gp_spr1vram; + f1gp_state *state = (f1gp_state *)machine->driver_data; + int attr_start, first; + UINT16 *spram = chip ? state->spr2vram : state->spr1vram; first = 4 * spram[0x1fe]; - for (attr_start = 0x0200-8;attr_start >= first;attr_start -= 4) + for (attr_start = 0x0200 - 8; attr_start >= first; attr_start -= 4) { int map_start; - int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color,pri; + int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color, pri; /* table hand made by looking at the ship explosion in attract mode */ /* it's almost a logarithmic scale but not exactly */ static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 }; @@ -199,17 +207,17 @@ static void f1gp_draw_sprites(running_machine *machine,bitmap_t *bitmap,const re pri = 0;//spram[attr_start + 2] & 0x0010; map_start = spram[attr_start + 3]; - zoomx = 16 - zoomtable[zoomx]/8; - zoomy = 16 - zoomtable[zoomy]/8; + zoomx = 16 - zoomtable[zoomx] / 8; + zoomy = 16 - zoomtable[zoomy] / 8; - for (y = 0;y <= ysize;y++) + for (y = 0; y <= ysize; y++) { - int sx,sy; + int sx, sy; if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16; else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16; - for (x = 0;x <= xsize;x++) + for (x = 0; x <= xsize; x++) { int code; @@ -217,9 +225,9 @@ static void f1gp_draw_sprites(running_machine *machine,bitmap_t *bitmap,const re else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16; if (chip == 0) - code = f1gp_spr1cgram[map_start % (f1gp_spr1cgram_size/2)]; + code = state->spr1cgram[map_start % (state->spr1cgram_size / 2)]; else - code = f1gp_spr2cgram[map_start % (f1gp_spr2cgram_size/2)]; + code = state->spr2cgram[map_start % (state->spr2cgram_size / 2)]; pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[1 + chip], code, @@ -241,15 +249,42 @@ static void f1gp_draw_sprites(running_machine *machine,bitmap_t *bitmap,const re } } -static void f1gpb_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) + +VIDEO_UPDATE( f1gp ) { - UINT16 *spriteram16 = machine->generic.spriteram.u16; - int attr_start, start_offset = machine->generic.spriteram_size/2 - 4; + f1gp_state *state = (f1gp_state *)screen->machine->driver_data; + + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); + + k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, 0, 0, 1); + + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 1); + + /* quick kludge for "continue" screen priority */ + if (state->gfxctrl == 0x00) + { + f1gp_draw_sprites(screen->machine, bitmap, cliprect, 0, 0x02); + f1gp_draw_sprites(screen->machine, bitmap, cliprect, 1, 0x02); + } + else + { + f1gp_draw_sprites(screen->machine, bitmap, cliprect, 0, 0x00); + f1gp_draw_sprites(screen->machine, bitmap, cliprect, 1, 0x02); + } + return 0; +} + + +static void f1gpb_draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect ) +{ + f1gp_state *state = (f1gp_state *)machine->driver_data; + UINT16 *spriteram = state->spriteram; + int attr_start, start_offset = state->spriteram_size / 2 - 4; // find the "end of list" to draw the sprites in reverse order - for (attr_start = 4;attr_start < machine->generic.spriteram_size/2;attr_start += 4) + for (attr_start = 4; attr_start < state->spriteram_size / 2; attr_start += 4) { - if (spriteram16[attr_start+3-4] == 0xffff) /* end of list marker */ + if (spriteram[attr_start + 3 - 4] == 0xffff) /* end of list marker */ { start_offset = attr_start - 4; break; @@ -258,26 +293,26 @@ static void f1gpb_draw_sprites(running_machine *machine, bitmap_t *bitmap,const for (attr_start = start_offset;attr_start >= 4;attr_start -= 4) { - int code,gfx; - int x,y,flipx,flipy,color,pri; + int code, gfx; + int x, y, flipx, flipy, color, pri; - x = (spriteram16[attr_start + 2] & 0x03ff) - 48; - y = (256 - (spriteram16[attr_start + 3 - 4] & 0x03ff)) - 15; - flipx = spriteram16[attr_start + 1] & 0x0800; - flipy = spriteram16[attr_start + 1] & 0x8000; - color = spriteram16[attr_start + 1] & 0x000f; - code = spriteram16[attr_start + 0] & 0x3fff; + x = (spriteram[attr_start + 2] & 0x03ff) - 48; + y = (256 - (spriteram[attr_start + 3 - 4] & 0x03ff)) - 15; + flipx = spriteram[attr_start + 1] & 0x0800; + flipy = spriteram[attr_start + 1] & 0x8000; + color = spriteram[attr_start + 1] & 0x000f; + code = spriteram[attr_start + 0] & 0x3fff; pri = 0; //? - if((spriteram16[attr_start + 1] & 0x00f0) && (spriteram16[attr_start + 1] & 0x00f0) != 0xc0) + if((spriteram[attr_start + 1] & 0x00f0) && (spriteram[attr_start + 1] & 0x00f0) != 0xc0) { - printf("attr %X\n",spriteram16[attr_start + 1] & 0x00f0); + printf("attr %X\n",spriteram[attr_start + 1] & 0x00f0); code = mame_rand(machine); } /* - if(spriteram16[attr_start + 1] & ~0x88cf) - printf("1 = %X\n",spriteram16[attr_start + 1] & ~0x88cf); + if (spriteram[attr_start + 1] & ~0x88cf) + printf("1 = %X\n", spriteram[attr_start + 1] & ~0x88cf); */ if(code >= 0x2000) { @@ -308,83 +343,59 @@ static void f1gpb_draw_sprites(running_machine *machine, bitmap_t *bitmap,const } } - -VIDEO_UPDATE( f1gp ) -{ - const device_config *k053936 = devtag_get_device(screen->machine, "k053936"); - - bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); - - k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, 0, 0, 1); - - tilemap_draw(bitmap,cliprect,fg_tilemap,0,1); - - /* quick kludge for "continue" screen priority */ - if (gfxctrl == 0x00) - { - f1gp_draw_sprites(screen->machine,bitmap,cliprect,0,0x02); - f1gp_draw_sprites(screen->machine,bitmap,cliprect,1,0x02); - } - else - { - f1gp_draw_sprites(screen->machine,bitmap,cliprect,0,0x00); - f1gp_draw_sprites(screen->machine,bitmap,cliprect,1,0x02); - } - return 0; -} - VIDEO_UPDATE( f1gpb ) { - UINT32 startx,starty; - int incxx,incxy,incyx,incyy; + f1gp_state *state = (f1gp_state *)screen->machine->driver_data; + UINT32 startx, starty; + int incxx, incxy, incyx, incyy; - incxy = (INT16)f1gpb_rozregs[1]; + incxy = (INT16)state->rozregs[1]; incyx = -incxy; - incxx = incyy = (INT16)f1gpb_rozregs[3]; - startx = f1gpb_rozregs[0] + 328; - starty = f1gpb_rozregs[2]; + incxx = incyy = (INT16)state->rozregs[3]; + startx = state->rozregs[0] + 328; + starty = state->rozregs[2]; - tilemap_set_scrolly(fg_tilemap,0,f1gpb_fgregs[0] + 8); + tilemap_set_scrolly(state->fg_tilemap, 0, state->fgregs[0] + 8); bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); - tilemap_draw_roz(bitmap, cliprect, roz_tilemap, + tilemap_draw_roz(bitmap, cliprect, state->roz_tilemap, startx << 13, starty << 13, incxx << 5, incxy << 5, incyx << 5, incyy << 5, 1, 0, 0); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,1); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 1); - f1gpb_draw_sprites(screen->machine,bitmap,cliprect); + f1gpb_draw_sprites(screen->machine, bitmap, cliprect); return 0; } -static void f1gp2_draw_sprites(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect) +static void f1gp2_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { + f1gp_state *state = (f1gp_state *)machine->driver_data; int offs; - offs = 0; - while (offs < 0x0400 && (f1gp2_spritelist[offs] & 0x4000) == 0) + while (offs < 0x0400 && (state->spritelist[offs] & 0x4000) == 0) { int attr_start; int map_start; - int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color; + int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color; - attr_start = 4 * (f1gp2_spritelist[offs++] & 0x01ff); + attr_start = 4 * (state->spritelist[offs++] & 0x01ff); - ox = f1gp2_spritelist[attr_start + 1] & 0x01ff; - xsize = (f1gp2_spritelist[attr_start + 1] & 0x0e00) >> 9; - zoomx = (f1gp2_spritelist[attr_start + 1] & 0xf000) >> 12; - oy = f1gp2_spritelist[attr_start + 0] & 0x01ff; - ysize = (f1gp2_spritelist[attr_start + 0] & 0x0e00) >> 9; - zoomy = (f1gp2_spritelist[attr_start + 0] & 0xf000) >> 12; - flipx = f1gp2_spritelist[attr_start + 2] & 0x4000; - flipy = f1gp2_spritelist[attr_start + 2] & 0x8000; - color = (f1gp2_spritelist[attr_start + 2] & 0x1f00) >> 8; - map_start = f1gp2_spritelist[attr_start + 3] & 0x7fff; + ox = state->spritelist[attr_start + 1] & 0x01ff; + xsize = (state->spritelist[attr_start + 1] & 0x0e00) >> 9; + zoomx = (state->spritelist[attr_start + 1] & 0xf000) >> 12; + oy = state->spritelist[attr_start + 0] & 0x01ff; + ysize = (state->spritelist[attr_start + 0] & 0x0e00) >> 9; + zoomy = (state->spritelist[attr_start + 0] & 0xf000) >> 12; + flipx = state->spritelist[attr_start + 2] & 0x4000; + flipy = state->spritelist[attr_start + 2] & 0x8000; + color = (state->spritelist[attr_start + 2] & 0x1f00) >> 8; + map_start = state->spritelist[attr_start + 3] & 0x7fff; // aerofgt has the following adjustment, but doing it here would break the title screen // ox += (xsize*zoomx+2)/4; @@ -393,26 +404,27 @@ static void f1gp2_draw_sprites(running_machine *machine,bitmap_t *bitmap,const r zoomx = 32 - zoomx; zoomy = 32 - zoomy; - if (f1gp2_spritelist[attr_start + 2] & 0x20ff) color = mame_rand(machine); + if (state->spritelist[attr_start + 2] & 0x20ff) + color = mame_rand(machine); - for (y = 0;y <= ysize;y++) + for (y = 0; y <= ysize; y++) { int sx,sy; if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16; else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16; - for (x = 0;x <= xsize;x++) + for (x = 0; x <= xsize; x++) { int code; if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16; else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16; - code = f1gp2_sprcgram[map_start & 0x3fff]; + code = state->sprcgram[map_start & 0x3fff]; map_start++; - if (flipscreen) + if (state->flipscreen) drawgfxzoom_transpen(bitmap,cliprect,machine->gfx[1], code, color, @@ -434,28 +446,28 @@ static void f1gp2_draw_sprites(running_machine *machine,bitmap_t *bitmap,const r VIDEO_UPDATE( f1gp2 ) { - const device_config *k053936 = devtag_get_device(screen->machine, "k053936"); + f1gp_state *state = (f1gp_state *)screen->machine->driver_data; - if (gfxctrl & 4) /* blank screen */ + if (state->gfxctrl & 4) /* blank screen */ bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); else { - switch (gfxctrl & 3) + switch (state->gfxctrl & 3) { case 0: - k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1); - f1gp2_draw_sprites(screen->machine,bitmap,cliprect); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); + k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1); + f1gp2_draw_sprites(screen->machine, bitmap, cliprect); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); break; case 1: - k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); - f1gp2_draw_sprites(screen->machine,bitmap,cliprect); + k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); + f1gp2_draw_sprites(screen->machine, bitmap, cliprect); break; case 2: - tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_OPAQUE,0); - k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, 0, 0, 1); - f1gp2_draw_sprites(screen->machine,bitmap,cliprect); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_OPAQUE, 0); + k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, 0, 0, 1); + f1gp2_draw_sprites(screen->machine, bitmap, cliprect); break; #ifdef MAME_DEBUG case 3: diff --git a/src/mame/video/fastlane.c b/src/mame/video/fastlane.c index cb532cca115..601238c0e39 100644 --- a/src/mame/video/fastlane.c +++ b/src/mame/video/fastlane.c @@ -1,9 +1,6 @@ #include "driver.h" #include "video/konicdev.h" - -UINT8 *fastlane_k007121_regs,*fastlane_videoram1,*fastlane_videoram2; -static tilemap *layer0, *layer1; -static rectangle clip0, clip1; +#include "includes/fastlane.h" PALETTE_INIT( fastlane ) @@ -26,20 +23,21 @@ PALETTE_INIT( fastlane ) } -static void set_pens(running_machine *machine) +static void set_pens( running_machine *machine ) { + fastlane_state *state = (fastlane_state *)machine->driver_data; int i; for (i = 0x00; i < 0x800; i += 2) { - UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8); + UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8); rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); colortable_palette_set_color(machine->colortable, i >> 1, color); } } - + /*************************************************************************** @@ -50,12 +48,12 @@ static void set_pens(running_machine *machine) static TILE_GET_INFO( get_tile_info0 ) { - const device_config *k007121 = devtag_get_device(machine, "k007121"); - UINT8 ctrl_3 = k007121_ctrlram_r(k007121, 3); - UINT8 ctrl_4 = k007121_ctrlram_r(k007121, 4); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - int attr = fastlane_videoram1[tile_index]; - int code = fastlane_videoram1[tile_index + 0x400]; + fastlane_state *state = (fastlane_state *)machine->driver_data; + UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3); + UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4); + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5); + int attr = state->videoram1[tile_index]; + int code = state->videoram1[tile_index + 0x400]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; @@ -79,12 +77,12 @@ static TILE_GET_INFO( get_tile_info0 ) static TILE_GET_INFO( get_tile_info1 ) { - const device_config *k007121 = devtag_get_device(machine, "k007121"); - UINT8 ctrl_3 = k007121_ctrlram_r(k007121, 3); - UINT8 ctrl_4 = k007121_ctrlram_r(k007121, 4); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - int attr = fastlane_videoram2[tile_index]; - int code = fastlane_videoram2[tile_index + 0x400]; + fastlane_state *state = (fastlane_state *)machine->driver_data; + UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3); + UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4); + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5); + int attr = state->videoram2[tile_index]; + int code = state->videoram2[tile_index + 0x400]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; @@ -114,17 +112,19 @@ static TILE_GET_INFO( get_tile_info1 ) VIDEO_START( fastlane ) { - layer0 = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,32,32); - layer1 = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,32,32); + fastlane_state *state = (fastlane_state *)machine->driver_data; - tilemap_set_scroll_rows( layer0, 32 ); + state->layer0 = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 8, 8, 32, 32); + state->layer1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 8, 8, 32, 32); - clip0 = *video_screen_get_visible_area(machine->primary_screen); - clip0.min_x += 40; + tilemap_set_scroll_rows(state->layer0, 32); - clip1 = *video_screen_get_visible_area(machine->primary_screen); - clip1.max_x = 39; - clip1.min_x = 0; + state->clip0 = *video_screen_get_visible_area(machine->primary_screen); + state->clip0.min_x += 40; + + state->clip1 = *video_screen_get_visible_area(machine->primary_screen); + state->clip1.max_x = 39; + state->clip1.min_x = 0; } /*************************************************************************** @@ -135,14 +135,16 @@ VIDEO_START( fastlane ) WRITE8_HANDLER( fastlane_vram1_w ) { - fastlane_videoram1[offset] = data; - tilemap_mark_tile_dirty(layer0,offset & 0x3ff); + fastlane_state *state = (fastlane_state *)space->machine->driver_data; + state->videoram1[offset] = data; + tilemap_mark_tile_dirty(state->layer0, offset & 0x3ff); } WRITE8_HANDLER( fastlane_vram2_w ) { - fastlane_videoram2[offset] = data; - tilemap_mark_tile_dirty(layer1,offset & 0x3ff); + fastlane_state *state = (fastlane_state *)space->machine->driver_data; + state->videoram2[offset] = data; + tilemap_mark_tile_dirty(state->layer1, offset & 0x3ff); } @@ -155,8 +157,8 @@ WRITE8_HANDLER( fastlane_vram2_w ) VIDEO_UPDATE( fastlane ) { - const device_config *k007121 = devtag_get_device(screen->machine, "k007121"); - rectangle finalclip0 = clip0, finalclip1 = clip1; + fastlane_state *state = (fastlane_state *)screen->machine->driver_data; + rectangle finalclip0 = state->clip0, finalclip1 = state->clip1; int i, xoffs; sect_rect(&finalclip0, cliprect); @@ -165,14 +167,14 @@ VIDEO_UPDATE( fastlane ) set_pens(screen->machine); /* set scroll registers */ - xoffs = k007121_ctrlram_r(k007121, 0); - for( i=0; i<32; i++ ){ - tilemap_set_scrollx(layer0, i, fastlane_k007121_regs[0x20 + i] + xoffs - 40); - } - tilemap_set_scrolly(layer0, 0, k007121_ctrlram_r(k007121, 2)); + xoffs = k007121_ctrlram_r(state->k007121, 0); + for (i = 0; i < 32; i++) + tilemap_set_scrollx(state->layer0, i, state->k007121_regs[0x20 + i] + xoffs - 40); - tilemap_draw(bitmap,&finalclip0,layer0,0,0); - k007121_sprites_draw(k007121,bitmap,cliprect,screen->machine->gfx[0],screen->machine->colortable,screen->machine->generic.spriteram.u8,0,40,0,-1); - tilemap_draw(bitmap,&finalclip1,layer1,0,0); + tilemap_set_scrolly(state->layer0, 0, k007121_ctrlram_r(state->k007121, 2)); + + tilemap_draw(bitmap, &finalclip0, state->layer0, 0, 0); + k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], screen->machine->colortable, state->spriteram, 0, 40, 0, -1); + tilemap_draw(bitmap, &finalclip1, state->layer1, 0, 0); return 0; } diff --git a/src/mame/video/flkatck.c b/src/mame/video/flkatck.c index cc704eb4ad0..eac8a9dd937 100644 --- a/src/mame/video/flkatck.c +++ b/src/mame/video/flkatck.c @@ -6,15 +6,7 @@ #include "driver.h" #include "video/konicdev.h" - -static tilemap *k007121_tilemap[2]; -static rectangle k007121_clip[2]; - -UINT8 *k007121_ram; - -int flkatck_irq_enabled; - -static int k007121_flip_screen = 0; +#include "includes/flkatck.h" /*************************************************************************** @@ -24,23 +16,23 @@ static int k007121_flip_screen = 0; static TILE_GET_INFO( get_tile_info_A ) { - const device_config *k007121 = devtag_get_device(machine, "k007121"); - UINT8 ctrl_0 = k007121_ctrlram_r(k007121, 0); - UINT8 ctrl_2 = k007121_ctrlram_r(k007121, 2); - UINT8 ctrl_3 = k007121_ctrlram_r(k007121, 3); - UINT8 ctrl_4 = k007121_ctrlram_r(k007121, 4); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - int attr = k007121_ram[tile_index]; - int code = k007121_ram[tile_index+0x400]; + flkatck_state *state = (flkatck_state *)machine->driver_data; + UINT8 ctrl_0 = k007121_ctrlram_r(state->k007121, 0); + UINT8 ctrl_2 = k007121_ctrlram_r(state->k007121, 2); + UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3); + UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4); + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5); + int attr = state->k007121_ram[tile_index]; + int code = state->k007121_ram[tile_index + 0x400]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; int bit3 = (ctrl_5 >> 6) & 0x03; int bank = ((attr & 0x80) >> 7) | - ((attr >> (bit0+2)) & 0x02) | - ((attr >> (bit1+1)) & 0x04) | + ((attr >> (bit0 + 2)) & 0x02) | + ((attr >> (bit1 + 1)) & 0x04) | ((attr >> (bit2 )) & 0x08) | - ((attr >> (bit3-1)) & 0x10) | + ((attr >> (bit3 - 1)) & 0x10) | ((ctrl_3 & 0x01) << 5); int mask = (ctrl_4 & 0xf0) >> 4; @@ -59,8 +51,9 @@ static TILE_GET_INFO( get_tile_info_A ) static TILE_GET_INFO( get_tile_info_B ) { - int attr = k007121_ram[tile_index+0x800]; - int code = k007121_ram[tile_index+0xc00]; + flkatck_state *state = (flkatck_state *)machine->driver_data; + int attr = state->k007121_ram[tile_index + 0x800]; + int code = state->k007121_ram[tile_index + 0xc00]; SET_TILE_INFO( 0, @@ -78,9 +71,9 @@ static TILE_GET_INFO( get_tile_info_B ) VIDEO_START( flkatck ) { - k007121_tilemap[0] = tilemap_create(machine, get_tile_info_A,tilemap_scan_rows,8,8,32,32); - k007121_tilemap[1] = tilemap_create(machine, get_tile_info_B,tilemap_scan_rows,8,8,32,32); - + flkatck_state *state = (flkatck_state *)machine->driver_data; + state->k007121_tilemap[0] = tilemap_create(machine, get_tile_info_A, tilemap_scan_rows, 8, 8, 32, 32); + state->k007121_tilemap[1] = tilemap_create(machine, get_tile_info_B, tilemap_scan_rows, 8, 8, 32, 32); } @@ -92,34 +85,37 @@ VIDEO_START( flkatck ) WRITE8_HANDLER( flkatck_k007121_w ) { - k007121_ram[offset] = data; + flkatck_state *state = (flkatck_state *)space->machine->driver_data; + + state->k007121_ram[offset] = data; if (offset < 0x1000) /* tiles */ { if (offset & 0x800) /* score */ - tilemap_mark_tile_dirty(k007121_tilemap[1],offset & 0x3ff); + tilemap_mark_tile_dirty(state->k007121_tilemap[1], offset & 0x3ff); else - tilemap_mark_tile_dirty(k007121_tilemap[0],offset & 0x3ff); + tilemap_mark_tile_dirty(state->k007121_tilemap[0], offset & 0x3ff); } } WRITE8_HANDLER( flkatck_k007121_regs_w ) { - const device_config *k007121 = devtag_get_device(space->machine, "k007121"); + flkatck_state *state = (flkatck_state *)space->machine->driver_data; + switch (offset) { case 0x04: /* ROM bank select */ - if (data != k007121_ctrlram_r(k007121, 4)) + if (data != k007121_ctrlram_r(state->k007121, 4)) tilemap_mark_all_tiles_dirty_all(space->machine); break; case 0x07: /* flip screen + IRQ control */ - k007121_flip_screen = data & 0x08; - tilemap_set_flip_all(space->machine, k007121_flip_screen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - flkatck_irq_enabled = data & 0x02; + state->flipscreen = data & 0x08; + tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + state->irq_enabled = data & 0x02; break; } - k007121_ctrl_w(k007121, offset, data); + k007121_ctrl_w(state->k007121, offset, data); } @@ -138,45 +134,43 @@ WRITE8_HANDLER( flkatck_k007121_regs_w ) VIDEO_UPDATE( flkatck ) { - const device_config *k007121 = devtag_get_device(screen->machine, "k007121"); - rectangle final_clip[2]; + flkatck_state *state = (flkatck_state *)screen->machine->driver_data; + rectangle clip[2]; const rectangle *visarea = video_screen_get_visible_area(screen); - if (k007121_flip_screen) + if (state->flipscreen) { - k007121_clip[0] = *visarea; - k007121_clip[0].max_x -= 40; + clip[0] = *visarea; + clip[0].max_x -= 40; - k007121_clip[1] = *visarea; - k007121_clip[1].min_x = k007121_clip[1].max_x-40; + clip[1] = *visarea; + clip[1].min_x = clip[1].max_x - 40; - tilemap_set_scrollx(k007121_tilemap[0], 0, k007121_ctrlram_r(k007121, 0) - 56 ); - tilemap_set_scrolly(k007121_tilemap[0], 0, k007121_ctrlram_r(k007121, 2)); - tilemap_set_scrollx(k007121_tilemap[1], 0, -16); + tilemap_set_scrollx(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 0) - 56 ); + tilemap_set_scrolly(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 2)); + tilemap_set_scrollx(state->k007121_tilemap[1], 0, -16); } else { - k007121_clip[0] = *visarea; - k007121_clip[0].min_x += 40; + clip[0] = *visarea; + clip[0].min_x += 40; - k007121_clip[1] = *visarea; - k007121_clip[1].max_x = 39; - k007121_clip[1].min_x = 0; + clip[1] = *visarea; + clip[1].max_x = 39; + clip[1].min_x = 0; - tilemap_set_scrollx(k007121_tilemap[0],0,k007121_ctrlram_r(k007121, 0) - 40 ); - tilemap_set_scrolly(k007121_tilemap[0],0,k007121_ctrlram_r(k007121, 2)); - tilemap_set_scrollx(k007121_tilemap[1],0,0); + tilemap_set_scrollx(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 0) - 40 ); + tilemap_set_scrolly(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 2)); + tilemap_set_scrollx(state->k007121_tilemap[1], 0, 0); } /* compute clipping */ - final_clip[0] = k007121_clip[0]; - final_clip[1] = k007121_clip[1]; - sect_rect(&final_clip[0], cliprect); - sect_rect(&final_clip[1], cliprect); + sect_rect(&clip[0], cliprect); + sect_rect(&clip[1], cliprect); /* draw the graphics */ - tilemap_draw(bitmap,&final_clip[0],k007121_tilemap[0],0,0); - k007121_sprites_draw(k007121,bitmap,cliprect,screen->machine->gfx[0],NULL,&k007121_ram[0x1000],0,40,0,-1); - tilemap_draw(bitmap,&final_clip[1],k007121_tilemap[1],0,0); + tilemap_draw(bitmap, &clip[0], state->k007121_tilemap[0], 0, 0); + k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], NULL, &state->k007121_ram[0x1000], 0, 40, 0, -1); + tilemap_draw(bitmap, &clip[1], state->k007121_tilemap[1], 0, 0); return 0; } diff --git a/src/mame/video/hcastle.c b/src/mame/video/hcastle.c index b8846e84701..e4b53aba629 100644 --- a/src/mame/video/hcastle.c +++ b/src/mame/video/hcastle.c @@ -6,12 +6,7 @@ #include "driver.h" #include "video/konicdev.h" - -UINT8 *hcastle_pf1_videoram,*hcastle_pf2_videoram; -static int gfx_bank; - -static tilemap *fg_tilemap,*bg_tilemap; -static int pf2_bankbase,pf1_bankbase; +#include "includes/hcastle.h" PALETTE_INIT( hcastle ) @@ -48,11 +43,12 @@ PALETTE_INIT( hcastle ) static void set_pens(running_machine *machine) { + hcastle_state *state = (hcastle_state *)machine->driver_data; int i; for (i = 0x00; i < 0x100; i += 2) { - UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8); + UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8); rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); @@ -76,50 +72,50 @@ static TILEMAP_MAPPER( tilemap_scan ) static TILE_GET_INFO( get_fg_tile_info ) { - const device_config *k007121 = devtag_get_device(machine, "k007121_1"); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); + hcastle_state *state = (hcastle_state *)machine->driver_data; + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_1, 5); + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6); int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; int bit3 = (ctrl_5 >> 6) & 0x03; - int attr = hcastle_pf1_videoram[tile_index]; - int tile = hcastle_pf1_videoram[tile_index + 0x400]; + int attr = state->pf1_videoram[tile_index]; + int tile = state->pf1_videoram[tile_index + 0x400]; int color = attr & 0x7; int bank = ((attr & 0x80) >> 7) | - ((attr >> (bit0+2)) & 0x02) | - ((attr >> (bit1+1)) & 0x04) | - ((attr >> (bit2 )) & 0x08) | - ((attr >> (bit3-1)) & 0x10); + ((attr >> (bit0 + 2)) & 0x02) | + ((attr >> (bit1 + 1)) & 0x04) | + ((attr >> (bit2 )) & 0x08) | + ((attr >> (bit3 - 1)) & 0x10); SET_TILE_INFO( 0, - tile + bank*0x100 + pf1_bankbase, + tile + bank * 0x100 + state->pf1_bankbase, ((ctrl_6 & 0x30) * 2 + 16) + color, 0); } static TILE_GET_INFO( get_bg_tile_info ) { - const device_config *k007121 = devtag_get_device(machine, "k007121_2"); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); + hcastle_state *state = (hcastle_state *)machine->driver_data; + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_2, 5); + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6); int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; int bit3 = (ctrl_5 >> 6) & 0x03; - int attr = hcastle_pf2_videoram[tile_index]; - int tile = hcastle_pf2_videoram[tile_index + 0x400]; + int attr = state->pf2_videoram[tile_index]; + int tile = state->pf2_videoram[tile_index + 0x400]; int color = attr & 0x7; int bank = ((attr & 0x80) >> 7) | - ((attr >> (bit0+2)) & 0x02) | - ((attr >> (bit1+1)) & 0x04) | - ((attr >> (bit2 )) & 0x08) | - ((attr >> (bit3-1)) & 0x10); + ((attr >> (bit0 + 2)) & 0x02) | + ((attr >> (bit1 + 1)) & 0x04) | + ((attr >> (bit2 )) & 0x08) | + ((attr >> (bit3 - 1)) & 0x10); SET_TILE_INFO( 1, - tile + bank*0x100 + pf2_bankbase, + tile + bank * 0x100 + state->pf2_bankbase, ((ctrl_6 & 0x30) * 2 + 16) + color, 0); } @@ -134,10 +130,12 @@ static TILE_GET_INFO( get_bg_tile_info ) VIDEO_START( hcastle ) { - fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan, 8, 8, 64, 32); - bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan, 8, 8, 64, 32); + hcastle_state *state = (hcastle_state *)machine->driver_data; - tilemap_set_transparent_pen(fg_tilemap,0); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan, 8, 8, 64, 32); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan, 8, 8, 64, 32); + + tilemap_set_transparent_pen(state->fg_tilemap, 0); } @@ -150,125 +148,132 @@ VIDEO_START( hcastle ) WRITE8_HANDLER( hcastle_pf1_video_w ) { - hcastle_pf1_videoram[offset] = data; - tilemap_mark_tile_dirty(fg_tilemap,offset & 0xbff); + hcastle_state *state = (hcastle_state *)space->machine->driver_data; + state->pf1_videoram[offset] = data; + tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0xbff); } WRITE8_HANDLER( hcastle_pf2_video_w ) { - hcastle_pf2_videoram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap,offset & 0xbff); + hcastle_state *state = (hcastle_state *)space->machine->driver_data; + state->pf2_videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0xbff); } WRITE8_HANDLER( hcastle_gfxbank_w ) { - gfx_bank = data; + hcastle_state *state = (hcastle_state *)space->machine->driver_data; + state->gfx_bank = data; } READ8_HANDLER( hcastle_gfxbank_r ) { - return gfx_bank; + hcastle_state *state = (hcastle_state *)space->machine->driver_data; + return state->gfx_bank; } WRITE8_HANDLER( hcastle_pf1_control_w ) { - const device_config *k007121 = devtag_get_device(space->machine, "k007121_1"); - if (offset==3) + hcastle_state *state = (hcastle_state *)space->machine->driver_data; + + if (offset == 3) { - if ((data&0x8)==0) - buffer_spriteram(space->machine, space->machine->generic.spriteram.u8+0x800,0x800); + if ((data & 0x8) == 0) + buffer_spriteram(space->machine, space->machine->generic.spriteram.u8 + 0x800, 0x800); else - buffer_spriteram(space->machine, space->machine->generic.spriteram.u8,0x800); + buffer_spriteram(space->machine, space->machine->generic.spriteram.u8, 0x800); } else if (offset == 7) { - tilemap_set_flip(fg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + tilemap_set_flip(state->fg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); } - k007121_ctrl_w(k007121, offset, data); + k007121_ctrl_w(state->k007121_1, offset, data); } WRITE8_HANDLER( hcastle_pf2_control_w ) { - const device_config *k007121 = devtag_get_device(space->machine, "k007121_2"); - if (offset==3) + hcastle_state *state = (hcastle_state *)space->machine->driver_data; + + if (offset == 3) { - if ((data&0x8)==0) - buffer_spriteram_2(space->machine,space->machine->generic.spriteram2.u8+0x800,0x800); + if ((data & 0x8) == 0) + buffer_spriteram_2(space->machine, space->machine->generic.spriteram2.u8 + 0x800, 0x800); else - buffer_spriteram_2(space->machine,space->machine->generic.spriteram2.u8,0x800); + buffer_spriteram_2(space->machine, space->machine->generic.spriteram2.u8, 0x800); } else if (offset == 7) { - tilemap_set_flip(bg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + tilemap_set_flip(state->bg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); } - k007121_ctrl_w(k007121, offset, data); + k007121_ctrl_w(state->k007121_2, offset, data); } /*****************************************************************************/ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 *sbank, int bank ) { - const char *chiptag = bank ? "k007121_2" : "k007121_1"; - const device_config *k007121 = devtag_get_device(machine, chiptag); + hcastle_state *state = (hcastle_state *)machine->driver_data; + const device_config *k007121 = bank ? state->k007121_2 : state->k007121_1; int base_color = (k007121_ctrlram_r(k007121, 6) & 0x30) * 2; - int bank_base = (bank == 0) ? 0x4000 * (gfx_bank & 1) : 0; + int bank_base = (bank == 0) ? 0x4000 * (state->gfx_bank & 1) : 0; - k007121_sprites_draw(k007121, bitmap, cliprect,machine->gfx[bank], machine->colortable, sbank, base_color, 0, bank_base, -1); + k007121_sprites_draw(k007121, bitmap, cliprect, machine->gfx[bank], machine->colortable, sbank, base_color, 0, bank_base, -1); } /*****************************************************************************/ VIDEO_UPDATE( hcastle ) { - const device_config *k007121_1 = devtag_get_device(screen->machine, "k007121_1"); - const device_config *k007121_2 = devtag_get_device(screen->machine, "k007121_2"); - UINT8 ctrl_1_0 = k007121_ctrlram_r(k007121_1, 0); - UINT8 ctrl_1_1 = k007121_ctrlram_r(k007121_1, 1); - UINT8 ctrl_1_2 = k007121_ctrlram_r(k007121_1, 2); - UINT8 ctrl_1_3 = k007121_ctrlram_r(k007121_1, 3); - UINT8 ctrl_2_0 = k007121_ctrlram_r(k007121_2, 0); - UINT8 ctrl_2_1 = k007121_ctrlram_r(k007121_2, 1); - UINT8 ctrl_2_2 = k007121_ctrlram_r(k007121_2, 2); - UINT8 ctrl_2_3 = k007121_ctrlram_r(k007121_2, 3); - static int old_pf1,old_pf2; + hcastle_state *state = (hcastle_state *)screen->machine->driver_data; + + UINT8 ctrl_1_0 = k007121_ctrlram_r(state->k007121_1, 0); + UINT8 ctrl_1_1 = k007121_ctrlram_r(state->k007121_1, 1); + UINT8 ctrl_1_2 = k007121_ctrlram_r(state->k007121_1, 2); + UINT8 ctrl_1_3 = k007121_ctrlram_r(state->k007121_1, 3); + UINT8 ctrl_2_0 = k007121_ctrlram_r(state->k007121_2, 0); + UINT8 ctrl_2_1 = k007121_ctrlram_r(state->k007121_2, 1); + UINT8 ctrl_2_2 = k007121_ctrlram_r(state->k007121_2, 2); + UINT8 ctrl_2_3 = k007121_ctrlram_r(state->k007121_2, 3); set_pens(screen->machine); - pf1_bankbase = 0x0000; - pf2_bankbase = 0x4000 * ((gfx_bank & 2) >> 1); + state->pf1_bankbase = 0x0000; + state->pf2_bankbase = 0x4000 * ((state->gfx_bank & 2) >> 1); - if (ctrl_1_3 & 0x01) pf1_bankbase += 0x2000; - if (ctrl_2_3 & 0x01) pf2_bankbase += 0x2000; + if (ctrl_1_3 & 0x01) + state->pf1_bankbase += 0x2000; + if (ctrl_2_3 & 0x01) + state->pf2_bankbase += 0x2000; - if (pf1_bankbase != old_pf1) - tilemap_mark_all_tiles_dirty(fg_tilemap); + if (state->pf1_bankbase != state->old_pf1) + tilemap_mark_all_tiles_dirty(state->fg_tilemap); - if (pf2_bankbase != old_pf2) - tilemap_mark_all_tiles_dirty(bg_tilemap); + if (state->pf2_bankbase != state->old_pf2) + tilemap_mark_all_tiles_dirty(state->bg_tilemap); - old_pf1 = pf1_bankbase; - old_pf2 = pf2_bankbase; + state->old_pf1 = state->pf1_bankbase; + state->old_pf2 = state->pf2_bankbase; - tilemap_set_scrolly(bg_tilemap,0,ctrl_2_2); - tilemap_set_scrollx(bg_tilemap,0,((ctrl_2_1<<8)+ctrl_2_0)); - tilemap_set_scrolly(fg_tilemap,0,ctrl_1_2); - tilemap_set_scrollx(fg_tilemap,0,((ctrl_1_1<<8)+ctrl_1_0)); + tilemap_set_scrolly(state->bg_tilemap, 0, ctrl_2_2); + tilemap_set_scrollx(state->bg_tilemap, 0, ((ctrl_2_1 << 8) + ctrl_2_0)); + tilemap_set_scrolly(state->fg_tilemap, 0, ctrl_1_2); + tilemap_set_scrollx(state->fg_tilemap, 0, ((ctrl_1_1 << 8) + ctrl_1_0)); // /* Sprite priority */ // if (ctrl_1_3 & 0x20) - if ((gfx_bank & 0x04) == 0) + if ((state->gfx_bank & 0x04) == 0) { - tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); - draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram.u8, 0 ); - draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram2.u8, 1 ); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); + draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u8, 0); + draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u8, 1); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); } else { - tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); - draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram.u8, 0 ); - draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram2.u8, 1 ); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); + draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u8, 0); + draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u8, 1); } return 0; } diff --git a/src/mame/video/konicdev.c b/src/mame/video/konicdev.c index a3fae89acdb..593756f7efe 100644 --- a/src/mame/video/konicdev.c +++ b/src/mame/video/konicdev.c @@ -5396,6 +5396,7 @@ struct _k053936_state int wraparound; int offset[2]; + int size; }; /***************************************************************************** @@ -5449,7 +5450,7 @@ READ16_DEVICE_HANDLER( k053936_linectrl_r ) // there is another implementation of this in video/konamigx.c (!) // why? shall they be merged? -void k053936_zoom_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int flags, UINT32 priority, int glfgreat_hack) +void k053936_zoom_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int flags, UINT32 priority, int glfgreat_hack ) { k053936_state *k053936= k053936_get_safe_token(device); if (!tmap) @@ -5497,10 +5498,10 @@ void k053936_zoom_draw( const device_config *device, bitmap_t *bitmap, const rec while (y <= maxy) { - UINT16 *lineaddr = k053936->linectrl + 4 * ((y - k053936->offset[1]) & 0x1ff); + UINT16 *lineaddr = 4 * ((y - k053936->offset[1]) & 0x1ff) + (k053936->linectrl) ? k053936->linectrl : 0; my_clip.min_y = my_clip.max_y = y; - startx = 256 * (INT16)(lineaddr[0] + k053936->ctrl[0x00]); +// startx = 256 * (INT16)(lineaddr[0] + k053936->ctrl[0x00]); starty = 256 * (INT16)(lineaddr[1] + k053936->ctrl[0x01]); incxx = (INT16)(lineaddr[2]); incxy = (INT16)(lineaddr[3]); @@ -5590,14 +5591,35 @@ static DEVICE_START( k053936 ) const k053936_interface *intf = k053936_get_interface(device); k053936->ctrl = auto_alloc_array(device->machine, UINT16, 0x20); - k053936->linectrl = auto_alloc_array(device->machine, UINT16, intf->linectrl_size); // FIXME: should this only be 0x1000? + + if (intf->linectrl_size) + k053936->linectrl = auto_alloc_array(device->machine, UINT16, intf->linectrl_size); // FIXME: should this only be 0x1000? + else + { + /* f1gp.c & crshrace.c seem to have no linectrl ram: is it unmapped or really not present? */ + /* in the meanwhile, we alloc a fake entry to avoid debug to complain for 0-size alloc */ + k053936->linectrl = NULL; + } k053936->wraparound = intf->wrap; k053936->offset[0] = intf->xoff; k053936->offset[1] = intf->yoff; + k053936->size = intf->linectrl_size; + state_save_register_device_item_pointer(device, 0, k053936->ctrl, 0x20); - state_save_register_device_item_pointer(device, 0, k053936->linectrl, intf->linectrl_size); + + if (intf->linectrl_size) + state_save_register_device_item_pointer(device, 0, k053936->linectrl, intf->linectrl_size); +} + +static DEVICE_RESET( k053936 ) +{ + k053936_state *k053936 = k053936_get_safe_token(device); + memset(k053936->ctrl, 0, 0x20); + + if (k053936->linectrl != NULL) + memset(k053936->linectrl, 0, k053936->size); } /***************************************************************************/ @@ -9297,7 +9319,7 @@ DEVICE_GET_INFO( k053936 ) /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k053936); break; case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: /* Nothing */ break; + case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(k053936); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "Konami 053936"); break; diff --git a/src/mame/video/labyrunr.c b/src/mame/video/labyrunr.c index 84bbe2c0ecc..3877ac3e7e5 100644 --- a/src/mame/video/labyrunr.c +++ b/src/mame/video/labyrunr.c @@ -1,10 +1,6 @@ #include "driver.h" #include "video/konicdev.h" - -UINT8 *labyrunr_videoram1,*labyrunr_videoram2,*labyrunr_scrollram; -static tilemap *layer0, *layer1; -static rectangle clip0, clip1; - +#include "includes/labyrunr.h" PALETTE_INIT( labyrunr ) { @@ -44,13 +40,14 @@ PALETTE_INIT( labyrunr ) } -static void set_pens(running_machine *machine) +static void set_pens( running_machine *machine ) { + labyrunr_state *state = (labyrunr_state *)machine->driver_data; int i; for (i = 0x00; i < 0x100; i += 2) { - UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8); + UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8); rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); @@ -68,13 +65,13 @@ static void set_pens(running_machine *machine) static TILE_GET_INFO( get_tile_info0 ) { - const device_config *k007121 = devtag_get_device(machine, "k007121"); - UINT8 ctrl_3 = k007121_ctrlram_r(k007121, 3); - UINT8 ctrl_4 = k007121_ctrlram_r(k007121, 4); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); - int attr = labyrunr_videoram1[tile_index]; - int code = labyrunr_videoram1[tile_index + 0x400]; + labyrunr_state *state = (labyrunr_state *)machine->driver_data; + UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3); + UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4); + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5); + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121, 6); + int attr = state->videoram1[tile_index]; + int code = state->videoram1[tile_index + 0x400]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; @@ -91,20 +88,20 @@ static TILE_GET_INFO( get_tile_info0 ) SET_TILE_INFO( 0, - code+bank*256, + code + bank * 256, ((ctrl_6 & 0x30) * 2 + 16)+(attr & 7), 0); } static TILE_GET_INFO( get_tile_info1 ) { - const device_config *k007121 = devtag_get_device(machine, "k007121"); - UINT8 ctrl_3 = k007121_ctrlram_r(k007121, 3); - UINT8 ctrl_4 = k007121_ctrlram_r(k007121, 4); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); - int attr = labyrunr_videoram2[tile_index]; - int code = labyrunr_videoram2[tile_index + 0x400]; + labyrunr_state *state = (labyrunr_state *)machine->driver_data; + UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3); + UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4); + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5); + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121, 6); + int attr = state->videoram2[tile_index]; + int code = state->videoram2[tile_index + 0x400]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; @@ -135,20 +132,22 @@ static TILE_GET_INFO( get_tile_info1 ) VIDEO_START( labyrunr ) { - layer0 = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,32,32); - layer1 = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,32,32); + labyrunr_state *state = (labyrunr_state *)machine->driver_data; - tilemap_set_transparent_pen(layer0,0); - tilemap_set_transparent_pen(layer1,0); + state->layer0 = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 8, 8, 32, 32); + state->layer1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 8, 8, 32, 32); - clip0 = *video_screen_get_visible_area(machine->primary_screen); - clip0.min_x += 40; + tilemap_set_transparent_pen(state->layer0, 0); + tilemap_set_transparent_pen(state->layer1, 0); - clip1 = *video_screen_get_visible_area(machine->primary_screen); - clip1.max_x = 39; - clip1.min_x = 0; + state->clip0 = *video_screen_get_visible_area(machine->primary_screen); + state->clip0.min_x += 40; - tilemap_set_scroll_cols(layer0,32); + state->clip1 = *video_screen_get_visible_area(machine->primary_screen); + state->clip1.max_x = 39; + state->clip1.min_x = 0; + + tilemap_set_scroll_cols(state->layer0, 32); } @@ -161,14 +160,16 @@ VIDEO_START( labyrunr ) WRITE8_HANDLER( labyrunr_vram1_w ) { - labyrunr_videoram1[offset] = data; - tilemap_mark_tile_dirty(layer0,offset & 0x3ff); + labyrunr_state *state = (labyrunr_state *)space->machine->driver_data; + state->videoram1[offset] = data; + tilemap_mark_tile_dirty(state->layer0, offset & 0x3ff); } WRITE8_HANDLER( labyrunr_vram2_w ) { - labyrunr_videoram2[offset] = data; - tilemap_mark_tile_dirty(layer1,offset & 0x3ff); + labyrunr_state *state = (labyrunr_state *)space->machine->driver_data; + state->videoram2[offset] = data; + tilemap_mark_tile_dirty(state->layer1, offset & 0x3ff); } @@ -181,41 +182,41 @@ WRITE8_HANDLER( labyrunr_vram2_w ) VIDEO_UPDATE( labyrunr ) { - const device_config *k007121 = devtag_get_device(screen->machine, "k007121"); - UINT8 ctrl_0 = k007121_ctrlram_r(k007121, 0); + labyrunr_state *state = (labyrunr_state *)screen->machine->driver_data; + UINT8 ctrl_0 = k007121_ctrlram_r(state->k007121, 0); rectangle finalclip0, finalclip1; set_pens(screen->machine); - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); + bitmap_fill(screen->machine->priority_bitmap, cliprect,0); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); - if(~k007121_ctrlram_r(k007121, 3) & 0x20) + if (~k007121_ctrlram_r(state->k007121, 3) & 0x20) { int i; - finalclip0 = clip0; - finalclip1 = clip1; + finalclip0 = state->clip0; + finalclip1 = state->clip1; sect_rect(&finalclip0, cliprect); sect_rect(&finalclip1, cliprect); - tilemap_set_scrollx(layer0,0,ctrl_0 - 40); - tilemap_set_scrollx(layer1,0,0); + tilemap_set_scrollx(state->layer0, 0, ctrl_0 - 40); + tilemap_set_scrollx(state->layer1, 0, 0); for(i = 0; i < 32; i++) { /* enable colscroll */ - if((k007121_ctrlram_r(k007121, 1) & 6) == 6) // it's probably just one bit, but it's only used once in the game so I don't know which it's - tilemap_set_scrolly(layer0,(i+2) & 0x1f,k007121_ctrlram_r(k007121, 2) + labyrunr_scrollram[i]); + if((k007121_ctrlram_r(state->k007121, 1) & 6) == 6) // it's probably just one bit, but it's only used once in the game so I don't know which it's + tilemap_set_scrolly(state->layer0, (i + 2) & 0x1f, k007121_ctrlram_r(state->k007121, 2) + state->scrollram[i]); else - tilemap_set_scrolly(layer0,(i+2) & 0x1f,k007121_ctrlram_r(k007121, 2)); + tilemap_set_scrolly(state->layer0, (i + 2) & 0x1f, k007121_ctrlram_r(state->k007121, 2)); } - tilemap_draw(bitmap,&finalclip0,layer0,TILEMAP_DRAW_OPAQUE,0); - k007121_sprites_draw(k007121,bitmap,cliprect,screen->machine->gfx[0],screen->machine->colortable,screen->machine->generic.spriteram.u8,(k007121_ctrlram_r(k007121, 6) & 0x30) * 2, 40,0,(k007121_ctrlram_r(k007121, 3) & 0x40) >> 5); + tilemap_draw(bitmap, &finalclip0, state->layer0, TILEMAP_DRAW_OPAQUE, 0); + k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], screen->machine->colortable, state->spriteram,(k007121_ctrlram_r(state->k007121, 6) & 0x30) * 2, 40,0,(k007121_ctrlram_r(state->k007121, 3) & 0x40) >> 5); /* we ignore the transparency because layer1 is drawn only at the top of the screen also covering sprites */ - tilemap_draw(bitmap,&finalclip1,layer1,TILEMAP_DRAW_OPAQUE,0); + tilemap_draw(bitmap, &finalclip1, state->layer1, TILEMAP_DRAW_OPAQUE, 0); } else { @@ -226,7 +227,7 @@ VIDEO_UPDATE( labyrunr ) finalclip0.min_y = finalclip1.min_y = cliprect->min_y; finalclip0.max_y = finalclip1.max_y = cliprect->max_y; - if(k007121_ctrlram_r(k007121, 1) & 1) + if(k007121_ctrlram_r(state->k007121, 1) & 1) { finalclip0.min_x = cliprect->max_x - ctrl_0 + 8; finalclip0.max_x = cliprect->max_x; @@ -272,16 +273,18 @@ VIDEO_UPDATE( labyrunr ) finalclip3.max_x = 40 - ctrl_0 - 8; } - tilemap_set_scrollx(layer0,0,ctrl_0 - 40); - tilemap_set_scrollx(layer1,0,ctrl_0 - 40); + tilemap_set_scrollx(state->layer0, 0, ctrl_0 - 40); + tilemap_set_scrollx(state->layer1, 0, ctrl_0 - 40); - tilemap_draw(bitmap,&finalclip0,layer0,0,1); - if(use_clip3[0]) tilemap_draw(bitmap,&finalclip3,layer0,0,1); + tilemap_draw(bitmap, &finalclip0, state->layer0, 0, 1); + if(use_clip3[0]) + tilemap_draw(bitmap, &finalclip3, state->layer0, 0, 1); - tilemap_draw(bitmap,&finalclip1,layer1,0,1); - if(use_clip3[1]) tilemap_draw(bitmap,&finalclip3,layer1,0,1); + tilemap_draw(bitmap, &finalclip1, state->layer1, 0, 1); + if(use_clip3[1]) + tilemap_draw(bitmap, &finalclip3, state->layer1, 0, 1); - k007121_sprites_draw(k007121,bitmap,cliprect,screen->machine->gfx[0],screen->machine->colortable,screen->machine->generic.spriteram.u8,(k007121_ctrlram_r(k007121, 6) & 0x30) * 2,40,0,(k007121_ctrlram_r(k007121, 3) & 0x40) >> 5); + k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], screen->machine->colortable, state->spriteram, (k007121_ctrlram_r(state->k007121, 6) & 0x30) * 2,40,0,(k007121_ctrlram_r(state->k007121, 3) & 0x40) >> 5); } return 0; } diff --git a/src/mame/video/suprslam.c b/src/mame/video/suprslam.c index 5d2d7bd7057..cabad0e7c38 100644 --- a/src/mame/video/suprslam.c +++ b/src/mame/video/suprslam.c @@ -2,14 +2,11 @@ #include "driver.h" #include "video/konicdev.h" +#include "includes/suprslam.h" -UINT16 *suprslam_screen_videoram, *suprslam_bg_videoram,*suprslam_sp_videoram, *suprslam_spriteram; -static UINT16 screen_bank, bg_bank; -static tilemap *suprslam_screen_tilemap, *suprslam_bg_tilemap; - -/* todo, fix zooming correctly, its _not_ like aerofgt */ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) +/* todo, fix zooming correctly, it's _not_ like aerofgt */ +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { /* SPRITE INFO @@ -33,13 +30,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta */ - + suprslam_state *state = (suprslam_state *)machine->driver_data; const gfx_element *gfx = machine->gfx[1]; - UINT16 *source = suprslam_spriteram; - UINT16 *source2 = suprslam_spriteram; + UINT16 *source = state->spriteram; + UINT16 *source2 = state->spriteram; UINT16 *finish = source + 0x2000/2; - while( source> 9; - int yzoom = (source2[sprnum+0] & 0xf000) >> 12; + int ypos = source2[sprnum + 0] & 0x1ff; + int high = (source2[sprnum + 0] & 0x0e00) >> 9; + int yzoom = (source2[sprnum + 0] & 0xf000) >> 12; - int xpos = source2[sprnum+1] & 0x1ff; - int wide = (source2[sprnum+1] & 0x0e00) >> 9; - int xzoom = (source2[sprnum+1] & 0xf000) >> 12; + int xpos = source2[sprnum + 1] & 0x1ff; + int wide = (source2[sprnum + 1] & 0x0e00) >> 9; + int xzoom = (source2[sprnum + 1] & 0xf000) >> 12; - int col = (source2[sprnum+2] & 0x3f00) >> 8; - int flipx = (source2[sprnum+2] & 0x4000) >> 14; -// int flipy = (source2[sprnum+2] & 0x8000) >> 15; + int col = (source2[sprnum + 2] & 0x3f00) >> 8; + int flipx = (source2[sprnum + 2] & 0x4000) >> 14; +// int flipy = (source2[sprnum + 2] & 0x8000) >> 15; - int word_offset = source2[sprnum+3] & 0x7fff; + int word_offset = source2[sprnum + 3] & 0x7fff; int xcnt, ycnt; int loopno = 0; @@ -71,17 +68,23 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta if (ypos > 0xff) ypos -=0x200; - for (ycnt = 0; ycnt < high+1; ycnt ++) { - if (!flipx) { - for (xcnt = 0; xcnt < wide+1; xcnt ++) { - int tileno = suprslam_sp_videoram[word_offset+loopno]; + for (ycnt = 0; ycnt < high+1; ycnt ++) + { + if (!flipx) + { + for (xcnt = 0; xcnt < wide+1; xcnt ++) + { + int tileno = state->sp_videoram[word_offset + loopno]; drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 0, 0,xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15); drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 0, 0,-0x200+xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15); loopno ++; } - } else { - for (xcnt = wide; xcnt >= 0; xcnt --) { - int tileno = suprslam_sp_videoram[word_offset+loopno]; + } + else + { + for (xcnt = wide; xcnt >= 0; xcnt --) + { + int tileno = state->sp_videoram[word_offset + loopno]; drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 1, 0,xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15); drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 1, 0,-0x200+xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15); loopno ++; @@ -96,75 +99,82 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta WRITE16_HANDLER( suprslam_screen_videoram_w ) { - suprslam_screen_videoram[offset] = data; - tilemap_mark_tile_dirty(suprslam_screen_tilemap,offset); + suprslam_state *state = (suprslam_state *)space->machine->driver_data; + + state->screen_videoram[offset] = data; + tilemap_mark_tile_dirty(state->screen_tilemap, offset); } static TILE_GET_INFO( get_suprslam_tile_info ) { - int tileno, colour; + suprslam_state *state = (suprslam_state *)machine->driver_data; + int tileno = state->screen_videoram[tile_index] & 0x0fff; + int colour = state->screen_videoram[tile_index] & 0xf000; - tileno = suprslam_screen_videoram[tile_index] & 0x0fff; - colour = suprslam_screen_videoram[tile_index] & 0xf000; - - tileno += screen_bank; + tileno += state->screen_bank; colour = colour >> 12; - SET_TILE_INFO(0,tileno,colour,0); + SET_TILE_INFO(0, tileno, colour, 0); } /* BG LAYER */ WRITE16_HANDLER( suprslam_bg_videoram_w ) { - suprslam_bg_videoram[offset] = data; - tilemap_mark_tile_dirty(suprslam_bg_tilemap,offset); + suprslam_state *state = (suprslam_state *)space->machine->driver_data; + + state->bg_videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset); } static TILE_GET_INFO( get_suprslam_bg_tile_info ) { - int tileno, colour; + suprslam_state *state = (suprslam_state *)machine->driver_data; + int tileno = state->bg_videoram[tile_index] & 0x0fff; + int colour = state->bg_videoram[tile_index] & 0xf000; - tileno = suprslam_bg_videoram[tile_index] & 0x0fff; - colour = suprslam_bg_videoram[tile_index] & 0xf000; - - tileno += bg_bank; + tileno += state->bg_bank; colour = colour >> 12; - SET_TILE_INFO(2,tileno,colour,0); + SET_TILE_INFO(2, tileno, colour, 0); } VIDEO_START( suprslam ) { - suprslam_bg_tilemap = tilemap_create(machine, get_suprslam_bg_tile_info,tilemap_scan_rows, 16, 16,64,64); - suprslam_screen_tilemap = tilemap_create(machine, get_suprslam_tile_info,tilemap_scan_rows, 8, 8,64,32); + suprslam_state *state = (suprslam_state *)machine->driver_data; - tilemap_set_transparent_pen(suprslam_screen_tilemap,15); + state->bg_tilemap = tilemap_create(machine, get_suprslam_bg_tile_info, tilemap_scan_rows, 16, 16, 64, 64); + state->screen_tilemap = tilemap_create(machine, get_suprslam_tile_info, tilemap_scan_rows, 8, 8, 64, 32); + + tilemap_set_transparent_pen(state->screen_tilemap, 15); } VIDEO_UPDATE( suprslam ) { - const device_config *k053936 = devtag_get_device(screen->machine, "k053936"); + suprslam_state *state = (suprslam_state *)screen->machine->driver_data; - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); - k053936_zoom_draw(k053936, bitmap,cliprect,suprslam_bg_tilemap,0,0,1); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); + k053936_zoom_draw(state->k053936, bitmap, cliprect, state->bg_tilemap, 0, 0, 1); draw_sprites(screen->machine, bitmap, cliprect); - tilemap_draw(bitmap,cliprect,suprslam_screen_tilemap,0,0); + tilemap_draw(bitmap, cliprect, state->screen_tilemap, 0, 0); return 0; } WRITE16_HANDLER (suprslam_bank_w) { + suprslam_state *state = (suprslam_state *)space->machine->driver_data; UINT16 old_screen_bank, old_bg_bank; - old_screen_bank = screen_bank; - old_bg_bank = bg_bank; + old_screen_bank = state->screen_bank; + old_bg_bank = state->bg_bank; - screen_bank = data & 0xf000; - bg_bank = (data & 0x0f00) << 4; + state->screen_bank = data & 0xf000; + state->bg_bank = (data & 0x0f00) << 4; - if (screen_bank != old_screen_bank) tilemap_mark_all_tiles_dirty (suprslam_screen_tilemap); - if (bg_bank != old_bg_bank) tilemap_mark_all_tiles_dirty (suprslam_bg_tilemap); + if (state->screen_bank != old_screen_bank) + tilemap_mark_all_tiles_dirty(state->screen_tilemap); + if (state->bg_bank != old_bg_bank) + tilemap_mark_all_tiles_dirty(state->bg_tilemap); }