Added save state support to marineb.c

Added driver data struct to espial.c, marineb.c & zodiack.c
This commit is contained in:
Fabio Priuli 2009-11-17 18:51:55 +00:00
parent 112a759ceb
commit 2548154f87
7 changed files with 319 additions and 264 deletions

View File

@ -14,8 +14,6 @@ Espial: The Orca logo is displayed, but looks to be "blacked out" via the
#include "sound/ay8910.h"
static UINT8 sound_nmi_enabled;
static TIMER_CALLBACK( interrupt_disable )
{
//interrupt_enable = 0;
@ -24,33 +22,42 @@ static TIMER_CALLBACK( interrupt_disable )
MACHINE_RESET( espial )
{
espial_state *state = (espial_state *)machine->driver_data;
state->flipscreen = 0;
/* we must start with NMI interrupts disabled */
timer_call_after_resynch(machine, NULL, 0, interrupt_disable);
sound_nmi_enabled = FALSE;
state->sound_nmi_enabled = FALSE;
}
MACHINE_START( espial )
{
espial_state *state = (espial_state *)machine->driver_data;
//state_save_register_global_array(machine, mcu_out[1]);
state_save_register_global(machine, sound_nmi_enabled);
state_save_register_global(machine, state->sound_nmi_enabled);
}
WRITE8_HANDLER( zodiac_master_interrupt_enable_w )
{
interrupt_enable_w(space,offset,~data & 1);
interrupt_enable_w(space, offset, ~data & 1);
}
WRITE8_HANDLER( espial_sound_nmi_enable_w )
{
sound_nmi_enabled = data & 1;
espial_state *state = (espial_state *)space->machine->driver_data;
state->sound_nmi_enabled = data & 1;
}
INTERRUPT_GEN( espial_sound_nmi_gen )
{
if (sound_nmi_enabled)
espial_state *state = (espial_state *)device->machine->driver_data;
if (state->sound_nmi_enabled)
nmi_line_pulse(device);
}
@ -82,14 +89,14 @@ static ADDRESS_MAP_START( espial_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x7000, 0x7000) AM_READWRITE(watchdog_reset_r, watchdog_reset_w)
AM_RANGE(0x7100, 0x7100) AM_WRITE(zodiac_master_interrupt_enable_w)
AM_RANGE(0x7200, 0x7200) AM_WRITE(espial_flipscreen_w)
AM_RANGE(0x8000, 0x801f) AM_RAM AM_BASE(&espial_spriteram_1)
AM_RANGE(0x8000, 0x801f) AM_RAM AM_BASE_MEMBER(espial_state, spriteram_1)
AM_RANGE(0x8020, 0x803f) AM_READ(SMH_RAM)
AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(espial_videoram_w) AM_BASE(&espial_videoram)
AM_RANGE(0x8800, 0x880f) AM_WRITE(SMH_RAM) AM_BASE(&espial_spriteram_3)
AM_RANGE(0x8c00, 0x8fff) AM_RAM_WRITE(espial_attributeram_w) AM_BASE(&espial_attributeram)
AM_RANGE(0x9000, 0x901f) AM_RAM AM_BASE(&espial_spriteram_2)
AM_RANGE(0x9020, 0x903f) AM_RAM_WRITE(espial_scrollram_w) AM_BASE(&espial_scrollram)
AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(espial_colorram_w) AM_BASE(&espial_colorram)
AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(espial_videoram_w) AM_BASE_MEMBER(espial_state, videoram)
AM_RANGE(0x8800, 0x880f) AM_WRITE(SMH_RAM) AM_BASE_MEMBER(espial_state, spriteram_3)
AM_RANGE(0x8c00, 0x8fff) AM_RAM_WRITE(espial_attributeram_w) AM_BASE_MEMBER(espial_state, attributeram)
AM_RANGE(0x9000, 0x901f) AM_RAM AM_BASE_MEMBER(espial_state, spriteram_2)
AM_RANGE(0x9020, 0x903f) AM_RAM_WRITE(espial_scrollram_w) AM_BASE_MEMBER(espial_state, scrollram)
AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(espial_colorram_w) AM_BASE_MEMBER(espial_state, colorram)
AM_RANGE(0xc000, 0xcfff) AM_ROM
ADDRESS_MAP_END
@ -107,13 +114,13 @@ static ADDRESS_MAP_START( netwars_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x7000, 0x7000) AM_READWRITE(watchdog_reset_r, watchdog_reset_w)
AM_RANGE(0x7100, 0x7100) AM_WRITE(zodiac_master_interrupt_enable_w)
AM_RANGE(0x7200, 0x7200) AM_WRITE(espial_flipscreen_w)
AM_RANGE(0x8000, 0x801f) AM_RAM AM_BASE(&espial_spriteram_1)
AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(espial_videoram_w) AM_BASE(&espial_videoram)
AM_RANGE(0x8800, 0x880f) AM_RAM AM_BASE(&espial_spriteram_3)
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(espial_attributeram_w) AM_BASE(&espial_attributeram)
AM_RANGE(0x9000, 0x901f) AM_RAM AM_BASE(&espial_spriteram_2)
AM_RANGE(0x9020, 0x903f) AM_RAM_WRITE(espial_scrollram_w) AM_BASE(&espial_scrollram)
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(espial_colorram_w) AM_BASE(&espial_colorram)
AM_RANGE(0x8000, 0x801f) AM_RAM AM_BASE_MEMBER(espial_state, spriteram_1)
AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(espial_videoram_w) AM_BASE_MEMBER(espial_state, videoram)
AM_RANGE(0x8800, 0x880f) AM_RAM AM_BASE_MEMBER(espial_state, spriteram_3)
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(espial_attributeram_w) AM_BASE_MEMBER(espial_state, attributeram)
AM_RANGE(0x9000, 0x901f) AM_RAM AM_BASE_MEMBER(espial_state, spriteram_2)
AM_RANGE(0x9020, 0x903f) AM_RAM_WRITE(espial_scrollram_w) AM_BASE_MEMBER(espial_state, scrollram)
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(espial_colorram_w) AM_BASE_MEMBER(espial_state, colorram)
ADDRESS_MAP_END
@ -291,6 +298,9 @@ GFXDECODE_END
static MACHINE_DRIVER_START( espial )
/* driver data */
MDRV_DRIVER_DATA(espial_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 3072000) /* 3.072 MHz */
MDRV_CPU_PROGRAM_MAP(espial_map)

View File

@ -43,22 +43,41 @@ write
static MACHINE_RESET( marineb )
{
marineb_active_low_flipscreen = 0;
espial_state *state = (espial_state *)machine->driver_data;
state->palette_bank = 0;
state->column_scroll = 0;
state->flipscreen_x = 0;
state->flipscreen_y = 0;
state->marineb_active_low_flipscreen = 0;
MACHINE_RESET_CALL(espial);
}
static MACHINE_RESET( springer )
{
marineb_active_low_flipscreen = 1;
espial_state *state = (espial_state *)machine->driver_data;
state->palette_bank = 0;
state->column_scroll = 0;
state->flipscreen_x = 0;
state->flipscreen_y = 0;
state->marineb_active_low_flipscreen = 1;
MACHINE_RESET_CALL(espial);
}
static MACHINE_START( marineb )
{
espial_state *state = (espial_state *)machine->driver_data;
state_save_register_global(machine, state->marineb_active_low_flipscreen);
}
static ADDRESS_MAP_START( marineb_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(marineb_videoram_w) AM_BASE(&marineb_videoram)
AM_RANGE(0x8c00, 0x8c3f) AM_RAM AM_BASE(&spriteram) /* Hoccer only */
AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(marineb_colorram_w) AM_BASE(&marineb_colorram)
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(marineb_videoram_w) AM_BASE_MEMBER(espial_state, videoram)
AM_RANGE(0x8c00, 0x8c3f) AM_RAM AM_BASE_MEMBER(espial_state, spriteram) /* Hoccer only */
AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(marineb_colorram_w) AM_BASE_MEMBER(espial_state, colorram)
AM_RANGE(0x9800, 0x9800) AM_WRITE(marineb_column_scroll_w)
AM_RANGE(0x9a00, 0x9a00) AM_WRITE(marineb_palette_bank_0_w)
AM_RANGE(0x9c00, 0x9c00) AM_WRITE(marineb_palette_bank_1_w)
@ -505,12 +524,16 @@ GFXDECODE_END
static MACHINE_DRIVER_START( marineb )
/* driver data */
MDRV_DRIVER_DATA(espial_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 3072000) /* 3.072 MHz */
MDRV_CPU_PROGRAM_MAP(marineb_map)
MDRV_CPU_IO_MAP(marineb_io_map)
MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse)
MDRV_MACHINE_START(marineb)
MDRV_MACHINE_RESET(marineb)
/* video hardware */

View File

@ -85,18 +85,27 @@ TODO:
#include "includes/espial.h"
int percuss_hardware;
static MACHINE_START( zodiack )
{
espial_state *state = (espial_state *)machine->driver_data;
state_save_register_global(machine, state->percuss_hardware);
MACHINE_START_CALL(espial);
}
static MACHINE_RESET( zodiack )
{
percuss_hardware = 0;
espial_state *state = (espial_state *)machine->driver_data;
state->percuss_hardware = 0;
MACHINE_RESET_CALL(espial);
}
static MACHINE_RESET( percuss )
{
percuss_hardware = 1;
espial_state *state = (espial_state *)machine->driver_data;
state->percuss_hardware = 1;
MACHINE_RESET_CALL(espial);
}
@ -122,12 +131,12 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x7000, 0x7000) AM_READWRITE(SMH_NOP,watchdog_reset_w) /* NOP??? */
AM_RANGE(0x7100, 0x7100) AM_WRITE(zodiac_master_interrupt_enable_w)
AM_RANGE(0x7200, 0x7200) AM_WRITE(zodiack_flipscreen_w)
AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(zodiack_attributes_w) AM_BASE(&zodiack_attributesram)
AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE(&zodiack_bulletsram) AM_SIZE(&zodiack_bulletsram_size)
AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(zodiack_attributes_w) AM_BASE_MEMBER(espial_state, attributeram)
AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE_MEMBER(espial_state, spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE_MEMBER(espial_state, bulletsram) AM_SIZE(&zodiack_bulletsram_size)
AM_RANGE(0x9080, 0x93ff) AM_RAM
AM_RANGE(0xa000, 0xa3ff) AM_RAM_WRITE(zodiack_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
AM_RANGE(0xb000, 0xb3ff) AM_RAM_WRITE(zodiack_videoram2_w) AM_BASE(&zodiack_videoram2)
AM_RANGE(0xa000, 0xa3ff) AM_RAM_WRITE(zodiack_videoram_w) AM_BASE_MEMBER(espial_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0xb000, 0xb3ff) AM_RAM_WRITE(zodiack_videoram2_w) AM_BASE_MEMBER(espial_state, videoram_2)
AM_RANGE(0xc000, 0xcfff) AM_ROM
ADDRESS_MAP_END
@ -516,6 +525,9 @@ GFXDECODE_END
static MACHINE_DRIVER_START( zodiack )
/* driver data */
MDRV_DRIVER_DATA(espial_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4.00 MHz??? */
MDRV_CPU_PROGRAM_MAP(main_map)
@ -527,7 +539,7 @@ static MACHINE_DRIVER_START( zodiack )
MDRV_CPU_VBLANK_INT_HACK(espial_sound_nmi_gen,8) /* IRQs are triggered by the main CPU */
MDRV_MACHINE_RESET(zodiack)
MDRV_MACHINE_START(espial)
MDRV_MACHINE_START(zodiack)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)

View File

@ -1,9 +1,39 @@
/***************************************************************************
Espial hardware games
Espial hardware games (drivers: espial.c, marineb.c and zodiack.c)
***************************************************************************/
typedef struct _espial_state espial_state;
struct _espial_state
{
UINT8 * videoram; // espial, zodiack, marineb
UINT8 * colorram; // espial, marineb
UINT8 * attributeram; // espial, zodiack
UINT8 * scrollram; // espial
UINT8 * spriteram_1; // espial
UINT8 * spriteram_2; // espial
UINT8 * spriteram_3; // espial
UINT8 * spriteram; // zodiack, marineb (hoccer only)
UINT8 * videoram_2; // zodiack
UINT8 * bulletsram; // zodiack
/* video-related */
tilemap *bg_tilemap, *fg_tilemap;
int flipscreen; // espial
UINT8 palette_bank; // marineb
UINT8 column_scroll; // marineb
UINT8 flipscreen_x, flipscreen_y; // marineb
UINT8 marineb_active_low_flipscreen; // marineb
/* sound-related */
UINT8 sound_nmi_enabled; // espial
/* misc */
int percuss_hardware; // zodiack
};
/*----------- defined in drivers/espial.c -----------*/
MACHINE_RESET( espial );
@ -18,14 +48,6 @@ INTERRUPT_GEN( espial_sound_nmi_gen );
/*----------- defined in video/espial.c -----------*/
extern UINT8 *espial_videoram;
extern UINT8 *espial_colorram;
extern UINT8 *espial_attributeram;
extern UINT8 *espial_scrollram;
extern UINT8 *espial_spriteram_1;
extern UINT8 *espial_spriteram_2;
extern UINT8 *espial_spriteram_3;
PALETTE_INIT( espial );
VIDEO_START( espial );
VIDEO_START( netwars );
@ -39,10 +61,6 @@ VIDEO_UPDATE( espial );
/*----------- defined in video/marineb.c -----------*/
extern UINT8 *marineb_videoram;
extern UINT8 *marineb_colorram;
extern UINT8 marineb_active_low_flipscreen;
WRITE8_HANDLER( marineb_videoram_w );
WRITE8_HANDLER( marineb_colorram_w );
WRITE8_HANDLER( marineb_column_scroll_w );
@ -59,15 +77,8 @@ VIDEO_UPDATE( hoccer );
VIDEO_UPDATE( hopprobo );
/*----------- defined in drivers/zodiack.c -----------*/
extern int percuss_hardware;
/*----------- defined in video/zodiack.c -----------*/
extern UINT8 *zodiack_videoram2;
extern UINT8 *zodiack_attributesram;
extern UINT8 *zodiack_bulletsram;
extern size_t zodiack_bulletsram_size;
WRITE8_HANDLER( zodiack_videoram_w );

View File

@ -9,19 +9,6 @@
#include "driver.h"
#include "includes/espial.h"
UINT8 *espial_videoram;
UINT8 *espial_colorram;
UINT8 *espial_attributeram;
UINT8 *espial_scrollram;
UINT8 *espial_spriteram_1;
UINT8 *espial_spriteram_2;
UINT8 *espial_spriteram_3;
static int flipscreen;
static tilemap *bg_tilemap;
/***************************************************************************
Convert the color PROMs into a more useable format.
@ -41,15 +28,14 @@ static tilemap *bg_tilemap;
bit 0 -- 1 kohm resistor -- RED
***************************************************************************/
PALETTE_INIT( espial )
{
int i;
for (i = 0;i < machine->config->total_colors;i++)
for (i = 0; i < machine->config->total_colors; i++)
{
int bit0,bit1,bit2,r,g,b;
int bit0, bit1, bit2, r, g, b;
/* red component */
bit0 = (color_prom[i] >> 0) & 0x01;
@ -67,7 +53,7 @@ PALETTE_INIT( espial )
bit2 = (color_prom[i + machine->config->total_colors] >> 3) & 0x01;
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
palette_set_color(machine,i,MAKE_RGB(r,g,b));
palette_set_color(machine, i, MAKE_RGB(r,g,b));
}
}
@ -81,9 +67,10 @@ PALETTE_INIT( espial )
static TILE_GET_INFO( get_tile_info )
{
UINT8 code = espial_videoram[tile_index];
UINT8 col = espial_colorram[tile_index];
UINT8 attr = espial_attributeram[tile_index];
espial_state *state = (espial_state *)machine->driver_data;
UINT8 code = state->videoram[tile_index];
UINT8 col = state->colorram[tile_index];
UINT8 attr = state->attributeram[tile_index];
SET_TILE_INFO(0,
code | ((attr & 0x03) << 8),
col & 0x3f,
@ -100,22 +87,25 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( espial )
{
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
espial_state *state = (espial_state *)machine->driver_data;
tilemap_set_scroll_cols(bg_tilemap, 32);
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_scroll_cols(state->bg_tilemap, 32);
state_save_register_global(machine, flipscreen);
state_save_register_global(machine, state->flipscreen);
}
VIDEO_START( netwars )
{
espial_state *state = (espial_state *)machine->driver_data;
/* Net Wars has a tile map that's twice as big as Espial's */
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,64);
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 64);
tilemap_set_scroll_cols(bg_tilemap, 32);
tilemap_set_scrolldy(bg_tilemap, 0, 0x100);
tilemap_set_scroll_cols(state->bg_tilemap, 32);
tilemap_set_scrolldy(state->bg_tilemap, 0, 0x100);
state_save_register_global(machine, flipscreen);
state_save_register_global(machine, state->flipscreen);
}
@ -127,37 +117,46 @@ VIDEO_START( netwars )
WRITE8_HANDLER( espial_videoram_w )
{
espial_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
espial_state *state = (espial_state *)space->machine->driver_data;
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( espial_colorram_w )
{
espial_colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
espial_state *state = (espial_state *)space->machine->driver_data;
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( espial_attributeram_w )
{
espial_attributeram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
espial_state *state = (espial_state *)space->machine->driver_data;
state->attributeram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( espial_scrollram_w )
{
espial_scrollram[offset] = data;
tilemap_set_scrolly(bg_tilemap, offset, data);
espial_state *state = (espial_state *)space->machine->driver_data;
state->scrollram[offset] = data;
tilemap_set_scrolly(state->bg_tilemap, offset, data);
}
WRITE8_HANDLER( espial_flipscreen_w )
{
flipscreen = data;
espial_state *state = (espial_state *)space->machine->driver_data;
tilemap_set_flip(bg_tilemap, flipscreen ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
state->flipscreen = data;
tilemap_set_flip(state->bg_tilemap, state->flipscreen ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
}
@ -167,26 +166,26 @@ WRITE8_HANDLER( espial_flipscreen_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 )
{
espial_state *state = (espial_state *)machine->driver_data;
int offs;
/* Note that it is important to draw them exactly in this */
/* order, to have the correct priorities. */
for (offs = 0;offs < 16;offs++)
for (offs = 0; offs < 16; offs++)
{
int sx,sy,code,color,flipx,flipy;
int sx, sy, code, color, flipx, flipy;
sx = espial_spriteram_1[offs + 16];
sy = espial_spriteram_2[offs];
code = espial_spriteram_1[offs] >> 1;
color = espial_spriteram_2[offs + 16];
flipx = espial_spriteram_3[offs] & 0x04;
flipy = espial_spriteram_3[offs] & 0x08;
sx = state->spriteram_1[offs + 16];
sy = state->spriteram_2[offs];
code = state->spriteram_1[offs] >> 1;
color = state->spriteram_2[offs + 16];
flipx = state->spriteram_3[offs] & 0x04;
flipy = state->spriteram_3[offs] & 0x08;
if (flipscreen)
if (state->flipscreen)
{
flipx = !flipx;
flipy = !flipy;
@ -196,9 +195,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
sy = 240 - sy;
}
if (espial_spriteram_1[offs] & 1) /* double height */
if (state->spriteram_1[offs] & 1) /* double height */
{
if (flipscreen)
if (state->flipscreen)
{
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
code,color,
@ -235,7 +234,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( espial )
{
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
espial_state *state = (espial_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -10,18 +10,6 @@
#include "includes/espial.h"
UINT8 *marineb_videoram;
UINT8 *marineb_colorram;
UINT8 marineb_active_low_flipscreen;
static UINT8 column_scroll;
static UINT8 palette_bank;
static UINT8 flipscreen_x;
static UINT8 flipscreen_y;
static tilemap *bg_tilemap;
/***************************************************************************
Callbacks for the TileMap code
@ -30,12 +18,14 @@ static tilemap *bg_tilemap;
static TILE_GET_INFO( get_tile_info )
{
UINT8 code = marineb_videoram[tile_index];
UINT8 col = marineb_colorram[tile_index];
espial_state *state = (espial_state *)machine->driver_data;
UINT8 code = state->videoram[tile_index];
UINT8 col = state->colorram[tile_index];
SET_TILE_INFO(0,
code | ((col & 0xc0) << 2),
(col & 0x0f) | (palette_bank << 4),
(col & 0x0f) | (state->palette_bank << 4),
TILE_FLIPXY((col >> 4) & 0x03));
}
@ -49,9 +39,15 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( marineb )
{
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
espial_state *state = (espial_state *)machine->driver_data;
tilemap_set_scroll_cols(bg_tilemap, 32);
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_scroll_cols(state->bg_tilemap, 32);
state_save_register_global(machine, state->palette_bank);
state_save_register_global(machine, state->column_scroll);
state_save_register_global(machine, state->flipscreen_x);
state_save_register_global(machine, state->flipscreen_y);
}
@ -64,63 +60,72 @@ VIDEO_START( marineb )
WRITE8_HANDLER( marineb_videoram_w )
{
marineb_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
espial_state *state = (espial_state *)space->machine->driver_data;
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( marineb_colorram_w )
{
marineb_colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
espial_state *state = (espial_state *)space->machine->driver_data;
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( marineb_column_scroll_w )
{
column_scroll = data;
espial_state *state = (espial_state *)space->machine->driver_data;
state->column_scroll = data;
}
WRITE8_HANDLER( marineb_palette_bank_0_w )
{
UINT8 old = palette_bank;
espial_state *state = (espial_state *)space->machine->driver_data;
UINT8 old = state->palette_bank;
palette_bank = (palette_bank & 0x02) | ((data & 0x01) << 0);
state->palette_bank = (state->palette_bank & 0x02) | (data & 0x01);
if (old != palette_bank)
if (old != state->palette_bank)
{
tilemap_mark_all_tiles_dirty(bg_tilemap);
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
}
WRITE8_HANDLER( marineb_palette_bank_1_w )
{
UINT8 old = palette_bank;
espial_state *state = (espial_state *)space->machine->driver_data;
UINT8 old = state->palette_bank;
palette_bank = (palette_bank & 0x01) | ((data & 0x01) << 1);
state->palette_bank = (state->palette_bank & 0x01) | ((data & 0x01) << 1);
if (old != palette_bank)
if (old != state->palette_bank)
{
tilemap_mark_all_tiles_dirty(bg_tilemap);
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
}
WRITE8_HANDLER( marineb_flipscreen_x_w )
{
flipscreen_x = data ^ marineb_active_low_flipscreen;
espial_state *state = (espial_state *)space->machine->driver_data;
tilemap_set_flip(bg_tilemap, (flipscreen_x ? TILEMAP_FLIPX : 0) | (flipscreen_y ? TILEMAP_FLIPY : 0));
state->flipscreen_x = data ^ state->marineb_active_low_flipscreen;
tilemap_set_flip(state->bg_tilemap, (state->flipscreen_x ? TILEMAP_FLIPX : 0) | (state->flipscreen_y ? TILEMAP_FLIPY : 0));
}
WRITE8_HANDLER( marineb_flipscreen_y_w )
{
flipscreen_y = data ^ marineb_active_low_flipscreen;
espial_state *state = (espial_state *)space->machine->driver_data;
tilemap_set_flip(bg_tilemap, (flipscreen_x ? TILEMAP_FLIPX : 0) | (flipscreen_y ? TILEMAP_FLIPY : 0));
state->flipscreen_y = data ^ state->marineb_active_low_flipscreen;
tilemap_set_flip(state->bg_tilemap, (state->flipscreen_x ? TILEMAP_FLIPX : 0) | (state->flipscreen_y ? TILEMAP_FLIPY : 0));
}
@ -131,50 +136,44 @@ WRITE8_HANDLER( marineb_flipscreen_y_w )
*
*************************************/
static void set_tilemap_scrolly(int cols)
static void set_tilemap_scrolly( running_machine *machine, int cols )
{
espial_state *state = (espial_state *)machine->driver_data;
int col;
for (col = 0; col < cols; col++)
tilemap_set_scrolly(bg_tilemap, col, column_scroll);
tilemap_set_scrolly(state->bg_tilemap, col, state->column_scroll);
for (; col < 32; col++)
tilemap_set_scrolly(bg_tilemap, col, 0);
tilemap_set_scrolly(state->bg_tilemap, col, 0);
}
VIDEO_UPDATE( marineb )
{
espial_state *state = (espial_state *)screen->machine->driver_data;
int offs;
set_tilemap_scrolly(24);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
set_tilemap_scrolly(screen->machine, 24);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the sprites */
for (offs = 0x0f; offs >= 0; offs--)
{
int gfx,sx,sy,code,col,flipx,flipy,offs2;
if ((offs == 0) || (offs == 2)) continue; /* no sprites here */
int gfx, sx, sy, code, col, flipx, flipy, offs2;
if ((offs == 0) || (offs == 2))
continue; /* no sprites here */
if (offs < 8)
{
offs2 = 0x0018 + offs;
}
else
{
offs2 = 0x03d8 - 8 + offs;
}
code = marineb_videoram[offs2];
sx = marineb_videoram[offs2 + 0x20];
sy = marineb_colorram[offs2];
col = (marineb_colorram[offs2 + 0x20] & 0x0f) + 16 * palette_bank;
code = state->videoram[offs2];
sx = state->videoram[offs2 + 0x20];
sy = state->colorram[offs2];
col = (state->colorram[offs2 + 0x20] & 0x0f) + 16 * state->palette_bank;
flipx = code & 0x02;
flipy = !(code & 0x01);
@ -191,13 +190,13 @@ VIDEO_UPDATE( marineb )
code >>= 2;
}
if (!flipscreen_y)
if (!state->flipscreen_y)
{
sy = 256 - screen->machine->gfx[gfx]->width - sy;
flipy = !flipy;
}
if (flipscreen_x)
if (state->flipscreen_x)
{
sx++;
}
@ -214,35 +213,33 @@ VIDEO_UPDATE( marineb )
VIDEO_UPDATE( changes )
{
int offs,sx,sy,code,col,flipx,flipy;
set_tilemap_scrolly(26);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
espial_state *state = (espial_state *)screen->machine->driver_data;
int offs, sx, sy, code, col, flipx, flipy;
set_tilemap_scrolly(screen->machine, 26);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the small sprites */
for (offs = 0x05; offs >= 0; offs--)
{
int offs2;
offs2 = 0x001a + offs;
code = marineb_videoram[offs2];
sx = marineb_videoram[offs2 + 0x20];
sy = marineb_colorram[offs2];
col = (marineb_colorram[offs2 + 0x20] & 0x0f) + 16 * palette_bank;
code = state->videoram[offs2];
sx = state->videoram[offs2 + 0x20];
sy = state->colorram[offs2];
col = (state->colorram[offs2 + 0x20] & 0x0f) + 16 * state->palette_bank;
flipx = code & 0x02;
flipy = !(code & 0x01);
if (!flipscreen_y)
if (!state->flipscreen_y)
{
sy = 256 - screen->machine->gfx[1]->width - sy;
flipy = !flipy;
}
if (flipscreen_x)
if (state->flipscreen_x)
{
sx++;
}
@ -256,20 +253,20 @@ VIDEO_UPDATE( changes )
/* draw the big sprite */
code = marineb_videoram[0x3df];
sx = marineb_videoram[0x3ff];
sy = marineb_colorram[0x3df];
col = marineb_colorram[0x3ff];
code = state->videoram[0x3df];
sx = state->videoram[0x3ff];
sy = state->colorram[0x3df];
col = state->colorram[0x3ff];
flipx = code & 0x02;
flipy = !(code & 0x01);
if (!flipscreen_y)
if (!state->flipscreen_y)
{
sy = 256 - screen->machine->gfx[2]->width - sy;
flipy = !flipy;
}
if (flipscreen_x)
if (state->flipscreen_x)
{
sx++;
}
@ -295,29 +292,26 @@ VIDEO_UPDATE( changes )
VIDEO_UPDATE( springer )
{
espial_state *state = (espial_state *)screen->machine->driver_data;
int offs;
set_tilemap_scrolly(0);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
set_tilemap_scrolly(screen->machine, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the sprites */
for (offs = 0x0f; offs >= 0; offs--)
{
int gfx,sx,sy,code,col,flipx,flipy,offs2;
if ((offs == 0) || (offs == 2)) continue; /* no sprites here */
int gfx, sx, sy, code, col, flipx, flipy, offs2;
if ((offs == 0) || (offs == 2))
continue; /* no sprites here */
offs2 = 0x0010 + offs;
code = marineb_videoram[offs2];
sx = 240 - marineb_videoram[offs2 + 0x20];
sy = marineb_colorram[offs2];
col = (marineb_colorram[offs2 + 0x20] & 0x0f) + 16 * palette_bank;
code = state->videoram[offs2];
sx = 240 - state->videoram[offs2 + 0x20];
sy = state->colorram[offs2];
col = (state->colorram[offs2 + 0x20] & 0x0f) + 16 * state->palette_bank;
flipx = !(code & 0x02);
flipy = !(code & 0x01);
@ -335,13 +329,13 @@ VIDEO_UPDATE( springer )
code >>= 2;
}
if (!flipscreen_y)
if (!state->flipscreen_y)
{
sy = 256 - screen->machine->gfx[gfx]->width - sy;
flipy = !flipy;
}
if (!flipscreen_x)
if (!state->flipscreen_x)
{
sx--;
}
@ -358,36 +352,33 @@ VIDEO_UPDATE( springer )
VIDEO_UPDATE( hoccer )
{
espial_state *state = (espial_state *)screen->machine->driver_data;
int offs;
set_tilemap_scrolly(0);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
set_tilemap_scrolly(screen->machine, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the sprites */
for (offs = 0x07; offs >= 0; offs--)
{
int sx,sy,code,col,flipx,flipy,offs2;
int sx, sy, code, col, flipx, flipy, offs2;
offs2 = 0x0018 + offs;
code = spriteram[offs2];
sx = spriteram[offs2 + 0x20];
sy = marineb_colorram[offs2];
col = marineb_colorram[offs2 + 0x20];
code = state->spriteram[offs2];
sx = state->spriteram[offs2 + 0x20];
sy = state->colorram[offs2];
col = state->colorram[offs2 + 0x20];
flipx = code & 0x02;
flipy = !(code & 0x01);
if (!flipscreen_y)
if (!state->flipscreen_y)
{
sy = 256 - screen->machine->gfx[1]->width - sy;
flipy = !flipy;
}
if (flipscreen_x)
if (state->flipscreen_x)
{
sx = 256 - screen->machine->gfx[1]->width - sx;
flipx = !flipx;
@ -405,29 +396,26 @@ VIDEO_UPDATE( hoccer )
VIDEO_UPDATE( hopprobo )
{
espial_state *state = (espial_state *)screen->machine->driver_data;
int offs;
set_tilemap_scrolly(0);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
set_tilemap_scrolly(screen->machine, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the sprites */
for (offs = 0x0f; offs >= 0; offs--)
{
int gfx,sx,sy,code,col,flipx,flipy,offs2;
if ((offs == 0) || (offs == 2)) continue; /* no sprites here */
int gfx, sx, sy, code, col, flipx, flipy, offs2;
if ((offs == 0) || (offs == 2))
continue; /* no sprites here */
offs2 = 0x0010 + offs;
code = marineb_videoram[offs2];
sx = marineb_videoram[offs2 + 0x20];
sy = marineb_colorram[offs2];
col = (marineb_colorram[offs2 + 0x20] & 0x0f) + 16 * palette_bank;
code = state->videoram[offs2];
sx = state->videoram[offs2 + 0x20];
sy = state->colorram[offs2];
col = (state->colorram[offs2 + 0x20] & 0x0f) + 16 * state->palette_bank;
flipx = code & 0x02;
flipy = !(code & 0x01);
@ -444,13 +432,13 @@ VIDEO_UPDATE( hopprobo )
code >>= 2;
}
if (!flipscreen_y)
if (!state->flipscreen_y)
{
sy = 256 - screen->machine->gfx[gfx]->width - sy;
flipy = !flipy;
}
if (!flipscreen_x)
if (!state->flipscreen_x)
{
sx--;
}

View File

@ -9,39 +9,41 @@
#include "driver.h"
#include "includes/espial.h"
UINT8 *zodiack_videoram2;
UINT8 *zodiack_attributesram;
UINT8 *zodiack_bulletsram;
size_t zodiack_bulletsram_size;
static tilemap *bg_tilemap, *fg_tilemap;
WRITE8_HANDLER( zodiack_videoram_w )
{
videoram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap, offset);
espial_state *state = (espial_state *)space->machine->driver_data;
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset);
}
WRITE8_HANDLER( zodiack_videoram2_w )
{
zodiack_videoram2[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
espial_state *state = (espial_state *)space->machine->driver_data;
state->videoram_2[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( zodiack_attributes_w )
{
if ((offset & 1) && zodiack_attributesram[offset] != data)
espial_state *state = (espial_state *)space->machine->driver_data;
if ((offset & 1) && state->attributeram[offset] != data)
{
int i;
for (i = offset / 2;i < videoram_size; i += 32)
for (i = offset / 2; i < videoram_size; i += 32)
{
tilemap_mark_tile_dirty(bg_tilemap, i);
tilemap_mark_tile_dirty(fg_tilemap, i);
tilemap_mark_tile_dirty(state->bg_tilemap, i);
tilemap_mark_tile_dirty(state->fg_tilemap, i);
}
}
zodiack_attributesram[offset] = data;
state->attributeram[offset] = data;
}
WRITE8_HANDLER( zodiack_flipscreen_w )
@ -107,28 +109,33 @@ PALETTE_INIT( zodiack )
static TILE_GET_INFO( get_bg_tile_info )
{
int code = zodiack_videoram2[tile_index];
int color = (zodiack_attributesram[2 * (tile_index % 32) + 1] >> 4) & 0x07;
espial_state *state = (espial_state *)machine->driver_data;
int code = state->videoram_2[tile_index];
int color = (state->attributeram[2 * (tile_index % 32) + 1] >> 4) & 0x07;
SET_TILE_INFO(0, code, color, 0);
}
static TILE_GET_INFO( get_fg_tile_info )
{
int code = videoram[tile_index];
int color = zodiack_attributesram[2 * (tile_index % 32) + 1] & 0x07;
espial_state *state = (espial_state *)machine->driver_data;
int code = state->videoram[tile_index];
int color = state->attributeram[2 * (tile_index % 32) + 1] & 0x07;
SET_TILE_INFO(3, code, color, 0);
}
VIDEO_START( zodiack )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
espial_state *state = (espial_state *)machine->driver_data;
fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, 0);
tilemap_set_scroll_cols(fg_tilemap, 32);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
tilemap_set_scroll_cols(state->fg_tilemap, 32);
/* FIXME: flip_screen_x should not be written. */
flip_screen_set_no_update(machine, 0);
@ -136,16 +143,17 @@ VIDEO_START( zodiack )
static void draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
espial_state *state = (espial_state *)machine->driver_data;
int offs;
for (offs = 0; offs < zodiack_bulletsram_size; offs += 4)
{
int x, y;
x = zodiack_bulletsram[offs + 3] + 7;
y = 255 - zodiack_bulletsram[offs + 1];
x = state->bulletsram[offs + 3] + 7;
y = 255 - state->bulletsram[offs + 1];
if (flip_screen_get(machine) && percuss_hardware)
if (flip_screen_get(machine) && state->percuss_hardware)
{
y = 255 - y;
}
@ -162,19 +170,20 @@ static void draw_bullets(running_machine *machine, bitmap_t *bitmap, const recta
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
espial_state *state = (espial_state *)machine->driver_data;
int offs;
for (offs = spriteram_size - 4; offs >= 0; offs -= 4)
{
int flipx, flipy, sx, sy, spritecode;
sx = 240 - spriteram[offs + 3];
sy = 240 - spriteram[offs];
flipx = !(spriteram[offs + 1] & 0x40);
flipy = spriteram[offs + 1] & 0x80;
spritecode = spriteram[offs + 1] & 0x3f;
sx = 240 - state->spriteram[offs + 3];
sy = 240 - state->spriteram[offs];
flipx = !(state->spriteram[offs + 1] & 0x40);
flipy = state->spriteram[offs + 1] & 0x80;
spritecode = state->spriteram[offs + 1] & 0x3f;
if (flip_screen_get(machine) && percuss_hardware)
if (flip_screen_get(machine) && state->percuss_hardware)
{
sy = 240 - sy;
flipy = !flipy;
@ -182,7 +191,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
spritecode,
spriteram[offs + 2] & 0x07,
state->spriteram[offs + 2] & 0x07,
flipx, flipy,
sx, sy,
0);
@ -191,13 +200,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( zodiack )
{
espial_state *state = (espial_state *)screen->machine->driver_data;
int i;
for (i = 0; i < 32; i++)
tilemap_set_scrolly(fg_tilemap, i, zodiack_attributesram[i * 2]);
tilemap_set_scrolly(state->fg_tilemap, i, state->attributeram[i * 2]);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
draw_bullets(screen->machine, bitmap, cliprect);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;