diff options
author | 2011-03-25 16:05:24 +0000 | |
---|---|---|
committer | 2011-03-25 16:05:24 +0000 | |
commit | e9fc65db486e87fcd44bbb298cf957843a027359 (patch) | |
tree | 1d2c7a86a1efc96923d5e5c8533469d47280ab54 /src | |
parent | 0989f6fe05af001d8cd0788fa42ea0ac9e237311 (diff) |
Convert cclimber/galpani2/gticlub/namcond1/pacman/seibuspi/tetrisp2/vicdual
to driver_device. [Atari Ace]
Last commit should have been:
Removed globals from a number of device-like shared systems and made them
either statics or actual device variables. [Atari Ace]
Diffstat (limited to 'src')
26 files changed, 1342 insertions, 1158 deletions
diff --git a/src/mame/drivers/cclimber.c b/src/mame/drivers/cclimber.c index 4a4c61a033d..b33cbac74e2 100644 --- a/src/mame/drivers/cclimber.c +++ b/src/mame/drivers/cclimber.c @@ -213,10 +213,6 @@ Dip location verified from manual for: cclimber, guzzler, swimmer #define MASTER_CLOCK XTAL_18_432MHz -static UINT8 yamato_p0; -static UINT8 yamato_p1; -static UINT8 toprollr_rombank; - static WRITE8_HANDLER( swimmer_sh_soundlatch_w ) { @@ -227,32 +223,37 @@ static WRITE8_HANDLER( swimmer_sh_soundlatch_w ) static WRITE8_HANDLER( yamato_p0_w ) { - yamato_p0 = data; + cclimber_state *state = space->machine->driver_data<cclimber_state>(); + state->yamato_p0 = data; } static WRITE8_HANDLER( yamato_p1_w ) { - yamato_p1 = data; + cclimber_state *state = space->machine->driver_data<cclimber_state>(); + state->yamato_p1 = data; } static READ8_HANDLER( yamato_p0_r ) { - return yamato_p0; + cclimber_state *state = space->machine->driver_data<cclimber_state>(); + return state->yamato_p0; } static READ8_HANDLER( yamato_p1_r ) { - return yamato_p1; + cclimber_state *state = space->machine->driver_data<cclimber_state>(); + return state->yamato_p1; } static WRITE8_HANDLER(toprollr_rombank_w) { - toprollr_rombank &= ~(1 << offset); - toprollr_rombank |= (data & 1) << offset; + cclimber_state *state = space->machine->driver_data<cclimber_state>(); + state->toprollr_rombank &= ~(1 << offset); + state->toprollr_rombank |= (data & 1) << offset; - if (toprollr_rombank < 3) - memory_set_bank(space->machine, "bank1", toprollr_rombank); + if (state->toprollr_rombank < 3) + memory_set_bank(space->machine, "bank1", state->toprollr_rombank); } @@ -264,13 +265,14 @@ static TIMER_CALLBACK( disable_interrupts ) static MACHINE_RESET( cclimber ) { + cclimber_state *state = machine->driver_data<cclimber_state>(); /* Disable interrupts, River Patrol / Silver Land needs this */ /* we must do this on a timer in order to have it take effect */ /* otherwise, the reset process will override our changes */ machine->scheduler().synchronize(FUNC(disable_interrupts)); - toprollr_rombank = 0; + state->toprollr_rombank = 0; } @@ -282,18 +284,18 @@ static ADDRESS_MAP_START( cclimber_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROM AM_RANGE(0x6000, 0x6bff) AM_RAM /* Crazy Kong only */ AM_RANGE(0x8000, 0x83ff) AM_RAM - AM_RANGE(0x8800, 0x88ff) AM_RAM AM_BASE(&cclimber_bigsprite_videoram) + AM_RANGE(0x8800, 0x88ff) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_videoram) AM_RANGE(0x8900, 0x8bff) AM_RAM /* not used, but initialized */ - AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&cclimber_videoram) + AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(cclimber_state, videoram) /* 9800-9bff and 9c00-9fff share the same RAM, interleaved */ /* (9800-981f for scroll, 9c20-9c3f for color RAM, and so on) */ - AM_RANGE(0x9800, 0x981f) AM_RAM AM_BASE(&cclimber_column_scroll) - AM_RANGE(0x9880, 0x989f) AM_RAM AM_BASE(&cclimber_spriteram) - AM_RANGE(0x98dc, 0x98df) AM_RAM AM_BASE(&cclimber_bigsprite_control) + AM_RANGE(0x9800, 0x981f) AM_RAM AM_BASE_MEMBER(cclimber_state, column_scroll) + AM_RANGE(0x9880, 0x989f) AM_RAM AM_BASE_MEMBER(cclimber_state, spriteram) + AM_RANGE(0x98dc, 0x98df) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_control) AM_RANGE(0x9800, 0x9bff) AM_RAM /* not used, but initialized */ - AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE(&cclimber_colorram) + AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE_MEMBER(cclimber_state, colorram) AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(interrupt_enable_w) - AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE(&cclimber_flip_screen) + AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, flip_screen) AM_RANGE(0xa003, 0xa003) AM_WRITE(interrupt_enable_w) //used by Crazy Kong Bootleg with alt levels and speed up AM_RANGE(0xa004, 0xa004) AM_WRITE(cclimber_sample_trigger_w) AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P2") AM_WRITE(cclimber_sample_rate_w) @@ -306,18 +308,18 @@ static ADDRESS_MAP_START( cannonb_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROM AM_RANGE(0x6000, 0x6bff) AM_RAM AM_RANGE(0x8000, 0x83ff) AM_RAM - AM_RANGE(0x8800, 0x88ff) AM_READNOP AM_WRITEONLY AM_BASE(&cclimber_bigsprite_videoram) /* must not return what's written (game will reset after coin insert if it returns 0xff)*/ + AM_RANGE(0x8800, 0x88ff) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, bigsprite_videoram) /* must not return what's written (game will reset after coin insert if it returns 0xff)*/ // AM_RANGE(0x8900, 0x8bff) AM_WRITEONLY /* not used, but initialized */ - AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&cclimber_videoram) + AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(cclimber_state, videoram) /* 9800-9bff and 9c00-9fff share the same RAM, interleaved */ /* (9800-981f for scroll, 9c20-9c3f for color RAM, and so on) */ - AM_RANGE(0x9800, 0x981f) AM_RAM AM_BASE(&cclimber_column_scroll) - AM_RANGE(0x9880, 0x989f) AM_RAM AM_BASE(&cclimber_spriteram) - AM_RANGE(0x98dc, 0x98df) AM_RAM AM_BASE(&cclimber_bigsprite_control) + AM_RANGE(0x9800, 0x981f) AM_RAM AM_BASE_MEMBER(cclimber_state, column_scroll) + AM_RANGE(0x9880, 0x989f) AM_RAM AM_BASE_MEMBER(cclimber_state, spriteram) + AM_RANGE(0x98dc, 0x98df) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_control) AM_RANGE(0x9800, 0x9bff) AM_RAM /* not used, but initialized */ - AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE(&cclimber_colorram) + AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE_MEMBER(cclimber_state, colorram) AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(interrupt_enable_w) - AM_RANGE(0xa001, 0xa002) AM_WRITE(cannonb_flip_screen_w) AM_BASE(&cclimber_flip_screen) + AM_RANGE(0xa001, 0xa002) AM_WRITE(cannonb_flip_screen_w) AM_BASE_MEMBER(cclimber_state, flip_screen) AM_RANGE(0xa004, 0xa004) AM_WRITE(cclimber_sample_trigger_w) AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P2") AM_WRITE(cclimber_sample_rate_w) AM_RANGE(0xb000, 0xb000) AM_READ_PORT("DSW") AM_WRITE(cclimber_sample_volume_w) @@ -327,19 +329,19 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( swimmer_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x87ff) AM_RAM - AM_RANGE(0x8800, 0x88ff) AM_MIRROR(0x0100) AM_RAM AM_BASE(&cclimber_bigsprite_videoram) - AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&cclimber_videoram) - AM_RANGE(0x9800, 0x981f) AM_WRITEONLY AM_BASE(&cclimber_column_scroll) - AM_RANGE(0x9880, 0x989f) AM_WRITEONLY AM_BASE(&cclimber_spriteram) - AM_RANGE(0x98fc, 0x98ff) AM_WRITEONLY AM_BASE(&cclimber_bigsprite_control) - AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE(&cclimber_colorram) + AM_RANGE(0x8800, 0x88ff) AM_MIRROR(0x0100) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_videoram) + AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(cclimber_state, videoram) + AM_RANGE(0x9800, 0x981f) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, column_scroll) + AM_RANGE(0x9880, 0x989f) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, spriteram) + AM_RANGE(0x98fc, 0x98ff) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, bigsprite_control) + AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE_MEMBER(cclimber_state, colorram) AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P2") AM_WRITE(interrupt_enable_w) - AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE(&cclimber_flip_screen) - AM_RANGE(0xa003, 0xa003) AM_WRITEONLY AM_BASE(&swimmer_side_background_enabled) - AM_RANGE(0xa004, 0xa004) AM_WRITEONLY AM_BASE(&swimmer_palettebank) + AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, flip_screen) + AM_RANGE(0xa003, 0xa003) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, swimmer_side_background_enabled) + AM_RANGE(0xa004, 0xa004) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, swimmer_palettebank) AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P1") AM_WRITE(swimmer_sh_soundlatch_w) AM_RANGE(0xb000, 0xb000) AM_READ_PORT("DSW1") - AM_RANGE(0xb800, 0xb800) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE(&swimmer_background_color) + AM_RANGE(0xb800, 0xb800) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, swimmer_background_color) AM_RANGE(0xb880, 0xb880) AM_READ_PORT("SYSTEM") AM_RANGE(0xc000, 0xc7ff) AM_RAM /* ??? used by Guzzler */ AM_RANGE(0xe000, 0xffff) AM_ROM /* Guzzler only */ @@ -349,18 +351,18 @@ static ADDRESS_MAP_START( yamato_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROM AM_RANGE(0x6000, 0x6fff) AM_RAM AM_RANGE(0x7000, 0x7fff) AM_ROM - AM_RANGE(0x8800, 0x88ff) AM_RAM AM_BASE(&cclimber_bigsprite_videoram) + AM_RANGE(0x8800, 0x88ff) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_videoram) AM_RANGE(0x8900, 0x8bff) AM_RAM /* not used, but initialized */ - AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&cclimber_videoram) + AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(cclimber_state, videoram) /* 9800-9bff and 9c00-9fff share the same RAM, interleaved */ /* (9800-981f for scroll, 9c20-9c3f for color RAM, and so on) */ - AM_RANGE(0x9800, 0x981f) AM_RAM AM_BASE(&cclimber_column_scroll) - AM_RANGE(0x9880, 0x989f) AM_RAM AM_BASE(&cclimber_spriteram) - AM_RANGE(0x98dc, 0x98df) AM_RAM AM_BASE(&cclimber_bigsprite_control) + AM_RANGE(0x9800, 0x981f) AM_RAM AM_BASE_MEMBER(cclimber_state, column_scroll) + AM_RANGE(0x9880, 0x989f) AM_RAM AM_BASE_MEMBER(cclimber_state, spriteram) + AM_RANGE(0x98dc, 0x98df) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_control) AM_RANGE(0x9800, 0x9bff) AM_RAM /* not used, but initialized */ - AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE(&cclimber_colorram) + AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(cclimber_colorram_w) AM_BASE_MEMBER(cclimber_state, colorram) AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(interrupt_enable_w) - AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE(&cclimber_flip_screen) + AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, flip_screen) AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P2") AM_RANGE(0xb000, 0xb000) AM_READ_PORT("DSW") AM_RANGE(0xb800, 0xb800) AM_READ_PORT("COIN") @@ -370,16 +372,16 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( toprollr_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROMBANK("bank1") AM_RANGE(0x6000, 0x6bff) AM_RAM - AM_RANGE(0x8800, 0x88ff) AM_RAM AM_BASE(&cclimber_bigsprite_videoram) - AM_RANGE(0x8c00, 0x8fff) AM_RAM AM_BASE(&toprollr_bg_videoram) - AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE(&cclimber_videoram) - AM_RANGE(0x9400, 0x97ff) AM_RAM AM_BASE(&toprollr_bg_coloram) + AM_RANGE(0x8800, 0x88ff) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_videoram) + AM_RANGE(0x8c00, 0x8fff) AM_RAM AM_BASE_MEMBER(cclimber_state, toprollr_bg_videoram) + AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE_MEMBER(cclimber_state, videoram) + AM_RANGE(0x9400, 0x97ff) AM_RAM AM_BASE_MEMBER(cclimber_state, toprollr_bg_coloram) AM_RANGE(0x9800, 0x987f) AM_RAM /* unused ? */ - AM_RANGE(0x9880, 0x995f) AM_RAM AM_BASE(&cclimber_spriteram) - AM_RANGE(0x99dc, 0x99df) AM_RAM AM_BASE(&cclimber_bigsprite_control) - AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE(&cclimber_colorram) + AM_RANGE(0x9880, 0x995f) AM_RAM AM_BASE_MEMBER(cclimber_state, spriteram) + AM_RANGE(0x99dc, 0x99df) AM_RAM AM_BASE_MEMBER(cclimber_state, bigsprite_control) + AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE_MEMBER(cclimber_state, colorram) AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(interrupt_enable_w) - AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE(&cclimber_flip_screen) + AM_RANGE(0xa001, 0xa002) AM_WRITEONLY AM_BASE_MEMBER(cclimber_state, flip_screen) AM_RANGE(0xa004, 0xa004) AM_WRITE(cclimber_sample_trigger_w) AM_RANGE(0xa005, 0xa006) AM_WRITE(toprollr_rombank_w) AM_RANGE(0xa800, 0xa800) AM_READ_PORT("P2") AM_WRITE(cclimber_sample_rate_w) @@ -982,7 +984,7 @@ GFXDECODE_END -static MACHINE_CONFIG_START( root, driver_device ) +static MACHINE_CONFIG_START( root, cclimber_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK/3/2) /* 3.072 MHz */ @@ -1080,7 +1082,7 @@ static MACHINE_CONFIG_DERIVED( toprollr, cclimber ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( swimmer, driver_device ) +static MACHINE_CONFIG_START( swimmer, cclimber_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, XTAL_18_432MHz/6) /* verified on pcb */ diff --git a/src/mame/drivers/galpani2.c b/src/mame/drivers/galpani2.c index ea111c751fa..1450c1ba9e3 100644 --- a/src/mame/drivers/galpani2.c +++ b/src/mame/drivers/galpani2.c @@ -35,15 +35,16 @@ To Do: ***************************************************************************/ -static UINT16 eeprom_word; static READ16_DEVICE_HANDLER(galpani2_eeprom_r) { - return (eeprom_word & ~1) | (eeprom_read_bit(device) & 1); + galpani2_state *state = device->machine->driver_data<galpani2_state>(); + return (state->eeprom_word & ~1) | (eeprom_read_bit(device) & 1); } static WRITE16_DEVICE_HANDLER(galpani2_eeprom_w) { - COMBINE_DATA( &eeprom_word ); + galpani2_state *state = device->machine->driver_data<galpani2_state>(); + COMBINE_DATA( &state->eeprom_word ); if ( ACCESSING_BITS_0_7 ) { // latch the bit @@ -68,7 +69,6 @@ static WRITE16_DEVICE_HANDLER(galpani2_eeprom_w) ***************************************************************************/ -static UINT16 *galpani2_ram, *galpani2_ram2; static MACHINE_RESET( galpani2 ) { @@ -236,22 +236,22 @@ static void galpani2_mcu_nmi2(running_machine *machine) static WRITE8_HANDLER( galpani2_mcu_nmi1_w ) //driven by CPU1's int5 ISR { + galpani2_state *state = space->machine->driver_data<galpani2_state>(); //for galpan2t: //Triggered from 'maincpu' (00007D60),once, with no command, using alternate line, during init //Triggered from 'maincpu' (000080BE),once, for unknown command, during init //Triggered from 'maincpu' (0000741E),from here on...driven by int5, even if there's no command - static UINT16 old_mcu_nmi1 = 0; - if ( (data & 1) && !(old_mcu_nmi1 & 1) ) galpani2_mcu_nmi1(space->machine); - //if ( (data & 0x10) && !(old_mcu_nmi1 & 0x10) ) galpani2_mcu_nmi1(space->machine); + if ( (data & 1) && !(state->old_mcu_nmi1 & 1) ) galpani2_mcu_nmi1(space->machine); + //if ( (data & 0x10) && !(state->old_mcu_nmi1 & 0x10) ) galpani2_mcu_nmi1(space->machine); //alternate line, same function? - old_mcu_nmi1 = data; + state->old_mcu_nmi1 = data; } static WRITE8_HANDLER( galpani2_mcu_nmi2_w ) //driven by CPU2's int5 ISR { - static UINT16 old_mcu_nmi2 = 0; - if ( (data & 1) && !(old_mcu_nmi2 & 1) ) galpani2_mcu_nmi2(space->machine); - old_mcu_nmi2 = data; + galpani2_state *state = space->machine->driver_data<galpani2_state>(); + if ( (data & 1) && !(state->old_mcu_nmi2 & 1) ) galpani2_mcu_nmi2(space->machine); + state->old_mcu_nmi2 = data; } @@ -276,41 +276,41 @@ static WRITE8_HANDLER( galpani2_coin_lockout_w ) static WRITE8_DEVICE_HANDLER( galpani2_oki1_bank_w ) { - UINT8 *ROM = device->machine->region("oki1")->base(); - logerror("%s : %s bank %08X\n",device->machine->describe_context(),device->tag(),data); - memcpy(ROM + 0x30000, ROM + 0x40000 + 0x10000 * (~data & 0xf), 0x10000); + UINT8 *ROM = device->machine->region("oki1")->base(); + logerror("%s : %s bank %08X\n",device->machine->describe_context(),device->tag(),data); + memcpy(ROM + 0x30000, ROM + 0x40000 + 0x10000 * (~data & 0xf), 0x10000); } static WRITE8_DEVICE_HANDLER( galpani2_oki2_bank_w ) { - okim6295_device *oki = downcast<okim6295_device *>(device); - oki->set_bank_base(0x40000 * (data & 0xf) ); - logerror("%s : %s bank %08X\n",device->machine->describe_context(),device->tag(),data); + okim6295_device *oki = downcast<okim6295_device *>(device); + oki->set_bank_base(0x40000 * (data & 0xf) ); + logerror("%s : %s bank %08X\n",device->machine->describe_context(),device->tag(),data); } static ADDRESS_MAP_START( galpani2_mem1, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM // ROM - AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&galpani2_ram ) // Work RAM + AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE_MEMBER(galpani2_state, ram) // Work RAM AM_RANGE(0x110000, 0x11000f) AM_RAM // ? corrupted? stack dumper on POST failure, pc+sr on gp2se AM_RANGE(0x300000, 0x301fff) AM_RAM // ? AM_RANGE(0x302000, 0x303fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites AM_RANGE(0x304000, 0x30401f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs ) // Sprites Regs AM_RANGE(0x308000, 0x308001) AM_WRITENOP // ? 0 at startup AM_RANGE(0x30c000, 0x30c001) AM_WRITENOP // ? hblank effect ? - AM_RANGE(0x310000, 0x3101ff) AM_RAM_WRITE(galpani2_palette_0_w) AM_BASE(&galpani2_palette_0 ) // ? + AM_RANGE(0x310000, 0x3101ff) AM_RAM_WRITE(galpani2_palette_0_w) AM_BASE_MEMBER(galpani2_state, palette_0) // ? AM_RANGE(0x314000, 0x314001) AM_WRITENOP // ? flip backgrounds ? AM_RANGE(0x318000, 0x318001) AM_DEVREADWRITE("eeprom", galpani2_eeprom_r, galpani2_eeprom_w) // EEPROM AM_RANGE(0x380000, 0x387fff) AM_RAM // Palette? AM_RANGE(0x388000, 0x38ffff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram ) // Palette AM_RANGE(0x390000, 0x3901ff) AM_WRITENOP // ? at startup of service mode - AM_RANGE(0x400000, 0x43ffff) AM_RAM_WRITE(galpani2_bg8_0_w) AM_BASE(&galpani2_bg8_0 ) // Background 0 - AM_RANGE(0x440000, 0x440001) AM_RAM AM_BASE(&galpani2_bg8_0_scrollx ) // Background 0 Scroll X - AM_RANGE(0x480000, 0x480001) AM_RAM AM_BASE(&galpani2_bg8_0_scrolly ) // Background 0 Scroll Y + AM_RANGE(0x400000, 0x43ffff) AM_RAM_WRITE(galpani2_bg8_0_w) AM_BASE_MEMBER(galpani2_state, bg8_0) // Background 0 + AM_RANGE(0x440000, 0x440001) AM_RAM AM_BASE_MEMBER(galpani2_state, bg8_0_scrollx) // Background 0 Scroll X + AM_RANGE(0x480000, 0x480001) AM_RAM AM_BASE_MEMBER(galpani2_state, bg8_0_scrolly) // Background 0 Scroll Y AM_RANGE(0x4c0000, 0x4c0001) AM_WRITENOP // ? 0 at startup only - AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(galpani2_bg8_1_w) AM_BASE(&galpani2_bg8_1 ) // Background 1 - AM_RANGE(0x540000, 0x540001) AM_RAM AM_BASE(&galpani2_bg8_1_scrollx ) // Background 1 Scroll X + AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(galpani2_bg8_1_w) AM_BASE_MEMBER(galpani2_state, bg8_1) // Background 1 + AM_RANGE(0x540000, 0x540001) AM_RAM AM_BASE_MEMBER(galpani2_state, bg8_1_scrollx) // Background 1 Scroll X AM_RANGE(0x540572, 0x540573) AM_READNOP // ? galpani2 at F0A4 AM_RANGE(0x54057a, 0x54057b) AM_READNOP // ? galpani2 at F148 @@ -322,7 +322,7 @@ static ADDRESS_MAP_START( galpani2_mem1, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x5405c2, 0x5405c3) AM_READNOP // ? galpani2 at F0A4 and F148 AM_RANGE(0x5405ca, 0x5405cb) AM_READNOP // ? galpani2 at F148 - AM_RANGE(0x580000, 0x580001) AM_RAM AM_BASE(&galpani2_bg8_1_scrolly ) // Background 1 Scroll Y + AM_RANGE(0x580000, 0x580001) AM_RAM AM_BASE_MEMBER(galpani2_state, bg8_1_scrolly) // Background 1 Scroll Y AM_RANGE(0x5c0000, 0x5c0001) AM_WRITENOP // ? 0 at startup only AM_RANGE(0x600000, 0x600001) AM_WRITENOP // Watchdog AM_RANGE(0x640000, 0x640001) AM_WRITE8(galpani2_mcu_init_w, 0x00ff ) // ? 0 before resetting and at startup, Reset mcu ? @@ -347,14 +347,14 @@ ADDRESS_MAP_END ***************************************************************************/ -static UINT16 *galpani2_rombank; static READ16_HANDLER( galpani2_bankedrom_r ) { + galpani2_state *state = space->machine->driver_data<galpani2_state>(); UINT16 *ROM = (UINT16 *) space->machine->region( "user1" )->base(); size_t len = space->machine->region( "user1" )->bytes() / 2; - offset += (0x800000/2) * (*galpani2_rombank & 0x0003); + offset += (0x800000/2) * (*state->rombank & 0x0003); if ( offset < len ) return ROM[offset]; else return 0xffff; //floating bus for absent ROMs @@ -362,8 +362,8 @@ static READ16_HANDLER( galpani2_bankedrom_r ) static ADDRESS_MAP_START( galpani2_mem2, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM // ROM - AM_RANGE(0x100000, 0x13ffff) AM_RAM AM_BASE(&galpani2_ram2) // Work RAM - AM_RANGE(0x400000, 0x4fffff) AM_RAM_WRITE(galpani2_bg15_w) AM_BASE(&galpani2_bg15) // bg15 + AM_RANGE(0x100000, 0x13ffff) AM_RAM AM_BASE_MEMBER(galpani2_state, ram2) // Work RAM + AM_RANGE(0x400000, 0x4fffff) AM_RAM_WRITE(galpani2_bg15_w) AM_BASE_MEMBER(galpani2_state, bg15) // bg15 AM_RANGE(0x500000, 0x5fffff) AM_RAM // bg15 AM_RANGE(0x600000, 0x600001) AM_NOP // ? 0 at startup only AM_RANGE(0x640000, 0x640001) AM_WRITENOP // ? 0 at startup only @@ -372,7 +372,7 @@ static ADDRESS_MAP_START( galpani2_mem2, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x700000, 0x700001) AM_WRITENOP // Watchdog // AM_RANGE(0x740000, 0x740001) AM_WRITENOP // ? Reset mcu AM_RANGE(0x780000, 0x780001) AM_WRITE8(galpani2_mcu_nmi2_w, 0x00ff) // ? 0 -> 1 -> 0 (lev 5) - AM_RANGE(0x7c0000, 0x7c0001) AM_WRITEONLY AM_BASE(&galpani2_rombank ) // Rom Bank + AM_RANGE(0x7c0000, 0x7c0001) AM_WRITEONLY AM_BASE_MEMBER(galpani2_state, rombank) // Rom Bank AM_RANGE(0x800000, 0xffffff) AM_READ(galpani2_bankedrom_r ) // Banked ROM ADDRESS_MAP_END @@ -575,7 +575,7 @@ static INTERRUPT_GEN( galpani2_interrupt2 ) } } -static MACHINE_CONFIG_START( galpani2, driver_device ) +static MACHINE_CONFIG_START( galpani2, galpani2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_27MHz/2) /* Confirmed on galpani2i PCB */ diff --git a/src/mame/drivers/gticlub.c b/src/mame/drivers/gticlub.c index ebbe3a707ab..5c7a2dee6fb 100644 --- a/src/mame/drivers/gticlub.c +++ b/src/mame/drivers/gticlub.c @@ -235,7 +235,16 @@ Hang Pilot (uses an unknown but similar video board) 12W #include "rendlay.h" -static UINT32 *work_ram; +class gticlub_state : public driver_device +{ +public: + gticlub_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT32 *work_ram; + UINT32 *sharc_dataram_0; + UINT32 *sharc_dataram_1; +}; static WRITE32_HANDLER( paletteram32_w ) @@ -382,15 +391,17 @@ static WRITE8_HANDLER( sysreg_w ) static MACHINE_START( gticlub ) { + gticlub_state *state = machine->driver_data<gticlub_state>(); + /* set conservative DRC options */ ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS); /* configure fast RAM regions for DRC */ - ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x000fffff, FALSE, work_ram); + ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x000fffff, FALSE, state->work_ram); } static ADDRESS_MAP_START( gticlub_map, ADDRESS_SPACE_PROGRAM, 32 ) - AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_BASE(&work_ram) /* Work RAM */ + AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_BASE_MEMBER(gticlub_state, work_ram) /* Work RAM */ AM_RANGE(0x74000000, 0x740000ff) AM_READWRITE(gticlub_k001604_reg_r, gticlub_k001604_reg_w) AM_RANGE(0x74010000, 0x7401ffff) AM_RAM_WRITE(paletteram32_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x74020000, 0x7403ffff) AM_READWRITE(gticlub_k001604_tile_r, gticlub_k001604_tile_w) @@ -423,27 +434,28 @@ ADDRESS_MAP_END /*****************************************************************************/ -static UINT32 *sharc_dataram_0; -static UINT32 *sharc_dataram_1; - static READ32_HANDLER( dsp_dataram0_r ) { - return sharc_dataram_0[offset] & 0xffff; + gticlub_state *state = space->machine->driver_data<gticlub_state>(); + return state->sharc_dataram_0[offset] & 0xffff; } static WRITE32_HANDLER( dsp_dataram0_w ) { - sharc_dataram_0[offset] = data; + gticlub_state *state = space->machine->driver_data<gticlub_state>(); + state->sharc_dataram_0[offset] = data; } static READ32_HANDLER( dsp_dataram1_r ) { - return sharc_dataram_1[offset] & 0xffff; + gticlub_state *state = space->machine->driver_data<gticlub_state>(); + return state->sharc_dataram_1[offset] & 0xffff; } static WRITE32_HANDLER( dsp_dataram1_w ) { - sharc_dataram_1[offset] = data; + gticlub_state *state = space->machine->driver_data<gticlub_state>(); + state->sharc_dataram_1[offset] = data; } static ADDRESS_MAP_START( sharc_map, ADDRESS_SPACE_DATA, 32 ) @@ -776,7 +788,7 @@ static MACHINE_RESET( gticlub ) cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE); } -static MACHINE_CONFIG_START( gticlub, driver_device ) +static MACHINE_CONFIG_START( gticlub, gticlub_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */ @@ -859,7 +871,7 @@ static MACHINE_RESET( hangplt ) cputag_set_input_line(machine, "dsp2", INPUT_LINE_RESET, ASSERT_LINE); } -static MACHINE_CONFIG_START( hangplt, driver_device ) +static MACHINE_CONFIG_START( hangplt, gticlub_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */ @@ -1140,21 +1152,25 @@ ROM_END static DRIVER_INIT(gticlub) { + gticlub_state *state = machine->driver_data<gticlub_state>(); + init_konami_cgboard(machine, 1, CGBOARD_TYPE_GTICLUB); - sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4); + state->sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4); K001005_preprocess_texture_data(machine->region("gfx1")->base(), machine->region("gfx1")->bytes(), 1); } static DRIVER_INIT(hangplt) { + gticlub_state *state = machine->driver_data<gticlub_state>(); + init_konami_cgboard(machine, 2, CGBOARD_TYPE_HANGPLT); set_cgboard_texture_bank(machine, 0, "bank5", machine->region("user5")->base()); set_cgboard_texture_bank(machine, 1, "bank6", machine->region("user5")->base()); - sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4); - sharc_dataram_1 = auto_alloc_array(machine, UINT32, 0x100000/4); + state->sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4); + state->sharc_dataram_1 = auto_alloc_array(machine, UINT32, 0x100000/4); } /*************************************************************************/ diff --git a/src/mame/drivers/jrpacman.c b/src/mame/drivers/jrpacman.c index 36d0286a3ef..611b4bdc33d 100644 --- a/src/mame/drivers/jrpacman.c +++ b/src/mame/drivers/jrpacman.c @@ -104,11 +104,11 @@ #include "sound/namco.h" -class jrpacman_state : public driver_device +class jrpacman_state : public pacman_state { public: jrpacman_state(running_machine &machine, const driver_device_config_base &config) - : driver_device(machine, config) { } + : pacman_state(machine, config) { } UINT8 *spriteram; UINT8 *spriteram2; @@ -133,7 +133,7 @@ static WRITE8_HANDLER( jrpacman_interrupt_vector_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM - AM_RANGE(0x4000, 0x47ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE(&pacman_videoram) + AM_RANGE(0x4000, 0x47ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE_MEMBER(jrpacman_state, videoram) AM_RANGE(0x4800, 0x4fef) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_RAM AM_BASE_SIZE_MEMBER(jrpacman_state, spriteram, spriteram_size) AM_RANGE(0x5000, 0x503f) AM_READ_PORT("P1") @@ -228,12 +228,12 @@ INPUT_PORTS_END static const gfx_layout tilelayout = { 8,8, - RGN_FRAC(1,2), - 2, - { 0, 4 }, - { STEP4(8*8,1), STEP4(0*8,1) }, - { STEP8(0*8,8) }, - 16*8 + RGN_FRAC(1,2), + 2, + { 0, 4 }, + { STEP4(8*8,1), STEP4(0*8,1) }, + { STEP8(0*8,8) }, + 16*8 }; diff --git a/src/mame/drivers/namcond1.c b/src/mame/drivers/namcond1.c index 02f35af0d7b..b49c6a3054e 100644 --- a/src/mame/drivers/namcond1.c +++ b/src/mame/drivers/namcond1.c @@ -77,7 +77,7 @@ Notes: static ADDRESS_MAP_START( namcond1_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0x400000, 0x40ffff) AM_READWRITE(namcond1_shared_ram_r,namcond1_shared_ram_w) AM_BASE(&namcond1_shared_ram) + AM_RANGE(0x400000, 0x40ffff) AM_READWRITE(namcond1_shared_ram_r,namcond1_shared_ram_w) AM_BASE_MEMBER(namcond1_state, shared_ram) AM_RANGE(0x800000, 0x80000f) AM_READWRITE(ygv608_r,ygv608_w) AM_RANGE(0xa00000, 0xa00fff) AM_DEVREADWRITE8("at28c16", at28c16_r, at28c16_w, 0xff00) #ifdef MAME_DEBUG @@ -222,15 +222,16 @@ GFXDECODE_END static WRITE16_HANDLER( sharedram_sub_w ) { - COMBINE_DATA(&namcond1_shared_ram[offset]); + namcond1_state *state = space->machine->driver_data<namcond1_state>(); + COMBINE_DATA(&state->shared_ram[offset]); } static READ16_HANDLER( sharedram_sub_r ) { - return namcond1_shared_ram[offset]; + namcond1_state *state = space->machine->driver_data<namcond1_state>(); + return state->shared_ram[offset]; } -static int p8; static READ8_HANDLER( mcu_p7_read ) { @@ -244,7 +245,8 @@ static READ8_HANDLER( mcu_pa_read ) static WRITE8_HANDLER( mcu_pa_write ) { - p8 = data; + namcond1_state *state = space->machine->driver_data<namcond1_state>(); + state->p8 = data; } /* H8/3002 MCU stuff */ @@ -267,10 +269,11 @@ ADDRESS_MAP_END static INTERRUPT_GEN( mcu_interrupt ) { - if( namcond1_h8_irq5_enabled ) - { - generic_pulse_irq_line(device, H8_IRQ5); - } + namcond1_state *state = device->machine->driver_data<namcond1_state>(); + if( state->h8_irq5_enabled ) + { + generic_pulse_irq_line(device, H8_IRQ5); + } } /****************************************** @@ -281,7 +284,7 @@ static INTERRUPT_GEN( mcu_interrupt ) - The level 1 interrupt to the 68k has been measured at 60Hz. *******************************************/ -static MACHINE_CONFIG_START( namcond1, driver_device ) +static MACHINE_CONFIG_START( namcond1, namcond1_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 12288000) diff --git a/src/mame/drivers/pacman.c b/src/mame/drivers/pacman.c index ecc62b6a48b..acb9d3e8f0a 100644 --- a/src/mame/drivers/pacman.c +++ b/src/mame/drivers/pacman.c @@ -366,9 +366,6 @@ Boards: #define VBSTART (224) /*(224+16)*/ -static UINT8 cannonb_bit_to_read; - - /************************************* * * Machine init @@ -546,11 +543,11 @@ static READ8_HANDLER( alibaba_mystery_1_r ) static READ8_HANDLER( alibaba_mystery_2_r ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); /* The single bit return value determines when the mystery is lit up. This is certainly wrong */ - static int mystery = 0; - mystery++; - return (mystery >> 10) & 1; + state->mystery++; + return (state->mystery >> 10) & 1; } @@ -654,8 +651,8 @@ static READ8_HANDLER( korosuke_special_port3_r ) static READ8_HANDLER( mschamp_kludge_r ) { - static UINT8 counter; - return counter++; + pacman_state *state = space->machine->driver_data<pacman_state>(); + return state->counter++; } /************************************ @@ -664,20 +661,21 @@ static READ8_HANDLER( mschamp_kludge_r ) * ************************************/ -static int bigbucks_bank = 0; static WRITE8_HANDLER( bigbucks_bank_w ) { - bigbucks_bank = data; + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->bigbucks_bank = data; } static READ8_HANDLER( bigbucks_question_r ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); UINT8 *question = space->machine->region("user1")->base(); UINT8 ret; - ret = question[(bigbucks_bank << 16) | (offset ^ 0xffff)]; + ret = question[(state->bigbucks_bank << 16) | (offset ^ 0xffff)]; return ret; } @@ -745,43 +743,49 @@ static READ8_HANDLER( porky_port1_r ) * ************************************/ -static UINT8 *rocktrv2_prot_data, rocktrv2_question_bank = 0; static READ8_HANDLER( rocktrv2_prot1_data_r ) { - return rocktrv2_prot_data[0] >> 4; + pacman_state *state = space->machine->driver_data<pacman_state>(); + return state->rocktrv2_prot_data[0] >> 4; } static READ8_HANDLER( rocktrv2_prot2_data_r ) { - return rocktrv2_prot_data[1] >> 4; + pacman_state *state = space->machine->driver_data<pacman_state>(); + return state->rocktrv2_prot_data[1] >> 4; } static READ8_HANDLER( rocktrv2_prot3_data_r ) { - return rocktrv2_prot_data[2] >> 4; + pacman_state *state = space->machine->driver_data<pacman_state>(); + return state->rocktrv2_prot_data[2] >> 4; } static READ8_HANDLER( rocktrv2_prot4_data_r ) { - return rocktrv2_prot_data[3] >> 4; + pacman_state *state = space->machine->driver_data<pacman_state>(); + return state->rocktrv2_prot_data[3] >> 4; } static WRITE8_HANDLER( rocktrv2_prot_data_w ) { - rocktrv2_prot_data[offset] = data; + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->rocktrv2_prot_data[offset] = data; } static WRITE8_HANDLER( rocktrv2_question_bank_w ) { - rocktrv2_question_bank = data; + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->rocktrv2_question_bank = data; } static READ8_HANDLER( rocktrv2_question_r ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); UINT8 *question = space->machine->region("user1")->base(); - return question[offset | (rocktrv2_question_bank * 0x8000)]; + return question[offset | (state->rocktrv2_question_bank * 0x8000)]; } @@ -892,8 +896,8 @@ static WRITE8_HANDLER( mspacman_enable_decode_w ) { mspacman_enable_deco static ADDRESS_MAP_START( pacman_map, ADDRESS_SPACE_PROGRAM, 8 ) //A lot of games don't have an a15 at the cpu. Generally only games with a cpu daughter board can access the full 32k of romspace. AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x8000) AM_ROM - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) @@ -919,8 +923,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( mspacman_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) @@ -959,8 +963,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( woodpek_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) @@ -986,8 +990,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( alibaba_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP AM_RANGE(0x4c00, 0x4eef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ef0, 0x4eff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) @@ -1018,8 +1022,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( dremshpr_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4fef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x5000, 0x5000) AM_MIRROR(0xaf38) AM_WRITE(interrupt_enable_w) @@ -1048,8 +1052,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( epos_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x8000) AM_ROMBANK("bank1") - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) @@ -1074,11 +1078,11 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( s2650games_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x0fff) AM_MIRROR(0x8000) AM_ROMBANK("bank1") - AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0xe000) AM_WRITE(s2650games_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0xe000) AM_WRITE(s2650games_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x1400, 0x141f) AM_MIRROR(0xe000) AM_WRITE(s2650games_scroll_w) AM_RANGE(0x1420, 0x148f) AM_MIRROR(0xe000) AM_WRITEONLY - AM_RANGE(0x1490, 0x149f) AM_MIRROR(0xe000) AM_WRITEONLY AM_BASE(&s2650games_spriteram) - AM_RANGE(0x14a0, 0x14bf) AM_MIRROR(0xe000) AM_WRITE(s2650games_tilesbank_w) AM_BASE(&s2650games_tileram) + AM_RANGE(0x1490, 0x149f) AM_MIRROR(0xe000) AM_WRITEONLY AM_BASE_MEMBER(pacman_state, s2650games_spriteram) + AM_RANGE(0x14a0, 0x14bf) AM_MIRROR(0xe000) AM_WRITE(s2650games_tilesbank_w) AM_BASE_MEMBER(pacman_state, s2650games_tileram) AM_RANGE(0x14c0, 0x14ff) AM_MIRROR(0xe000) AM_WRITEONLY AM_RANGE(0x1500, 0x1502) AM_MIRROR(0xe000) AM_WRITENOP AM_RANGE(0x1503, 0x1503) AM_MIRROR(0xe000) AM_WRITE(pacman_flipscreen_w) @@ -1093,7 +1097,7 @@ static ADDRESS_MAP_START( s2650games_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x1500, 0x1500) AM_MIRROR(0xe000) AM_READ_PORT("IN0") AM_RANGE(0x1540, 0x1540) AM_MIRROR(0xe000) AM_READ_PORT("IN1") AM_RANGE(0x1580, 0x1580) AM_MIRROR(0xe000) AM_READ_PORT("DSW0") - AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0xe000) AM_WRITE(s2650games_videoram_w) AM_BASE(&pacman_videoram) + AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0xe000) AM_WRITE(s2650games_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) AM_RANGE(0x1c00, 0x1fef) AM_MIRROR(0xe000) AM_RAM AM_RANGE(0x1ff0, 0x1fff) AM_MIRROR(0xe000) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x2000, 0x2fff) AM_MIRROR(0x8000) AM_ROMBANK("bank2") @@ -1104,8 +1108,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( rocktrv2_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM - AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4c00, 0x4fff) AM_RAM AM_RANGE(0x5000, 0x5000) AM_WRITE(interrupt_enable_w) AM_RANGE(0x5001, 0x5001) AM_DEVWRITE("namco", pacman_sound_enable_w) @@ -1113,7 +1117,7 @@ static ADDRESS_MAP_START( rocktrv2_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x5007, 0x5007) AM_WRITE(pacman_coin_counter_w) AM_RANGE(0x5040, 0x505f) AM_DEVWRITE("namco", pacman_sound_w) AM_RANGE(0x50c0, 0x50c0) AM_WRITE(watchdog_reset_w) - AM_RANGE(0x5fe0, 0x5fe3) AM_WRITE(rocktrv2_prot_data_w) AM_BASE(&rocktrv2_prot_data) + AM_RANGE(0x5fe0, 0x5fe3) AM_WRITE(rocktrv2_prot_data_w) AM_BASE_MEMBER(pacman_state, rocktrv2_prot_data) AM_RANGE(0x5ff0, 0x5ff0) AM_WRITE(rocktrv2_question_bank_w) AM_RANGE(0x5000, 0x5000) AM_READ_PORT("IN0") /* IN0 */ AM_RANGE(0x5040, 0x507f) AM_READ_PORT("IN1") /* IN1 */ @@ -1131,8 +1135,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( bigbucks_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM - AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4c00, 0x4fff) AM_RAM AM_RANGE(0x5000, 0x5000) AM_WRITE(interrupt_enable_w) AM_RANGE(0x5001, 0x5001) AM_DEVWRITE("namco", pacman_sound_enable_w) @@ -1152,8 +1156,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( mschamp_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROMBANK("bank1") - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) @@ -1179,8 +1183,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( crushs_map, ADDRESS_SPACE_PROGRAM, 8 ) //A lot of games don't have an a15 at the cpu. Generally only games with a cpu daughter board can access the full 32k of romspace. AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x8000) AM_ROM - AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) - AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pacman_state, videoram) + AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pacman_state, colorram) AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) @@ -3137,7 +3141,7 @@ static const namco_interface namco_config = * *************************************/ -static MACHINE_CONFIG_START( pacman, driver_device ) +static MACHINE_CONFIG_START( pacman, pacman_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) @@ -5656,6 +5660,7 @@ static DRIVER_INIT( mspacmbe ) static READ8_HANDLER( cannonbp_protection_r ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); /* At 6p where a rom would usually be there is an epoxy resin chip with 'Novomatic Industrie' Cannon Ball tm 1984 label. */ /* As I have no clue about what shall be in this chip, what follows is only a simulation which is enough to play the game. */ @@ -5682,11 +5687,11 @@ static READ8_HANDLER( cannonbp_protection_r ) 2BA3: 00 nop */ case 0x0004: - cannonb_bit_to_read = 7; + state->cannonb_bit_to_read = 7; return 0x00; case 0x0001: // affects the ball hitting the blocks as well as jump address after bonus round if (cpu_get_pc(space->cpu) == 0x2b97) - return (BIT(0x46, cannonb_bit_to_read--) << 7); + return (BIT(0x46, state->cannonb_bit_to_read--) << 7); else return 0xff; /* value taken from the bootlegs */ diff --git a/src/mame/drivers/pengo.c b/src/mame/drivers/pengo.c index f8e464cffe0..676261bc49c 100644 --- a/src/mame/drivers/pengo.c +++ b/src/mame/drivers/pengo.c @@ -68,11 +68,11 @@ #include "sound/namco.h" -class pengo_state : public driver_device +class pengo_state : public pacman_state { public: pengo_state(running_machine &machine, const driver_device_config_base &config) - : driver_device(machine, config) { } + : pacman_state(machine, config) { } UINT8 *spriteram; UINT8 *spriteram2; @@ -111,8 +111,8 @@ public: static ADDRESS_MAP_START( pengo_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) /* video and color RAM, scratchpad RAM, sprite codes */ - AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram) + AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_MEMBER(pengo_state, videoram) /* video and color RAM, scratchpad RAM, sprite codes */ + AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_MEMBER(pengo_state, colorram) AM_RANGE(0x8800, 0x8fef) AM_RAM AM_RANGE(0x8ff0, 0x8fff) AM_RAM AM_BASE_SIZE_MEMBER(pengo_state, spriteram, spriteram_size) AM_RANGE(0x9000, 0x901f) AM_DEVWRITE("namco", pacman_sound_w) @@ -134,7 +134,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( jrpacmbl_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE(&pacman_videoram) + AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE_MEMBER(pengo_state, videoram) AM_RANGE(0x8800, 0x8fef) AM_RAM AM_RANGE(0x8ff0, 0x8fff) AM_RAM AM_BASE_SIZE_MEMBER(pengo_state, spriteram, spriteram_size) AM_RANGE(0x9000, 0x901f) AM_DEVWRITE("namco", pacman_sound_w) diff --git a/src/mame/drivers/seibuspi.c b/src/mame/drivers/seibuspi.c index d2adbf630c1..d721a586c68 100644 --- a/src/mame/drivers/seibuspi.c +++ b/src/mame/drivers/seibuspi.c @@ -739,45 +739,25 @@ Notes: #include "machine/seibuspi.h" #include "includes/seibuspi.h" -UINT32 *spimainram; - -static intel_e28f008sa_device *flash[2]; - -static UINT8 *z80_rom; - /********************************************************************/ -static int z80_prg_fifo_pos = 0; -static int z80_lastbank; - -#define FIFO_SIZE 512 -static int fifoin_rpos, fifoin_wpos; -static UINT8 fifoin_data[FIFO_SIZE]; -static int fifoin_read_request = 0; - -static int fifoout_rpos, fifoout_wpos; -static UINT8 fifoout_data[FIFO_SIZE]; -static int fifoout_read_request = 0; - -static UINT8 sb_coin_latch = 0; - -static UINT8 ejsakura_input_port = 0; static UINT8 z80_fifoout_pop(address_space *space) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); UINT8 r; - if (fifoout_wpos == fifoout_rpos) + if (state->fifoout_wpos == state->fifoout_rpos) { logerror("Sound FIFOOUT underflow at %08X\n", cpu_get_pc(space->cpu)); } - r = fifoout_data[fifoout_rpos++]; - if(fifoout_rpos == FIFO_SIZE) + r = state->fifoout_data[state->fifoout_rpos++]; + if(state->fifoout_rpos == FIFO_SIZE) { - fifoout_rpos = 0; + state->fifoout_rpos = 0; } - if (fifoout_wpos == fifoout_rpos) + if (state->fifoout_wpos == state->fifoout_rpos) { - fifoout_read_request = 0; + state->fifoout_read_request = 0; } return r; @@ -785,35 +765,37 @@ static UINT8 z80_fifoout_pop(address_space *space) static void z80_fifoout_push(address_space *space, UINT8 data) { - fifoout_data[fifoout_wpos++] = data; - if (fifoout_wpos == FIFO_SIZE) + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + state->fifoout_data[state->fifoout_wpos++] = data; + if (state->fifoout_wpos == FIFO_SIZE) { - fifoout_wpos = 0; + state->fifoout_wpos = 0; } - if(fifoout_wpos == fifoout_rpos) + if(state->fifoout_wpos == state->fifoout_rpos) { fatalerror("Sound FIFOOUT overflow at %08X", cpu_get_pc(space->cpu)); } - fifoout_read_request = 1; + state->fifoout_read_request = 1; } static UINT8 z80_fifoin_pop(address_space *space) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); UINT8 r; - if (fifoin_wpos == fifoin_rpos) + if (state->fifoin_wpos == state->fifoin_rpos) { fatalerror("Sound FIFOIN underflow at %08X", cpu_get_pc(space->cpu)); } - r = fifoin_data[fifoin_rpos++]; - if(fifoin_rpos == FIFO_SIZE) + r = state->fifoin_data[state->fifoin_rpos++]; + if(state->fifoin_rpos == FIFO_SIZE) { - fifoin_rpos = 0; + state->fifoin_rpos = 0; } - if (fifoin_wpos == fifoin_rpos) + if (state->fifoin_wpos == state->fifoin_rpos) { - fifoin_read_request = 0; + state->fifoin_read_request = 0; } return r; @@ -821,33 +803,36 @@ static UINT8 z80_fifoin_pop(address_space *space) static void z80_fifoin_push(address_space *space, UINT8 data) { - fifoin_data[fifoin_wpos++] = data; - if(fifoin_wpos == FIFO_SIZE) + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + state->fifoin_data[state->fifoin_wpos++] = data; + if(state->fifoin_wpos == FIFO_SIZE) { - fifoin_wpos = 0; + state->fifoin_wpos = 0; } - if(fifoin_wpos == fifoin_rpos) + if(state->fifoin_wpos == state->fifoin_rpos) { fatalerror("Sound FIFOIN overflow at %08X", cpu_get_pc(space->cpu)); } - fifoin_read_request = 1; + state->fifoin_read_request = 1; } static READ32_HANDLER( sb_coin_r ) { - UINT8 r = sb_coin_latch; + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + UINT8 r = state->sb_coin_latch; - sb_coin_latch = 0; + state->sb_coin_latch = 0; return r; } static WRITE8_HANDLER( sb_coin_w ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); if (data) - sb_coin_latch = 0xa0 | data; + state->sb_coin_latch = 0xa0 | data; else - sb_coin_latch = 0; + state->sb_coin_latch = 0; } static READ32_HANDLER( sound_fifo_r ) @@ -866,8 +851,9 @@ static WRITE32_HANDLER( sound_fifo_w ) static READ32_HANDLER( sound_fifo_status_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); UINT32 r = 0; - if (fifoout_read_request) + if (state->fifoout_read_request) { r |= 2; } @@ -891,7 +877,7 @@ static WRITE32_DEVICE_HANDLER( eeprom_w ) // tile banks if( ACCESSING_BITS_16_23 ) { - rf2_set_layer_banks(data >> 16); + rf2_set_layer_banks(device->machine, data >> 16); eeprom_write_bit(device, (data & 0x800000) ? 1 : 0); eeprom_set_clock_line(device, (data & 0x400000) ? ASSERT_LINE : CLEAR_LINE); eeprom_set_cs_line(device, (data & 0x200000) ? CLEAR_LINE : ASSERT_LINE); @@ -904,23 +890,25 @@ static WRITE32_DEVICE_HANDLER( eeprom_w ) static WRITE32_HANDLER( z80_prg_fifo_w ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); if( ACCESSING_BITS_0_7 ) { - if (z80_prg_fifo_pos<0x40000) z80_rom[z80_prg_fifo_pos] = data & 0xff; - z80_prg_fifo_pos++; + if (state->z80_prg_fifo_pos<0x40000) state->z80_rom[state->z80_prg_fifo_pos] = data & 0xff; + state->z80_prg_fifo_pos++; } } static WRITE32_HANDLER( z80_enable_w ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); // tile banks if( ACCESSING_BITS_16_23 ) { - rf2_set_layer_banks(data >> 16); + rf2_set_layer_banks(space->machine, data >> 16); } logerror("z80 data = %08x mask = %08x\n",data,mem_mask); if( ACCESSING_BITS_0_7 ) { if( data & 0x1 ) { - z80_prg_fifo_pos = 0; + state->z80_prg_fifo_pos = 0; cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, CLEAR_LINE ); } else { cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, ASSERT_LINE ); @@ -948,7 +936,8 @@ static READ32_HANDLER( spi_controls2_r ) static CUSTOM_INPUT( ejsakura_keyboard_r ) { - switch(ejsakura_input_port) + seibuspi_state *state = field->port->machine->driver_data<seibuspi_state>(); + switch(state->ejsakura_input_port) { case 0x01: return input_port_read(field->port->machine, "INPUT01"); @@ -981,8 +970,9 @@ static WRITE8_HANDLER( z80_soundfifo_w ) static READ8_HANDLER( z80_soundfifo_status_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); UINT8 r = 0; - if (fifoin_read_request) + if (state->fifoin_read_request) { r |= 2; } @@ -991,10 +981,11 @@ static READ8_HANDLER( z80_soundfifo_status_r ) static WRITE8_HANDLER( z80_bank_w ) { - if ((data & 7) != z80_lastbank) + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + if ((data & 7) != state->z80_lastbank) { - z80_lastbank = (data & 7); - memory_set_bankptr(space->machine, "bank4", z80_rom + (0x8000 * z80_lastbank)); + state->z80_lastbank = (data & 7); + memory_set_bankptr(space->machine, "bank4", state->z80_rom + (0x8000 * state->z80_lastbank)); } } @@ -1044,7 +1035,7 @@ static ADDRESS_MAP_START( spi_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000418, 0x0000041b) AM_READWRITE(spi_layer_bank_r, spi_layer_bank_w) AM_RANGE(0x0000041c, 0x0000041f) AM_READNOP AM_RANGE(0x0000041c, 0x0000041f) AM_WRITE(spi_layer_enable_w) - AM_RANGE(0x00000420, 0x0000042b) AM_RAM AM_BASE(&spi_scrollram) + AM_RANGE(0x00000420, 0x0000042b) AM_RAM AM_BASE_MEMBER(seibuspi_state, spi_scrollram) AM_RANGE(0x00000480, 0x00000483) AM_WRITE(tilemap_dma_start_w) AM_RANGE(0x00000484, 0x00000487) AM_WRITE(palette_dma_start_w) AM_RANGE(0x00000490, 0x00000493) AM_WRITE(video_dma_length_w) @@ -1062,7 +1053,7 @@ static ADDRESS_MAP_START( spi_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000006d4, 0x000006d7) AM_DEVWRITE8("ds2404", ds2404_data_w, 0x000000ff) AM_RANGE(0x000006d8, 0x000006db) AM_DEVWRITE8("ds2404", ds2404_clk_w, 0x000000ff) AM_RANGE(0x000006dc, 0x000006df) AM_DEVREAD8("ds2404", ds2404_data_r, 0x000000ff) - AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE(&spimainram) + AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE_MEMBER(seibuspi_state, spimainram) AM_RANGE(0x00200000, 0x003fffff) AM_ROM AM_SHARE("share2") AM_RANGE(0x00a00000, 0x013fffff) AM_READ(soundrom_r) AM_RANGE(0xffe00000, 0xffffffff) AM_ROM AM_REGION("user1", 0) AM_SHARE("share2") /* ROM location in real-mode */ @@ -1085,28 +1076,30 @@ ADDRESS_MAP_END static READ8_DEVICE_HANDLER( flashrom_read ) { + seibuspi_state *state = device->machine->driver_data<seibuspi_state>(); logerror("Flash Read: %08X\n", offset); if( offset < 0x100000 ) { - return flash[0]->read(offset); + return state->flash[0]->read(offset); } else if( offset < 0x200000 ) { - return flash[1]->read(offset - 0x100000 ); + return state->flash[1]->read(offset - 0x100000 ); } return 0; } static WRITE8_DEVICE_HANDLER( flashrom_write ) { + seibuspi_state *state = device->machine->driver_data<seibuspi_state>(); logerror("Flash Write: %08X, %02X\n", offset, data); if( offset < 0x100000 ) { - flash[0]->write(offset + 1, data); + state->flash[0]->write(offset + 1, data); } else if( offset < 0x200000 ) { - flash[1]->write(offset - 0x100000 + 1, data); + state->flash[1]->write(offset - 0x100000 + 1, data); } } @@ -1139,7 +1132,7 @@ static ADDRESS_MAP_START( seibu386_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000418, 0x0000041b) AM_READWRITE(spi_layer_bank_r, spi_layer_bank_w) AM_RANGE(0x0000041c, 0x0000041f) AM_READNOP AM_RANGE(0x0000041c, 0x0000041f) AM_WRITE(spi_layer_enable_w) - AM_RANGE(0x00000420, 0x0000042b) AM_RAM AM_BASE(&spi_scrollram) + AM_RANGE(0x00000420, 0x0000042b) AM_RAM AM_BASE_MEMBER(seibuspi_state, spi_scrollram) AM_RANGE(0x00000480, 0x00000483) AM_WRITE(tilemap_dma_start_w) AM_RANGE(0x00000484, 0x00000487) AM_WRITE(palette_dma_start_w) AM_RANGE(0x00000490, 0x00000493) AM_WRITE(video_dma_length_w) @@ -1150,7 +1143,7 @@ static ADDRESS_MAP_START( seibu386_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000608, 0x0000060b) AM_READ(spi_unknown_r) AM_RANGE(0x0000060c, 0x0000060f) AM_READ(spi_controls2_r) /* Player controls (start) */ AM_RANGE(0x0000068c, 0x0000068f) AM_DEVWRITE("eeprom", eeprom_w) - AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE(&spimainram) + AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE_MEMBER(seibuspi_state, spimainram) AM_RANGE(0x00200000, 0x003fffff) AM_ROM AM_SHARE("share2") AM_RANGE(0x01200000, 0x01200003) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x000000ff) AM_RANGE(0x01200004, 0x01200007) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x000000ff) @@ -1159,7 +1152,8 @@ ADDRESS_MAP_END static WRITE32_HANDLER(input_select_w) { - ejsakura_input_port = data; + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + state->ejsakura_input_port = data; } static ADDRESS_MAP_START( sys386f2_map, ADDRESS_SPACE_PROGRAM, 32 ) @@ -1177,7 +1171,7 @@ static ADDRESS_MAP_START( sys386f2_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000600, 0x00000607) AM_DEVREAD8("ymz", ymz280b_r, 0x000000ff) AM_RANGE(0x00000608, 0x0000060b) AM_READ(spi_unknown_r) AM_RANGE(0x0000060c, 0x0000060f) AM_READ(spi_controls1_r) /* Player controls */ - AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE(&spimainram) + AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE_MEMBER(seibuspi_state, spimainram) AM_RANGE(0x00200000, 0x003fffff) AM_ROM AM_SHARE("share2") AM_RANGE(0xffe00000, 0xffffffff) AM_ROM AM_REGION("user1", 0) AM_SHARE("share2") /* ROM location in real-mode */ ADDRESS_MAP_END @@ -1816,11 +1810,13 @@ static IRQ_CALLBACK(spi_irq_callback) static MACHINE_START( spi ) { - z80_rom = auto_alloc_array(machine, UINT8, 0x40000); + seibuspi_state *state = machine->driver_data<seibuspi_state>(); + state->z80_rom = auto_alloc_array(machine, UINT8, 0x40000); } static MACHINE_RESET( spi ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int i; UINT8 *sound = machine->region("ymf")->base(); @@ -1834,28 +1830,28 @@ static MACHINE_RESET( spi ) memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00000688, 0x0000068b, 0, 0, z80_prg_fifo_w); memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000068c, 0x0000068f, 0, 0, z80_enable_w); - memory_set_bankptr(machine, "bank4", z80_rom); - memory_set_bankptr(machine, "bank5", z80_rom); + memory_set_bankptr(machine, "bank4", state->z80_rom); + memory_set_bankptr(machine, "bank5", state->z80_rom); /* If the first value doesn't match, the game shows a checksum error */ /* If any of the other values are wrong, the game goes to update mode */ - flash[0]->write(0, 0xff); - flash[0]->write(0, 0x10); - flash[0]->write(0, flash_data); /* country code */ + state->flash[0]->write(0, 0xff); + state->flash[0]->write(0, 0x10); + state->flash[0]->write(0, flash_data); /* country code */ for (i=0; i < 0x100000; i++) { - flash[0]->write(0, 0xff); - sound[i] = flash[0]->read(i); + state->flash[0]->write(0, 0xff); + sound[i] = state->flash[0]->read(i); } for (i=0; i < 0x100000; i++) { - flash[1]->write(0, 0xff); - sound[0x100000+i] = flash[1]->read(i); + state->flash[1]->write(0, 0xff); + sound[0x100000+i] = state->flash[1]->read(i); } } -static MACHINE_CONFIG_START( spi, driver_device ) +static MACHINE_CONFIG_START( spi, seibuspi_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", I386, 50000000/2) /* Intel 386DX, 25MHz */ @@ -1901,24 +1897,26 @@ MACHINE_CONFIG_END static MACHINE_START( sxx2f ) { - z80_rom = auto_alloc_array(machine, UINT8, 0x40000); + seibuspi_state *state = machine->driver_data<seibuspi_state>(); + state->z80_rom = auto_alloc_array(machine, UINT8, 0x40000); } static MACHINE_RESET( sxx2f ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); UINT8 *rom = machine->region("soundcpu")->base(); - memory_set_bankptr(machine, "bank4", z80_rom); - memory_set_bankptr(machine, "bank5", z80_rom); + memory_set_bankptr(machine, "bank4", state->z80_rom); + memory_set_bankptr(machine, "bank5", state->z80_rom); - memcpy(z80_rom, rom, 0x40000); + memcpy(state->z80_rom, rom, 0x40000); memory_install_write32_device_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), machine->device("eeprom"), 0x0000068c, 0x0000068f, 0, 0, eeprom_w); memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00000680, 0x00000683, 0, 0, sb_coin_r); cpu_set_irq_callback(machine->device("maincpu"), spi_irq_callback); - sb_coin_latch = 0; + state->sb_coin_latch = 0; } static MACHINE_CONFIG_DERIVED( sxx2f, spi ) /* Intel i386DX @ 25MHz, YMF271 @ 16.9344MHz, Z80 @ 7.159MHz(?) */ @@ -1955,18 +1953,21 @@ MACHINE_CONFIG_END static READ32_HANDLER ( senkyu_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); if (cpu_get_pc(space->cpu)==0x00305bb2) cpu_spinuntil_int(space->cpu); // idle - return spimainram[(0x0018cb4-0x800)/4]; + return state->spimainram[(0x0018cb4-0x800)/4]; } static READ32_HANDLER( senkyua_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); if (cpu_get_pc(space->cpu)== 0x30582e) cpu_spinuntil_int(space->cpu); // idle - return spimainram[(0x0018c9c-0x800)/4]; + return state->spimainram[(0x0018c9c-0x800)/4]; } static READ32_HANDLER ( batlball_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); // printf("cpu_get_pc(space->cpu) %06x\n", cpu_get_pc(space->cpu)); /* batlbalu */ @@ -1975,11 +1976,12 @@ static READ32_HANDLER ( batlball_speedup_r ) /* batlball */ if (cpu_get_pc(space->cpu)==0x003058aa) cpu_spinuntil_int(space->cpu); // idle - return spimainram[(0x0018db4-0x800)/4]; + return state->spimainram[(0x0018db4-0x800)/4]; } static READ32_HANDLER ( rdft_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); /* rdft */ if (cpu_get_pc(space->cpu)==0x0203f0a) cpu_spinuntil_int(space->cpu); // idle @@ -1997,11 +1999,12 @@ static READ32_HANDLER ( rdft_speedup_r ) // mame_printf_debug("%08x\n",cpu_get_pc(space->cpu)); - return spimainram[(0x00298d0-0x800)/4]; + return state->spimainram[(0x00298d0-0x800)/4]; } static READ32_HANDLER ( viprp1_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); /* viprp1 */ if (cpu_get_pc(space->cpu)==0x0202769) cpu_spinuntil_int(space->cpu); // idle @@ -2013,29 +2016,32 @@ static READ32_HANDLER ( viprp1_speedup_r ) // mame_printf_debug("%08x\n",cpu_get_pc(space->cpu)); - return spimainram[(0x001e2e0-0x800)/4]; + return state->spimainram[(0x001e2e0-0x800)/4]; } static READ32_HANDLER ( viprp1o_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); /* viperp1o */ if (cpu_get_pc(space->cpu)==0x0201f99) cpu_spinuntil_int(space->cpu); // idle // mame_printf_debug("%08x\n",cpu_get_pc(space->cpu)); - return spimainram[(0x001d49c-0x800)/4]; + return state->spimainram[(0x001d49c-0x800)/4]; } #ifdef UNUSED_FUNCTION // causes input problems? READ32_HANDLER ( ejanhs_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); // mame_printf_debug("%08x\n",cpu_get_pc(space->cpu)); if (cpu_get_pc(space->cpu)==0x03032c7) cpu_spinuntil_int(space->cpu); // idle - return spimainram[(0x002d224-0x800)/4]; + return state->spimainram[(0x002d224-0x800)/4]; } #endif static READ32_HANDLER ( rf2_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); /* rdft22kc */ if (cpu_get_pc(space->cpu)==0x0203926) cpu_spinuntil_int(space->cpu); // idle @@ -2051,11 +2057,12 @@ static READ32_HANDLER ( rf2_speedup_r ) // mame_printf_debug("%08x\n",cpu_get_pc(space->cpu)); - return spimainram[(0x0282AC-0x800)/4]; + return state->spimainram[(0x0282AC-0x800)/4]; } static READ32_HANDLER ( rfjet_speedup_r ) { + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); /* rfjet, rfjetu, rfjeta */ if (cpu_get_pc(space->cpu)==0x0206082) cpu_spinuntil_int(space->cpu); // idle @@ -2065,7 +2072,7 @@ static READ32_HANDLER ( rfjet_speedup_r ) UINT32 r; cpu_spinuntil_int(space->cpu); // idle // Hack to enter test mode - r = spimainram[(0x002894c-0x800)/4] & (~0x400); + r = state->spimainram[(0x002894c-0x800)/4] & (~0x400); return r | (((input_port_read(space->machine, "SYSTEM") ^ 0xff)<<8) & 0x400); } @@ -2075,13 +2082,14 @@ static READ32_HANDLER ( rfjet_speedup_r ) // mame_printf_debug("%08x\n",cpu_get_pc(space->cpu)); - return spimainram[(0x002894c-0x800)/4]; + return state->spimainram[(0x002894c-0x800)/4]; } static void init_spi(running_machine *machine) { - flash[0] = machine->device<intel_e28f008sa_device>("flash0"); - flash[1] = machine->device<intel_e28f008sa_device>("flash1"); + seibuspi_state *state = machine->driver_data<seibuspi_state>(); + state->flash[0] = machine->device<intel_e28f008sa_device>("flash0"); + state->flash[1] = machine->device<intel_e28f008sa_device>("flash1"); seibuspi_text_decrypt(machine->region("gfx1")->base()); seibuspi_bg_decrypt(machine->region("gfx2")->base(), machine->region("gfx2")->bytes()); @@ -2142,8 +2150,9 @@ static DRIVER_INIT( viprp1o ) static void init_rf2(running_machine *machine) { - flash[0] = machine->device<intel_e28f008sa_device>("flash0"); - flash[1] = machine->device<intel_e28f008sa_device>("flash1"); + seibuspi_state *state = machine->driver_data<seibuspi_state>(); + state->flash[0] = machine->device<intel_e28f008sa_device>("flash0"); + state->flash[1] = machine->device<intel_e28f008sa_device>("flash1"); memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0282AC, 0x0282AF, 0, 0, rf2_speedup_r ); seibuspi_rise10_text_decrypt(machine->region("gfx1")->base()); @@ -2166,8 +2175,9 @@ static DRIVER_INIT( rdft2us ) static void init_rfjet(running_machine *machine) { - flash[0] = machine->device<intel_e28f008sa_device>("flash0"); - flash[1] = machine->device<intel_e28f008sa_device>("flash1"); + seibuspi_state *state = machine->driver_data<seibuspi_state>(); + state->flash[0] = machine->device<intel_e28f008sa_device>("flash0"); + state->flash[1] = machine->device<intel_e28f008sa_device>("flash1"); memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x002894c, 0x002894f, 0, 0, rfjet_speedup_r ); seibuspi_rise11_text_decrypt(machine->region("gfx1")->base()); @@ -2199,7 +2209,7 @@ static MACHINE_RESET( seibu386 ) cpu_set_irq_callback(machine->device("maincpu"), spi_irq_callback); } -static MACHINE_CONFIG_START( seibu386, driver_device ) +static MACHINE_CONFIG_START( seibu386, seibuspi_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", I386, 40000000) /* AMD 386DX, 40MHz */ @@ -2253,7 +2263,7 @@ static DRIVER_INIT( sys386f2 ) } } -static MACHINE_CONFIG_START( sys386f2, driver_device ) +static MACHINE_CONFIG_START( sys386f2, seibuspi_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", I386, 25000000) /* 25mhz */ diff --git a/src/mame/drivers/tetrisp2.c b/src/mame/drivers/tetrisp2.c index c0eee8ad451..3674af42a8b 100644 --- a/src/mame/drivers/tetrisp2.c +++ b/src/mame/drivers/tetrisp2.c @@ -41,15 +41,6 @@ Notes: #include "includes/tetrisp2.h" #include "machine/nvram.h" -UINT16 tetrisp2_systemregs[0x10]; -static UINT16 rocknms_sub_systemregs[0x10]; - -static UINT16 rockn_protectdata; -static UINT16 rockn_adpcmbank; -static UINT16 rockn_soundvolume; - -static emu_timer *rockn_timer_l4; -static emu_timer *rockn_timer_sub_l4; /*************************************************************************** @@ -61,9 +52,10 @@ static emu_timer *rockn_timer_sub_l4; static WRITE16_HANDLER( tetrisp2_systemregs_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); if (ACCESSING_BITS_0_7) { - tetrisp2_systemregs[offset] = data; + state->systemregs[offset] = data; } } @@ -71,13 +63,14 @@ static WRITE16_HANDLER( tetrisp2_systemregs_w ) static WRITE16_HANDLER( rockn_systemregs_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); if (ACCESSING_BITS_0_7) { - tetrisp2_systemregs[offset] = data; + state->systemregs[offset] = data; if (offset == 0x0c) { attotime timer = ROCKN_TIMER_BASE * (4096 - data); - rockn_timer_l4->adjust(timer, 0, timer); + state->rockn_timer_l4->adjust(timer, 0, timer); } } } @@ -85,13 +78,14 @@ static WRITE16_HANDLER( rockn_systemregs_w ) static WRITE16_HANDLER( rocknms_sub_systemregs_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); if (ACCESSING_BITS_0_7) { - rocknms_sub_systemregs[offset] = data; + state->rocknms_sub_systemregs[offset] = data; if (offset == 0x0c) { attotime timer = ROCKN_TIMER_BASE * (4096 - data); - rockn_timer_sub_l4->adjust(timer, 0, timer); + state->rockn_timer_sub_l4->adjust(timer, 0, timer); } } } @@ -107,15 +101,17 @@ static WRITE16_HANDLER( rocknms_sub_systemregs_w ) static READ16_HANDLER( rockn_adpcmbank_r ) { - return ((rockn_adpcmbank & 0xf0ff) | (rockn_protectdata << 8)); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + return ((state->rockn_adpcmbank & 0xf0ff) | (state->rockn_protectdata << 8)); } static WRITE16_HANDLER( rockn_adpcmbank_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); UINT8 *SNDROM = space->machine->region("ymz")->base(); int bank; - rockn_adpcmbank = data; + state->rockn_adpcmbank = data; bank = ((data & 0x001f) >> 2); if (bank > 7) @@ -129,6 +125,7 @@ static WRITE16_HANDLER( rockn_adpcmbank_w ) static WRITE16_HANDLER( rockn2_adpcmbank_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); UINT8 *SNDROM = space->machine->region("ymz")->base(); int bank; @@ -145,7 +142,7 @@ static WRITE16_HANDLER( rockn2_adpcmbank_w ) { 0, 5, 14 }, // bank $20 }; - rockn_adpcmbank = data; + state->rockn_adpcmbank = data; bank = ((data & 0x003f) >> 2); if (bank > 8) @@ -167,13 +164,14 @@ static READ16_HANDLER( rockn_soundvolume_r ) static WRITE16_HANDLER( rockn_soundvolume_w ) { - rockn_soundvolume = data; + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + state->rockn_soundvolume = data; } static WRITE16_HANDLER( nndmseal_sound_bank_w ) { - static int bank_lo, bank_hi; + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); if (ACCESSING_BITS_0_7) { @@ -181,19 +179,19 @@ static WRITE16_HANDLER( nndmseal_sound_bank_w ) if (data & 0x04) { - bank_lo = data & 0x03; + state->bank_lo = data & 0x03; - memcpy(space->machine->region("oki")->base(), rom + (bank_lo * 0x80000), 0x20000); + memcpy(space->machine->region("oki")->base(), rom + (state->bank_lo * 0x80000), 0x20000); -// logerror("PC:%06X sound bank_lo = %02X\n",cpu_get_pc(space->cpu),bank_lo); +// logerror("PC:%06X sound bank_lo = %02X\n",cpu_get_pc(space->cpu),state->bank_lo); } else { - bank_hi = data & 0x03; + state->bank_hi = data & 0x03; - memcpy(space->machine->region("oki")->base() + 0x20000, rom + (bank_lo * 0x80000) + (bank_hi * 0x20000), 0x20000); + memcpy(space->machine->region("oki")->base() + 0x20000, rom + (state->bank_lo * 0x80000) + (state->bank_hi * 0x20000), 0x20000); -// logerror("PC:%06X sound bank_hi = %02X\n",cpu_get_pc(space->cpu),bank_hi); +// logerror("PC:%06X sound bank_hi = %02X\n",cpu_get_pc(space->cpu),state->bank_hi); } } } @@ -222,24 +220,26 @@ static READ16_HANDLER( tetrisp2_ip_1_word_r ) ***************************************************************************/ -static UINT16 *tetrisp2_nvram; /* The game only ever writes even bytes and reads odd bytes */ static READ16_HANDLER( tetrisp2_nvram_r ) { - return ( (tetrisp2_nvram[offset] >> 8) & 0x00ff ) | - ( (tetrisp2_nvram[offset] << 8) & 0xff00 ) ; + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + return ( (state->nvram[offset] >> 8) & 0x00ff ) | + ( (state->nvram[offset] << 8) & 0xff00 ) ; } static WRITE16_HANDLER( tetrisp2_nvram_w ) { - COMBINE_DATA(&tetrisp2_nvram[offset]); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + COMBINE_DATA(&state->nvram[offset]); } static READ16_HANDLER( rockn_nvram_r ) { - return tetrisp2_nvram[offset]; + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + return state->nvram[offset]; } @@ -251,29 +251,31 @@ static READ16_HANDLER( rockn_nvram_r ) ***************************************************************************/ -static UINT16 rocknms_main2sub; -static UINT16 rocknms_sub2main; static READ16_HANDLER( rocknms_main2sub_r ) { - return rocknms_main2sub; + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + return state->rocknms_main2sub; } static WRITE16_HANDLER( rocknms_main2sub_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); if (ACCESSING_BITS_0_7) - rocknms_main2sub = (data ^ 0xffff); + state->rocknms_main2sub = (data ^ 0xffff); } static CUSTOM_INPUT( rocknms_main2sub_status_r ) { - return rocknms_sub2main & 0x0003; + tetrisp2_state *state = field->port->machine->driver_data<tetrisp2_state>(); + return state->rocknms_sub2main & 0x0003; } static WRITE16_HANDLER( rocknms_sub2main_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); if (ACCESSING_BITS_0_7) - rocknms_sub2main = (data ^ 0xffff); + state->rocknms_sub2main = (data ^ 0xffff); } @@ -299,21 +301,21 @@ static ADDRESS_MAP_START( tetrisp2_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x108000, 0x10ffff) AM_RAM // Work RAM AM_RANGE(0x200000, 0x23ffff) AM_READWRITE8(tetrisp2_priority_r, tetrisp2_priority_w, 0x00ff) AM_RANGE(0x300000, 0x31ffff) AM_RAM_WRITE(tetrisp2_palette_w) AM_BASE_GENERIC(paletteram) // Palette - AM_RANGE(0x400000, 0x403fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE(&tetrisp2_vram_fg) // Foreground - AM_RANGE(0x404000, 0x407fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE(&tetrisp2_vram_bg) // Background + AM_RANGE(0x400000, 0x403fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE_MEMBER(tetrisp2_state, vram_fg) // Foreground + AM_RANGE(0x404000, 0x407fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE_MEMBER(tetrisp2_state, vram_bg) // Background AM_RANGE(0x408000, 0x409fff) AM_RAM // ??? AM_RANGE(0x500000, 0x50ffff) AM_RAM // Line - AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE(&tetrisp2_vram_rot) // Rotation + AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE_MEMBER(tetrisp2_state, vram_rot) // Rotation AM_RANGE(0x650000, 0x651fff) AM_RAM_WRITE(tetrisp2_vram_rot_w) // Rotation (mirror) AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff) // Sound - AM_RANGE(0x900000, 0x903fff) AM_READWRITE(tetrisp2_nvram_r, tetrisp2_nvram_w) AM_BASE(&tetrisp2_nvram) AM_SHARE("nvram") // NVRAM + AM_RANGE(0x900000, 0x903fff) AM_READWRITE(tetrisp2_nvram_r, tetrisp2_nvram_w) AM_BASE_MEMBER(tetrisp2_state, nvram) AM_SHARE("nvram") // NVRAM AM_RANGE(0x904000, 0x907fff) AM_READWRITE(tetrisp2_nvram_r, tetrisp2_nvram_w) // NVRAM (mirror) AM_RANGE(0xb00000, 0xb00001) AM_WRITE(tetrisp2_coincounter_w) // Coin Counter AM_RANGE(0xb20000, 0xb20001) AM_WRITENOP // ??? - AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_fg) // Foreground Scrolling - AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_bg) // Background Scrolling + AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_fg) // Foreground Scrolling + AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_bg) // Background Scrolling AM_RANGE(0xb4003e, 0xb4003f) AM_WRITENOP // scr_size - AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE(&tetrisp2_rotregs) // Rotation Registers + AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rotregs) // Rotation Registers AM_RANGE(0xba0000, 0xba001f) AM_WRITE(tetrisp2_systemregs_w) // system param AM_RANGE(0xba001a, 0xba001b) AM_WRITENOP // Lev 4 irq ack AM_RANGE(0xba001e, 0xba001f) AM_WRITENOP // Lev 2 irq ack @@ -357,27 +359,27 @@ static ADDRESS_MAP_START( nndmseal_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200000, 0x23ffff) AM_WRITE8(tetrisp2_priority_w, 0x00ff) // Priority AM_RANGE(0x200000, 0x23ffff) AM_READ(nndmseal_priority_r) AM_RANGE(0x300000, 0x31ffff) AM_RAM_WRITE(tetrisp2_palette_w) AM_BASE_GENERIC(paletteram) // Palette - AM_RANGE(0x400000, 0x403fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE(&tetrisp2_vram_fg ) // Foreground - AM_RANGE(0x404000, 0x407fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE(&tetrisp2_vram_bg ) // Background + AM_RANGE(0x400000, 0x403fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE_MEMBER(tetrisp2_state, vram_fg ) // Foreground + AM_RANGE(0x404000, 0x407fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE_MEMBER(tetrisp2_state, vram_bg ) // Background AM_RANGE(0x408000, 0x409fff) AM_RAM // ??? AM_RANGE(0x500000, 0x50ffff) AM_RAM // Line - AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE(&tetrisp2_vram_rot ) // Rotation + AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE_MEMBER(tetrisp2_state, vram_rot ) // Rotation AM_RANGE(0x650000, 0x651fff) AM_RAM_WRITE(tetrisp2_vram_rot_w) // Rotation (mirror) AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff ) // Sound - AM_RANGE(0x900000, 0x903fff) AM_READWRITE(tetrisp2_nvram_r, tetrisp2_nvram_w) AM_BASE(&tetrisp2_nvram) AM_SHARE("nvram") // NVRAM + AM_RANGE(0x900000, 0x903fff) AM_READWRITE(tetrisp2_nvram_r, tetrisp2_nvram_w) AM_BASE_MEMBER(tetrisp2_state, nvram) AM_SHARE("nvram") // NVRAM AM_RANGE(0xb00000, 0xb00001) AM_WRITE(nndmseal_coincounter_w) // Coin Counter AM_RANGE(0xb20000, 0xb20001) AM_WRITE(nndmseal_b20000_w) // ??? - AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_fg ) // Foreground Scrolling - AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_bg ) // Background Scrolling + AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_fg ) // Foreground Scrolling + AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_bg ) // Background Scrolling AM_RANGE(0xb4003e, 0xb4003f) AM_WRITENOP // scr_size - AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE(&tetrisp2_rotregs) // Rotation Registers + AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rotregs) // Rotation Registers AM_RANGE(0xb80000, 0xb80001) AM_WRITE(nndmseal_sound_bank_w) @@ -402,22 +404,22 @@ static ADDRESS_MAP_START( rockn1_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x108000, 0x10ffff) AM_RAM // Work RAM AM_RANGE(0x200000, 0x23ffff) AM_READWRITE8(tetrisp2_priority_r, rockn_priority_w, 0x00ff) // Priority AM_RANGE(0x300000, 0x31ffff) AM_RAM_WRITE(tetrisp2_palette_w) AM_BASE_GENERIC(paletteram) // Palette - AM_RANGE(0x400000, 0x403fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE(&tetrisp2_vram_fg) // Foreground - AM_RANGE(0x404000, 0x407fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE(&tetrisp2_vram_bg) // Background + AM_RANGE(0x400000, 0x403fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE_MEMBER(tetrisp2_state, vram_fg) // Foreground + AM_RANGE(0x404000, 0x407fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE_MEMBER(tetrisp2_state, vram_bg) // Background AM_RANGE(0x408000, 0x409fff) AM_RAM // ??? AM_RANGE(0x500000, 0x50ffff) AM_RAM // Line - AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE(&tetrisp2_vram_rot) // Rotation - AM_RANGE(0x900000, 0x903fff) AM_READWRITE(rockn_nvram_r, tetrisp2_nvram_w) AM_BASE(&tetrisp2_nvram) AM_SHARE("nvram") // NVRAM + AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE_MEMBER(tetrisp2_state, vram_rot) // Rotation + AM_RANGE(0x900000, 0x903fff) AM_READWRITE(rockn_nvram_r, tetrisp2_nvram_w) AM_BASE_MEMBER(tetrisp2_state, nvram) AM_SHARE("nvram") // NVRAM AM_RANGE(0xa30000, 0xa30001) AM_READWRITE(rockn_soundvolume_r, rockn_soundvolume_w) // Sound Volume AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff) // Sound AM_RANGE(0xa44000, 0xa44001) AM_READWRITE(rockn_adpcmbank_r, rockn_adpcmbank_w) // Sound Bank AM_RANGE(0xa48000, 0xa48001) AM_NOP // YMZ280 Reset AM_RANGE(0xb00000, 0xb00001) AM_WRITE(tetrisp2_coincounter_w) // Coin Counter AM_RANGE(0xb20000, 0xb20001) AM_NOP // ??? - AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_fg) // Foreground Scrolling - AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_bg) // Background Scrolling + AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_fg) // Foreground Scrolling + AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_bg) // Background Scrolling AM_RANGE(0xb4003e, 0xb4003f) AM_WRITENOP // scr_size - AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE(&tetrisp2_rotregs) // Rotation Registers + AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rotregs) // Rotation Registers AM_RANGE(0xba0000, 0xba001f) AM_WRITE(rockn_systemregs_w) // system param AM_RANGE(0xba001a, 0xba001b) AM_WRITENOP // Lev 4 irq ack AM_RANGE(0xba001e, 0xba001f) AM_WRITENOP // Lev 2 irq ack @@ -437,21 +439,21 @@ static ADDRESS_MAP_START( rockn2_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200000, 0x23ffff) AM_READWRITE8(tetrisp2_priority_r, rockn_priority_w, 0x00ff) // Priority AM_RANGE(0x300000, 0x31ffff) AM_RAM_WRITE(tetrisp2_palette_w) AM_BASE_GENERIC(paletteram) // Palette AM_RANGE(0x500000, 0x50ffff) AM_RAM // Line - AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE(&tetrisp2_vram_rot) // Rotation - AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE(&tetrisp2_vram_fg) // Foreground - AM_RANGE(0x804000, 0x807fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE(&tetrisp2_vram_bg) // Background + AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE_MEMBER(tetrisp2_state, vram_rot) // Rotation + AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE_MEMBER(tetrisp2_state, vram_fg) // Foreground + AM_RANGE(0x804000, 0x807fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE_MEMBER(tetrisp2_state, vram_bg) // Background AM_RANGE(0x808000, 0x809fff) AM_RAM // ??? - AM_RANGE(0x900000, 0x903fff) AM_READWRITE(rockn_nvram_r, tetrisp2_nvram_w) AM_BASE(&tetrisp2_nvram) AM_SHARE("nvram") // NVRAM + AM_RANGE(0x900000, 0x903fff) AM_READWRITE(rockn_nvram_r, tetrisp2_nvram_w) AM_BASE_MEMBER(tetrisp2_state, nvram) AM_SHARE("nvram") // NVRAM AM_RANGE(0xa30000, 0xa30001) AM_READWRITE(rockn_soundvolume_r, rockn_soundvolume_w) // Sound Volume AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff) // Sound AM_RANGE(0xa44000, 0xa44001) AM_READWRITE(rockn_adpcmbank_r, rockn2_adpcmbank_w) // Sound Bank AM_RANGE(0xa48000, 0xa48001) AM_WRITENOP // YMZ280 Reset AM_RANGE(0xb00000, 0xb00001) AM_WRITE(tetrisp2_coincounter_w) // Coin Counter AM_RANGE(0xb20000, 0xb20001) AM_WRITENOP // ??? - AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_fg) // Foreground Scrolling - AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_bg) // Background Scrolling + AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_fg) // Foreground Scrolling + AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_bg) // Background Scrolling AM_RANGE(0xb4003e, 0xb4003f) AM_WRITENOP // scr_size - AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE(&tetrisp2_rotregs) // Rotation Registers + AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rotregs) // Rotation Registers AM_RANGE(0xba0000, 0xba001f) AM_WRITE(rockn_systemregs_w) // system param AM_RANGE(0xba001a, 0xba001b) AM_WRITENOP // Lev 4 irq ack AM_RANGE(0xba001e, 0xba001f) AM_WRITENOP // Lev 2 irq ack @@ -471,11 +473,11 @@ static ADDRESS_MAP_START( rocknms_main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200000, 0x23ffff) AM_READWRITE8(tetrisp2_priority_r, rockn_priority_w, 0x00ff) // Priority AM_RANGE(0x300000, 0x31ffff) AM_RAM_WRITE(tetrisp2_palette_w) AM_BASE_GENERIC(paletteram) // Palette // AM_RANGE(0x500000, 0x50ffff) AM_RAM // Line - AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE(&tetrisp2_vram_rot) // Rotation - AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE(&tetrisp2_vram_fg) // Foreground - AM_RANGE(0x804000, 0x807fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE(&tetrisp2_vram_bg) // Background + AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(tetrisp2_vram_rot_w) AM_BASE_MEMBER(tetrisp2_state, vram_rot) // Rotation + AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(tetrisp2_vram_fg_w) AM_BASE_MEMBER(tetrisp2_state, vram_fg) // Foreground + AM_RANGE(0x804000, 0x807fff) AM_RAM_WRITE(tetrisp2_vram_bg_w) AM_BASE_MEMBER(tetrisp2_state, vram_bg) // Background // AM_RANGE(0x808000, 0x809fff) AM_RAM // ??? - AM_RANGE(0x900000, 0x903fff) AM_READWRITE(rockn_nvram_r, tetrisp2_nvram_w) AM_BASE(&tetrisp2_nvram) AM_SHARE("nvram") // NVRAM + AM_RANGE(0x900000, 0x903fff) AM_READWRITE(rockn_nvram_r, tetrisp2_nvram_w) AM_BASE_MEMBER(tetrisp2_state, nvram) AM_SHARE("nvram") // NVRAM AM_RANGE(0xa30000, 0xa30001) AM_READWRITE(rockn_soundvolume_r, rockn_soundvolume_w) // Sound Volume AM_RANGE(0xa40000, 0xa40003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff) // Sound AM_RANGE(0xa44000, 0xa44001) AM_READWRITE(rockn_adpcmbank_r, rockn_adpcmbank_w) // Sound Bank @@ -483,10 +485,10 @@ static ADDRESS_MAP_START( rocknms_main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xa00000, 0xa00001) AM_WRITE(rocknms_main2sub_w) // MAIN -> SUB Communication AM_RANGE(0xb00000, 0xb00001) AM_WRITE(tetrisp2_coincounter_w) // Coin Counter AM_RANGE(0xb20000, 0xb20001) AM_WRITENOP // ??? - AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_fg) // Foreground Scrolling - AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE(&tetrisp2_scroll_bg) // Background Scrolling + AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_fg) // Foreground Scrolling + AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, scroll_bg) // Background Scrolling AM_RANGE(0xb4003e, 0xb4003f) AM_WRITENOP // scr_size - AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE(&tetrisp2_rotregs) // Rotation Registers + AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rotregs) // Rotation Registers AM_RANGE(0xba0000, 0xba001f) AM_WRITE(rockn_systemregs_w) // system param AM_RANGE(0xba001a, 0xba001b) AM_WRITENOP // Lev 4 irq ack AM_RANGE(0xba001e, 0xba001f) AM_WRITENOP // Lev 2 irq ack @@ -503,12 +505,12 @@ static ADDRESS_MAP_START( rocknms_sub_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2) // Object RAM AM_RANGE(0x104000, 0x107fff) AM_RAM // Spare Object RAM AM_RANGE(0x108000, 0x10ffff) AM_RAM // Work RAM - AM_RANGE(0x200000, 0x23ffff) AM_RAM_WRITE(rocknms_sub_priority_w) AM_BASE(&rocknms_sub_priority) // Priority + AM_RANGE(0x200000, 0x23ffff) AM_RAM_WRITE(rocknms_sub_priority_w) AM_BASE_MEMBER(tetrisp2_state, rocknms_sub_priority) // Priority AM_RANGE(0x300000, 0x31ffff) AM_RAM_WRITE(rocknms_sub_palette_w) AM_BASE_GENERIC(paletteram2) // Palette // AM_RANGE(0x500000, 0x50ffff) AM_RAM // Line - AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(rocknms_sub_vram_rot_w) AM_BASE(&rocknms_sub_vram_rot) // Rotation - AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(rocknms_sub_vram_fg_w) AM_BASE(&rocknms_sub_vram_fg) // Foreground - AM_RANGE(0x804000, 0x807fff) AM_RAM_WRITE(rocknms_sub_vram_bg_w) AM_BASE(&rocknms_sub_vram_bg) // Background + AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(rocknms_sub_vram_rot_w) AM_BASE_MEMBER(tetrisp2_state, rocknms_sub_vram_rot) // Rotation + AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(rocknms_sub_vram_fg_w) AM_BASE_MEMBER(tetrisp2_state, rocknms_sub_vram_fg) // Foreground + AM_RANGE(0x804000, 0x807fff) AM_RAM_WRITE(rocknms_sub_vram_bg_w) AM_BASE_MEMBER(tetrisp2_state, rocknms_sub_vram_bg) // Background // AM_RANGE(0x808000, 0x809fff) AM_RAM // ??? AM_RANGE(0x900000, 0x907fff) AM_RAM // NVRAM AM_RANGE(0xa30000, 0xa30001) AM_WRITE(rockn_soundvolume_w) // Sound Volume @@ -517,10 +519,10 @@ static ADDRESS_MAP_START( rocknms_sub_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xa48000, 0xa48001) AM_WRITENOP // YMZ280 Reset AM_RANGE(0xb00000, 0xb00001) AM_WRITE(rocknms_sub2main_w) // MAIN <- SUB Communication AM_RANGE(0xb20000, 0xb20001) AM_WRITENOP // ??? - AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE(&rocknms_sub_scroll_fg) // Foreground Scrolling - AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE(&rocknms_sub_scroll_bg) // Background Scrolling + AM_RANGE(0xb40000, 0xb4000b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rocknms_sub_scroll_fg) // Foreground Scrolling + AM_RANGE(0xb40010, 0xb4001b) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rocknms_sub_scroll_bg) // Background Scrolling AM_RANGE(0xb4003e, 0xb4003f) AM_WRITENOP // scr_size - AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE(&rocknms_sub_rotregs) // Rotation Registers + AM_RANGE(0xb60000, 0xb6002f) AM_WRITEONLY AM_BASE_MEMBER(tetrisp2_state, rocknms_sub_rotregs) // Rotation Registers AM_RANGE(0xba0000, 0xba001f) AM_WRITE(rocknms_sub_systemregs_w) // system param AM_RANGE(0xba001a, 0xba001b) AM_WRITENOP // Lev 4 irq ack AM_RANGE(0xba001e, 0xba001f) AM_WRITENOP // Lev 2 irq ack @@ -1046,53 +1048,59 @@ static TIMER_CALLBACK( rockn_timer_sub_level1_callback ) static void init_rockn_timer(running_machine *machine) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); machine->scheduler().timer_pulse(attotime::from_msec(32), FUNC(rockn_timer_level1_callback)); - rockn_timer_l4 = machine->scheduler().timer_alloc(FUNC(rockn_timer_level4_callback)); + state->rockn_timer_l4 = machine->scheduler().timer_alloc(FUNC(rockn_timer_level4_callback)); - state_save_register_global_array(machine, tetrisp2_systemregs); - state_save_register_global_array(machine, rocknms_sub_systemregs); - state_save_register_global(machine, rockn_protectdata); - state_save_register_global(machine, rockn_adpcmbank); - state_save_register_global(machine, rockn_soundvolume); + state_save_register_global_array(machine, state->systemregs); + state_save_register_global_array(machine, state->rocknms_sub_systemregs); + state_save_register_global(machine, state->rockn_protectdata); + state_save_register_global(machine, state->rockn_adpcmbank); + state_save_register_global(machine, state->rockn_soundvolume); } static DRIVER_INIT( rockn ) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); init_rockn_timer(machine); - rockn_protectdata = 1; + state->rockn_protectdata = 1; } static DRIVER_INIT( rockn1 ) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); init_rockn_timer(machine); - rockn_protectdata = 1; + state->rockn_protectdata = 1; } static DRIVER_INIT( rockn2 ) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); init_rockn_timer(machine); - rockn_protectdata = 2; + state->rockn_protectdata = 2; } static DRIVER_INIT( rocknms ) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); init_rockn_timer(machine); machine->scheduler().timer_pulse(attotime::from_msec(32), FUNC(rockn_timer_sub_level1_callback)); - rockn_timer_sub_l4 = machine->scheduler().timer_alloc(FUNC(rockn_timer_sub_level4_callback)); + state->rockn_timer_sub_l4 = machine->scheduler().timer_alloc(FUNC(rockn_timer_sub_level4_callback)); - rockn_protectdata = 3; + state->rockn_protectdata = 3; } static DRIVER_INIT( rockn3 ) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); init_rockn_timer(machine); - rockn_protectdata = 4; + state->rockn_protectdata = 4; } -static MACHINE_CONFIG_START( tetrisp2, driver_device ) +static MACHINE_CONFIG_START( tetrisp2, tetrisp2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 12000000) @@ -1125,7 +1133,7 @@ static MACHINE_CONFIG_START( tetrisp2, driver_device ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( nndmseal, driver_device ) +static MACHINE_CONFIG_START( nndmseal, tetrisp2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_12MHz) @@ -1156,7 +1164,7 @@ static MACHINE_CONFIG_START( nndmseal, driver_device ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( rockn, driver_device ) +static MACHINE_CONFIG_START( rockn, tetrisp2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 12000000) @@ -1188,7 +1196,7 @@ static MACHINE_CONFIG_START( rockn, driver_device ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( rockn2, driver_device ) +static MACHINE_CONFIG_START( rockn2, tetrisp2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 12000000) @@ -1220,7 +1228,7 @@ static MACHINE_CONFIG_START( rockn2, driver_device ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( rocknms, driver_device ) +static MACHINE_CONFIG_START( rocknms, tetrisp2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 12000000) diff --git a/src/mame/drivers/vicdual.c b/src/mame/drivers/vicdual.c index 5746a5ef155..9f900b4dd8a 100644 --- a/src/mame/drivers/vicdual.c +++ b/src/mame/drivers/vicdual.c @@ -66,24 +66,25 @@ #define COIN_PORT_TAG "COIN" -static UINT32 coin_status; - static TIMER_CALLBACK( clear_coin_status ) { - coin_status = 0; + vicdual_state *state = machine->driver_data<vicdual_state>(); + state->coin_status = 0; } -static void assert_coin_status(void) +static void assert_coin_status(running_machine *machine) { - coin_status = 1; + vicdual_state *state = machine->driver_data<vicdual_state>(); + state->coin_status = 1; } static CUSTOM_INPUT( vicdual_read_coin_status ) { - return coin_status; + vicdual_state *state = field->port->machine->driver_data<vicdual_state>(); + return state->coin_status; } @@ -189,44 +190,30 @@ int vicdual_is_cabinet_color(running_machine *machine) * *************************************/ -static UINT8 *vicdual_videoram; -static UINT8 *vicdual_characterram; - static WRITE8_HANDLER( vicdual_videoram_w ) { + vicdual_state *state = space->machine->driver_data<vicdual_state>(); space->machine->primary_screen->update_now(); - vicdual_videoram[offset] = data; -} - - -UINT8 vicdual_videoram_r(offs_t offset) -{ - return vicdual_videoram[offset]; + state->videoram[offset] = data; } static WRITE8_HANDLER( vicdual_characterram_w ) { + vicdual_state *state = space->machine->driver_data<vicdual_state>(); space->machine->primary_screen->update_now(); - vicdual_characterram[offset] = data; + state->characterram[offset] = data; } -UINT8 vicdual_characterram_r(offs_t offset) -{ - return vicdual_characterram[offset]; -} - - - /************************************* * * Root driver structure * *************************************/ -static MACHINE_CONFIG_START( vicdual_root, driver_device ) +static MACHINE_CONFIG_START( vicdual_root, vicdual_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, VICDUAL_MAIN_CPU_CLOCK) @@ -259,16 +246,16 @@ static READ8_HANDLER( depthch_io_r ) static WRITE8_HANDLER( depthch_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x04) depthch_audio_w(space, 0, data); } static ADDRESS_MAP_START( depthch_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x4000) AM_ROM - AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0x8400, 0x87ff) AM_MIRROR(0x7000) AM_RAM - AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -341,7 +328,7 @@ static READ8_HANDLER( safari_io_r ) static WRITE8_HANDLER( safari_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x02) { /* safari_audio_w(0, data) */ } } @@ -350,9 +337,9 @@ static ADDRESS_MAP_START( safari_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_ROM AM_RANGE(0x4000, 0x7fff) AM_NOP /* unused */ AM_RANGE(0x8000, 0x8fff) AM_MIRROR(0x3000) AM_RAM - AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0xc400, 0xc7ff) AM_MIRROR(0x3000) AM_RAM - AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -425,16 +412,16 @@ static READ8_HANDLER( frogs_io_r ) static WRITE8_HANDLER( frogs_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x02) frogs_audio_w(space, 0, data); } static ADDRESS_MAP_START( frogs_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x4000) AM_ROM - AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0x8400, 0x87ff) AM_MIRROR(0x7000) AM_RAM - AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -545,7 +532,7 @@ static READ8_HANDLER( sspaceat_io_r ) static WRITE8_HANDLER( headon_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x02) headon_audio_w(space, 0, data); if (offset & 0x04) { /* vicdual_palette_bank_w(0, data) */ } /* not written to */ } @@ -554,9 +541,9 @@ static WRITE8_HANDLER( headon_io_w ) static ADDRESS_MAP_START( headon_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_MIRROR(0x6000) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_NOP /* unused */ - AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0xc400, 0xc7ff) AM_MIRROR(0x3000) AM_RAM - AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -746,7 +733,7 @@ static READ8_HANDLER( headon2_io_r ) static WRITE8_HANDLER( headon2_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x02) headon_audio_w(space, 0, data); if (offset & 0x04) vicdual_palette_bank_w(space, 0, data); if (offset & 0x08) { /* schematics show this as going into a shifer circuit, but never written to */ } @@ -757,7 +744,7 @@ static WRITE8_HANDLER( headon2_io_w ) static WRITE8_HANDLER( digger_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x02) { /* digger_audio_1_w(0, data) */ } if (offset & 0x04) { @@ -774,9 +761,9 @@ static WRITE8_HANDLER( digger_io_w ) static ADDRESS_MAP_START( headon2_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_MIRROR(0x6000) AM_ROM /* AM_RANGE(0x8000, 0x80ff) AM_MIRROR(0x3f00) */ /* schematics show this as battery backed RAM, but doesn't appear to be used */ - AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0xc400, 0xc7ff) AM_MIRROR(0x3000) AM_RAM - AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -962,7 +949,7 @@ static WRITE8_HANDLER( invho2_io_w ) { if (offset & 0x01) invho2_audio_w(space, 0, data); if (offset & 0x02) invinco_audio_w(space, 0, data); - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } @@ -971,7 +958,7 @@ static WRITE8_HANDLER( invds_io_w ) { if (offset & 0x01) invinco_audio_w(space, 0, data); if (offset & 0x02) { /* deepscan_audio_w(0, data) */ } - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } @@ -980,7 +967,7 @@ static WRITE8_HANDLER( sspacaho_io_w ) { if (offset & 0x01) invho2_audio_w(space, 0, data); if (offset & 0x02) { /* sspaceatt_audio_w(space, 0, data) */ } - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } @@ -989,7 +976,7 @@ static WRITE8_HANDLER( tranqgun_io_w ) { if (offset & 0x01) { /* tranqgun_audio_w(space, 0, data) */ } if (offset & 0x02) vicdual_palette_bank_w(space, 0, data); - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); } @@ -997,7 +984,7 @@ static WRITE8_HANDLER( spacetrk_io_w ) { if (offset & 0x01) { /* spacetrk_audio_w(space, 0, data) */ } if (offset & 0x02) { /* spacetrk_audio_w(space, 0, data) */ } - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } @@ -1006,7 +993,7 @@ static WRITE8_HANDLER( carnival_io_w ) { if (offset & 0x01) carnival_audio_1_w(space, 0, data); if (offset & 0x02) carnival_audio_2_w(space, 0, data); - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } @@ -1015,7 +1002,7 @@ static WRITE8_HANDLER( brdrline_io_w ) { if (offset & 0x01) { /* brdrline_audio_w(space, 0, data) */ } if (offset & 0x02) vicdual_palette_bank_w(space, 0, data); - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); } @@ -1023,7 +1010,7 @@ static WRITE8_HANDLER( pulsar_io_w ) { if (offset & 0x01) pulsar_audio_1_w(space, 0, data); if (offset & 0x02) pulsar_audio_2_w(space, 0, data); - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } @@ -1038,7 +1025,7 @@ static WRITE8_HANDLER( heiankyo_io_w ) /* heiankyo_audio_2_w(0, data & 0x3f); */ } - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); } @@ -1046,16 +1033,16 @@ static WRITE8_HANDLER( alphaho_io_w ) { if (offset & 0x01) { /* headon_audio_w(0, data) */ } if (offset & 0x02) { /* alphaf_audio_w(0, data) */ } - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } static ADDRESS_MAP_START( vicdual_dualgame_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x4000) AM_ROM - AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0x8400, 0x87ff) AM_MIRROR(0x7000) AM_RAM - AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -2056,23 +2043,23 @@ MACHINE_CONFIG_END * *************************************/ -static UINT8 samurai_protection_data; - static WRITE8_HANDLER( samurai_protection_w ) { - samurai_protection_data = data; + vicdual_state *state = space->machine->driver_data<vicdual_state>(); + state->samurai_protection_data = data; } static CUSTOM_INPUT( samurai_protection_r ) { + vicdual_state *state = field->port->machine->driver_data<vicdual_state>(); int offset = (FPTR)param; UINT32 answer = 0; - if (samurai_protection_data == 0xab) + if (state->samurai_protection_data == 0xab) answer = 0x02; - else if (samurai_protection_data == 0x1d) + else if (state->samurai_protection_data == 0x1d) answer = 0x0c; return (answer >> offset) & 0x01; @@ -2082,7 +2069,7 @@ static CUSTOM_INPUT( samurai_protection_r ) static WRITE8_HANDLER( samurai_io_w ) { if (offset & 0x02) { /* samurai_audio_w(0, data) */ } - if (offset & 0x08) assert_coin_status(); + if (offset & 0x08) assert_coin_status(space->machine); if (offset & 0x40) vicdual_palette_bank_w(space, 0, data); } @@ -2090,9 +2077,9 @@ static WRITE8_HANDLER( samurai_io_w ) /* dual game hardware */ static ADDRESS_MAP_START( samurai_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x4000) AM_ROM AM_WRITE(samurai_protection_w) - AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0x8400, 0x87ff) AM_MIRROR(0x7000) AM_RAM - AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0x8800, 0x8fff) AM_MIRROR(0x7000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -2195,7 +2182,7 @@ static READ8_HANDLER( nsub_io_r ) static WRITE8_HANDLER( nsub_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x02) { /* nsub_audio_w(0, data) */ } if (offset & 0x04) vicdual_palette_bank_w(space, 0, data); } @@ -2204,9 +2191,9 @@ static WRITE8_HANDLER( nsub_io_w ) static ADDRESS_MAP_START( nsub_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x4000) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_NOP /* unused */ - AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0xc400, 0xc7ff) AM_MIRROR(0x3000) AM_RAM - AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END @@ -2291,7 +2278,7 @@ static READ8_HANDLER( invinco_io_r ) static WRITE8_HANDLER( invinco_io_w ) { - if (offset & 0x01) assert_coin_status(); + if (offset & 0x01) assert_coin_status(space->machine); if (offset & 0x02) invinco_audio_w(space, 0, data); if (offset & 0x04) vicdual_palette_bank_w(space, 0, data); } @@ -2300,9 +2287,9 @@ static WRITE8_HANDLER( invinco_io_w ) static ADDRESS_MAP_START( invinco_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x4000) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_NOP /* unused */ - AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE(&vicdual_videoram) + AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_videoram_w) AM_BASE_MEMBER(vicdual_state, videoram) AM_RANGE(0xc400, 0xc7ff) AM_MIRROR(0x3000) AM_RAM - AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE(&vicdual_characterram) + AM_RANGE(0xc800, 0xcfff) AM_MIRROR(0x3000) AM_RAM_WRITE(vicdual_characterram_w) AM_BASE_MEMBER(vicdual_state, characterram) ADDRESS_MAP_END diff --git a/src/mame/includes/cclimber.h b/src/mame/includes/cclimber.h index 87af075fed7..1af11d24498 100644 --- a/src/mame/includes/cclimber.h +++ b/src/mame/includes/cclimber.h @@ -1,3 +1,30 @@ +class cclimber_state : public driver_device +{ +public: + cclimber_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 *videoram; + UINT8 *colorram; + UINT8 *spriteram; + UINT8 *bigsprite_videoram; + UINT8 *bigsprite_control; + UINT8 *column_scroll; + UINT8 *flip_screen; + UINT8 *swimmer_background_color; + UINT8 *swimmer_side_background_enabled; + UINT8 *swimmer_palettebank; + UINT8 *toprollr_bg_videoram; + UINT8 *toprollr_bg_coloram; + UINT8 yamato_p0; + UINT8 yamato_p1; + UINT8 toprollr_rombank; + tilemap_t *pf_tilemap; + tilemap_t *bs_tilemap; + tilemap_t *toproller_bg_tilemap; +}; + + /*----------- defined in machine/cclimber.c -----------*/ DRIVER_INIT( cclimber ); @@ -8,22 +35,6 @@ DRIVER_INIT( ckongb ); /*----------- defined in video/cclimber.c -----------*/ -extern UINT8 *cclimber_videoram; -extern UINT8 *cclimber_colorram; -extern UINT8 *cclimber_spriteram; -extern UINT8 *cclimber_bigsprite_videoram; -extern UINT8 *cclimber_bigsprite_control; - -extern UINT8 *cclimber_column_scroll; -extern UINT8 *cclimber_flip_screen; - -extern UINT8 *swimmer_background_color; -extern UINT8 *swimmer_side_background_enabled; -extern UINT8 *swimmer_palettebank; - -extern UINT8 *toprollr_bg_videoram; -extern UINT8 *toprollr_bg_coloram; - WRITE8_HANDLER( cclimber_colorram_w ); WRITE8_HANDLER( cannonb_flip_screen_w ); diff --git a/src/mame/includes/galpani2.h b/src/mame/includes/galpani2.h index 2c2e6cc62a9..2409e6c68e1 100644 --- a/src/mame/includes/galpani2.h +++ b/src/mame/includes/galpani2.h @@ -1,11 +1,31 @@ -/*----------- defined in video/galpani2.c -----------*/ +class galpani2_state : public driver_device +{ +public: + galpani2_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT16 *bg8_0; + UINT16 *bg8_1; + UINT16 *palette_0; + UINT16 *palette_1; + UINT16 *bg8_0_scrollx; + UINT16 *bg8_1_scrollx; + UINT16 *bg8_0_scrolly; + UINT16 *bg8_1_scrolly; + UINT16 *bg15; + UINT16 eeprom_word; + UINT16 *ram; + UINT16 *ram2; + UINT16 old_mcu_nmi1; + UINT16 old_mcu_nmi2; + UINT16 *rombank; + bitmap_t *bg8_bitmap_0; + bitmap_t *bg8_bitmap_1; + bitmap_t *bg15_bitmap; +}; -extern UINT16 *galpani2_bg8_0, *galpani2_bg8_1; -extern UINT16 *galpani2_palette_0, *galpani2_palette_1; -extern UINT16 *galpani2_bg8_0_scrollx, *galpani2_bg8_1_scrollx; -extern UINT16 *galpani2_bg8_0_scrolly, *galpani2_bg8_1_scrolly; -extern UINT16 *galpani2_bg15; +/*----------- defined in video/galpani2.c -----------*/ PALETTE_INIT( galpani2 ); VIDEO_START( galpani2 ); diff --git a/src/mame/includes/namcond1.h b/src/mame/includes/namcond1.h index b14127ea8bb..9c892c08ace 100644 --- a/src/mame/includes/namcond1.h +++ b/src/mame/includes/namcond1.h @@ -6,15 +6,24 @@ ***************************************************************************/ -/*----------- defined in machine/namcond1.c -----------*/ +class namcond1_state : public driver_device +{ +public: + namcond1_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 h8_irq5_enabled; + UINT16 *shared_ram; + int p8; +}; -extern UINT8 namcond1_h8_irq5_enabled; -extern UINT16 *namcond1_shared_ram; -extern READ16_HANDLER( namcond1_shared_ram_r ); -extern READ16_HANDLER( namcond1_cuskey_r ); -extern WRITE16_HANDLER( namcond1_shared_ram_w ); -extern WRITE16_HANDLER( namcond1_cuskey_w ); +/*----------- defined in machine/namcond1.c -----------*/ + +READ16_HANDLER( namcond1_shared_ram_r ); +READ16_HANDLER( namcond1_cuskey_r ); +WRITE16_HANDLER( namcond1_shared_ram_w ); +WRITE16_HANDLER( namcond1_cuskey_w ); MACHINE_START( namcond1 ); MACHINE_RESET( namcond1 ); diff --git a/src/mame/includes/pacman.h b/src/mame/includes/pacman.h index ef15d311f32..5a7ab224762 100644 --- a/src/mame/includes/pacman.h +++ b/src/mame/includes/pacman.h @@ -4,10 +4,34 @@ **************************************************************************/ -/*----------- defined in video/pacman.c -----------*/ +class pacman_state : public driver_device +{ +public: + pacman_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 cannonb_bit_to_read; + int mystery; + UINT8 counter; + int bigbucks_bank; + UINT8 *rocktrv2_prot_data; + UINT8 rocktrv2_question_bank; + UINT8 *videoram; + UINT8 *colorram; + UINT8 *s2650games_spriteram; + UINT8 *s2650games_tileram; + tilemap_t *bg_tilemap; + UINT8 charbank; + UINT8 spritebank; + UINT8 palettebank; + UINT8 colortablebank; + UINT8 flipscreen; + UINT8 bgpriority; + int xoffsethack; +}; + -extern UINT8 *pacman_videoram; -extern UINT8 *pacman_colorram; +/*----------- defined in video/pacman.c -----------*/ PALETTE_INIT( pacman ); VIDEO_START( pacman ); @@ -28,8 +52,6 @@ WRITE8_HANDLER( pengo_gfxbank_w ); VIDEO_START( s2650games ); SCREEN_UPDATE( s2650games ); -extern UINT8 *s2650games_spriteram; -extern UINT8 *s2650games_tileram; WRITE8_HANDLER( s2650games_videoram_w ); WRITE8_HANDLER( s2650games_colorram_w ); diff --git a/src/mame/includes/seibuspi.h b/src/mame/includes/seibuspi.h index 310c8f6c8f9..83d38ac7fdf 100644 --- a/src/mame/includes/seibuspi.h +++ b/src/mame/includes/seibuspi.h @@ -1,6 +1,49 @@ -/*----------- defined in drivers/seibuspi.c -----------*/ +#include "machine/intelfsh.h" -extern UINT32 *spimainram; +#define FIFO_SIZE 512 + +class seibuspi_state : public driver_device +{ +public: + seibuspi_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT32 *spimainram; + UINT32 *spi_scrollram; + intel_e28f008sa_device *flash[2]; + UINT8 *z80_rom; + int z80_prg_fifo_pos; + int z80_lastbank; + int fifoin_rpos; + int fifoin_wpos; + UINT8 fifoin_data[FIFO_SIZE]; + int fifoin_read_request; + int fifoout_rpos; + int fifoout_wpos; + UINT8 fifoout_data[FIFO_SIZE]; + int fifoout_read_request; + UINT8 sb_coin_latch; + UINT8 ejsakura_input_port; + tilemap_t *text_layer; + tilemap_t *back_layer; + tilemap_t *mid_layer; + tilemap_t *fore_layer; + UINT32 layer_bank; + UINT32 layer_enable; + UINT32 video_dma_length; + UINT32 video_dma_address; + UINT32 sprite_dma_length; + int rf2_layer_bank[3]; + UINT32 *tilemap_ram; + UINT32 *palette_ram; + UINT32 *sprite_ram; + int mid_layer_offset; + int fore_layer_offset; + int text_layer_offset; + UINT32 bg_fore_layer_position; + UINT8 alpha_table[8192]; + UINT8 sprite_bpp; +}; /*----------- defined in machine/spisprit.c -----------*/ @@ -10,8 +53,6 @@ void seibuspi_sprite_decrypt(UINT8 *src, int romsize); /*----------- defined in video/seibuspi.c -----------*/ -extern UINT32 *spi_scrollram; - VIDEO_START( spi ); SCREEN_UPDATE( spi ); @@ -22,7 +63,7 @@ READ32_HANDLER( spi_layer_bank_r ); WRITE32_HANDLER( spi_layer_bank_w ); WRITE32_HANDLER( spi_layer_enable_w ); -void rf2_set_layer_banks(int banks); +void rf2_set_layer_banks(running_machine *machine, int banks); WRITE32_HANDLER( tilemap_dma_start_w ); WRITE32_HANDLER( palette_dma_start_w ); diff --git a/src/mame/includes/tetrisp2.h b/src/mame/includes/tetrisp2.h index c6d5394233e..d52c5f290a7 100644 --- a/src/mame/includes/tetrisp2.h +++ b/src/mame/includes/tetrisp2.h @@ -1,22 +1,47 @@ -/*----------- defined in drivers/tetrisp2.c -----------*/ +class tetrisp2_state : public driver_device +{ +public: + tetrisp2_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT16 tetrisp2_systemregs[0x10]; + UINT16 systemregs[0x10]; + UINT16 *vram_bg; + UINT16 *scroll_bg; + UINT16 *vram_fg; + UINT16 *scroll_fg; + UINT16 *vram_rot; + UINT16 *rotregs; + UINT8 *priority; + UINT16 *rocknms_sub_vram_bg; + UINT16 *rocknms_sub_scroll_bg; + UINT16 *rocknms_sub_vram_fg; + UINT16 *rocknms_sub_scroll_fg; + UINT16 *rocknms_sub_vram_rot; + UINT16 *rocknms_sub_rotregs; + UINT16 *rocknms_sub_priority; + UINT16 rocknms_sub_systemregs[0x10]; + UINT16 rockn_protectdata; + UINT16 rockn_adpcmbank; + UINT16 rockn_soundvolume; + emu_timer *rockn_timer_l4; + emu_timer *rockn_timer_sub_l4; + int bank_lo; + int bank_hi; + UINT16 *nvram; + UINT16 rocknms_main2sub; + UINT16 rocknms_sub2main; + int flipscreen_old; + tilemap_t *tilemap_bg; + tilemap_t *tilemap_fg; + tilemap_t *tilemap_rot; + tilemap_t *tilemap_sub_bg; + tilemap_t *tilemap_sub_fg; + tilemap_t *tilemap_sub_rot; +}; /*----------- defined in video/tetrisp2.c -----------*/ -extern UINT16 *tetrisp2_vram_bg, *tetrisp2_scroll_bg; -extern UINT16 *tetrisp2_vram_fg, *tetrisp2_scroll_fg; -extern UINT16 *tetrisp2_vram_rot, *tetrisp2_rotregs; - -extern UINT8 *tetrisp2_priority; - -extern UINT16 *rocknms_sub_vram_bg, *rocknms_sub_scroll_bg; -extern UINT16 *rocknms_sub_vram_fg, *rocknms_sub_scroll_fg; -extern UINT16 *rocknms_sub_vram_rot, *rocknms_sub_rotregs; - -extern UINT16 *rocknms_sub_priority; - WRITE16_HANDLER( tetrisp2_palette_w ); WRITE16_HANDLER( rocknms_sub_palette_w ); WRITE8_HANDLER( tetrisp2_priority_w ); diff --git a/src/mame/includes/vicdual.h b/src/mame/includes/vicdual.h index 706924b601e..a0a3e161104 100644 --- a/src/mame/includes/vicdual.h +++ b/src/mame/includes/vicdual.h @@ -22,10 +22,21 @@ #define VICDUAL_VSEND (0x0f0) -/*----------- defined in drivers/vicdual.c -----------*/ +class vicdual_state : public driver_device +{ +public: + vicdual_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT32 coin_status; + UINT8 *videoram; + UINT8 *characterram; + UINT8 samurai_protection_data; + UINT8 palette_bank; +}; -UINT8 vicdual_videoram_r(offs_t offset); -UINT8 vicdual_characterram_r(offs_t offset); + +/*----------- defined in drivers/vicdual.c -----------*/ int vicdual_is_cabinet_color(running_machine *machine); diff --git a/src/mame/machine/acitya.c b/src/mame/machine/acitya.c index f26ca3c9d79..3044cb5cfec 100644 --- a/src/mame/machine/acitya.c +++ b/src/mame/machine/acitya.c @@ -15,8 +15,6 @@ David Widel d_widel@hotmail.com #include "emu.h" #include "includes/pacman.h" -static INT8 counter=0; - static void acitya_decrypt_rom_8(running_machine *machine) { @@ -158,25 +156,24 @@ static void acitya_decrypt_rom_B(running_machine *machine) READ8_HANDLER( acitya_decrypt_rom ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); if (offset & 0x01) { - counter = counter - 1; - if (counter < 0) - counter = 0x0F; + state->counter = (state->counter - 1) & 0x0F; } else { - counter = (counter + 1) & 0x0F; + state->counter = (state->counter + 1) & 0x0F; } - switch(counter) + switch(state->counter) { case 0x08: memory_set_bank (space->machine, "bank1", 0); break; case 0x09: memory_set_bank (space->machine, "bank1", 1); break; case 0x0A: memory_set_bank (space->machine, "bank1", 2); break; case 0x0B: memory_set_bank (space->machine, "bank1", 3); break; default: - logerror("Invalid counter = %02X\n",counter); + logerror("Invalid counter = %02X\n",state->counter); break; } @@ -186,6 +183,7 @@ READ8_HANDLER( acitya_decrypt_rom ) MACHINE_START( acitya ) { + pacman_state *state = machine->driver_data<pacman_state>(); UINT8 *RAM = machine->region("maincpu")->base(); /* While the PAL supports up to 16 decryption methods, only four @@ -198,13 +196,14 @@ MACHINE_START( acitya ) memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000); - state_save_register_global(machine, counter); + state_save_register_global(machine, state->counter); } MACHINE_RESET( acitya ) { + pacman_state *state = machine->driver_data<pacman_state>(); /* The initial state of the counter is 0x0B */ - counter = 0x0B; + state->counter = 0x0B; memory_set_bank(machine, "bank1", 3); } diff --git a/src/mame/machine/namcond1.c b/src/mame/machine/namcond1.c index 3050e2c1d91..f0b91977abc 100644 --- a/src/mame/machine/namcond1.c +++ b/src/mame/machine/namcond1.c @@ -16,15 +16,16 @@ /* Perform basic machine initialisation */ -UINT8 namcond1_h8_irq5_enabled; MACHINE_START( namcond1 ) { - state_save_register_global(machine, namcond1_h8_irq5_enabled); + namcond1_state *state = machine->driver_data<namcond1_state>(); + state_save_register_global(machine, state->h8_irq5_enabled); } MACHINE_RESET( namcond1 ) { + namcond1_state *state = machine->driver_data<namcond1_state>(); #ifdef MAME_DEBUG /*UINT8 *ROM = machine->region(REGION_CPU1)->base();*/ /*UINT32 debug_trigger_addr;*/ @@ -44,18 +45,18 @@ MACHINE_RESET( namcond1 ) #endif // initialise MCU states - namcond1_h8_irq5_enabled = 0; + state->h8_irq5_enabled = 0; // halt the MCU cputag_set_input_line(machine, "mcu", INPUT_LINE_RESET, ASSERT_LINE); } // instance of the shared ram pointer -UINT16 *namcond1_shared_ram; READ16_HANDLER( namcond1_shared_ram_r ) { - return namcond1_shared_ram[offset]; + namcond1_state *state = space->machine->driver_data<namcond1_state>(); + return state->shared_ram[offset]; } // $c3ff00-$c3ffff @@ -79,26 +80,28 @@ READ16_HANDLER( namcond1_cuskey_r ) WRITE16_HANDLER( namcond1_shared_ram_w ) { + namcond1_state *state = space->machine->driver_data<namcond1_state>(); switch( offset ) { default : - COMBINE_DATA( namcond1_shared_ram + offset ); + COMBINE_DATA( state->shared_ram + offset ); break; } } WRITE16_HANDLER( namcond1_cuskey_w ) { + namcond1_state *state = space->machine->driver_data<namcond1_state>(); switch( offset ) { case (0x0a>>1): // this is a kludge until we emulate the h8 - if ((namcond1_h8_irq5_enabled == 0) && (data != 0x0000)) + if ((state->h8_irq5_enabled == 0) && (data != 0x0000)) { cputag_set_input_line(space->machine, "mcu", INPUT_LINE_RESET, CLEAR_LINE); } - namcond1_h8_irq5_enabled = ( data != 0x0000 ); + state->h8_irq5_enabled = ( data != 0x0000 ); break; case (0x0c>>1): diff --git a/src/mame/machine/theglobp.c b/src/mame/machine/theglobp.c index e8fc0bd1027..2051edf806b 100644 --- a/src/mame/machine/theglobp.c +++ b/src/mame/machine/theglobp.c @@ -64,8 +64,6 @@ #include "emu.h" #include "includes/pacman.h" -static INT8 counter=0; - static void theglobp_decrypt_rom_8(running_machine *machine) { @@ -212,25 +210,24 @@ static void theglobp_decrypt_rom_B(running_machine *machine) READ8_HANDLER( theglobp_decrypt_rom ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); if (offset & 0x01) { - counter = counter - 1; - if (counter < 0) - counter = 0x0F; + state->counter = (state->counter - 1) & 0x0F; } else { - counter = (counter + 1) & 0x0F; + state->counter = (state->counter + 1) & 0x0F; } - switch(counter) + switch(state->counter) { case 0x08: memory_set_bank (space->machine, "bank1", 0); break; case 0x09: memory_set_bank (space->machine, "bank1", 1); break; case 0x0A: memory_set_bank (space->machine, "bank1", 2); break; case 0x0B: memory_set_bank (space->machine, "bank1", 3); break; default: - logerror("Invalid counter = %02X\n",counter); + logerror("Invalid counter = %02X\n",state->counter); break; } @@ -240,6 +237,7 @@ READ8_HANDLER( theglobp_decrypt_rom ) MACHINE_START( theglobp ) { + pacman_state *state = machine->driver_data<pacman_state>(); UINT8 *RAM = machine->region("maincpu")->base(); /* While the PAL supports up to 16 decryption methods, only four @@ -252,13 +250,14 @@ MACHINE_START( theglobp ) memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000); - state_save_register_global(machine, counter); + state_save_register_global(machine, state->counter); } MACHINE_RESET( theglobp ) { + pacman_state *state = machine->driver_data<pacman_state>(); /* The initial state of the counter is 0x0A */ - counter = 0x0A; + state->counter = 0x0A; memory_set_bank(machine, "bank1", 2); } diff --git a/src/mame/video/cclimber.c b/src/mame/video/cclimber.c index 86c37e7c1ef..b9929ec61af 100644 --- a/src/mame/video/cclimber.c +++ b/src/mame/video/cclimber.c @@ -11,33 +11,13 @@ #include "includes/cclimber.h" -#define CCLIMBER_FLIP_X (cclimber_flip_screen[0] & 0x01) -#define CCLIMBER_FLIP_Y (cclimber_flip_screen[1] & 0x01) +#define CCLIMBER_FLIP_X (state->flip_screen[0] & 0x01) +#define CCLIMBER_FLIP_Y (state->flip_screen[1] & 0x01) #define CCLIMBER_BG_PEN (0) #define SWIMMER_SIDE_BG_PEN (0x120) #define SWIMMER_BG_SPLIT (0x18 * 8) #define YAMATO_SKY_PEN_BASE (0x60) -static tilemap_t *pf_tilemap; -static tilemap_t *bs_tilemap; - -UINT8 *cclimber_videoram; -UINT8 *cclimber_colorram; -UINT8 *cclimber_spriteram; - -UINT8 *cclimber_bigsprite_videoram; -UINT8 *cclimber_bigsprite_control; -UINT8 *cclimber_column_scroll; -UINT8 *cclimber_flip_screen; - -UINT8 *swimmer_background_color; -UINT8 *swimmer_side_background_enabled; -UINT8 *swimmer_palettebank; - -UINT8 *toprollr_bg_videoram; -UINT8 *toprollr_bg_coloram; -static tilemap_t *toproller_bg_tilemap; - /*************************************************************************** @@ -318,25 +298,26 @@ PALETTE_INIT( toprollr ) static void swimmer_set_background_pen(running_machine *machine) { + cclimber_state *state = machine->driver_data<cclimber_state>(); int bit0, bit1, bit2; int r, g, b; /* red component */ bit0 = 0; - bit1 = (*swimmer_background_color >> 6) & 0x01; - bit2 = (*swimmer_background_color >> 7) & 0x01; + bit1 = (*state->swimmer_background_color >> 6) & 0x01; + bit2 = (*state->swimmer_background_color >> 7) & 0x01; r = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2; /* green component */ - bit0 = (*swimmer_background_color >> 3) & 0x01; - bit1 = (*swimmer_background_color >> 4) & 0x01; - bit2 = (*swimmer_background_color >> 5) & 0x01; + bit0 = (*state->swimmer_background_color >> 3) & 0x01; + bit1 = (*state->swimmer_background_color >> 4) & 0x01; + bit2 = (*state->swimmer_background_color >> 5) & 0x01; g = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2; /* blue component */ - bit0 = (*swimmer_background_color >> 0) & 0x01; - bit1 = (*swimmer_background_color >> 1) & 0x01; - bit2 = (*swimmer_background_color >> 2) & 0x01; + bit0 = (*state->swimmer_background_color >> 0) & 0x01; + bit1 = (*state->swimmer_background_color >> 1) & 0x01; + bit2 = (*state->swimmer_background_color >> 2) & 0x01; b = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2; palette_set_color(machine, CCLIMBER_BG_PEN, MAKE_RGB(r, g, b)); @@ -346,34 +327,37 @@ static void swimmer_set_background_pen(running_machine *machine) WRITE8_HANDLER( cclimber_colorram_w ) { + cclimber_state *state = space->machine->driver_data<cclimber_state>(); /* A5 is not connected, there is only 0x200 bytes of RAM */ - cclimber_colorram[offset & ~0x20] = data; - cclimber_colorram[offset | 0x20] = data; + state->colorram[offset & ~0x20] = data; + state->colorram[offset | 0x20] = data; } WRITE8_HANDLER( cannonb_flip_screen_w ) { - cclimber_flip_screen[0] = data; - cclimber_flip_screen[1] = data; + cclimber_state *state = space->machine->driver_data<cclimber_state>(); + state->flip_screen[0] = data; + state->flip_screen[1] = data; } static TILE_GET_INFO( cclimber_get_pf_tile_info ) { + cclimber_state *state = machine->driver_data<cclimber_state>(); int code, color; - int flags = TILE_FLIPYX(cclimber_colorram[tile_index] >> 6); + int flags = TILE_FLIPYX(state->colorram[tile_index] >> 6); /* vertical flipping flips two adjacent characters */ if (flags & 0x02) tile_index = tile_index ^ 0x20; - code = ((cclimber_colorram[tile_index] & 0x10) << 5) | - ((cclimber_colorram[tile_index] & 0x20) << 3) | - cclimber_videoram[tile_index]; + code = ((state->colorram[tile_index] & 0x10) << 5) | + ((state->colorram[tile_index] & 0x20) << 3) | + state->videoram[tile_index]; - color = cclimber_colorram[tile_index] & 0x0f; + color = state->colorram[tile_index] & 0x0f; SET_TILE_INFO(0, code, color, flags); } @@ -381,16 +365,17 @@ static TILE_GET_INFO( cclimber_get_pf_tile_info ) static TILE_GET_INFO( swimmer_get_pf_tile_info ) { + cclimber_state *state = machine->driver_data<cclimber_state>(); int code, color; - int flags = TILE_FLIPYX(cclimber_colorram[tile_index] >> 6); + int flags = TILE_FLIPYX(state->colorram[tile_index] >> 6); /* vertical flipping flips two adjacent characters */ if (flags & 0x02) tile_index = tile_index ^ 0x20; - code = ((cclimber_colorram[tile_index] & 0x10) << 4) | cclimber_videoram[tile_index]; - color = ((*swimmer_palettebank & 0x01) << 4) | (cclimber_colorram[tile_index] & 0x0f); + code = ((state->colorram[tile_index] & 0x10) << 4) | state->videoram[tile_index]; + color = ((*state->swimmer_palettebank & 0x01) << 4) | (state->colorram[tile_index] & 0x0f); SET_TILE_INFO(0, code, color, flags); } @@ -398,10 +383,11 @@ static TILE_GET_INFO( swimmer_get_pf_tile_info ) static TILE_GET_INFO( toprollr_get_pf_tile_info ) { + cclimber_state *state = machine->driver_data<cclimber_state>(); int code, attr, color; - attr = tile_index & 0x10 ? cclimber_colorram[tile_index & ~0x20] : cclimber_colorram[tile_index]; - code = ((attr & 0x30) << 4) | cclimber_videoram[tile_index]; + attr = tile_index & 0x10 ? state->colorram[tile_index & ~0x20] : state->colorram[tile_index]; + code = ((attr & 0x30) << 4) | state->videoram[tile_index]; color = attr & 0x0f; SET_TILE_INFO(0, code, color, 0); @@ -410,6 +396,7 @@ static TILE_GET_INFO( toprollr_get_pf_tile_info ) static TILE_GET_INFO( cclimber_get_bs_tile_info ) { + cclimber_state *state = machine->driver_data<cclimber_state>(); int code, color; /* only the lower right is visible */ @@ -418,8 +405,8 @@ static TILE_GET_INFO( cclimber_get_bs_tile_info ) /* the address doesn't use A4 of the coordinates, giving a 16x16 map */ tile_index = ((tile_index & 0x1e0) >> 1) | (tile_index & 0x0f); - code = ((cclimber_bigsprite_control[1] & 0x08) << 5) | cclimber_bigsprite_videoram[tile_index]; - color = cclimber_bigsprite_control[1] & 0x07; + code = ((state->bigsprite_control[1] & 0x08) << 5) | state->bigsprite_videoram[tile_index]; + color = state->bigsprite_control[1] & 0x07; SET_TILE_INFO(2, code, color, 0); } @@ -427,6 +414,7 @@ static TILE_GET_INFO( cclimber_get_bs_tile_info ) static TILE_GET_INFO( toprollr_get_bs_tile_info ) { + cclimber_state *state = machine->driver_data<cclimber_state>(); int code, color; /* only the lower right is visible */ @@ -435,8 +423,8 @@ static TILE_GET_INFO( toprollr_get_bs_tile_info ) /* the address doesn't use A4 of the coordinates, giving a 16x16 map */ tile_index = ((tile_index & 0x1e0) >> 1) | (tile_index & 0x0f); - code = ((cclimber_bigsprite_control[1] & 0x18) << 5) | cclimber_bigsprite_videoram[tile_index]; - color = cclimber_bigsprite_control[1] & 0x07; + code = ((state->bigsprite_control[1] & 0x18) << 5) | state->bigsprite_videoram[tile_index]; + color = state->bigsprite_control[1] & 0x07; SET_TILE_INFO(2, code, color, 0); } @@ -444,8 +432,9 @@ static TILE_GET_INFO( toprollr_get_bs_tile_info ) static TILE_GET_INFO( toproller_get_bg_tile_info ) { - int code = ((toprollr_bg_coloram[tile_index] & 0x40) << 2) | toprollr_bg_videoram[tile_index]; - int color = toprollr_bg_coloram[tile_index] & 0x0f; + cclimber_state *state = machine->driver_data<cclimber_state>(); + int code = ((state->toprollr_bg_coloram[tile_index] & 0x40) << 2) | state->toprollr_bg_videoram[tile_index]; + int color = state->toprollr_bg_coloram[tile_index] & 0x0f; SET_TILE_INFO(3, code, color, TILE_FLIPX); } @@ -453,68 +442,73 @@ static TILE_GET_INFO( toproller_get_bg_tile_info ) VIDEO_START( cclimber ) { - pf_tilemap = tilemap_create(machine, cclimber_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_transparent_pen(pf_tilemap, 0); - tilemap_set_scroll_cols(pf_tilemap, 32); - - bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_scroll_cols(bs_tilemap, 1); - tilemap_set_scroll_rows(bs_tilemap, 1); - tilemap_set_transmask(bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */ - tilemap_set_transmask(bs_tilemap, 1, 0x0f, 0); /* all 4 pens are transparent */ + cclimber_state *state = machine->driver_data<cclimber_state>(); + state->pf_tilemap = tilemap_create(machine, cclimber_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_transparent_pen(state->pf_tilemap, 0); + tilemap_set_scroll_cols(state->pf_tilemap, 32); + + state->bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_scroll_cols(state->bs_tilemap, 1); + tilemap_set_scroll_rows(state->bs_tilemap, 1); + tilemap_set_transmask(state->bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */ + tilemap_set_transmask(state->bs_tilemap, 1, 0x0f, 0); /* all 4 pens are transparent */ } VIDEO_START( swimmer ) { - pf_tilemap = tilemap_create(machine, swimmer_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_transparent_pen(pf_tilemap, 0); - tilemap_set_scroll_cols(pf_tilemap, 32); - - bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_scroll_cols(bs_tilemap, 1); - tilemap_set_scroll_rows(bs_tilemap, 1); - tilemap_set_transmask(bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */ - tilemap_set_transmask(bs_tilemap, 1, 0xff, 0); /* all 8 pens are transparent */ + cclimber_state *state = machine->driver_data<cclimber_state>(); + state->pf_tilemap = tilemap_create(machine, swimmer_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_transparent_pen(state->pf_tilemap, 0); + tilemap_set_scroll_cols(state->pf_tilemap, 32); + + state->bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_scroll_cols(state->bs_tilemap, 1); + tilemap_set_scroll_rows(state->bs_tilemap, 1); + tilemap_set_transmask(state->bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */ + tilemap_set_transmask(state->bs_tilemap, 1, 0xff, 0); /* all 8 pens are transparent */ } VIDEO_START( toprollr ) { - pf_tilemap = tilemap_create(machine, toprollr_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_transparent_pen(pf_tilemap, 0); - - toproller_bg_tilemap = tilemap_create(machine, toproller_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_scroll_rows(toproller_bg_tilemap, 1); - - bs_tilemap = tilemap_create(machine, toprollr_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_scroll_cols(bs_tilemap, 1); - tilemap_set_scroll_rows(bs_tilemap, 1); - tilemap_set_transmask(bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */ - tilemap_set_transmask(bs_tilemap, 1, 0x0f, 0); /* all 4 pens are transparent */ + cclimber_state *state = machine->driver_data<cclimber_state>(); + state->pf_tilemap = tilemap_create(machine, toprollr_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_transparent_pen(state->pf_tilemap, 0); + + state->toproller_bg_tilemap = tilemap_create(machine, toproller_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_scroll_rows(state->toproller_bg_tilemap, 1); + + state->bs_tilemap = tilemap_create(machine, toprollr_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_scroll_cols(state->bs_tilemap, 1); + tilemap_set_scroll_rows(state->bs_tilemap, 1); + tilemap_set_transmask(state->bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */ + tilemap_set_transmask(state->bs_tilemap, 1, 0x0f, 0); /* all 4 pens are transparent */ } -static void draw_playfield(bitmap_t *bitmap, const rectangle *cliprect) +static void draw_playfield(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { + cclimber_state *state = machine->driver_data<cclimber_state>(); int i; - tilemap_mark_all_tiles_dirty(pf_tilemap); - tilemap_set_flip(pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | + tilemap_mark_all_tiles_dirty(state->pf_tilemap); + tilemap_set_flip(state->pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0)); for (i = 0; i < 32; i++) - tilemap_set_scrolly(pf_tilemap, i, cclimber_column_scroll[i]); + tilemap_set_scrolly(state->pf_tilemap, i, state->column_scroll[i]); - tilemap_draw(bitmap, cliprect, pf_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->pf_tilemap, 0, 0); } -static void cclimber_draw_bigsprite(bitmap_t *bitmap, const rectangle *cliprect) +static void cclimber_draw_bigsprite(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { - UINT8 x = cclimber_bigsprite_control[3] - 8; - UINT8 y = cclimber_bigsprite_control[2]; - int bigsprite_flip_x = (cclimber_bigsprite_control[1] & 0x10) >> 4; - int bigsprite_flip_y = (cclimber_bigsprite_control[1] & 0x20) >> 5; + cclimber_state *state = machine->driver_data<cclimber_state>(); + UINT8 x = state->bigsprite_control[3] - 8; + UINT8 y = state->bigsprite_control[2]; + int bigsprite_flip_x = (state->bigsprite_control[1] & 0x10) >> 4; + int bigsprite_flip_y = (state->bigsprite_control[1] & 0x20) >> 5; if (bigsprite_flip_x) x = 0x80 - x; @@ -522,56 +516,58 @@ static void cclimber_draw_bigsprite(bitmap_t *bitmap, const rectangle *cliprect) if (bigsprite_flip_y) y = 0x80 - y; - tilemap_mark_all_tiles_dirty(bs_tilemap); + tilemap_mark_all_tiles_dirty(state->bs_tilemap); - tilemap_set_flip(bs_tilemap, (bigsprite_flip_x ? TILEMAP_FLIPX : 0) | + tilemap_set_flip(state->bs_tilemap, (bigsprite_flip_x ? TILEMAP_FLIPX : 0) | (CCLIMBER_FLIP_Y ^ bigsprite_flip_y ? TILEMAP_FLIPY : 0)); - tilemap_set_scrollx(bs_tilemap, 0, x); - tilemap_set_scrolly(bs_tilemap, 0, y); + tilemap_set_scrollx(state->bs_tilemap, 0, x); + tilemap_set_scrolly(state->bs_tilemap, 0, y); - tilemap_draw(bitmap, cliprect, bs_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->bs_tilemap, 0, 0); } -static void toprollr_draw_bigsprite(bitmap_t *bitmap, const rectangle *cliprect) +static void toprollr_draw_bigsprite(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { - UINT8 x = cclimber_bigsprite_control[3] - 8; - UINT8 y = cclimber_bigsprite_control[2]; + cclimber_state *state = machine->driver_data<cclimber_state>(); + UINT8 x = state->bigsprite_control[3] - 8; + UINT8 y = state->bigsprite_control[2]; - tilemap_mark_all_tiles_dirty(bs_tilemap); + tilemap_mark_all_tiles_dirty(state->bs_tilemap); - tilemap_set_flip(bs_tilemap, CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0); + tilemap_set_flip(state->bs_tilemap, CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0); - tilemap_set_scrollx(bs_tilemap, 0, x); - tilemap_set_scrolly(bs_tilemap, 0, y); + tilemap_set_scrollx(state->bs_tilemap, 0, x); + tilemap_set_scrolly(state->bs_tilemap, 0, y); - tilemap_draw(bitmap, cliprect, bs_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->bs_tilemap, 0, 0); } static void cclimber_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx) { + cclimber_state *state = gfx->machine->driver_data<cclimber_state>(); int offs; /* draw the sprites -- note that it is important to draw them exactly in this order, to have the correct priorities. */ for (offs = 0x1c; offs >= 0; offs -= 4) { - int x = cclimber_spriteram[offs + 3] + 1; + int x = state->spriteram[offs + 3] + 1; /* x + 1 is evident in cclimber and ckong. It looks worse, but it has been confirmed on several PCBs. */ - int y = 240 - cclimber_spriteram[offs + 2]; + int y = 240 - state->spriteram[offs + 2]; - int code = ((cclimber_spriteram[offs + 1] & 0x10) << 3) | - ((cclimber_spriteram[offs + 1] & 0x20) << 1) | - ( cclimber_spriteram[offs + 0] & 0x3f); + int code = ((state->spriteram[offs + 1] & 0x10) << 3) | + ((state->spriteram[offs + 1] & 0x20) << 1) | + ( state->spriteram[offs + 0] & 0x3f); - int color = cclimber_spriteram[offs + 1] & 0x0f; + int color = state->spriteram[offs + 1] & 0x0f; - int flipx = cclimber_spriteram[offs + 0] & 0x40; - int flipy = cclimber_spriteram[offs + 0] & 0x80; + int flipx = state->spriteram[offs + 0] & 0x40; + int flipy = state->spriteram[offs + 0] & 0x80; if (CCLIMBER_FLIP_X) { @@ -592,23 +588,24 @@ static void cclimber_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, c static void toprollr_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx) { + cclimber_state *state = gfx->machine->driver_data<cclimber_state>(); int offs; /* draw the sprites -- note that it is important to draw them exactly in this order, to have the correct priorities. */ for (offs = 0x1c; offs >= 0; offs -= 4) { - int x = cclimber_spriteram[offs + 3]; - int y = 240 - cclimber_spriteram[offs + 2]; + int x = state->spriteram[offs + 3]; + int y = 240 - state->spriteram[offs + 2]; - int code = ((cclimber_spriteram[offs + 1] & 0x10) << 3) | - ((cclimber_spriteram[offs + 1] & 0x20) << 1) | - ( cclimber_spriteram[offs + 0] & 0x3f); + int code = ((state->spriteram[offs + 1] & 0x10) << 3) | + ((state->spriteram[offs + 1] & 0x20) << 1) | + ( state->spriteram[offs + 0] & 0x3f); - int color = cclimber_spriteram[offs + 1] & 0x0f; + int color = state->spriteram[offs + 1] & 0x0f; - int flipx = cclimber_spriteram[offs + 0] & 0x40; - int flipy = cclimber_spriteram[offs + 0] & 0x80; + int flipx = state->spriteram[offs + 0] & 0x40; + int flipy = state->spriteram[offs + 0] & 0x80; if (CCLIMBER_FLIP_X) { @@ -629,23 +626,24 @@ static void toprollr_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, c static void swimmer_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx) { + cclimber_state *state = gfx->machine->driver_data<cclimber_state>(); int offs; /* draw the sprites -- note that it is important to draw them exactly in this order, to have the correct priorities. */ for (offs = 0x1c; offs >= 0; offs -= 4) { - int x = cclimber_spriteram[offs + 3]; - int y = 240 - cclimber_spriteram[offs + 2]; + int x = state->spriteram[offs + 3]; + int y = 240 - state->spriteram[offs + 2]; - int code = ((cclimber_spriteram[offs + 1] & 0x10) << 2) | - (cclimber_spriteram[offs + 0] & 0x3f); + int code = ((state->spriteram[offs + 1] & 0x10) << 2) | + (state->spriteram[offs + 0] & 0x3f); - int color = ((*swimmer_palettebank & 0x01) << 4) | - (cclimber_spriteram[offs + 1] & 0x0f); + int color = ((*state->swimmer_palettebank & 0x01) << 4) | + (state->spriteram[offs + 1] & 0x0f); - int flipx = cclimber_spriteram[offs + 0] & 0x40; - int flipy = cclimber_spriteram[offs + 0] & 0x80; + int flipx = state->spriteram[offs + 0] & 0x40; + int flipy = state->spriteram[offs + 0] & 0x80; if (CCLIMBER_FLIP_X) { @@ -666,13 +664,14 @@ static void swimmer_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, co SCREEN_UPDATE( cclimber ) { + cclimber_state *state = screen->machine->driver_data<cclimber_state>(); bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN); - draw_playfield(bitmap, cliprect); + draw_playfield(screen->machine, bitmap, cliprect); /* draw the "big sprite" under the regular sprites */ - if ((cclimber_bigsprite_control[0] & 0x01)) + if ((state->bigsprite_control[0] & 0x01)) { - cclimber_draw_bigsprite(bitmap, cliprect); + cclimber_draw_bigsprite(screen->machine, bitmap, cliprect); cclimber_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]); } @@ -680,7 +679,7 @@ SCREEN_UPDATE( cclimber ) else { cclimber_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]); - cclimber_draw_bigsprite(bitmap, cliprect); + cclimber_draw_bigsprite(screen->machine, bitmap, cliprect); } return 0; @@ -689,6 +688,7 @@ SCREEN_UPDATE( cclimber ) SCREEN_UPDATE( yamato ) { + cclimber_state *state = screen->machine->driver_data<cclimber_state>(); int i; UINT8 *sky_rom = screen->machine->region("user1")->base() + 0x1200; @@ -701,12 +701,12 @@ SCREEN_UPDATE( yamato ) *BITMAP_ADDR16(bitmap, j, (i - 8) & 0xff) = pen; } - draw_playfield(bitmap, cliprect); + draw_playfield(screen->machine, bitmap, cliprect); /* draw the "big sprite" under the regular sprites */ - if ((cclimber_bigsprite_control[0] & 0x01)) + if ((state->bigsprite_control[0] & 0x01)) { - cclimber_draw_bigsprite(bitmap, cliprect); + cclimber_draw_bigsprite(screen->machine, bitmap, cliprect); toprollr_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]); } @@ -714,7 +714,7 @@ SCREEN_UPDATE( yamato ) else { toprollr_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]); - cclimber_draw_bigsprite(bitmap, cliprect); + cclimber_draw_bigsprite(screen->machine, bitmap, cliprect); } return 0; @@ -723,9 +723,10 @@ SCREEN_UPDATE( yamato ) SCREEN_UPDATE( swimmer ) { + cclimber_state *state = screen->machine->driver_data<cclimber_state>(); swimmer_set_background_pen(screen->machine); - if (*swimmer_side_background_enabled & 0x01) + if (*state->swimmer_side_background_enabled & 0x01) { if (CCLIMBER_FLIP_X) { @@ -753,12 +754,12 @@ SCREEN_UPDATE( swimmer ) else bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN); - draw_playfield(bitmap, cliprect); + draw_playfield(screen->machine, bitmap, cliprect); /* draw the "big sprite" under the regular sprites */ - if ((cclimber_bigsprite_control[0] & 0x01)) + if ((state->bigsprite_control[0] & 0x01)) { - cclimber_draw_bigsprite(bitmap, cliprect); + cclimber_draw_bigsprite(screen->machine, bitmap, cliprect); swimmer_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]); } @@ -766,7 +767,7 @@ SCREEN_UPDATE( swimmer ) else { swimmer_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]); - cclimber_draw_bigsprite(bitmap, cliprect); + cclimber_draw_bigsprite(screen->machine, bitmap, cliprect); } return 0; @@ -775,36 +776,37 @@ SCREEN_UPDATE( swimmer ) SCREEN_UPDATE( toprollr ) { + cclimber_state *state = screen->machine->driver_data<cclimber_state>(); rectangle scroll_area_clip = *cliprect; scroll_area_clip.min_x = 4*8; scroll_area_clip.max_x = 29*8-1; bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN); - tilemap_set_scrollx(toproller_bg_tilemap, 0, toprollr_bg_videoram[0]); - tilemap_set_flip(toproller_bg_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | + tilemap_set_scrollx(state->toproller_bg_tilemap, 0, state->toprollr_bg_videoram[0]); + tilemap_set_flip(state->toproller_bg_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0)); - tilemap_mark_all_tiles_dirty(toproller_bg_tilemap); - tilemap_draw(bitmap, &scroll_area_clip, toproller_bg_tilemap, 0, 0); + tilemap_mark_all_tiles_dirty(state->toproller_bg_tilemap); + tilemap_draw(bitmap, &scroll_area_clip, state->toproller_bg_tilemap, 0, 0); /* draw the "big sprite" over the regular sprites */ - if ((cclimber_bigsprite_control[1] & 0x20)) + if ((state->bigsprite_control[1] & 0x20)) { toprollr_draw_sprites(bitmap, &scroll_area_clip, screen->machine->gfx[1]); - toprollr_draw_bigsprite(bitmap, &scroll_area_clip); + toprollr_draw_bigsprite(screen->machine, bitmap, &scroll_area_clip); } /* draw the "big sprite" under the regular sprites */ else { - toprollr_draw_bigsprite(bitmap, &scroll_area_clip); + toprollr_draw_bigsprite(screen->machine, bitmap, &scroll_area_clip); toprollr_draw_sprites(bitmap, &scroll_area_clip, screen->machine->gfx[1]); } - tilemap_mark_all_tiles_dirty(pf_tilemap); - tilemap_set_flip(pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | + tilemap_mark_all_tiles_dirty(state->pf_tilemap); + tilemap_set_flip(state->pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) | (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0)); - tilemap_draw(bitmap, cliprect, pf_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, state->pf_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/galpani2.c b/src/mame/video/galpani2.c index 1b4891ec691..3880b6b4c31 100644 --- a/src/mame/video/galpani2.c +++ b/src/mame/video/galpani2.c @@ -24,25 +24,19 @@ ***************************************************************************/ -UINT16 *galpani2_bg8_0, *galpani2_bg8_1; -UINT16 *galpani2_palette_0, *galpani2_palette_1; -//UINT16 *galpani2_bg8_regs_0, *galpani2_bg8_regs_1; -UINT16 *galpani2_bg8_0_scrollx, *galpani2_bg8_1_scrollx; -UINT16 *galpani2_bg8_0_scrolly, *galpani2_bg8_1_scrolly; - -static bitmap_t *galpani2_bg8_bitmap_0, *galpani2_bg8_bitmap_1; #ifdef UNUSED_DEFINITION #define galpani2_BG8_REGS_R( _n_ ) \ READ16_HANDLER( galpani2_bg8_regs_##_n_##_r ) \ { \ + galpani2_state *state = space->machine->driver_data<galpani2_state>(); \ switch (offset * 2) \ { \ case 0x16: return space->machine->rand() & 1; \ default: \ logerror("CPU #0 PC %06X : Warning, bg8 #%d screen reg %04X read\n",cpu_get_pc(space->cpu),_n_,offset*2); \ } \ - return galpani2_bg8_regs_##_n_[offset]; \ + return state->bg8_regs_##_n_[offset]; \ } /* @@ -55,25 +49,28 @@ READ16_HANDLER( galpani2_bg8_regs_##_n_##_r ) \ #define galpani2_BG8_REGS_W( _n_ ) \ WRITE16_HANDLER( galpani2_bg8_regs_##_n_##_w ) \ { \ - COMBINE_DATA(&galpani2_bg8_regs_##_n_[offset]); \ + galpani2_state *state = space->machine->driver_data<galpani2_state>(); \ + COMBINE_DATA(&state->bg8_regs_##_n_[offset]); \ } #endif #define galpani2_BG8_W( _n_ ) \ WRITE16_HANDLER( galpani2_bg8_##_n_##_w ) \ { \ + galpani2_state *state = space->machine->driver_data<galpani2_state>(); \ int x,y,pen; \ - UINT16 newword = COMBINE_DATA(&galpani2_bg8_##_n_[offset]); \ + UINT16 newword = COMBINE_DATA(&state->bg8_##_n_[offset]); \ pen = newword & 0xff; \ x = (offset % 512); /* 512 x 256 */ \ y = (offset / 512); \ - *BITMAP_ADDR16(galpani2_bg8_bitmap_##_n_, y, x) = 0x4000 + pen; \ + *BITMAP_ADDR16(state->bg8_bitmap_##_n_, y, x) = 0x4000 + pen; \ } #define galpani2_BG8_PALETTE_W( _n_ ) \ WRITE16_HANDLER( galpani2_palette_##_n_##_w ) \ { \ - UINT16 newword = COMBINE_DATA(&galpani2_palette_##_n_[offset]); \ + galpani2_state *state = space->machine->driver_data<galpani2_state>(); \ + UINT16 newword = COMBINE_DATA(&state->palette_##_n_[offset]); \ palette_set_color_rgb( space->machine, offset + 0x4000 + _n_ * 0x100, pal5bit(newword >> 5), pal5bit(newword >> 10), pal5bit(newword >> 0) ); \ } @@ -100,19 +97,16 @@ galpani2_BG8_PALETTE_W( 1 ) ***************************************************************************/ -UINT16 *galpani2_bg15; - -static bitmap_t *galpani2_bg15_bitmap; - /* 8 horizontal pages of 256x256 pixels? */ WRITE16_HANDLER( galpani2_bg15_w ) { - UINT16 newword = COMBINE_DATA(&galpani2_bg15[offset]); + galpani2_state *state = space->machine->driver_data<galpani2_state>(); + UINT16 newword = COMBINE_DATA(&state->bg15[offset]); int x = (offset % 256) + (offset / (256*256)) * 256 ; int y = (offset / 256) % 256; - *BITMAP_ADDR16(galpani2_bg15_bitmap, y, x) = 0x4200 + (newword & 0x7fff); + *BITMAP_ADDR16(state->bg15_bitmap, y, x) = 0x4200 + (newword & 0x7fff); } @@ -136,9 +130,10 @@ PALETTE_INIT( galpani2 ) VIDEO_START( galpani2 ) { - galpani2_bg15_bitmap = auto_bitmap_alloc(machine, 256*8, 256, BITMAP_FORMAT_INDEXED16); - galpani2_bg8_bitmap_0 = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16); - galpani2_bg8_bitmap_1 = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16); + galpani2_state *state = machine->driver_data<galpani2_state>(); + state->bg15_bitmap = auto_bitmap_alloc(machine, 256*8, 256, BITMAP_FORMAT_INDEXED16); + state->bg8_bitmap_0 = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16); + state->bg8_bitmap_1 = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16); VIDEO_START_CALL(kaneko16_sprites); } @@ -154,6 +149,7 @@ VIDEO_START( galpani2 ) SCREEN_UPDATE( galpani2 ) { + galpani2_state *state = screen->machine->driver_data<galpani2_state>(); int layers_ctrl = -1; #ifdef MAME_DEBUG @@ -175,7 +171,7 @@ if (input_code_pressed(screen->machine, KEYCODE_Z)) { int x = 0; int y = 0; - copyscrollbitmap_trans(bitmap, galpani2_bg15_bitmap, + copyscrollbitmap_trans(bitmap, state->bg15_bitmap, 1, &x, 1, &y, cliprect,0x4200 + 0); } @@ -188,18 +184,18 @@ if (input_code_pressed(screen->machine, KEYCODE_Z)) if (layers_ctrl & 0x2) { - int x = - ( *galpani2_bg8_0_scrollx + 0x200 - 0x0f5 ); - int y = - ( *galpani2_bg8_0_scrolly + 0x200 - 0x1be ); - copyscrollbitmap_trans(bitmap, galpani2_bg8_bitmap_0, + int x = - ( *state->bg8_0_scrollx + 0x200 - 0x0f5 ); + int y = - ( *state->bg8_0_scrolly + 0x200 - 0x1be ); + copyscrollbitmap_trans(bitmap, state->bg8_bitmap_0, 1, &x, 1, &y, cliprect,0x4000 + 0); } if (layers_ctrl & 0x4) { - int x = - ( *galpani2_bg8_1_scrollx + 0x200 - 0x0f5 ); - int y = - ( *galpani2_bg8_1_scrolly + 0x200 - 0x1be ); - copyscrollbitmap_trans(bitmap, galpani2_bg8_bitmap_1, + int x = - ( *state->bg8_1_scrollx + 0x200 - 0x0f5 ); + int y = - ( *state->bg8_1_scrolly + 0x200 - 0x1be ); + copyscrollbitmap_trans(bitmap, state->bg8_bitmap_1, 1, &x, 1, &y, cliprect,0x4000 + 0); } diff --git a/src/mame/video/pacman.c b/src/mame/video/pacman.c index 7935e2554d9..0d367b21805 100644 --- a/src/mame/video/pacman.c +++ b/src/mame/video/pacman.c @@ -20,19 +20,6 @@ #include "includes/pacman.h" #include "video/resnet.h" -UINT8 *pacman_videoram; -UINT8 *pacman_colorram; -static tilemap_t *bg_tilemap; -static UINT8 charbank; -static UINT8 spritebank; -static UINT8 palettebank; -static UINT8 colortablebank; -static UINT8 flipscreen; -static UINT8 bgpriority; - -static int xoffsethack; -UINT8 *s2650games_spriteram; -UINT8 *s2650games_tileram; static const rectangle spritevisiblearea = { @@ -154,8 +141,9 @@ static TILEMAP_MAPPER( pacman_scan_rows ) static TILE_GET_INFO( pacman_get_tile_info ) { - int code = pacman_videoram[tile_index] | (charbank << 8); - int attr = (pacman_colorram[tile_index] & 0x1f) | (colortablebank << 5) | (palettebank << 6 ); + pacman_state *state = machine->driver_data<pacman_state>(); + int code = state->videoram[tile_index] | (state->charbank << 8); + int attr = (state->colorram[tile_index] & 0x1f) | (state->colortablebank << 5) | (state->palettebank << 6 ); SET_TILE_INFO(0,code,attr,0); } @@ -168,61 +156,67 @@ static TILE_GET_INFO( pacman_get_tile_info ) static void init_save_state(running_machine *machine) { - state_save_register_global(machine, charbank); - state_save_register_global(machine, spritebank); - state_save_register_global(machine, palettebank); - state_save_register_global(machine, colortablebank); - state_save_register_global(machine, flipscreen); - state_save_register_global(machine, bgpriority); + pacman_state *state = machine->driver_data<pacman_state>(); + state_save_register_global(machine, state->charbank); + state_save_register_global(machine, state->spritebank); + state_save_register_global(machine, state->palettebank); + state_save_register_global(machine, state->colortablebank); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->bgpriority); } VIDEO_START( pacman ) { + pacman_state *state = machine->driver_data<pacman_state>(); init_save_state(machine); - charbank = 0; - spritebank = 0; - palettebank = 0; - colortablebank = 0; - flipscreen = 0; - bgpriority = 0; + state->charbank = 0; + state->spritebank = 0; + state->palettebank = 0; + state->colortablebank = 0; + state->flipscreen = 0; + state->bgpriority = 0; /* In the Pac Man based games (NOT Pengo) the first two sprites must be offset */ /* one pixel to the left to get a more correct placement */ - xoffsethack = 1; + state->xoffsethack = 1; - bg_tilemap = tilemap_create( machine, pacman_get_tile_info, pacman_scan_rows, 8, 8, 36, 28 ); + state->bg_tilemap = tilemap_create( machine, pacman_get_tile_info, pacman_scan_rows, 8, 8, 36, 28 ); - tilemap_set_scrolldx( bg_tilemap, 0, 384 - 288 ); - tilemap_set_scrolldy( bg_tilemap, 0, 264 - 224 ); + tilemap_set_scrolldx( state->bg_tilemap, 0, 384 - 288 ); + tilemap_set_scrolldy( state->bg_tilemap, 0, 264 - 224 ); } WRITE8_HANDLER( pacman_videoram_w ) { - pacman_videoram[offset] = data; - tilemap_mark_tile_dirty( bg_tilemap, offset ); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->videoram[offset] = data; + tilemap_mark_tile_dirty( state->bg_tilemap, offset ); } WRITE8_HANDLER( pacman_colorram_w ) { - pacman_colorram[offset] = data; - tilemap_mark_tile_dirty( bg_tilemap, offset ); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->colorram[offset] = data; + tilemap_mark_tile_dirty( state->bg_tilemap, offset ); } WRITE8_HANDLER( pacman_flipscreen_w ) { - flipscreen = data & 1; - tilemap_set_flip( bg_tilemap, flipscreen * ( TILEMAP_FLIPX + TILEMAP_FLIPY ) ); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->flipscreen = data & 1; + tilemap_set_flip( state->bg_tilemap, state->flipscreen * ( TILEMAP_FLIPX + TILEMAP_FLIPY ) ); } SCREEN_UPDATE( pacman ) { - if (bgpriority != 0) + pacman_state *state = screen->machine->driver_data<pacman_state>(); + if (state->bgpriority != 0) bitmap_fill(bitmap,cliprect,0); else - tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_OPAQUE,0); + tilemap_draw(bitmap,cliprect,state->bg_tilemap,TILEMAP_DRAW_OPAQUE,0); if( screen->machine->generic.spriteram_size ) { @@ -242,10 +236,10 @@ SCREEN_UPDATE( pacman ) sx = 272 - spriteram_2[offs + 1]; sy = spriteram_2[offs] - 31; - color = ( spriteram[offs + 1] & 0x1f ) | (colortablebank << 5) | (palettebank << 6 ); + color = ( spriteram[offs + 1] & 0x1f ) | (state->colortablebank << 5) | (state->palettebank << 6 ); drawgfx_transmask(bitmap,&spriteclip,screen->machine->gfx[1], - ( spriteram[offs] >> 2 ) | (spritebank << 6), + ( spriteram[offs] >> 2 ) | (state->spritebank << 6), color, spriteram[offs] & 1,spriteram[offs] & 2, sx,sy, @@ -253,7 +247,7 @@ SCREEN_UPDATE( pacman ) /* also plot the sprite with wraparound (tunnel in Crush Roller) */ drawgfx_transmask(bitmap,&spriteclip,screen->machine->gfx[1], - ( spriteram[offs] >> 2 ) | (spritebank << 6), + ( spriteram[offs] >> 2 ) | (state->spritebank << 6), color, spriteram[offs] & 1,spriteram[offs] & 2, sx - 256,sy, @@ -268,27 +262,27 @@ SCREEN_UPDATE( pacman ) sx = 272 - spriteram_2[offs + 1]; sy = spriteram_2[offs] - 31; - color = ( spriteram[offs + 1] & 0x1f ) | (colortablebank << 5) | (palettebank << 6 ); + color = ( spriteram[offs + 1] & 0x1f ) | (state->colortablebank << 5) | (state->palettebank << 6 ); drawgfx_transmask(bitmap,&spriteclip,screen->machine->gfx[1], - ( spriteram[offs] >> 2 ) | (spritebank << 6), + ( spriteram[offs] >> 2 ) | (state->spritebank << 6), color, spriteram[offs] & 1,spriteram[offs] & 2, - sx,sy + xoffsethack, + sx,sy + state->xoffsethack, colortable_get_transpen_mask(screen->machine->colortable, screen->machine->gfx[1], color & 0x3f, 0)); /* also plot the sprite with wraparound (tunnel in Crush Roller) */ drawgfx_transmask(bitmap,&spriteclip,screen->machine->gfx[1], - ( spriteram[offs] >> 2 ) | (spritebank << 6), + ( spriteram[offs] >> 2 ) | (state->spritebank << 6), color, spriteram[offs] & 2,spriteram[offs] & 1, - sx - 256,sy + xoffsethack, + sx - 256,sy + state->xoffsethack, colortable_get_transpen_mask(screen->machine->colortable, screen->machine->gfx[1], color & 0x3f, 0)); } } - if (bgpriority != 0) - tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); + if (state->bgpriority != 0) + tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0); return 0; } @@ -301,48 +295,52 @@ SCREEN_UPDATE( pacman ) VIDEO_START( pengo ) { + pacman_state *state = machine->driver_data<pacman_state>(); init_save_state(machine); - charbank = 0; - spritebank = 0; - palettebank = 0; - colortablebank = 0; - flipscreen = 0; - bgpriority = 0; + state->charbank = 0; + state->spritebank = 0; + state->palettebank = 0; + state->colortablebank = 0; + state->flipscreen = 0; + state->bgpriority = 0; - xoffsethack = 0; + state->xoffsethack = 0; - bg_tilemap = tilemap_create( machine, pacman_get_tile_info, pacman_scan_rows, 8, 8, 36, 28 ); + state->bg_tilemap = tilemap_create( machine, pacman_get_tile_info, pacman_scan_rows, 8, 8, 36, 28 ); - tilemap_set_scrolldx( bg_tilemap, 0, 384 - 288 ); - tilemap_set_scrolldy( bg_tilemap, 0, 264 - 224 ); + tilemap_set_scrolldx( state->bg_tilemap, 0, 384 - 288 ); + tilemap_set_scrolldy( state->bg_tilemap, 0, 264 - 224 ); } WRITE8_HANDLER( pengo_palettebank_w ) { - if (palettebank != data) + pacman_state *state = space->machine->driver_data<pacman_state>(); + if (state->palettebank != data) { - palettebank = data; - tilemap_mark_all_tiles_dirty( bg_tilemap ); + state->palettebank = data; + tilemap_mark_all_tiles_dirty( state->bg_tilemap ); } } WRITE8_HANDLER( pengo_colortablebank_w ) { - if (colortablebank != data) + pacman_state *state = space->machine->driver_data<pacman_state>(); + if (state->colortablebank != data) { - colortablebank = data; - tilemap_mark_all_tiles_dirty( bg_tilemap ); + state->colortablebank = data; + tilemap_mark_all_tiles_dirty( state->bg_tilemap ); } } WRITE8_HANDLER( pengo_gfxbank_w ) { - if (charbank != (data & 1)) + pacman_state *state = space->machine->driver_data<pacman_state>(); + if (state->charbank != (data & 1)) { - spritebank = data & 1; - charbank = data & 1; - tilemap_mark_all_tiles_dirty( bg_tilemap ); + state->spritebank = data & 1; + state->charbank = data & 1; + tilemap_mark_all_tiles_dirty( state->bg_tilemap ); } } @@ -355,41 +353,44 @@ S2650 Games static TILE_GET_INFO( s2650_get_tile_info ) { + pacman_state *state = machine->driver_data<pacman_state>(); int colbank, code, attr; - colbank = s2650games_tileram[tile_index & 0x1f] & 0x3; + colbank = state->s2650games_tileram[tile_index & 0x1f] & 0x3; - code = pacman_videoram[tile_index] + (colbank << 8); - attr = pacman_colorram[tile_index & 0x1f]; + code = state->videoram[tile_index] + (colbank << 8); + attr = state->colorram[tile_index & 0x1f]; SET_TILE_INFO(0,code,attr & 0x1f,0); } VIDEO_START( s2650games ) { + pacman_state *state = machine->driver_data<pacman_state>(); init_save_state(machine); - charbank = 0; - spritebank = 0; - palettebank = 0; - colortablebank = 0; - flipscreen = 0; - bgpriority = 0; + state->charbank = 0; + state->spritebank = 0; + state->palettebank = 0; + state->colortablebank = 0; + state->flipscreen = 0; + state->bgpriority = 0; - xoffsethack = 1; + state->xoffsethack = 1; - bg_tilemap = tilemap_create( machine, s2650_get_tile_info,tilemap_scan_rows,8,8,32,32 ); + state->bg_tilemap = tilemap_create( machine, s2650_get_tile_info,tilemap_scan_rows,8,8,32,32 ); - tilemap_set_scroll_cols(bg_tilemap, 32); + tilemap_set_scroll_cols(state->bg_tilemap, 32); } SCREEN_UPDATE( s2650games ) { + pacman_state *state = screen->machine->driver_data<pacman_state>(); UINT8 *spriteram = screen->machine->generic.spriteram.u8; UINT8 *spriteram_2 = screen->machine->generic.spriteram2.u8; int offs; - tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0); for (offs = screen->machine->generic.spriteram_size - 2;offs > 2*2;offs -= 2) { @@ -403,7 +404,7 @@ SCREEN_UPDATE( s2650games ) /* TODO: ?? */ drawgfx_transmask(bitmap,cliprect,screen->machine->gfx[1], - (spriteram[offs] >> 2) | ((s2650games_spriteram[offs] & 3) << 6), + (spriteram[offs] >> 2) | ((state->s2650games_spriteram[offs] & 3) << 6), color, spriteram[offs] & 1,spriteram[offs] & 2, sx,sy, @@ -423,10 +424,10 @@ SCREEN_UPDATE( s2650games ) /* TODO: ?? */ drawgfx_transmask(bitmap,cliprect,screen->machine->gfx[1], - (spriteram[offs] >> 2) | ((s2650games_spriteram[offs] & 3)<<6), + (spriteram[offs] >> 2) | ((state->s2650games_spriteram[offs] & 3)<<6), color, spriteram[offs] & 1,spriteram[offs] & 2, - sx,sy + xoffsethack, + sx,sy + state->xoffsethack, colortable_get_transpen_mask(screen->machine->colortable, screen->machine->gfx[1], color & 0x3f, 0)); } return 0; @@ -434,27 +435,31 @@ SCREEN_UPDATE( s2650games ) WRITE8_HANDLER( s2650games_videoram_w ) { - pacman_videoram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap,offset); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap,offset); } WRITE8_HANDLER( s2650games_colorram_w ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); int i; - pacman_colorram[offset & 0x1f] = data; + state->colorram[offset & 0x1f] = data; for (i = offset; i < 0x0400; i += 32) - tilemap_mark_tile_dirty(bg_tilemap, i); + tilemap_mark_tile_dirty(state->bg_tilemap, i); } WRITE8_HANDLER( s2650games_scroll_w ) { - tilemap_set_scrolly(bg_tilemap, offset, data); + pacman_state *state = space->machine->driver_data<pacman_state>(); + tilemap_set_scrolly(state->bg_tilemap, offset, data); } WRITE8_HANDLER( s2650games_tilesbank_w ) { - s2650games_tileram[offset] = data; - tilemap_mark_all_tiles_dirty(bg_tilemap); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->s2650games_tileram[offset] = data; + tilemap_mark_all_tiles_dirty(state->bg_tilemap); } @@ -494,6 +499,7 @@ static TILEMAP_MAPPER( jrpacman_scan_rows ) static TILE_GET_INFO( jrpacman_get_tile_info ) { + pacman_state *state = machine->driver_data<pacman_state>(); int color_index, code, attr; if( tile_index < 1792 ) { @@ -504,32 +510,33 @@ static TILE_GET_INFO( jrpacman_get_tile_info ) color_index = tile_index + 0x80; } - code = pacman_videoram[tile_index] | (charbank << 8); - attr = (pacman_videoram[color_index] & 0x1f) | (colortablebank << 5) | (palettebank << 6 ); + code = state->videoram[tile_index] | (state->charbank << 8); + attr = (state->videoram[color_index] & 0x1f) | (state->colortablebank << 5) | (state->palettebank << 6 ); SET_TILE_INFO(0,code,attr,0); } -static void jrpacman_mark_tile_dirty( int offset ) +static void jrpacman_mark_tile_dirty( running_machine *machine, int offset ) { + pacman_state *state = machine->driver_data<pacman_state>(); if( offset < 0x20 ) { /* line color - mark whole line as dirty */ int i; for( i = 2 * 0x20; i < 56 * 0x20; i += 0x20 ) { - tilemap_mark_tile_dirty( bg_tilemap, offset + i ); + tilemap_mark_tile_dirty( state->bg_tilemap, offset + i ); } } else if (offset < 1792) { /* tiles for playfield */ - tilemap_mark_tile_dirty( bg_tilemap, offset ); + tilemap_mark_tile_dirty( state->bg_tilemap, offset ); } else { /* tiles & colors for top and bottom two rows */ - tilemap_mark_tile_dirty( bg_tilemap, offset & ~0x80 ); + tilemap_mark_tile_dirty( state->bg_tilemap, offset & ~0x80 ); } } @@ -540,53 +547,59 @@ static void jrpacman_mark_tile_dirty( int offset ) ***************************************************************************/ VIDEO_START( jrpacman ) { + pacman_state *state = machine->driver_data<pacman_state>(); init_save_state(machine); - charbank = 0; - spritebank = 0; - palettebank = 0; - colortablebank = 0; - flipscreen = 0; - bgpriority = 0; + state->charbank = 0; + state->spritebank = 0; + state->palettebank = 0; + state->colortablebank = 0; + state->flipscreen = 0; + state->bgpriority = 0; - xoffsethack = 1; + state->xoffsethack = 1; - bg_tilemap = tilemap_create( machine, jrpacman_get_tile_info,jrpacman_scan_rows,8,8,36,54 ); + state->bg_tilemap = tilemap_create( machine, jrpacman_get_tile_info,jrpacman_scan_rows,8,8,36,54 ); - tilemap_set_transparent_pen( bg_tilemap, 0 ); - tilemap_set_scroll_cols( bg_tilemap, 36 ); + tilemap_set_transparent_pen( state->bg_tilemap, 0 ); + tilemap_set_scroll_cols( state->bg_tilemap, 36 ); } WRITE8_HANDLER( jrpacman_videoram_w ) { - pacman_videoram[offset] = data; - jrpacman_mark_tile_dirty(offset); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->videoram[offset] = data; + jrpacman_mark_tile_dirty(space->machine, offset); } WRITE8_HANDLER( jrpacman_charbank_w ) { - if (charbank != (data & 1)) + pacman_state *state = space->machine->driver_data<pacman_state>(); + if (state->charbank != (data & 1)) { - charbank = data & 1; - tilemap_mark_all_tiles_dirty(bg_tilemap); + state->charbank = data & 1; + tilemap_mark_all_tiles_dirty(state->bg_tilemap); } } WRITE8_HANDLER( jrpacman_spritebank_w ) { - spritebank = (data & 1); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->spritebank = (data & 1); } WRITE8_HANDLER( jrpacman_scroll_w ) { + pacman_state *state = space->machine->driver_data<pacman_state>(); int i; for( i = 2; i < 34; i++ ) { - tilemap_set_scrolly( bg_tilemap, i, data ); + tilemap_set_scrolly( state->bg_tilemap, i, data ); } } WRITE8_HANDLER( jrpacman_bgpriority_w ) { - bgpriority = (data & 1); + pacman_state *state = space->machine->driver_data<pacman_state>(); + state->bgpriority = (data & 1); } diff --git a/src/mame/video/seibuspi.c b/src/mame/video/seibuspi.c index 35860041874..f7ba2953d75 100644 --- a/src/mame/video/seibuspi.c +++ b/src/mame/video/seibuspi.c @@ -1,151 +1,131 @@ #include "emu.h" #include "includes/seibuspi.h" -static tilemap_t *text_layer; -static tilemap_t *back_layer; -static tilemap_t *mid_layer; -static tilemap_t *fore_layer; - -UINT32 *spi_scrollram; - -static UINT32 layer_bank; -static UINT32 layer_enable; -static UINT32 video_dma_length; -static UINT32 video_dma_address; -static UINT32 sprite_dma_length; - -static int rf2_layer_bank[3]; -static UINT32 *tilemap_ram; -static UINT32 *palette_ram; -static UINT32 *sprite_ram; - -static int mid_layer_offset; -static int fore_layer_offset; -static int text_layer_offset; - -static UINT32 bg_fore_layer_position; - -static UINT8 alpha_table[8192]; -static UINT8 sprite_bpp; READ32_HANDLER( spi_layer_bank_r ) { - return layer_bank; + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + return state->layer_bank; } WRITE32_HANDLER( spi_layer_bank_w ) { - COMBINE_DATA( &layer_bank ); + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + COMBINE_DATA( &state->layer_bank ); - if (layer_bank & 0x80000000) { - fore_layer_offset = 0x1000 / 4; - mid_layer_offset = 0x2000 / 4; - text_layer_offset = 0x3000 / 4; + if (state->layer_bank & 0x80000000) { + state->fore_layer_offset = 0x1000 / 4; + state->mid_layer_offset = 0x2000 / 4; + state->text_layer_offset = 0x3000 / 4; } else { - fore_layer_offset = 0x800 / 4; - mid_layer_offset = 0x1000 / 4; - text_layer_offset = 0x1800 / 4; + state->fore_layer_offset = 0x800 / 4; + state->mid_layer_offset = 0x1000 / 4; + state->text_layer_offset = 0x1800 / 4; } } -void rf2_set_layer_banks(int banks) +void rf2_set_layer_banks(running_machine *machine, int banks) { - if (rf2_layer_bank[0] != BIT(banks,0)) + seibuspi_state *state = machine->driver_data<seibuspi_state>(); + if (state->rf2_layer_bank[0] != BIT(banks,0)) { - rf2_layer_bank[0] = BIT(banks,0); - tilemap_mark_all_tiles_dirty(back_layer); + state->rf2_layer_bank[0] = BIT(banks,0); + tilemap_mark_all_tiles_dirty(state->back_layer); } - if (rf2_layer_bank[1] != BIT(banks,1)) + if (state->rf2_layer_bank[1] != BIT(banks,1)) { - rf2_layer_bank[1] = BIT(banks,1); - tilemap_mark_all_tiles_dirty(mid_layer); + state->rf2_layer_bank[1] = BIT(banks,1); + tilemap_mark_all_tiles_dirty(state->mid_layer); } - if (rf2_layer_bank[2] != BIT(banks,2)) + if (state->rf2_layer_bank[2] != BIT(banks,2)) { - rf2_layer_bank[2] = BIT(banks,2); - tilemap_mark_all_tiles_dirty(fore_layer); + state->rf2_layer_bank[2] = BIT(banks,2); + tilemap_mark_all_tiles_dirty(state->fore_layer); } } #ifdef UNUSED_FUNCTION READ32_HANDLER( spi_layer_enable_r ) { - return layer_enable; + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + return state->layer_enable; } #endif WRITE32_HANDLER( spi_layer_enable_w ) { - COMBINE_DATA( &layer_enable ); - tilemap_set_enable(back_layer, (layer_enable & 0x1) ^ 0x1); - tilemap_set_enable(mid_layer, ((layer_enable >> 1) & 0x1) ^ 0x1); - tilemap_set_enable(fore_layer, ((layer_enable >> 2) & 0x1) ^ 0x1); + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + COMBINE_DATA( &state->layer_enable ); + tilemap_set_enable(state->back_layer, (state->layer_enable & 0x1) ^ 0x1); + tilemap_set_enable(state->mid_layer, ((state->layer_enable >> 1) & 0x1) ^ 0x1); + tilemap_set_enable(state->fore_layer, ((state->layer_enable >> 2) & 0x1) ^ 0x1); } WRITE32_HANDLER( tilemap_dma_start_w ) { - if (video_dma_address != 0) + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + if (state->video_dma_address != 0) { int i; - int index = (video_dma_address / 4) - 0x200; + int index = (state->video_dma_address / 4) - 0x200; - if (layer_bank & 0x80000000) + if (state->layer_bank & 0x80000000) { /* back layer */ for (i=0; i < 0x800/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i] != tile) { - tilemap_ram[i] = tile; - tilemap_mark_tile_dirty( back_layer, (i * 2) ); - tilemap_mark_tile_dirty( back_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i] != tile) { + state->tilemap_ram[i] = tile; + tilemap_mark_tile_dirty( state->back_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->back_layer, (i * 2) + 1 ); } index++; } /* back layer row scroll */ - memcpy(&tilemap_ram[0x800/4], &spimainram[index], 0x800/4); + memcpy(&state->tilemap_ram[0x800/4], &state->spimainram[index], 0x800/4); index += 0x800/4; /* fore layer */ for (i=0; i < 0x800/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i+fore_layer_offset] != tile) { - tilemap_ram[i+fore_layer_offset] = tile; - tilemap_mark_tile_dirty( fore_layer, (i * 2) ); - tilemap_mark_tile_dirty( fore_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i+state->fore_layer_offset] != tile) { + state->tilemap_ram[i+state->fore_layer_offset] = tile; + tilemap_mark_tile_dirty( state->fore_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->fore_layer, (i * 2) + 1 ); } index++; } /* fore layer row scroll */ - memcpy(&tilemap_ram[0x1800/4], &spimainram[index], 0x800/4); + memcpy(&state->tilemap_ram[0x1800/4], &state->spimainram[index], 0x800/4); index += 0x800/4; /* mid layer */ for (i=0; i < 0x800/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i+mid_layer_offset] != tile) { - tilemap_ram[i+mid_layer_offset] = tile; - tilemap_mark_tile_dirty( mid_layer, (i * 2) ); - tilemap_mark_tile_dirty( mid_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i+state->mid_layer_offset] != tile) { + state->tilemap_ram[i+state->mid_layer_offset] = tile; + tilemap_mark_tile_dirty( state->mid_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->mid_layer, (i * 2) + 1 ); } index++; } /* mid layer row scroll */ - memcpy(&tilemap_ram[0x1800/4], &spimainram[index], 0x800/4); + memcpy(&state->tilemap_ram[0x1800/4], &state->spimainram[index], 0x800/4); index += 0x800/4; /* text layer */ for (i=0; i < 0x1000/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i+text_layer_offset] != tile) { - tilemap_ram[i+text_layer_offset] = tile; - tilemap_mark_tile_dirty( text_layer, (i * 2) ); - tilemap_mark_tile_dirty( text_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i+state->text_layer_offset] != tile) { + state->tilemap_ram[i+state->text_layer_offset] = tile; + tilemap_mark_tile_dirty( state->text_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->text_layer, (i * 2) + 1 ); } index++; } @@ -154,44 +134,44 @@ WRITE32_HANDLER( tilemap_dma_start_w ) { /* back layer */ for (i=0; i < 0x800/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i] != tile) { - tilemap_ram[i] = tile; - tilemap_mark_tile_dirty( back_layer, (i * 2) ); - tilemap_mark_tile_dirty( back_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i] != tile) { + state->tilemap_ram[i] = tile; + tilemap_mark_tile_dirty( state->back_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->back_layer, (i * 2) + 1 ); } index++; } /* fore layer */ for (i=0; i < 0x800/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i+fore_layer_offset] != tile) { - tilemap_ram[i+fore_layer_offset] = tile; - tilemap_mark_tile_dirty( fore_layer, (i * 2) ); - tilemap_mark_tile_dirty( fore_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i+state->fore_layer_offset] != tile) { + state->tilemap_ram[i+state->fore_layer_offset] = tile; + tilemap_mark_tile_dirty( state->fore_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->fore_layer, (i * 2) + 1 ); } index++; } /* mid layer */ for (i=0; i < 0x800/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i+mid_layer_offset] != tile) { - tilemap_ram[i+mid_layer_offset] = tile; - tilemap_mark_tile_dirty( mid_layer, (i * 2) ); - tilemap_mark_tile_dirty( mid_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i+state->mid_layer_offset] != tile) { + state->tilemap_ram[i+state->mid_layer_offset] = tile; + tilemap_mark_tile_dirty( state->mid_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->mid_layer, (i * 2) + 1 ); } index++; } /* text layer */ for (i=0; i < 0x1000/4; i++) { - UINT32 tile = spimainram[index]; - if (tilemap_ram[i+text_layer_offset] != tile) { - tilemap_ram[i+text_layer_offset] = tile; - tilemap_mark_tile_dirty( text_layer, (i * 2) ); - tilemap_mark_tile_dirty( text_layer, (i * 2) + 1 ); + UINT32 tile = state->spimainram[index]; + if (state->tilemap_ram[i+state->text_layer_offset] != tile) { + state->tilemap_ram[i+state->text_layer_offset] = tile; + tilemap_mark_tile_dirty( state->text_layer, (i * 2) ); + tilemap_mark_tile_dirty( state->text_layer, (i * 2) + 1 ); } index++; } @@ -201,16 +181,17 @@ WRITE32_HANDLER( tilemap_dma_start_w ) WRITE32_HANDLER( palette_dma_start_w ) { - if (video_dma_address != 0) + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + if (state->video_dma_address != 0) { int i; - for (i=0; i < ((video_dma_length+1) * 2) / 4; i++) + for (i=0; i < ((state->video_dma_length+1) * 2) / 4; i++) { - UINT32 color = spimainram[(video_dma_address / 4) + i - 0x200]; - if (palette_ram[i] != color) { - palette_ram[i] = color; - palette_set_color_rgb( space->machine, (i * 2), pal5bit(palette_ram[i] >> 0), pal5bit(palette_ram[i] >> 5), pal5bit(palette_ram[i] >> 10) ); - palette_set_color_rgb( space->machine, (i * 2) + 1, pal5bit(palette_ram[i] >> 16), pal5bit(palette_ram[i] >> 21), pal5bit(palette_ram[i] >> 26) ); + UINT32 color = state->spimainram[(state->video_dma_address / 4) + i - 0x200]; + if (state->palette_ram[i] != color) { + state->palette_ram[i] = color; + palette_set_color_rgb( space->machine, (i * 2), pal5bit(state->palette_ram[i] >> 0), pal5bit(state->palette_ram[i] >> 5), pal5bit(state->palette_ram[i] >> 10) ); + palette_set_color_rgb( space->machine, (i * 2) + 1, pal5bit(state->palette_ram[i] >> 16), pal5bit(state->palette_ram[i] >> 21), pal5bit(state->palette_ram[i] >> 26) ); } } } @@ -218,24 +199,28 @@ WRITE32_HANDLER( palette_dma_start_w ) WRITE32_HANDLER( sprite_dma_start_w ) { - if (video_dma_address != 0) + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + if (state->video_dma_address != 0) { - memcpy( sprite_ram, &spimainram[(video_dma_address / 4) - 0x200], sprite_dma_length); + memcpy( state->sprite_ram, &state->spimainram[(state->video_dma_address / 4) - 0x200], state->sprite_dma_length); } } WRITE32_HANDLER( video_dma_length_w ) { - COMBINE_DATA( &video_dma_length ); + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + COMBINE_DATA( &state->video_dma_length ); } WRITE32_HANDLER( video_dma_address_w ) { - COMBINE_DATA( &video_dma_address ); + seibuspi_state *state = space->machine->driver_data<seibuspi_state>(); + COMBINE_DATA( &state->video_dma_address ); } static void drawgfx_blend(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy) { + seibuspi_state *state = gfx->machine->driver_data<seibuspi_state>(); const pen_t *pens = &gfx->machine->pens[gfx->color_base]; const UINT8 *dp; int i, j; @@ -322,7 +307,7 @@ static void drawgfx_blend(bitmap_t *bitmap, const rectangle *cliprect, const gfx for (j=y1; j <= y2; j++) { UINT32 *p = BITMAP_ADDR32(bitmap, j, 0); - UINT8 trans_pen = (1 << sprite_bpp) - 1; + UINT8 trans_pen = (1 << state->sprite_bpp) - 1; int dp_i = (py * width) + px; py += yd; @@ -331,8 +316,8 @@ static void drawgfx_blend(bitmap_t *bitmap, const rectangle *cliprect, const gfx UINT8 pen = dp[dp_i]; if (pen != trans_pen) { - int global_pen = pen + (color << sprite_bpp); - UINT8 alpha = alpha_table[global_pen]; + int global_pen = pen + (color << state->sprite_bpp); + UINT8 alpha = state->alpha_table[global_pen]; if (alpha) { p[i] = alpha_blend_r32(p[i], pens[global_pen], 0x7f); @@ -360,6 +345,7 @@ static const int sprite_ytable[2][8] = static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri_mask) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); INT16 xpos, ypos; int tile_num, color; int width, height; @@ -369,33 +355,33 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta int x,y, x1, y1; const gfx_element *gfx = machine->gfx[2]; - if( layer_enable & 0x10 ) + if( state->layer_enable & 0x10 ) return; - for( a = (sprite_dma_length / 4) - 2; a >= 0; a -= 2 ) { - tile_num = (sprite_ram[a + 0] >> 16) & 0xffff; - if( sprite_ram[a + 1] & 0x1000 ) + for( a = (state->sprite_dma_length / 4) - 2; a >= 0; a -= 2 ) { + tile_num = (state->sprite_ram[a + 0] >> 16) & 0xffff; + if( state->sprite_ram[a + 1] & 0x1000 ) tile_num |= 0x10000; if( !tile_num ) continue; - priority = (sprite_ram[a + 0] >> 6) & 0x3; + priority = (state->sprite_ram[a + 0] >> 6) & 0x3; if( pri_mask != priority ) continue; - xpos = sprite_ram[a + 1] & 0x3ff; + xpos = state->sprite_ram[a + 1] & 0x3ff; if( xpos & 0x200 ) xpos |= 0xfc00; - ypos = (sprite_ram[a + 1] >> 16) & 0x1ff; + ypos = (state->sprite_ram[a + 1] >> 16) & 0x1ff; if( ypos & 0x100 ) ypos |= 0xfe00; - color = (sprite_ram[a + 0] & 0x3f); + color = (state->sprite_ram[a + 0] & 0x3f); - width = ((sprite_ram[a + 0] >> 8) & 0x7) + 1; - height = ((sprite_ram[a + 0] >> 12) & 0x7) + 1; - flip_x = (sprite_ram[a + 0] >> 11) & 0x1; - flip_y = (sprite_ram[a + 0] >> 15) & 0x1; + width = ((state->sprite_ram[a + 0] >> 8) & 0x7) + 1; + height = ((state->sprite_ram[a + 0] >> 12) & 0x7) + 1; + flip_x = (state->sprite_ram[a + 0] >> 11) & 0x1; + flip_y = (state->sprite_ram[a + 0] >> 15) & 0x1; x1 = 0; y1 = 0; @@ -425,8 +411,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta static TILE_GET_INFO( get_text_tile_info ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int offs = tile_index / 2; - int tile = (tilemap_ram[offs + text_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; + int tile = (state->tilemap_ram[offs + state->text_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; int color = (tile >> 12) & 0xf; tile &= 0xfff; @@ -436,13 +423,14 @@ static TILE_GET_INFO( get_text_tile_info ) static TILE_GET_INFO( get_back_tile_info ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int offs = tile_index / 2; - int tile = (tilemap_ram[offs] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; + int tile = (state->tilemap_ram[offs] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; int color = (tile >> 13) & 0x7; tile &= 0x1fff; - if( rf2_layer_bank[0] ) + if( state->rf2_layer_bank[0] ) tile |= 0x4000; SET_TILE_INFO(1, tile, color, 0); @@ -450,14 +438,15 @@ static TILE_GET_INFO( get_back_tile_info ) static TILE_GET_INFO( get_mid_tile_info ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int offs = tile_index / 2; - int tile = (tilemap_ram[offs + mid_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; + int tile = (state->tilemap_ram[offs + state->mid_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; int color = (tile >> 13) & 0x7; tile &= 0x1fff; tile |= 0x2000; - if( rf2_layer_bank[1] ) + if( state->rf2_layer_bank[1] ) tile |= 0x4000; SET_TILE_INFO(1, tile, color + 16, 0); @@ -465,89 +454,92 @@ static TILE_GET_INFO( get_mid_tile_info ) static TILE_GET_INFO( get_fore_tile_info ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int offs = tile_index / 2; - int tile = (tilemap_ram[offs + fore_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; + int tile = (state->tilemap_ram[offs + state->fore_layer_offset] >> ((tile_index & 0x1) ? 16 : 0)) & 0xffff; int color = (tile >> 13) & 0x7; tile &= 0x1fff; - tile |= bg_fore_layer_position; + tile |= state->bg_fore_layer_position; - if( rf2_layer_bank[2] ) + if( state->rf2_layer_bank[2] ) tile |= 0x4000; - tile |= ((layer_bank >> 27) & 0x1) << 13; + tile |= ((state->layer_bank >> 27) & 0x1) << 13; SET_TILE_INFO(1, tile, color + 8, 0); } VIDEO_START( spi ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int i; int region_length; - text_layer = tilemap_create( machine, get_text_tile_info, tilemap_scan_rows, 8,8,64,32 ); - back_layer = tilemap_create( machine, get_back_tile_info, tilemap_scan_cols, 16,16,32,32 ); - mid_layer = tilemap_create( machine, get_mid_tile_info, tilemap_scan_cols, 16,16,32,32 ); - fore_layer = tilemap_create( machine, get_fore_tile_info, tilemap_scan_cols, 16,16,32,32 ); + state->text_layer = tilemap_create( machine, get_text_tile_info, tilemap_scan_rows, 8,8,64,32 ); + state->back_layer = tilemap_create( machine, get_back_tile_info, tilemap_scan_cols, 16,16,32,32 ); + state->mid_layer = tilemap_create( machine, get_mid_tile_info, tilemap_scan_cols, 16,16,32,32 ); + state->fore_layer = tilemap_create( machine, get_fore_tile_info, tilemap_scan_cols, 16,16,32,32 ); - tilemap_set_transparent_pen(text_layer, 31); - tilemap_set_transparent_pen(mid_layer, 63); - tilemap_set_transparent_pen(fore_layer, 63); + tilemap_set_transparent_pen(state->text_layer, 31); + tilemap_set_transparent_pen(state->mid_layer, 63); + tilemap_set_transparent_pen(state->fore_layer, 63); - tilemap_ram = auto_alloc_array_clear(machine, UINT32, 0x4000/4); - palette_ram = auto_alloc_array_clear(machine, UINT32, 0x3000/4); - sprite_ram = auto_alloc_array_clear(machine, UINT32, 0x1000/4); + state->tilemap_ram = auto_alloc_array_clear(machine, UINT32, 0x4000/4); + state->palette_ram = auto_alloc_array_clear(machine, UINT32, 0x3000/4); + state->sprite_ram = auto_alloc_array_clear(machine, UINT32, 0x1000/4); - sprite_bpp = 6; - sprite_dma_length = 0x1000; + state->sprite_bpp = 6; + state->sprite_dma_length = 0x1000; for (i=0; i < 6144; i++) { palette_set_color(machine, i, MAKE_RGB(0, 0, 0)); } - memset(alpha_table, 0, 6144 * sizeof(UINT8)); + memset(state->alpha_table, 0, 6144 * sizeof(UINT8)); // sprites - //for (i = 1792; i < 1808; i++) { alpha_table[i] = 1; } // breaks rdft - for (i = 1840; i < 1856; i++) { alpha_table[i] = 1; } - for (i = 1920; i < 1952; i++) { alpha_table[i] = 1; } - //for (i = 1984; i < 2048; i++) { alpha_table[i] = 1; } // breaks batlball - //for (i = 3840; i < 3904; i++) { alpha_table[i] = 1; } // breaks rdft - for (i = 4032; i < 4096; i++) { alpha_table[i] = 1; } + //for (i = 1792; i < 1808; i++) { state->alpha_table[i] = 1; } // breaks rdft + for (i = 1840; i < 1856; i++) { state->alpha_table[i] = 1; } + for (i = 1920; i < 1952; i++) { state->alpha_table[i] = 1; } + //for (i = 1984; i < 2048; i++) { state->alpha_table[i] = 1; } // breaks batlball + //for (i = 3840; i < 3904; i++) { state->alpha_table[i] = 1; } // breaks rdft + for (i = 4032; i < 4096; i++) { state->alpha_table[i] = 1; } // mid layer - for (i = 4960; i < 4992; i++) { alpha_table[i] = 1; } // breaks ejanhs - for (i = 5040; i < 5056; i++) { alpha_table[i] = 1; } // breaks ejanhs - for (i = 5104; i < 5120; i++) { alpha_table[i] = 1; } + for (i = 4960; i < 4992; i++) { state->alpha_table[i] = 1; } // breaks ejanhs + for (i = 5040; i < 5056; i++) { state->alpha_table[i] = 1; } // breaks ejanhs + for (i = 5104; i < 5120; i++) { state->alpha_table[i] = 1; } // fore layer - for (i = 5552; i < 5568; i++) { alpha_table[i] = 1; } // breaks ejanhs - for (i = 5616; i < 5632; i++) { alpha_table[i] = 1; } // breaks ejanhs + for (i = 5552; i < 5568; i++) { state->alpha_table[i] = 1; } // breaks ejanhs + for (i = 5616; i < 5632; i++) { state->alpha_table[i] = 1; } // breaks ejanhs // text layer - for (i = 6000; i < 6016; i++) { alpha_table[i] = 1; } - for (i = 6128; i < 6144; i++) { alpha_table[i] = 1; } + for (i = 6000; i < 6016; i++) { state->alpha_table[i] = 1; } + for (i = 6128; i < 6144; i++) { state->alpha_table[i] = 1; } region_length = machine->region("gfx2")->bytes(); if (region_length <= 0x300000) { - bg_fore_layer_position = 0x2000; + state->bg_fore_layer_position = 0x2000; } else if (region_length <= 0x600000) { - bg_fore_layer_position = 0x4000; + state->bg_fore_layer_position = 0x4000; } else { - bg_fore_layer_position = 0x8000; + state->bg_fore_layer_position = 0x8000; } } #ifdef UNUSED_FUNCTION static void set_rowscroll(tilemap_t *layer, int scroll, INT16* rows) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int i; - int x = spi_scrollram[scroll] & 0xffff; - int y = (spi_scrollram[scroll] >> 16) & 0xffff; + int x = state->spi_scrollram[scroll] & 0xffff; + int y = (state->spi_scrollram[scroll] >> 16) & 0xffff; tilemap_set_scroll_rows(layer, 512); for( i=0; i < 512; i++ ) { tilemap_set_scrollx(layer, i, x + rows[i]); @@ -557,8 +549,9 @@ static void set_rowscroll(tilemap_t *layer, int scroll, INT16* rows) static void set_scroll(tilemap_t *layer, int scroll) { - int x = spi_scrollram[scroll] & 0xffff; - int y = (spi_scrollram[scroll] >> 16) & 0xffff; + seibuspi_state *state = machine->driver_data<seibuspi_state>(); + int x = state->spi_scrollram[scroll] & 0xffff; + int y = (state->spi_scrollram[scroll] >> 16) & 0xffff; tilemap_set_scrollx(layer, 0, x); tilemap_set_scrolly(layer, 0, y); } @@ -567,6 +560,7 @@ static void set_scroll(tilemap_t *layer, int scroll) static void combine_tilemap(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap_t *tile, int x, int y, int opaque, INT16 *rowscroll) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int i,j; UINT16 *s; UINT32 *d; @@ -596,7 +590,7 @@ static void combine_tilemap(running_machine *machine, bitmap_t *bitmap, const re if (opaque || (t[i & xscroll_mask] & (TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1))) { UINT16 pen = s[i & xscroll_mask]; - UINT8 alpha = alpha_table[pen]; + UINT8 alpha = state->alpha_table[pen]; if (alpha) { *d = alpha_blend_r32(*d, machine->pens[pen], 0x7f); @@ -615,63 +609,65 @@ static void combine_tilemap(running_machine *machine, bitmap_t *bitmap, const re SCREEN_UPDATE( spi ) { + seibuspi_state *state = screen->machine->driver_data<seibuspi_state>(); INT16 *back_rowscroll, *mid_rowscroll, *fore_rowscroll; - if( layer_bank & 0x80000000 ) { - back_rowscroll = (INT16*)&tilemap_ram[0x200]; - mid_rowscroll = (INT16*)&tilemap_ram[0x600]; - fore_rowscroll = (INT16*)&tilemap_ram[0xa00]; + if( state->layer_bank & 0x80000000 ) { + back_rowscroll = (INT16*)&state->tilemap_ram[0x200]; + mid_rowscroll = (INT16*)&state->tilemap_ram[0x600]; + fore_rowscroll = (INT16*)&state->tilemap_ram[0xa00]; } else { back_rowscroll = NULL; mid_rowscroll = NULL; fore_rowscroll = NULL; } - if( layer_enable & 0x1 ) + if( state->layer_enable & 0x1 ) bitmap_fill(bitmap, cliprect, 0); - if (!(layer_enable & 0x1)) - combine_tilemap(screen->machine, bitmap, cliprect, back_layer, spi_scrollram[0] & 0xffff, (spi_scrollram[0] >> 16) & 0xffff, 1, back_rowscroll); + if (!(state->layer_enable & 0x1)) + combine_tilemap(screen->machine, bitmap, cliprect, state->back_layer, state->spi_scrollram[0] & 0xffff, (state->spi_scrollram[0] >> 16) & 0xffff, 1, back_rowscroll); draw_sprites(screen->machine, bitmap, cliprect, 0); // if fore layer is enabled, draw priority 1 sprites behind mid layer - if (!(layer_enable & 0x4)) + if (!(state->layer_enable & 0x4)) draw_sprites(screen->machine, bitmap, cliprect, 1); - if (!(layer_enable & 0x2)) - combine_tilemap(screen->machine, bitmap, cliprect, mid_layer, spi_scrollram[1] & 0xffff, (spi_scrollram[1] >> 16) & 0xffff, 0, mid_rowscroll); + if (!(state->layer_enable & 0x2)) + combine_tilemap(screen->machine, bitmap, cliprect, state->mid_layer, state->spi_scrollram[1] & 0xffff, (state->spi_scrollram[1] >> 16) & 0xffff, 0, mid_rowscroll); // if fore layer is disabled, draw priority 1 sprites above mid layer - if ((layer_enable & 0x4)) + if ((state->layer_enable & 0x4)) draw_sprites(screen->machine, bitmap, cliprect, 1); draw_sprites(screen->machine, bitmap, cliprect, 2); - if (!(layer_enable & 0x4)) - combine_tilemap(screen->machine, bitmap, cliprect, fore_layer, spi_scrollram[2] & 0xffff, (spi_scrollram[2] >> 16) & 0xffff, 0, fore_rowscroll); + if (!(state->layer_enable & 0x4)) + combine_tilemap(screen->machine, bitmap, cliprect, state->fore_layer, state->spi_scrollram[2] & 0xffff, (state->spi_scrollram[2] >> 16) & 0xffff, 0, fore_rowscroll); draw_sprites(screen->machine, bitmap, cliprect, 3); - combine_tilemap(screen->machine, bitmap, cliprect, text_layer, 0, 0, 0, NULL); + combine_tilemap(screen->machine, bitmap, cliprect, state->text_layer, 0, 0, 0, NULL); return 0; } VIDEO_START( sys386f2 ) { + seibuspi_state *state = machine->driver_data<seibuspi_state>(); int i; - palette_ram = auto_alloc_array_clear(machine, UINT32, 0x4000/4); - sprite_ram = auto_alloc_array_clear(machine, UINT32, 0x2000/4); + state->palette_ram = auto_alloc_array_clear(machine, UINT32, 0x4000/4); + state->sprite_ram = auto_alloc_array_clear(machine, UINT32, 0x2000/4); - sprite_bpp = 8; - sprite_dma_length = 0x2000; - layer_enable = 0; + state->sprite_bpp = 8; + state->sprite_dma_length = 0x2000; + state->layer_enable = 0; for (i=0; i < 8192; i++) { palette_set_color(machine, i, MAKE_RGB(0, 0, 0)); } - memset(alpha_table, 0, 8192 * sizeof(UINT8)); + memset(state->alpha_table, 0, 8192 * sizeof(UINT8)); } SCREEN_UPDATE( sys386f2 ) diff --git a/src/mame/video/tetrisp2.c b/src/mame/video/tetrisp2.c index c2ed65a505e..9ade64309b7 100644 --- a/src/mame/video/tetrisp2.c +++ b/src/mame/video/tetrisp2.c @@ -35,22 +35,6 @@ To Do: #include "includes/tetrisp2.h" -/* Variables needed by driver: */ - -UINT16 *tetrisp2_vram_bg, *tetrisp2_scroll_bg; -UINT16 *tetrisp2_vram_fg, *tetrisp2_scroll_fg; -UINT16 *tetrisp2_vram_rot, *tetrisp2_rotregs; - -UINT8 *tetrisp2_priority; - -UINT16 *rocknms_sub_vram_bg, *rocknms_sub_scroll_bg; -UINT16 *rocknms_sub_vram_fg, *rocknms_sub_scroll_fg; -UINT16 *rocknms_sub_vram_rot, *rocknms_sub_rotregs; - -UINT16 *rocknms_sub_priority; - -static int flipscreen_old; - /*************************************************************************** @@ -86,38 +70,43 @@ WRITE16_HANDLER( rocknms_sub_palette_w ) WRITE8_HANDLER( tetrisp2_priority_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); //if (ACCESSING_BITS_8_15) { data |= ((data & 0xff00) >> 8); - tetrisp2_priority[offset] = data; + state->priority[offset] = data; } } WRITE8_HANDLER( rockn_priority_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); //if (ACCESSING_BITS_8_15) { - tetrisp2_priority[offset] = data; + state->priority[offset] = data; } } WRITE16_HANDLER( rocknms_sub_priority_w ) { + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); if (ACCESSING_BITS_8_15) { - rocknms_sub_priority[offset] = data; + state->rocknms_sub_priority[offset] = data; } } READ16_HANDLER( nndmseal_priority_r ) { - return tetrisp2_priority[offset] | 0xff00; + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + return state->priority[offset] | 0xff00; } READ8_HANDLER( tetrisp2_priority_r ) { - return tetrisp2_priority[offset]; + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + return state->priority[offset]; } /*************************************************************************** @@ -135,16 +124,15 @@ READ8_HANDLER( tetrisp2_priority_r ) ***************************************************************************/ -static tilemap_t *tilemap_bg, *tilemap_fg, *tilemap_rot; -static tilemap_t *tilemap_sub_bg, *tilemap_sub_fg, *tilemap_sub_rot; #define NX_0 (0x40) #define NY_0 (0x40) static TILE_GET_INFO( get_tile_info_bg ) { - UINT16 code_hi = tetrisp2_vram_bg[ 2 * tile_index + 0]; - UINT16 code_lo = tetrisp2_vram_bg[ 2 * tile_index + 1]; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + UINT16 code_hi = state->vram_bg[ 2 * tile_index + 0]; + UINT16 code_lo = state->vram_bg[ 2 * tile_index + 1]; SET_TILE_INFO( 1, code_hi, @@ -154,8 +142,9 @@ static TILE_GET_INFO( get_tile_info_bg ) WRITE16_HANDLER( tetrisp2_vram_bg_w ) { - COMBINE_DATA(&tetrisp2_vram_bg[offset]); - tilemap_mark_tile_dirty(tilemap_bg,offset/2); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + COMBINE_DATA(&state->vram_bg[offset]); + tilemap_mark_tile_dirty(state->tilemap_bg,offset/2); } @@ -165,8 +154,9 @@ WRITE16_HANDLER( tetrisp2_vram_bg_w ) static TILE_GET_INFO( get_tile_info_fg ) { - UINT16 code_hi = tetrisp2_vram_fg[ 2 * tile_index + 0]; - UINT16 code_lo = tetrisp2_vram_fg[ 2 * tile_index + 1]; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + UINT16 code_hi = state->vram_fg[ 2 * tile_index + 0]; + UINT16 code_lo = state->vram_fg[ 2 * tile_index + 1]; SET_TILE_INFO( 3, code_hi, @@ -176,15 +166,17 @@ static TILE_GET_INFO( get_tile_info_fg ) WRITE16_HANDLER( tetrisp2_vram_fg_w ) { - COMBINE_DATA(&tetrisp2_vram_fg[offset]); - tilemap_mark_tile_dirty(tilemap_fg,offset/2); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + COMBINE_DATA(&state->vram_fg[offset]); + tilemap_mark_tile_dirty(state->tilemap_fg,offset/2); } static TILE_GET_INFO( get_tile_info_rot ) { - UINT16 code_hi = tetrisp2_vram_rot[ 2 * tile_index + 0]; - UINT16 code_lo = tetrisp2_vram_rot[ 2 * tile_index + 1]; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + UINT16 code_hi = state->vram_rot[ 2 * tile_index + 0]; + UINT16 code_lo = state->vram_rot[ 2 * tile_index + 1]; SET_TILE_INFO( 2, code_hi, @@ -194,14 +186,16 @@ static TILE_GET_INFO( get_tile_info_rot ) WRITE16_HANDLER( tetrisp2_vram_rot_w ) { - COMBINE_DATA(&tetrisp2_vram_rot[offset]); - tilemap_mark_tile_dirty(tilemap_rot,offset/2); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + COMBINE_DATA(&state->vram_rot[offset]); + tilemap_mark_tile_dirty(state->tilemap_rot,offset/2); } static TILE_GET_INFO( get_tile_info_rocknms_sub_bg ) { - UINT16 code_hi = rocknms_sub_vram_bg[ 2 * tile_index + 0]; - UINT16 code_lo = rocknms_sub_vram_bg[ 2 * tile_index + 1]; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + UINT16 code_hi = state->rocknms_sub_vram_bg[ 2 * tile_index + 0]; + UINT16 code_lo = state->rocknms_sub_vram_bg[ 2 * tile_index + 1]; SET_TILE_INFO( 5, code_hi, @@ -211,15 +205,17 @@ static TILE_GET_INFO( get_tile_info_rocknms_sub_bg ) WRITE16_HANDLER( rocknms_sub_vram_bg_w ) { - COMBINE_DATA(&rocknms_sub_vram_bg[offset]); - tilemap_mark_tile_dirty(tilemap_sub_bg,offset/2); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + COMBINE_DATA(&state->rocknms_sub_vram_bg[offset]); + tilemap_mark_tile_dirty(state->tilemap_sub_bg,offset/2); } static TILE_GET_INFO( get_tile_info_rocknms_sub_fg ) { - UINT16 code_hi = rocknms_sub_vram_fg[ 2 * tile_index + 0]; - UINT16 code_lo = rocknms_sub_vram_fg[ 2 * tile_index + 1]; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + UINT16 code_hi = state->rocknms_sub_vram_fg[ 2 * tile_index + 0]; + UINT16 code_lo = state->rocknms_sub_vram_fg[ 2 * tile_index + 1]; SET_TILE_INFO( 7, code_hi, @@ -229,15 +225,17 @@ static TILE_GET_INFO( get_tile_info_rocknms_sub_fg ) WRITE16_HANDLER( rocknms_sub_vram_fg_w ) { - COMBINE_DATA(&rocknms_sub_vram_fg[offset]); - tilemap_mark_tile_dirty(tilemap_sub_fg,offset/2); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + COMBINE_DATA(&state->rocknms_sub_vram_fg[offset]); + tilemap_mark_tile_dirty(state->tilemap_sub_fg,offset/2); } static TILE_GET_INFO( get_tile_info_rocknms_sub_rot ) { - UINT16 code_hi = rocknms_sub_vram_rot[ 2 * tile_index + 0]; - UINT16 code_lo = rocknms_sub_vram_rot[ 2 * tile_index + 1]; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + UINT16 code_hi = state->rocknms_sub_vram_rot[ 2 * tile_index + 0]; + UINT16 code_lo = state->rocknms_sub_vram_rot[ 2 * tile_index + 1]; SET_TILE_INFO( 6, code_hi, @@ -247,88 +245,93 @@ static TILE_GET_INFO( get_tile_info_rocknms_sub_rot ) WRITE16_HANDLER( rocknms_sub_vram_rot_w ) { - COMBINE_DATA(&rocknms_sub_vram_rot[offset]); - tilemap_mark_tile_dirty(tilemap_sub_rot,offset/2); + tetrisp2_state *state = space->machine->driver_data<tetrisp2_state>(); + COMBINE_DATA(&state->rocknms_sub_vram_rot[offset]); + tilemap_mark_tile_dirty(state->tilemap_sub_rot,offset/2); } VIDEO_START( tetrisp2 ) { - flipscreen_old = -1; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + state->flipscreen_old = -1; - tilemap_bg = tilemap_create( machine, get_tile_info_bg,tilemap_scan_rows, + state->tilemap_bg = tilemap_create( machine, get_tile_info_bg,tilemap_scan_rows, 16,16,NX_0,NY_0); - tilemap_fg = tilemap_create( machine, get_tile_info_fg,tilemap_scan_rows, + state->tilemap_fg = tilemap_create( machine, get_tile_info_fg,tilemap_scan_rows, 8,8,NX_1,NY_1); - tilemap_rot = tilemap_create( machine, get_tile_info_rot,tilemap_scan_rows, + state->tilemap_rot = tilemap_create( machine, get_tile_info_rot,tilemap_scan_rows, 16,16,NX_0*2,NY_0*2); - tilemap_set_transparent_pen(tilemap_bg,0); - tilemap_set_transparent_pen(tilemap_fg,0); - tilemap_set_transparent_pen(tilemap_rot,0); + tilemap_set_transparent_pen(state->tilemap_bg,0); + tilemap_set_transparent_pen(state->tilemap_fg,0); + tilemap_set_transparent_pen(state->tilemap_rot,0); // should be smaller and mirrored like m32 I guess - tetrisp2_priority = auto_alloc_array(machine, UINT8, 0x40000); + state->priority = auto_alloc_array(machine, UINT8, 0x40000); ms32_rearrange_sprites(machine, "gfx1"); } VIDEO_START( nndmseal ) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); VIDEO_START_CALL( tetrisp2 ); - tilemap_set_scrolldx(tilemap_bg, -4,-4); + tilemap_set_scrolldx(state->tilemap_bg, -4,-4); } VIDEO_START( rockntread ) { - flipscreen_old = -1; + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); + state->flipscreen_old = -1; - tilemap_bg = tilemap_create( machine, get_tile_info_bg,tilemap_scan_rows, + state->tilemap_bg = tilemap_create( machine, get_tile_info_bg,tilemap_scan_rows, 16, 16, 256, 16); // rockn ms(main),1,2,3,4 - tilemap_fg = tilemap_create( machine, get_tile_info_fg,tilemap_scan_rows, + state->tilemap_fg = tilemap_create( machine, get_tile_info_fg,tilemap_scan_rows, 8, 8, 64, 64); - tilemap_rot = tilemap_create( machine, get_tile_info_rot,tilemap_scan_rows, + state->tilemap_rot = tilemap_create( machine, get_tile_info_rot,tilemap_scan_rows, 16, 16, 128, 128); - tilemap_set_transparent_pen(tilemap_bg, 0); - tilemap_set_transparent_pen(tilemap_fg, 0); - tilemap_set_transparent_pen(tilemap_rot, 0); + tilemap_set_transparent_pen(state->tilemap_bg, 0); + tilemap_set_transparent_pen(state->tilemap_fg, 0); + tilemap_set_transparent_pen(state->tilemap_rot, 0); // should be smaller and mirrored like m32 I guess - tetrisp2_priority = auto_alloc_array(machine, UINT8, 0x40000); + state->priority = auto_alloc_array(machine, UINT8, 0x40000); ms32_rearrange_sprites(machine, "gfx1"); } VIDEO_START( rocknms ) { + tetrisp2_state *state = machine->driver_data<tetrisp2_state>(); VIDEO_START_CALL( rockntread ); - tilemap_sub_bg = tilemap_create(machine, get_tile_info_rocknms_sub_bg,tilemap_scan_rows, + state->tilemap_sub_bg = tilemap_create(machine, get_tile_info_rocknms_sub_bg,tilemap_scan_rows, 16, 16, 32, 256); // rockn ms(sub) - tilemap_sub_fg = tilemap_create(machine, get_tile_info_rocknms_sub_fg,tilemap_scan_rows, + state->tilemap_sub_fg = tilemap_create(machine, get_tile_info_rocknms_sub_fg,tilemap_scan_rows, 8, 8, 64, 64); - tilemap_sub_rot = tilemap_create( machine, get_tile_info_rocknms_sub_rot,tilemap_scan_rows, + state->tilemap_sub_rot = tilemap_create( machine, get_tile_info_rocknms_sub_rot,tilemap_scan_rows, 16, 16, 128, 128); - tilemap_set_transparent_pen(tilemap_sub_bg, 0); - tilemap_set_transparent_pen(tilemap_sub_fg, 0); - tilemap_set_transparent_pen(tilemap_sub_rot, 0); + tilemap_set_transparent_pen(state->tilemap_sub_bg, 0); + tilemap_set_transparent_pen(state->tilemap_sub_fg, 0); + tilemap_set_transparent_pen(state->tilemap_sub_rot, 0); ms32_rearrange_sprites(machine, "gfx5"); } @@ -458,22 +461,23 @@ static void tetrisp2_draw_sprites(running_machine *machine, bitmap_t *bitmap, bi SCREEN_UPDATE( tetrisp2 ) { + tetrisp2_state *state = screen->machine->driver_data<tetrisp2_state>(); int flipscreen; int asc_pri; int scr_pri; int rot_pri; int rot_ofsx, rot_ofsy; - flipscreen = (tetrisp2_systemregs[0x00] & 0x02); + flipscreen = (state->systemregs[0x00] & 0x02); /* Black background color */ bitmap_fill(bitmap, cliprect, 0); bitmap_fill(screen->machine->priority_bitmap, NULL, 0); /* Flip Screen */ - if (flipscreen != flipscreen_old) + if (flipscreen != state->flipscreen_old) { - flipscreen_old = flipscreen; + state->flipscreen_old = flipscreen; tilemap_set_flip_all(screen->machine, flipscreen ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0); } @@ -489,75 +493,76 @@ SCREEN_UPDATE( tetrisp2 ) rot_ofsy = 0x400; } - tilemap_set_scrollx(tilemap_bg, 0, (((tetrisp2_scroll_bg[ 0 ] + 0x0014) + tetrisp2_scroll_bg[ 2 ] ) & 0xffff)); - tilemap_set_scrolly(tilemap_bg, 0, (((tetrisp2_scroll_bg[ 3 ] + 0x0000) + tetrisp2_scroll_bg[ 5 ] ) & 0xffff)); + tilemap_set_scrollx(state->tilemap_bg, 0, (((state->scroll_bg[ 0 ] + 0x0014) + state->scroll_bg[ 2 ] ) & 0xffff)); + tilemap_set_scrolly(state->tilemap_bg, 0, (((state->scroll_bg[ 3 ] + 0x0000) + state->scroll_bg[ 5 ] ) & 0xffff)); - tilemap_set_scrollx(tilemap_fg, 0, tetrisp2_scroll_fg[ 2 ]); - tilemap_set_scrolly(tilemap_fg, 0, tetrisp2_scroll_fg[ 5 ]); + tilemap_set_scrollx(state->tilemap_fg, 0, state->scroll_fg[ 2 ]); + tilemap_set_scrolly(state->tilemap_fg, 0, state->scroll_fg[ 5 ]); - tilemap_set_scrollx(tilemap_rot, 0, (tetrisp2_rotregs[ 0 ] - rot_ofsx)); - tilemap_set_scrolly(tilemap_rot, 0, (tetrisp2_rotregs[ 2 ] - rot_ofsy)); + tilemap_set_scrollx(state->tilemap_rot, 0, (state->rotregs[ 0 ] - rot_ofsx)); + tilemap_set_scrolly(state->tilemap_rot, 0, (state->rotregs[ 2 ] - rot_ofsy)); asc_pri = scr_pri = rot_pri = 0; - if((tetrisp2_priority[0x2b00 / 2] & 0x00ff) == 0x0034) + if((state->priority[0x2b00 / 2] & 0x00ff) == 0x0034) asc_pri++; else rot_pri++; - if((tetrisp2_priority[0x2e00 / 2] & 0x00ff) == 0x0034) + if((state->priority[0x2e00 / 2] & 0x00ff) == 0x0034) asc_pri++; else scr_pri++; - if((tetrisp2_priority[0x3a00 / 2] & 0x00ff) == 0x000c) + if((state->priority[0x3a00 / 2] & 0x00ff) == 0x000c) scr_pri++; else rot_pri++; if (rot_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); if (rot_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); if (rot_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); - tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap, cliprect, tetrisp2_priority, screen->machine->generic.spriteram.u16, screen->machine->generic.spriteram_size, 0, (tetrisp2_systemregs[0x00] & 0x02)); + tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap, cliprect, state->priority, screen->machine->generic.spriteram.u16, screen->machine->generic.spriteram_size, 0, (state->systemregs[0x00] & 0x02)); return 0; } SCREEN_UPDATE( rockntread ) { + tetrisp2_state *state = screen->machine->driver_data<tetrisp2_state>(); int flipscreen; int asc_pri; int scr_pri; int rot_pri; int rot_ofsx, rot_ofsy; - flipscreen = (tetrisp2_systemregs[0x00] & 0x02); + flipscreen = (state->systemregs[0x00] & 0x02); /* Black background color */ bitmap_fill(bitmap, cliprect, 0); bitmap_fill(screen->machine->priority_bitmap, NULL, 0); /* Flip Screen */ - if (flipscreen != flipscreen_old) + if (flipscreen != state->flipscreen_old) { - flipscreen_old = flipscreen; + state->flipscreen_old = flipscreen; tilemap_set_flip_all(screen->machine, flipscreen ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0); } @@ -573,54 +578,54 @@ SCREEN_UPDATE( rockntread ) rot_ofsy = 0x400; } - tilemap_set_scrollx(tilemap_bg, 0, (((tetrisp2_scroll_bg[ 0 ] + 0x0014) + tetrisp2_scroll_bg[ 2 ] ) & 0xffff)); - tilemap_set_scrolly(tilemap_bg, 0, (((tetrisp2_scroll_bg[ 3 ] + 0x0000) + tetrisp2_scroll_bg[ 5 ] ) & 0xffff)); + tilemap_set_scrollx(state->tilemap_bg, 0, (((state->scroll_bg[ 0 ] + 0x0014) + state->scroll_bg[ 2 ] ) & 0xffff)); + tilemap_set_scrolly(state->tilemap_bg, 0, (((state->scroll_bg[ 3 ] + 0x0000) + state->scroll_bg[ 5 ] ) & 0xffff)); - tilemap_set_scrollx(tilemap_fg, 0, tetrisp2_scroll_fg[ 2 ]); - tilemap_set_scrolly(tilemap_fg, 0, tetrisp2_scroll_fg[ 5 ]); + tilemap_set_scrollx(state->tilemap_fg, 0, state->scroll_fg[ 2 ]); + tilemap_set_scrolly(state->tilemap_fg, 0, state->scroll_fg[ 5 ]); - tilemap_set_scrollx(tilemap_rot, 0, (tetrisp2_rotregs[ 0 ] - rot_ofsx)); - tilemap_set_scrolly(tilemap_rot, 0, (tetrisp2_rotregs[ 2 ] - rot_ofsy)); + tilemap_set_scrollx(state->tilemap_rot, 0, (state->rotregs[ 0 ] - rot_ofsx)); + tilemap_set_scrolly(state->tilemap_rot, 0, (state->rotregs[ 2 ] - rot_ofsy)); asc_pri = scr_pri = rot_pri = 0; - if((tetrisp2_priority[0x2b00 / 2] & 0x00ff) == 0x0034) + if((state->priority[0x2b00 / 2] & 0x00ff) == 0x0034) asc_pri++; else rot_pri++; - if((tetrisp2_priority[0x2e00 / 2] & 0x00ff) == 0x0034) + if((state->priority[0x2e00 / 2] & 0x00ff) == 0x0034) asc_pri++; else scr_pri++; - if((tetrisp2_priority[0x3a00 / 2] & 0x00ff) == 0x000c) + if((state->priority[0x3a00 / 2] & 0x00ff) == 0x000c) scr_pri++; else rot_pri++; if (rot_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); if (rot_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); if (rot_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); - tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap,cliprect, tetrisp2_priority, screen->machine->generic.spriteram.u16, screen->machine->generic.spriteram_size, 0, (tetrisp2_systemregs[0x00] & 0x02)); + tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap,cliprect, state->priority, screen->machine->generic.spriteram.u16, screen->machine->generic.spriteram_size, 0, (state->systemregs[0x00] & 0x02)); return 0; } @@ -629,6 +634,7 @@ SCREEN_UPDATE( rockntread ) SCREEN_UPDATE( rocknms ) { + tetrisp2_state *state = screen->machine->driver_data<tetrisp2_state>(); int asc_pri; int scr_pri; int rot_pri; @@ -639,64 +645,64 @@ SCREEN_UPDATE( rocknms ) /* Black background color */ if (screen == left_screen) { - tilemap_set_scrollx(tilemap_sub_bg, 0, rocknms_sub_scroll_bg[ 2 ] + 0x000); - tilemap_set_scrolly(tilemap_sub_bg, 0, rocknms_sub_scroll_bg[ 5 ] + 0x000); - tilemap_set_scrollx(tilemap_sub_fg, 0, rocknms_sub_scroll_fg[ 2 ] + 0x000); - tilemap_set_scrolly(tilemap_sub_fg, 0, rocknms_sub_scroll_fg[ 5 ] + 0x000); - tilemap_set_scrollx(tilemap_sub_rot, 0, rocknms_sub_rotregs[ 0 ] + 0x400); - tilemap_set_scrolly(tilemap_sub_rot, 0, rocknms_sub_rotregs[ 2 ] + 0x400); + tilemap_set_scrollx(state->tilemap_sub_bg, 0, state->rocknms_sub_scroll_bg[ 2 ] + 0x000); + tilemap_set_scrolly(state->tilemap_sub_bg, 0, state->rocknms_sub_scroll_bg[ 5 ] + 0x000); + tilemap_set_scrollx(state->tilemap_sub_fg, 0, state->rocknms_sub_scroll_fg[ 2 ] + 0x000); + tilemap_set_scrolly(state->tilemap_sub_fg, 0, state->rocknms_sub_scroll_fg[ 5 ] + 0x000); + tilemap_set_scrollx(state->tilemap_sub_rot, 0, state->rocknms_sub_rotregs[ 0 ] + 0x400); + tilemap_set_scrolly(state->tilemap_sub_rot, 0, state->rocknms_sub_rotregs[ 2 ] + 0x400); bitmap_fill(bitmap, cliprect, screen->machine->pens[0x0000]); bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); asc_pri = scr_pri = rot_pri = 0; - if((rocknms_sub_priority[0x2b00 / 2] & 0x00ff) == 0x0034) + if((state->rocknms_sub_priority[0x2b00 / 2] & 0x00ff) == 0x0034) asc_pri++; else rot_pri++; - if((rocknms_sub_priority[0x2e00 / 2] & 0x00ff) == 0x0034) + if((state->rocknms_sub_priority[0x2e00 / 2] & 0x00ff) == 0x0034) asc_pri++; else scr_pri++; - if((rocknms_sub_priority[0x3a00 / 2] & 0x00ff) == 0x000c) + if((state->rocknms_sub_priority[0x3a00 / 2] & 0x00ff) == 0x000c) scr_pri++; else rot_pri++; if (rot_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_sub_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_rot, 0, 1 << 1); else if (scr_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_sub_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_bg, 0, 1 << 0); else if (asc_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_sub_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_fg, 0, 1 << 2); if (rot_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_sub_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_rot, 0, 1 << 1); else if (scr_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_sub_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_bg, 0, 1 << 0); else if (asc_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_sub_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_fg, 0, 1 << 2); if (rot_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_sub_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_rot, 0, 1 << 1); else if (scr_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_sub_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_bg, 0, 1 << 0); else if (asc_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_sub_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_sub_fg, 0, 1 << 2); - tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap,cliprect, tetrisp2_priority, screen->machine->generic.spriteram2.u16, screen->machine->generic.spriteram2_size, 4, (tetrisp2_systemregs[0x00] & 0x02)); + tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap,cliprect, state->priority, screen->machine->generic.spriteram2.u16, screen->machine->generic.spriteram2_size, 4, (state->systemregs[0x00] & 0x02)); } else if (screen == right_screen) /* game screen */ { - tilemap_set_scrollx(tilemap_bg, 0, tetrisp2_scroll_bg[ 2 ] + 0x000); - tilemap_set_scrolly(tilemap_bg, 0, tetrisp2_scroll_bg[ 5 ] + 0x000); - tilemap_set_scrollx(tilemap_fg, 0, tetrisp2_scroll_fg[ 2 ] + 0x000); - tilemap_set_scrolly(tilemap_fg, 0, tetrisp2_scroll_fg[ 5 ] + 0x000); - tilemap_set_scrollx(tilemap_rot, 0, tetrisp2_rotregs[ 0 ] + 0x400); - tilemap_set_scrolly(tilemap_rot, 0, tetrisp2_rotregs[ 2 ] + 0x400); + tilemap_set_scrollx(state->tilemap_bg, 0, state->scroll_bg[ 2 ] + 0x000); + tilemap_set_scrolly(state->tilemap_bg, 0, state->scroll_bg[ 5 ] + 0x000); + tilemap_set_scrollx(state->tilemap_fg, 0, state->scroll_fg[ 2 ] + 0x000); + tilemap_set_scrolly(state->tilemap_fg, 0, state->scroll_fg[ 5 ] + 0x000); + tilemap_set_scrollx(state->tilemap_rot, 0, state->rotregs[ 0 ] + 0x400); + tilemap_set_scrolly(state->tilemap_rot, 0, state->rotregs[ 2 ] + 0x400); /* Black background color */ bitmap_fill(bitmap, cliprect, screen->machine->pens[0x0000]); @@ -704,43 +710,43 @@ SCREEN_UPDATE( rocknms ) asc_pri = scr_pri = rot_pri = 0; - if((tetrisp2_priority[0x2b00 / 2] & 0x00ff) == 0x0034) + if((state->priority[0x2b00 / 2] & 0x00ff) == 0x0034) asc_pri++; else rot_pri++; - if((tetrisp2_priority[0x2e00 / 2] & 0x00ff) == 0x0034) + if((state->priority[0x2e00 / 2] & 0x00ff) == 0x0034) asc_pri++; else scr_pri++; - if((tetrisp2_priority[0x3a00 / 2] & 0x00ff) == 0x000c) + if((state->priority[0x3a00 / 2] & 0x00ff) == 0x000c) scr_pri++; else rot_pri++; if (rot_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 0) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); if (rot_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 1) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); if (rot_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_rot, 0, 1 << 1); + tilemap_draw(bitmap,cliprect, state->tilemap_rot, 0, 1 << 1); else if (scr_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_bg, 0, 1 << 0); + tilemap_draw(bitmap,cliprect, state->tilemap_bg, 0, 1 << 0); else if (asc_pri == 2) - tilemap_draw(bitmap,cliprect, tilemap_fg, 0, 1 << 2); + tilemap_draw(bitmap,cliprect, state->tilemap_fg, 0, 1 << 2); - tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap,cliprect, tetrisp2_priority, screen->machine->generic.spriteram.u16, screen->machine->generic.spriteram_size, 0, (tetrisp2_systemregs[0x00] & 0x02)); + tetrisp2_draw_sprites(screen->machine, bitmap, screen->machine->priority_bitmap,cliprect, state->priority, screen->machine->generic.spriteram.u16, screen->machine->generic.spriteram_size, 0, (state->systemregs[0x00] & 0x02)); } return 0; diff --git a/src/mame/video/vicdual.c b/src/mame/video/vicdual.c index 68893f8d137..9ec9b51e914 100644 --- a/src/mame/video/vicdual.c +++ b/src/mame/video/vicdual.c @@ -8,9 +8,6 @@ #include "includes/vicdual.h" -static UINT8 palette_bank; - - static const pen_t pens_from_color_prom[] = { RGB_BLACK, @@ -26,13 +23,15 @@ static const pen_t pens_from_color_prom[] = WRITE8_HANDLER( vicdual_palette_bank_w ) { + vicdual_state *state = space->machine->driver_data<vicdual_state>(); space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); - palette_bank = data & 3; + state->palette_bank = data & 3; } SCREEN_UPDATE( vicdual_bw ) { + vicdual_state *state = screen->machine->driver_data<vicdual_state>(); UINT8 x = 0; UINT8 y = cliprect->min_y; UINT8 video_data = 0; @@ -48,11 +47,11 @@ SCREEN_UPDATE( vicdual_bw ) /* read the character code */ offs = (y >> 3 << 5) | (x >> 3); - char_code = vicdual_videoram_r(offs); + char_code = state->videoram[offs]; /* read the appropriate line of the character ram */ offs = (char_code << 3) | (y & 0x07); - video_data = vicdual_characterram_r(offs); + video_data = state->characterram[offs]; } /* plot the current pixel */ @@ -83,6 +82,7 @@ SCREEN_UPDATE( vicdual_bw ) SCREEN_UPDATE( vicdual_color ) { + vicdual_state *state = screen->machine->driver_data<vicdual_state>(); UINT8 *color_prom = (UINT8 *)screen->machine->region("proms")->base(); UINT8 x = 0; UINT8 y = cliprect->min_y; @@ -101,14 +101,14 @@ SCREEN_UPDATE( vicdual_color ) /* read the character code */ offs = (y >> 3 << 5) | (x >> 3); - char_code = vicdual_videoram_r(offs); + char_code = state->videoram[offs]; /* read the appropriate line of the character ram */ offs = (char_code << 3) | (y & 0x07); - video_data = vicdual_characterram_r(offs); + video_data = state->characterram[offs]; /* get the foreground and background colors from the PROM */ - offs = (char_code >> 5) | (palette_bank << 3); + offs = (char_code >> 5) | (state->palette_bank << 3); back_pen = pens_from_color_prom[(color_prom[offs] >> 1) & 0x07]; fore_pen = pens_from_color_prom[(color_prom[offs] >> 5) & 0x07]; } |