Moved global and static variables in driver galaga into a machine class. Renamed some variables, e.g. galaga_videoram and bosco_videoram to just videoram. [Couriersud]

This commit is contained in:
Couriersud 2010-05-23 20:03:35 +00:00
parent 6a325434b0
commit cb097b7f95
6 changed files with 286 additions and 252 deletions

View File

@ -920,16 +920,16 @@ static ADDRESS_MAP_START( bosco_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx_0", namco_06xx_data_r, namco_06xx_data_w) AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx_0", namco_06xx_data_r, namco_06xx_data_w)
AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx_0", namco_06xx_ctrl_r, namco_06xx_ctrl_w) AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx_0", namco_06xx_ctrl_r, namco_06xx_ctrl_w)
AM_RANGE(0x7800, 0x7fff) AM_RAM AM_SHARE("share1") AM_RANGE(0x7800, 0x7fff) AM_RAM AM_SHARE("share1")
AM_RANGE(0x8000, 0x8fff) AM_READWRITE(bosco_videoram_r, bosco_videoram_w) AM_BASE(&bosco_videoram) /* + sprite registers */ AM_RANGE(0x8000, 0x8fff) AM_RAM_WRITE(bosco_videoram_w) AM_BASE_MEMBER(_galaga_state, videoram) AM_SHARE("bvr") /* + sprite registers */
AM_RANGE(0x9000, 0x90ff) AM_DEVREADWRITE("06xx_1", namco_06xx_data_r, namco_06xx_data_w) AM_RANGE(0x9000, 0x90ff) AM_DEVREADWRITE("06xx_1", namco_06xx_data_r, namco_06xx_data_w)
AM_RANGE(0x9100, 0x9100) AM_DEVREADWRITE("06xx_1", namco_06xx_ctrl_r, namco_06xx_ctrl_w) AM_RANGE(0x9100, 0x9100) AM_DEVREADWRITE("06xx_1", namco_06xx_ctrl_r, namco_06xx_ctrl_w)
AM_RANGE(0x9800, 0x980f) AM_WRITEONLY AM_SHARE("share2") AM_BASE(&bosco_radarattr) AM_RANGE(0x9800, 0x980f) AM_WRITEONLY AM_SHARE("share2") AM_BASE_MEMBER(_galaga_state, bosco_radarattr)
AM_RANGE(0x9810, 0x9810) AM_WRITE(bosco_scrollx_w) AM_RANGE(0x9810, 0x9810) AM_WRITE(bosco_scrollx_w)
AM_RANGE(0x9820, 0x9820) AM_WRITE(bosco_scrolly_w) AM_RANGE(0x9820, 0x9820) AM_WRITE(bosco_scrolly_w)
AM_RANGE(0x9830, 0x9830) AM_WRITE(bosco_starcontrol_w) AM_RANGE(0x9830, 0x9830) AM_WRITEONLY AM_BASE_MEMBER(_galaga_state, bosco_starcontrol) AM_SHARE("bsc")
AM_RANGE(0x9840, 0x9840) AM_WRITE(bosco_starclr_w) AM_RANGE(0x9840, 0x9840) AM_WRITE(bosco_starclr_w)
AM_RANGE(0x9870, 0x9870) AM_WRITE(bosco_flip_screen_w) AM_RANGE(0x9870, 0x9870) AM_WRITE(bosco_flip_screen_w)
AM_RANGE(0x9874, 0x9875) AM_WRITE(bosco_starblink_w) AM_RANGE(0x9874, 0x9875) AM_WRITEONLY AM_BASE_MEMBER(_galaga_state, bosco_starblink) AM_SHARE("bsb")
ADDRESS_MAP_END ADDRESS_MAP_END
@ -941,11 +941,11 @@ static ADDRESS_MAP_START( galaga_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x6830, 0x6830) AM_WRITE(watchdog_reset_w) AM_RANGE(0x6830, 0x6830) AM_WRITE(watchdog_reset_w)
AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx", namco_06xx_data_r, namco_06xx_data_w) AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx", namco_06xx_data_r, namco_06xx_data_w)
AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx", namco_06xx_ctrl_r, namco_06xx_ctrl_w) AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx", namco_06xx_ctrl_r, namco_06xx_ctrl_w)
AM_RANGE(0x8000, 0x87ff) AM_READWRITE(galaga_videoram_r, galaga_videoram_w) AM_BASE(&galaga_videoram) AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(galaga_videoram_w) AM_BASE_MEMBER(_galaga_state, videoram) AM_SHARE("gvr")
AM_RANGE(0x8800, 0x8bff) AM_RAM AM_SHARE("share1") AM_BASE(&galaga_ram1) AM_RANGE(0x8800, 0x8bff) AM_RAM AM_SHARE("share1") AM_BASE_MEMBER(_galaga_state, galaga_ram1)
AM_RANGE(0x9000, 0x93ff) AM_RAM AM_SHARE("share2") AM_BASE(&galaga_ram2) AM_RANGE(0x9000, 0x93ff) AM_RAM AM_SHARE("share2") AM_BASE_MEMBER(_galaga_state, galaga_ram2)
AM_RANGE(0x9800, 0x9bff) AM_RAM AM_SHARE("share3") AM_BASE(&galaga_ram3) AM_RANGE(0x9800, 0x9bff) AM_RAM AM_SHARE("share3") AM_BASE_MEMBER(_galaga_state, galaga_ram3)
AM_RANGE(0xa000, 0xa005) AM_WRITE(galaga_starcontrol_w) AM_RANGE(0xa000, 0xa005) AM_WRITEONLY AM_BASE_MEMBER(_galaga_state, galaga_starcontrol) AM_SHARE("gsc")
AM_RANGE(0xa007, 0xa007) AM_WRITE(galaga_flip_screen_w) AM_RANGE(0xa007, 0xa007) AM_WRITE(galaga_flip_screen_w)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -959,13 +959,13 @@ static ADDRESS_MAP_START( xevious_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx", namco_06xx_data_r, namco_06xx_data_w) AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx", namco_06xx_data_r, namco_06xx_data_w)
AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx", namco_06xx_ctrl_r, namco_06xx_ctrl_w) AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx", namco_06xx_ctrl_r, namco_06xx_ctrl_w)
AM_RANGE(0x7800, 0x7fff) AM_RAM AM_SHARE("share1") /* work RAM */ AM_RANGE(0x7800, 0x7fff) AM_RAM AM_SHARE("share1") /* work RAM */
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("share2") AM_BASE(&xevious_sr1) /* work RAM + sprite registers */ AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("share2") AM_BASE_MEMBER(_galaga_state, xevious_sr1) /* work RAM + sprite registers */
AM_RANGE(0x9000, 0x97ff) AM_RAM AM_SHARE("share3") AM_BASE(&xevious_sr2) /* work RAM + sprite registers */ AM_RANGE(0x9000, 0x97ff) AM_RAM AM_SHARE("share3") AM_BASE_MEMBER(_galaga_state, xevious_sr2) /* work RAM + sprite registers */
AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_SHARE("share4") AM_BASE(&xevious_sr3) /* work RAM + sprite registers */ AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_SHARE("share4") AM_BASE_MEMBER(_galaga_state, xevious_sr3) /* work RAM + sprite registers */
AM_RANGE(0xb000, 0xb7ff) AM_READWRITE(xevious_fg_colorram_r, xevious_fg_colorram_w) AM_BASE(&xevious_fg_colorram) AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(xevious_fg_colorram_w) AM_BASE_MEMBER(_galaga_state, xevious_fg_colorram) AM_SHARE("fgc")
AM_RANGE(0xb800, 0xbfff) AM_READWRITE(xevious_bg_colorram_r, xevious_bg_colorram_w) AM_BASE(&xevious_bg_colorram) AM_RANGE(0xb800, 0xbfff) AM_RAM_WRITE(xevious_bg_colorram_w) AM_BASE_MEMBER(_galaga_state, xevious_bg_colorram) AM_SHARE("bgc")
AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(xevious_fg_videoram_r, xevious_fg_videoram_w) AM_BASE(&xevious_fg_videoram) AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(xevious_fg_videoram_w) AM_BASE_MEMBER(_galaga_state, xevious_fg_videoram) AM_SHARE("fgv")
AM_RANGE(0xc800, 0xcfff) AM_READWRITE(xevious_bg_videoram_r, xevious_bg_videoram_w) AM_BASE(&xevious_bg_videoram) AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(xevious_bg_videoram_w) AM_BASE_MEMBER(_galaga_state, xevious_bg_videoram) AM_SHARE("bgv")
AM_RANGE(0xd000, 0xd07f) AM_WRITE(xevious_vh_latch_w) AM_RANGE(0xd000, 0xd07f) AM_WRITE(xevious_vh_latch_w)
AM_RANGE(0xf000, 0xffff) AM_READWRITE(xevious_bb_r, xevious_bs_w) AM_RANGE(0xf000, 0xffff) AM_READWRITE(xevious_bb_r, xevious_bs_w)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -978,11 +978,11 @@ static ADDRESS_MAP_START( digdug_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x6830, 0x6830) AM_WRITE(watchdog_reset_w) AM_RANGE(0x6830, 0x6830) AM_WRITE(watchdog_reset_w)
AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx", namco_06xx_data_r, namco_06xx_data_w) AM_RANGE(0x7000, 0x70ff) AM_DEVREADWRITE("06xx", namco_06xx_data_r, namco_06xx_data_w)
AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx", namco_06xx_ctrl_r, namco_06xx_ctrl_w) AM_RANGE(0x7100, 0x7100) AM_DEVREADWRITE("06xx", namco_06xx_ctrl_r, namco_06xx_ctrl_w)
AM_RANGE(0x8000, 0x83ff) AM_READWRITE(digdug_videoram_r, digdug_videoram_w) AM_BASE(&digdug_videoram) /* tilemap RAM (bottom half of RAM 0 */ AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(digdug_videoram_w) AM_BASE_MEMBER(_galaga_state, videoram) AM_SHARE("dvr")/* tilemap RAM (bottom half of RAM 0 */
AM_RANGE(0x8400, 0x87ff) AM_RAM AM_SHARE("share1") /* work RAM (top half for RAM 0 */ AM_RANGE(0x8400, 0x87ff) AM_RAM AM_SHARE("share1") /* work RAM (top half for RAM 0 */
AM_RANGE(0x8800, 0x8bff) AM_RAM AM_SHARE("share2") AM_BASE(&digdug_objram) /* work RAM + sprite registers */ AM_RANGE(0x8800, 0x8bff) AM_RAM AM_SHARE("share2") AM_BASE_MEMBER(_galaga_state, digdug_objram) /* work RAM + sprite registers */
AM_RANGE(0x9000, 0x93ff) AM_RAM AM_SHARE("share3") AM_BASE(&digdug_posram) /* work RAM + sprite registers */ AM_RANGE(0x9000, 0x93ff) AM_RAM AM_SHARE("share3") AM_BASE_MEMBER(_galaga_state, digdug_posram) /* work RAM + sprite registers */
AM_RANGE(0x9800, 0x9bff) AM_RAM AM_SHARE("share4") AM_BASE(&digdug_flpram) /* work RAM + sprite registers */ AM_RANGE(0x9800, 0x9bff) AM_RAM AM_SHARE("share4") AM_BASE_MEMBER(_galaga_state, digdug_flpram) /* work RAM + sprite registers */
AM_RANGE(0xa000, 0xa007) AM_READNOP AM_WRITE(digdug_PORT_w) /* video latches (spurious reads when setting latch bits) */ AM_RANGE(0xa000, 0xa007) AM_READNOP AM_WRITE(digdug_PORT_w) /* video latches (spurious reads when setting latch bits) */
AM_RANGE(0xb800, 0xb83f) AM_DEVREADWRITE("earom", atari_vg_earom_r, atari_vg_earom_w) /* non volatile memory data */ AM_RANGE(0xb800, 0xb83f) AM_DEVREADWRITE("earom", atari_vg_earom_r, atari_vg_earom_w) /* non volatile memory data */
AM_RANGE(0xb840, 0xb840) AM_DEVWRITE("earom", atari_vg_earom_ctrl_w) /* non volatile memory control */ AM_RANGE(0xb840, 0xb840) AM_DEVWRITE("earom", atari_vg_earom_ctrl_w) /* non volatile memory control */
@ -1583,6 +1583,8 @@ static const samples_interface battles_samples_interface =
static MACHINE_DRIVER_START( bosco ) static MACHINE_DRIVER_START( bosco )
MDRV_DRIVER_DATA(_galaga_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */ MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */
MDRV_CPU_PROGRAM_MAP(bosco_map) MDRV_CPU_PROGRAM_MAP(bosco_map)
@ -1639,6 +1641,8 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( galaga ) static MACHINE_DRIVER_START( galaga )
MDRV_DRIVER_DATA(_galaga_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */ MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */
MDRV_CPU_PROGRAM_MAP(galaga_map) MDRV_CPU_PROGRAM_MAP(galaga_map)
@ -1709,6 +1713,8 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( xevious ) static MACHINE_DRIVER_START( xevious )
MDRV_DRIVER_DATA(_galaga_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */ MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */
MDRV_CPU_PROGRAM_MAP(xevious_map) MDRV_CPU_PROGRAM_MAP(xevious_map)
@ -1792,6 +1798,8 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( digdug ) static MACHINE_DRIVER_START( digdug )
MDRV_DRIVER_DATA(_galaga_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */ MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK/6) /* 3.072 MHz */
MDRV_CPU_PROGRAM_MAP(digdug_map) MDRV_CPU_PROGRAM_MAP(digdug_map)

View File

@ -1,16 +1,83 @@
#include "sound/discrete.h" #include "sound/discrete.h"
class _galaga_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _galaga_state(machine)); }
_galaga_state(running_machine &machine)
{
xevious_bs[0] = 0;
xevious_bs[1] = 0;
}
/* memory pointers */
UINT8 *galaga_ram1,*galaga_ram2,*galaga_ram3;
UINT8 *galaga_starcontrol; // 6 addresses
/* machine state */
UINT32 stars_scrollx;
UINT32 stars_scrolly;
UINT32 galaga_gfxbank; // used by catsbee
/* devices */
/* bank support */
/* shared */
UINT8 *videoram;
tilemap_t *fg_tilemap;
tilemap_t *bg_tilemap;
/* xevious */
UINT8 *xevious_fg_videoram;
UINT8 *xevious_fg_colorram;
UINT8 *xevious_bg_videoram;
UINT8 *xevious_bg_colorram;
UINT8 *xevious_sr1;
UINT8 *xevious_sr2;
UINT8 *xevious_sr3;
/* xevious static */
INT32 xevious_bs[2];
/* bosco */
UINT8 *bosco_radarattr;
/* bosco static */
UINT8 *bosco_starcontrol;
UINT8 *bosco_starblink;
UINT8 *bosco_radarx;
UINT8 *bosco_radary;
/* digdug */
UINT8 *digdug_objram;
UINT8 *digdug_posram;
UINT8 *digdug_flpram;
/* digdug static*/
UINT8 bg_select;
UINT8 tx_color_mode;
UINT8 bg_disable;
UINT8 bg_color_bank;
};
/*----------- defined in video/bosco.c -----------*/ /*----------- defined in video/bosco.c -----------*/
extern UINT8 *bosco_videoram;
extern UINT8 *bosco_radarattr;
READ8_HANDLER( bosco_videoram_r );
WRITE8_HANDLER( bosco_videoram_w ); WRITE8_HANDLER( bosco_videoram_w );
WRITE8_HANDLER( bosco_scrollx_w ); WRITE8_HANDLER( bosco_scrollx_w );
WRITE8_HANDLER( bosco_scrolly_w ); WRITE8_HANDLER( bosco_scrolly_w );
WRITE8_HANDLER( bosco_starcontrol_w );
WRITE8_HANDLER( bosco_starclr_w ); WRITE8_HANDLER( bosco_starclr_w );
WRITE8_HANDLER( bosco_starblink_w );
VIDEO_START( bosco ); VIDEO_START( bosco );
VIDEO_UPDATE( bosco ); VIDEO_UPDATE( bosco );
PALETTE_INIT( bosco ); PALETTE_INIT( bosco );
@ -30,15 +97,10 @@ struct star
UINT8 col,set; UINT8 col,set;
}; };
extern UINT8 *galaga_videoram;
extern UINT8 *galaga_ram1,*galaga_ram2,*galaga_ram3;
extern UINT8 galaga_starcontrol[];
extern const struct star star_seed_tab[]; extern const struct star star_seed_tab[];
PALETTE_INIT( galaga ); PALETTE_INIT( galaga );
READ8_HANDLER( galaga_videoram_r );
WRITE8_HANDLER( galaga_videoram_w ); WRITE8_HANDLER( galaga_videoram_w );
WRITE8_HANDLER( galaga_starcontrol_w );
WRITE8_HANDLER( gatsbee_bank_w ); WRITE8_HANDLER( gatsbee_bank_w );
VIDEO_START( galaga ); VIDEO_START( galaga );
VIDEO_UPDATE( galaga ); VIDEO_UPDATE( galaga );
@ -46,14 +108,6 @@ VIDEO_EOF( galaga ); /* update starfield */
/*----------- defined in video/xevious.c -----------*/ /*----------- defined in video/xevious.c -----------*/
extern UINT8 *xevious_fg_videoram,*xevious_fg_colorram;
extern UINT8 *xevious_bg_videoram,*xevious_bg_colorram;
extern UINT8 *xevious_sr1,*xevious_sr2,*xevious_sr3;
READ8_HANDLER( xevious_fg_videoram_r );
READ8_HANDLER( xevious_fg_colorram_r );
READ8_HANDLER( xevious_bg_videoram_r );
READ8_HANDLER( xevious_bg_colorram_r );
WRITE8_HANDLER( xevious_fg_videoram_w ); WRITE8_HANDLER( xevious_fg_videoram_w );
WRITE8_HANDLER( xevious_fg_colorram_w ); WRITE8_HANDLER( xevious_fg_colorram_w );
WRITE8_HANDLER( xevious_bg_videoram_w ); WRITE8_HANDLER( xevious_bg_videoram_w );
@ -89,9 +143,6 @@ INTERRUPT_GEN( battles_interrupt_4 );
/*----------- defined in video/digdug.c -----------*/ /*----------- defined in video/digdug.c -----------*/
extern UINT8 *digdug_videoram,*digdug_objram, *digdug_posram, *digdug_flpram;
READ8_HANDLER( digdug_videoram_r );
WRITE8_HANDLER( digdug_videoram_w ); WRITE8_HANDLER( digdug_videoram_w );
WRITE8_HANDLER( digdug_PORT_w ); WRITE8_HANDLER( digdug_PORT_w );
VIDEO_START( digdug ); VIDEO_START( digdug );

View File

@ -12,21 +12,8 @@
#define MAX_STARS 252 #define MAX_STARS 252
#define STARS_COLOR_BASE (64*4+64*4+4) #define STARS_COLOR_BASE (64*4+64*4+4)
static UINT32 stars_scrollx;
static UINT32 stars_scrolly;
static INT32 bosco_starcontrol,bosco_starblink[2];
static tilemap_t *bg_tilemap,*fg_tilemap;
#define VIDEO_RAM_SIZE 0x400 #define VIDEO_RAM_SIZE 0x400
UINT8 *bosco_videoram;
UINT8 *bosco_radarattr;
static UINT8 *bosco_radarx,*bosco_radary;
PALETTE_INIT( bosco ) PALETTE_INIT( bosco )
{ {
int i; int i;
@ -106,12 +93,14 @@ static TILEMAP_MAPPER( fg_tilemap_scan )
INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int ram_offs) INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int ram_offs)
{ {
UINT8 attr = bosco_videoram[ram_offs + tile_index + 0x800]; _galaga_state *state = (_galaga_state *) machine->driver_data;
UINT8 attr = state->videoram[ram_offs + tile_index + 0x800];
tileinfo->category = (attr & 0x20) >> 5; tileinfo->category = (attr & 0x20) >> 5;
tileinfo->group = attr & 0x3f; tileinfo->group = attr & 0x3f;
SET_TILE_INFO( SET_TILE_INFO(
0, 0,
bosco_videoram[ram_offs + tile_index], state->videoram[ram_offs + tile_index],
attr & 0x3f, attr & 0x3f,
TILE_FLIPYX(attr >> 6) ^ TILE_FLIPX); TILE_FLIPYX(attr >> 6) ^ TILE_FLIPX);
} }
@ -136,25 +125,25 @@ static TILE_GET_INFO( fg_get_tile_info )
VIDEO_START( bosco ) VIDEO_START( bosco )
{ {
bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan_rows,8,8,32,32); _galaga_state *state = (_galaga_state *) machine->driver_data;
fg_tilemap = tilemap_create(machine, fg_get_tile_info,fg_tilemap_scan, 8,8, 8,32);
colortable_configure_tilemap_groups(machine->colortable, bg_tilemap, machine->gfx[0], 0x1f); state->bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan_rows,8,8,32,32);
colortable_configure_tilemap_groups(machine->colortable, fg_tilemap, machine->gfx[0], 0x1f); state->fg_tilemap = tilemap_create(machine, fg_get_tile_info,fg_tilemap_scan, 8,8, 8,32);
tilemap_set_scrolldx(bg_tilemap,3,3); colortable_configure_tilemap_groups(machine->colortable, state->bg_tilemap, machine->gfx[0], 0x1f);
colortable_configure_tilemap_groups(machine->colortable, state->fg_tilemap, machine->gfx[0], 0x1f);
tilemap_set_scrolldx(state->bg_tilemap,3,3);
machine->generic.spriteram_size = 0x0c; machine->generic.spriteram_size = 0x0c;
machine->generic.spriteram.u8 = bosco_videoram + 0x03d4; machine->generic.spriteram.u8 = state->videoram + 0x03d4;
machine->generic.spriteram2.u8 = machine->generic.spriteram.u8 + 0x0800; machine->generic.spriteram2.u8 = machine->generic.spriteram.u8 + 0x0800;
bosco_radarx = bosco_videoram + 0x03f0; state->bosco_radarx = state->videoram + 0x03f0;
bosco_radary = bosco_radarx + 0x0800; state->bosco_radary = state->bosco_radarx + 0x0800;
state_save_register_global(machine, stars_scrollx); state_save_register_global(machine, state->stars_scrollx);
state_save_register_global(machine, stars_scrolly); state_save_register_global(machine, state->stars_scrolly);
state_save_register_global(machine, bosco_starcontrol);
state_save_register_global_array(machine, bosco_starblink);
} }
@ -165,38 +154,28 @@ VIDEO_START( bosco )
***************************************************************************/ ***************************************************************************/
READ8_HANDLER( bosco_videoram_r )
{
return bosco_videoram[offset];
}
WRITE8_HANDLER( bosco_videoram_w ) WRITE8_HANDLER( bosco_videoram_w )
{ {
bosco_videoram[offset] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
state->videoram[offset] = data;
if (offset & 0x400) if (offset & 0x400)
tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff); tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x3ff);
else else
tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff); tilemap_mark_tile_dirty(state->fg_tilemap,offset & 0x3ff);
} }
WRITE8_HANDLER( bosco_scrollx_w ) WRITE8_HANDLER( bosco_scrollx_w )
{ {
tilemap_set_scrollx(bg_tilemap,0,data); _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_set_scrollx(state->bg_tilemap,0,data);
} }
WRITE8_HANDLER( bosco_scrolly_w ) WRITE8_HANDLER( bosco_scrolly_w )
{ {
tilemap_set_scrolly(bg_tilemap,0,data); _galaga_state *state = (_galaga_state *) space->machine->driver_data;
} tilemap_set_scrolly(state->bg_tilemap,0,data);
WRITE8_HANDLER( bosco_starcontrol_w )
{
bosco_starcontrol = data;
}
WRITE8_HANDLER( bosco_starblink_w )
{
bosco_starblink[offset] = data & 1;
} }
WRITE8_HANDLER( bosco_starclr_w ) WRITE8_HANDLER( bosco_starclr_w )
@ -238,18 +217,19 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static void draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) static void draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
_galaga_state *state = (_galaga_state *) machine->driver_data;
int offs; int offs;
for (offs = 4; offs < 0x10;offs++) for (offs = 4; offs < 0x10;offs++)
{ {
int x,y; int x,y;
x = bosco_radarx[offs] + ((~bosco_radarattr[offs] & 0x01) << 8); x = state->bosco_radarx[offs] + ((~state->bosco_radarattr[offs] & 0x01) << 8);
y = 253 - bosco_radary[offs]; y = 253 - state->bosco_radary[offs];
if (flip_screen_get(machine)) x -= 3; if (flip_screen_get(machine)) x -= 3;
drawgfx_transmask(bitmap,cliprect,machine->gfx[2], drawgfx_transmask(bitmap,cliprect,machine->gfx[2],
((bosco_radarattr[offs] & 0x0e) >> 1) ^ 0x07, ((state->bosco_radarattr[offs] & 0x0e) >> 1) ^ 0x07,
0, 0,
0,0, 0,0,
x,y,0xf0); x,y,0xf0);
@ -257,16 +237,18 @@ static void draw_bullets(running_machine *machine, bitmap_t *bitmap, const recta
} }
static void draw_stars(bitmap_t *bitmap, const rectangle *cliprect, int flip) static void draw_stars(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int flip)
{ {
_galaga_state *state = (_galaga_state *) machine->driver_data;
if (1) if (1)
{ {
int star_cntr; int star_cntr;
int set_a, set_b; int set_a, set_b;
/* two sets of stars controlled by these bits */ /* two sets of stars controlled by these bits */
set_a = bosco_starblink[0]; set_a = state->bosco_starblink[0] & 0x01;
set_b = bosco_starblink[1] |0x2; set_b = (state->bosco_starblink[1] & 0x01) |0x2;
for (star_cntr = 0;star_cntr < MAX_STARS;star_cntr++) for (star_cntr = 0;star_cntr < MAX_STARS;star_cntr++)
{ {
@ -274,8 +256,8 @@ static void draw_stars(bitmap_t *bitmap, const rectangle *cliprect, int flip)
if ( (set_a == star_seed_tab[star_cntr].set) || ( set_b == star_seed_tab[star_cntr].set) ) if ( (set_a == star_seed_tab[star_cntr].set) || ( set_b == star_seed_tab[star_cntr].set) )
{ {
x = ( star_seed_tab[star_cntr].x + stars_scrollx) % 256; x = ( star_seed_tab[star_cntr].x + state->stars_scrollx) % 256;
y = ( star_seed_tab[star_cntr].y + stars_scrolly) % 256; y = ( star_seed_tab[star_cntr].y + state->stars_scrolly) % 256;
/* dont draw the stars that are off the screen */ /* dont draw the stars that are off the screen */
if ( x < 224 && y < 224 ) if ( x < 224 && y < 224 )
@ -293,6 +275,8 @@ static void draw_stars(bitmap_t *bitmap, const rectangle *cliprect, int flip)
VIDEO_UPDATE( bosco ) VIDEO_UPDATE( bosco )
{ {
_galaga_state *state = (_galaga_state *) screen->machine->driver_data;
/* the radar tilemap is just 8x32. We rely on the tilemap code to repeat it across /* the radar tilemap is just 8x32. We rely on the tilemap code to repeat it across
the screen, and clip it to only the position where it is supposed to be shown */ the screen, and clip it to only the position where it is supposed to be shown */
rectangle fg_clip = *cliprect; rectangle fg_clip = *cliprect;
@ -309,16 +293,16 @@ VIDEO_UPDATE( bosco )
} }
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
draw_stars(bitmap,cliprect,flip_screen_get(screen->machine)); draw_stars(screen->machine,bitmap,cliprect,flip_screen_get(screen->machine));
tilemap_draw(bitmap,&bg_clip,bg_tilemap,0,0); tilemap_draw(bitmap,&bg_clip,state->bg_tilemap,0,0);
tilemap_draw(bitmap,&fg_clip,fg_tilemap,0,0); tilemap_draw(bitmap,&fg_clip,state->fg_tilemap,0,0);
draw_sprites(screen->machine, bitmap,cliprect); draw_sprites(screen->machine, bitmap,cliprect);
/* draw the high priority characters */ /* draw the high priority characters */
tilemap_draw(bitmap,&bg_clip,bg_tilemap,1,0); tilemap_draw(bitmap,&bg_clip,state->bg_tilemap,1,0);
tilemap_draw(bitmap,&fg_clip,fg_tilemap,1,0); tilemap_draw(bitmap,&fg_clip,state->fg_tilemap,1,0);
draw_bullets(screen->machine, bitmap,cliprect); draw_bullets(screen->machine, bitmap,cliprect);
@ -328,9 +312,10 @@ VIDEO_UPDATE( bosco )
VIDEO_EOF( bosco ) VIDEO_EOF( bosco )
{ {
_galaga_state *state = (_galaga_state *) machine->driver_data;
static const int speedsx[8] = { -1, -2, -3, 0, 3, 2, 1, 0 }; static const int speedsx[8] = { -1, -2, -3, 0, 3, 2, 1, 0 };
static const int speedsy[8] = { 0, -1, -2, -3, 0, 3, 2, 1 }; static const int speedsy[8] = { 0, -1, -2, -3, 0, 3, 2, 1 };
stars_scrollx += speedsx[bosco_starcontrol & 0x07]; state->stars_scrollx += speedsx[state->bosco_starcontrol[0] & 0x07];
stars_scrolly += speedsy[(bosco_starcontrol & 0x38) >> 3]; state->stars_scrolly += speedsy[(state->bosco_starcontrol[0] & 0x38) >> 3];
} }

View File

@ -2,14 +2,6 @@
#include "includes/galaga.h" #include "includes/galaga.h"
UINT8 *digdug_videoram,*digdug_objram, *digdug_posram, *digdug_flpram;
static tilemap_t *bg_tilemap,*tx_tilemap;
static INT32 bg_select, tx_color_mode, bg_disable, bg_color_bank;
/*************************************************************************** /***************************************************************************
Convert the color PROMs. Convert the color PROMs.
@ -98,23 +90,26 @@ static TILEMAP_MAPPER( tilemap_scan )
static TILE_GET_INFO( bg_get_tile_info ) static TILE_GET_INFO( bg_get_tile_info )
{ {
UINT8 *rom = memory_region(machine, "gfx4"); UINT8 *rom = memory_region(machine, "gfx4");
int code = rom[tile_index | (bg_select << 10)]; _galaga_state *state = (_galaga_state *) machine->driver_data;
int code = rom[tile_index | (state->bg_select << 10)];
/* when the background is "disabled", it is actually still drawn, but using /* when the background is "disabled", it is actually still drawn, but using
a color code that makes all pixels black. There are pullups setting the a color code that makes all pixels black. There are pullups setting the
code to 0xf, but also solder pads that optionally connect the lines with code to 0xf, but also solder pads that optionally connect the lines with
tilemap RAM, therefore allowing to pick some bits of the color code from tilemap RAM, therefore allowing to pick some bits of the color code from
the top 4 bits of alpha code. This feature is not used by Dig Dug. */ the top 4 bits of alpha code. This feature is not used by Dig Dug. */
int color = bg_disable ? 0xf : (code >> 4); int color = state->bg_disable ? 0xf : (code >> 4);
SET_TILE_INFO( SET_TILE_INFO(
2, 2,
code, code,
color | bg_color_bank, color | state->bg_color_bank,
0); 0);
} }
static TILE_GET_INFO( tx_get_tile_info ) static TILE_GET_INFO( tx_get_tile_info )
{ {
UINT8 code = digdug_videoram[tile_index]; _galaga_state *state = (_galaga_state *) machine->driver_data;
UINT8 code = state->videoram[tile_index];
int color; int color;
/* the hardware has two ways to pick the color, either straight from the /* the hardware has two ways to pick the color, either straight from the
@ -122,7 +117,7 @@ static TILE_GET_INFO( tx_get_tile_info )
formula. The former method isnot used by Dig Dug and seems kind of formula. The former method isnot used by Dig Dug and seems kind of
useless (I don't know what use they were thinking of when they added useless (I don't know what use they were thinking of when they added
it), anyway here it is reproduced faithfully. */ it), anyway here it is reproduced faithfully. */
if (tx_color_mode) if (state->tx_color_mode)
color = code & 0x0f; color = code & 0x0f;
else else
color = ((code >> 4) & 0x0e) | ((code >> 3) & 2); color = ((code >> 4) & 0x0e) | ((code >> 3) & 2);
@ -149,15 +144,17 @@ static TILE_GET_INFO( tx_get_tile_info )
VIDEO_START( digdug ) VIDEO_START( digdug )
{ {
bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan, 8,8,36,28); _galaga_state *state = (_galaga_state *) machine->driver_data;
tx_tilemap = tilemap_create(machine, tx_get_tile_info,tilemap_scan,8,8,36,28);
tilemap_set_transparent_pen(tx_tilemap, 0); state->bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan, 8,8,36,28);
state->fg_tilemap = tilemap_create(machine, tx_get_tile_info,tilemap_scan,8,8,36,28);
state_save_register_global(machine, bg_select); tilemap_set_transparent_pen(state->fg_tilemap, 0);
state_save_register_global(machine, tx_color_mode);
state_save_register_global(machine, bg_disable); state_save_register_global(machine, state->bg_select);
state_save_register_global(machine, bg_color_bank); state_save_register_global(machine, state->tx_color_mode);
state_save_register_global(machine, state->bg_disable);
state_save_register_global(machine, state->bg_color_bank);
} }
@ -168,19 +165,18 @@ VIDEO_START( digdug )
***************************************************************************/ ***************************************************************************/
READ8_HANDLER( digdug_videoram_r )
{
return digdug_videoram[offset];
}
WRITE8_HANDLER( digdug_videoram_w ) WRITE8_HANDLER( digdug_videoram_w )
{ {
digdug_videoram[offset] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_mark_tile_dirty(tx_tilemap,offset & 0x3ff);
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap,offset & 0x3ff);
} }
WRITE8_HANDLER( digdug_PORT_w ) WRITE8_HANDLER( digdug_PORT_w )
{ {
_galaga_state *state = (_galaga_state *) space->machine->driver_data;
switch (offset) switch (offset)
{ {
case 0: /* select background picture */ case 0: /* select background picture */
@ -189,27 +185,27 @@ WRITE8_HANDLER( digdug_PORT_w )
int shift = offset; int shift = offset;
int mask = 1 << shift; int mask = 1 << shift;
if ((bg_select & mask) != ((data & 1) << shift)) if ((state->bg_select & mask) != ((data & 1) << shift))
{ {
bg_select = (bg_select & ~mask) | ((data & 1) << shift); state->bg_select = (state->bg_select & ~mask) | ((data & 1) << shift);
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
} }
} }
break; break;
case 2: /* select alpha layer color mode (see tx_get_tile_info) */ case 2: /* select alpha layer color mode (see tx_get_tile_info) */
if (tx_color_mode != (data & 1)) if (state->tx_color_mode != (data & 1))
{ {
tx_color_mode = data & 1; state->tx_color_mode = data & 1;
tilemap_mark_all_tiles_dirty(tx_tilemap); tilemap_mark_all_tiles_dirty(state->fg_tilemap);
} }
break; break;
case 3: /* "disable" background (see bg_get_tile_info) */ case 3: /* "disable" background (see bg_get_tile_info) */
if (bg_disable != (data & 1)) if (state->bg_disable != (data & 1))
{ {
bg_disable = data & 1; state->bg_disable = data & 1;
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
} }
break; break;
@ -219,10 +215,10 @@ WRITE8_HANDLER( digdug_PORT_w )
int shift = offset; int shift = offset;
int mask = 1 << shift; int mask = 1 << shift;
if ((bg_color_bank & mask) != ((data & 1) << shift)) if ((state->bg_color_bank & mask) != ((data & 1) << shift))
{ {
bg_color_bank = (bg_color_bank & ~mask) | ((data & 1) << shift); state->bg_color_bank = (state->bg_color_bank & ~mask) | ((data & 1) << shift);
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
} }
} }
break; break;
@ -252,9 +248,10 @@ static const rectangle spritevisiblearea =
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 )
{ {
UINT8 *spriteram = digdug_objram + 0x380; _galaga_state *state = (_galaga_state *) machine->driver_data;
UINT8 *spriteram_2 = digdug_posram + 0x380; UINT8 *spriteram = state->digdug_objram + 0x380;
UINT8 *spriteram_3 = digdug_flpram + 0x380; UINT8 *spriteram_2 = state->digdug_posram + 0x380;
UINT8 *spriteram_3 = state->digdug_flpram + 0x380;
int offs; int offs;
for (offs = 0;offs < 0x80;offs += 2) for (offs = 0;offs < 0x80;offs += 2)
@ -310,8 +307,10 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( digdug ) VIDEO_UPDATE( digdug )
{ {
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); _galaga_state *state = (_galaga_state *) screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,tx_tilemap,0,0);
tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
draw_sprites(screen->machine,bitmap,cliprect); draw_sprites(screen->machine,bitmap,cliprect);
return 0; return 0;
} }

View File

@ -13,15 +13,6 @@
#define MAX_STARS 252 #define MAX_STARS 252
#define STARS_COLOR_BASE (64*4+64*4) #define STARS_COLOR_BASE (64*4+64*4)
UINT8 *galaga_videoram;
UINT8 *galaga_ram1,*galaga_ram2,*galaga_ram3;
UINT8 galaga_starcontrol[6];
static UINT32 stars_scrollx,stars_scrolly;
static INT32 galaga_gfxbank; // used by catsbee
static tilemap_t *tx_tilemap;
/* /*
Galaga star line and pixel locations pulled directly from Galaga star line and pixel locations pulled directly from
a clocked stepping of the 05 starfield. The chip was clocked a clocked stepping of the 05 starfield. The chip was clocked
@ -421,10 +412,11 @@ static TILE_GET_INFO( get_tile_info )
timing signals, while x flip is done by selecting the 2nd character set. timing signals, while x flip is done by selecting the 2nd character set.
We reproduce this here, but since the tilemap system automatically flips We reproduce this here, but since the tilemap system automatically flips
characters when screen is flipped, we have to flip them back. */ characters when screen is flipped, we have to flip them back. */
int color = galaga_videoram[tile_index + 0x400] & 0x3f; _galaga_state *state = (_galaga_state *) machine->driver_data;
int color = state->videoram[tile_index + 0x400] & 0x3f;
SET_TILE_INFO( SET_TILE_INFO(
0, 0,
(galaga_videoram[tile_index] & 0x7f) | (flip_screen_get(machine) ? 0x80 : 0) | (galaga_gfxbank << 8), (state->videoram[tile_index] & 0x7f) | (flip_screen_get(machine) ? 0x80 : 0) | (state->galaga_gfxbank << 8),
color, color,
flip_screen_get(machine) ? TILE_FLIPX : 0); flip_screen_get(machine) ? TILE_FLIPX : 0);
tileinfo->group = color; tileinfo->group = color;
@ -440,15 +432,15 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( galaga ) VIDEO_START( galaga )
{ {
tx_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan,8,8,36,28); _galaga_state *state = (_galaga_state *) machine->driver_data;
colortable_configure_tilemap_groups(machine->colortable, tx_tilemap, machine->gfx[0], 0x1f); state->fg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan,8,8,36,28);
colortable_configure_tilemap_groups(machine->colortable, state->fg_tilemap, machine->gfx[0], 0x1f);
galaga_gfxbank = 0; state->galaga_gfxbank = 0;
state_save_register_global_array(machine, galaga_starcontrol); state_save_register_global(machine, state->stars_scrollx);
state_save_register_global(machine, stars_scrollx); state_save_register_global(machine, state->stars_scrolly);
state_save_register_global(machine, stars_scrolly); state_save_register_global(machine, state->galaga_gfxbank);
state_save_register_global(machine, galaga_gfxbank);
} }
@ -459,26 +451,21 @@ VIDEO_START( galaga )
***************************************************************************/ ***************************************************************************/
READ8_HANDLER( galaga_videoram_r )
{
return galaga_videoram[offset];
}
WRITE8_HANDLER( galaga_videoram_w ) WRITE8_HANDLER( galaga_videoram_w )
{ {
galaga_videoram[offset] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_mark_tile_dirty(tx_tilemap,offset & 0x3ff);
}
WRITE8_HANDLER( galaga_starcontrol_w ) state->videoram[offset] = data;
{ tilemap_mark_tile_dirty(state->fg_tilemap,offset & 0x3ff);
galaga_starcontrol[offset] = data & 1;
} }
WRITE8_HANDLER ( gatsbee_bank_w ) WRITE8_HANDLER ( gatsbee_bank_w )
{ {
galaga_gfxbank = data & 0x1; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_mark_all_tiles_dirty(tx_tilemap);
state->galaga_gfxbank = data & 0x1;
tilemap_mark_all_tiles_dirty(state->fg_tilemap);
} }
@ -491,9 +478,11 @@ WRITE8_HANDLER ( gatsbee_bank_w )
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 )
{ {
UINT8 *spriteram = galaga_ram1 + 0x380; _galaga_state *state = (_galaga_state *) machine->driver_data;
UINT8 *spriteram_2 = galaga_ram2 + 0x380;
UINT8 *spriteram_3 = galaga_ram3 + 0x380; UINT8 *spriteram = state->galaga_ram1 + 0x380;
UINT8 *spriteram_2 = state->galaga_ram2 + 0x380;
UINT8 *spriteram_3 = state->galaga_ram3 + 0x380;
int offs; int offs;
@ -540,22 +529,23 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
} }
static void draw_stars(bitmap_t *bitmap, const rectangle *cliprect ) static void draw_stars(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
_galaga_state *state = (_galaga_state *) machine->driver_data;
/* draw the stars */ /* draw the stars */
/* $a005 controls the stars ON/OFF */ /* $a005 controls the stars ON/OFF */
if ( galaga_starcontrol[5] == 1 ) if ( (state->galaga_starcontrol[5] & 1) == 1 )
{ {
int star_cntr; int star_cntr;
int set_a, set_b; int set_a, set_b;
/* two sets of stars controlled by these bits */ /* two sets of stars controlled by these bits */
set_a = galaga_starcontrol[3]; set_a = (state->galaga_starcontrol[3] & 1);
set_b = galaga_starcontrol[4] | 0x2; set_b = (state->galaga_starcontrol[4] & 1) | 0x2;
for (star_cntr = 0;star_cntr < MAX_STARS ;star_cntr++) for (star_cntr = 0;star_cntr < MAX_STARS ;star_cntr++)
@ -564,8 +554,8 @@ static void draw_stars(bitmap_t *bitmap, const rectangle *cliprect )
if ( (set_a == star_seed_tab[star_cntr].set) || ( set_b == star_seed_tab[star_cntr].set) ) if ( (set_a == star_seed_tab[star_cntr].set) || ( set_b == star_seed_tab[star_cntr].set) )
{ {
x = (star_seed_tab[star_cntr].x + stars_scrollx) % 256 + 16; x = (star_seed_tab[star_cntr].x + state->stars_scrollx) % 256 + 16;
y = (112 + star_seed_tab[star_cntr].y + stars_scrolly) % 256; y = (112 + star_seed_tab[star_cntr].y + state->stars_scrolly) % 256;
/* 112 is a tweak to get alignment about perfect */ /* 112 is a tweak to get alignment about perfect */
if (y >= cliprect->min_y && y <= cliprect->max_y) if (y >= cliprect->min_y && y <= cliprect->max_y)
@ -578,10 +568,12 @@ static void draw_stars(bitmap_t *bitmap, const rectangle *cliprect )
VIDEO_UPDATE( galaga ) VIDEO_UPDATE( galaga )
{ {
_galaga_state *state = (_galaga_state *) screen->machine->driver_data;
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
draw_stars(bitmap,cliprect); draw_stars(screen->machine,bitmap,cliprect);
draw_sprites(screen->machine,bitmap,cliprect); draw_sprites(screen->machine,bitmap,cliprect);
tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
return 0; return 0;
} }
@ -589,16 +581,17 @@ VIDEO_UPDATE( galaga )
VIDEO_EOF( galaga ) VIDEO_EOF( galaga )
{ {
_galaga_state *state = (_galaga_state *) machine->driver_data;
/* this function is called by galaga_interrupt_1() */ /* this function is called by galaga_interrupt_1() */
int s0,s1,s2; int s0,s1,s2;
static const int speeds[8] = { -1, -2, -3, 0, 3, 2, 1, 0 }; static const int speeds[8] = { -1, -2, -3, 0, 3, 2, 1, 0 };
s0 = galaga_starcontrol[0]; s0 = (state->galaga_starcontrol[0] & 1);
s1 = galaga_starcontrol[1]; s1 = (state->galaga_starcontrol[1] & 1);
s2 = galaga_starcontrol[2]; s2 = (state->galaga_starcontrol[2] & 1);
stars_scrollx += speeds[s0 + s1*2 + s2*4]; state->stars_scrollx += speeds[s0 + s1*2 + s2*4];
} }

View File

@ -9,14 +9,6 @@
#include "emu.h" #include "emu.h"
#include "includes/galaga.h" #include "includes/galaga.h"
UINT8 *xevious_fg_videoram,*xevious_fg_colorram;
UINT8 *xevious_bg_videoram,*xevious_bg_colorram;
UINT8 *xevious_sr1,*xevious_sr2,*xevious_sr3;
static tilemap_t *fg_tilemap,*bg_tilemap;
static INT32 xevious_bs[2];
/*************************************************************************** /***************************************************************************
Convert the color PROMs into a more useable format. Convert the color PROMs into a more useable format.
@ -184,7 +176,9 @@ PALETTE_INIT( battles )
static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_fg_tile_info )
{ {
UINT8 attr = xevious_fg_colorram[tile_index]; _galaga_state *state = (_galaga_state *) machine->driver_data;
UINT8 attr = state->xevious_fg_colorram[tile_index];
/* the hardware has two character sets, one normal and one x-flipped. When /* the hardware has two character sets, one normal and one x-flipped. When
screen is flipped, character y flip is done by the hardware inverting the screen is flipped, character y flip is done by the hardware inverting the
@ -194,15 +188,17 @@ static TILE_GET_INFO( get_fg_tile_info )
UINT8 color = ((attr & 0x03) << 4) | ((attr & 0x3c) >> 2); UINT8 color = ((attr & 0x03) << 4) | ((attr & 0x3c) >> 2);
SET_TILE_INFO( SET_TILE_INFO(
0, 0,
xevious_fg_videoram[tile_index] | (flip_screen_get(machine) ? 0x100 : 0), state->xevious_fg_videoram[tile_index] | (flip_screen_get(machine) ? 0x100 : 0),
color, color,
TILE_FLIPYX((attr & 0xc0) >> 6) ^ (flip_screen_get(machine) ? TILE_FLIPX : 0)); TILE_FLIPYX((attr & 0xc0) >> 6) ^ (flip_screen_get(machine) ? TILE_FLIPX : 0));
} }
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
UINT8 code = xevious_bg_videoram[tile_index]; _galaga_state *state = (_galaga_state *) machine->driver_data;
UINT8 attr = xevious_bg_colorram[tile_index];
UINT8 code = state->xevious_bg_videoram[tile_index];
UINT8 attr = state->xevious_bg_colorram[tile_index];
UINT8 color = ((attr & 0x3c) >> 2) | ((code & 0x80) >> 3) | ((attr & 0x03) << 5); UINT8 color = ((attr & 0x3c) >> 2) | ((code & 0x80) >> 3) | ((attr & 0x03) << 5);
SET_TILE_INFO( SET_TILE_INFO(
1, 1,
@ -221,16 +217,20 @@ static TILE_GET_INFO( get_bg_tile_info )
VIDEO_START( xevious ) VIDEO_START( xevious )
{ {
bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows, 8,8,64,32); _galaga_state *state = (_galaga_state *) machine->driver_data;
fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,64,32);
tilemap_set_scrolldx(bg_tilemap,-20,288+27); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows, 8,8,64,32);
tilemap_set_scrolldy(bg_tilemap,-16,-16); state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,64,32);
tilemap_set_scrolldx(fg_tilemap,-32,288+32);
tilemap_set_scrolldy(fg_tilemap,-18,-10);
tilemap_set_transparent_pen(fg_tilemap,0);
state_save_register_global_array(machine, xevious_bs); tilemap_set_scrolldx(state->bg_tilemap,-20,288+27);
tilemap_set_scrolldy(state->bg_tilemap,-16,-16);
tilemap_set_scrolldx(state->fg_tilemap,-32,288+32);
tilemap_set_scrolldy(state->fg_tilemap,-18,-10);
tilemap_set_transparent_pen(state->fg_tilemap,0);
state->xevious_bs[0] = 0;
state->xevious_bs[1] = 0;
state_save_register_global_array(machine, state->xevious_bs);
} }
@ -241,52 +241,42 @@ VIDEO_START( xevious )
***************************************************************************/ ***************************************************************************/
READ8_HANDLER( xevious_fg_videoram_r )
{
return xevious_fg_videoram[offset];
}
READ8_HANDLER( xevious_fg_colorram_r )
{
return xevious_fg_colorram[offset];
}
READ8_HANDLER( xevious_bg_videoram_r )
{
return xevious_bg_videoram[offset];
}
READ8_HANDLER( xevious_bg_colorram_r )
{
return xevious_bg_colorram[offset];
}
WRITE8_HANDLER( xevious_fg_videoram_w ) WRITE8_HANDLER( xevious_fg_videoram_w )
{ {
xevious_fg_videoram[offset] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_mark_tile_dirty(fg_tilemap,offset);
state->xevious_fg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap,offset);
} }
WRITE8_HANDLER( xevious_fg_colorram_w ) WRITE8_HANDLER( xevious_fg_colorram_w )
{ {
xevious_fg_colorram[offset] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_mark_tile_dirty(fg_tilemap,offset);
state->xevious_fg_colorram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap,offset);
} }
WRITE8_HANDLER( xevious_bg_videoram_w ) WRITE8_HANDLER( xevious_bg_videoram_w )
{ {
xevious_bg_videoram[offset] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
state->xevious_bg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset);
} }
WRITE8_HANDLER( xevious_bg_colorram_w ) WRITE8_HANDLER( xevious_bg_colorram_w )
{ {
xevious_bg_colorram[offset] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
state->xevious_bg_colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset);
} }
WRITE8_HANDLER( xevious_vh_latch_w ) WRITE8_HANDLER( xevious_vh_latch_w )
{ {
_galaga_state *state = (_galaga_state *) space->machine->driver_data;
int reg; int reg;
int scroll = data + ((offset&0x01)<<8); /* A0 -> D8 */ int scroll = data + ((offset&0x01)<<8); /* A0 -> D8 */
@ -295,16 +285,16 @@ WRITE8_HANDLER( xevious_vh_latch_w )
switch (reg) switch (reg)
{ {
case 0: case 0:
tilemap_set_scrollx(bg_tilemap,0,scroll); tilemap_set_scrollx(state->bg_tilemap,0,scroll);
break; break;
case 1: case 1:
tilemap_set_scrollx(fg_tilemap,0,scroll); tilemap_set_scrollx(state->fg_tilemap,0,scroll);
break; break;
case 2: case 2:
tilemap_set_scrolly(bg_tilemap,0,scroll); tilemap_set_scrolly(state->bg_tilemap,0,scroll);
break; break;
case 3: case 3:
tilemap_set_scrolly(fg_tilemap,0,scroll); tilemap_set_scrolly(state->fg_tilemap,0,scroll);
break; break;
case 7: case 7:
flip_screen_set(space->machine, scroll & 1); flip_screen_set(space->machine, scroll & 1);
@ -319,11 +309,15 @@ WRITE8_HANDLER( xevious_vh_latch_w )
/* emulation for schematic 9B */ /* emulation for schematic 9B */
WRITE8_HANDLER( xevious_bs_w ) WRITE8_HANDLER( xevious_bs_w )
{ {
xevious_bs[offset & 1] = data; _galaga_state *state = (_galaga_state *) space->machine->driver_data;
state->xevious_bs[offset & 1] = data;
} }
READ8_HANDLER( xevious_bb_r ) READ8_HANDLER( xevious_bb_r )
{ {
_galaga_state *state = (_galaga_state *) space->machine->driver_data;
UINT8 *rom2a = memory_region(space->machine, "gfx4"); UINT8 *rom2a = memory_region(space->machine, "gfx4");
UINT8 *rom2b = rom2a+0x1000; UINT8 *rom2b = rom2a+0x1000;
UINT8 *rom2c = rom2a+0x3000; UINT8 *rom2c = rom2a+0x3000;
@ -331,7 +325,7 @@ READ8_HANDLER( xevious_bb_r )
int dat1,dat2; int dat1,dat2;
/* get BS to 12 bit data from 2A,2B */ /* get BS to 12 bit data from 2A,2B */
adr_2b = ((xevious_bs[1] & 0x7e) << 6) | ((xevious_bs[0] & 0xfe) >> 1); adr_2b = ((state->xevious_bs[1] & 0x7e) << 6) | ((state->xevious_bs[0] & 0xfe) >> 1);
if (adr_2b & 1) if (adr_2b & 1)
{ {
@ -344,7 +338,7 @@ READ8_HANDLER( xevious_bb_r )
dat1 = ((rom2a[adr_2b >> 1] & 0x0f) << 8) | rom2b[adr_2b]; dat1 = ((rom2a[adr_2b >> 1] & 0x0f) << 8) | rom2b[adr_2b];
} }
adr_2c = ((dat1 & 0x1ff) << 2) | ((xevious_bs[1] & 1) << 1) | (xevious_bs[0] & 1); adr_2c = ((dat1 & 0x1ff) << 2) | ((state->xevious_bs[1] & 1) << 1) | (state->xevious_bs[0] & 1);
if (dat1 & 0x400) adr_2c ^= 1; if (dat1 & 0x400) adr_2c ^= 1;
if (dat1 & 0x200) adr_2c ^= 2; if (dat1 & 0x200) adr_2c ^= 2;
@ -422,9 +416,11 @@ ROM 3M,3L color replace table for sprite
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)
{ {
UINT8 *spriteram = xevious_sr3 + 0x780; _galaga_state *state = (_galaga_state *) machine->driver_data;
UINT8 *spriteram_2 = xevious_sr1 + 0x780;
UINT8 *spriteram_3 = xevious_sr2 + 0x780; UINT8 *spriteram = state->xevious_sr3 + 0x780;
UINT8 *spriteram_2 = state->xevious_sr1 + 0x780;
UINT8 *spriteram_3 = state->xevious_sr2 + 0x780;
int offs,sx,sy; int offs,sx,sy;
for (offs = 0;offs < 0x80;offs += 2) for (offs = 0;offs < 0x80;offs += 2)
@ -503,8 +499,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
VIDEO_UPDATE( xevious ) VIDEO_UPDATE( xevious )
{ {
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); _galaga_state *state = (_galaga_state *) screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
draw_sprites(screen->machine, bitmap,cliprect); draw_sprites(screen->machine, bitmap,cliprect);
tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
return 0; return 0;
} }