diff --git a/.gitattributes b/.gitattributes index 86a336e3628..34e26f12d55 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2474,6 +2474,7 @@ src/mame/includes/gberet.h svneol=native#text/plain src/mame/includes/gcpinbal.h svneol=native#text/plain src/mame/includes/genesis.h svneol=native#text/plain src/mame/includes/ginganin.h svneol=native#text/plain +src/mame/includes/glass.h svneol=native#text/plain src/mame/includes/gng.h svneol=native#text/plain src/mame/includes/goal92.h svneol=native#text/plain src/mame/includes/goindol.h svneol=native#text/plain diff --git a/src/mame/drivers/glass.c b/src/mame/drivers/glass.c index b580b876f0a..45a8ae4ecf8 100644 --- a/src/mame/drivers/glass.c +++ b/src/mame/drivers/glass.c @@ -11,36 +11,22 @@ The DS5002FP has up to 128KB undumped gameplay code making the game unplayable : #include "driver.h" #include "cpu/m68000/m68000.h" #include "sound/okim6295.h" - -extern UINT16 *glass_vregs; -extern UINT16 *glass_videoram; -extern UINT16 *glass_spriteram; -extern int glass_current_bit; - -/* from video/glass.c */ -WRITE16_HANDLER( glass_vram_w ); -WRITE16_HANDLER( glass_blitter_w ); -VIDEO_START( glass ); -VIDEO_UPDATE( glass ); - -static int cause_interrupt; - -static MACHINE_RESET( glass ) -{ - cause_interrupt = 1; - glass_current_bit = 0; -} +#include "includes/glass.h" static WRITE16_HANDLER( clr_int_w ) { - cause_interrupt = 1; + glass_state *state = (glass_state *)space->machine->driver_data; + state->cause_interrupt = 1; } static INTERRUPT_GEN( glass_interrupt ) { - if (cause_interrupt){ + glass_state *state = (glass_state *)device->machine->driver_data; + + if (state->cause_interrupt) + { cpu_set_input_line(device, 6, HOLD_LINE); - cause_interrupt = 0; + state->cause_interrupt = 0; } } @@ -71,14 +57,14 @@ static WRITE16_HANDLER( OKIM6295_bankswitch_w ) { UINT8 *RAM = memory_region(space->machine, "oki"); - if (ACCESSING_BITS_0_7){ - memcpy(&RAM[0x30000], &RAM[0x40000 + (data & 0x0f)*0x10000], 0x10000); - } + if (ACCESSING_BITS_0_7) + memcpy(&RAM[0x30000], &RAM[0x40000 + (data & 0x0f) * 0x10000], 0x10000); } static WRITE16_HANDLER( glass_coin_w ) { - switch (offset >> 3){ + switch (offset >> 3) + { case 0x00: /* Coin Lockouts */ case 0x01: coin_lockout_w(space->machine, (offset >> 3) & 0x01, ~data & 0x01); @@ -94,12 +80,12 @@ static WRITE16_HANDLER( glass_coin_w ) static ADDRESS_MAP_START( glass_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM /* ROM */ - AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(glass_vram_w) AM_BASE(&glass_videoram) /* Video RAM */ + AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(glass_vram_w) AM_BASE_MEMBER(glass_state, videoram) /* Video RAM */ AM_RANGE(0x102000, 0x102fff) AM_RAM /* Extra Video RAM */ - AM_RANGE(0x108000, 0x108007) AM_WRITEONLY AM_BASE(&glass_vregs) /* Video Registers */ + AM_RANGE(0x108000, 0x108007) AM_WRITEONLY AM_BASE_MEMBER(glass_state, vregs) /* Video Registers */ AM_RANGE(0x108008, 0x108009) AM_WRITE(clr_int_w) /* CLR INT Video */ AM_RANGE(0x200000, 0x2007ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) /* Palette */ - AM_RANGE(0x440000, 0x440fff) AM_RAM AM_BASE(&glass_spriteram) /* Sprite RAM */ + AM_RANGE(0x440000, 0x440fff) AM_RAM AM_BASE_MEMBER(glass_state, spriteram) /* Sprite RAM */ AM_RANGE(0x700000, 0x700001) AM_READ_PORT("DSW2") AM_RANGE(0x700002, 0x700003) AM_READ_PORT("DSW1") AM_RANGE(0x700004, 0x700005) AM_READ_PORT("P1") @@ -114,50 +100,50 @@ ADDRESS_MAP_END static INPUT_PORTS_START( glass ) PORT_START("DSW1") - PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:6,7,8") - PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x00, DEF_STR( 3C_4C ) ) - PORT_DIPSETTING( 0x01, DEF_STR( 2C_3C ) ) - PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x05, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x03, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x02, DEF_STR( 1C_6C ) ) - PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:3,4,5") - PORT_DIPSETTING( 0x10, DEF_STR( 6C_1C ) ) - PORT_DIPSETTING( 0x18, DEF_STR( 5C_1C ) ) - PORT_DIPSETTING( 0x20, DEF_STR( 4C_1C ) ) - PORT_DIPSETTING( 0x28, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x30, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x08, DEF_STR( 3C_2C ) ) - PORT_DIPSETTING( 0x00, DEF_STR( 4C_3C ) ) - PORT_DIPSETTING( 0x38, DEF_STR( 1C_1C ) ) - PORT_DIPNAME( 0x40, 0x40, "Credit configuration" ) PORT_DIPLOCATION("SW1:2") - PORT_DIPSETTING( 0x40, "Start 1C" ) - PORT_DIPSETTING( 0x00, "Start 2C" ) - PORT_DIPNAME( 0x80, 0x80, DEF_STR( Free_Play ) ) PORT_DIPLOCATION("SW1:1") - PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:6,7,8") + PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) ) + PORT_DIPSETTING( 0x00, DEF_STR( 3C_4C ) ) + PORT_DIPSETTING( 0x01, DEF_STR( 2C_3C ) ) + PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) ) + PORT_DIPSETTING( 0x05, DEF_STR( 1C_3C ) ) + PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) ) + PORT_DIPSETTING( 0x03, DEF_STR( 1C_5C ) ) + PORT_DIPSETTING( 0x02, DEF_STR( 1C_6C ) ) + PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:3,4,5") + PORT_DIPSETTING( 0x10, DEF_STR( 6C_1C ) ) + PORT_DIPSETTING( 0x18, DEF_STR( 5C_1C ) ) + PORT_DIPSETTING( 0x20, DEF_STR( 4C_1C ) ) + PORT_DIPSETTING( 0x28, DEF_STR( 3C_1C ) ) + PORT_DIPSETTING( 0x30, DEF_STR( 2C_1C ) ) + PORT_DIPSETTING( 0x08, DEF_STR( 3C_2C ) ) + PORT_DIPSETTING( 0x00, DEF_STR( 4C_3C ) ) + PORT_DIPSETTING( 0x38, DEF_STR( 1C_1C ) ) + PORT_DIPNAME( 0x40, 0x40, "Credit configuration" ) PORT_DIPLOCATION("SW1:2") + PORT_DIPSETTING( 0x40, "Start 1C" ) + PORT_DIPSETTING( 0x00, "Start 2C" ) + PORT_DIPNAME( 0x80, 0x80, DEF_STR( Free_Play ) ) PORT_DIPLOCATION("SW1:1") + PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_START("DSW2") - PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:7,8") - PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x03, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) - PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:5,6") - PORT_DIPSETTING( 0x0c, "3" ) - PORT_DIPSETTING( 0x08, "1" ) - PORT_DIPSETTING( 0x04, "2" ) - PORT_DIPSETTING( 0x00, "4" ) - PORT_DIPNAME( 0x10, 0x10, DEF_STR( Version ) ) PORT_DIPLOCATION("SW2:4") - PORT_DIPSETTING( 0x10, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x00, "Light" ) - PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:3") - PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x20, DEF_STR( On ) ) + PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:7,8") + PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) + PORT_DIPSETTING( 0x03, DEF_STR( Normal ) ) + PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) + PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:5,6") + PORT_DIPSETTING( 0x0c, "3" ) + PORT_DIPSETTING( 0x08, "1" ) + PORT_DIPSETTING( 0x04, "2" ) + PORT_DIPSETTING( 0x00, "4" ) + PORT_DIPNAME( 0x10, 0x10, DEF_STR( Version ) ) PORT_DIPLOCATION("SW2:4") + PORT_DIPSETTING( 0x10, DEF_STR( Normal ) ) + PORT_DIPSETTING( 0x00, "Light" ) + PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:3") + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x20, DEF_STR( On ) ) PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW2:2" ) /* Listed as "Unused" */ - PORT_SERVICE_DIPLOC( 0x80, IP_ACTIVE_LOW, "SW2:1" ) + PORT_SERVICE_DIPLOC( 0x80, IP_ACTIVE_LOW, "SW2:1" ) PORT_START("P1") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) @@ -185,13 +171,40 @@ INPUT_PORTS_END +static MACHINE_START( glass ) +{ + glass_state *state = (glass_state *)machine->driver_data; + + state_save_register_global(machine, state->cause_interrupt); + state_save_register_global(machine, state->current_bit); + state_save_register_global(machine, state->current_command); + state_save_register_global_array(machine, state->blitter_serial_buffer); +} + +static MACHINE_RESET( glass ) +{ + glass_state *state = (glass_state *)machine->driver_data; + int i; + + state->cause_interrupt = 1; + state->current_bit = 0; + state->current_command = 0; + + for (i = 0; i < 5; i++) + state->blitter_serial_buffer[i] = 0; +} + static MACHINE_DRIVER_START( glass ) + /* driver data */ + MDRV_DRIVER_DATA(glass_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,24000000/2) /* 12 MHz (M680000 P12) */ MDRV_CPU_PROGRAM_MAP(glass_map) MDRV_CPU_VBLANK_INT("screen", glass_interrupt) + MDRV_MACHINE_START(glass) MDRV_MACHINE_RESET(glass) /* video hardware */ @@ -285,7 +298,7 @@ ROM_END ***************************************************************************/ -static void glass_ROM16_split_gfx(running_machine *machine, const char *src_reg, const char *dst_reg, int start, int length, int dest1, int dest2) +static void glass_ROM16_split_gfx( running_machine *machine, const char *src_reg, const char *dst_reg, int start, int length, int dest1, int dest2 ) { int i; @@ -296,9 +309,10 @@ static void glass_ROM16_split_gfx(running_machine *machine, const char *src_reg, UINT8 *dst = (UINT8 *)memory_region(machine, dst_reg); /* fill destination areas with the proper data */ - for (i = 0; i < length/2; i++){ - dst[dest1 + i] = src[start + i*2 + 0]; - dst[dest2 + i] = src[start + i*2 + 1]; + for (i = 0; i < length / 2; i++) + { + dst[dest1 + i] = src[start + i * 2 + 0]; + dst[dest2 + i] = src[start + i * 2 + 1]; } } @@ -323,6 +337,6 @@ static DRIVER_INIT( glass ) glass_ROM16_split_gfx(machine, "gfx2", "gfx1", 0x0200000, 0x0200000, 0x0200000, 0x0300000); } -GAME( 1993, glass, 0, glass, glass, glass, ROT0, "Gaelco", "Glass (Ver 1.1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1993, glass10, glass, glass, glass, glass, ROT0, "Gaelco", "Glass (Ver 1.0)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1993, glassbrk, glass, glass, glass, glass, ROT0, "Gaelco", "Glass (Ver 1.0, Break Edition)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) +GAME( 1993, glass, 0, glass, glass, glass, ROT0, "Gaelco", "Glass (Ver 1.1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1993, glass10, glass, glass, glass, glass, ROT0, "Gaelco", "Glass (Ver 1.0)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1993, glassbrk, glass, glass, glass, glass, ROT0, "Gaelco", "Glass (Ver 1.0, Break Edition)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/homedata.c b/src/mame/drivers/homedata.c index a63869ef130..7c4f1302acf 100644 --- a/src/mame/drivers/homedata.c +++ b/src/mame/drivers/homedata.c @@ -224,21 +224,16 @@ Custom: GX61A01 #include "sound/2203intf.h" #include "sound/sn76496.h" - -/********************************************************************************/ - - -static int vblank; - static INTERRUPT_GEN( homedata_irq ) { - vblank = 1; - cpu_set_input_line(device,M6809_FIRQ_LINE,HOLD_LINE); + homedata_state *state = (homedata_state *)device->machine->driver_data; + state->vblank = 1; + cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE); } static INTERRUPT_GEN( upd7807_irq ) { - cpu_set_input_line(device,UPD7810_INTF1,HOLD_LINE); + cpu_set_input_line(device, UPD7810_INTF1, HOLD_LINE); } @@ -250,19 +245,18 @@ static INTERRUPT_GEN( upd7807_irq ) ********************************************************************************/ -static int keyb; - static READ8_HANDLER( mrokumei_keyboard_r ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; int res = 0x3f,i; static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4" }; /* offset 0 is player 1, offset 1 player 2 (not supported) */ if (offset == 0) { - for (i = 0;i < 5;i++) + for (i = 0; i < 5; i++) { - if (keyb & (1 << i)) + if (state->keyb & (1 << i)) { res = input_port_read(space->machine, keynames[i]) & 0x3f; break; @@ -276,11 +270,12 @@ static READ8_HANDLER( mrokumei_keyboard_r ) * bit 6: vblank * other bits are inputs */ - res |= homedata_visible_page << 7; + res |= state->visible_page << 7; - if (vblank) res |= 0x40; + if (state->vblank) + res |= 0x40; - vblank = 0; + state->vblank = 0; } return res; @@ -288,46 +283,48 @@ static READ8_HANDLER( mrokumei_keyboard_r ) static WRITE8_HANDLER( mrokumei_keyboard_select_w ) { - keyb = data; + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->keyb = data; } - -static int sndbank; - static READ8_HANDLER( mrokumei_sound_io_r ) { - if (sndbank & 4) - return(soundlatch_r(space,0)); + homedata_state *state = (homedata_state *)space->machine->driver_data; + if (state->sndbank & 4) + return(soundlatch_r(space, 0)); else - return memory_region(space->machine, "audiocpu")[0x10000 + offset + (sndbank & 1) * 0x10000]; + return memory_region(space->machine, "audiocpu")[0x10000 + offset + (state->sndbank & 1) * 0x10000]; } static WRITE8_HANDLER( mrokumei_sound_bank_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; /* bit 0 = ROM bank bit 2 = ROM or soundlatch */ - sndbank = data; + state->sndbank = data; } static WRITE8_HANDLER( mrokumei_sound_io_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; switch (offset & 0xff) { case 0x40: - dac_signed_data_w(devtag_get_device(space->machine, "dac"),data); + dac_signed_data_w(state->dac, data); break; default: - logerror("%04x: I/O write to port %04x\n",cpu_get_pc(space->cpu),offset); + logerror("%04x: I/O write to port %04x\n", cpu_get_pc(space->cpu), offset); break; } } static WRITE8_HANDLER( mrokumei_sound_cmd_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; soundlatch_w(space, offset, data); - cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE); + cpu_set_input_line(state->audiocpu, 0, HOLD_LINE); } @@ -339,20 +336,22 @@ static WRITE8_HANDLER( mrokumei_sound_cmd_w ) ********************************************************************************/ -static int upd7807_porta,upd7807_portc; - static READ8_HANDLER( reikaids_upd7807_porta_r ) { - return upd7807_porta; + homedata_state *state = (homedata_state *)space->machine->driver_data; + return state->upd7807_porta; } static WRITE8_HANDLER( reikaids_upd7807_porta_w ) { - upd7807_porta = data; + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->upd7807_porta = data; } static WRITE8_HANDLER( reikaids_upd7807_portc_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; + /* port C layout: 7 coin counter 6 to main CPU (data) @@ -363,68 +362,55 @@ static WRITE8_HANDLER( reikaids_upd7807_portc_w ) 1 \ ROM bank 0 / */ -// logerror("%04x: port C wr %02x (STATUS %d DATA %d)\n",cpu_get_pc(space->cpu),data,BIT(data,2),BIT(data,6)); +// logerror("%04x: port C wr %02x (STATUS %d DATA %d)\n", cpu_get_pc(space->cpu), data, BIT(data, 2), BIT(data, 6)); - memory_set_bankptr(space->machine, "bank2",memory_region(space->machine, "audiocpu") + 0x10000 * (data & 0x03)); + memory_set_bankptr(space->machine, "bank2", memory_region(space->machine, "audiocpu") + 0x10000 * (data & 0x03)); - coin_counter_w(space->machine, 0,~data & 0x80); + coin_counter_w(space->machine, 0, ~data & 0x80); - if (BIT(upd7807_portc,5) && !BIT(data,5)) /* write clock 1->0 */ - { - const device_config *device = devtag_get_device(space->machine, "ymsnd"); - ym2203_w(device, BIT(data,3), upd7807_porta); - } + if (BIT(state->upd7807_portc, 5) && !BIT(data, 5)) /* write clock 1->0 */ + ym2203_w(state->ym, BIT(data, 3), state->upd7807_porta); - if (BIT(upd7807_portc,4) && !BIT(data,4)) /* read clock 1->0 */ - { - const device_config *device = devtag_get_device(space->machine, "ymsnd"); - upd7807_porta = ym2203_r(device, BIT(data,3)); - } + if (BIT(state->upd7807_portc, 4) && !BIT(data, 4)) /* read clock 1->0 */ + state->upd7807_porta = ym2203_r(state->ym, BIT(data, 3)); - upd7807_portc = data; -} - -static MACHINE_RESET( reikaids_upd7807 ) -{ - const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - /* on reset, ports are set as input (high impedance), therefore 0xff output */ - reikaids_which=homedata_priority; - reikaids_upd7807_portc_w(space,0,0xff); + state->upd7807_portc = data; } static READ8_HANDLER( reikaids_io_r ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; int res = input_port_read(space->machine, "IN2"); // bit 4 = coin, bit 5 = service - res |= BIT(upd7807_portc,2) * 0x01; // bit 0 = upd7807 status - res |= BIT(upd7807_portc,6) * 0x02; // bit 1 = upd7807 data - if (vblank) res |= 0x04; // bit 2 = vblank - res |= homedata_visible_page * 0x08; // bit 3 = visible page + res |= BIT(state->upd7807_portc, 2) * 0x01; // bit 0 = upd7807 status + res |= BIT(state->upd7807_portc, 6) * 0x02; // bit 1 = upd7807 data + if (state->vblank) + res |= 0x04; // bit 2 = vblank + res |= state->visible_page * 0x08; // bit 3 = visible page - vblank = 0; + state->vblank = 0; -//logerror("%04x: io_r %02x\n",cpu_get_pc(space->cpu),res); + //logerror("%04x: io_r %02x\n", cpu_get_pc(space->cpu), res); return res; } -static int snd_command; - static READ8_HANDLER( reikaids_snd_command_r ) { -//logerror("%04x: sndmcd_r (%02x)\n",cpu_get_pc(space->cpu),snd_command); - return snd_command; + homedata_state *state = (homedata_state *)space->machine->driver_data; + //logerror("%04x: sndmcd_r (%02x)\n", cpu_get_pc(space->cpu), state->snd_command); + return state->snd_command; } static WRITE8_HANDLER( reikaids_snd_command_w ) { - snd_command = data; -//logerror("%04x: coprocessor_command_w %02x\n",cpu_get_pc(space->cpu),data); + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->snd_command = data; + //logerror("%04x: coprocessor_command_w %02x\n", cpu_get_pc(space->cpu), data); } - /******************************************************************************** Newer Mahjong games: @@ -433,54 +419,57 @@ static WRITE8_HANDLER( reikaids_snd_command_w ) ********************************************************************************/ -static int to_cpu,from_cpu; - static WRITE8_HANDLER( pteacher_snd_command_w ) { -//logerror("%04x: snd_command_w %02x\n",cpu_get_pc(space->cpu),data); - from_cpu = data; + homedata_state *state = (homedata_state *)space->machine->driver_data; + //logerror("%04x: snd_command_w %02x\n", cpu_get_pc(space->cpu), data); + state->from_cpu = data; } static READ8_HANDLER( pteacher_snd_r ) { -//logerror("%04x: pteacher_snd_r %02x\n",cpu_get_pc(space->cpu),to_cpu); - return to_cpu; + homedata_state *state = (homedata_state *)space->machine->driver_data; + //logerror("%04x: pteacher_snd_r %02x\n",cpu_get_pc(space->cpu),to_cpu); + return state->to_cpu; } static READ8_HANDLER( pteacher_io_r ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; /* bit 6: !vblank * bit 7: visible page * other bits seem unused */ - int res = (homedata_visible_page ^ 1) << 7; + int res = (state->visible_page ^ 1) << 7; - if (!vblank) res |= 0x40; + if (!state->vblank) + res |= 0x40; - vblank = 0; + state->vblank = 0; return res; } static READ8_HANDLER( pteacher_keyboard_r ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5" }; int dips = input_port_read(space->machine, "DSW"); -// logerror("%04x: keyboard_r with port A = %02x\n",cpu_get_pc(space->cpu),upd7807_porta); + // logerror("%04x: keyboard_r with port A = %02x\n",cpu_get_pc(space->cpu),upd7807_porta); - if (upd7807_porta & 0x80) + if (state->upd7807_porta & 0x80) { /* player 1 + dip switches */ - int row = (upd7807_porta & 0x07); + int row = (state->upd7807_porta & 0x07); return input_port_read(space->machine, keynames[row]) | (((dips >> row) & 1) << 5); // 0-5 } - if (upd7807_porta & 0x08) + if (state->upd7807_porta & 0x08) { /* player 2 (not supported) + dip switches */ - int row = ((upd7807_porta >> 4) & 0x07); - return 0xdf | (((dips >> (row+5)) & 1) << 5); // 6-11 + int row = ((state->upd7807_porta >> 4) & 0x07); + return 0xdf | (((dips >> (row + 5)) & 1) << 5); // 6-11 } return 0xff; @@ -488,27 +477,31 @@ static READ8_HANDLER( pteacher_keyboard_r ) static READ8_HANDLER( pteacher_upd7807_porta_r ) { - if (!BIT(upd7807_portc,6)) - upd7807_porta = from_cpu; + homedata_state *state = (homedata_state *)space->machine->driver_data; + if (!BIT(state->upd7807_portc, 6)) + state->upd7807_porta = state->from_cpu; else -logerror("%04x: read PA with PC *not* clear\n",cpu_get_pc(space->cpu)); + logerror("%04x: read PA with PC *not* clear\n", cpu_get_pc(space->cpu)); - return upd7807_porta; + return state->upd7807_porta; } static WRITE8_HANDLER( pteacher_snd_answer_w ) { - to_cpu = data; -//logerror("%04x: to_cpu = %02x\n",cpu_get_pc(space->cpu),to_cpu); + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->to_cpu = data; + //logerror("%04x: to_cpu = %02x\n", cpu_get_pc(space->cpu), state->to_cpu); } static WRITE8_HANDLER( pteacher_upd7807_porta_w ) { - upd7807_porta = data; + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->upd7807_porta = data; } static WRITE8_HANDLER( pteacher_upd7807_portc_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; /* port C layout: 7 coin counter 6 enable message from main CPU on port A @@ -520,34 +513,26 @@ static WRITE8_HANDLER( pteacher_upd7807_portc_w ) 0 input (coin) */ -// logerror("%04x: port C wr %02x\n",cpu_get_pc(space->cpu),data); + // logerror("%04x: port C wr %02x\n", cpu_get_pc(space->cpu), data); - memory_set_bankptr(space->machine, "bank2",memory_region(space->machine, "audiocpu") + 0x10000 * ((data & 0x0c) >> 2)); + memory_set_bankptr(space->machine, "bank2", memory_region(space->machine, "audiocpu") + 0x10000 * ((data & 0x0c) >> 2)); - coin_counter_w(space->machine, 0,~data & 0x80); + coin_counter_w(space->machine, 0, ~data & 0x80); - if (BIT(upd7807_portc,5) && !BIT(data,5)) /* clock 1->0 */ - sn76496_w(devtag_get_device(space->machine, "snsnd"),0,upd7807_porta); + if (BIT(state->upd7807_portc, 5) && !BIT(data, 5)) /* clock 1->0 */ + sn76496_w(state->sn, 0, state->upd7807_porta); - upd7807_portc = data; + state->upd7807_portc = data; } -static MACHINE_RESET( pteacher_upd7807 ) -{ - const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - /* on reset, ports are set as input (high impedance), therefore 0xff output */ - pteacher_upd7807_portc_w(space,0,0xff); -} - - /********************************************************************************/ static WRITE8_HANDLER( bankswitch_w ) { UINT8 *rom = memory_region(space->machine, "maincpu"); - int len = memory_region_length(space->machine, "maincpu") - 0x10000+0x4000; - int offs = (data * 0x4000) & (len-1); + int len = memory_region_length(space->machine, "maincpu") - 0x10000 + 0x4000; + int offs = (data * 0x4000) & (len - 1); /* last bank is fixed */ if (offs < len - 0x4000) @@ -565,7 +550,7 @@ static WRITE8_HANDLER( bankswitch_w ) static ADDRESS_MAP_START( mrokumei_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(mrokumei_videoram_w) AM_BASE_GENERIC(videoram) + AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(mrokumei_videoram_w) AM_BASE_MEMBER(homedata_state, videoram) AM_RANGE(0x4000, 0x5fff) AM_RAM AM_RANGE(0x6000, 0x6fff) AM_RAM /* work ram */ AM_RANGE(0x7000, 0x77ff) AM_RAM /* hourouki expects this to act as RAM */ @@ -574,7 +559,7 @@ static ADDRESS_MAP_START( mrokumei_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x7803, 0x7803) AM_READ_PORT("IN0") // coin, service AM_RANGE(0x7804, 0x7804) AM_READ_PORT("DSW1") // DSW1 AM_RANGE(0x7805, 0x7805) AM_READ_PORT("DSW2") // DSW2 - AM_RANGE(0x7ff0, 0x7ffd) AM_WRITEONLY AM_BASE(&homedata_vreg) + AM_RANGE(0x7ff0, 0x7ffd) AM_WRITEONLY AM_BASE_MEMBER(homedata_state, vreg) AM_RANGE(0x7ffe, 0x7ffe) AM_READNOP // ??? read every vblank, value discarded AM_RANGE(0x8000, 0x8000) AM_WRITE(mrokumei_blitter_start_w) // in some games also ROM bank switch to access service ROM AM_RANGE(0x8001, 0x8001) AM_WRITE(mrokumei_keyboard_select_w) @@ -599,14 +584,14 @@ ADDRESS_MAP_END /********************************************************************************/ static ADDRESS_MAP_START( reikaids_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(reikaids_videoram_w) AM_BASE_GENERIC(videoram) + AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(reikaids_videoram_w) AM_BASE_MEMBER(homedata_state, videoram) AM_RANGE(0x4000, 0x5fff) AM_RAM AM_RANGE(0x6000, 0x6fff) AM_RAM /* work RAM */ AM_RANGE(0x7800, 0x7800) AM_RAM /* behaves as normal RAM */ AM_RANGE(0x7801, 0x7801) AM_READ_PORT("IN0") AM_RANGE(0x7802, 0x7802) AM_READ_PORT("IN1") AM_RANGE(0x7803, 0x7803) AM_READ(reikaids_io_r) // coin, blitter, upd7807 - AM_RANGE(0x7ff0, 0x7ffd) AM_WRITEONLY AM_BASE(&homedata_vreg) + AM_RANGE(0x7ff0, 0x7ffd) AM_WRITEONLY AM_BASE_MEMBER(homedata_state, vreg) AM_RANGE(0x7ffe, 0x7ffe) AM_WRITE(reikaids_blitter_bank_w) AM_RANGE(0x7fff, 0x7fff) AM_WRITE(reikaids_blitter_start_w) AM_RANGE(0x8000, 0x8000) AM_WRITE(bankswitch_w) @@ -633,14 +618,14 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( pteacher_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(pteacher_videoram_w) AM_BASE_GENERIC(videoram) + AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(pteacher_videoram_w) AM_BASE_MEMBER(homedata_state, videoram) AM_RANGE(0x4000, 0x5eff) AM_RAM AM_RANGE(0x5f00, 0x5fff) AM_RAM AM_RANGE(0x6000, 0x6fff) AM_RAM /* work ram */ AM_RANGE(0x7800, 0x7800) AM_RAM /* behaves as normal RAM */ AM_RANGE(0x7801, 0x7801) AM_READ(pteacher_io_r) // vblank, visible page AM_RANGE(0x7ff2, 0x7ff2) AM_READ(pteacher_snd_r) - AM_RANGE(0x7ff0, 0x7ffd) AM_WRITEONLY AM_BASE(&homedata_vreg) + AM_RANGE(0x7ff0, 0x7ffd) AM_WRITEONLY AM_BASE_MEMBER(homedata_state, vreg) AM_RANGE(0x7fff, 0x7fff) AM_WRITE(pteacher_blitter_start_w) AM_RANGE(0x8000, 0x8000) AM_WRITE(bankswitch_w) AM_RANGE(0x8002, 0x8002) AM_WRITE(pteacher_snd_command_w) @@ -773,7 +758,7 @@ static INPUT_PORTS_START( mjhokite ) INPUT_PORTS_END static INPUT_PORTS_START( reikaids ) - PORT_START("IN0") // IN0 - 0x7801 + PORT_START("IN0") // 0x7801 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(1) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(1) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(1) @@ -783,7 +768,7 @@ static INPUT_PORTS_START( reikaids ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) /* jump */ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 ) - PORT_START("IN1") // IN1 - 0x7802 + PORT_START("IN1") // 0x7802 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(2) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(2) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(2) @@ -793,7 +778,7 @@ static INPUT_PORTS_START( reikaids ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) /* jump */ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) - PORT_START("IN2") // IN2 - 0x7803 + PORT_START("IN2") // 0x7803 PORT_BIT( 0x01, IP_ACTIVE_HIGH,IPT_SPECIAL ) /* coprocessor status */ PORT_BIT( 0x02, IP_ACTIVE_HIGH,IPT_SPECIAL ) /* coprocessor data */ PORT_BIT( 0x04, IP_ACTIVE_HIGH,IPT_SPECIAL ) /* vblank */ @@ -803,7 +788,7 @@ static INPUT_PORTS_START( reikaids ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START("DSW1") // DSW1 + PORT_START("DSW1") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Allow_Continue ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) @@ -827,7 +812,7 @@ static INPUT_PORTS_START( reikaids ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START("DSW2") // DSW2 + PORT_START("DSW2") PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x03, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x02, DEF_STR( Normal ) ) @@ -1167,8 +1152,110 @@ GFXDECODE_END +static MACHINE_START( homedata ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->ym = devtag_get_device(machine, "ymsnd"); + state->sn = devtag_get_device(machine, "snsnd"); + state->dac = devtag_get_device(machine, "dac"); + + state_save_register_global(machine, state->visible_page); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->blitter_bank); + state_save_register_global(machine, state->blitter_param_count); + state_save_register_global_array(machine, state->blitter_param); + state_save_register_global(machine, state->vblank); + state_save_register_global(machine, state->sndbank); + state_save_register_global(machine, state->keyb); + state_save_register_global(machine, state->snd_command); +} + +static MACHINE_START( reikaids ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + + MACHINE_START_CALL(homedata); + + state_save_register_global(machine, state->upd7807_porta); + state_save_register_global(machine, state->upd7807_portc); + + state_save_register_global(machine, state->reikaids_which); + state_save_register_global_array(machine, state->gfx_bank); +} + +static MACHINE_START( pteacher ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + + MACHINE_START_CALL(homedata); + + state_save_register_global(machine, state->upd7807_porta); + state_save_register_global(machine, state->upd7807_portc); + + state_save_register_global_array(machine, state->gfx_bank); + state_save_register_global(machine, state->to_cpu); + state_save_register_global(machine, state->from_cpu); +} + +static MACHINE_RESET( homedata ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + + state->visible_page = 0; + state->flipscreen = 0; + state->blitter_bank = 0; + state->blitter_param_count = 0; + state->blitter_param[0] = 0; + state->blitter_param[1] = 0; + state->blitter_param[2] = 0; + state->blitter_param[3] = 0; + state->vblank = 0; + state->sndbank = 0; + state->keyb = 0; + state->snd_command = 0; +} + +static MACHINE_RESET( pteacher ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); + + /* on reset, ports are set as input (high impedance), therefore 0xff output */ + pteacher_upd7807_portc_w(space, 0, 0xff); + + MACHINE_RESET_CALL(homedata); + + state->upd7807_porta = 0; + state->gfx_bank[0] = 0; + state->gfx_bank[1] = 0; + state->to_cpu = 0; + state->from_cpu = 0; +} + +static MACHINE_RESET( reikaids ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); + + /* on reset, ports are set as input (high impedance), therefore 0xff output */ + reikaids_upd7807_portc_w(space, 0, 0xff); + + MACHINE_RESET_CALL(homedata); + + state->reikaids_which = state->priority; // state->priority is set in DRIVER_INIT + state->upd7807_porta = 0; + state->gfx_bank[0] = 0; + state->gfx_bank[1] = 0; // this is not used by reikaids +} + static MACHINE_DRIVER_START( mrokumei ) + /* driver data */ + MDRV_DRIVER_DATA(homedata_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6809, 16000000/4) /* 4MHz ? */ MDRV_CPU_PROGRAM_MAP(mrokumei_map) @@ -1178,6 +1265,9 @@ static MACHINE_DRIVER_START( mrokumei ) MDRV_CPU_PROGRAM_MAP(mrokumei_sound_map) MDRV_CPU_IO_MAP(mrokumei_sound_io_map) + MDRV_MACHINE_START(homedata) + MDRV_MACHINE_RESET(homedata) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(59) @@ -1232,6 +1322,9 @@ static const UPD7810_CONFIG upd_config = static MACHINE_DRIVER_START( reikaids ) + /* driver data */ + MDRV_DRIVER_DATA(homedata_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6809, 16000000/4) /* 4MHz ? */ MDRV_CPU_PROGRAM_MAP(reikaids_map) @@ -1245,7 +1338,8 @@ static MACHINE_DRIVER_START( reikaids ) MDRV_QUANTUM_TIME(HZ(30000)) // very high interleave required to sync for startup tests - MDRV_MACHINE_RESET(reikaids_upd7807) + MDRV_MACHINE_START(reikaids) + MDRV_MACHINE_RESET(reikaids) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -1282,6 +1376,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( pteacher ) + /* driver data */ + MDRV_DRIVER_DATA(homedata_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6809, 16000000/4) /* 4MHz ? */ MDRV_CPU_PROGRAM_MAP(pteacher_map) @@ -1295,7 +1392,8 @@ static MACHINE_DRIVER_START( pteacher ) MDRV_QUANTUM_TIME(HZ(6000)) // should be enough - MDRV_MACHINE_RESET(pteacher_upd7807) + MDRV_MACHINE_START(pteacher) + MDRV_MACHINE_RESET(pteacher) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -1785,29 +1883,31 @@ static DRIVER_INIT( mjikaga ) static DRIVER_INIT( reikaids ) { - homedata_priority=0; + homedata_state *state = (homedata_state *)machine->driver_data; + state->priority = 0; } static DRIVER_INIT( battlcry ) { - homedata_priority=1; /* priority and initial value for bank write */ + homedata_state *state = (homedata_state *)machine->driver_data; + state->priority = 1; /* priority and initial value for bank write */ } -GAME( 1987, hourouki, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Hourouki Part 1 - Seisyun Hen (Japan)", GAME_IMPERFECT_GRAPHICS ) -GAME( 1987, mhgaiden, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Hourouki Gaiden (Japan)", 0 ) -GAME( 1988, mjhokite, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Hourouki Okite (Japan)", 0 ) -GAME( 1988, mjclinic, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Clinic (Japan)", 0 ) -GAME( 1988, mrokumei, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Rokumeikan (Japan)", GAME_IMPERFECT_GRAPHICS ) +GAME( 1987, hourouki, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Hourouki Part 1 - Seisyun Hen (Japan)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) +GAME( 1987, mhgaiden, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Hourouki Gaiden (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1988, mjhokite, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Hourouki Okite (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1988, mjclinic, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Clinic (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1988, mrokumei, 0, mrokumei, mjhokite, 0, ROT0, "Home Data", "Mahjong Rokumeikan (Japan)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) -GAME( 1988, reikaids, 0, reikaids, reikaids, reikaids, ROT0, "Home Data", "Reikai Doushi (Japan)", 0 ) -GAME( 1991, battlcry, 0, reikaids, battlcry, battlcry, ROT0, "Home Data", "Battlecry", GAME_IMPERFECT_GRAPHICS ) -GAME( 1989, mjkojink, 0, pteacher, pteacher, 0, ROT0, "Home Data", "Mahjong Kojinkyouju (Private Teacher) (Japan)", 0 ) -GAME( 1989, vitaminc, 0, pteacher, pteacher, 0, ROT0, "Home Data", "Mahjong Vitamin C (Japan)", 0 ) -GAME( 1989, mjyougo, 0, pteacher, pteacher, 0, ROT0, "Home Data", "Mahjong-yougo no Kisotairyoku (Japan)", 0 ) -GAME( 1991, mjkinjas, 0, mjkinjas, pteacher, 0, ROT0, "Home Data", "Mahjong Kinjirareta Asobi (Japan)", 0 ) -GAME( 1992?,jogakuen, 0, pteacher, jogakuen, jogakuen, ROT0, "Windom", "Mahjong Jogakuen (Japan)", 0 ) +GAME( 1988, reikaids, 0, reikaids, reikaids, reikaids, ROT0, "Home Data", "Reikai Doushi (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1991, battlcry, 0, reikaids, battlcry, battlcry, ROT0, "Home Data", "Battlecry", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) +GAME( 1989, mjkojink, 0, pteacher, pteacher, 0, ROT0, "Home Data", "Mahjong Kojinkyouju (Private Teacher) (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1989, vitaminc, 0, pteacher, pteacher, 0, ROT0, "Home Data", "Mahjong Vitamin C (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1989, mjyougo, 0, pteacher, pteacher, 0, ROT0, "Home Data", "Mahjong-yougo no Kisotairyoku (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1991, mjkinjas, 0, mjkinjas, pteacher, 0, ROT0, "Home Data", "Mahjong Kinjirareta Asobi (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1992?,jogakuen, 0, pteacher, jogakuen, jogakuen, ROT0, "Windom", "Mahjong Jogakuen (Japan)", GAME_SUPPORTS_SAVE ) -GAME( 1990, lemnangl, 0, lemnangl, pteacher, 0, ROT0, "Home Data", "Mahjong Lemon Angel (Japan)", 0 ) -GAME( 1991, mjprivat, 0, lemnangl, pteacher, 0, ROT0, "Matoba", "Mahjong Private (Japan)", 0 ) +GAME( 1990, lemnangl, 0, lemnangl, pteacher, 0, ROT0, "Home Data", "Mahjong Lemon Angel (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1991, mjprivat, 0, lemnangl, pteacher, 0, ROT0, "Matoba", "Mahjong Private (Japan)", GAME_SUPPORTS_SAVE ) -GAME( 1991?,mjikaga, 0, lemnangl, mjikaga, mjikaga, ROT0, "Mitchell", "Mahjong Ikaga Desu ka (Japan)", GAME_IMPERFECT_SOUND ) +GAME( 1991?,mjikaga, 0, lemnangl, mjikaga, mjikaga, ROT0, "Mitchell", "Mahjong Ikaga Desu ka (Japan)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/hyprduel.c b/src/mame/drivers/hyprduel.c index 34e6f4aba80..b1d723039ef 100644 --- a/src/mame/drivers/hyprduel.c +++ b/src/mame/drivers/hyprduel.c @@ -42,64 +42,58 @@ fix comms so it boots, it's a bit of a hack for hyperduel at the moment ;-) #include "sound/2413intf.h" #include "includes/hyprduel.h" - -static int blitter_bit; -static int requested_int; -static UINT16 *hyprduel_irq_enable; -static int subcpu_resetline; -static int cpu_trigger; -static int int_num; - -static UINT16 *sharedram1; -static UINT16 *sharedram3; - /*************************************************************************** Interrupts ***************************************************************************/ -static void update_irq_state(running_machine *machine) +static void update_irq_state( running_machine *machine ) { - int irq = requested_int & ~*hyprduel_irq_enable; + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + int irq = state->requested_int & ~*state->irq_enable; - cputag_set_input_line(machine, "maincpu", 3, (irq & int_num) ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(state->maincpu, 3, (irq & state->int_num) ? ASSERT_LINE : CLEAR_LINE); } static TIMER_CALLBACK( vblank_end_callback ) { - requested_int &= ~param; + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + state->requested_int &= ~param; } static INTERRUPT_GEN( hyprduel_interrupt ) { + hyprduel_state *state = (hyprduel_state *)device->machine->driver_data; int line = RASTER_LINES - cpu_getiloops(device); if (line == RASTER_LINES) { - requested_int |= 0x01; /* vblank */ - requested_int |= 0x20; + state->requested_int |= 0x01; /* vblank */ + state->requested_int |= 0x20; cpu_set_input_line(device, 2, HOLD_LINE); /* the duration is a guess */ timer_set(device->machine, ATTOTIME_IN_USEC(2500), NULL, 0x20, vblank_end_callback); - } else { - requested_int |= 0x12; /* hsync */ - } + } + else + state->requested_int |= 0x12; /* hsync */ update_irq_state(device->machine); } static READ16_HANDLER( hyprduel_irq_cause_r ) { - return requested_int; + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + return state->requested_int; } static WRITE16_HANDLER( hyprduel_irq_cause_w ) { + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - if (data == int_num) - requested_int &= ~(int_num & ~*hyprduel_irq_enable); + if (data == state->int_num) + state->requested_int &= ~(state->int_num & ~*state->irq_enable); else - requested_int &= ~(data & *hyprduel_irq_enable); + state->requested_int &= ~(data & *state->irq_enable); update_irq_state(space->machine); } @@ -108,30 +102,32 @@ static WRITE16_HANDLER( hyprduel_irq_cause_w ) static WRITE16_HANDLER( hyprduel_subcpu_control_w ) { + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + switch (data) { case 0x0d: case 0x0f: case 0x01: - if (!subcpu_resetline) + if (!state->subcpu_resetline) { - cputag_set_input_line(space->machine, "sub", INPUT_LINE_RESET, ASSERT_LINE); - subcpu_resetline = 1; + cpu_set_input_line(state->subcpu, INPUT_LINE_RESET, ASSERT_LINE); + state->subcpu_resetline = 1; } break; case 0x00: - if (subcpu_resetline) + if (state->subcpu_resetline) { - cputag_set_input_line(space->machine, "sub", INPUT_LINE_RESET, CLEAR_LINE); - subcpu_resetline = 0; + cpu_set_input_line(state->subcpu, INPUT_LINE_RESET, CLEAR_LINE); + state->subcpu_resetline = 0; } cpu_spinuntil_int(space->cpu); break; case 0x0c: case 0x80: - cputag_set_input_line(space->machine, "sub", 2, HOLD_LINE); + cpu_set_input_line(state->subcpu, 2, HOLD_LINE); break; } } @@ -139,25 +135,27 @@ static WRITE16_HANDLER( hyprduel_subcpu_control_w ) static READ16_HANDLER( hyprduel_cpusync_trigger1_r ) { - if (cpu_trigger == 1001) + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + if (state->cpu_trigger == 1001) { cpuexec_trigger(space->machine, 1001); - cpu_trigger = 0; + state->cpu_trigger = 0; } - return sharedram1[0x000408/2 + offset]; + return state->sharedram1[0x000408 / 2 + offset]; } static WRITE16_HANDLER( hyprduel_cpusync_trigger1_w ) { - COMBINE_DATA(&sharedram1[0x00040e/2 + offset]); + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + COMBINE_DATA(&state->sharedram1[0x00040e / 2 + offset]); - if (((sharedram1[0x00040e/2]<<16) + sharedram1[0x000410/2]) != 0x00) + if (((state->sharedram1[0x00040e / 2] << 16) + state->sharedram1[0x000410 / 2]) != 0x00) { - if (!cpu_trigger && !subcpu_resetline) + if (!state->cpu_trigger && !state->subcpu_resetline) { cpu_spinuntil_trigger(space->cpu, 1001); - cpu_trigger = 1001; + state->cpu_trigger = 1001; } } } @@ -165,35 +163,36 @@ static WRITE16_HANDLER( hyprduel_cpusync_trigger1_w ) static READ16_HANDLER( hyprduel_cpusync_trigger2_r ) { - if (cpu_trigger == 1002) + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + if (state->cpu_trigger == 1002) { cpuexec_trigger(space->machine, 1002); - cpu_trigger = 0; + state->cpu_trigger = 0; } - return sharedram3[(0xfff34c - 0xfe4000)/2 + offset]; + return state->sharedram3[(0xfff34c - 0xfe4000) / 2 + offset]; } static WRITE16_HANDLER( hyprduel_cpusync_trigger2_w ) { - COMBINE_DATA(&sharedram1[0x000408/2 + offset]); + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + COMBINE_DATA(&state->sharedram1[0x000408 / 2 + offset]); if (ACCESSING_BITS_8_15) { - if (!cpu_trigger && !subcpu_resetline) + if (!state->cpu_trigger && !state->subcpu_resetline) { cpu_spinuntil_trigger(space->cpu, 1002); - cpu_trigger = 1002; + state->cpu_trigger = 1002; } } } -static emu_timer *magerror_irq_timer; - static TIMER_CALLBACK( magerror_irq_callback ) { - cputag_set_input_line(machine, "sub", 1, HOLD_LINE); + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + cpu_set_input_line(state->subcpu, 1, HOLD_LINE); } /*************************************************************************** @@ -208,17 +207,18 @@ static TIMER_CALLBACK( magerror_irq_callback ) that the blitter can readily use (which is a form of compression) */ -static UINT16 *hyprduel_rombank; - static READ16_HANDLER( hyprduel_bankedrom_r ) { - UINT8 *ROM = memory_region( space->machine, "gfx1" ); - size_t len = memory_region_length( space->machine, "gfx1" ); + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + UINT8 *ROM = memory_region(space->machine, "gfx1"); + size_t len = memory_region_length(space->machine, "gfx1"); - offset = offset * 2 + 0x10000 * (*hyprduel_rombank); + offset = offset * 2 + 0x10000 * (*state->rombank); - if ( offset < len ) return ((ROM[offset+0]<<8)+ROM[offset+1]); - else return 0xffff; + if (offset < len) + return ((ROM[offset + 0] << 8) + ROM[offset + 1]); + else + return 0xffff; } /*************************************************************************** @@ -265,76 +265,73 @@ static READ16_HANDLER( hyprduel_bankedrom_r ) ***************************************************************************/ -static UINT16 *hyprduel_blitter_regs; - static TIMER_CALLBACK( hyprduel_blit_done ) { - requested_int |= 1 << blitter_bit; + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + state->requested_int |= 1 << state->blitter_bit; update_irq_state(machine); } -INLINE int blt_read(const UINT8 *ROM, const int offs) +INLINE int blt_read( const UINT8 *ROM, const int offs ) { return ROM[offs]; } -INLINE void blt_write(const address_space *space, const int tmap, const offs_t offs, const UINT16 data, const UINT16 mask) +INLINE void blt_write( const address_space *space, const int tmap, const offs_t offs, const UINT16 data, const UINT16 mask ) { switch( tmap ) { case 1: hyprduel_vram_0_w(space,offs,data,mask); break; - case 2: hyprduel_vram_1_w(space,offs,data,mask); break; - case 3: hyprduel_vram_2_w(space,offs,data,mask); break; + case 2: hyprduel_vram_1_w(space, offs, data, mask); break; + case 3: hyprduel_vram_2_w(space, offs, data, mask); break; } -// logerror("%s : Blitter %X] %04X <- %04X & %04X\n",cpuexec_describe_context(space->machine),tmap,offs,data,mask); +// logerror("%s : Blitter %X] %04X <- %04X & %04X\n", cpuexec_describe_context(space->machine), tmap, offs, data, mask); } static WRITE16_HANDLER( hyprduel_blitter_w ) { - COMBINE_DATA( &hyprduel_blitter_regs[offset] ); + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + COMBINE_DATA(&state->blitter_regs[offset]); - if (offset == 0xC/2) + if (offset == 0xc / 2) { - UINT8 *src = memory_region(space->machine, "gfx1"); - size_t src_len = memory_region_length(space->machine, "gfx1"); + UINT8 *src = memory_region(space->machine, "gfx1"); + size_t src_len = memory_region_length(space->machine, "gfx1"); - UINT32 tmap = (hyprduel_blitter_regs[ 0x00 / 2 ] << 16 ) + - hyprduel_blitter_regs[ 0x02 / 2 ]; - UINT32 src_offs = (hyprduel_blitter_regs[ 0x04 / 2 ] << 16 ) + - hyprduel_blitter_regs[ 0x06 / 2 ]; - UINT32 dst_offs = (hyprduel_blitter_regs[ 0x08 / 2 ] << 16 ) + - hyprduel_blitter_regs[ 0x0a / 2 ]; + UINT32 tmap = (state->blitter_regs[0x00 / 2] << 16) + state->blitter_regs[0x02 / 2]; + UINT32 src_offs = (state->blitter_regs[0x04 / 2] << 16) + state->blitter_regs[0x06 / 2]; + UINT32 dst_offs = (state->blitter_regs[0x08 / 2] << 16) + state->blitter_regs[0x0a / 2]; - int shift = (dst_offs & 0x80) ? 0 : 8; - UINT16 mask = (dst_offs & 0x80) ? 0x00ff : 0xff00; + int shift = (dst_offs & 0x80) ? 0 : 8; + UINT16 mask = (dst_offs & 0x80) ? 0x00ff : 0xff00; -// logerror("CPU #0 PC %06X : Blitter regs %08X, %08X, %08X\n",cpu_get_pc(space->cpu),tmap,src_offs,dst_offs); +// logerror("CPU #0 PC %06X : Blitter regs %08X, %08X, %08X\n", cpu_get_pc(space->cpu), tmap, src_offs, dst_offs); - dst_offs >>= 7+1; - switch( tmap ) + dst_offs >>= 7 + 1; + switch (tmap) { case 1: case 2: case 3: break; default: - logerror("CPU #0 PC %06X : Blitter unknown destination: %08X\n",cpu_get_pc(space->cpu),tmap); + logerror("CPU #0 PC %06X : Blitter unknown destination: %08X\n", cpu_get_pc(space->cpu), tmap); return; } while (1) { - UINT16 b1,b2,count; + UINT16 b1, b2, count; src_offs %= src_len; - b1 = blt_read(src,src_offs); -// logerror("CPU #0 PC %06X : Blitter opcode %02X at %06X\n",cpu_get_pc(space->cpu),b1,src_offs); + b1 = blt_read(src, src_offs); +// logerror("CPU #0 PC %06X : Blitter opcode %02X at %06X\n", cpu_get_pc(space->cpu), b1, src_offs); src_offs++; count = ((~b1) & 0x3f) + 1; - switch( (b1 & 0xc0) >> 6 ) + switch ((b1 & 0xc0) >> 6) { case 0: @@ -345,7 +342,7 @@ static WRITE16_HANDLER( hyprduel_blitter_w ) another blit. */ if (b1 == 0) { - timer_set(space->machine, ATTOTIME_IN_USEC(500), NULL,0,hyprduel_blit_done); + timer_set(space->machine, ATTOTIME_IN_USEC(500), NULL, 0, hyprduel_blit_done); return; } @@ -353,12 +350,12 @@ static WRITE16_HANDLER( hyprduel_blitter_w ) while (count--) { src_offs %= src_len; - b2 = blt_read(src,src_offs) << shift; + b2 = blt_read(src, src_offs) << shift; src_offs++; dst_offs &= 0xffff; - blt_write(space,tmap,dst_offs,b2,mask); - dst_offs = ((dst_offs+1) & (0x100-1)) | (dst_offs & (~(0x100-1))); + blt_write(space, tmap, dst_offs, b2, mask); + dst_offs = ((dst_offs + 1) & (0x100 - 1)) | (dst_offs & (~(0x100 - 1))); } break; @@ -367,14 +364,14 @@ static WRITE16_HANDLER( hyprduel_blitter_w ) /* Fill with an increasing value */ src_offs %= src_len; - b2 = blt_read(src,src_offs); + b2 = blt_read(src, src_offs); src_offs++; while (count--) { dst_offs &= 0xffff; - blt_write(space,tmap,dst_offs,b2<> (7+1)); + dst_offs += 0x100; + dst_offs &= ~(0x100 - 1); + dst_offs |= (0x100 - 1) & (state->blitter_regs[0x0a / 2] >> (7 + 1)); } else { @@ -413,7 +410,7 @@ static WRITE16_HANDLER( hyprduel_blitter_w ) default: - logerror("CPU #0 PC %06X : Blitter unknown opcode %02X at %06X\n",cpu_get_pc(space->cpu),b1,src_offs-1); + logerror("CPU #0 PC %06X : Blitter unknown opcode %02X at %06X\n", cpu_get_pc(space->cpu), b1, src_offs - 1); return; } @@ -428,34 +425,34 @@ static WRITE16_HANDLER( hyprduel_blitter_w ) static ADDRESS_MAP_START( hyprduel_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0x400000, 0x41ffff) AM_RAM_WRITE(hyprduel_vram_0_w) AM_BASE(&hyprduel_vram_0) /* Layer 0 */ - AM_RANGE(0x420000, 0x43ffff) AM_RAM_WRITE(hyprduel_vram_1_w) AM_BASE(&hyprduel_vram_1) /* Layer 1 */ - AM_RANGE(0x440000, 0x45ffff) AM_RAM_WRITE(hyprduel_vram_2_w) AM_BASE(&hyprduel_vram_2) /* Layer 2 */ + AM_RANGE(0x400000, 0x41ffff) AM_RAM_WRITE(hyprduel_vram_0_w) AM_BASE_MEMBER(hyprduel_state, vram_0) /* Layer 0 */ + AM_RANGE(0x420000, 0x43ffff) AM_RAM_WRITE(hyprduel_vram_1_w) AM_BASE_MEMBER(hyprduel_state, vram_1) /* Layer 1 */ + AM_RANGE(0x440000, 0x45ffff) AM_RAM_WRITE(hyprduel_vram_2_w) AM_BASE_MEMBER(hyprduel_state, vram_2) /* Layer 2 */ AM_RANGE(0x460000, 0x46ffff) AM_READ(hyprduel_bankedrom_r) /* Banked ROM */ - AM_RANGE(0x470000, 0x473fff) AM_RAM_WRITE(hyprduel_paletteram_w) AM_BASE_GENERIC(paletteram) /* Palette */ - AM_RANGE(0x474000, 0x474fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Sprites */ + AM_RANGE(0x470000, 0x473fff) AM_RAM_WRITE(hyprduel_paletteram_w) AM_BASE_MEMBER(hyprduel_state, paletteram) /* Palette */ + AM_RANGE(0x474000, 0x474fff) AM_RAM AM_BASE_SIZE_MEMBER(hyprduel_state, spriteram, spriteram_size) /* Sprites */ AM_RANGE(0x475000, 0x477fff) AM_RAM /* only used memory test */ - AM_RANGE(0x478000, 0x4787ff) AM_RAM AM_BASE(&hyprduel_tiletable) AM_SIZE(&hyprduel_tiletable_size) /* Tiles Set */ - AM_RANGE(0x478840, 0x47884d) AM_WRITE(hyprduel_blitter_w) AM_BASE(&hyprduel_blitter_regs) /* Tiles Blitter */ - AM_RANGE(0x478860, 0x47886b) AM_WRITE(hyprduel_window_w) AM_BASE(&hyprduel_window) /* Tilemap Window */ - AM_RANGE(0x478870, 0x47887b) AM_RAM_WRITE(hyprduel_scrollreg_w) AM_BASE(&hyprduel_scroll) /* Scroll Regs */ + AM_RANGE(0x478000, 0x4787ff) AM_RAM AM_BASE_SIZE_MEMBER(hyprduel_state, tiletable, tiletable_size) /* Tiles Set */ + AM_RANGE(0x478840, 0x47884d) AM_WRITE(hyprduel_blitter_w) AM_BASE_MEMBER(hyprduel_state, blitter_regs) /* Tiles Blitter */ + AM_RANGE(0x478860, 0x47886b) AM_WRITE(hyprduel_window_w) AM_BASE_MEMBER(hyprduel_state, window) /* Tilemap Window */ + AM_RANGE(0x478870, 0x47887b) AM_RAM_WRITE(hyprduel_scrollreg_w) AM_BASE_MEMBER(hyprduel_state, scroll) /* Scroll Regs */ AM_RANGE(0x47887c, 0x47887d) AM_WRITE(hyprduel_scrollreg_init_w) AM_RANGE(0x478880, 0x478881) AM_WRITENOP AM_RANGE(0x478890, 0x478891) AM_WRITENOP AM_RANGE(0x4788a0, 0x4788a1) AM_WRITENOP AM_RANGE(0x4788a2, 0x4788a3) AM_READWRITE(hyprduel_irq_cause_r, hyprduel_irq_cause_w) /* IRQ Cause,Acknowledge */ - AM_RANGE(0x4788a4, 0x4788a5) AM_RAM AM_BASE(&hyprduel_irq_enable) /* IRQ Enable */ - AM_RANGE(0x4788aa, 0x4788ab) AM_RAM AM_BASE(&hyprduel_rombank) /* Rom Bank */ - AM_RANGE(0x4788ac, 0x4788ad) AM_RAM AM_BASE(&hyprduel_screenctrl) /* Screen Control */ - AM_RANGE(0x479700, 0x479713) AM_RAM AM_BASE(&hyprduel_videoregs) /* Video Registers */ + AM_RANGE(0x4788a4, 0x4788a5) AM_RAM AM_BASE_MEMBER(hyprduel_state, irq_enable) /* IRQ Enable */ + AM_RANGE(0x4788aa, 0x4788ab) AM_RAM AM_BASE_MEMBER(hyprduel_state, rombank) /* Rom Bank */ + AM_RANGE(0x4788ac, 0x4788ad) AM_RAM AM_BASE_MEMBER(hyprduel_state, screenctrl) /* Screen Control */ + AM_RANGE(0x479700, 0x479713) AM_RAM AM_BASE_MEMBER(hyprduel_state, videoregs) /* Video Registers */ AM_RANGE(0x800000, 0x800001) AM_WRITE(hyprduel_subcpu_control_w) - AM_RANGE(0xc00000, 0xc07fff) AM_RAM AM_SHARE("share1") AM_BASE(&sharedram1) + AM_RANGE(0xc00000, 0xc07fff) AM_RAM AM_SHARE("share1") AM_BASE_MEMBER(hyprduel_state, sharedram1) AM_RANGE(0xe00000, 0xe00001) AM_READ_PORT("SERVICE") AM_WRITENOP AM_RANGE(0xe00002, 0xe00003) AM_READ_PORT("DSW") AM_RANGE(0xe00004, 0xe00005) AM_READ_PORT("P1_P2") AM_RANGE(0xe00006, 0xe00007) AM_READ_PORT("SYSTEM") AM_RANGE(0xfe0000, 0xfe3fff) AM_RAM AM_SHARE("share2") - AM_RANGE(0xfe4000, 0xffffff) AM_RAM AM_SHARE("share3") AM_BASE(&sharedram3) + AM_RANGE(0xfe4000, 0xffffff) AM_RAM AM_SHARE("share3") AM_BASE_MEMBER(hyprduel_state, sharedram3) ADDRESS_MAP_END static ADDRESS_MAP_START( hyprduel_map2, ADDRESS_SPACE_PROGRAM, 16 ) @@ -475,33 +472,33 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( magerror_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0x400000, 0x400001) AM_WRITE(hyprduel_subcpu_control_w) - AM_RANGE(0x800000, 0x81ffff) AM_RAM_WRITE(hyprduel_vram_0_w) AM_BASE(&hyprduel_vram_0) /* Layer 0 */ - AM_RANGE(0x820000, 0x83ffff) AM_RAM_WRITE(hyprduel_vram_1_w) AM_BASE(&hyprduel_vram_1) /* Layer 1 */ - AM_RANGE(0x840000, 0x85ffff) AM_RAM_WRITE(hyprduel_vram_2_w) AM_BASE(&hyprduel_vram_2) /* Layer 2 */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM_WRITE(hyprduel_vram_0_w) AM_BASE_MEMBER(hyprduel_state, vram_0) /* Layer 0 */ + AM_RANGE(0x820000, 0x83ffff) AM_RAM_WRITE(hyprduel_vram_1_w) AM_BASE_MEMBER(hyprduel_state, vram_1) /* Layer 1 */ + AM_RANGE(0x840000, 0x85ffff) AM_RAM_WRITE(hyprduel_vram_2_w) AM_BASE_MEMBER(hyprduel_state, vram_2) /* Layer 2 */ AM_RANGE(0x860000, 0x86ffff) AM_READ(hyprduel_bankedrom_r) /* Banked ROM */ - AM_RANGE(0x870000, 0x873fff) AM_RAM_WRITE(hyprduel_paletteram_w) AM_BASE_GENERIC(paletteram) /* Palette */ - AM_RANGE(0x874000, 0x874fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Sprites */ + AM_RANGE(0x870000, 0x873fff) AM_RAM_WRITE(hyprduel_paletteram_w) AM_BASE_MEMBER(hyprduel_state, paletteram) /* Palette */ + AM_RANGE(0x874000, 0x874fff) AM_RAM AM_BASE_SIZE_MEMBER(hyprduel_state, spriteram, spriteram_size) /* Sprites */ AM_RANGE(0x875000, 0x877fff) AM_RAM /* only used memory test */ - AM_RANGE(0x878000, 0x8787ff) AM_RAM AM_BASE(&hyprduel_tiletable) AM_SIZE(&hyprduel_tiletable_size) /* Tiles Set */ - AM_RANGE(0x878840, 0x87884d) AM_WRITE(hyprduel_blitter_w) AM_BASE(&hyprduel_blitter_regs) /* Tiles Blitter */ - AM_RANGE(0x878860, 0x87886b) AM_WRITE(hyprduel_window_w) AM_BASE(&hyprduel_window) /* Tilemap Window */ - AM_RANGE(0x878870, 0x87887b) AM_RAM_WRITE(hyprduel_scrollreg_w) AM_BASE(&hyprduel_scroll) /* Scroll Regs */ + AM_RANGE(0x878000, 0x8787ff) AM_RAM AM_BASE_SIZE_MEMBER(hyprduel_state, tiletable, tiletable_size) /* Tiles Set */ + AM_RANGE(0x878840, 0x87884d) AM_WRITE(hyprduel_blitter_w) AM_BASE_MEMBER(hyprduel_state, blitter_regs) /* Tiles Blitter */ + AM_RANGE(0x878860, 0x87886b) AM_WRITE(hyprduel_window_w) AM_BASE_MEMBER(hyprduel_state, window) /* Tilemap Window */ + AM_RANGE(0x878870, 0x87887b) AM_RAM_WRITE(hyprduel_scrollreg_w) AM_BASE_MEMBER(hyprduel_state, scroll) /* Scroll Regs */ AM_RANGE(0x87887c, 0x87887d) AM_WRITE(hyprduel_scrollreg_init_w) AM_RANGE(0x878880, 0x878881) AM_WRITENOP AM_RANGE(0x878890, 0x878891) AM_WRITENOP AM_RANGE(0x8788a0, 0x8788a1) AM_WRITENOP AM_RANGE(0x8788a2, 0x8788a3) AM_READWRITE(hyprduel_irq_cause_r, hyprduel_irq_cause_w) /* IRQ Cause, Acknowledge */ - AM_RANGE(0x8788a4, 0x8788a5) AM_RAM AM_BASE(&hyprduel_irq_enable) /* IRQ Enable */ - AM_RANGE(0x8788aa, 0x8788ab) AM_RAM AM_BASE(&hyprduel_rombank) /* Rom Bank */ - AM_RANGE(0x8788ac, 0x8788ad) AM_RAM AM_BASE(&hyprduel_screenctrl) /* Screen Control */ - AM_RANGE(0x879700, 0x879713) AM_RAM AM_BASE(&hyprduel_videoregs) /* Video Registers */ - AM_RANGE(0xc00000, 0xc1ffff) AM_RAM AM_SHARE("share1") AM_BASE(&sharedram1) + AM_RANGE(0x8788a4, 0x8788a5) AM_RAM AM_BASE_MEMBER(hyprduel_state, irq_enable) /* IRQ Enable */ + AM_RANGE(0x8788aa, 0x8788ab) AM_RAM AM_BASE_MEMBER(hyprduel_state, rombank) /* Rom Bank */ + AM_RANGE(0x8788ac, 0x8788ad) AM_RAM AM_BASE_MEMBER(hyprduel_state, screenctrl) /* Screen Control */ + AM_RANGE(0x879700, 0x879713) AM_RAM AM_BASE_MEMBER(hyprduel_state, videoregs) /* Video Registers */ + AM_RANGE(0xc00000, 0xc1ffff) AM_RAM AM_SHARE("share1") AM_BASE_MEMBER(hyprduel_state, sharedram1) AM_RANGE(0xe00000, 0xe00001) AM_READ_PORT("SERVICE") AM_WRITENOP AM_RANGE(0xe00002, 0xe00003) AM_READ_PORT("DSW") AM_RANGE(0xe00004, 0xe00005) AM_READ_PORT("P1_P2") AM_RANGE(0xe00006, 0xe00007) AM_READ_PORT("SYSTEM") AM_RANGE(0xfe0000, 0xfe3fff) AM_RAM AM_SHARE("share2") - AM_RANGE(0xfe4000, 0xffffff) AM_RAM AM_SHARE("share3") AM_BASE(&sharedram3) + AM_RANGE(0xfe4000, 0xffffff) AM_RAM AM_SHARE("share3") AM_BASE_MEMBER(hyprduel_state, sharedram3) ADDRESS_MAP_END static ADDRESS_MAP_START( magerror_map2, ADDRESS_SPACE_PROGRAM, 16 ) @@ -519,27 +516,6 @@ ADDRESS_MAP_END Input Ports ***************************************************************************/ -#define JOY_LSB(_n_, _b1_, _b2_, _b3_, _b4_) \ - PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_##_b1_ ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_##_b2_ ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_##_b3_ ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_##_b4_ ) PORT_PLAYER(_n_) \ - -#define JOY_MSB(_n_, _b1_, _b2_, _b3_, _b4_) \ - PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_##_b1_ ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_##_b2_ ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_##_b3_ ) PORT_PLAYER(_n_) \ - PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_##_b4_ ) PORT_PLAYER(_n_) \ - - static INPUT_PORTS_START( hyprduel ) PORT_START("SERVICE") PORT_SERVICE_NO_TOGGLE( 0x8000, IP_ACTIVE_LOW ) @@ -590,16 +566,30 @@ static INPUT_PORTS_START( hyprduel ) PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("P1_P2") - JOY_LSB(1, BUTTON1, BUTTON2, BUTTON3, UNKNOWN) - JOY_MSB(2, BUTTON1, BUTTON2, BUTTON3, UNKNOWN) + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_PLAYER(1) + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_PLAYER(2) PORT_START("SYSTEM") - PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) - PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2) + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_SERVICE2 ) - PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START1 ) - PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START2 ) + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START1 ) + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END @@ -607,45 +597,9 @@ static INPUT_PORTS_START( magerror ) PORT_INCLUDE( hyprduel ) PORT_MODIFY("DSW") - PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) ) - PORT_DIPSETTING( 0x0001, DEF_STR( 4C_1C ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x0003, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x0007, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x0006, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x0005, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( Free_Play ) ) - PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( 4C_1C ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x0018, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x0038, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x0030, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x0028, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( Free_Play ) ) - PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Demo_Sounds ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) PORT_DIPNAME( 0x0080, 0x0080, "Start Up Mode" ) PORT_DIPSETTING( 0x0080, "Game Mode" ) PORT_DIPSETTING( 0x0000, "Test Mode" ) - PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Flip_Screen ) ) - PORT_DIPSETTING( 0x0100, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) ) - PORT_DIPSETTING( 0x0800, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x0c00, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x0400, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( Very_Hard ) ) - PORT_DIPNAME( 0x3000, 0x3000, DEF_STR( Lives ) ) - PORT_DIPSETTING( 0x2000, "2" ) - PORT_DIPSETTING( 0x3000, "3" ) - PORT_DIPSETTING( 0x1000, "4" ) - PORT_DIPSETTING( 0x0000, "5" ) - PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END /*************************************************************************** @@ -667,9 +621,10 @@ GFXDECODE_END Sound Communication ***************************************************************************/ -static void sound_irq(const device_config *device, int state) +static void sound_irq( const device_config *device, int state ) { - cputag_set_input_line(device->machine, "sub", 1, HOLD_LINE); + hyprduel_state *hyprduel = (hyprduel_state *)device->machine->driver_data; + cpu_set_input_line(hyprduel->subcpu, 1, HOLD_LINE); } static const ym2151_interface ym2151_config = @@ -683,23 +638,44 @@ static const ym2151_interface ym2151_config = static MACHINE_RESET( hyprduel ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + /* start with cpu2 halted */ cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, ASSERT_LINE); - subcpu_resetline = 1; - cpu_trigger = 0; + state->subcpu_resetline = 1; + state->cpu_trigger = 0; - requested_int = 0x00; - blitter_bit = 2; - *hyprduel_irq_enable = 0xff; + state->requested_int = 0x00; + state->blitter_bit = 2; + *state->irq_enable = 0xff; +} + +static MACHINE_START( hyprduel ) +{ + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->subcpu = devtag_get_device(machine, "sub"); + + state_save_register_global(machine, state->blitter_bit); + state_save_register_global(machine, state->requested_int); + state_save_register_global(machine, state->subcpu_resetline); + state_save_register_global(machine, state->cpu_trigger); } static MACHINE_START( magerror ) { - timer_adjust_periodic(magerror_irq_timer, attotime_zero, 0, ATTOTIME_IN_HZ(968)); /* tempo? */ + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + + MACHINE_START_CALL(hyprduel); + timer_adjust_periodic(state->magerror_irq_timer, attotime_zero, 0, ATTOTIME_IN_HZ(968)); /* tempo? */ } static MACHINE_DRIVER_START( hyprduel ) + /* driver data */ + MDRV_DRIVER_DATA(hyprduel_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,20000000/2) /* 10MHz */ MDRV_CPU_PROGRAM_MAP(hyprduel_map) @@ -708,6 +684,7 @@ static MACHINE_DRIVER_START( hyprduel ) MDRV_CPU_ADD("sub", M68000,20000000/2) /* 10MHz */ MDRV_CPU_PROGRAM_MAP(hyprduel_map2) + MDRV_MACHINE_START(hyprduel) MDRV_MACHINE_RESET(hyprduel) /* video hardware */ @@ -743,6 +720,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( magerror ) + /* driver data */ + MDRV_DRIVER_DATA(hyprduel_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,20000000/2) /* 10MHz */ MDRV_CPU_PROGRAM_MAP(magerror_map) @@ -767,7 +747,7 @@ static MACHINE_DRIVER_START( magerror ) MDRV_GFXDECODE(14220) MDRV_PALETTE_LENGTH(8192) - MDRV_VIDEO_START(hyprduel_14220) + MDRV_VIDEO_START(magerror_14220) MDRV_VIDEO_UPDATE(hyprduel) /* sound hardware */ @@ -833,20 +813,11 @@ ROM_START( magerror ) ROM_END -static void savestate(running_machine *machine) -{ - /* Set up save state */ - state_save_register_global(machine, blitter_bit); - state_save_register_global(machine, requested_int); - state_save_register_global(machine, subcpu_resetline); - state_save_register_global(machine, cpu_trigger); - state_save_register_global(machine, int_num); -} - static DRIVER_INIT( hyprduel ) { - int_num = 0x02; - savestate(machine); + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + + state->int_num = 0x02; /* cpu synchronization (severe timings) */ memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc0040e, 0xc00411, 0, 0, hyprduel_cpusync_trigger1_w); @@ -857,10 +828,10 @@ static DRIVER_INIT( hyprduel ) static DRIVER_INIT( magerror ) { - int_num = 0x01; - savestate(machine); + hyprduel_state *state = (hyprduel_state *)machine->driver_data; - magerror_irq_timer = timer_alloc(machine, magerror_irq_callback, NULL); + state->int_num = 0x01; + state->magerror_irq_timer = timer_alloc(machine, magerror_irq_callback, NULL); } diff --git a/src/mame/includes/glass.h b/src/mame/includes/glass.h new file mode 100644 index 00000000000..1fad5fb297a --- /dev/null +++ b/src/mame/includes/glass.h @@ -0,0 +1,32 @@ +/************************************************************************* + + Glass + +*************************************************************************/ + +typedef struct _glass_state glass_state; +struct _glass_state +{ + /* memory pointers */ + UINT16 * videoram; + UINT16 * vregs; + UINT16 * spriteram; +// UINT16 * paletteram; // currently this uses generic palette handling + + /* video-related */ + tilemap *pant[2]; + bitmap_t *screen_bitmap; + + /* misc */ + int current_bit, current_command, cause_interrupt; + int blitter_serial_buffer[5]; +}; + + +/*----------- defined in video/glass.c -----------*/ + +WRITE16_HANDLER( glass_vram_w ); +WRITE16_HANDLER( glass_blitter_w ); + +VIDEO_START( glass ); +VIDEO_UPDATE( glass ); diff --git a/src/mame/includes/homedata.h b/src/mame/includes/homedata.h index 490cc65b1a3..c8329096e50 100644 --- a/src/mame/includes/homedata.h +++ b/src/mame/includes/homedata.h @@ -1,9 +1,42 @@ -/*----------- defined in video/homedata.c -----------*/ -extern UINT8 *homedata_vreg; -extern int homedata_visible_page; -extern int homedata_priority; -extern UINT8 reikaids_which; +typedef struct _homedata_state homedata_state; +struct _homedata_state +{ + /* memory pointers */ + UINT8 * vreg; + UINT8 * videoram; + + /* video-related */ + tilemap *bg_tilemap[2][4]; + int visible_page; + int priority; + UINT8 reikaids_which; + int flipscreen; + UINT8 gfx_bank[2]; // pteacher only uses the first one + UINT8 blitter_bank; + int blitter_param_count; + UINT8 blitter_param[4]; /* buffers last 4 writes to 0x8006 */ + + + /* misc */ + int vblank; + int sndbank; + int keyb; + int snd_command; + int upd7807_porta, upd7807_portc; + int to_cpu, from_cpu; + + /* device */ + const device_config *maincpu; + const device_config *audiocpu; + const device_config *dac; + const device_config *ym; + const device_config *sn; +}; + + + +/*----------- defined in video/homedata.c -----------*/ WRITE8_HANDLER( mrokumei_videoram_w ); WRITE8_HANDLER( reikaids_videoram_w ); diff --git a/src/mame/includes/hyprduel.h b/src/mame/includes/hyprduel.h index ecd1b5414d7..1e395197335 100644 --- a/src/mame/includes/hyprduel.h +++ b/src/mame/includes/hyprduel.h @@ -2,15 +2,52 @@ #define FIRST_VISIBLE_LINE 0 #define LAST_VISIBLE_LINE 223 +typedef struct _hyprduel_state hyprduel_state; +struct _hyprduel_state +{ + /* memory pointers */ + UINT16 * videoregs; + UINT16 * screenctrl; + UINT16 * tiletable_old; + UINT16 * tiletable; + UINT16 * vram_0; + UINT16 * vram_1; + UINT16 * vram_2; + UINT16 * window; + UINT16 * scroll; + UINT16 * rombank; + UINT16 * blitter_regs; + UINT16 * irq_enable; + UINT16 * sharedram1; + UINT16 * sharedram3; + UINT16 * spriteram; + UINT16 * paletteram; + size_t tiletable_size; + size_t spriteram_size; + + /* video-related */ + tilemap *bg_tilemap[3]; + UINT8 *empty_tiles; + UINT8 *dirtyindex; + int sprite_xoffs, sprite_yoffs, sprite_yoffs_sub; + + /* misc */ + emu_timer *magerror_irq_timer; + int blitter_bit; + int requested_int; + int subcpu_resetline; + int cpu_trigger; + int int_num; + + /* devices */ + const device_config *maincpu; + const device_config *subcpu; +}; + + + /*----------- defined in video/hyprduel.c -----------*/ -extern UINT16 *hyprduel_videoregs; -extern UINT16 *hyprduel_screenctrl; -extern UINT16 *hyprduel_tiletable; -extern size_t hyprduel_tiletable_size; -extern UINT16 *hyprduel_vram_0, *hyprduel_vram_1, *hyprduel_vram_2; -extern UINT16 *hyprduel_window; -extern UINT16 *hyprduel_scroll; WRITE16_HANDLER( hyprduel_paletteram_w ); WRITE16_HANDLER( hyprduel_window_w ); @@ -19,6 +56,7 @@ WRITE16_HANDLER( hyprduel_vram_1_w ); WRITE16_HANDLER( hyprduel_vram_2_w ); WRITE16_HANDLER( hyprduel_scrollreg_w ); WRITE16_HANDLER( hyprduel_scrollreg_init_w ); -VIDEO_START( hyprduel_14220 ); -VIDEO_UPDATE( hyprduel ); +VIDEO_START( hyprduel_14220 ); +VIDEO_START( magerror_14220 ); +VIDEO_UPDATE( hyprduel ); diff --git a/src/mame/video/glass.c b/src/mame/video/glass.c index 15c03024e2c..55e71f7f032 100644 --- a/src/mame/video/glass.c +++ b/src/mame/video/glass.c @@ -7,17 +7,7 @@ ***************************************************************************/ #include "driver.h" - -UINT16 *glass_spriteram; -UINT16 *glass_vregs; -UINT16 *glass_videoram; - -static tilemap *pant[2]; -static bitmap_t *screen_bitmap; - -static int glass_blitter_serial_buffer[5]; -static int current_command = 0; -int glass_current_bit = 0; +#include "includes/glass.h" /*************************************************************************** @@ -43,8 +33,9 @@ int glass_current_bit = 0; static TILE_GET_INFO( get_tile_info_glass_screen0 ) { - int data = glass_videoram[tile_index << 1]; - int data2 = glass_videoram[(tile_index << 1) + 1]; + glass_state *state = (glass_state *)machine->driver_data; + int data = state->videoram[tile_index << 1]; + int data2 = state->videoram[(tile_index << 1) + 1]; int code = ((data & 0x03) << 14) | ((data & 0x0fffc) >> 2); SET_TILE_INFO(0, code, 0x20 + (data2 & 0x1f), TILE_FLIPYX((data2 & 0xc0) >> 6)); @@ -53,8 +44,9 @@ static TILE_GET_INFO( get_tile_info_glass_screen0 ) static TILE_GET_INFO( get_tile_info_glass_screen1 ) { - int data = glass_videoram[(0x1000/2) + (tile_index << 1)]; - int data2 = glass_videoram[(0x1000/2) + (tile_index << 1) + 1]; + glass_state *state = (glass_state *)machine->driver_data; + int data = state->videoram[(0x1000 / 2) + (tile_index << 1)]; + int data2 = state->videoram[(0x1000 / 2) + (tile_index << 1) + 1]; int code = ((data & 0x03) << 14) | ((data & 0x0fffc) >> 2); SET_TILE_INFO(0, code, 0x20 + (data2 & 0x1f), TILE_FLIPYX((data2 & 0xc0) >> 6)); @@ -77,35 +69,40 @@ static TILE_GET_INFO( get_tile_info_glass_screen1 ) WRITE16_HANDLER( glass_blitter_w ) { - glass_blitter_serial_buffer[glass_current_bit] = data & 0x01; - glass_current_bit++; + glass_state *state = (glass_state *)space->machine->driver_data; + state->blitter_serial_buffer[state->current_bit] = data & 0x01; + state->current_bit++; - if (glass_current_bit == 5){ - current_command = (glass_blitter_serial_buffer[0] << 4) | - (glass_blitter_serial_buffer[1] << 3) | - (glass_blitter_serial_buffer[2] << 2) | - (glass_blitter_serial_buffer[3] << 1) | - (glass_blitter_serial_buffer[4] << 0); - glass_current_bit = 0; + if (state->current_bit == 5) + { + state->current_command = (state->blitter_serial_buffer[0] << 4) | + (state->blitter_serial_buffer[1] << 3) | + (state->blitter_serial_buffer[2] << 2) | + (state->blitter_serial_buffer[3] << 1) | + (state->blitter_serial_buffer[4] << 0); + state->current_bit = 0; /* fill the screen bitmap with the current picture */ { int i, j; UINT8 *gfx = (UINT8 *)memory_region(space->machine, "gfx3"); - gfx = gfx + (current_command & 0x07)*0x10000 + (current_command & 0x08)*0x10000 + 0x140; + gfx = gfx + (state->current_command & 0x07) * 0x10000 + (state->current_command & 0x08) * 0x10000 + 0x140; - if ((current_command & 0x18) != 0){ - for (j = 0; j < 200; j++){ - for (i = 0; i < 320; i++){ + if ((state->current_command & 0x18) != 0) + { + for (j = 0; j < 200; j++) + { + for (i = 0; i < 320; i++) + { int color = *gfx; gfx++; - *BITMAP_ADDR16(screen_bitmap, j, i) = color & 0xff; + *BITMAP_ADDR16(state->screen_bitmap, j, i) = color & 0xff; } } - } else { - bitmap_fill(screen_bitmap, 0, 0); - } + } + else + bitmap_fill(state->screen_bitmap, 0, 0); } } } @@ -118,8 +115,9 @@ WRITE16_HANDLER( glass_blitter_w ) WRITE16_HANDLER( glass_vram_w ) { - COMBINE_DATA(&glass_videoram[offset]); - tilemap_mark_tile_dirty(pant[offset >> 11],((offset << 1) & 0x0fff) >> 2); + glass_state *state = (glass_state *)space->machine->driver_data; + COMBINE_DATA(&state->videoram[offset]); + tilemap_mark_tile_dirty(state->pant[offset >> 11], ((offset << 1) & 0x0fff) >> 2); } @@ -131,12 +129,15 @@ WRITE16_HANDLER( glass_vram_w ) VIDEO_START( glass ) { - pant[0] = tilemap_create(machine, get_tile_info_glass_screen0,tilemap_scan_rows,16,16,32,32); - pant[1] = tilemap_create(machine, get_tile_info_glass_screen1,tilemap_scan_rows,16,16,32,32); - screen_bitmap = auto_bitmap_alloc (machine, 320, 200, video_screen_get_format(machine->primary_screen)); + glass_state *state = (glass_state *)machine->driver_data; + state->pant[0] = tilemap_create(machine, get_tile_info_glass_screen0, tilemap_scan_rows, 16, 16, 32, 32); + state->pant[1] = tilemap_create(machine, get_tile_info_glass_screen1, tilemap_scan_rows, 16, 16, 32, 32); + state->screen_bitmap = auto_bitmap_alloc (machine, 320, 200, video_screen_get_format(machine->primary_screen)); - tilemap_set_transparent_pen(pant[0],0); - tilemap_set_transparent_pen(pant[1],0); + state_save_register_global_bitmap(machine, state->screen_bitmap); + + tilemap_set_transparent_pen(state->pant[0], 0); + tilemap_set_transparent_pen(state->pant[1], 0); } @@ -163,17 +164,19 @@ VIDEO_START( glass ) 3 | xxxxxxxx xxxxxxxx | sprite code */ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { + glass_state *state = (glass_state *)machine->driver_data; int i; const gfx_element *gfx = machine->gfx[0]; - for (i = 3; i < (0x1000 - 6)/2; i += 4){ - int sx = glass_spriteram[i+2] & 0x01ff; - int sy = (240 - (glass_spriteram[i] & 0x00ff)) & 0x00ff; - int number = glass_spriteram[i+3]; - int color = (glass_spriteram[i+2] & 0x1e00) >> 9; - int attr = (glass_spriteram[i] & 0xfe00) >> 9; + for (i = 3; i < (0x1000 - 6) / 2; i += 4) + { + int sx = state->spriteram[i + 2] & 0x01ff; + int sy = (240 - (state->spriteram[i] & 0x00ff)) & 0x00ff; + int number = state->spriteram[i + 3]; + int color = (state->spriteram[i + 2] & 0x1e00) >> 9; + int attr = (state->spriteram[i] & 0xfe00) >> 9; int xflip = attr & 0x20; int yflip = attr & 0x40; @@ -194,17 +197,18 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta VIDEO_UPDATE( glass ) { + glass_state *state = (glass_state *)screen->machine->driver_data; /* set scroll registers */ - tilemap_set_scrolly(pant[0], 0, glass_vregs[0]); - tilemap_set_scrollx(pant[0], 0, glass_vregs[1] + 0x04); - tilemap_set_scrolly(pant[1], 0, glass_vregs[2]); - tilemap_set_scrollx(pant[1], 0, glass_vregs[3]); + tilemap_set_scrolly(state->pant[0], 0, state->vregs[0]); + tilemap_set_scrollx(state->pant[0], 0, state->vregs[1] + 0x04); + tilemap_set_scrolly(state->pant[1], 0, state->vregs[2]); + tilemap_set_scrollx(state->pant[1], 0, state->vregs[3]); /* draw layers + sprites */ bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); - copybitmap(bitmap,screen_bitmap,0,0,0x18,0x24,cliprect); - tilemap_draw(bitmap,cliprect,pant[1],0,0); - tilemap_draw(bitmap,cliprect,pant[0],0,0); - draw_sprites(screen->machine,bitmap,cliprect); + copybitmap(bitmap, state->screen_bitmap, 0, 0, 0x18, 0x24, cliprect); + tilemap_draw(bitmap, cliprect, state->pant[1], 0, 0); + tilemap_draw(bitmap, cliprect, state->pant[0], 0, 0); + draw_sprites(screen->machine, bitmap, cliprect); return 0; } diff --git a/src/mame/video/homedata.c b/src/mame/video/homedata.c index da0f5bdcb4b..5a45a71a368 100644 --- a/src/mame/video/homedata.c +++ b/src/mame/video/homedata.c @@ -2,22 +2,6 @@ #include "cpu/m6809/m6809.h" #include "homedata.h" - -UINT8 *homedata_vreg; /* pointer to RAM associated with 0x7ffx */ -UINT8 reikaids_which; -int homedata_visible_page; -int homedata_priority; -static int homedata_flipscreen; - -static UINT8 reikaids_gfx_bank[2]; -static UINT8 pteacher_gfx_bank; -static UINT8 blitter_bank; -static int blitter_param_count; -static UINT8 blitter_param[4]; /* buffers last 4 writes to 0x8006 */ - -static tilemap *bg_tilemap[2][4]; - - /* video control registers: 0 xxxxxxxx unknown @@ -50,39 +34,38 @@ static tilemap *bg_tilemap[2][4]; static void mrokumei_handleblit( const address_space *space, int rom_base ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; int i; - int DestParam; - int SourceAddr; - int DestAddr; - int BaseAddr; - int opcode,data,NumTiles; + int dest_param; + int source_addr; + int dest_addr; + int base_addr; + int opcode, data, num_tiles; UINT8 *pBlitData = memory_region(space->machine, "user1") + rom_base; - DestParam = - blitter_param[(blitter_param_count-4)&3]*256+ - blitter_param[(blitter_param_count-3)&3]; + dest_param = state->blitter_param[(state->blitter_param_count - 4) & 3] * 256 + + state->blitter_param[(state->blitter_param_count - 3) & 3]; - SourceAddr = - blitter_param[(blitter_param_count-2)&3]*256+ - blitter_param[(blitter_param_count-1)&3]; + source_addr = state->blitter_param[(state->blitter_param_count - 2) & 3] * 256 + + state->blitter_param[(state->blitter_param_count - 1) & 3]; /* xxx-.----.----.---- not used? * ---x.----.----.---- layer * ----.xxxx.xxxx.xxxx addr */ - BaseAddr= (DestParam&0x1000); - DestAddr= (DestParam&0x0fff); + base_addr= (dest_param & 0x1000); + dest_addr= (dest_param & 0x0fff); -// logerror( "[blit bank %02x src %04x dst %04x]\n",blitter_bank,SourceAddr,DestParam); +// logerror( "[blit bank %02x src %04x dst %04x]\n", blitter_bank, source_addr, dest_param); - if( homedata_visible_page == 0 ) + if( state->visible_page == 0 ) { - BaseAddr += 0x2000; + base_addr += 0x2000; } for(;;) { - opcode = pBlitData[SourceAddr++]; + opcode = pBlitData[source_addr++]; /* 00xxxxxx RLE incrementing * 01xxxxxx Raw Run * 1xxxxxxx RLE constant data @@ -92,21 +75,21 @@ static void mrokumei_handleblit( const address_space *space, int rom_base ) /* end-of-graphic */ goto finish; } - data = pBlitData[SourceAddr++]; + data = pBlitData[source_addr++]; - if (opcode&0x80) - NumTiles = 0x80-(opcode&0x7f); + if (opcode & 0x80) + num_tiles = 0x80 - (opcode & 0x7f); else - NumTiles = 0x40-(opcode&0x3f); + num_tiles = 0x40 - (opcode & 0x3f); - for( i=0; ivreg[1] & 0x80) /* flip screen */ { - DestAddr-=2; - if (DestAddr < 0) goto finish; + dest_addr -= 2; + if (dest_addr < 0) + goto finish; } else { - DestAddr+=2; - if (DestAddr >= 0x1000) goto finish; + dest_addr+=2; + if (dest_addr >= 0x1000) goto finish; } - } /* for( i=0; imachine, "maincpu", M6809_FIRQ_LINE, HOLD_LINE); + cpu_set_input_line(state->maincpu, M6809_FIRQ_LINE, HOLD_LINE); } static void reikaids_handleblit( const address_space *space, int rom_base ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; int i; - UINT16 DestParam; + UINT16 dest_param; int flipx; - int SourceAddr, BaseAddr; - int DestAddr; + int source_addr, base_addr; + int dest_addr; UINT8 *pBlitData = memory_region(space->machine, "user1") + rom_base; - int opcode,data,NumTiles; + int opcode, data, num_tiles; - DestParam = - blitter_param[(blitter_param_count-4)&3]*256+ - blitter_param[(blitter_param_count-3)&3]; + dest_param = state->blitter_param[(state->blitter_param_count - 4) & 3] * 256 + + state->blitter_param[(state->blitter_param_count - 3) & 3]; - SourceAddr = - blitter_param[(blitter_param_count-2)&3]*256+ - blitter_param[(blitter_param_count-1)&3]; + source_addr = state->blitter_param[(state->blitter_param_count - 2) & 3] * 256 + + state->blitter_param[(state->blitter_param_count - 1) & 3]; /* x---.----.----.---- flipx * -x--.----.----.---- select: attr/tile * --*x.xxxx.*xxx.xxxx addr */ - BaseAddr= (DestParam&0x4000); - DestAddr= (DestParam&0x3fff); - flipx = (DestParam&0x8000); + base_addr = (dest_param & 0x4000); + dest_addr = (dest_param & 0x3fff); + flipx = (dest_param & 0x8000); -// logerror( "[blit %02x %04x %04x]\n",blitter_bank,SourceAddr,DestParam); +// logerror( "[blit %02x %04x %04x]\n",blitter_bank,source_addr,dest_param); - if( homedata_visible_page == 0 ) - { - BaseAddr += 0x2000<<2; - } + if (state->visible_page == 0) + base_addr += 0x2000 << 2; for(;;) { - opcode = pBlitData[SourceAddr++]; + opcode = pBlitData[source_addr++]; /* 00xxxxxx Raw Run * 01xxxxxx RLE incrementing * 1xxxxxxx RLE constant data */ - if( opcode == 0x00 ) + if (opcode == 0x00) { /* end-of-graphic */ goto finish; } - data = pBlitData[SourceAddr++]; + data = pBlitData[source_addr++]; - if( (opcode&0xc0)==0x80 ) - NumTiles = 0x80 - (opcode&0x7f); + if ((opcode & 0xc0) == 0x80) + num_tiles = 0x80 - (opcode & 0x7f); else - NumTiles = 0x40 - (opcode&0x3f); + num_tiles = 0x40 - (opcode & 0x3f); - for( i=0; i> 2) | ((addr & 0x1f00) >> 1) | (addr & 0x7f); - if( flipx ) + if (flipx) { - if ((BaseAddr & 0x4000) == 0) dat |= 0x80; + if ((base_addr & 0x4000) == 0) + dat |= 0x80; addr ^= 0x007c; } - reikaids_videoram_w( space, addr, dat ); + reikaids_videoram_w(space, addr, dat); } } - if (homedata_vreg[1] & 0x80) /* flip screen */ - DestAddr-=4; + if (state->vreg[1] & 0x80) /* flip screen */ + dest_addr-=4; else - DestAddr+=4; - } /* for( i=0; imachine, "maincpu", M6809_FIRQ_LINE, HOLD_LINE); + cpu_set_input_line(state->maincpu, M6809_FIRQ_LINE, HOLD_LINE); } static void pteacher_handleblit( const address_space *space, int rom_base ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; int i; - int DestParam; - int SourceAddr; - int DestAddr, BaseAddr; - int opcode,data,NumTiles; + int dest_param; + int source_addr; + int dest_addr, base_addr; + int opcode, data, num_tiles; UINT8 *pBlitData = memory_region(space->machine, "user1") + rom_base; - DestParam = - blitter_param[(blitter_param_count-4)&3]*256+ - blitter_param[(blitter_param_count-3)&3]; + dest_param = state->blitter_param[(state->blitter_param_count - 4) & 3] * 256 + + state->blitter_param[(state->blitter_param_count - 3) & 3]; - SourceAddr = - blitter_param[(blitter_param_count-2)&3]*256+ - blitter_param[(blitter_param_count-1)&3]; + source_addr = state->blitter_param[(state->blitter_param_count - 2) & 3] * 256 + + state->blitter_param[(state->blitter_param_count - 1) & 3]; /* x---.----.----.---- not used? * -x--.----.----.---- layer (0..1) * --*x.xxxx.*xxx.xxxx addr */ - BaseAddr= (DestParam&0x4000); - DestAddr= (DestParam&0x3fff); + base_addr = (dest_param & 0x4000); + dest_addr = (dest_param & 0x3fff); -// logerror( "[blit %02x %04x %04x]->%d\n",blitter_bank,SourceAddr,DestParam,homedata_visible_page); +// logerror( "[blit %02x %04x %04x]->%d\n",blitter_bank,source_addr,dest_param,homedata_visible_page); - if( homedata_visible_page == 0 ) + if (state->visible_page == 0) { - BaseAddr += 0x2000<<2; + base_addr += 0x2000 << 2; } for(;;) { - opcode = pBlitData[SourceAddr++]; + opcode = pBlitData[source_addr++]; /* 00xxxxxx Raw Run * 01xxxxxx RLE incrementing * 1xxxxxxx RLE constant data */ - if( opcode == 0x00 ) + if (opcode == 0x00) { /* end-of-graphic */ goto finish; } - data = pBlitData[SourceAddr++]; + data = pBlitData[source_addr++]; if (opcode & 0x80) - NumTiles = 0x80-(opcode&0x7f); + num_tiles = 0x80 - (opcode & 0x7f); else - NumTiles = 0x40-(opcode&0x3f); + num_tiles = 0x40 - (opcode & 0x3f); - for( i=0; i> 2) | ((addr & 0x1f00) >> 1) | (addr & 0x7f); - pteacher_videoram_w( space, addr, data ); + pteacher_videoram_w(space, addr, data); } } - if (homedata_vreg[1] & 0x80) /* flip screen */ - DestAddr-=2; + if (state->vreg[1] & 0x80) /* flip screen */ + dest_addr -= 2; else - DestAddr+=2; - } /* for( i=0; imachine, "maincpu", M6809_FIRQ_LINE, HOLD_LINE); + cpu_set_input_line(state->maincpu, M6809_FIRQ_LINE, HOLD_LINE); } @@ -350,7 +331,7 @@ PALETTE_INIT( mrokumei ) g = ((color >> 7) & 0x1e) | ((color >> 2) & 1); b = ((color >> 3) & 0x1e) | ((color >> 1) & 1); - palette_set_color_rgb(machine,i,pal5bit(r),pal5bit(g),pal5bit(b)); + palette_set_color_rgb(machine, i, pal5bit(r), pal5bit(g), pal5bit(b)); } } @@ -372,7 +353,7 @@ PALETTE_INIT( reikaids ) r = ((color >> 7) & 0x1e) | ((color >> 2) & 1); b = ((color >> 3) & 0x1e) | ((color >> 1) & 1); - palette_set_color_rgb(machine,i,pal5bit(r),pal5bit(g),pal5bit(b)); + palette_set_color_rgb(machine, i, pal5bit(r), pal5bit(g), pal5bit(b)); } } @@ -394,7 +375,7 @@ PALETTE_INIT( pteacher ) r = ((color >> 6) & 0x1f); b = ((color >> 1) & 0x1f); - palette_set_color_rgb(machine,i,pal5bit(r),pal5bit(g),pal5bit(b)); + palette_set_color_rgb(machine, i, pal5bit(r), pal5bit(g), pal5bit(b)); } } @@ -408,36 +389,58 @@ PALETTE_INIT( pteacher ) INLINE void mrokumei_info0( running_machine *machine, tile_data *tileinfo, int tile_index, int page, int gfxbank ) { + homedata_state *state = (homedata_state *)machine->driver_data; int addr = tile_index * 2 + 0x2000 * page; - int attr = machine->generic.videoram.u8[addr]; - int code = machine->generic.videoram.u8[addr + 1] + ((attr & 0x03) << 8) + (gfxbank << 10); + int attr = state->videoram[addr]; + int code = state->videoram[addr + 1] + ((attr & 0x03) << 8) + (gfxbank << 10); int color = (attr >> 2) + (gfxbank << 6); - SET_TILE_INFO( 0, code, color, homedata_flipscreen ); + SET_TILE_INFO( 0, code, color, state->flipscreen ); } INLINE void mrokumei_info1( running_machine *machine, tile_data *tileinfo, int tile_index, int page, int gfxbank ) { + homedata_state *state = (homedata_state *)machine->driver_data; int addr = tile_index * 2 + 0x1000 + 0x2000 * page; - int attr = machine->generic.videoram.u8[addr]; - int code = machine->generic.videoram.u8[addr + 1] + ((attr & 0x07) << 8) + (gfxbank << 11); + int attr = state->videoram[addr]; + int code = state->videoram[addr + 1] + ((attr & 0x07) << 8) + (gfxbank << 11); int color = (attr >> 3) + ((gfxbank & 3) << 6); - SET_TILE_INFO( 1, code, color, homedata_flipscreen ); + SET_TILE_INFO( 1, code, color, state->flipscreen ); } -static TILE_GET_INFO( mrokumei_get_info0_0 ) { mrokumei_info0( machine, tileinfo, tile_index, 0, blitter_bank & 0x03 ); } -static TILE_GET_INFO( mrokumei_get_info1_0 ) { mrokumei_info0( machine, tileinfo, tile_index, 1, blitter_bank & 0x03 ); } -static TILE_GET_INFO( mrokumei_get_info0_1 ) { mrokumei_info1( machine, tileinfo, tile_index, 0, (blitter_bank & 0x38) >> 3 ); } -static TILE_GET_INFO( mrokumei_get_info1_1 ) { mrokumei_info1( machine, tileinfo, tile_index, 1, (blitter_bank & 0x38) >> 3 ); } +static TILE_GET_INFO( mrokumei_get_info0_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + mrokumei_info0( machine, tileinfo, tile_index, 0, state->blitter_bank & 0x03 ); +} + +static TILE_GET_INFO( mrokumei_get_info1_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + mrokumei_info0( machine, tileinfo, tile_index, 1, state->blitter_bank & 0x03 ); +} + +static TILE_GET_INFO( mrokumei_get_info0_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + mrokumei_info1( machine, tileinfo, tile_index, 0, (state->blitter_bank & 0x38) >> 3 ); +} + +static TILE_GET_INFO( mrokumei_get_info1_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + mrokumei_info1( machine, tileinfo, tile_index, 1, (state->blitter_bank & 0x38) >> 3 ); +} INLINE void reikaids_info( running_machine *machine, tile_data *tileinfo, int tile_index, int page, int layer, int gfxbank ) { + homedata_state *state = (homedata_state *)machine->driver_data; int addr = tile_index * 4 + layer + 0x2000 * page; - int attr = machine->generic.videoram.u8[addr]; - int code = machine->generic.videoram.u8[addr + 0x1000] + ((attr & 0x03) << 8) + (gfxbank << 10); + int attr = state->videoram[addr]; + int code = state->videoram[addr + 0x1000] + ((attr & 0x03) << 8) + (gfxbank << 10); int color = (attr & 0x7c) >> 2; - int flags = homedata_flipscreen; + int flags = state->flipscreen; if (attr & 0x80) flags ^= TILE_FLIPX; @@ -452,46 +455,126 @@ INLINE void reikaids_info( running_machine *machine, tile_data *tileinfo, int ti * xxxx.x--- layer#0 * ----.-xxx layer#2 */ -static TILE_GET_INFO( reikaids_get_info0_0 ) { reikaids_info( machine, tileinfo, tile_index, 0, 0, (reikaids_gfx_bank[1]>>3)); } -static TILE_GET_INFO( reikaids_get_info1_0 ) { reikaids_info( machine, tileinfo, tile_index, 1, 0, (reikaids_gfx_bank[1]>>3)); } -static TILE_GET_INFO( reikaids_get_info0_1 ) { reikaids_info( machine, tileinfo, tile_index, 0, 1, ((reikaids_gfx_bank[0]&0x78)>>3)); } -static TILE_GET_INFO( reikaids_get_info1_1 ) { reikaids_info( machine, tileinfo, tile_index, 1, 1, ((reikaids_gfx_bank[0]&0x78)>>3)); } -static TILE_GET_INFO( reikaids_get_info0_2 ) { reikaids_info( machine, tileinfo, tile_index, 0, 2, (reikaids_gfx_bank[1]&0x7)); } -static TILE_GET_INFO( reikaids_get_info1_2 ) { reikaids_info( machine, tileinfo, tile_index, 1, 2, (reikaids_gfx_bank[1]&0x7)); } -static TILE_GET_INFO( reikaids_get_info0_3 ) { reikaids_info( machine, tileinfo, tile_index, 0, 3, (reikaids_gfx_bank[0]&0x7)); } -static TILE_GET_INFO( reikaids_get_info1_3 ) { reikaids_info( machine, tileinfo, tile_index, 1, 3, (reikaids_gfx_bank[0]&0x7)); } +static TILE_GET_INFO( reikaids_get_info0_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 0, 0, (state->gfx_bank[1] >> 3)); +} + +static TILE_GET_INFO( reikaids_get_info1_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 1, 0, (state->gfx_bank[1] >> 3)); +} + +static TILE_GET_INFO( reikaids_get_info0_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 0, 1, ((state->gfx_bank[0] & 0x78) >> 3)); +} + +static TILE_GET_INFO( reikaids_get_info1_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 1, 1, ((state->gfx_bank[0] & 0x78) >> 3)); +} + +static TILE_GET_INFO( reikaids_get_info0_2 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 0, 2, (state->gfx_bank[1] & 0x7)); +} + +static TILE_GET_INFO( reikaids_get_info1_2 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 1, 2, (state->gfx_bank[1] & 0x7)); +} + +static TILE_GET_INFO( reikaids_get_info0_3 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 0, 3, (state->gfx_bank[0] & 0x7)); +} + +static TILE_GET_INFO( reikaids_get_info1_3 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + reikaids_info(machine, tileinfo, tile_index, 1, 3, (state->gfx_bank[0] & 0x7)); +} INLINE void pteacher_info( running_machine *machine, tile_data *tileinfo, int tile_index, int page, int layer, int gfxbank ) { + homedata_state *state = (homedata_state *)machine->driver_data; int addr = tile_index * 2 + 0x1000 * layer + 0x2000 * page; - int attr = machine->generic.videoram.u8[addr]; - int code = machine->generic.videoram.u8[addr + 1] + ((attr & 0x07) << 8) + (gfxbank << 11); + int attr = state->videoram[addr]; + int code = state->videoram[addr + 1] + ((attr & 0x07) << 8) + (gfxbank << 11); int color = (attr >> 3) + ((gfxbank & 1) << 5); - SET_TILE_INFO( layer, code, color, homedata_flipscreen ); + SET_TILE_INFO(layer, code, color, state->flipscreen); } -static TILE_GET_INFO( pteacher_get_info0_0 ) { pteacher_info( machine, tileinfo, tile_index, 0, 0, pteacher_gfx_bank & 0x0f ); } -static TILE_GET_INFO( pteacher_get_info1_0 ) { pteacher_info( machine, tileinfo, tile_index, 1, 0, pteacher_gfx_bank & 0x0f ); } -static TILE_GET_INFO( pteacher_get_info0_1 ) { pteacher_info( machine, tileinfo, tile_index, 0, 1, pteacher_gfx_bank >> 4 ); } -static TILE_GET_INFO( pteacher_get_info1_1 ) { pteacher_info( machine, tileinfo, tile_index, 1, 1, pteacher_gfx_bank >> 4 ); } +static TILE_GET_INFO( pteacher_get_info0_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + pteacher_info(machine, tileinfo, tile_index, 0, 0, state->gfx_bank[0] & 0x0f); +} + +static TILE_GET_INFO( pteacher_get_info1_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + pteacher_info(machine, tileinfo, tile_index, 1, 0, state->gfx_bank[0] & 0x0f); +} + +static TILE_GET_INFO( pteacher_get_info0_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + pteacher_info(machine, tileinfo, tile_index, 0, 1, state->gfx_bank[0] >> 4); +} + +static TILE_GET_INFO( pteacher_get_info1_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + pteacher_info(machine, tileinfo, tile_index, 1, 1, state->gfx_bank[0] >> 4); +} INLINE void lemnangl_info( running_machine *machine, tile_data *tileinfo, int tile_index, int page, int layer, int gfxset, int gfxbank ) { + homedata_state *state = (homedata_state *)machine->driver_data; int addr = tile_index * 2 + 0x1000 * layer + 0x2000 * page; - int attr = machine->generic.videoram.u8[addr]; - int code = machine->generic.videoram.u8[addr + 1] + ((attr & 0x07) << 8) + (gfxbank << 11); + int attr = state->videoram[addr]; + int code = state->videoram[addr + 1] + ((attr & 0x07) << 8) + (gfxbank << 11); int color = 16 * (attr >> 3) + gfxbank; - SET_TILE_INFO( 2*layer + gfxset, code, color, homedata_flipscreen ); + SET_TILE_INFO(2 * layer + gfxset, code, color, state->flipscreen); } -static TILE_GET_INFO( lemnangl_get_info0_0 ) { lemnangl_info( machine, tileinfo, tile_index, 0, 0, blitter_bank & 1, pteacher_gfx_bank & 0x0f ); } -static TILE_GET_INFO( lemnangl_get_info1_0 ) { lemnangl_info( machine, tileinfo, tile_index, 1, 0, blitter_bank & 1, pteacher_gfx_bank & 0x0f ); } -static TILE_GET_INFO( lemnangl_get_info0_1 ) { lemnangl_info( machine, tileinfo, tile_index, 0, 1, (blitter_bank & 2) >> 1, pteacher_gfx_bank >> 4 ); } -static TILE_GET_INFO( lemnangl_get_info1_1 ) { lemnangl_info( machine, tileinfo, tile_index, 1, 1, (blitter_bank & 2) >> 1, pteacher_gfx_bank >> 4 ); } +static TILE_GET_INFO( lemnangl_get_info0_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + lemnangl_info( machine, tileinfo, tile_index, 0, 0, state->blitter_bank & 1, state->gfx_bank[0] & 0x0f ); +} + +static TILE_GET_INFO( lemnangl_get_info1_0 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + lemnangl_info( machine, tileinfo, tile_index, 1, 0, state->blitter_bank & 1, state->gfx_bank[0] & 0x0f ); +} + + +static TILE_GET_INFO( lemnangl_get_info0_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + lemnangl_info( machine, tileinfo, tile_index, 0, 1, (state->blitter_bank & 2) >> 1, state->gfx_bank[0] >> 4 ); +} + +static TILE_GET_INFO( lemnangl_get_info1_1 ) +{ + homedata_state *state = (homedata_state *)machine->driver_data; + lemnangl_info( machine, tileinfo, tile_index, 1, 1, (state->blitter_bank & 2) >> 1, state->gfx_bank[0] >> 4 ); +} /*************************************************************************** @@ -502,56 +585,60 @@ static TILE_GET_INFO( lemnangl_get_info1_1 ) { lemnangl_info( machine, tileinfo, VIDEO_START( mrokumei ) { - bg_tilemap[0][0] = tilemap_create( machine, mrokumei_get_info0_0, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[0][1] = tilemap_create( machine, mrokumei_get_info0_1, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[1][0] = tilemap_create( machine, mrokumei_get_info1_0, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[1][1] = tilemap_create( machine, mrokumei_get_info1_1, tilemap_scan_rows, 8, 8, 64,32 ); + homedata_state *state = (homedata_state *)machine->driver_data; + state->bg_tilemap[0][0] = tilemap_create( machine, mrokumei_get_info0_0, tilemap_scan_rows, 8, 8, 64, 32 ); + state->bg_tilemap[0][1] = tilemap_create( machine, mrokumei_get_info0_1, tilemap_scan_rows, 8, 8, 64, 32 ); + state->bg_tilemap[1][0] = tilemap_create( machine, mrokumei_get_info1_0, tilemap_scan_rows, 8, 8, 64, 32 ); + state->bg_tilemap[1][1] = tilemap_create( machine, mrokumei_get_info1_1, tilemap_scan_rows, 8, 8, 64, 32 ); - tilemap_set_transparent_pen(bg_tilemap[0][1],0); - tilemap_set_transparent_pen(bg_tilemap[1][1],0); + tilemap_set_transparent_pen(state->bg_tilemap[0][1], 0); + tilemap_set_transparent_pen(state->bg_tilemap[1][1], 0); } VIDEO_START( reikaids ) { - bg_tilemap[0][0] = tilemap_create( machine, reikaids_get_info0_0, tilemap_scan_rows, 8, 8, 32, 32 ); - bg_tilemap[0][1] = tilemap_create( machine, reikaids_get_info0_1, tilemap_scan_rows, 8, 8, 32, 32 ); - bg_tilemap[0][2] = tilemap_create( machine, reikaids_get_info0_2, tilemap_scan_rows, 8, 8, 32, 32 ); - bg_tilemap[0][3] = tilemap_create( machine, reikaids_get_info0_3, tilemap_scan_rows, 8, 8, 32, 32 ); - bg_tilemap[1][0] = tilemap_create( machine, reikaids_get_info1_0, tilemap_scan_rows, 8, 8, 32, 32 ); - bg_tilemap[1][1] = tilemap_create( machine, reikaids_get_info1_1, tilemap_scan_rows, 8, 8, 32, 32 ); - bg_tilemap[1][2] = tilemap_create( machine, reikaids_get_info1_2, tilemap_scan_rows, 8, 8, 32, 32 ); - bg_tilemap[1][3] = tilemap_create( machine, reikaids_get_info1_3, tilemap_scan_rows, 8, 8, 32, 32 ); + homedata_state *state = (homedata_state *)machine->driver_data; + state->bg_tilemap[0][0] = tilemap_create(machine, reikaids_get_info0_0, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[0][1] = tilemap_create(machine, reikaids_get_info0_1, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[0][2] = tilemap_create(machine, reikaids_get_info0_2, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[0][3] = tilemap_create(machine, reikaids_get_info0_3, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[1][0] = tilemap_create(machine, reikaids_get_info1_0, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[1][1] = tilemap_create(machine, reikaids_get_info1_1, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[1][2] = tilemap_create(machine, reikaids_get_info1_2, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[1][3] = tilemap_create(machine, reikaids_get_info1_3, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_transparent_pen(bg_tilemap[0][0],0xff); - tilemap_set_transparent_pen(bg_tilemap[0][1],0xff); - tilemap_set_transparent_pen(bg_tilemap[0][2],0xff); - tilemap_set_transparent_pen(bg_tilemap[0][3],0xff); - tilemap_set_transparent_pen(bg_tilemap[1][0],0xff); - tilemap_set_transparent_pen(bg_tilemap[1][1],0xff); - tilemap_set_transparent_pen(bg_tilemap[1][2],0xff); - tilemap_set_transparent_pen(bg_tilemap[1][3],0xff); + tilemap_set_transparent_pen(state->bg_tilemap[0][0], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[0][1], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[0][2], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[0][3], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[1][0], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[1][1], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[1][2], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[1][3], 0xff); } VIDEO_START( pteacher ) { - bg_tilemap[0][0] = tilemap_create( machine, pteacher_get_info0_0, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[0][1] = tilemap_create( machine, pteacher_get_info0_1, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[1][0] = tilemap_create( machine, pteacher_get_info1_0, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[1][1] = tilemap_create( machine, pteacher_get_info1_1, tilemap_scan_rows, 8, 8, 64,32 ); + homedata_state *state = (homedata_state *)machine->driver_data; + state->bg_tilemap[0][0] = tilemap_create(machine, pteacher_get_info0_0, tilemap_scan_rows, 8, 8, 64, 32); + state->bg_tilemap[0][1] = tilemap_create(machine, pteacher_get_info0_1, tilemap_scan_rows, 8, 8, 64, 32); + state->bg_tilemap[1][0] = tilemap_create(machine, pteacher_get_info1_0, tilemap_scan_rows, 8, 8, 64, 32); + state->bg_tilemap[1][1] = tilemap_create(machine, pteacher_get_info1_1, tilemap_scan_rows, 8, 8, 64, 32); - tilemap_set_transparent_pen(bg_tilemap[0][1],0xff); - tilemap_set_transparent_pen(bg_tilemap[1][1],0xff); + tilemap_set_transparent_pen(state->bg_tilemap[0][1], 0xff); + tilemap_set_transparent_pen(state->bg_tilemap[1][1], 0xff); } VIDEO_START( lemnangl ) { - bg_tilemap[0][0] = tilemap_create( machine, lemnangl_get_info0_0, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[0][1] = tilemap_create( machine, lemnangl_get_info0_1, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[1][0] = tilemap_create( machine, lemnangl_get_info1_0, tilemap_scan_rows, 8, 8, 64,32 ); - bg_tilemap[1][1] = tilemap_create( machine, lemnangl_get_info1_1, tilemap_scan_rows, 8, 8, 64,32 ); + homedata_state *state = (homedata_state *)machine->driver_data; + state->bg_tilemap[0][0] = tilemap_create(machine, lemnangl_get_info0_0, tilemap_scan_rows, 8, 8, 64, 32); + state->bg_tilemap[0][1] = tilemap_create(machine, lemnangl_get_info0_1, tilemap_scan_rows, 8, 8, 64, 32); + state->bg_tilemap[1][0] = tilemap_create(machine, lemnangl_get_info1_0, tilemap_scan_rows, 8, 8, 64, 32); + state->bg_tilemap[1][1] = tilemap_create(machine, lemnangl_get_info1_1, tilemap_scan_rows, 8, 8, 64, 32); - tilemap_set_transparent_pen(bg_tilemap[0][1],0x0f); - tilemap_set_transparent_pen(bg_tilemap[1][1],0x0f); + tilemap_set_transparent_pen(state->bg_tilemap[0][1], 0x0f); + tilemap_set_transparent_pen(state->bg_tilemap[1][1], 0x0f); } @@ -564,93 +651,103 @@ VIDEO_START( lemnangl ) WRITE8_HANDLER( mrokumei_videoram_w ) { - space->machine->generic.videoram.u8[offset] = data; - tilemap_mark_tile_dirty( bg_tilemap[(offset & 0x2000) >> 13][(offset & 0x1000) >> 12], (offset & 0xffe) >> 1 ); + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap[(offset & 0x2000) >> 13][(offset & 0x1000) >> 12], (offset & 0xffe) >> 1); } WRITE8_HANDLER( reikaids_videoram_w ) { - space->machine->generic.videoram.u8[offset] = data; - tilemap_mark_tile_dirty( bg_tilemap[(offset & 0x2000) >> 13][offset & 3], (offset & 0xffc) >> 2 ); + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap[(offset & 0x2000) >> 13][offset & 3], (offset & 0xffc) >> 2); } WRITE8_HANDLER( pteacher_videoram_w ) { - space->machine->generic.videoram.u8[offset] = data; - tilemap_mark_tile_dirty( bg_tilemap[(offset & 0x2000) >> 13][(offset & 0x1000) >> 12], (offset & 0xffe) >> 1 ); + homedata_state *state = (homedata_state *)space->machine->driver_data; + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap[(offset & 0x2000) >> 13][(offset & 0x1000) >> 12], (offset & 0xffe) >> 1); } WRITE8_HANDLER( reikaids_gfx_bank_w ) { - + homedata_state *state = (homedata_state *)space->machine->driver_data; //logerror( "%04x: [setbank %02x]\n",cpu_get_pc(space->cpu),data); - if (reikaids_gfx_bank[reikaids_which] != data) + if (state->gfx_bank[state->reikaids_which] != data) { - reikaids_gfx_bank[reikaids_which] = data; - tilemap_mark_all_tiles_dirty_all( space->machine ); + state->gfx_bank[state->reikaids_which] = data; + tilemap_mark_all_tiles_dirty_all(space->machine); } - reikaids_which ^= 1; + state->reikaids_which ^= 1; } WRITE8_HANDLER( pteacher_gfx_bank_w ) { -// logerror( "%04x: gfxbank:=%02x\n", cpu_get_pc(space->cpu), data ); - if (pteacher_gfx_bank != data) + homedata_state *state = (homedata_state *)space->machine->driver_data; +// logerror("%04x: gfxbank:=%02x\n", cpu_get_pc(space->cpu), data); + if (state->gfx_bank[0] != data) { - pteacher_gfx_bank = data; - tilemap_mark_all_tiles_dirty_all( space->machine ); + state->gfx_bank[0] = data; + tilemap_mark_all_tiles_dirty_all(space->machine); } } WRITE8_HANDLER( homedata_blitter_param_w ) { -//logerror("%04x: blitter_param_w %02x\n",cpu_get_pc(space->cpu),data); - blitter_param[blitter_param_count] = data; - blitter_param_count++; - blitter_param_count&=3; + homedata_state *state = (homedata_state *)space->machine->driver_data; +//logerror("%04x: blitter_param_w %02x\n", cpu_get_pc(space->cpu), data); + state->blitter_param[state->blitter_param_count] = data; + state->blitter_param_count++; + state->blitter_param_count &= 3; } WRITE8_HANDLER( mrokumei_blitter_bank_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; /* --xxx--- layer 1 gfx bank -----x-- blitter ROM bank ------xx layer 0 gfx bank */ - if ((blitter_bank ^ data) & 0x3b) - tilemap_mark_all_tiles_dirty_all( space->machine); + if ((state->blitter_bank ^ data) & 0x3b) + tilemap_mark_all_tiles_dirty_all(space->machine); - blitter_bank = data; + state->blitter_bank = data; } WRITE8_HANDLER( reikaids_blitter_bank_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; /* xxx----- priority control ----x--- target page? what's this for? ------xx blitter ROM bank */ - blitter_bank = data; + state->blitter_bank = data; } WRITE8_HANDLER( pteacher_blitter_bank_w ) { + homedata_state *state = (homedata_state *)space->machine->driver_data; /* xxx----- blitter ROM bank -----x-- pixel clock (normal/slow) ------x- layer #1 gfx charset (lemnangl only) -------x layer #0 gfx charset (lemnangl only) */ - if ((blitter_bank ^ data) & 0x03) - tilemap_mark_all_tiles_dirty_all( space->machine); + if ((state->blitter_bank ^ data) & 0x03) + tilemap_mark_all_tiles_dirty_all(space->machine); - blitter_bank = data; + state->blitter_bank = data; } WRITE8_HANDLER( mrokumei_blitter_start_w ) { - if (data & 0x80) mrokumei_handleblit(space, ((blitter_bank & 0x04) >> 2) * 0x10000); + homedata_state *state = (homedata_state *)space->machine->driver_data; + if (data & 0x80) + mrokumei_handleblit(space, ((state->blitter_bank & 0x04) >> 2) * 0x10000); /* bit 0 = bank switch; used by hourouki to access the optional service mode ROM (not available in current dump) */ @@ -658,12 +755,14 @@ WRITE8_HANDLER( mrokumei_blitter_start_w ) WRITE8_HANDLER( reikaids_blitter_start_w ) { - reikaids_handleblit(space, (blitter_bank & 3) * 0x10000); + homedata_state *state = (homedata_state *)space->machine->driver_data; + reikaids_handleblit(space, (state->blitter_bank & 3) * 0x10000); } WRITE8_HANDLER( pteacher_blitter_start_w ) { - pteacher_handleblit(space, (blitter_bank >> 5) * 0x10000 & (memory_region_length(space->machine, "user1") - 1)); + homedata_state *state = (homedata_state *)space->machine->driver_data; + pteacher_handleblit(space, (state->blitter_bank >> 5) * 0x10000 & (memory_region_length(space->machine, "user1") - 1)); } @@ -676,84 +775,87 @@ WRITE8_HANDLER( pteacher_blitter_start_w ) VIDEO_UPDATE( mrokumei ) { + homedata_state *state = (homedata_state *)screen->machine->driver_data; int flags,width; /* blank screen */ - if (homedata_vreg[0x3] == 0xc1 && homedata_vreg[0x4] == 0xc0 && homedata_vreg[0x5] == 0xff) + if (state->vreg[0x3] == 0xc1 && state->vreg[0x4] == 0xc0 && state->vreg[0x5] == 0xff) { - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); return 0; } - flags = (homedata_vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; - if (flags != homedata_flipscreen) + flags = (state->vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; + if (flags != state->flipscreen) { - homedata_flipscreen = flags; - tilemap_mark_all_tiles_dirty_all( screen->machine ); + state->flipscreen = flags; + tilemap_mark_all_tiles_dirty_all(screen->machine); } - switch (homedata_vreg[0x3]) + switch (state->vreg[0x3]) { case 0xb7: width = 54; break; // mjclinic case 0xae: width = 52; break; // mrokumei case 0x9f: width = 49; break; // hourouki, mhgaiden, mjhokite case 0x96: width = 49; break; // mjclinic default: - if (homedata_vreg[0x3]) + if (state->vreg[0x3]) popmessage("unknown video control %02x %02x %02x %02x", - homedata_vreg[0x3], - homedata_vreg[0x4], - homedata_vreg[0x5], - homedata_vreg[0x6]); + state->vreg[0x3], + state->vreg[0x4], + state->vreg[0x5], + state->vreg[0x6]); width = 54; break; } video_screen_set_visarea(screen, 0*8, width*8-1, 2*8, 30*8-1); - tilemap_set_scrollx(bg_tilemap[homedata_visible_page][0],0,homedata_vreg[0xc] << 1); + tilemap_set_scrollx(state->bg_tilemap[state->visible_page][0], 0, state->vreg[0xc] << 1); - tilemap_draw(bitmap, cliprect, bg_tilemap[homedata_visible_page][0], 0, 0); - tilemap_draw(bitmap, cliprect, bg_tilemap[homedata_visible_page][1], 0, 0); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[state->visible_page][0], 0, 0); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[state->visible_page][1], 0, 0); return 0; } #ifdef UNUSED_FUNCTION VIDEO_UPDATE( reikaids ) { - int flags; - static const int pritable[8][4] = - { - { 3,1,0,2 }, - { 1,3,0,2 }, - { 0,3,1,2 }, - { 0,1,3,2 }, - { 3,0,1,2 }, - { 1,0,3,2 }, - { 2,3,1,0 }, // (bg color should be taken from 1) - { 3,1,2,0 }, // (bg color should be taken from 1) - }; - int pri,i; + homedata_state *state = (homedata_state *)screen->machine->driver_data; + int flags; + static const int pritable[8][4] = + { + { 3,1,0,2 }, + { 1,3,0,2 }, + { 0,3,1,2 }, + { 0,1,3,2 }, + { 3,0,1,2 }, + { 1,0,3,2 }, + { 2,3,1,0 }, // (bg color should be taken from 1) + { 3,1,2,0 }, // (bg color should be taken from 1) + }; + int pri, i; - flags = (homedata_vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; - if (flags != homedata_flipscreen) - { - homedata_flipscreen = flags; - tilemap_mark_all_tiles_dirty_all( screen->machine ); - } + flags = (state->vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; + if (flags != state->flipscreen) + { + state->flipscreen = flags; + tilemap_mark_all_tiles_dirty_all(screen->machine); + } - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); - pri = (blitter_bank & 0x70) >> 4; - for (i = 0;i < 4;i++) - tilemap_draw(bitmap, cliprect, bg_tilemap[homedata_visible_page][pritable[pri][3-i]], 0, 0); - return 0; + pri = (state->bank & 0x70) >> 4; + for (i = 0; i < 4; i++) + tilemap_draw(bitmap, cliprect, state->bg_tilemap[state->visible_page][pritable[pri][3 - i]], 0, 0); + return 0; } #endif VIDEO_UPDATE( reikaids ) { + homedata_state *state = (homedata_state *)screen->machine->driver_data; int flags; static const int pritable[2][8][4] = /* table of priorities derived from the PROM */ { @@ -779,42 +881,43 @@ VIDEO_UPDATE( reikaids ) }, }; - int pri,i; + int pri, i; - flags = (homedata_vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; - if (flags != homedata_flipscreen) + flags = (state->vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; + if (flags != state->flipscreen) { - homedata_flipscreen = flags; - tilemap_mark_all_tiles_dirty_all( screen->machine ); + state->flipscreen = flags; + tilemap_mark_all_tiles_dirty_all(screen->machine); } - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); - pri = (blitter_bank & 0x70) >> 4; - for (i = 0;i < 4;i++) - tilemap_draw(bitmap, cliprect, bg_tilemap[homedata_visible_page][pritable[homedata_priority][pri][3-i]], 0, 0); + pri = (state->blitter_bank & 0x70) >> 4; + for (i = 0; i < 4; i++) + tilemap_draw(bitmap, cliprect, state->bg_tilemap[state->visible_page][pritable[state->priority][pri][3 - i]], 0, 0); return 0; } VIDEO_UPDATE( pteacher ) { - int flags,scroll_low,scroll_high; + homedata_state *state = (homedata_state *)screen->machine->driver_data; + int flags, scroll_low, scroll_high; /* blank screen */ - if (homedata_vreg[0x3] == 0xc1 && homedata_vreg[0x4] == 0xc0 && homedata_vreg[0x5] == 0xff) + if (state->vreg[0x3] == 0xc1 && state->vreg[0x4] == 0xc0 && state->vreg[0x5] == 0xff) { - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); return 0; } - flags = (homedata_vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; - if (flags != homedata_flipscreen) + flags = (state->vreg[1] & 0x80) ? (TILE_FLIPX | TILE_FLIPY) : 0; + if (flags != state->flipscreen) { - homedata_flipscreen = flags; - tilemap_mark_all_tiles_dirty_all( screen->machine ); + state->flipscreen = flags; + tilemap_mark_all_tiles_dirty_all(screen->machine); } /* bit 2 of blitter_bank stretches characters horizontally by 3/2, @@ -841,9 +944,9 @@ VIDEO_UPDATE( pteacher ) blanked = c1 c0 ff -- */ - if (blitter_bank & 0x04) + if (state->blitter_bank & 0x04) { - if (homedata_vreg[0x4] == 0xae || homedata_vreg[0x4] == 0xb8) + if (state->vreg[0x4] == 0xae || state->vreg[0x4] == 0xb8) { /* kludge for mjkinjas */ video_screen_set_visarea(screen, 0*8, 42*8-1, 2*8, 30*8-1); @@ -851,33 +954,34 @@ VIDEO_UPDATE( pteacher ) } else { - if (homedata_vreg[0x3] == 0xa6) + if (state->vreg[0x3] == 0xa6) video_screen_set_visarea(screen, 0*8, 33*8-1, 2*8, 30*8-1); else video_screen_set_visarea(screen, 0*8, 35*8-1, 2*8, 30*8-1); - scroll_low = (11 - (homedata_vreg[0x4] & 0x0f)) * 8 / 12; + scroll_low = (11 - (state->vreg[0x4] & 0x0f)) * 8 / 12; } } else { - if (homedata_vreg[0x3] == 0xa6) + if (state->vreg[0x3] == 0xa6) video_screen_set_visarea(screen, 0*8, 51*8-1, 2*8, 30*8-1); else video_screen_set_visarea(screen, 0*8, 54*8-1, 2*8, 30*8-1); - scroll_low = 7 - (homedata_vreg[0x4] & 0x0f); + scroll_low = 7 - (state->vreg[0x4] & 0x0f); } - scroll_high = homedata_vreg[0xb] >> 2; + scroll_high = state->vreg[0xb] >> 2; - tilemap_set_scrollx(bg_tilemap[homedata_visible_page][0],0,scroll_high*8 + scroll_low); - tilemap_set_scrollx(bg_tilemap[homedata_visible_page][1],0,scroll_high*8 + scroll_low); + tilemap_set_scrollx(state->bg_tilemap[state->visible_page][0], 0, scroll_high * 8 + scroll_low); + tilemap_set_scrollx(state->bg_tilemap[state->visible_page][1], 0, scroll_high * 8 + scroll_low); - tilemap_draw(bitmap, cliprect, bg_tilemap[homedata_visible_page][0], 0, 0); - tilemap_draw(bitmap, cliprect, bg_tilemap[homedata_visible_page][1], 0, 0); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[state->visible_page][0], 0, 0); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[state->visible_page][1], 0, 0); return 0; } VIDEO_EOF( homedata ) { - homedata_visible_page ^= 1; + homedata_state *state = (homedata_state *)machine->driver_data; + state->visible_page ^= 1; } diff --git a/src/mame/video/hyprduel.c b/src/mame/video/hyprduel.c index f1b66a37a2a..ff5cc5ee7b3 100644 --- a/src/mame/video/hyprduel.c +++ b/src/mame/video/hyprduel.c @@ -57,31 +57,15 @@ Note: if MAME_DEBUG is defined, pressing Z with: #include "driver.h" #include "includes/hyprduel.h" - -/* Variables that driver has access to: */ -UINT16 *hyprduel_videoregs; -UINT16 *hyprduel_screenctrl; -UINT16 *hyprduel_tiletable; -size_t hyprduel_tiletable_size; -UINT16 *hyprduel_vram_0,*hyprduel_vram_1,*hyprduel_vram_2; -UINT16 *hyprduel_window; -UINT16 *hyprduel_scroll; - -static UINT16 *hyprduel_tiletable_old; -static UINT8 *dirtyindex; - -static int hyprduel_sprite_xoffs; -static int hyprduel_sprite_yoffs; -static int hyprduel_sprite_yoffs_sub; - /*************************************************************************** Palette GGGGGRRRRRBBBBBx ***************************************************************************/ WRITE16_HANDLER( hyprduel_paletteram_w ) { - data = COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]); - palette_set_color_rgb(space->machine,offset,pal5bit(data >> 6),pal5bit(data >> 11),pal5bit(data >> 1)); + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + data = COMBINE_DATA(&state->paletteram[offset]); + palette_set_color_rgb(space->machine, offset, pal5bit(data >> 6), pal5bit(data >> 11), pal5bit(data >> 1)); } @@ -106,9 +90,6 @@ WRITE16_HANDLER( hyprduel_paletteram_w ) Tilemaps: Rendering ***************************************************************************/ -static tilemap *bg_tilemap[3]; -static UINT8 *empty_tiles; - /* A 2048 x 2048 virtual tilemap */ #define BIG_NX (0x100) @@ -123,28 +104,28 @@ static UINT8 *empty_tiles; /* 8x8x4 tiles only */ -INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int layer,UINT16 *vram) +INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int layer, UINT16 *vram) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; UINT16 code; - int table_index; - UINT32 tile; + int table_index; + UINT32 tile; /* The actual tile index depends on the window */ - tile_index = ((tile_index / WIN_NX + hyprduel_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX + - ((tile_index % WIN_NX + hyprduel_window[layer * 2 + 1] / 8) % BIG_NX); + tile_index = ((tile_index / WIN_NX + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX + + ((tile_index % WIN_NX + state->window[layer * 2 + 1] / 8) % BIG_NX); /* Fetch the code */ - code = vram[ tile_index ]; + code = vram[tile_index]; /* Use it as an index into the tiles set table */ - table_index = ( (code & 0x1ff0) >> 4 ) * 2; - tile = (hyprduel_tiletable[table_index + 0] << 16 ) + - hyprduel_tiletable[table_index + 1]; + table_index = ((code & 0x1ff0) >> 4 ) * 2; + tile = (state->tiletable[table_index + 0] << 16) + state->tiletable[table_index + 1]; if (code & 0x8000) /* Special: draw a tile of a single color (i.e. not from the gfx ROMs) */ { int _code = code & 0x000f; - tileinfo->pen_data = empty_tiles + _code*16*16; + tileinfo->pen_data = state->empty_tiles + _code * 16 * 16; tileinfo->palette_base = ((code & 0x0ff0)) + 0x1000; tileinfo->flags = 0; tileinfo->group = 0; @@ -162,33 +143,33 @@ INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_ /* 8x8x4 or 8x8x8 tiles. It's the tile's color that decides: if its low 4 bits are high ($f,$1f,$2f etc) the tile is 8bpp, otherwise it's 4bpp */ -INLINE void get_tile_info_8bit(running_machine *machine,tile_data *tileinfo,int tile_index,int layer,UINT16 *vram) +INLINE void get_tile_info_8bit( running_machine *machine, tile_data *tileinfo, int tile_index, int layer, UINT16 *vram ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; UINT16 code; - int table_index; - UINT32 tile; + int table_index; + UINT32 tile; /* The actual tile index depends on the window */ - tile_index = ((tile_index / WIN_NX + hyprduel_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX + - ((tile_index % WIN_NX + hyprduel_window[layer * 2 + 1] / 8) % BIG_NX); + tile_index = ((tile_index / WIN_NX + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX + + ((tile_index % WIN_NX + state->window[layer * 2 + 1] / 8) % BIG_NX); /* Fetch the code */ - code = vram[ tile_index ]; + code = vram[tile_index]; /* Use it as an index into the tiles set table */ - table_index = ( (code & 0x1ff0) >> 4 ) * 2; - tile = (hyprduel_tiletable[table_index + 0] << 16 ) + - hyprduel_tiletable[table_index + 1]; + table_index = ((code & 0x1ff0) >> 4) * 2; + tile = (state->tiletable[table_index + 0] << 16) + state->tiletable[table_index + 1]; if (code & 0x8000) /* Special: draw a tile of a single color (i.e. not from the gfx ROMs) */ { int _code = code & 0x000f; - tileinfo->pen_data = empty_tiles + _code*16*16; + tileinfo->pen_data = state->empty_tiles + _code * 16 * 16; tileinfo->palette_base = ((code & 0x0ff0)) + 0x1000; tileinfo->flags = 0; tileinfo->group = 0; } - else if ((tile & 0x00f00000)==0x00f00000) /* draw tile as 8bpp */ + else if ((tile & 0x00f00000) == 0x00f00000) /* draw tile as 8bpp */ { tileinfo->group = 1; SET_TILE_INFO( @@ -210,33 +191,33 @@ INLINE void get_tile_info_8bit(running_machine *machine,tile_data *tileinfo,int /* 16x16x4 or 16x16x8 tiles. It's the tile's color that decides: if its low 4 bits are high ($f,$1f,$2f etc) the tile is 8bpp, otherwise it's 4bpp */ -INLINE void get_tile_info_16x16_8bit(running_machine *machine,tile_data *tileinfo,int tile_index,int layer,UINT16 *vram) +INLINE void get_tile_info_16x16_8bit( running_machine *machine, tile_data *tileinfo, int tile_index, int layer, UINT16 *vram ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; UINT16 code; - int table_index; - UINT32 tile; + int table_index; + UINT32 tile; /* The actual tile index depends on the window */ - tile_index = ((tile_index / WIN_NX + hyprduel_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX + - ((tile_index % WIN_NX + hyprduel_window[layer * 2 + 1] / 8) % BIG_NX); + tile_index = ((tile_index / WIN_NX + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX + + ((tile_index % WIN_NX + state->window[layer * 2 + 1] / 8) % BIG_NX); /* Fetch the code */ - code = vram[ tile_index ]; + code = vram[tile_index]; /* Use it as an index into the tiles set table */ - table_index = ( (code & 0x1ff0) >> 4 ) * 2; - tile = (hyprduel_tiletable[table_index + 0] << 16 ) + - hyprduel_tiletable[table_index + 1]; + table_index = ((code & 0x1ff0) >> 4) * 2; + tile = (state->tiletable[table_index + 0] << 16) + state->tiletable[table_index + 1]; if (code & 0x8000) /* Special: draw a tile of a single color (i.e. not from the gfx ROMs) */ { int _code = code & 0x000f; - tileinfo->pen_data = empty_tiles + _code*16*16; + tileinfo->pen_data = state->empty_tiles + _code * 16 * 16; tileinfo->palette_base = ((code & 0x0ff0)) + 0x1000; tileinfo->flags = 0; tileinfo->group = 0; } - else if ((tile & 0x00f00000)==0x00f00000) /* draw tile as 8bpp */ + else if ((tile & 0x00f00000) == 0x00f00000) /* draw tile as 8bpp */ { tileinfo->group = 1; SET_TILE_INFO( @@ -257,43 +238,72 @@ INLINE void get_tile_info_16x16_8bit(running_machine *machine,tile_data *tileinf } } -INLINE void hyprduel_vram_w(offs_t offset,UINT16 data,UINT16 mem_mask,int layer,UINT16 *vram) +INLINE void hyprduel_vram_w( running_machine *machine, offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; COMBINE_DATA(&vram[offset]); { /* Account for the window */ - int col = (offset % BIG_NX) - ((hyprduel_window[layer * 2 + 1] / 8) % BIG_NX); - int row = (offset / BIG_NX) - ((hyprduel_window[layer * 2 + 0] / 8) % BIG_NY); - if (col < -(BIG_NX-WIN_NX)) col += (BIG_NX-WIN_NX) + WIN_NX; - if (row < -(BIG_NY-WIN_NY)) row += (BIG_NY-WIN_NY) + WIN_NY; - if ( (col >= 0) && (col < WIN_NX) && - (row >= 0) && (row < WIN_NY) ) - { - tilemap_mark_tile_dirty(bg_tilemap[layer], row * WIN_NX + col ); - } + int col = (offset % BIG_NX) - ((state->window[layer * 2 + 1] / 8) % BIG_NX); + int row = (offset / BIG_NX) - ((state->window[layer * 2 + 0] / 8) % BIG_NY); + if (col < -(BIG_NX-WIN_NX)) + col += (BIG_NX-WIN_NX) + WIN_NX; + if (row < -(BIG_NY-WIN_NY)) + row += (BIG_NY-WIN_NY) + WIN_NY; + if ((col >= 0) && (col < WIN_NX) && (row >= 0) && (row < WIN_NY)) + tilemap_mark_tile_dirty(state->bg_tilemap[layer], row * WIN_NX + col); } } -static TILE_GET_INFO( get_tile_info_0_8bit ) { get_tile_info_8bit(machine,tileinfo,tile_index,0,hyprduel_vram_0); } -static TILE_GET_INFO( get_tile_info_1_8bit ) { get_tile_info_8bit(machine,tileinfo,tile_index,1,hyprduel_vram_1); } -static TILE_GET_INFO( get_tile_info_2_8bit ) { get_tile_info_8bit(machine,tileinfo,tile_index,2,hyprduel_vram_2); } +static TILE_GET_INFO( get_tile_info_0_8bit ) +{ + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + get_tile_info_8bit(machine, tileinfo, tile_index, 0, state->vram_0); +} -WRITE16_HANDLER( hyprduel_vram_0_w ) { hyprduel_vram_w(offset,data,mem_mask,0,hyprduel_vram_0); } -WRITE16_HANDLER( hyprduel_vram_1_w ) { hyprduel_vram_w(offset,data,mem_mask,1,hyprduel_vram_1); } -WRITE16_HANDLER( hyprduel_vram_2_w ) { hyprduel_vram_w(offset,data,mem_mask,2,hyprduel_vram_2); } +static TILE_GET_INFO( get_tile_info_1_8bit ) +{ + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + get_tile_info_8bit(machine, tileinfo, tile_index, 1, state->vram_1); +} + +static TILE_GET_INFO( get_tile_info_2_8bit ) +{ + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + get_tile_info_8bit(machine, tileinfo, tile_index, 2, state->vram_2); +} + +WRITE16_HANDLER( hyprduel_vram_0_w ) +{ + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + hyprduel_vram_w(space->machine, offset, data, mem_mask, 0, state->vram_0); +} + +WRITE16_HANDLER( hyprduel_vram_1_w ) +{ + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + hyprduel_vram_w(space->machine, offset, data, mem_mask, 1, state->vram_1); +} + +WRITE16_HANDLER( hyprduel_vram_2_w ) +{ + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + hyprduel_vram_w(space->machine, offset, data, mem_mask, 2, state->vram_2); +} /* Dirty the relevant tilemap when its window changes */ WRITE16_HANDLER( hyprduel_window_w ) { - UINT16 olddata = hyprduel_window[offset]; - UINT16 newdata = COMBINE_DATA( &hyprduel_window[offset] ); - if ( newdata != olddata ) + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + UINT16 olddata = state->window[offset]; + UINT16 newdata = COMBINE_DATA(&state->window[offset]); + if (newdata != olddata) { offset /= 2; - tilemap_mark_all_tiles_dirty(bg_tilemap[offset]); + tilemap_mark_all_tiles_dirty(state->bg_tilemap[offset]); } } @@ -309,70 +319,89 @@ WRITE16_HANDLER( hyprduel_window_w ) the tile's sizes to be known at startup - which we don't! */ -static void alloc_empty_tiles(running_machine *machine) +static void alloc_empty_tiles( running_machine *machine ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; int code,i; - empty_tiles = auto_alloc_array(machine, UINT8, 16*16*16); + state->empty_tiles = auto_alloc_array(machine, UINT8, 16*16*16); + state_save_register_global_pointer(machine, state->empty_tiles, 16*16*16); - for (code = 0;code < 0x10;code++) - for (i = 0;i < 16*16;i++) - empty_tiles[16*16*code + i] = code; + for (code = 0; code < 0x10; code++) + for (i = 0; i < 16 * 16; i++) + state->empty_tiles[16 * 16 * code + i] = code; } static STATE_POSTLOAD( hyprduel_postload ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; int i; - for (i=0; i<3; i++) + for (i = 0; i < 3; i++) { - UINT16 wx = hyprduel_window[i * 2 + 1]; - UINT16 wy = hyprduel_window[i * 2 + 0]; + UINT16 wx = state->window[i * 2 + 1]; + UINT16 wy = state->window[i * 2 + 0]; - tilemap_set_scrollx(bg_tilemap[i], 0, hyprduel_scroll[i * 2 + 1] - wx - (wx & 7)); - tilemap_set_scrolly(bg_tilemap[i], 0, hyprduel_scroll[i * 2 + 0] - wy - (wy & 7)); + tilemap_set_scrollx(state->bg_tilemap[i], 0, state->scroll[i * 2 + 1] - wx - (wx & 7)); + tilemap_set_scrolly(state->bg_tilemap[i], 0, state->scroll[i * 2 + 0] - wy - (wy & 7)); - tilemap_mark_all_tiles_dirty(bg_tilemap[i]); + tilemap_mark_all_tiles_dirty(state->bg_tilemap[i]); } } -VIDEO_START( hyprduel_14220 ) +VIDEO_START( common_14220 ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; alloc_empty_tiles(machine); - hyprduel_tiletable_old = auto_alloc_array(machine, UINT16, hyprduel_tiletable_size/2); - dirtyindex = auto_alloc_array(machine, UINT8, hyprduel_tiletable_size/4); + state->tiletable_old = auto_alloc_array(machine, UINT16, state->tiletable_size / 2); + state->dirtyindex = auto_alloc_array(machine, UINT8, state->tiletable_size / 4); - bg_tilemap[0] = tilemap_create(machine, get_tile_info_0_8bit,tilemap_scan_rows,8,8,WIN_NX,WIN_NY); - bg_tilemap[1] = tilemap_create(machine, get_tile_info_1_8bit,tilemap_scan_rows,8,8,WIN_NX,WIN_NY); - bg_tilemap[2] = tilemap_create(machine, get_tile_info_2_8bit,tilemap_scan_rows,8,8,WIN_NX,WIN_NY); + state_save_register_global_pointer(machine, state->tiletable_old, state->tiletable_size / 2); + state_save_register_global_pointer(machine, state->dirtyindex, state->tiletable_size / 4); - tilemap_map_pen_to_layer(bg_tilemap[0], 0, 15, TILEMAP_PIXEL_TRANSPARENT); - tilemap_map_pen_to_layer(bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT); + state->bg_tilemap[0] = tilemap_create(machine, get_tile_info_0_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY); + state->bg_tilemap[1] = tilemap_create(machine, get_tile_info_1_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY); + state->bg_tilemap[2] = tilemap_create(machine, get_tile_info_2_8bit, tilemap_scan_rows, 8, 8, WIN_NX, WIN_NY); - tilemap_map_pen_to_layer(bg_tilemap[1], 0, 15, TILEMAP_PIXEL_TRANSPARENT); - tilemap_map_pen_to_layer(bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT); + tilemap_map_pen_to_layer(state->bg_tilemap[0], 0, 15, TILEMAP_PIXEL_TRANSPARENT); + tilemap_map_pen_to_layer(state->bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT); - tilemap_map_pen_to_layer(bg_tilemap[2], 0, 15, TILEMAP_PIXEL_TRANSPARENT); - tilemap_map_pen_to_layer(bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT); + tilemap_map_pen_to_layer(state->bg_tilemap[1], 0, 15, TILEMAP_PIXEL_TRANSPARENT); + tilemap_map_pen_to_layer(state->bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT); - tilemap_set_scrolldx(bg_tilemap[0], 0, 0); - tilemap_set_scrolldx(bg_tilemap[1], 0, 0); - tilemap_set_scrolldx(bg_tilemap[2], 0, 0); + tilemap_map_pen_to_layer(state->bg_tilemap[2], 0, 15, TILEMAP_PIXEL_TRANSPARENT); + tilemap_map_pen_to_layer(state->bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT); - if (!strcmp(machine->gamedrv->name, "magerror")) - hyprduel_sprite_yoffs_sub = 0; - else - hyprduel_sprite_yoffs_sub = 2; + tilemap_set_scrolldx(state->bg_tilemap[0], 0, 0); + tilemap_set_scrolldx(state->bg_tilemap[1], 0, 0); + tilemap_set_scrolldx(state->bg_tilemap[2], 0, 0); /* Set up save state */ - state_save_register_global(machine, hyprduel_sprite_xoffs); - state_save_register_global(machine, hyprduel_sprite_yoffs); - state_save_register_global(machine, hyprduel_sprite_yoffs_sub); + state_save_register_global(machine, state->sprite_xoffs); + state_save_register_global(machine, state->sprite_yoffs); state_save_register_postload(machine, hyprduel_postload, NULL); } +VIDEO_START( hyprduel_14220 ) +{ + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + + state->sprite_yoffs_sub = 2; + + VIDEO_START_CALL(common_14220); +} + +VIDEO_START( magerror_14220 ) +{ + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + + state->sprite_yoffs_sub = 0; + + VIDEO_START_CALL(common_14220); +} + /*************************************************************************** Video Registers @@ -430,18 +459,19 @@ VIDEO_START( hyprduel_14220 ) /* Draw sprites */ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { + hyprduel_state *state = (hyprduel_state *)machine->driver_data; UINT8 *base_gfx = memory_region(machine, "gfx1"); UINT8 *gfx_max = base_gfx + memory_region_length(machine, "gfx1"); int max_x = video_screen_get_width(machine->primary_screen); int max_y = video_screen_get_height(machine->primary_screen); - int max_sprites = machine->generic.spriteram_size / 8; - int sprites = hyprduel_videoregs[0x00/2] % max_sprites; + int max_sprites = state->spriteram_size / 8; + int sprites = state->videoregs[0x00 / 2] % max_sprites; - int color_start = ((hyprduel_videoregs[0x08/2] & 0xf) << 4 ) + 0x100; + int color_start = ((state->videoregs[0x08 / 2] & 0xf) << 4) + 0x100; int i, j, pri; static const int primask[4] = { 0x0000, 0xff00, 0xff00|0xf0f0, 0xff00|0xf0f0|0xcccc }; @@ -452,22 +482,22 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta if (sprites == 0) return; - for (i=0; i<0x20; i++) + for (i = 0; i < 0x20; i++) { gfx_element gfx; - if (!(hyprduel_videoregs[0x02/2] & 0x8000)) + if (!(state->videoregs[0x02 / 2] & 0x8000)) { - src = machine->generic.spriteram.u16 + (sprites - 1) * (8/2); - inc = -(8/2); + src = state->spriteram + (sprites - 1) * (8 / 2); + inc = -(8 / 2); } else { - src = machine->generic.spriteram.u16; - inc = (8/2); + src = state->spriteram; + inc = (8 / 2); } - for (j=0; j> 11; + x = src[0]; + curr_pri = (x & 0xf800) >> 11; if ((curr_pri == 0x1f) || (curr_pri != i)) { @@ -490,31 +520,31 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta continue; } - pri = (hyprduel_videoregs[0x02/2] & 0x0300) >> 8; + pri = (state->videoregs[0x02 / 2] & 0x0300) >> 8; - if (!(hyprduel_videoregs[0x02/2] & 0x8000)) + if (!(state->videoregs[0x02 / 2] & 0x8000)) { - if (curr_pri > (hyprduel_videoregs[0x02/2] & 0x1f)) - pri = (hyprduel_videoregs[0x02/2] & 0x0c00) >> 10; + if (curr_pri > (state->videoregs[0x02 / 2] & 0x1f)) + pri = (state->videoregs[0x02 / 2] & 0x0c00) >> 10; } - y = src[ 1 ]; - attr = src[ 2 ]; - code = src[ 3 ]; + y = src[1]; + attr = src[2]; + code = src[3]; - flipx = attr & 0x8000; - flipy = attr & 0x4000; - color = (attr & 0xf0) >> 4; + flipx = attr & 0x8000; + flipy = attr & 0x4000; + color = (attr & 0xf0) >> 4; - zoom = zoomtable[(y & 0xfc00) >> 10] << (16-8); + zoom = zoomtable[(y & 0xfc00) >> 10] << (16 - 8); - x = (x & 0x07ff) - hyprduel_sprite_xoffs; - y = (y & 0x03ff) - hyprduel_sprite_yoffs; + x = (x & 0x07ff) - state->sprite_xoffs; + y = (y & 0x03ff) - state->sprite_yoffs; - width = (( (attr >> 11) & 0x7 ) + 1 ) * 8; - height = (( (attr >> 8) & 0x7 ) + 1 ) * 8; + width = (((attr >> 11) & 0x7) + 1) * 8; + height = (((attr >> 8) & 0x7) + 1) * 8; - gfxdata = base_gfx + (8*8*4/8) * (((attr & 0x000f) << 16) + code); + gfxdata = base_gfx + (8 * 8 * 4 / 8) * (((attr & 0x000f) << 16) + code); if (flip_screen_get(machine)) { @@ -525,12 +555,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta if (color == 0xf) /* 8bpp */ { /* Bounds checking */ - if ( (gfxdata + width * height - 1) >= gfx_max ) + if ((gfxdata + width * height - 1) >= gfx_max) continue; gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0); - pdrawgfxzoom_transpen( bitmap,cliprect, &gfx, + pdrawgfxzoom_transpen(bitmap,cliprect, &gfx, 0, color_start >> 4, flipx, flipy, @@ -541,12 +571,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta else { /* Bounds checking */ - if ( (gfxdata + width/2 * height - 1) >= gfx_max ) + if ( (gfxdata + width / 2 * height - 1) >= gfx_max ) continue; - gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width/2, 0, 16, GFX_ELEMENT_PACKED); + gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width / 2, 0, 16, GFX_ELEMENT_PACKED); - pdrawgfxzoom_transpen( bitmap,cliprect, &gfx, + pdrawgfxzoom_transpen(bitmap,cliprect, &gfx, 0, color + color_start, flipx, flipy, @@ -572,37 +602,40 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta WRITE16_HANDLER( hyprduel_scrollreg_w ) { - UINT16 window = hyprduel_window[offset]; + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; + UINT16 window = state->window[offset]; - COMBINE_DATA(&hyprduel_scroll[offset]); + COMBINE_DATA(&state->scroll[offset]); if (offset & 0x01) - tilemap_set_scrollx(bg_tilemap[offset / 2], 0, hyprduel_scroll[offset] - window - (window & 7)); + tilemap_set_scrollx(state->bg_tilemap[offset / 2], 0, state->scroll[offset] - window - (window & 7)); else - tilemap_set_scrolly(bg_tilemap[offset / 2], 0, hyprduel_scroll[offset] - window - (window & 7)); + tilemap_set_scrolly(state->bg_tilemap[offset / 2], 0, state->scroll[offset] - window - (window & 7)); } WRITE16_HANDLER( hyprduel_scrollreg_init_w ) { + hyprduel_state *state = (hyprduel_state *)space->machine->driver_data; int i; - for (i=0; i<3; i++) + for (i = 0; i < 3; i++) { - UINT16 wx = hyprduel_window[i * 2 + 1]; - UINT16 wy = hyprduel_window[i * 2 + 0]; + UINT16 wx = state->window[i * 2 + 1]; + UINT16 wy = state->window[i * 2 + 0]; - hyprduel_scroll[i * 2 + 1] = data; - hyprduel_scroll[i * 2 + 0] = data; + state->scroll[i * 2 + 1] = data; + state->scroll[i * 2 + 0] = data; - tilemap_set_scrollx(bg_tilemap[i], 0, data - wx - (wx & 7)); - tilemap_set_scrolly(bg_tilemap[i], 0, data - wy - (wy & 7)); + tilemap_set_scrollx(state->bg_tilemap[i], 0, data - wx - (wx & 7)); + tilemap_set_scrolly(state->bg_tilemap[i], 0, data - wy - (wy & 7)); } } -static void draw_layers(bitmap_t *bitmap, const rectangle *cliprect, int pri, int layers_ctrl) +static void draw_layers( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri, int layers_ctrl ) { - UINT16 layers_pri = hyprduel_videoregs[0x10/2]; + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + UINT16 layers_pri = state->videoregs[0x10/2]; int layer; /* Draw all the layers with priority == pri */ @@ -610,27 +643,27 @@ static void draw_layers(bitmap_t *bitmap, const rectangle *cliprect, int pri, in { if ( pri == ((layers_pri >> (layer*2)) & 3) ) { - if (layers_ctrl & (1<bg_tilemap[layer], 0, 1 << (3 - pri)); } } } /* Dirty tilemaps when the tiles set changes */ -static void dirty_tiles(int layer,UINT16 *vram) +static void dirty_tiles( running_machine *machine, int layer, UINT16 *vram ) { - int col,row; + hyprduel_state *state = (hyprduel_state *)machine->driver_data; + int col, row; - for (row = 0;row < WIN_NY;row++) + for (row = 0; row < WIN_NY; row++) { - for (col = 0;col < WIN_NX;col++) + for (col = 0; col < WIN_NX; col++) { - int offset = (col + hyprduel_window[layer * 2 + 1] / 8) % BIG_NX + - ((row + hyprduel_window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX; + int offset = (col + state->window[layer * 2 + 1] / 8) % BIG_NX + ((row + state->window[layer * 2 + 0] / 8) % BIG_NY) * BIG_NX; UINT16 code = vram[offset]; - if (!(code & 0x8000) && dirtyindex[(code & 0x1ff0) >> 4]) - tilemap_mark_tile_dirty(bg_tilemap[layer], row * WIN_NX + col ); + if (!(code & 0x8000) && state->dirtyindex[(code & 0x1ff0) >> 4]) + tilemap_mark_tile_dirty(state->bg_tilemap[layer], row * WIN_NX + col); } } } @@ -638,40 +671,41 @@ static void dirty_tiles(int layer,UINT16 *vram) VIDEO_UPDATE( hyprduel ) { - int i,pri,layers_ctrl = -1; - UINT16 screenctrl = *hyprduel_screenctrl; + hyprduel_state *state = (hyprduel_state *)screen->machine->driver_data; + int i, pri, layers_ctrl = -1; + UINT16 screenctrl = *state->screenctrl; { int dirty = 0; - memset(dirtyindex,0,hyprduel_tiletable_size/4); - for (i = 0;i < hyprduel_tiletable_size/4;i++) + memset(state->dirtyindex, 0, state->tiletable_size / 4); + for (i = 0; i < state->tiletable_size / 4; i++) { - UINT32 tile_new = (hyprduel_tiletable[2*i + 0] << 16 ) + hyprduel_tiletable[2*i + 1]; - UINT32 tile_old = (hyprduel_tiletable_old[2*i + 0] << 16 ) + hyprduel_tiletable_old[2*i + 1]; + UINT32 tile_new = (state->tiletable[2 * i + 0] << 16 ) + state->tiletable[2 * i + 1]; + UINT32 tile_old = (state->tiletable_old[2 * i + 0] << 16 ) + state->tiletable_old[2 * i + 1]; if ((tile_new ^ tile_old) & 0x0fffffff) { - dirtyindex[i] = 1; + state->dirtyindex[i] = 1; dirty = 1; } } - memcpy(hyprduel_tiletable_old,hyprduel_tiletable,hyprduel_tiletable_size); + memcpy(state->tiletable_old, state->tiletable, state->tiletable_size); if (dirty) { - dirty_tiles(0,hyprduel_vram_0); - dirty_tiles(1,hyprduel_vram_1); - dirty_tiles(2,hyprduel_vram_2); + dirty_tiles(screen->machine, 0, state->vram_0); + dirty_tiles(screen->machine, 1, state->vram_1); + dirty_tiles(screen->machine, 2, state->vram_2); } } - hyprduel_sprite_xoffs = hyprduel_videoregs[0x06/2] - video_screen_get_width(screen) / 2; - hyprduel_sprite_yoffs = hyprduel_videoregs[0x04/2] - video_screen_get_height(screen) / 2 - hyprduel_sprite_yoffs_sub; + state->sprite_xoffs = state->videoregs[0x06 / 2] - video_screen_get_width(screen) / 2; + state->sprite_yoffs = state->videoregs[0x04 / 2] - video_screen_get_height(screen) / 2 - state->sprite_yoffs_sub; /* The background color is selected by a register */ - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); - bitmap_fill(bitmap,cliprect,((hyprduel_videoregs[0x12/2] & 0x0fff)) + 0x1000); + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); + bitmap_fill(bitmap, cliprect, ((state->videoregs[0x12 / 2] & 0x0fff)) + 0x1000); /* Screen Control Register: @@ -684,7 +718,8 @@ VIDEO_UPDATE( hyprduel ) ---- ---- ---4 32-- ---- ---- ---- --1- ? Blank Screen ---- ---- ---- ---0 Flip Screen */ - if (screenctrl & 2) return 0; + if (screenctrl & 2) + return 0; flip_screen_set(screen->machine, screenctrl & 1); #if 0 @@ -695,20 +730,22 @@ if (input_code_pressed(screen->machine, KEYCODE_Z)) if (input_code_pressed(screen->machine, KEYCODE_E)) msk |= 0x04; if (input_code_pressed(screen->machine, KEYCODE_A)) msk |= 0x08; if (msk != 0) - { bitmap_fill(bitmap,cliprect,0); - layers_ctrl &= msk; } + { + bitmap_fill(bitmap, cliprect,0); + layers_ctrl &= msk; + } popmessage("%x-%x-%x:%04x %04x %04x", - hyprduel_videoregs[0x10/2]&3,(hyprduel_videoregs[0x10/2]&0xc)>>2,(hyprduel_videoregs[0x10/2]&0x30)>>4, - hyprduel_videoregs[0x02/2],hyprduel_videoregs[0x08/2], - *hyprduel_screenctrl);} + state->videoregs[0x10/2]&3,(state->videoregs[0x10/2] & 0xc) >> 2, (state->videoregs[0x10/2] & 0x30) >> 4, + state->videoregs[0x02/2], state->videoregs[0x08/2], + *state->screenctrl);} #endif - for (pri=3; pri>=0; pri--) - draw_layers(bitmap,cliprect,pri,layers_ctrl); + for (pri = 3; pri >= 0; pri--) + draw_layers(screen->machine, bitmap, cliprect, pri, layers_ctrl); if (layers_ctrl & 0x08) - draw_sprites(screen->machine,bitmap,cliprect); + draw_sprites(screen->machine, bitmap, cliprect); return 0; }