summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2009-11-18 15:30:40 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2009-11-18 15:30:40 +0000
commit0e9664b331e80bb08502500670458796e00ddcae (patch)
treea89483e96ec23039c3e8bfe8cffffd377b8eb91a /src
parentea72b5770dd11276b3c35d87bf322ea9cd9ceb04 (diff)
Added driver_data struct to 1942.c and 1943.c. Also moved 1943.c to use memory_configure_bank in place of memory_set_bankptr.
Side-notes (not worth mention): * I fear we were missing a local static array in 1942 save states (now it is saved) * I haven't found a better way to configure 1943 banks than to split the 0x4000 bank into 4 pieces. can anyone come up with a better approach?
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/1942.c53
-rw-r--r--src/mame/drivers/1943.c65
-rw-r--r--src/mame/includes/1942.h33
-rw-r--r--src/mame/includes/1943.h34
-rw-r--r--src/mame/video/1942.c138
-rw-r--r--src/mame/video/1943.c121
6 files changed, 257 insertions, 187 deletions
diff --git a/src/mame/drivers/1942.c b/src/mame/drivers/1942.c
index ae4cec83312..c440e749ab0 100644
--- a/src/mame/drivers/1942.c
+++ b/src/mame/drivers/1942.c
@@ -57,19 +57,6 @@ correctly.
at the sound CPU.
-SAVE STATE (lee@lmservers.com):
-1942 uses the Z80 and AY8910 which both support save state.
-
-The global variables in drivers/1942.c are extern and defined in video/1942.c
-The rationale for saving/not saving are as follows:
-UINT8 *c1942_fgvideoram; Saved via reference to AM_BASE
-UINT8 *c1942_bgvideoram; Saved via reference to AM_BASE
-
-static int c1942_palette_bank; Explicitly saved
-static tilemap *fg_tilemap, *bg_tilemap; Saved due to tilemap supporting save
-
-There are no static local variables.
-
***************************************************************************/
#define MAIN_CPU_CLOCK (XTAL_12MHz/3) /* 12MHz is the only OSC on the PCB */
@@ -80,22 +67,7 @@ There are no static local variables.
#include "cpu/z80/z80.h"
#include "deprecat.h"
#include "sound/ay8910.h"
-
-
-extern UINT8 *c1942_fgvideoram;
-extern UINT8 *c1942_bgvideoram;
-
-
-extern WRITE8_HANDLER( c1942_fgvideoram_w );
-extern WRITE8_HANDLER( c1942_bgvideoram_w );
-extern WRITE8_HANDLER( c1942_scroll_w );
-extern WRITE8_HANDLER( c1942_c804_w );
-extern WRITE8_HANDLER( c1942_palette_bank_w );
-
-extern PALETTE_INIT( 1942 );
-extern VIDEO_START( 1942 );
-extern VIDEO_UPDATE( 1942 );
-
+#include "1942.h"
static WRITE8_HANDLER( c1942_bankswitch_w )
@@ -103,18 +75,15 @@ static WRITE8_HANDLER( c1942_bankswitch_w )
memory_set_bank(space->machine, 1, data & 0x03);
}
-
-
static INTERRUPT_GEN( c1942_interrupt )
{
if (cpu_getiloops(device) != 0)
- cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xcf);/* RST 08h */
+ cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xcf); /* RST 08h */
else
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7); /* RST 10h - vblank */
}
-
static ADDRESS_MAP_START( c1942_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK(1)
@@ -128,9 +97,9 @@ static ADDRESS_MAP_START( c1942_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc804, 0xc804) AM_WRITE(c1942_c804_w)
AM_RANGE(0xc805, 0xc805) AM_WRITE(c1942_palette_bank_w)
AM_RANGE(0xc806, 0xc806) AM_WRITE(c1942_bankswitch_w)
- AM_RANGE(0xcc00, 0xcc7f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
- AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(c1942_fgvideoram_w) AM_BASE(&c1942_fgvideoram)
- AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(c1942_bgvideoram_w) AM_BASE(&c1942_bgvideoram)
+ AM_RANGE(0xcc00, 0xcc7f) AM_RAM AM_BASE_MEMBER(_1942_state, spriteram) AM_SIZE(&spriteram_size)
+ AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(c1942_fgvideoram_w) AM_BASE_MEMBER(_1942_state, fg_videoram)
+ AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(c1942_bgvideoram_w) AM_BASE_MEMBER(_1942_state, bg_videoram)
AM_RANGE(0xe000, 0xefff) AM_RAM
ADDRESS_MAP_END
@@ -265,9 +234,19 @@ static GFXDECODE_START( 1942 )
GFXDECODE_END
+static MACHINE_RESET( 1942 )
+{
+ _1942_state *state = (_1942_state *)machine->driver_data;
+
+ state->palette_bank = 0;
+ state->scroll[0] = 0;
+ state->scroll[1] = 0;
+}
static MACHINE_DRIVER_START( 1942 )
+ MDRV_DRIVER_DATA(_1942_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, MAIN_CPU_CLOCK) /* 4 MHz ??? */
MDRV_CPU_PROGRAM_MAP(c1942_map)
@@ -277,6 +256,8 @@ static MACHINE_DRIVER_START( 1942 )
MDRV_CPU_PROGRAM_MAP(sound_map)
MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4)
+ MDRV_MACHINE_RESET(1942)
+
/* video hardware */
MDRV_GFXDECODE(1942)
MDRV_PALETTE_LENGTH(64*4+4*32*8+16*16)
diff --git a/src/mame/drivers/1943.c b/src/mame/drivers/1943.c
index 2c11cce19f3..3fcdf2e9583 100644
--- a/src/mame/drivers/1943.c
+++ b/src/mame/drivers/1943.c
@@ -24,19 +24,8 @@
#include "deprecat.h"
#include "cpu/z80/z80.h"
#include "sound/2203intf.h"
+#include "1943.h"
-extern UINT8 *c1943_scrollx;
-extern UINT8 *c1943_scrolly;
-extern UINT8 *c1943_bgscrollx;
-
-extern WRITE8_HANDLER( c1943_c804_w );
-extern WRITE8_HANDLER( c1943_d806_w );
-extern WRITE8_HANDLER( c1943_videoram_w );
-extern WRITE8_HANDLER( c1943_colorram_w );
-
-extern PALETTE_INIT( 1943 );
-extern VIDEO_START( 1943 );
-extern VIDEO_UPDATE( 1943 );
/* Read/Write Handlers */
@@ -48,7 +37,7 @@ static READ8_HANDLER( c1943_protection_r )
*/
int data = cpu_get_reg(space->cpu, Z80_BC) >> 8;
-// logerror("protection read, PC: %04x Result:%02x\n",cpu_get_pc(space->cpu),data);
+// logerror("protection read, PC: %04x Result:%02x\n", cpu_get_pc(space->cpu), data);
return data;
}
@@ -56,7 +45,10 @@ static READ8_HANDLER( c1943_protection_r )
static ADDRESS_MAP_START( c1943_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK(1)
+ AM_RANGE(0x8000, 0x8fff) AM_ROMBANK(1)
+ AM_RANGE(0x9000, 0x9fff) AM_ROMBANK(2)
+ AM_RANGE(0xa000, 0xafff) AM_ROMBANK(3)
+ AM_RANGE(0xb000, 0xbfff) AM_ROMBANK(4)
AM_RANGE(0xc000, 0xc000) AM_READ_PORT("SYSTEM")
AM_RANGE(0xc001, 0xc001) AM_READ_PORT("P1")
AM_RANGE(0xc002, 0xc002) AM_READ_PORT("P2")
@@ -67,18 +59,18 @@ static ADDRESS_MAP_START( c1943_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc804, 0xc804) AM_WRITE(c1943_c804_w) // ROM bank switch, screen flip
AM_RANGE(0xc806, 0xc806) AM_WRITE(watchdog_reset_w)
AM_RANGE(0xc807, 0xc807) AM_WRITENOP // ???
- AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(c1943_videoram_w) AM_BASE(&videoram)
- AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(c1943_colorram_w) AM_BASE(&colorram)
- AM_RANGE(0xd800, 0xd801) AM_RAM AM_BASE(&c1943_scrollx)
- AM_RANGE(0xd802, 0xd802) AM_RAM AM_BASE(&c1943_scrolly)
- AM_RANGE(0xd803, 0xd804) AM_RAM AM_BASE(&c1943_bgscrollx)
+ AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(c1943_videoram_w) AM_BASE_MEMBER(_1943_state, videoram)
+ AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(c1943_colorram_w) AM_BASE_MEMBER(_1943_state, colorram)
+ AM_RANGE(0xd800, 0xd801) AM_RAM AM_BASE_MEMBER(_1943_state, scrollx)
+ AM_RANGE(0xd802, 0xd802) AM_RAM AM_BASE_MEMBER(_1943_state, scrolly)
+ AM_RANGE(0xd803, 0xd804) AM_RAM AM_BASE_MEMBER(_1943_state, bgscrollx)
AM_RANGE(0xd806, 0xd806) AM_WRITE(c1943_d806_w) // sprites, bg1, bg2 enable
AM_RANGE(0xd808, 0xd808) AM_WRITENOP // ???
AM_RANGE(0xd868, 0xd868) AM_WRITENOP // ???
AM_RANGE(0xd888, 0xd888) AM_WRITENOP // ???
AM_RANGE(0xd8a8, 0xd8a8) AM_WRITENOP // ???
AM_RANGE(0xe000, 0xefff) AM_RAM
- AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
+ AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_MEMBER(_1943_state, spriteram) AM_SIZE(&spriteram_size)
ADDRESS_MAP_END
static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
@@ -244,9 +236,23 @@ static GFXDECODE_START( 1943 )
GFXDECODE_ENTRY( "gfx4", 0, spritelayout, 32*4+16*16+16*16, 16 )
GFXDECODE_END
+
/* Machine Driver */
+static MACHINE_RESET( 1943 )
+{
+ _1943_state *state = (_1943_state *)machine->driver_data;
+
+ state->char_on = 0;
+ state->obj_on = 0;
+ state->bg1_on = 0;
+ state->bg2_on = 0;
+}
+
static MACHINE_DRIVER_START( 1943 )
+
+ MDRV_DRIVER_DATA(_1943_state)
+
// basic machine hardware
MDRV_CPU_ADD("maincpu", Z80, XTAL_24MHz/4) /* verified on pcb */
MDRV_CPU_PROGRAM_MAP(c1943_map)
@@ -256,8 +262,9 @@ static MACHINE_DRIVER_START( 1943 )
MDRV_CPU_PROGRAM_MAP(sound_map)
MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold, 4)
- // video hardware
+ MDRV_MACHINE_RESET(1943)
+ // video hardware
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
@@ -454,8 +461,16 @@ ROM_START( 1943kai )
ROM_LOAD( "bmprom.06", 0x0b00, 0x0100, CRC(0eaf5158) SHA1(bafd4108708f66cd7b280e47152b108f3e254fc9) ) /* video timing (not used) */
ROM_END
-/* Game Drivers */
+static DRIVER_INIT( 1943 )
+{
+ UINT8 *ROM = memory_region(machine, "maincpu");
+ memory_configure_bank(machine, 1, 0, 28, &ROM[0x10000], 0x1000);
+ memory_configure_bank(machine, 2, 0, 28, &ROM[0x11000], 0x1000);
+ memory_configure_bank(machine, 3, 0, 28, &ROM[0x12000], 0x1000);
+ memory_configure_bank(machine, 4, 0, 28, &ROM[0x13000], 0x1000);
+}
-GAME( 1987, 1943, 0, 1943, 1943, 0, ROT270, "Capcom", "1943: The Battle of Midway (US)", GAME_SUPPORTS_SAVE )
-GAME( 1987, 1943j, 1943, 1943, 1943, 0, ROT270, "Capcom", "1943: Midway Kaisen (Japan)", GAME_SUPPORTS_SAVE )
-GAME( 1987, 1943kai, 0, 1943, 1943, 0, ROT270, "Capcom", "1943 Kai: Midway Kaisen (Japan)", GAME_SUPPORTS_SAVE )
+/* Game Drivers */
+GAME( 1987, 1943, 0, 1943, 1943, 1943, ROT270, "Capcom", "1943: The Battle of Midway (US)", GAME_SUPPORTS_SAVE )
+GAME( 1987, 1943j, 1943, 1943, 1943, 1943, ROT270, "Capcom", "1943: Midway Kaisen (Japan)", GAME_SUPPORTS_SAVE )
+GAME( 1987, 1943kai, 0, 1943, 1943, 1943, ROT270, "Capcom", "1943 Kai: Midway Kaisen (Japan)", GAME_SUPPORTS_SAVE )
diff --git a/src/mame/includes/1942.h b/src/mame/includes/1942.h
new file mode 100644
index 00000000000..1d4954f8ccd
--- /dev/null
+++ b/src/mame/includes/1942.h
@@ -0,0 +1,33 @@
+/***************************************************************************
+
+ 1942
+
+***************************************************************************/
+
+typedef struct __1942_state _1942_state;
+struct __1942_state
+{
+ /* memory pointers */
+ UINT8 * fg_videoram;
+ UINT8 * bg_videoram;
+ UINT8 * spriteram;
+
+ /* video-related */
+ tilemap *fg_tilemap, *bg_tilemap;
+ int palette_bank;
+ UINT8 scroll[2];
+};
+
+
+
+/*----------- defined in video/1942.c -----------*/
+
+extern WRITE8_HANDLER( c1942_fgvideoram_w );
+extern WRITE8_HANDLER( c1942_bgvideoram_w );
+extern WRITE8_HANDLER( c1942_scroll_w );
+extern WRITE8_HANDLER( c1942_c804_w );
+extern WRITE8_HANDLER( c1942_palette_bank_w );
+
+extern PALETTE_INIT( 1942 );
+extern VIDEO_START( 1942 );
+extern VIDEO_UPDATE( 1942 );
diff --git a/src/mame/includes/1943.h b/src/mame/includes/1943.h
new file mode 100644
index 00000000000..d746964ef2d
--- /dev/null
+++ b/src/mame/includes/1943.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+
+ 1943
+
+***************************************************************************/
+
+typedef struct __1943_state _1943_state;
+struct __1943_state
+{
+ /* memory pointers */
+ UINT8 * videoram;
+ UINT8 * colorram;
+ UINT8 * spriteram;
+ UINT8 * scrollx;
+ UINT8 * scrolly;
+ UINT8 * bgscrollx;
+
+ /* video-related */
+ tilemap *fg_tilemap, *bg_tilemap, *bg2_tilemap;
+ int char_on, obj_on, bg1_on, bg2_on;
+};
+
+
+
+/*----------- defined in video/1943.c -----------*/
+
+extern WRITE8_HANDLER( c1943_c804_w );
+extern WRITE8_HANDLER( c1943_d806_w );
+extern WRITE8_HANDLER( c1943_videoram_w );
+extern WRITE8_HANDLER( c1943_colorram_w );
+
+extern PALETTE_INIT( 1943 );
+extern VIDEO_START( 1943 );
+extern VIDEO_UPDATE( 1943 );
diff --git a/src/mame/video/1942.c b/src/mame/video/1942.c
index dc831d71d61..4b519305d12 100644
--- a/src/mame/video/1942.c
+++ b/src/mame/video/1942.c
@@ -7,15 +7,7 @@
***************************************************************************/
#include "driver.h"
-
-
-UINT8 *c1942_fgvideoram;
-UINT8 *c1942_bgvideoram;
-
-static int c1942_palette_bank;
-static tilemap *fg_tilemap, *bg_tilemap;
-
-
+#include "1942.h"
/***************************************************************************
@@ -31,6 +23,7 @@ static tilemap *fg_tilemap, *bg_tilemap;
bit 0 -- 2.2kohm resistor -- RED/GREEN/BLUE
***************************************************************************/
+
PALETTE_INIT( 1942 )
{
rgb_t palette[256];
@@ -38,53 +31,53 @@ PALETTE_INIT( 1942 )
for (i = 0; i < 256; i++)
{
- int bit0,bit1,bit2,bit3,r,g,b;
+ int bit0, bit1, bit2, bit3, r, g, b;
/* red component */
- bit0 = (color_prom[i + 0*256] >> 0) & 0x01;
- bit1 = (color_prom[i + 0*256] >> 1) & 0x01;
- bit2 = (color_prom[i + 0*256] >> 2) & 0x01;
- bit3 = (color_prom[i + 0*256] >> 3) & 0x01;
+ bit0 = (color_prom[i + 0 * 256] >> 0) & 0x01;
+ bit1 = (color_prom[i + 0 * 256] >> 1) & 0x01;
+ bit2 = (color_prom[i + 0 * 256] >> 2) & 0x01;
+ bit3 = (color_prom[i + 0 * 256] >> 3) & 0x01;
r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
/* green component */
- bit0 = (color_prom[i + 1*256] >> 0) & 0x01;
- bit1 = (color_prom[i + 1*256] >> 1) & 0x01;
- bit2 = (color_prom[i + 1*256] >> 2) & 0x01;
- bit3 = (color_prom[i + 1*256] >> 3) & 0x01;
+ bit0 = (color_prom[i + 1 * 256] >> 0) & 0x01;
+ bit1 = (color_prom[i + 1 * 256] >> 1) & 0x01;
+ bit2 = (color_prom[i + 1 * 256] >> 2) & 0x01;
+ bit3 = (color_prom[i + 1 * 256] >> 3) & 0x01;
g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
/* blue component */
- bit0 = (color_prom[i + 2*256] >> 0) & 0x01;
- bit1 = (color_prom[i + 2*256] >> 1) & 0x01;
- bit2 = (color_prom[i + 2*256] >> 2) & 0x01;
- bit3 = (color_prom[i + 2*256] >> 3) & 0x01;
+ bit0 = (color_prom[i + 2 * 256] >> 0) & 0x01;
+ bit1 = (color_prom[i + 2 * 256] >> 1) & 0x01;
+ bit2 = (color_prom[i + 2 * 256] >> 2) & 0x01;
+ bit3 = (color_prom[i + 2 * 256] >> 3) & 0x01;
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
palette[i] = MAKE_RGB(r,g,b);
}
- color_prom += 3*256;
+ color_prom += 3 * 256;
/* color_prom now points to the beginning of the lookup table */
/* characters use palette entries 128-143 */
colorbase = 0;
- for (i = 0; i < 64*4; i++)
+ for (i = 0; i < 64 * 4; i++)
palette_set_color(machine, colorbase + i, palette[0x80 | *color_prom++]);
- colorbase += 64*4;
+ colorbase += 64 * 4;
/* background tiles use palette entries 0-63 in four banks */
- for (i = 0; i < 32*8; i++)
+ for (i = 0; i < 32 * 8; i++)
{
- palette_set_color(machine, colorbase + 0*32*8 + i, palette[0x00 | *color_prom]);
- palette_set_color(machine, colorbase + 1*32*8 + i, palette[0x10 | *color_prom]);
- palette_set_color(machine, colorbase + 2*32*8 + i, palette[0x20 | *color_prom]);
- palette_set_color(machine, colorbase + 3*32*8 + i, palette[0x30 | *color_prom]);
+ palette_set_color(machine, colorbase + 0 * 32 * 8 + i, palette[0x00 | *color_prom]);
+ palette_set_color(machine, colorbase + 1 * 32 * 8 + i, palette[0x10 | *color_prom]);
+ palette_set_color(machine, colorbase + 2 * 32 * 8 + i, palette[0x20 | *color_prom]);
+ palette_set_color(machine, colorbase + 3 * 32 * 8 + i, palette[0x30 | *color_prom]);
color_prom++;
}
- colorbase += 4*32*8;
+ colorbase += 4 * 32 * 8;
/* sprites use palette entries 64-79 */
- for (i = 0; i < 16*16; i++)
+ for (i = 0; i < 16 * 16; i++)
palette_set_color(machine, colorbase + i, palette[0x40 | *color_prom++]);
}
@@ -97,10 +90,11 @@ PALETTE_INIT( 1942 )
static TILE_GET_INFO( get_fg_tile_info )
{
+ _1942_state *state = (_1942_state *)machine->driver_data;
int code, color;
- code = c1942_fgvideoram[tile_index];
- color = c1942_fgvideoram[tile_index + 0x400];
+ code = state->fg_videoram[tile_index];
+ color = state->fg_videoram[tile_index + 0x400];
SET_TILE_INFO(
0,
code + ((color & 0x80) << 1),
@@ -110,16 +104,17 @@ static TILE_GET_INFO( get_fg_tile_info )
static TILE_GET_INFO( get_bg_tile_info )
{
+ _1942_state *state = (_1942_state *)machine->driver_data;
int code, color;
tile_index = (tile_index & 0x0f) | ((tile_index & 0x01f0) << 1);
- code = c1942_bgvideoram[tile_index];
- color = c1942_bgvideoram[tile_index + 0x10];
+ code = state->bg_videoram[tile_index];
+ color = state->bg_videoram[tile_index + 0x10];
SET_TILE_INFO(
1,
code + ((color & 0x80) << 1),
- (color & 0x1f) + (0x20 * c1942_palette_bank),
+ (color & 0x1f) + (0x20 * state->palette_bank),
TILE_FLIPYX((color & 0x60) >> 5));
}
@@ -131,12 +126,14 @@ static TILE_GET_INFO( get_bg_tile_info )
***************************************************************************/
VIDEO_START( 1942 )
{
- fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows, 8, 8,32,32);
- bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols, 16,16,32,16);
+ _1942_state *state = (_1942_state *)machine->driver_data;
+ state->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_cols, 16, 16, 32, 16);
- tilemap_set_transparent_pen(fg_tilemap,0);
+ tilemap_set_transparent_pen(state->fg_tilemap,0);
- state_save_register_global(machine, c1942_palette_bank);
+ state_save_register_global(machine, state->palette_bank);
+ state_save_register_global_array(machine, state->scroll);
}
@@ -148,32 +145,38 @@ VIDEO_START( 1942 )
WRITE8_HANDLER( c1942_fgvideoram_w )
{
- c1942_fgvideoram[offset] = data;
- tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff);
+ _1942_state *state = (_1942_state *)space->machine->driver_data;
+
+ state->fg_videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
}
WRITE8_HANDLER( c1942_bgvideoram_w )
{
- c1942_bgvideoram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap,(offset & 0x0f) | ((offset >> 1) & 0x01f0));
+ _1942_state *state = (_1942_state *)space->machine->driver_data;
+
+ state->bg_videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, (offset & 0x0f) | ((offset >> 1) & 0x01f0));
}
WRITE8_HANDLER( c1942_palette_bank_w )
{
- if (c1942_palette_bank != data)
+ _1942_state *state = (_1942_state *)space->machine->driver_data;
+
+ if (state->palette_bank != data)
{
- c1942_palette_bank = data;
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ state->palette_bank = data;
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
}
WRITE8_HANDLER( c1942_scroll_w )
{
- static UINT8 scroll[2];
+ _1942_state *state = (_1942_state *)space->machine->driver_data;
- scroll[offset] = data;
- tilemap_set_scrollx(bg_tilemap,0,scroll[0] | (scroll[1] << 8));
+ state->scroll[offset] = data;
+ tilemap_set_scrollx(state->bg_tilemap, 0, state->scroll[0] | (state->scroll[1] << 8));
}
@@ -197,22 +200,22 @@ WRITE8_HANDLER( c1942_c804_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 )
{
+ _1942_state *state = (_1942_state *)machine->driver_data;
int offs;
-
- for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
+ for (offs = spriteram_size - 4; offs >= 0; offs -= 4)
{
- int i,code,col,sx,sy,dir;
+ int i, code, col, sx, sy, dir;
-
- code = (spriteram[offs] & 0x7f) + 4*(spriteram[offs + 1] & 0x20)
- + 2*(spriteram[offs] & 0x80);
- col = spriteram[offs + 1] & 0x0f;
- sx = spriteram[offs + 3] - 0x10 * (spriteram[offs + 1] & 0x10);
- sy = spriteram[offs + 2];
+ code = (state->spriteram[offs] & 0x7f) + 4 * (state->spriteram[offs + 1] & 0x20)
+ + 2 * (state->spriteram[offs] & 0x80);
+ col = state->spriteram[offs + 1] & 0x0f;
+ sx = state->spriteram[offs + 3] - 0x10 * (state->spriteram[offs + 1] & 0x10);
+ sy = state->spriteram[offs + 2];
dir = 1;
+
if (flip_screen_get(machine))
{
sx = 240 - sx;
@@ -221,8 +224,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
}
/* handle double / quadruple height */
- i = (spriteram[offs + 1] & 0xc0) >> 6;
- if (i == 2) i = 3;
+ i = (state->spriteram[offs + 1] & 0xc0) >> 6;
+ if (i == 2)
+ i = 3;
do
{
@@ -240,8 +244,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
VIDEO_UPDATE( 1942 )
{
- tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
- draw_sprites(screen->machine,bitmap,cliprect);
- tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
+ _1942_state *state = (_1942_state *)screen->machine->driver_data;
+
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
+ draw_sprites(screen->machine, bitmap, cliprect);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
diff --git a/src/mame/video/1943.c b/src/mame/video/1943.c
index f22ca7de0f0..c903ac281b0 100644
--- a/src/mame/video/1943.c
+++ b/src/mame/video/1943.c
@@ -28,14 +28,7 @@ other 2 bits (output & 0x0c) unknown
***************************************************************************/
#include "driver.h"
-
-UINT8 *c1943_scrollx;
-UINT8 *c1943_scrolly;
-UINT8 *c1943_bgscrollx;
-
-static int chon, objon, sc1on, sc2on;
-
-static tilemap *bg2_tilemap, *bg_tilemap, *fg_tilemap;
+#include "1943.h"
/***************************************************************************
@@ -127,28 +120,33 @@ PALETTE_INIT( 1943 )
WRITE8_HANDLER( c1943_videoram_w )
{
- videoram[offset] = data;
- tilemap_mark_tile_dirty(fg_tilemap, offset);
+ _1943_state *state = (_1943_state *)space->machine->driver_data;
+
+ state->videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->fg_tilemap, offset);
}
WRITE8_HANDLER( c1943_colorram_w )
{
- colorram[offset] = data;
- tilemap_mark_tile_dirty(fg_tilemap, offset);
+ _1943_state *state = (_1943_state *)space->machine->driver_data;
+
+ state->colorram[offset] = data;
+ tilemap_mark_tile_dirty(state->fg_tilemap, offset);
}
WRITE8_HANDLER( c1943_c804_w )
{
- int bankaddress;
- UINT8 *RAM = memory_region(space->machine, "maincpu");
+ _1943_state *state = (_1943_state *)space->machine->driver_data;
+ int bank, i;
/* bits 0 and 1 are coin counters */
coin_counter_w(0, data & 0x01);
coin_counter_w(1, data & 0x02);
/* bits 2, 3 and 4 select the ROM bank */
- bankaddress = 0x10000 + (data & 0x1c) * 0x1000;
- memory_set_bankptr(space->machine, 1, &RAM[bankaddress]);
+ bank = data & 0x1c;
+ for (i = 1; i < 5; i++)
+ memory_set_bank(space->machine, i, bank);
/* bit 5 resets the sound CPU - we ignore it */
@@ -156,19 +154,21 @@ WRITE8_HANDLER( c1943_c804_w )
flip_screen_set(space->machine, data & 0x40);
/* bit 7 enables characters */
- chon = data & 0x80;
+ state->char_on = data & 0x80;
}
WRITE8_HANDLER( c1943_d806_w )
{
+ _1943_state *state = (_1943_state *)space->machine->driver_data;
+
/* bit 4 enables bg 1 */
- sc1on = data & 0x10;
+ state->bg1_on = data & 0x10;
/* bit 5 enables bg 2 */
- sc2on = data & 0x20;
+ state->bg2_on = data & 0x20;
/* bit 6 enables sprites */
- objon = data & 0x40;
+ state->obj_on = data & 0x40;
}
static TILE_GET_INFO( c1943_get_bg2_tile_info )
@@ -200,8 +200,9 @@ static TILE_GET_INFO( c1943_get_bg_tile_info )
static TILE_GET_INFO( c1943_get_fg_tile_info )
{
- int attr = colorram[tile_index];
- int code = videoram[tile_index] + ((attr & 0xe0) << 3);
+ _1943_state *state = (_1943_state *)machine->driver_data;
+ int attr = state->colorram[tile_index];
+ int code = state->videoram[tile_index] + ((attr & 0xe0) << 3);
int color = attr & 0x1f;
SET_TILE_INFO(0, code, color, 0);
@@ -209,35 +210,32 @@ static TILE_GET_INFO( c1943_get_fg_tile_info )
VIDEO_START( 1943 )
{
- bg2_tilemap = tilemap_create(machine, c1943_get_bg2_tile_info, tilemap_scan_cols,
- 32, 32, 2048, 8);
-
- bg_tilemap = tilemap_create(machine, c1943_get_bg_tile_info, tilemap_scan_cols,
- 32, 32, 2048, 8);
-
- fg_tilemap = tilemap_create(machine, c1943_get_fg_tile_info, tilemap_scan_rows,
- 8, 8, 32, 32);
-
- colortable_configure_tilemap_groups(machine->colortable, bg_tilemap, machine->gfx[1], 0x0f);
- tilemap_set_transparent_pen(fg_tilemap, 0);
-
- state_save_register_global(machine, chon);
- state_save_register_global(machine, objon);
- state_save_register_global(machine, sc1on);
- state_save_register_global(machine, sc2on);
+ _1943_state *state = (_1943_state *)machine->driver_data;
+ state->bg2_tilemap = tilemap_create(machine, c1943_get_bg2_tile_info, tilemap_scan_cols, 32, 32, 2048, 8);
+ state->bg_tilemap = tilemap_create(machine, c1943_get_bg_tile_info, tilemap_scan_cols, 32, 32, 2048, 8);
+ state->fg_tilemap = tilemap_create(machine, c1943_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+
+ colortable_configure_tilemap_groups(machine->colortable, state->bg_tilemap, machine->gfx[1], 0x0f);
+ tilemap_set_transparent_pen(state->fg_tilemap, 0);
+
+ state_save_register_global(machine, state->char_on);
+ state_save_register_global(machine, state->obj_on);
+ state_save_register_global(machine, state->bg1_on);
+ state_save_register_global(machine, state->bg2_on);
}
-static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority)
+static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority )
{
+ _1943_state *state = (_1943_state *)machine->driver_data;
int offs;
for (offs = spriteram_size - 32; offs >= 0; offs -= 32)
{
- int attr = spriteram[offs + 1];
- int code = spriteram[offs] + ((attr & 0xe0) << 3);
+ int attr = state->spriteram[offs + 1];
+ int code = state->spriteram[offs] + ((attr & 0xe0) << 3);
int color = attr & 0x0f;
- int sx = spriteram[offs + 3] - ((attr & 0x10) << 4);
- int sy = spriteram[offs + 2];
+ int sx = state->spriteram[offs + 3] - ((attr & 0x10) << 4);
+ int sy = state->spriteram[offs + 2];
if (flip_screen_get(machine))
{
@@ -249,36 +247,39 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
if (priority)
{
if (color != 0x0a && color != 0x0b)
- {
- drawgfx_transpen(bitmap, cliprect, machine->gfx[3], code, color, flip_screen_get(machine), flip_screen_get(machine),
- sx, sy, 0);
- }
+ drawgfx_transpen(bitmap, cliprect, machine->gfx[3], code, color, flip_screen_get(machine), flip_screen_get(machine), sx, sy, 0);
}
else
{
if (color == 0x0a || color == 0x0b)
- {
- drawgfx_transpen(bitmap, cliprect, machine->gfx[3], code, color, flip_screen_get(machine), flip_screen_get(machine),
- sx, sy, 0);
- }
+ drawgfx_transpen(bitmap, cliprect, machine->gfx[3], code, color, flip_screen_get(machine), flip_screen_get(machine), sx, sy, 0);
}
}
}
VIDEO_UPDATE( 1943 )
{
- tilemap_set_scrollx(bg2_tilemap, 0, c1943_bgscrollx[0] + 256 * c1943_bgscrollx[1]);
- tilemap_set_scrollx(bg_tilemap, 0, c1943_scrollx[0] + 256 * c1943_scrollx[1]);
- tilemap_set_scrolly(bg_tilemap, 0, c1943_scrolly[0]);
+ _1943_state *state = (_1943_state *)screen->machine->driver_data;
+ tilemap_set_scrollx(state->bg2_tilemap, 0, state->bgscrollx[0] + 256 * state->bgscrollx[1]);
+ tilemap_set_scrollx(state->bg_tilemap, 0, state->scrollx[0] + 256 * state->scrollx[1]);
+ tilemap_set_scrolly(state->bg_tilemap, 0, state->scrolly[0]);
- if (sc2on)
- tilemap_draw(bitmap, cliprect, bg2_tilemap, 0, 0);
+ if (state->bg2_on)
+ tilemap_draw(bitmap, cliprect, state->bg2_tilemap, 0, 0);
else
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
- if (objon) draw_sprites(screen->machine, bitmap, cliprect, 0);
- if (sc1on) tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
- if (objon) draw_sprites(screen->machine, bitmap, cliprect, 1);
- if (chon) tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
+ if (state->obj_on)
+ draw_sprites(screen->machine, bitmap, cliprect, 0);
+
+ if (state->bg1_on)
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
+
+ if (state->obj_on)
+ draw_sprites(screen->machine, bitmap, cliprect, 1);
+
+ if (state->char_on)
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
+
return 0;
}