summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2009-12-10 14:22:37 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2009-12-10 14:22:37 +0000
commit4a396461b3ae2ca2ad8b752f29c5e3035691f2d8 (patch)
tree486a36c6948c5248edcb7f7d481b910cc9f4b99b
parentc0488dbe0d434c3bc74c3e07f5033cfceb0fb11a (diff)
Added driver data struct and save states to the following drivers:
ladybug.c, ladyfrog.c, lastduel.c, lwings.c, redclash.c and yunsung8.c
-rw-r--r--.gitattributes4
-rw-r--r--src/mame/drivers/ladybug.c178
-rw-r--r--src/mame/drivers/ladyfrog.c116
-rw-r--r--src/mame/drivers/lastduel.c461
-rw-r--r--src/mame/drivers/lwings.c205
-rw-r--r--src/mame/drivers/redclash.c106
-rw-r--r--src/mame/drivers/yunsung8.c205
-rw-r--r--src/mame/includes/ladybug.h78
-rw-r--r--src/mame/includes/ladyfrog.h49
-rw-r--r--src/mame/includes/lastduel.h41
-rw-r--r--src/mame/includes/lwings.h30
-rw-r--r--src/mame/includes/yunsung8.h36
-rw-r--r--src/mame/video/ladybug.c182
-rw-r--r--src/mame/video/ladyfrog.c124
-rw-r--r--src/mame/video/lastduel.c213
-rw-r--r--src/mame/video/lwings.c148
-rw-r--r--src/mame/video/redclash.c160
-rw-r--r--src/mame/video/yunsung8.c99
18 files changed, 1448 insertions, 987 deletions
diff --git a/.gitattributes b/.gitattributes
index ee546012473..abbf62f1038 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2528,7 +2528,10 @@ src/mame/includes/konamipt.h svneol=native#text/plain
src/mame/includes/kopunch.h svneol=native#text/plain
src/mame/includes/ksayakyu.h svneol=native#text/plain
src/mame/includes/kyugo.h svneol=native#text/plain
+src/mame/includes/ladybug.h svneol=native#text/plain
+src/mame/includes/ladyfrog.h svneol=native#text/plain
src/mame/includes/lasso.h svneol=native#text/plain
+src/mame/includes/lastduel.h svneol=native#text/plain
src/mame/includes/lazercmd.h svneol=native#text/plain
src/mame/includes/legionna.h svneol=native#text/plain
src/mame/includes/leland.h svneol=native#text/plain
@@ -2707,6 +2710,7 @@ src/mame/includes/wwfwfest.h svneol=native#text/plain
src/mame/includes/xmen.h svneol=native#text/plain
src/mame/includes/xybots.h svneol=native#text/plain
src/mame/includes/yunsun16.h svneol=native#text/plain
+src/mame/includes/yunsung8.h svneol=native#text/plain
src/mame/includes/zaxxon.h svneol=native#text/plain
src/mame/includes/zerozone.h svneol=native#text/plain
src/mame/layout/280zzzap.lay svneol=native#text/plain
diff --git a/src/mame/drivers/ladybug.c b/src/mame/drivers/ladybug.c
index 21c9d5b029c..6fdd8ff0696 100644
--- a/src/mame/drivers/ladybug.c
+++ b/src/mame/drivers/ladybug.c
@@ -61,36 +61,78 @@ TODO:
#include "driver.h"
#include "cpu/z80/z80.h"
#include "sound/sn76496.h"
+#include "includes/ladybug.h"
-extern UINT8 *sraider_grid_data;
+/* Sound comm between CPU's */
+static READ8_HANDLER( sraider_sound_low_r )
+{
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+ return state->sound_low;
+}
-WRITE8_HANDLER( ladybug_videoram_w );
-WRITE8_HANDLER( ladybug_colorram_w );
-WRITE8_HANDLER( ladybug_flipscreen_w );
+static READ8_HANDLER( sraider_sound_high_r )
+{
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+ return state->sound_high;
+}
-PALETTE_INIT( ladybug );
-VIDEO_START( ladybug );
-VIDEO_UPDATE( ladybug );
+static WRITE8_HANDLER( sraider_sound_low_w )
+{
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+ state->sound_low = data;
+}
-PALETTE_INIT( sraider );
-VIDEO_START( sraider );
-VIDEO_UPDATE( sraider );
-VIDEO_EOF( sraider );
+static WRITE8_HANDLER( sraider_sound_high_w )
+{
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+ state->sound_high = data;
+}
-READ8_HANDLER( sraider_8005_r );
-WRITE8_HANDLER( sraider_sound_low_w );
-WRITE8_HANDLER( sraider_sound_high_w );
-READ8_HANDLER( sraider_sound_low_r );
-READ8_HANDLER( sraider_sound_high_r );
-WRITE8_HANDLER( sraider_io_w );
-WRITE8_HANDLER( sraider_misc_w );
+/* Protection? */
+static READ8_HANDLER( sraider_8005_r )
+{
+ /* This must return X011111X or cpu #1 will hang */
+ /* see code at rst $10 */
+ return 0x3e;
+}
+/* Unknown IO */
+static WRITE8_HANDLER( sraider_misc_w )
+{
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+
+ switch(offset)
+ {
+ /* These 8 bits are stored in the latch at A7 */
+ case 0x00:
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ state->weird_value[offset & 7] = data & 1;
+ break;
+ /* These 6 bits are stored in the latch at N7 */
+ case 0x08:
+ state->sraider_0x30 = data&0x3f;
+ break;
+ /* These 6 bits are stored in the latch at N8 */
+ case 0x10:
+ state->sraider_0x38 = data&0x3f;
+ break;
+ default:
+ mame_printf_debug("(%04X) write to %02X\n", cpu_get_pc(space->cpu), offset);
+ break;
+ }
+}
static ADDRESS_MAP_START( ladybug_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0x6000, 0x6fff) AM_RAM
- AM_RANGE(0x7000, 0x73ff) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram)
+ AM_RANGE(0x7000, 0x73ff) AM_WRITEONLY AM_BASE_SIZE_MEMBER(ladybug_state, spriteram, spriteram_size)
AM_RANGE(0x8000, 0x8fff) AM_READNOP
AM_RANGE(0x9000, 0x9000) AM_READ_PORT("IN0")
AM_RANGE(0x9001, 0x9001) AM_READ_PORT("IN1")
@@ -99,8 +141,8 @@ static ADDRESS_MAP_START( ladybug_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xa000, 0xa000) AM_WRITE(ladybug_flipscreen_w)
AM_RANGE(0xb000, 0xbfff) AM_DEVWRITE("sn1", sn76496_w)
AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("sn2", sn76496_w)
- AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(ladybug_videoram_w) AM_BASE_GENERIC(videoram)
- AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(ladybug_colorram_w) AM_BASE_GENERIC(colorram)
+ AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(ladybug_videoram_w) AM_BASE_MEMBER(ladybug_state, videoram)
+ AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(ladybug_colorram_w) AM_BASE_MEMBER(ladybug_state, colorram)
AM_RANGE(0xe000, 0xe000) AM_READ_PORT("IN2")
ADDRESS_MAP_END
@@ -108,7 +150,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( sraider_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0x6000, 0x6fff) AM_RAM
- AM_RANGE(0x7000, 0x73ff) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram)
+ AM_RANGE(0x7000, 0x73ff) AM_WRITEONLY AM_BASE_SIZE_MEMBER(ladybug_state, spriteram, spriteram_size)
AM_RANGE(0x8005, 0x8005) AM_READ(sraider_8005_r) // protection check?
AM_RANGE(0x8006, 0x8006) AM_WRITE(sraider_sound_low_w)
AM_RANGE(0x8007, 0x8007) AM_WRITE(sraider_sound_high_w)
@@ -116,8 +158,8 @@ static ADDRESS_MAP_START( sraider_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x9001, 0x9001) AM_READ_PORT("IN1")
AM_RANGE(0x9002, 0x9002) AM_READ_PORT("DSW0")
AM_RANGE(0x9003, 0x9003) AM_READ_PORT("DSW1")
- AM_RANGE(0xd000, 0xd3ff) AM_WRITE(ladybug_videoram_w) AM_BASE_GENERIC(videoram)
- AM_RANGE(0xd400, 0xd7ff) AM_WRITE(ladybug_colorram_w) AM_BASE_GENERIC(colorram)
+ AM_RANGE(0xd000, 0xd3ff) AM_WRITE(ladybug_videoram_w) AM_BASE_MEMBER(ladybug_state, videoram)
+ AM_RANGE(0xd400, 0xd7ff) AM_WRITE(ladybug_colorram_w) AM_BASE_MEMBER(ladybug_state, colorram)
AM_RANGE(0xe000, 0xe000) AM_WRITENOP //unknown 0x10 when in attract, 0x20 when coined/playing
ADDRESS_MAP_END
@@ -128,7 +170,7 @@ static ADDRESS_MAP_START( sraider_cpu2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0x8000) AM_READ(sraider_sound_low_r)
AM_RANGE(0xa000, 0xa000) AM_READ(sraider_sound_high_r)
AM_RANGE(0xc000, 0xc000) AM_READNOP //some kind of sync
- AM_RANGE(0xe000, 0xe0ff) AM_WRITEONLY AM_BASE(&sraider_grid_data)
+ AM_RANGE(0xe000, 0xe0ff) AM_WRITEONLY AM_BASE_MEMBER(ladybug_state, grid_data)
AM_RANGE(0xe800, 0xe800) AM_WRITE(sraider_io_w)
ADDRESS_MAP_END
@@ -147,15 +189,19 @@ ADDRESS_MAP_END
static INPUT_CHANGED( coin1_inserted )
{
+ ladybug_state *state = (ladybug_state *)field->port->machine->driver_data;
+
/* left coin insertion causes an NMI */
- cputag_set_input_line(field->port->machine, "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
+ cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
}
static INPUT_CHANGED( coin2_inserted )
{
+ ladybug_state *state = (ladybug_state *)field->port->machine->driver_data;
+
/* right coin insertion causes an IRQ */
if (newval)
- cputag_set_input_line(field->port->machine, "maincpu", 0, HOLD_LINE);
+ cpu_set_input_line(state->maincpu, 0, HOLD_LINE);
}
@@ -676,12 +722,68 @@ static GFXDECODE_START( sraider )
GFXDECODE_END
+static MACHINE_START( ladybug )
+{
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ state->maincpu = devtag_get_device(machine, "maincpu");
+}
+
+static MACHINE_START( sraider )
+{
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+
+ state->maincpu = devtag_get_device(machine, "maincpu");
+
+ state_save_register_global(machine, state->grid_color);
+ state_save_register_global(machine, state->sound_low);
+ state_save_register_global(machine, state->sound_high);
+ state_save_register_global(machine, state->sraider_0x30);
+ state_save_register_global(machine, state->sraider_0x38);
+ state_save_register_global_array(machine, state->weird_value);
+
+ /* for stars */
+ state_save_register_global(machine, state->star_speed);
+ state_save_register_global(machine, state->stars_enable);
+ state_save_register_global(machine, state->stars_speed);
+ state_save_register_global(machine, state->stars_state);
+ state_save_register_global(machine, state->stars_offset);
+ state_save_register_global(machine, state->stars_count);
+}
+
+static MACHINE_RESET( sraider )
+{
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ int i;
+
+ state->grid_color = 0;
+ state->sound_low = 0;
+ state->sound_high = 0;
+ state->sraider_0x30 = 0;
+ state->sraider_0x38 = 0;
+
+ /* for stars */
+ state->star_speed = 0;
+ state->stars_enable = 0;
+ state->stars_speed = 0;
+ state->stars_state = 0;
+ state->stars_offset = 0;
+ state->stars_count = 0;
+
+ for (i = 0; i < 8; i++)
+ state->weird_value[i] = 0;
+}
+
static MACHINE_DRIVER_START( ladybug )
+ /* driver data */
+ MDRV_DRIVER_DATA(ladybug_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */
MDRV_CPU_PROGRAM_MAP(ladybug_map)
+ MDRV_MACHINE_START(ladybug)
+
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@@ -710,6 +812,9 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( sraider )
+ /* driver data */
+ MDRV_DRIVER_DATA(ladybug_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */
MDRV_CPU_PROGRAM_MAP(sraider_cpu1_map)
@@ -720,6 +825,9 @@ static MACHINE_DRIVER_START( sraider )
MDRV_CPU_IO_MAP(sraider_cpu2_io_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
+ MDRV_MACHINE_START(sraider)
+ MDRV_MACHINE_RESET(sraider)
+
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@@ -972,11 +1080,11 @@ static DRIVER_INIT( dorodon )
}
-GAME( 1981, cavenger, 0, ladybug, cavenger, 0, ROT0, "Universal", "Cosmic Avenger", 0 )
-GAME( 1981, ladybug, 0, ladybug, ladybug, 0, ROT270, "Universal", "Lady Bug", 0 )
-GAME( 1981, ladybugb, ladybug, ladybug, ladybug, 0, ROT270, "bootleg", "Lady Bug (bootleg set 1)", 0 )
-GAME( 1981, ladybgb2, ladybug, ladybug, ladybug, 0, ROT270, "bootleg", "Lady Bug (bootleg set 2)", 0 )
-GAME( 1982, dorodon, 0, ladybug, dorodon, dorodon, ROT270, "Falcon", "Dorodon (set 1)", 0 )
-GAME( 1982, dorodon2, dorodon, ladybug, dorodon, dorodon, ROT270, "Falcon", "Dorodon (set 2)", 0 )
-GAME( 1982, snapjack, 0, ladybug, snapjack, 0, ROT0, "Universal", "Snap Jack", 0 )
-GAME( 1982, sraider, 0, sraider, sraider, 0, ROT270, "Universal", "Space Raider", 0 )
+GAME( 1981, cavenger, 0, ladybug, cavenger, 0, ROT0, "Universal", "Cosmic Avenger", GAME_SUPPORTS_SAVE )
+GAME( 1981, ladybug, 0, ladybug, ladybug, 0, ROT270, "Universal", "Lady Bug", GAME_SUPPORTS_SAVE )
+GAME( 1981, ladybugb, ladybug, ladybug, ladybug, 0, ROT270, "bootleg", "Lady Bug (bootleg set 1)", GAME_SUPPORTS_SAVE )
+GAME( 1981, ladybgb2, ladybug, ladybug, ladybug, 0, ROT270, "bootleg", "Lady Bug (bootleg set 2)", GAME_SUPPORTS_SAVE )
+GAME( 1982, dorodon, 0, ladybug, dorodon, dorodon, ROT270, "Falcon", "Dorodon (set 1)", GAME_SUPPORTS_SAVE )
+GAME( 1982, dorodon2, dorodon, ladybug, dorodon, dorodon, ROT270, "Falcon", "Dorodon (set 2)", GAME_SUPPORTS_SAVE )
+GAME( 1982, snapjack, 0, ladybug, snapjack, 0, ROT0, "Universal", "Snap Jack", GAME_SUPPORTS_SAVE )
+GAME( 1982, sraider, 0, sraider, sraider, 0, ROT270, "Universal", "Space Raider", GAME_SUPPORTS_SAVE )
diff --git a/src/mame/drivers/ladyfrog.c b/src/mame/drivers/ladyfrog.c
index 6b6321dc169..1466768d4a1 100644
--- a/src/mame/drivers/ladyfrog.c
+++ b/src/mame/drivers/ladyfrog.c
@@ -51,50 +51,37 @@ Notes:
#include "deprecat.h"
#include "sound/ay8910.h"
#include "sound/msm5232.h"
+#include "includes/ladyfrog.h"
-VIDEO_START( ladyfrog );
-VIDEO_START( toucheme );
-VIDEO_UPDATE( ladyfrog );
-
-extern UINT8 *ladyfrog_scrlram;
-static int sound_nmi_enable=0,pending_nmi=0;
-static int snd_flag;
-static UINT8 snd_data;
-
-WRITE8_HANDLER( ladyfrog_videoram_w );
-WRITE8_HANDLER( ladyfrog_spriteram_w );
-WRITE8_HANDLER( ladyfrog_palette_w );
-WRITE8_HANDLER( ladyfrog_gfxctrl_w );
-WRITE8_HANDLER( ladyfrog_gfxctrl2_w );
-WRITE8_HANDLER( ladyfrog_scrlram_w );
-
-READ8_HANDLER( ladyfrog_spriteram_r );
-READ8_HANDLER( ladyfrog_palette_r );
-READ8_HANDLER( ladyfrog_scrlram_r );
-READ8_HANDLER( ladyfrog_videoram_r );
static READ8_HANDLER( from_snd_r )
{
- snd_flag=0;
- return snd_data;
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ state->snd_flag = 0;
+ return state->snd_data;
}
static WRITE8_HANDLER( to_main_w )
{
- snd_data = data;
- snd_flag = 2;
-
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ state->snd_data = data;
+ state->snd_flag = 2;
}
static WRITE8_HANDLER( sound_cpu_reset_w )
{
- cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (data & 1 ) ? ASSERT_LINE : CLEAR_LINE);
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ cpu_set_input_line(state->audiocpu, INPUT_LINE_RESET, (data & 1 ) ? ASSERT_LINE : CLEAR_LINE);
}
static TIMER_CALLBACK( nmi_callback )
{
- if (sound_nmi_enable) cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
- else pending_nmi = 1;
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
+
+ if (state->sound_nmi_enable)
+ cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
+ else
+ state->pending_nmi = 1;
}
static WRITE8_HANDLER( sound_command_w )
@@ -105,16 +92,19 @@ static WRITE8_HANDLER( sound_command_w )
static WRITE8_HANDLER( nmi_disable_w )
{
- sound_nmi_enable = 0;
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ state->sound_nmi_enable = 0;
}
static WRITE8_HANDLER( nmi_enable_w )
{
- sound_nmi_enable = 1;
- if (pending_nmi)
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+
+ state->sound_nmi_enable = 1;
+ if (state->pending_nmi)
{
- cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
- pending_nmi = 0;
+ cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
+ state->pending_nmi = 0;
}
}
@@ -140,25 +130,26 @@ static const msm5232_interface msm5232_config =
static READ8_HANDLER( snd_flag_r )
{
- return snd_flag | 0xfd;
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ return state->snd_flag | 0xfd;
}
static ADDRESS_MAP_START( ladyfrog_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc07f) AM_RAM
- AM_RANGE(0xc080, 0xc87f) AM_READ(ladyfrog_videoram_r) AM_WRITE(ladyfrog_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
+ AM_RANGE(0xc080, 0xc87f) AM_READWRITE(ladyfrog_videoram_r, ladyfrog_videoram_w) AM_BASE_SIZE_MEMBER(ladyfrog_state, videoram, videoram_size)
AM_RANGE(0xd000, 0xd000) AM_WRITE(ladyfrog_gfxctrl2_w)
- AM_RANGE(0xd400, 0xd400) AM_READ(from_snd_r) AM_WRITE(sound_command_w)
+ AM_RANGE(0xd400, 0xd400) AM_READWRITE(from_snd_r, sound_command_w)
AM_RANGE(0xd401, 0xd401) AM_READ(snd_flag_r)
AM_RANGE(0xd403, 0xd403) AM_WRITE(sound_cpu_reset_w)
AM_RANGE(0xd800, 0xd800) AM_READ_PORT("DSW1")
AM_RANGE(0xd801, 0xd801) AM_READ_PORT("DSW2")
AM_RANGE(0xd804, 0xd804) AM_READ_PORT("INPUTS")
AM_RANGE(0xd806, 0xd806) AM_READ_PORT("SYSTEM")
- AM_RANGE(0xdc00, 0xdc9f) AM_READ(ladyfrog_spriteram_r) AM_WRITE(ladyfrog_spriteram_w)
- AM_RANGE(0xdca0, 0xdcbf) AM_READ(ladyfrog_scrlram_r) AM_WRITE(ladyfrog_scrlram_w) AM_BASE(&ladyfrog_scrlram)
+ AM_RANGE(0xdc00, 0xdc9f) AM_READWRITE(ladyfrog_spriteram_r,ladyfrog_spriteram_w)
+ AM_RANGE(0xdca0, 0xdcbf) AM_READWRITE(ladyfrog_scrlram_r, ladyfrog_scrlram_w) AM_BASE_MEMBER(ladyfrog_state, scrlram)
AM_RANGE(0xdcc0, 0xdcff) AM_RAM
- AM_RANGE(0xdd00, 0xdeff) AM_READ(ladyfrog_palette_r) AM_WRITE(ladyfrog_palette_w)
+ AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(ladyfrog_palette_r, ladyfrog_palette_w)
AM_RANGE(0xd0d0, 0xd0d0) AM_READNOP /* code jumps to ASCII text "Alfa tecnology" @ $b7 */
AM_RANGE(0xdf03, 0xdf03) AM_WRITE(ladyfrog_gfxctrl_w)
AM_RANGE(0xe000, 0xffff) AM_RAM
@@ -173,7 +164,7 @@ static ADDRESS_MAP_START( ladyfrog_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xca00, 0xca00) AM_WRITENOP
AM_RANGE(0xcb00, 0xcb00) AM_WRITENOP
AM_RANGE(0xcc00, 0xcc00) AM_WRITENOP
- AM_RANGE(0xd000, 0xd000) AM_READ(soundlatch_r) AM_WRITE(to_main_w)
+ AM_RANGE(0xd000, 0xd000) AM_READWRITE(soundlatch_r,to_main_w)
AM_RANGE(0xd200, 0xd200) AM_READNOP AM_WRITE(nmi_enable_w)
AM_RANGE(0xd400, 0xd400) AM_WRITE(nmi_disable_w)
AM_RANGE(0xd600, 0xd600) AM_WRITENOP
@@ -291,7 +282,39 @@ static GFXDECODE_START( ladyfrog )
GFXDECODE_ENTRY( "gfx1", 0, spritelayout, 256, 16 )
GFXDECODE_END
+
+static MACHINE_START( ladyfrog )
+{
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
+
+ state->audiocpu = devtag_get_device(machine, "audiocpu");
+
+ state_save_register_global(machine, state->tilebank);
+ state_save_register_global(machine, state->palette_bank);
+ state_save_register_global(machine, state->sound_nmi_enable);
+ state_save_register_global(machine, state->pending_nmi);
+ state_save_register_global(machine, state->snd_flag);
+ state_save_register_global(machine, state->snd_data);
+}
+
+static MACHINE_RESET( ladyfrog )
+{
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
+
+ state->tilebank = 0;
+ state->palette_bank = 0;
+ state->sound_nmi_enable = 0;
+ state->pending_nmi = 0;
+ state->snd_flag = 0;
+ state->snd_data = 0;
+}
+
static MACHINE_DRIVER_START( ladyfrog )
+
+ /* driver data */
+ MDRV_DRIVER_DATA(ladyfrog_state)
+
+ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,8000000/2)
MDRV_CPU_PROGRAM_MAP(ladyfrog_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
@@ -300,10 +323,12 @@ static MACHINE_DRIVER_START( ladyfrog )
MDRV_CPU_PROGRAM_MAP(ladyfrog_sound_map)
MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,2)
- /* video hardware */
- MDRV_QUANTUM_TIME(HZ(6000))
+ MDRV_MACHINE_START(ladyfrog)
+ MDRV_MACHINE_RESET(ladyfrog)
+ MDRV_QUANTUM_TIME(HZ(6000))
+ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
@@ -311,7 +336,6 @@ static MACHINE_DRIVER_START( ladyfrog )
MDRV_SCREEN_SIZE(32*8, 32*8)
MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 29*8-1) // black borders in ladyfrog gameplay are correct
-
MDRV_GFXDECODE(ladyfrog)
MDRV_PALETTE_LENGTH(512)
@@ -378,5 +402,7 @@ ROM_START( toucheme )
ROM_LOAD( "8.ic10", 0x20000, 0x10000, CRC(fc6808bf) SHA1(f1f1b75a79dfdb500012f9b52c6364f0a13dce2d) )
ROM_END
-GAME( 1990, ladyfrog, 0, ladyfrog, ladyfrog, 0, ORIENTATION_SWAP_XY, "Mondial Games", "Lady Frog", 0)
-GAME( 19??, toucheme, 0, toucheme, toucheme, 0, ORIENTATION_SWAP_XY, "Unknown", "Touche Me", 0) // art style is similar, so it's probably the same manufacturer
+GAME( 1990, ladyfrog, 0, ladyfrog, ladyfrog, 0, ORIENTATION_SWAP_XY, "Mondial Games", "Lady Frog", GAME_SUPPORTS_SAVE )
+
+// toucheme art style is similar to ladyfrog, so it's probably the same manufacturer
+GAME( 19??, toucheme, 0, toucheme, toucheme, 0, ORIENTATION_SWAP_XY, "<unknown>", "Touche Me", GAME_SUPPORTS_SAVE )
diff --git a/src/mame/drivers/lastduel.c b/src/mame/drivers/lastduel.c
index 9820ed00135..dfb69f61025 100644
--- a/src/mame/drivers/lastduel.c
+++ b/src/mame/drivers/lastduel.c
@@ -120,29 +120,15 @@ Notes:
#include "deprecat.h"
#include "sound/2203intf.h"
#include "sound/okim6295.h"
+#include "includes/lastduel.h"
-WRITE16_HANDLER( lastduel_vram_w );
-WRITE16_HANDLER( lastduel_flip_w );
-WRITE16_HANDLER( lastduel_scroll1_w );
-WRITE16_HANDLER( lastduel_scroll2_w );
-WRITE16_HANDLER( madgear_scroll1_w );
-WRITE16_HANDLER( madgear_scroll2_w );
-WRITE16_HANDLER( lastduel_scroll_w );
-WRITE16_HANDLER( lastduel_palette_word_w );
-VIDEO_START( lastduel );
-VIDEO_START( madgear );
-VIDEO_UPDATE( lastduel );
-VIDEO_UPDATE( madgear );
-VIDEO_EOF( lastduel );
-
-extern UINT16 *lastduel_vram,*lastduel_scroll2,*lastduel_scroll1;
/******************************************************************************/
static WRITE16_HANDLER( lastduel_sound_w )
{
if (ACCESSING_BITS_0_7)
- soundlatch_w(space,0,data & 0xff);
+ soundlatch_w(space, 0, data & 0xff);
}
/******************************************************************************/
@@ -156,10 +142,10 @@ static ADDRESS_MAP_START( lastduel_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xfc4004, 0xfc4005) AM_READ_PORT("DSW1")
AM_RANGE(0xfc4006, 0xfc4007) AM_READ_PORT("DSW2")
AM_RANGE(0xfc8000, 0xfc800f) AM_WRITE(lastduel_scroll_w)
- AM_RANGE(0xfcc000, 0xfcdfff) AM_RAM_WRITE(lastduel_vram_w) AM_BASE(&lastduel_vram)
- AM_RANGE(0xfd0000, 0xfd3fff) AM_RAM_WRITE(lastduel_scroll1_w) AM_BASE(&lastduel_scroll1)
- AM_RANGE(0xfd4000, 0xfd7fff) AM_RAM_WRITE(lastduel_scroll2_w) AM_BASE(&lastduel_scroll2)
- AM_RANGE(0xfd8000, 0xfd87ff) AM_RAM_WRITE(lastduel_palette_word_w) AM_BASE_GENERIC(paletteram)
+ AM_RANGE(0xfcc000, 0xfcdfff) AM_RAM_WRITE(lastduel_vram_w) AM_BASE_MEMBER(lastduel_state, vram)
+ AM_RANGE(0xfd0000, 0xfd3fff) AM_RAM_WRITE(lastduel_scroll1_w) AM_BASE_MEMBER(lastduel_state, scroll1)
+ AM_RANGE(0xfd4000, 0xfd7fff) AM_RAM_WRITE(lastduel_scroll2_w) AM_BASE_MEMBER(lastduel_state, scroll2)
+ AM_RANGE(0xfd8000, 0xfd87ff) AM_RAM_WRITE(lastduel_palette_word_w) AM_BASE_MEMBER(lastduel_state, paletteram)
AM_RANGE(0xfe0000, 0xffffff) AM_RAM
ADDRESS_MAP_END
@@ -170,11 +156,11 @@ static ADDRESS_MAP_START( madgear_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xfc4002, 0xfc4003) AM_READ_PORT("DSW2") AM_WRITE(lastduel_sound_w)
AM_RANGE(0xfc4004, 0xfc4005) AM_READ_PORT("P1_P2")
AM_RANGE(0xfc4006, 0xfc4007) AM_READ_PORT("SYSTEM")
- AM_RANGE(0xfc8000, 0xfc9fff) AM_RAM_WRITE(lastduel_vram_w) AM_BASE(&lastduel_vram)
- AM_RANGE(0xfcc000, 0xfcc7ff) AM_RAM_WRITE(lastduel_palette_word_w) AM_BASE_GENERIC(paletteram)
+ AM_RANGE(0xfc8000, 0xfc9fff) AM_RAM_WRITE(lastduel_vram_w) AM_BASE_MEMBER(lastduel_state, vram)
+ AM_RANGE(0xfcc000, 0xfcc7ff) AM_RAM_WRITE(lastduel_palette_word_w) AM_BASE_MEMBER(lastduel_state, paletteram)
AM_RANGE(0xfd0000, 0xfd000f) AM_WRITE(lastduel_scroll_w)
- AM_RANGE(0xfd4000, 0xfd7fff) AM_RAM_WRITE(madgear_scroll1_w) AM_BASE(&lastduel_scroll1)
- AM_RANGE(0xfd8000, 0xfdffff) AM_RAM_WRITE(madgear_scroll2_w) AM_BASE(&lastduel_scroll2)
+ AM_RANGE(0xfd4000, 0xfd7fff) AM_RAM_WRITE(madgear_scroll1_w) AM_BASE_MEMBER(lastduel_state, scroll1)
+ AM_RANGE(0xfd8000, 0xfdffff) AM_RAM_WRITE(madgear_scroll2_w) AM_BASE_MEMBER(lastduel_state, scroll2)
AM_RANGE(0xff0000, 0xffffff) AM_RAM
ADDRESS_MAP_END
@@ -190,11 +176,7 @@ ADDRESS_MAP_END
static WRITE8_HANDLER( mg_bankswitch_w )
{
- int bankaddress;
- UINT8 *RAM = memory_region(space->machine, "audiocpu");
-
- bankaddress = 0x10000 + (data & 0x01) * 0x4000;
- memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
+ memory_set_bank(space->machine, "bank1", data & 0x01);
}
static ADDRESS_MAP_START( madgear_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
@@ -210,187 +192,6 @@ ADDRESS_MAP_END
/******************************************************************************/
-static const gfx_layout sprite_layout =
-{
- 16,16,
- RGN_FRAC(1,4),
- 4,
- { RGN_FRAC(0,4), RGN_FRAC(1,4), RGN_FRAC(2,4), RGN_FRAC(3,4) },
- { 0, 1, 2, 3, 4, 5, 6, 7,
- 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7 },
- { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
- 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
- 32*8
-};
-
-static const gfx_layout text_layout =
-{
- 8,8,
- RGN_FRAC(1,1),
- 2,
- { 4, 0 },
- { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3 },
- { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
- 16*8
-};
-
-static const gfx_layout madgear_tile =
-{
- 16,16,
- RGN_FRAC(1,1),
- 4,
- { 3*4, 2*4, 1*4, 0*4 },
- { 0, 1, 2, 3, 16+0, 16+1, 16+2, 16+3,
- 32*16+0, 32*16+1, 32*16+2, 32*16+3, 32*16+16+0, 32*16+16+1, 32*16+16+2, 32*16+16+3 },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
- 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
- 64*16
-};
-
-static const gfx_layout madgear_tile2 =
-{
- 16,16,
- RGN_FRAC(1,1),
- 4,
- { 1*4, 3*4, 0*4, 2*4 },
- { 0, 1, 2, 3, 16+0, 16+1, 16+2, 16+3,
- 32*16+0, 32*16+1, 32*16+2, 32*16+3, 32*16+16+0, 32*16+16+1, 32*16+16+2, 32*16+16+3 },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
- 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
- 64*16
-};
-
-static GFXDECODE_START( lastduel )
- GFXDECODE_ENTRY( "gfx1", 0,sprite_layout, 0x200, 16 ) /* colors 0x200-0x2ff */
- GFXDECODE_ENTRY( "gfx2", 0,text_layout, 0x300, 16 ) /* colors 0x300-0x33f */
- GFXDECODE_ENTRY( "gfx3", 0,madgear_tile, 0x000, 16 ) /* colors 0x000-0x0ff */
- GFXDECODE_ENTRY( "gfx4", 0,madgear_tile, 0x100, 16 ) /* colors 0x100-0x1ff */
-GFXDECODE_END
-
-static GFXDECODE_START( madgear )
- GFXDECODE_ENTRY( "gfx1", 0,sprite_layout, 0x200, 16 ) /* colors 0x200-0x2ff */
- GFXDECODE_ENTRY( "gfx2", 0,text_layout, 0x300, 16 ) /* colors 0x300-0x33f */
- GFXDECODE_ENTRY( "gfx3", 0,madgear_tile, 0x000, 16 ) /* colors 0x000-0x0ff */
- GFXDECODE_ENTRY( "gfx4", 0,madgear_tile2, 0x100, 16 ) /* colors 0x100-0x1ff */
-GFXDECODE_END
-
-/******************************************************************************/
-
-/* handler called by the 2203 emulator when the internal timers cause an IRQ */
-static void irqhandler(const device_config *device, int irq)
-{
- cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
-}
-
-static const ym2203_interface ym2203_config =
-{
- {
- AY8910_LEGACY_OUTPUT,
- AY8910_DEFAULT_LOADS,
- DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
- },
- irqhandler
-};
-
-static INTERRUPT_GEN( lastduel_interrupt )
-{
- if (cpu_getiloops(device) == 0)
- cpu_set_input_line(device, 2, HOLD_LINE); /* VBL */
- else
- cpu_set_input_line(device, 4, HOLD_LINE); /* Controls */
-}
-
-static INTERRUPT_GEN( madgear_interrupt )
-{
- if (cpu_getiloops(device) == 0)
- cpu_set_input_line(device, 5, HOLD_LINE); /* VBL */
- else
- cpu_set_input_line(device, 6, HOLD_LINE); /* Controls */
-}
-
-static MACHINE_DRIVER_START( lastduel )
-
- /* basic machine hardware */
- MDRV_CPU_ADD("maincpu", M68000, 10000000) /* Could be 8 MHz */
- MDRV_CPU_PROGRAM_MAP(lastduel_map)
- MDRV_CPU_VBLANK_INT_HACK(lastduel_interrupt,3) /* 1 for vbl, 2 for control reads?? */
-
- MDRV_CPU_ADD("audiocpu", Z80, 3579545) /* Accurate */
- MDRV_CPU_PROGRAM_MAP(sound_map)
-
- /* video hardware */
- MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_BUFFERS_SPRITERAM)
-
- MDRV_SCREEN_ADD("screen", RASTER)
- MDRV_SCREEN_REFRESH_RATE(60)
- MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
- MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
- MDRV_SCREEN_SIZE(64*8, 32*8)
- MDRV_SCREEN_VISIBLE_AREA(8*8, (64-8)*8-1, 1*8, 31*8-1 )
-
- MDRV_GFXDECODE(lastduel)
- MDRV_PALETTE_LENGTH(1024)
-
- MDRV_VIDEO_START(lastduel)
- MDRV_VIDEO_EOF(lastduel)
- MDRV_VIDEO_UPDATE(lastduel)
-
- /* sound hardware */
- MDRV_SPEAKER_STANDARD_MONO("mono")
-
- MDRV_SOUND_ADD("ym1", YM2203, 3579545)
- MDRV_SOUND_CONFIG(ym2203_config)
- MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
-
- MDRV_SOUND_ADD("ym2", YM2203, 3579545)
- MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
-MACHINE_DRIVER_END
-
-
-static MACHINE_DRIVER_START( madgear )
-
- /* basic machine hardware */
- MDRV_CPU_ADD("maincpu", M68000, 10000000) /* Accurate */
- MDRV_CPU_PROGRAM_MAP(madgear_map)
- MDRV_CPU_VBLANK_INT_HACK(madgear_interrupt,3) /* 1 for vbl, 2 for control reads?? */
-
- MDRV_CPU_ADD("audiocpu", Z80, XTAL_3_579545MHz) /* verified on pcb */
- MDRV_CPU_PROGRAM_MAP(madgear_sound_map)
-
- /* video hardware */
- MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_BUFFERS_SPRITERAM)
-
- MDRV_SCREEN_ADD("screen", RASTER)
- MDRV_SCREEN_REFRESH_RATE(60)
- MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
- MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
- MDRV_SCREEN_SIZE(64*8, 32*8)
- MDRV_SCREEN_VISIBLE_AREA(8*8, (64-8)*8-1, 1*8, 31*8-1 )
-
- MDRV_GFXDECODE(madgear)
- MDRV_PALETTE_LENGTH(1024)
-
- MDRV_VIDEO_START(madgear)
- MDRV_VIDEO_EOF(lastduel)
- MDRV_VIDEO_UPDATE(madgear)
-
- /* sound hardware */
- MDRV_SPEAKER_STANDARD_MONO("mono")
-
- MDRV_SOUND_ADD("ym1", YM2203, XTAL_3_579545MHz) /* verified on pcb */
- MDRV_SOUND_CONFIG(ym2203_config)
- MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
-
- MDRV_SOUND_ADD("ym2", YM2203, XTAL_3_579545MHz) /* verified on pcb */
- MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
-
- MDRV_SOUND_ADD("oki", OKIM6295, XTAL_10MHz/10)
- MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */
- MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.98)
-MACHINE_DRIVER_END
-
-/******************************************************************************/
-
static INPUT_PORTS_START( lastduel )
PORT_START("P1_P2")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
@@ -572,6 +373,230 @@ INPUT_PORTS_END
/******************************************************************************/
+static const gfx_layout sprite_layout =
+{
+ 16,16,
+ RGN_FRAC(1,4),
+ 4,
+ { RGN_FRAC(0,4), RGN_FRAC(1,4), RGN_FRAC(2,4), RGN_FRAC(3,4) },
+ { 0, 1, 2, 3, 4, 5, 6, 7,
+ 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7 },
+ { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
+ 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
+ 32*8
+};
+
+static const gfx_layout text_layout =
+{
+ 8,8,
+ RGN_FRAC(1,1),
+ 2,
+ { 4, 0 },
+ { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3 },
+ { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
+ 16*8
+};
+
+static const gfx_layout madgear_tile =
+{
+ 16,16,
+ RGN_FRAC(1,1),
+ 4,
+ { 3*4, 2*4, 1*4, 0*4 },
+ { 0, 1, 2, 3, 16+0, 16+1, 16+2, 16+3,
+ 32*16+0, 32*16+1, 32*16+2, 32*16+3, 32*16+16+0, 32*16+16+1, 32*16+16+2, 32*16+16+3 },
+ { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
+ 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
+ 64*16
+};
+
+static const gfx_layout madgear_tile2 =
+{
+ 16,16,
+ RGN_FRAC(1,1),
+ 4,
+ { 1*4, 3*4, 0*4, 2*4 },
+ { 0, 1, 2, 3, 16+0, 16+1, 16+2, 16+3,
+ 32*16+0, 32*16+1, 32*16+2, 32*16+3, 32*16+16+0, 32*16+16+1, 32*16+16+2, 32*16+16+3 },
+ { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
+ 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
+ 64*16
+};
+
+static GFXDECODE_START( lastduel )
+ GFXDECODE_ENTRY( "gfx1", 0, sprite_layout, 0x200, 16 ) /* colors 0x200-0x2ff */
+ GFXDECODE_ENTRY( "gfx2", 0, text_layout, 0x300, 16 ) /* colors 0x300-0x33f */
+ GFXDECODE_ENTRY( "gfx3", 0, madgear_tile, 0x000, 16 ) /* colors 0x000-0x0ff */
+ GFXDECODE_ENTRY( "gfx4", 0, madgear_tile, 0x100, 16 ) /* colors 0x100-0x1ff */
+GFXDECODE_END
+
+static GFXDECODE_START( madgear )
+ GFXDECODE_ENTRY( "gfx1", 0, sprite_layout, 0x200, 16 ) /* colors 0x200-0x2ff */
+ GFXDECODE_ENTRY( "gfx2", 0, text_layout, 0x300, 16 ) /* colors 0x300-0x33f */
+ GFXDECODE_ENTRY( "gfx3", 0, madgear_tile, 0x000, 16 ) /* colors 0x000-0x0ff */
+ GFXDECODE_ENTRY( "gfx4", 0, madgear_tile2, 0x100, 16 ) /* colors 0x100-0x1ff */
+GFXDECODE_END
+
+/******************************************************************************/
+
+/* handler called by the 2203 emulator when the internal timers cause an IRQ */
+static void irqhandler( const device_config *device, int irq )
+{
+ lastduel_state *state = (lastduel_state *)device->machine->driver_data;
+ cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
+}
+
+static const ym2203_interface ym2203_config =
+{
+ {
+ AY8910_LEGACY_OUTPUT,
+ AY8910_DEFAULT_LOADS,
+ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
+ },
+ irqhandler
+};
+
+static INTERRUPT_GEN( lastduel_interrupt )
+{
+ if (cpu_getiloops(device) == 0)
+ cpu_set_input_line(device, 2, HOLD_LINE); /* VBL */
+ else
+ cpu_set_input_line(device, 4, HOLD_LINE); /* Controls */
+}
+
+static INTERRUPT_GEN( madgear_interrupt )
+{
+ if (cpu_getiloops(device) == 0)
+ cpu_set_input_line(device, 5, HOLD_LINE); /* VBL */
+ else
+ cpu_set_input_line(device, 6, HOLD_LINE); /* Controls */
+}
+
+static MACHINE_START( lastduel )
+{
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+
+ state->audiocpu = devtag_get_device(machine, "audiocpu");
+
+ state_save_register_global(machine, state->tilemap_priority);
+ state_save_register_global_array(machine, state->scroll);
+}
+
+static MACHINE_START( madgear )
+{
+ UINT8 *ROM = memory_region(machine, "audiocpu");
+
+ memory_configure_bank(machine, "bank1", 0, 2, &ROM[0x10000], 0x4000);
+
+ MACHINE_START_CALL(lastduel);
+}
+
+static MACHINE_RESET( lastduel )
+{
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ int i;
+
+ state->tilemap_priority = 0;
+
+ for (i = 0; i < 8; i++)
+ state->scroll[i] = 0;
+}
+
+static MACHINE_DRIVER_START( lastduel )
+
+ /* driver data */
+ MDRV_DRIVER_DATA(lastduel_state)
+
+ /* basic machine hardware */
+ MDRV_CPU_ADD("maincpu", M68000, 10000000) /* Could be 8 MHz */
+ MDRV_CPU_PROGRAM_MAP(lastduel_map)
+ MDRV_CPU_VBLANK_INT_HACK(lastduel_interrupt,3) /* 1 for vbl, 2 for control reads?? */
+
+ MDRV_CPU_ADD("audiocpu", Z80, 3579545) /* Accurate */
+ MDRV_CPU_PROGRAM_MAP(sound_map)
+
+ MDRV_MACHINE_START(lastduel)
+ MDRV_MACHINE_RESET(lastduel)
+
+ /* video hardware */
+ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_BUFFERS_SPRITERAM)
+
+ MDRV_SCREEN_ADD("screen", RASTER)
+ MDRV_SCREEN_REFRESH_RATE(60)
+ MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
+ MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
+ MDRV_SCREEN_SIZE(64*8, 32*8)
+ MDRV_SCREEN_VISIBLE_AREA(8*8, (64-8)*8-1, 1*8, 31*8-1 )
+
+ MDRV_GFXDECODE(lastduel)
+ MDRV_PALETTE_LENGTH(1024)
+
+ MDRV_VIDEO_START(lastduel)
+ MDRV_VIDEO_EOF(lastduel)
+ MDRV_VIDEO_UPDATE(lastduel)
+
+ /* sound hardware */
+ MDRV_SPEAKER_STANDARD_MONO("mono")
+
+ MDRV_SOUND_ADD("ym1", YM2203, 3579545)
+ MDRV_SOUND_CONFIG(ym2203_config)
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
+
+ MDRV_SOUND_ADD("ym2", YM2203, 3579545)
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
+MACHINE_DRIVER_END
+
+
+static MACHINE_DRIVER_START( madgear )
+
+ /* driver data */
+ MDRV_DRIVER_DATA(lastduel_state)
+
+ /* basic machine hardware */
+ MDRV_CPU_ADD("maincpu", M68000, 10000000) /* Accurate */
+ MDRV_CPU_PROGRAM_MAP(madgear_map)
+ MDRV_CPU_VBLANK_INT_HACK(madgear_interrupt,3) /* 1 for vbl, 2 for control reads?? */
+
+ MDRV_CPU_ADD("audiocpu", Z80, XTAL_3_579545MHz) /* verified on pcb */
+ MDRV_CPU_PROGRAM_MAP(madgear_sound_map)
+
+ MDRV_MACHINE_START(madgear)
+ MDRV_MACHINE_RESET(lastduel)
+
+ /* video hardware */
+ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_BUFFERS_SPRITERAM)
+
+ MDRV_SCREEN_ADD("screen", RASTER)
+ MDRV_SCREEN_REFRESH_RATE(60)
+ MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
+ MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
+ MDRV_SCREEN_SIZE(64*8, 32*8)
+ MDRV_SCREEN_VISIBLE_AREA(8*8, (64-8)*8-1, 1*8, 31*8-1 )
+
+ MDRV_GFXDECODE(madgear)
+ MDRV_PALETTE_LENGTH(1024)
+
+ MDRV_VIDEO_START(madgear)
+ MDRV_VIDEO_EOF(lastduel)
+ MDRV_VIDEO_UPDATE(madgear)
+
+ /* sound hardware */
+ MDRV_SPEAKER_STANDARD_MONO("mono")
+
+ MDRV_SOUND_ADD("ym1", YM2203, XTAL_3_579545MHz) /* verified on pcb */
+ MDRV_SOUND_CONFIG(ym2203_config)
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
+
+ MDRV_SOUND_ADD("ym2", YM2203, XTAL_3_579545MHz) /* verified on pcb */
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
+
+ MDRV_SOUND_ADD("oki", OKIM6295, XTAL_10MHz/10)
+ MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.98)
+MACHINE_DRIVER_END
+
+/******************************************************************************/
+
ROM_START( lastduel )
ROM_REGION( 0x60000, "maincpu", 0 ) /* 68000 code */
ROM_LOAD16_BYTE( "ldu_06b.13k", 0x00000, 0x20000, CRC(0e71acaf) SHA1(e804c77bfd768ae2fc1917bcec1fd0ec7418b780) )
@@ -855,11 +880,11 @@ ROM_END
/******************************************************************************/
-GAME( 1988, lastduel, 0, lastduel, lastduel, 0, ROT270, "Capcom", "Last Duel (US New Ver.)", 0 )
-GAME( 1988, lastduelo, lastduel, lastduel, lastduel, 0, ROT270, "Capcom", "Last Duel (US Old Ver.)", 0 )
-GAME( 1988, lastduelj, lastduel, lastduel, lastduel, 0, ROT270, "Capcom", "Last Duel (Japan)", 0 )
-GAME( 1988, lastduelb, lastduel, lastduel, lastduel, 0, ROT270, "bootleg", "Last Duel (bootleg)", 0 )
-GAME( 1989, madgear, 0, madgear, madgear, 0, ROT270, "Capcom", "Mad Gear (US)", 0 )
-GAME( 1989, madgearj, madgear, madgear, madgear, 0, ROT270, "Capcom", "Mad Gear (Japan)", 0 )
-GAME( 1988, ledstorm, madgear, madgear, madgear, 0, ROT270, "Capcom", "Led Storm (US)", 0 )
-GAME( 1988, ledstorm2, madgear, madgear, madgear, 0, ROT270, "Capcom", "Led Storm Rally 2011 (US)", GAME_IMPERFECT_GRAPHICS ) /* game still has wrong sprite issues */
+GAME( 1988, lastduel, 0, lastduel, lastduel, 0, ROT270, "Capcom", "Last Duel (US New Ver.)", GAME_SUPPORTS_SAVE )
+GAME( 1988, lastduelo, lastduel, lastduel, lastduel, 0, ROT270, "Capcom", "Last Duel (US Old Ver.)", GAME_SUPPORTS_SAVE )
+GAME( 1988, lastduelj, lastduel, lastduel, lastduel, 0, ROT270, "Capcom", "Last Duel (Japan)", GAME_SUPPORTS_SAVE )
+GAME( 1988, lastduelb, lastduel, lastduel, lastduel, 0, ROT270, "bootleg", "Last Duel (bootleg)", GAME_SUPPORTS_SAVE )
+GAME( 1989, madgear, 0, madgear, madgear, 0, ROT270, "Capcom", "Mad Gear (US)", GAME_SUPPORTS_SAVE )
+GAME( 1989, madgearj, madgear, madgear, madgear, 0, ROT270, "Capcom", "Mad Gear (Japan)", GAME_SUPPORTS_SAVE )
+GAME( 1988, ledstorm, madgear, madgear, madgear, 0, ROT270, "Capcom", "Led Storm (US)", GAME_SUPPORTS_SAVE )
+GAME( 1988, ledstorm2, madgear, madgear, madgear, 0, ROT270, "Capcom", "Led Storm Rally 2011 (US)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) /* game still has wrong sprite issues */
diff --git a/src/mame/drivers/lwings.c b/src/mame/drivers/lwings.c
index d515fd2ac1d..2984608c081 100644
--- a/src/mame/drivers/lwings.c
+++ b/src/mame/drivers/lwings.c
@@ -47,9 +47,9 @@ Notes:
#include "driver.h"
#include "cpu/z80/z80.h"
-#include "lwings.h"
#include "sound/2203intf.h"
#include "sound/msm5205.h"
+#include "includes/lwings.h"
/* Avengers runs on hardware almost identical to Trojan, but with a protection
* device and some small changes to the memory map and videohardware.
@@ -59,83 +59,80 @@ Notes:
* Another function takes as input 2 pairs of (x,y) coordinates, and returns
* a code reflecting the direction (8 angles) from one point to the other.
*/
-static UINT8 avengers_param[4];
-static int avengers_palette_pen;
-static UINT8 *avengers_soundlatch2, avengers_soundstate=0;
-static UINT8 avengers_adpcm;
static WRITE8_HANDLER( avengers_adpcm_w )
{
- avengers_adpcm = data;
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ state->adpcm = data;
}
static READ8_HANDLER( avengers_adpcm_r )
{
- return avengers_adpcm;
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ return state->adpcm;
}
static WRITE8_HANDLER( lwings_bankswitch_w )
{
- UINT8 *RAM;
- int bank;
-
/* bit 0 is flip screen */
flip_screen_set(space->machine, ~data & 0x01);
/* bits 1 and 2 select ROM bank */
- RAM = memory_region(space->machine, "maincpu");
- bank = (data & 0x06) >> 1;
- memory_set_bankptr(space->machine, "bank1",&RAM[0x10000 + bank*0x4000]);
+ memory_set_bank(space->machine, "bank1", (data & 0x06) >> 1);
/* bit 3 enables NMI */
- interrupt_enable_w(space,0,data & 0x08);
+ interrupt_enable_w(space, 0, data & 0x08);
/* bits 6 and 7 are coin counters */
- coin_counter_w(space->machine, 1,data & 0x40);
- coin_counter_w(space->machine, 0,data & 0x80);
+ coin_counter_w(space->machine, 1, data & 0x40);
+ coin_counter_w(space->machine, 0, data & 0x80);
}
static INTERRUPT_GEN( lwings_interrupt )
{
if (interrupt_enable_r(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), 0))
- cpu_set_input_line_and_vector(device,0,HOLD_LINE,0xd7); /* RST 10h */
+ cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7); /* RST 10h */
}
static WRITE8_HANDLER( avengers_protection_w )
{
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
int pc = cpu_get_pc(space->cpu);
- if( pc == 0x2eeb )
+ if (pc == 0x2eeb)
{
- avengers_param[0] = data;
+ state->param[0] = data;
}
- else if( pc == 0x2f09 )
+ else if (pc == 0x2f09)
{
- avengers_param[1] = data;
+ state->param[1] = data;
}
- else if( pc == 0x2f26 )
+ else if(pc == 0x2f26)
{
- avengers_param[2] = data;
+ state->param[2] = data;
}
- else if( pc == 0x2f43 )
+ else if (pc == 0x2f43)
{
- avengers_param[3] = data;
+ state->param[3] = data;
}
- else if( pc == 0x0445 )
+ else if (pc == 0x0445)
{
- avengers_soundstate = 0x80;
- soundlatch_w( space, 0, data );
+ state->soundstate = 0x80;
+ soundlatch_w(space, 0, data);
}
}
static WRITE8_HANDLER( avengers_prot_bank_w )
{
- avengers_palette_pen = data*64;
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ state->palette_pen = data * 64;
}
-static int avengers_fetch_paldata( void )
+static int avengers_fetch_paldata( running_machine *machine )
{
+ lwings_state *state = (lwings_state *)machine->driver_data;
+
static const char pal_data[] =
/* page 1: 0x03,0x02,0x01,0x00 */
"0000000000000000" "A65486A6364676D6" "C764C777676778A7" "A574E5E5C5756AE5"
@@ -197,38 +194,48 @@ static int avengers_fetch_paldata( void )
"0000000000000000" "6474667676660100" "7696657575650423" "88A8647474645473"
"0000000000000000" "0001070701050004" "0003060603040303" "0005050505040302";
- int bank = avengers_palette_pen/64;
- int offs = avengers_palette_pen%64;
- int page = bank/4; /* 0..7 */
- int base = (3-(bank&3)); /* 0..3 */
- int row = offs&0xf; /* 0..15 */
- int col = offs/16 + base*4; /* 0..15 */
- int digit0 = pal_data[page*256*2 + (31-row*2)*16+col];
- int digit1 = pal_data[page*256*2 + (30-row*2)*16+col];
+ int bank = state->palette_pen / 64;
+ int offs = state->palette_pen % 64;
+ int page = bank / 4; /* 0..7 */
+ int base = (3 - (bank & 3)); /* 0..3 */
+ int row = offs & 0xf; /* 0..15 */
+ int col = offs / 16 + base * 4; /* 0..15 */
+ int digit0 = pal_data[page * 256 * 2 + (31 - row * 2) * 16 + col];
+ int digit1 = pal_data[page * 256 * 2 + (30 - row * 2) * 16 + col];
int result;
- if( digit0>='A' ) digit0 += 10 - 'A'; else digit0 -= '0';
- if( digit1>='A' ) digit1 += 10 - 'A'; else digit1 -= '0';
+ if (digit0 >= 'A')
+ digit0 += 10 - 'A';
+ else
+ digit0 -= '0';
+
+ if (digit1 >= 'A')
+ digit1 += 10 - 'A';
+ else
+ digit1 -= '0';
+
result = digit0 * 16 + digit1;
- if( (avengers_palette_pen&0x3f)!=0x3f ) avengers_palette_pen++;
+ if ((state->palette_pen & 0x3f) != 0x3f)
+ state->palette_pen++;
return result;
}
static READ8_HANDLER( avengers_protection_r )
{
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
static const int xpos[8] = { 10, 7, 0, -7, -10, -7, 0, 7 };
static const int ypos[8] = { 0, 7, 10, 7, 0, -7, -10, -7 };
int best_dist = 0;
int best_dir = 0;
- int x,y;
- int dx,dy,dist,dir;
+ int x, y;
+ int dx, dy, dist, dir;
- if( cpu_get_pc(space->cpu) == 0x7c7 )
+ if (cpu_get_pc(space->cpu) == 0x7c7)
{
/* palette data */
- return avengers_fetch_paldata();
+ return avengers_fetch_paldata(space->machine);
}
/* Point to Angle Function
@@ -236,35 +243,36 @@ static READ8_HANDLER( avengers_protection_r )
Input: two cartesian points
Output: direction code (north,northeast,east,...)
*/
- x = avengers_param[0] - avengers_param[2];
- y = avengers_param[1] - avengers_param[3];
- for( dir=0; dir<8; dir++ )
+ x = state->param[0] - state->param[2];
+ y = state->param[1] - state->param[3];
+ for (dir = 0; dir < 8; dir++)
{
- dx = xpos[dir]-x;
- dy = ypos[dir]-y;
- dist = dx*dx+dy*dy;
- if( dist < best_dist || dir==0 )
+ dx = xpos[dir] - x;
+ dy = ypos[dir] - y;
+ dist = dx * dx + dy * dy;
+ if (dist < best_dist || dir == 0)
{
best_dir = dir;
best_dist = dist;
}
}
- return best_dir<<5;
+ return best_dir << 5;
}
static READ8_HANDLER( avengers_soundlatch2_r )
{
- UINT8 data = *avengers_soundlatch2 | avengers_soundstate;
- avengers_soundstate = 0;
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ UINT8 data = *state->soundlatch2 | state->soundstate;
+ state->soundstate = 0;
return(data);
}
static WRITE8_DEVICE_HANDLER( msm5205_w )
{
- msm5205_reset_w(device,(data>>7)&1);
- msm5205_data_w(device,data);
- msm5205_vclk_w(device,1);
- msm5205_vclk_w(device,0);
+ msm5205_reset_w(device, (data >> 7) & 1);
+ msm5205_data_w(device, data);
+ msm5205_vclk_w(device, 1);
+ msm5205_vclk_w(device, 0);
}
static ADDRESS_MAP_START( avengers_map, ADDRESS_SPACE_PROGRAM, 8 )
@@ -273,8 +281,8 @@ static ADDRESS_MAP_START( avengers_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xddff) AM_RAM
AM_RANGE(0xde00, 0xdf7f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xdf80, 0xdfff) AM_RAM
- AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(lwings_fgvideoram_w) AM_BASE(&lwings_fgvideoram)
- AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(lwings_bg1videoram_w) AM_BASE(&lwings_bg1videoram)
+ AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(lwings_fgvideoram_w) AM_BASE_MEMBER(lwings_state, fgvideoram)
+ AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(lwings_bg1videoram_w) AM_BASE_MEMBER(lwings_state, bg1videoram)
AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_split2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xf400, 0xf7ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_split1_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xf800, 0xf801) AM_WRITE(lwings_bg1_scrollx_w)
@@ -296,8 +304,8 @@ static ADDRESS_MAP_START( lwings_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xddff) AM_RAM
AM_RANGE(0xde00, 0xdfff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
- AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(lwings_fgvideoram_w) AM_BASE(&lwings_fgvideoram)
- AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(lwings_bg1videoram_w) AM_BASE(&lwings_bg1videoram)
+ AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(lwings_fgvideoram_w) AM_BASE_MEMBER(lwings_state, fgvideoram)
+ AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(lwings_bg1videoram_w) AM_BASE_MEMBER(lwings_state, bg1videoram)
AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_split2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xf400, 0xf7ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_split1_w) AM_BASE_GENERIC(paletteram)
@@ -318,8 +326,8 @@ static ADDRESS_MAP_START( trojan_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xddff) AM_RAM
AM_RANGE(0xde00, 0xdf7f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xdf80, 0xdfff) AM_RAM
- AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(lwings_fgvideoram_w) AM_BASE(&lwings_fgvideoram)
- AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(lwings_bg1videoram_w) AM_BASE(&lwings_bg1videoram)
+ AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(lwings_fgvideoram_w) AM_BASE_MEMBER(lwings_state, fgvideoram)
+ AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(lwings_bg1videoram_w) AM_BASE_MEMBER(lwings_state, bg1videoram)
AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_split2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xf400, 0xf7ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_split1_w) AM_BASE_GENERIC(paletteram)
@@ -343,7 +351,7 @@ static ADDRESS_MAP_START( lwings_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xe000, 0xe001) AM_DEVWRITE("2203a", ym2203_w)
AM_RANGE(0xe002, 0xe003) AM_DEVWRITE("2203b", ym2203_w)
AM_RANGE(0xe006, 0xe006) AM_READ(avengers_soundlatch2_r) //AT: (avengers061gre)
- AM_RANGE(0xe006, 0xe006) AM_WRITEONLY AM_BASE(&avengers_soundlatch2)
+ AM_RANGE(0xe006, 0xe006) AM_WRITEONLY AM_BASE_MEMBER(lwings_state, soundlatch2)
ADDRESS_MAP_END
/* Yes, _no_ ram */
@@ -732,8 +740,45 @@ static const msm5205_interface msm5205_config =
*
*************************************/
+static MACHINE_START( lwings )
+{
+ lwings_state *state = (lwings_state *)machine->driver_data;
+ UINT8 *ROM = memory_region(machine, "maincpu");
+
+ memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x4000);
+
+ state_save_register_global(machine, state->bg2_image);
+ state_save_register_global_array(machine, state->scroll_x);
+ state_save_register_global_array(machine, state->scroll_y);
+ state_save_register_global_array(machine, state->param);
+ state_save_register_global(machine, state->palette_pen);
+ state_save_register_global(machine, state->soundstate);
+ state_save_register_global(machine, state->adpcm);
+}
+
+static MACHINE_RESET( lwings )
+{
+ lwings_state *state = (lwings_state *)machine->driver_data;
+
+ state->bg2_image = 0;
+ state->scroll_x[0] = 0;
+ state->scroll_x[1] = 0;
+ state->scroll_y[0] = 0;
+ state->scroll_y[1] = 0;
+ state->param[0] = 0;
+ state->param[1] = 0;
+ state->param[2] = 0;
+ state->param[3] = 0;
+ state->palette_pen = 0;
+ state->soundstate = 0;
+ state->adpcm = 0;
+}
+
static MACHINE_DRIVER_START( lwings )
+ /* driver data */
+ MDRV_DRIVER_DATA(lwings_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, XTAL_12MHz/4) /* verified on pcb */
MDRV_CPU_PROGRAM_MAP(lwings_map)
@@ -743,6 +788,9 @@ static MACHINE_DRIVER_START( lwings )
MDRV_CPU_PROGRAM_MAP(lwings_sound_map)
MDRV_CPU_PERIODIC_INT(irq0_line_hold,4*60) /* ??? */
+ MDRV_MACHINE_START(lwings)
+ MDRV_MACHINE_RESET(lwings)
+
/* video hardware */
MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
@@ -1299,16 +1347,15 @@ ROM_END
*
*************************************/
-GAME( 1985, sectionz, 0, lwings, sectionz, 0, ROT0, "Capcom", "Section Z (set 1)", 0 )
-GAME( 1985, sectionza,sectionz, lwings, sectionz, 0, ROT0, "Capcom", "Section Z (set 2)", 0 )
-GAME( 1986, lwings, 0, lwings, lwings, 0, ROT90, "Capcom", "Legendary Wings (US set 1)", 0 )
-GAME( 1986, lwings2, lwings, lwings, lwings, 0, ROT90, "Capcom", "Legendary Wings (US set 2)", 0 )
-GAME( 1986, lwingsj, lwings, lwings, lwings, 0, ROT90, "Capcom", "Ares no Tsubasa (Japan)", 0 )
-GAME( 1986, lwingsb, lwings, lwings, lwingsb, 0, ROT90, "bootleg", "Legendary Wings (bootleg)", 0 )
-GAME( 1986, trojan, 0, trojan, trojanls, 0, ROT0, "Capcom", "Trojan (US)", 0 )
-GAME( 1986, trojanr, trojan, trojan, trojan, 0, ROT0, "Capcom (Romstar license)", "Trojan (Romstar)", 0 )
-GAME( 1986, trojanj, trojan, trojan, trojan, 0, ROT0, "Capcom", "Tatakai no Banka (Japan)", 0 )
-GAME( 1987, avengers, 0, avengers, avengers, 0, ROT90, "Capcom", "Avengers (US set 1)", 0 )
-GAME( 1987, avengers2,avengers, avengers, avengers, 0, ROT90, "Capcom", "Avengers (US set 2)", 0 )
-GAME( 1987, buraiken, avengers, avengers, avengers, 0, ROT90, "Capcom", "Hissatsu Buraiken (Japan)", 0 )
-
+GAME( 1985, sectionz, 0, lwings, sectionz, 0, ROT0, "Capcom", "Section Z (set 1)", GAME_SUPPORTS_SAVE )
+GAME( 1985, sectionza, sectionz, lwings, sectionz, 0, ROT0, "Capcom", "Section Z (set 2)", GAME_SUPPORTS_SAVE )
+GAME( 1986, lwings, 0, lwings, lwings, 0, ROT90, "Capcom", "Legendary Wings (US set 1)", GAME_SUPPORTS_SAVE )
+GAME( 1986, lwings2, lwings, lwings, lwings, 0, ROT90, "Capcom", "Legendary Wings (US set 2)", GAME_SUPPORTS_SAVE )
+GAME( 1986, lwingsj, lwings, lwings, lwings, 0, ROT90, "Capcom", "Ares no Tsubasa (Japan)", GAME_SUPPORTS_SAVE )
+GAME( 1986, lwingsb, lwings, lwings, lwingsb, 0, ROT90, "bootleg", "Legendary Wings (bootleg)", GAME_SUPPORTS_SAVE )
+GAME( 1986, trojan, 0, trojan, trojanls, 0, ROT0, "Capcom", "Trojan (US)", GAME_SUPPORTS_SAVE )
+GAME( 1986, trojanr, trojan, trojan, trojan, 0, ROT0, "Capcom (Romstar license)", "Trojan (Romstar)", GAME_SUPPORTS_SAVE )
+GAME( 1986, trojanj, trojan, trojan, trojan, 0, ROT0, "Capcom", "Tatakai no Banka (Japan)", GAME_SUPPORTS_SAVE )
+GAME( 1987, avengers, 0, avengers, avengers, 0, ROT90, "Capcom", "Avengers (US set 1)", GAME_SUPPORTS_SAVE )
+GAME( 1987, avengers2, avengers, avengers, avengers, 0, ROT90, "Capcom", "Avengers (US set 2)", GAME_SUPPORTS_SAVE )
+GAME( 1987, buraiken, avengers, avengers, avengers, 0, ROT90, "Capcom", "Hissatsu Buraiken (Japan)", GAME_SUPPORTS_SAVE )
diff --git a/src/mame/drivers/redclash.c b/src/mame/drivers/redclash.c
index ec809756a32..e8541b2e2d6 100644
--- a/src/mame/drivers/redclash.c
+++ b/src/mame/drivers/redclash.c
@@ -22,35 +22,20 @@ TODO:
#include "driver.h"
#include "cpu/z80/z80.h"
-
-
-extern WRITE8_HANDLER( redclash_videoram_w );
-extern WRITE8_HANDLER( redclash_gfxbank_w );
-extern WRITE8_HANDLER( redclash_flipscreen_w );
-
-extern WRITE8_HANDLER( redclash_star0_w );
-extern WRITE8_HANDLER( redclash_star1_w );
-extern WRITE8_HANDLER( redclash_star2_w );
-extern WRITE8_HANDLER( redclash_star_reset_w );
-
-extern PALETTE_INIT( redclash );
-extern VIDEO_START( redclash );
-extern VIDEO_UPDATE( redclash );
-extern VIDEO_EOF( redclash );
-
+#include "includes/ladybug.h"
static WRITE8_HANDLER( irqack_w )
{
- cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+ cpu_set_input_line(state->maincpu, 0, CLEAR_LINE);
}
-
static ADDRESS_MAP_START( zerohour_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x2fff) AM_ROM
AM_RANGE(0x3000, 0x37ff) AM_RAM
- AM_RANGE(0x3800, 0x3bff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
- AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(redclash_videoram_w) AM_BASE_GENERIC(videoram)
+ AM_RANGE(0x3800, 0x3bff) AM_RAM AM_BASE_SIZE_MEMBER(ladybug_state, spriteram, spriteram_size)
+ AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(redclash_videoram_w) AM_BASE_MEMBER(ladybug_state, videoram)
AM_RANGE(0x4800, 0x4800) AM_READ_PORT("IN0") /* IN0 */
AM_RANGE(0x4801, 0x4801) AM_READ_PORT("IN1") /* IN1 */
AM_RANGE(0x4802, 0x4802) AM_READ_PORT("DSW1") /* DSW0 */
@@ -69,7 +54,7 @@ static ADDRESS_MAP_START( redclash_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x2fff) AM_ROM
// AM_RANGE(0x3000, 0x3000) AM_WRITENOP
// AM_RANGE(0x3800, 0x3800) AM_WRITENOP
- AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(redclash_videoram_w) AM_BASE_GENERIC(videoram)
+ AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(redclash_videoram_w) AM_BASE_MEMBER(ladybug_state, videoram)
AM_RANGE(0x4800, 0x4800) AM_READ_PORT("IN0") /* IN0 */
AM_RANGE(0x4801, 0x4801) AM_READ_PORT("IN1") /* IN1 */
AM_RANGE(0x4802, 0x4802) AM_READ_PORT("DSW1") /* DSW0 */
@@ -81,7 +66,7 @@ static ADDRESS_MAP_START( redclash_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x5806, 0x5806) AM_WRITE(redclash_star2_w)
AM_RANGE(0x5807, 0x5807) AM_WRITE(redclash_flipscreen_w)
AM_RANGE(0x6000, 0x67ff) AM_RAM
- AM_RANGE(0x6800, 0x6bff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
+ AM_RANGE(0x6800, 0x6bff) AM_RAM AM_BASE_SIZE_MEMBER(ladybug_state, spriteram, spriteram_size)
AM_RANGE(0x7000, 0x7000) AM_WRITE(redclash_star_reset_w)
AM_RANGE(0x7800, 0x7800) AM_WRITE(irqack_w)
ADDRESS_MAP_END
@@ -93,18 +78,22 @@ ADDRESS_MAP_END
*/
static INPUT_CHANGED( left_coin_inserted )
{
+ ladybug_state *state = (ladybug_state *)field->port->machine->driver_data;
+
if(newval)
- cputag_set_input_line(field->port->machine, "maincpu", 0, ASSERT_LINE);
+ cpu_set_input_line(state->maincpu, 0, ASSERT_LINE);
}
static INPUT_CHANGED( right_coin_inserted )
{
+ ladybug_state *state = (ladybug_state *)field->port->machine->driver_data;
+
if(newval)
- cputag_set_input_line(field->port->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
+ cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, PULSE_LINE);
}
static INPUT_PORTS_START( redclash )
- PORT_START("IN0") /* IN0 */
+ PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
@@ -114,7 +103,7 @@ static INPUT_PORTS_START( redclash )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_START("IN1") /* IN1 */
+ PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
@@ -126,7 +115,7 @@ static INPUT_PORTS_START( redclash )
/* them this way is enough to get the game running. */
PORT_BIT( 0xc0, 0x40, IPT_VBLANK )
- PORT_START("DSW1") /* DSW0 */
+ PORT_START("DSW1")
PORT_DIPNAME( 0x03, 0x03, "Difficulty?" )
PORT_DIPSETTING( 0x03, "Easy?" )
PORT_DIPSETTING( 0x02, "Medium?" )
@@ -150,7 +139,7 @@ static INPUT_PORTS_START( redclash )
PORT_DIPSETTING( 0x80, "5" )
PORT_DIPSETTING( 0x40, "7" )
- PORT_START("DSW2") /* DSW1 */
+ PORT_START("DSW2")
PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
PORT_DIPSETTING( 0x04, DEF_STR( 6C_1C ) )
PORT_DIPSETTING( 0x05, DEF_STR( 5C_1C ) )
@@ -186,7 +175,7 @@ static INPUT_PORTS_START( redclash )
PORT_DIPSETTING( 0x10, DEF_STR( 1C_8C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 1C_9C ) )
- PORT_START("FAKE") /* FAKE */
+ PORT_START("FAKE")
/* The coin slots are not memory mapped. Coin Left causes a NMI, */
/* Coin Right an IRQ. This fake input port is used by the interrupt */
/* handler to be notified of coin insertions. We use IMPULSE to */
@@ -197,7 +186,7 @@ static INPUT_PORTS_START( redclash )
INPUT_PORTS_END
static INPUT_PORTS_START( zerohour )
- PORT_START("IN0") /* IN0 */
+ PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
@@ -207,7 +196,7 @@ static INPUT_PORTS_START( zerohour )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_START("IN1") /* IN1 */
+ PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
@@ -219,7 +208,7 @@ static INPUT_PORTS_START( zerohour )
/* them this way is enough to get the game running. */
PORT_BIT( 0xc0, 0x40, IPT_VBLANK )
- PORT_START("DSW1") /* DSW0 */
+ PORT_START("DSW1")
PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW1:8" ) /* Switches 6-8 are not used */
PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW1:7" )
PORT_DIPUNUSED_DIPLOC( 0x04, 0x04, "SW1:6" )
@@ -237,7 +226,7 @@ static INPUT_PORTS_START( zerohour )
PORT_DIPSETTING( 0x80, "4" )
PORT_DIPSETTING( 0x40, "5" )
- PORT_START("DSW2") /* DSW1 */
+ PORT_START("DSW2")
PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW2:4,3,2,1")
PORT_DIPSETTING( 0x06, DEF_STR( 4C_1C ) )
PORT_DIPSETTING( 0x08, DEF_STR( 3C_1C ) )
@@ -261,7 +250,7 @@ static INPUT_PORTS_START( zerohour )
PORT_DIPSETTING( 0xc0, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0xb0, DEF_STR( 1C_5C ) )
- PORT_START("FAKE") /* FAKE */
+ PORT_START("FAKE")
/* The coin slots are not memory mapped. Coin Left causes a NMI, */
/* Coin Right an IRQ. This fake input port is used by the interrupt */
/* handler to be notified of coin insertions. We use IMPULSE to */
@@ -337,12 +326,46 @@ GFXDECODE_END
+static MACHINE_START( redclash )
+{
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+
+ state->maincpu = devtag_get_device(machine, "maincpu");
+
+ state_save_register_global(machine, state->star_speed);
+ state_save_register_global(machine, state->gfxbank);
+ state_save_register_global(machine, state->stars_enable);
+ state_save_register_global(machine, state->stars_speed);
+ state_save_register_global(machine, state->stars_state);
+ state_save_register_global(machine, state->stars_offset);
+ state_save_register_global(machine, state->stars_count);
+}
+
+static MACHINE_RESET( redclash )
+{
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+
+ state->star_speed = 0;
+ state->gfxbank = 0;
+ state->stars_enable = 0;
+ state->stars_speed = 0;
+ state->stars_state = 0;
+ state->stars_offset = 0;
+ state->stars_count = 0;
+}
+
static MACHINE_DRIVER_START( zerohour )
+ /* driver data */
+ MDRV_DRIVER_DATA(ladybug_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */
MDRV_CPU_PROGRAM_MAP(zerohour_map)
+ MDRV_MACHINE_START(redclash)
+ MDRV_MACHINE_RESET(redclash)
+
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@@ -365,10 +388,16 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( redclash )
+ /* driver data */
+ MDRV_DRIVER_DATA(ladybug_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */
MDRV_CPU_PROGRAM_MAP(redclash_map)
+ MDRV_MACHINE_START(redclash)
+ MDRV_MACHINE_RESET(redclash)
+
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@@ -510,8 +539,7 @@ static DRIVER_INIT( redclash )
}
-
-GAME( 1980, zerohour, 0, zerohour, zerohour, redclash, ROT270, "Universal", "Zero Hour", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
-GAME( 1981, redclash, 0, redclash, redclash, redclash, ROT270, "Tehkan", "Red Clash (set 1)", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
-GAME( 1981, redclasha, redclash, redclash, redclash, redclash, ROT270, "Tehkan", "Red Clash (set 2)", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
-GAME( 1981, redclashk, redclash, redclash, redclash, redclash, ROT270, "Kaneko", "Red Clash (Kaneko)", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS )
+GAME( 1980, zerohour, 0, zerohour, zerohour, redclash, ROT270, "Universal", "Zero Hour", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
+GAME( 1981, redclash, 0, redclash, redclash, redclash, ROT270, "Tehkan", "Red Clash (set 1)", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
+GAME( 1981, redclasha, redclash, redclash, redclash, redclash, ROT270, "Tehkan", "Red Clash (set 2)", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
+GAME( 1981, redclashk, redclash, redclash, redclash, redclash, ROT270, "Kaneko", "Red Clash (Kaneko)", GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
diff --git a/src/mame/drivers/yunsung8.c b/src/mame/drivers/yunsung8.c
index 157d69950af..6f037eb9651 100644
--- a/src/mame/drivers/yunsung8.c
+++ b/src/mame/drivers/yunsung8.c
@@ -33,36 +33,7 @@ To Do:
#include "cpu/z80/z80.h"
#include "sound/3812intf.h"
#include "sound/msm5205.h"
-
-/* Variables defined in video: */
-
-extern UINT8 *yunsung8_videoram_0, *yunsung8_videoram_1;
-extern int yunsung8_layers_ctrl;
-
-/* Functions defined in video: */
-
-WRITE8_HANDLER( yunsung8_videobank_w );
-
-READ8_HANDLER ( yunsung8_videoram_r );
-WRITE8_HANDLER( yunsung8_videoram_w );
-
-WRITE8_HANDLER( yunsung8_flipscreen_w );
-
-VIDEO_START( yunsung8 );
-VIDEO_UPDATE( yunsung8 );
-
-
-
-static MACHINE_RESET( yunsung8 )
-{
- const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
- UINT8* yunsung8_videoram = auto_alloc_array(machine, UINT8, 0x4000);
-
- yunsung8_videoram_0 = yunsung8_videoram + 0x0000; // Ram is banked
- yunsung8_videoram_1 = yunsung8_videoram + 0x2000;
- yunsung8_videobank_w(space, 0, 0);
-}
-
+#include "includes/yunsung8.h"
/***************************************************************************
@@ -75,17 +46,14 @@ static MACHINE_RESET( yunsung8 )
static WRITE8_HANDLER( yunsung8_bankswitch_w )
{
- UINT8 *RAM = memory_region(space->machine, "maincpu");
-
- int bank = data & 7; // ROM bank
- yunsung8_layers_ctrl = data & 0x30; // Layers enable
+ yunsung8_state *state = (yunsung8_state *)space->machine->driver_data;
- if (data & ~0x37) logerror("CPU #0 - PC %04X: Bank %02X\n",cpu_get_pc(space->cpu),data);
+ state->layers_ctrl = data & 0x30; // Layers enable
- if (bank < 3) RAM = &RAM[0x4000 * bank];
- else RAM = &RAM[0x4000 * (bank-3) + 0x10000];
+ memory_set_bank(space->machine, "bank1", data & 0x07);
- memory_set_bankptr(space->machine, "bank1", RAM);
+ if (data & ~0x37)
+ logerror("CPU #0 - PC %04X: Bank %02X\n", cpu_get_pc(space->cpu), data);
}
/*
@@ -98,10 +66,10 @@ static WRITE8_HANDLER( yunsung8_bankswitch_w )
*/
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
- AM_RANGE(0x0001, 0x0001) AM_WRITE(yunsung8_bankswitch_w ) // ROM Bank (again?)
- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1" ) // Banked ROM
+ AM_RANGE(0x0001, 0x0001) AM_WRITE(yunsung8_bankswitch_w) // ROM Bank (again?)
+ AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") // Banked ROM
AM_RANGE(0x0000, 0xbfff) AM_ROM
- AM_RANGE(0xc000, 0xdfff) AM_READWRITE(yunsung8_videoram_r, yunsung8_videoram_w ) // Video RAM (Banked)
+ AM_RANGE(0xc000, 0xdfff) AM_READWRITE(yunsung8_videoram_r, yunsung8_videoram_w) // Video RAM (Banked)
AM_RANGE(0xe000, 0xffff) AM_RAM
ADDRESS_MAP_END
@@ -109,11 +77,11 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( port_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_READ_PORT("SYSTEM") AM_WRITE(yunsung8_videobank_w) // video RAM bank
- AM_RANGE(0x01, 0x01) AM_READ_PORT("P1") AM_WRITE(yunsung8_bankswitch_w ) // ROM Bank + Layers Enable
- AM_RANGE(0x02, 0x02) AM_READ_PORT("P2") AM_WRITE(soundlatch_w ) // To Sound CPU
+ AM_RANGE(0x01, 0x01) AM_READ_PORT("P1") AM_WRITE(yunsung8_bankswitch_w) // ROM Bank + Layers Enable
+ AM_RANGE(0x02, 0x02) AM_READ_PORT("P2") AM_WRITE(soundlatch_w) // To Sound CPU
AM_RANGE(0x03, 0x03) AM_READ_PORT("DSW1")
AM_RANGE(0x04, 0x04) AM_READ_PORT("DSW2")
- AM_RANGE(0x06, 0x06) AM_WRITE(yunsung8_flipscreen_w ) // Flip Screen
+ AM_RANGE(0x06, 0x06) AM_WRITE(yunsung8_flipscreen_w) // Flip Screen
AM_RANGE(0x07, 0x07) AM_WRITENOP // ? (end of IRQ, random value)
ADDRESS_MAP_END
@@ -127,28 +95,22 @@ ADDRESS_MAP_END
***************************************************************************/
-
-static int adpcm;
-
static WRITE8_DEVICE_HANDLER( yunsung8_sound_bankswitch_w )
{
- UINT8 *RAM = memory_region(device->machine, "audiocpu");
- int bank = data & 7;
-
- if ( bank != (data&(~0x20)) ) logerror("%s: Bank %02X\n",cpuexec_describe_context(device->machine),data);
-
- if (bank < 3) RAM = &RAM[0x4000 * bank];
- else RAM = &RAM[0x4000 * (bank-3) + 0x10000];
+ msm5205_reset_w(device, data & 0x20);
- memory_set_bankptr(device->machine, "bank2", RAM);
+ memory_set_bank(device->machine, "bank2", data & 0x07);
- msm5205_reset_w(device,data & 0x20);
+ if (data != (data & (~0x27)))
+ logerror("%s: Bank %02X\n", cpuexec_describe_context(device->machine), data);
}
static WRITE8_HANDLER( yunsung8_adpcm_w )
{
+ yunsung8_state *state = (yunsung8_state *)space->machine->driver_data;
+
/* Swap the nibbles */
- adpcm = ((data&0xf)<<4) | ((data >>4)&0xf);
+ state->adpcm = ((data & 0xf) << 4) | ((data >> 4) & 0xf);
}
@@ -157,10 +119,10 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2") // Banked ROM
AM_RANGE(0xe000, 0xe000) AM_DEVWRITE("msm", yunsung8_sound_bankswitch_w ) // ROM Bank
- AM_RANGE(0xe400, 0xe400) AM_WRITE(yunsung8_adpcm_w )
- AM_RANGE(0xec00, 0xec01) AM_DEVWRITE("ymsnd", ym3812_w )
+ AM_RANGE(0xe400, 0xe400) AM_WRITE(yunsung8_adpcm_w)
+ AM_RANGE(0xec00, 0xec01) AM_DEVWRITE("ymsnd", ym3812_w)
AM_RANGE(0xf000, 0xf7ff) AM_RAM
- AM_RANGE(0xf800, 0xf800) AM_READ(soundlatch_r ) // From Main CPU
+ AM_RANGE(0xf800, 0xf800) AM_READ(soundlatch_r) // From Main CPU
ADDRESS_MAP_END
@@ -180,18 +142,18 @@ ADDRESS_MAP_END
static INPUT_PORTS_START( magix )
PORT_START("SYSTEM")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
- PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
+ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 )
- PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
+ PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_START("P1")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) // same as button1 !?
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
@@ -200,8 +162,8 @@ static INPUT_PORTS_START( magix )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
PORT_START("P2")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) // same as button1 !?
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
@@ -266,17 +228,17 @@ INPUT_PORTS_END
static INPUT_PORTS_START( cannball )
PORT_START("SYSTEM")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
- PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
+ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 )
- PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
+ PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_START("P1")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
@@ -286,7 +248,7 @@ static INPUT_PORTS_START( cannball )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
PORT_START("P2")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
@@ -356,18 +318,18 @@ INPUT_PORTS_END
static INPUT_PORTS_START( rocktris )
PORT_START("SYSTEM")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
- PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
+ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_IMPULSE(1)
- PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1)
+ PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1)
PORT_START("P1")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) // same as button1 !?
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
@@ -376,8 +338,8 @@ static INPUT_PORTS_START( rocktris )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
PORT_START("P2")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) // same as button1 !?
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
@@ -484,16 +446,16 @@ GFXDECODE_END
***************************************************************************/
-static void yunsung8_adpcm_int(const device_config *device)
+static void yunsung8_adpcm_int( const device_config *device )
{
- static int toggle = 0;
+ yunsung8_state *state = (yunsung8_state *)device->machine->driver_data;
- msm5205_data_w(device, adpcm >> 4);
- adpcm <<= 4;
+ msm5205_data_w(device, state->adpcm >> 4);
+ state->adpcm <<= 4;
- toggle ^= 1;
- if (toggle)
- cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
+ state->toggle ^= 1;
+ if (state->toggle)
+ cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
}
static const msm5205_interface yunsung8_msm5205_interface =
@@ -503,8 +465,46 @@ static const msm5205_interface yunsung8_msm5205_interface =
};
+static MACHINE_START( yunsung8 )
+{
+ yunsung8_state *state = (yunsung8_state *)machine->driver_data;
+ UINT8 *MAIN = memory_region(machine, "maincpu");
+ UINT8 *AUDIO = memory_region(machine, "audiocpu");
+
+ state->videoram = auto_alloc_array(machine, UINT8, 0x4000);
+ state->videoram_0 = state->videoram + 0x0000; // Ram is banked
+ state->videoram_1 = state->videoram + 0x2000;
+
+ memory_configure_bank(machine, "bank1", 0, 3, &MAIN[0x00000], 0x4000);
+ memory_configure_bank(machine, "bank1", 3, 5, &MAIN[0x10000], 0x4000);
+ memory_configure_bank(machine, "bank2", 0, 3, &AUDIO[0x00000], 0x4000);
+ memory_configure_bank(machine, "bank2", 3, 5, &AUDIO[0x10000], 0x4000);
+
+ state->audiocpu = devtag_get_device(machine, "audiocpu");
+
+ state_save_register_global_pointer(machine, state->videoram, 0x4000);
+ state_save_register_global(machine, state->layers_ctrl);
+ state_save_register_global(machine, state->videobank);
+ state_save_register_global(machine, state->adpcm);
+ state_save_register_global(machine, state->toggle);
+}
+
+static MACHINE_RESET( yunsung8 )
+{
+ yunsung8_state *state = (yunsung8_state *)machine->driver_data;
+
+ state->videobank = 0;
+ state->layers_ctrl = 0;
+ state->adpcm = 0;
+ state->toggle = 0;
+}
+
+
static MACHINE_DRIVER_START( yunsung8 )
+ /* driver data */
+ MDRV_DRIVER_DATA(yunsung8_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 8000000) /* Z80B */
MDRV_CPU_PROGRAM_MAP(main_map)
@@ -515,6 +515,7 @@ static MACHINE_DRIVER_START( yunsung8 )
MDRV_CPU_PROGRAM_MAP(sound_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) /* NMI caused by the MSM5205? */
+ MDRV_MACHINE_START(yunsung8)
MDRV_MACHINE_RESET(yunsung8)
/* video hardware */
@@ -702,7 +703,7 @@ ROM_END
***************************************************************************/
-GAME( 1995, cannball, 0, yunsung8, cannball, 0, ROT0, "Yun Sung / Soft Vision", "Cannon Ball (Yun Sung) (horizontal)", GAME_IMPERFECT_SOUND )
-GAME( 1995, cannballv,cannball, yunsung8, cannbalv, 0, ROT270, "Yun Sung / T&K", "Cannon Ball (Yun Sung) (vertical)", GAME_IMPERFECT_SOUND )
-GAME( 1995, magix, 0, yunsung8, magix, 0, ROT0, "Yun Sung", "Magix / Rock", GAME_IMPERFECT_SOUND ) // Title: DSW
-GAME( 1994?, rocktris, 0, yunsung8, rocktris, 0, ROT0, "Yun Sung", "Rock Tris", GAME_IMPERFECT_SOUND )
+GAME( 1995, cannball, 0, yunsung8, cannball, 0, ROT0, "Yun Sung / Soft Vision", "Cannon Ball (Yun Sung) (horizontal)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
+GAME( 1995, cannballv, cannball, yunsung8, cannbalv, 0, ROT270, "Yun Sung / T&K", "Cannon Ball (Yun Sung) (vertical)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
+GAME( 1995, magix, 0, yunsung8, magix, 0, ROT0, "Yun Sung", "Magix / Rock", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
+GAME( 1994?, rocktris, 0, yunsung8, rocktris, 0, ROT0, "Yun Sung", "Rock Tris", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
diff --git a/src/mame/includes/ladybug.h b/src/mame/includes/ladybug.h
new file mode 100644
index 00000000000..3329b3be8a7
--- /dev/null
+++ b/src/mame/includes/ladybug.h
@@ -0,0 +1,78 @@
+/*************************************************************************
+
+ Universal 8106-A2 + 8106-B PCB set
+
+ and Zero Hour / Red Clash
+
+*************************************************************************/
+
+typedef struct _ladybug_state ladybug_state;
+struct _ladybug_state
+{
+ /* memory pointers */
+ UINT8 * videoram;
+ UINT8 * colorram;
+ UINT8 * spriteram;
+ UINT8 * grid_data;
+ size_t spriteram_size;
+
+ /* video-related */
+ tilemap *bg_tilemap, *grid_tilemap; // ladybug
+ tilemap *fg_tilemap; // redclash
+ UINT8 grid_color;
+ int star_speed;
+ int gfxbank; // redclash only
+ UINT8 stars_enable;
+ UINT8 stars_speed;
+ UINT32 stars_state;
+ UINT16 stars_offset;
+ UINT8 stars_count;
+
+ /* misc */
+ UINT8 sound_low;
+ UINT8 sound_high;
+ UINT8 weird_value[8];
+ UINT8 sraider_0x30, sraider_0x38;
+
+ /* devices */
+ const device_config *maincpu;
+};
+
+
+/*----------- defined in video/ladybug.c -----------*/
+
+WRITE8_HANDLER( ladybug_videoram_w );
+WRITE8_HANDLER( ladybug_colorram_w );
+WRITE8_HANDLER( ladybug_flipscreen_w );
+WRITE8_HANDLER( sraider_io_w );
+
+PALETTE_INIT( ladybug );
+VIDEO_START( ladybug );
+VIDEO_UPDATE( ladybug );
+
+PALETTE_INIT( sraider );
+VIDEO_START( sraider );
+VIDEO_UPDATE( sraider );
+VIDEO_EOF( sraider );
+
+/*----------- defined in video/redclash.c -----------*/
+
+WRITE8_HANDLER( redclash_videoram_w );
+WRITE8_HANDLER( redclash_gfxbank_w );
+WRITE8_HANDLER( redclash_flipscreen_w );
+
+WRITE8_HANDLER( redclash_star0_w );
+WRITE8_HANDLER( redclash_star1_w );
+WRITE8_HANDLER( redclash_star2_w );
+WRITE8_HANDLER( redclash_star_reset_w );
+
+PALETTE_INIT( redclash );
+VIDEO_START( redclash );
+VIDEO_UPDATE( redclash );
+VIDEO_EOF( redclash );
+
+/* sraider uses the zerohour star generator board */
+void redclash_set_stars_enable(running_machine *machine, UINT8 on);
+void redclash_update_stars_state(running_machine *machine);
+void redclash_set_stars_speed(running_machine *machine, UINT8 speed);
+void redclash_draw_stars(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx);
diff --git a/src/mame/includes/ladyfrog.h b/src/mame/includes/ladyfrog.h
new file mode 100644
index 00000000000..103d64a35e9
--- /dev/null
+++ b/src/mame/includes/ladyfrog.h
@@ -0,0 +1,49 @@
+/*************************************************************************
+
+ Lady Frog
+
+*************************************************************************/
+
+typedef struct _ladyfrog_state ladyfrog_state;
+struct _ladyfrog_state
+{
+ /* memory pointers */
+ UINT8 * videoram;
+ UINT8 * spriteram;
+ UINT8 * scrlram;
+// UINT8 * paletteram; // currently this uses generic palette handling
+// UINT8 * paletteram2; // currently this uses generic palette handling
+ size_t videoram_size;
+
+ /* video-related */
+ tilemap *bg_tilemap;
+ int tilebank, palette_bank;
+ int spritetilebase;
+
+ /* misc */
+ int sound_nmi_enable, pending_nmi;
+ int snd_flag;
+ UINT8 snd_data;
+
+ /* devices */
+ const device_config *audiocpu;
+};
+
+
+/*----------- defined in video/ladyfrog.c -----------*/
+
+WRITE8_HANDLER( ladyfrog_videoram_w );
+WRITE8_HANDLER( ladyfrog_spriteram_w );
+WRITE8_HANDLER( ladyfrog_palette_w );
+WRITE8_HANDLER( ladyfrog_gfxctrl_w );
+WRITE8_HANDLER( ladyfrog_gfxctrl2_w );
+WRITE8_HANDLER( ladyfrog_scrlram_w );
+
+READ8_HANDLER( ladyfrog_spriteram_r );
+READ8_HANDLER( ladyfrog_palette_r );
+READ8_HANDLER( ladyfrog_scrlram_r );
+READ8_HANDLER( ladyfrog_videoram_r );
+
+VIDEO_START( ladyfrog );
+VIDEO_START( toucheme );
+VIDEO_UPDATE( ladyfrog );
diff --git a/src/mame/includes/lastduel.h b/src/mame/includes/lastduel.h
new file mode 100644
index 00000000000..6a8379deac5
--- /dev/null
+++ b/src/mame/includes/lastduel.h
@@ -0,0 +1,41 @@
+/*************************************************************************
+
+ Last Duel
+
+*************************************************************************/
+
+typedef struct _lastduel_state lastduel_state;
+struct _lastduel_state
+{
+ /* memory pointers */
+ UINT16 * vram;
+ UINT16 * scroll1;
+ UINT16 * scroll2;
+// UINT16 * spriteram; // this currently uses generic buffered spriteram
+ UINT16 * paletteram;
+
+ /* video-related */
+ tilemap *bg_tilemap, *fg_tilemap, *tx_tilemap;
+ UINT16 scroll[8];
+ int sprite_flipy_mask, sprite_pri_mask, tilemap_priority;
+
+ /* devices */
+ const device_config *audiocpu;
+};
+
+/*----------- defined in video/lastduel.c -----------*/
+
+WRITE16_HANDLER( lastduel_vram_w );
+WRITE16_HANDLER( lastduel_flip_w );
+WRITE16_HANDLER( lastduel_scroll1_w );
+WRITE16_HANDLER( lastduel_scroll2_w );
+WRITE16_HANDLER( madgear_scroll1_w );
+WRITE16_HANDLER( madgear_scroll2_w );
+WRITE16_HANDLER( lastduel_scroll_w );
+WRITE16_HANDLER( lastduel_palette_word_w );
+
+VIDEO_START( lastduel );
+VIDEO_START( madgear );
+VIDEO_UPDATE( lastduel );
+VIDEO_UPDATE( madgear );
+VIDEO_EOF( lastduel );
diff --git a/src/mame/includes/lwings.h b/src/mame/includes/lwings.h
index aeb8f3e1931..0381fe2acee 100644
--- a/src/mame/includes/lwings.h
+++ b/src/mame/includes/lwings.h
@@ -1,7 +1,30 @@
-/*----------- defined in video/lwings.c -----------*/
-extern UINT8 *lwings_fgvideoram;
-extern UINT8 *lwings_bg1videoram;
+typedef struct _lwings_state lwings_state;
+struct _lwings_state
+{
+ /* memory pointers */
+ UINT8 * fgvideoram;
+ UINT8 * bg1videoram;
+ UINT8 * soundlatch2;
+// UINT8 * spriteram; // currently this uses generic buffered spriteram
+// UINT8 * paletteram; // currently this uses generic palette handling
+// UINT8 * paletteram2; // currently this uses generic palette handling
+
+ /* video-related */
+ tilemap *fg_tilemap, *bg1_tilemap, *bg2_tilemap;
+ UINT8 bg2_image;
+ int bg2_avenger_hw;
+ UINT8 scroll_x[2], scroll_y[2];
+
+ /* misc */
+ UINT8 param[4];
+ int palette_pen;
+ UINT8 soundstate;
+ UINT8 adpcm;
+};
+
+
+/*----------- defined in video/lwings.c -----------*/
WRITE8_HANDLER( lwings_fgvideoram_w );
WRITE8_HANDLER( lwings_bg1videoram_w );
@@ -9,6 +32,7 @@ WRITE8_HANDLER( lwings_bg1_scrollx_w );
WRITE8_HANDLER( lwings_bg1_scrolly_w );
WRITE8_HANDLER( trojan_bg2_scrollx_w );
WRITE8_HANDLER( trojan_bg2_image_w );
+
VIDEO_START( lwings );
VIDEO_START( trojan );
VIDEO_START( avengers );
diff --git a/src/mame/includes/yunsung8.h b/src/mame/includes/yunsung8.h
new file mode 100644
index 00000000000..49c756dff9e
--- /dev/null
+++ b/src/mame/includes/yunsung8.h
@@ -0,0 +1,36 @@
+/*************************************************************************
+
+ Yun Sung 8 Bit Games
+
+*************************************************************************/
+
+typedef struct _yunsung8_state yunsung8_state;
+struct _yunsung8_state
+{
+ /* memory pointers */
+ UINT8 * videoram;
+
+ /* video-related */
+ tilemap *tilemap_0, *tilemap_1;
+ UINT8 *videoram_0, *videoram_1;
+ int layers_ctrl;
+ int videobank;
+
+ /* misc */
+ int adpcm;
+ int toggle;
+
+ /* devices */
+ const device_config *audiocpu;
+};
+
+
+/*----------- defined in video/yunsung8.c -----------*/
+
+WRITE8_HANDLER( yunsung8_videobank_w );
+READ8_HANDLER ( yunsung8_videoram_r );
+WRITE8_HANDLER( yunsung8_videoram_w );
+WRITE8_HANDLER( yunsung8_flipscreen_w );
+
+VIDEO_START( yunsung8 );
+VIDEO_UPDATE( yunsung8 );
diff --git a/src/mame/video/ladybug.c b/src/mame/video/ladybug.c
index a270525ce7a..181c4739b91 100644
--- a/src/mame/video/ladybug.c
+++ b/src/mame/video/ladybug.c
@@ -8,19 +8,7 @@
#include "driver.h"
#include "video/resnet.h"
-
-
-UINT8 *sraider_grid_data;
-static UINT8 sraider_grid_color;
-
-/* Use the Zero Hour star generator board */
-void redclash_set_stars_enable( UINT8 on );
-void redclash_update_stars_state(void);
-void redclash_set_stars_speed( UINT8 speed );
-void redclash_draw_stars(bitmap_t *bitmap, const rectangle *cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx);
-
-static tilemap *bg_tilemap;
-static tilemap *grid_tilemap;
+#include "includes/ladybug.h"
/***************************************************************************
@@ -41,8 +29,8 @@ static tilemap *grid_tilemap;
***************************************************************************/
-static void palette_init_common(running_machine *machine, const UINT8 *color_prom, int colortable_size,
- int r_bit0, int r_bit1, int g_bit0, int g_bit1, int b_bit0, int b_bit1)
+static void palette_init_common( running_machine *machine, const UINT8 *color_prom, int colortable_size,
+ int r_bit0, int r_bit1, int g_bit0, int g_bit1, int b_bit0, int b_bit1 )
{
static const int resistances[2] = { 470, 220 };
double rweights[2], gweights[2], bweights[2];
@@ -149,14 +137,16 @@ PALETTE_INIT( sraider )
WRITE8_HANDLER( ladybug_videoram_w )
{
- space->machine->generic.videoram.u8[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+ state->videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( ladybug_colorram_w )
{
- space->machine->generic.colorram.u8[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+ state->colorram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( ladybug_flipscreen_w )
@@ -168,81 +158,10 @@ WRITE8_HANDLER( ladybug_flipscreen_w )
}
}
-////////////////////////////////////////////////
-/* All this should probably go somewhere else */
-
-/* Sound comm between CPU's */
-static UINT8 sraider_sound_low;
-
-READ8_HANDLER( sraider_sound_low_r )
-{
- return sraider_sound_low;
-}
-
-static UINT8 sraider_sound_high;
-
-READ8_HANDLER( sraider_sound_high_r )
-{
- return sraider_sound_high;
-}
-
-WRITE8_HANDLER( sraider_sound_low_w )
-{
- sraider_sound_low = data;
-}
-
-WRITE8_HANDLER( sraider_sound_high_w )
-{
- sraider_sound_high = data;
-}
-
-/* Protection? */
-
-READ8_HANDLER( sraider_8005_r )
-{
- /* This must return X011111X or cpu #1 will hang */
- /* see code at rst $10 */
- return 0x3e;
-}
-
-/* Unknown IO */
-
-static UINT8 sraider_wierd_value[8];
-static UINT8 sraider_0x30, sraider_0x38;
-
-WRITE8_HANDLER( sraider_misc_w )
-{
- switch(offset)
- {
- /* These 8 bits are stored in the latch at A7 */
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07:
- sraider_wierd_value[offset&7] = data&1;
- break;
- /* These 6 bits are stored in the latch at N7 */
- case 0x08:
- sraider_0x30 = data&0x3f;
- break;
- /* These 6 bits are stored in the latch at N8 */
- case 0x10:
- sraider_0x38 = data&0x3f;
- break;
- default:
- mame_printf_debug("(%04X) write to %02X\n",cpu_get_pc(space->cpu),offset);
- break;
- }
-}
-
-////////////////////////////////////////////////////
-
WRITE8_HANDLER( sraider_io_w )
{
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+
// bit7 = flip
// bit6 = grid red
// bit5 = grid green
@@ -256,9 +175,9 @@ WRITE8_HANDLER( sraider_io_w )
tilemap_mark_all_tiles_dirty_all(space->machine);
}
- sraider_grid_color = data & 0x70;
+ state->grid_color = data & 0x70;
- redclash_set_stars_enable((data&0x08)>>3);
+ redclash_set_stars_enable(space->machine, (data & 0x08) >> 3);
/*
* There must be a subtle clocking difference between
@@ -266,13 +185,14 @@ WRITE8_HANDLER( sraider_io_w )
* hence the -1 here
*/
- redclash_set_stars_speed((data&0x07) - 1);
+ redclash_set_stars_speed(space->machine, (data & 0x07) - 1);
}
static TILE_GET_INFO( get_bg_tile_info )
{
- int code = machine->generic.videoram.u8[tile_index] + 32 * (machine->generic.colorram.u8[tile_index] & 0x08);
- int color = machine->generic.colorram.u8[tile_index] & 0x07;
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ int code = state->videoram[tile_index] + 32 * (state->colorram[tile_index] & 0x08);
+ int color = state->colorram[tile_index] & 0x07;
SET_TILE_INFO(0, code, color, 0);
}
@@ -283,7 +203,7 @@ static TILE_GET_INFO( get_grid_tile_info )
SET_TILE_INFO(3, tile_index, 0, 0);
else
{
- int temp = tile_index/32;
+ int temp = tile_index / 32;
tile_index = (31 - temp) * 32 + (tile_index % 32);
SET_TILE_INFO(4, tile_index, 0, 0);
}
@@ -291,28 +211,33 @@ static TILE_GET_INFO( get_grid_tile_info )
VIDEO_START( ladybug )
{
- bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
- tilemap_set_scroll_rows(bg_tilemap, 32);
- tilemap_set_transparent_pen(bg_tilemap, 0);
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+
+ state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ tilemap_set_scroll_rows(state->bg_tilemap, 32);
+ tilemap_set_transparent_pen(state->bg_tilemap, 0);
}
VIDEO_START( sraider )
{
- grid_tilemap = tilemap_create(machine, get_grid_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
- tilemap_set_scroll_rows(grid_tilemap, 32);
- tilemap_set_transparent_pen(grid_tilemap, 0);
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
- bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
- tilemap_set_scroll_rows(bg_tilemap, 32);
- tilemap_set_transparent_pen(bg_tilemap, 0);
+ state->grid_tilemap = tilemap_create(machine, get_grid_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ tilemap_set_scroll_rows(state->grid_tilemap, 32);
+ tilemap_set_transparent_pen(state->grid_tilemap, 0);
+
+ state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ tilemap_set_scroll_rows(state->bg_tilemap, 32);
+ tilemap_set_transparent_pen(state->bg_tilemap, 0);
}
-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 = machine->generic.spriteram.u8;
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ UINT8 *spriteram = state->spriteram;
int offs;
- for (offs = machine->generic.spriteram_size - 2*0x40;offs >= 2*0x40;offs -= 0x40)
+ for (offs = state->spriteram_size - 2 * 0x40; offs >= 2 * 0x40; offs -= 0x40)
{
int i = 0;
@@ -359,10 +284,11 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( ladybug )
{
+ ladybug_state *state = (ladybug_state *)screen->machine->driver_data;
int offs;
// clear the bg bitmap
- bitmap_fill(bitmap,cliprect,0);
+ bitmap_fill(bitmap, cliprect, 0);
for (offs = 0; offs < 32; offs++)
{
@@ -370,23 +296,25 @@ VIDEO_UPDATE( ladybug )
int sy = offs / 4;
if (flip_screen_get(screen->machine))
- tilemap_set_scrollx(bg_tilemap, offs, -screen->machine->generic.videoram.u8[32 * sx + sy]);
+ tilemap_set_scrollx(state->bg_tilemap, offs, -state->videoram[32 * sx + sy]);
else
- tilemap_set_scrollx(bg_tilemap, offs, screen->machine->generic.videoram.u8[32 * sx + sy]);
+ tilemap_set_scrollx(state->bg_tilemap, offs, state->videoram[32 * sx + sy]);
}
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}
VIDEO_EOF( sraider ) /* update starfield position */
{
- redclash_update_stars_state();
+ redclash_update_stars_state(machine);
}
VIDEO_UPDATE( sraider )
{
+ ladybug_state *state = (ladybug_state *)screen->machine->driver_data;
+
// this part is boilerplate from ladybug, not sure if hardware does this,
// since it's not used
@@ -399,32 +327,31 @@ VIDEO_UPDATE( sraider )
int sy = offs / 4;
if (flip_screen_get(screen->machine))
- tilemap_set_scrollx(bg_tilemap, offs, -screen->machine->generic.videoram.u8[32 * sx + sy]);
+ tilemap_set_scrollx(state->bg_tilemap, offs, -state->videoram[32 * sx + sy]);
else
- tilemap_set_scrollx(bg_tilemap, offs, screen->machine->generic.videoram.u8[32 * sx + sy]);
+ tilemap_set_scrollx(state->bg_tilemap, offs, state->videoram[32 * sx + sy]);
}
// clear the bg bitmap
- bitmap_fill(bitmap,cliprect,0);
+ bitmap_fill(bitmap, cliprect, 0);
// draw the stars
if (flip_screen_get(screen->machine))
- redclash_draw_stars(bitmap,cliprect,0x60,1,0x27,0xff);
+ redclash_draw_stars(screen->machine, bitmap, cliprect, 0x60, 1, 0x27, 0xff);
else
- redclash_draw_stars(bitmap,cliprect,0x60,1,0x00,0xd8);
+ redclash_draw_stars(screen->machine, bitmap, cliprect, 0x60, 1, 0x00, 0xd8);
// draw the gridlines
- colortable_palette_set_color(screen->machine->colortable, 0x40, MAKE_RGB(sraider_grid_color & 0x40 ? 0xff : 0,
- sraider_grid_color & 0x20 ? 0xff : 0,
- sraider_grid_color & 0x10 ? 0xff : 0));
- tilemap_draw(bitmap, cliprect, grid_tilemap, 0, flip_screen_get(screen->machine));
+ colortable_palette_set_color(screen->machine->colortable, 0x40, MAKE_RGB(state->grid_color & 0x40 ? 0xff : 0,
+ state->grid_color & 0x20 ? 0xff : 0,
+ state->grid_color & 0x10 ? 0xff : 0));
+ tilemap_draw(bitmap, cliprect, state->grid_tilemap, 0, flip_screen_get(screen->machine));
for (i = 0; i < 0x100; i++)
{
- if (sraider_grid_data[i] != 0)
+ if (state->grid_data[i] != 0)
{
UINT8 x = i;
-
int height = cliprect->max_y - cliprect->min_y + 1;
if (flip_screen_get(screen->machine))
@@ -435,11 +362,10 @@ VIDEO_UPDATE( sraider )
}
// now the chars
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, flip_screen_get(screen->machine));
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, flip_screen_get(screen->machine));
// now the sprites
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}
-
diff --git a/src/mame/video/ladyfrog.c b/src/mame/video/ladyfrog.c
index 0f6f5dbc90d..bf8a6b5f3a6 100644
--- a/src/mame/video/ladyfrog.c
+++ b/src/mame/video/ladyfrog.c
@@ -6,121 +6,128 @@
***************************************************************************/
#include "driver.h"
-static int tilebank=0;
+#include "includes/ladyfrog.h"
-static tilemap *bg_tilemap;
-static int palette_bank;
-//static int gfxctrl;
-static int spritetilebase;
-
-UINT8 *ladyfrog_scrlram;
-
-static UINT8 *ladyfrog_spriteram;
WRITE8_HANDLER(ladyfrog_spriteram_w)
{
- ladyfrog_spriteram[offset]=data;
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ state->spriteram[offset] = data;
}
READ8_HANDLER(ladyfrog_spriteram_r)
{
- return ladyfrog_spriteram[offset];
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ return state->spriteram[offset];
}
static TILE_GET_INFO( get_tile_info )
{
- int pal,tile;
- pal=machine->generic.videoram.u8[tile_index*2+1]&0x0f;
- tile=machine->generic.videoram.u8[tile_index*2] + ((machine->generic.videoram.u8[tile_index*2+1] & 0xc0) << 2)+ ((machine->generic.videoram.u8[tile_index*2+1] & 0x30) <<6 );
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
+ int pal = state->videoram[tile_index * 2 + 1] & 0x0f;
+ int tile = state->videoram[tile_index * 2] + ((state->videoram[tile_index * 2 + 1] & 0xc0) << 2)+ ((state->videoram[tile_index * 2 + 1] & 0x30) << 6);
SET_TILE_INFO(
0,
- tile +0x1000 * tilebank,
+ tile + 0x1000 * state->tilebank,
pal,TILE_FLIPY
);
}
WRITE8_HANDLER( ladyfrog_videoram_w )
{
- space->machine->generic.videoram.u8[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap,offset>>1);
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ state->videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset >> 1);
}
READ8_HANDLER( ladyfrog_videoram_r )
{
- return space->machine->generic.videoram.u8[offset];
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ return state->videoram[offset];
}
WRITE8_HANDLER( ladyfrog_palette_w )
{
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+
if (offset & 0x100)
- paletteram_xxxxBBBBGGGGRRRR_split2_w(space, (offset & 0xff) + (palette_bank << 8),data);
+ paletteram_xxxxBBBBGGGGRRRR_split2_w(space, (offset & 0xff) + (state->palette_bank << 8), data);
else
- paletteram_xxxxBBBBGGGGRRRR_split1_w(space, (offset & 0xff) + (palette_bank << 8),data);
+ paletteram_xxxxBBBBGGGGRRRR_split1_w(space, (offset & 0xff) + (state->palette_bank << 8), data);
}
READ8_HANDLER( ladyfrog_palette_r )
{
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+
if (offset & 0x100)
- return space->machine->generic.paletteram2.u8[ (offset & 0xff) + (palette_bank << 8) ];
+ return space->machine->generic.paletteram2.u8[(offset & 0xff) + (state->palette_bank << 8)];
else
- return space->machine->generic.paletteram.u8 [ (offset & 0xff) + (palette_bank << 8) ];
+ return space->machine->generic.paletteram.u8[(offset & 0xff) + (state->palette_bank << 8)];
}
WRITE8_HANDLER( ladyfrog_gfxctrl_w )
{
- palette_bank = (data & 0x20) >> 5;
-
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ state->palette_bank = (data & 0x20) >> 5;
}
WRITE8_HANDLER( ladyfrog_gfxctrl2_w )
{
- tilebank=((data & 0x18) >> 3)^3;
- tilemap_mark_all_tiles_dirty( bg_tilemap );
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ state->tilebank = ((data & 0x18) >> 3) ^ 3;
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
#ifdef UNUSED_FUNCTION
+int gfxctrl;
+
READ8_HANDLER( ladyfrog_gfxctrl_r )
{
- return gfxctrl;
+ return gfxctrl;
}
#endif
READ8_HANDLER( ladyfrog_scrlram_r )
{
- return ladyfrog_scrlram[offset];
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+ return state->scrlram[offset];
}
WRITE8_HANDLER( ladyfrog_scrlram_w )
{
- ladyfrog_scrlram[offset] = data;
- tilemap_set_scrolly(bg_tilemap, offset, data );
+ ladyfrog_state *state = (ladyfrog_state *)space->machine->driver_data;
+
+ state->scrlram[offset] = data;
+ tilemap_set_scrolly(state->bg_tilemap, offset, data);
}
-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 )
{
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
int i;
- for (i=0;i<0x20;i++)
+ for (i = 0; i < 0x20; i++)
{
- int pr = ladyfrog_spriteram[0x9f-i];
+ int pr = state->spriteram[0x9f - i];
int offs = (pr & 0x1f) * 4;
{
- int code,sx,sy,flipx,flipy,pal;
- code = ladyfrog_spriteram[offs+2] + ((ladyfrog_spriteram[offs+1] & 0x10) << 4)+spritetilebase;
- pal=ladyfrog_spriteram[offs+1] & 0x0f;
- sx = ladyfrog_spriteram[offs+3];
- sy = 238-ladyfrog_spriteram[offs+0];
- flipx = ((ladyfrog_spriteram[offs+1]&0x40)>>6);
- flipy = ((ladyfrog_spriteram[offs+1]&0x80)>>7);
+ int code, sx, sy, flipx, flipy, pal;
+ code = state->spriteram[offs + 2] + ((state->spriteram[offs + 1] & 0x10) << 4) + state->spritetilebase;
+ pal = state->spriteram[offs + 1] & 0x0f;
+ sx = state->spriteram[offs + 3];
+ sy = 238 - state->spriteram[offs + 0];
+ flipx = ((state->spriteram[offs + 1] & 0x40)>>6);
+ flipy = ((state->spriteram[offs + 1] & 0x80)>>7);
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
code,
pal,
flipx,flipy,
sx,sy,15);
- if(ladyfrog_spriteram[offs+3]>240)
+ if (state->spriteram[offs + 3] > 240)
{
- sx = (ladyfrog_spriteram[offs+3]-256);
+ sx = (state->spriteram[offs + 3] - 256);
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
code,
pal,
@@ -134,33 +141,44 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static VIDEO_START( ladyfrog_common )
{
- ladyfrog_spriteram = auto_alloc_array(machine, UINT8, 160);
- bg_tilemap = tilemap_create( machine, get_tile_info,tilemap_scan_rows,8,8,32,32 );
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
- machine->generic.paletteram.u8 = auto_alloc_array(machine, UINT8, 0x200);
- machine->generic.paletteram2.u8 = auto_alloc_array(machine, UINT8, 0x200);
- tilemap_set_scroll_cols(bg_tilemap,32);
- tilemap_set_scrolldy( bg_tilemap, 15, 15 );
+ state->spriteram = auto_alloc_array(machine, UINT8, 160);
+ state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+
+ machine->generic.paletteram.u8 = auto_alloc_array(machine, UINT8, 0x200);
+ machine->generic.paletteram2.u8 = auto_alloc_array(machine, UINT8, 0x200);
+ tilemap_set_scroll_cols(state->bg_tilemap, 32);
+ tilemap_set_scrolldy(state->bg_tilemap, 15, 15);
+
+ state_save_register_global_pointer(machine, machine->generic.paletteram.u8, 0x200);
+ state_save_register_global_pointer(machine, machine->generic.paletteram2.u8, 0x200);
+ state_save_register_global_pointer(machine, state->spriteram, 160);
}
VIDEO_START( ladyfrog )
{
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
+
// weird, there are sprite tiles at 0x000 and 0x400, but they don't contain all the sprites!
- spritetilebase = 0x800;
+ state->spritetilebase = 0x800;
VIDEO_START_CALL(ladyfrog_common);
}
VIDEO_START( toucheme )
{
- spritetilebase = 0x000;
+ ladyfrog_state *state = (ladyfrog_state *)machine->driver_data;
+
+ state->spritetilebase = 0x000;
VIDEO_START_CALL(ladyfrog_common);
}
VIDEO_UPDATE( ladyfrog )
{
- tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
- draw_sprites(screen->machine,bitmap,cliprect);
+ ladyfrog_state *state = (ladyfrog_state *)screen->machine->driver_data;
+
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
+ draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}
-
diff --git a/src/mame/video/lastduel.c b/src/mame/video/lastduel.c
index 29292498c8d..e81aa7bc21a 100644
--- a/src/mame/video/lastduel.c
+++ b/src/mame/video/lastduel.c
@@ -7,13 +7,7 @@
***************************************************************************/
#include "driver.h"
-
-UINT16 *lastduel_vram,*lastduel_scroll2,*lastduel_scroll1;
-
-static tilemap *bg_tilemap,*fg_tilemap,*tx_tilemap;
-
-static int sprite_flipy_mask,sprite_pri_mask,tilemap_priority;
-
+#include "includes/lastduel.h"
/***************************************************************************
@@ -24,8 +18,9 @@ static int sprite_flipy_mask,sprite_pri_mask,tilemap_priority;
static TILE_GET_INFO( ld_get_bg_tile_info )
{
- int tile = lastduel_scroll2[2*tile_index] & 0x1fff;
- int color = lastduel_scroll2[2*tile_index+1];
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ int tile = state->scroll2[2 * tile_index] & 0x1fff;
+ int color = state->scroll2[2 * tile_index + 1];
SET_TILE_INFO(
2,
tile,color & 0xf,
@@ -34,8 +29,9 @@ static TILE_GET_INFO( ld_get_bg_tile_info )
static TILE_GET_INFO( ld_get_fg_tile_info )
{
- int tile = lastduel_scroll1[2*tile_index] & 0x1fff;
- int color = lastduel_scroll1[2*tile_index+1];
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ int tile = state->scroll1[2 * tile_index] & 0x1fff;
+ int color = state->scroll1[2 * tile_index + 1];
SET_TILE_INFO(
3,
tile,
@@ -46,8 +42,9 @@ static TILE_GET_INFO( ld_get_fg_tile_info )
static TILE_GET_INFO( get_bg_tile_info )
{
- int tile = lastduel_scroll2[tile_index] & 0x1fff;
- int color = lastduel_scroll2[tile_index+0x0800];
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ int tile = state->scroll2[tile_index] & 0x1fff;
+ int color = state->scroll2[tile_index + 0x0800];
SET_TILE_INFO(
2,
tile,
@@ -57,8 +54,9 @@ static TILE_GET_INFO( get_bg_tile_info )
static TILE_GET_INFO( get_fg_tile_info )
{
- int tile = lastduel_scroll1[tile_index] & 0x1fff;
- int color = lastduel_scroll1[tile_index+0x0800];
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ int tile = state->scroll1[tile_index] & 0x1fff;
+ int color = state->scroll1[tile_index + 0x0800];
SET_TILE_INFO(
3,
tile,
@@ -69,7 +67,8 @@ static TILE_GET_INFO( get_fg_tile_info )
static TILE_GET_INFO( get_fix_info )
{
- int tile = lastduel_vram[tile_index];
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ int tile = state->vram[tile_index];
SET_TILE_INFO(
1,
tile & 0x7ff,
@@ -87,33 +86,34 @@ static TILE_GET_INFO( get_fix_info )
VIDEO_START( lastduel )
{
- bg_tilemap = tilemap_create(machine, ld_get_bg_tile_info,tilemap_scan_rows,16,16,64,64);
- fg_tilemap = tilemap_create(machine, ld_get_fg_tile_info,tilemap_scan_rows,16,16,64,64);
- tx_tilemap = tilemap_create(machine, get_fix_info,tilemap_scan_rows,8,8,64,32);
-
- tilemap_set_transmask(fg_tilemap,0,0xffff,0x0001);
- tilemap_set_transmask(fg_tilemap,1,0xf07f,0x0f81);
- tilemap_set_transparent_pen(tx_tilemap,3);
-
- sprite_flipy_mask = 0x40;
- sprite_pri_mask = 0x00;
- tilemap_priority = 0;
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ state->bg_tilemap = tilemap_create(machine, ld_get_bg_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
+ state->fg_tilemap = tilemap_create(machine, ld_get_fg_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
+ state->tx_tilemap = tilemap_create(machine, get_fix_info, tilemap_scan_rows, 8, 8, 64, 32);
+
+ tilemap_set_transmask(state->fg_tilemap, 0, 0xffff, 0x0001);
+ tilemap_set_transmask(state->fg_tilemap, 1, 0xf07f, 0x0f81);
+ tilemap_set_transparent_pen(state->tx_tilemap, 3);
+
+ state->sprite_flipy_mask = 0x40;
+ state->sprite_pri_mask = 0x00;
+ state->tilemap_priority = 0;
}
VIDEO_START( madgear )
{
- bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols,16,16,64,32);
- fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_cols,16,16,64,32);
- tx_tilemap = tilemap_create(machine, get_fix_info,tilemap_scan_rows,8,8,64,32);
-
- tilemap_set_transmask(fg_tilemap,0,0xffff,0x8000);
- tilemap_set_transmask(fg_tilemap,1,0x80ff,0xff00);
- tilemap_set_transparent_pen(tx_tilemap,3);
- tilemap_set_transparent_pen(bg_tilemap,15);
-
- sprite_flipy_mask = 0x80;
- sprite_pri_mask = 0x10;
- tilemap_priority = 0;
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+ state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols,16,16,64,32);
+ state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_cols,16,16,64,32);
+ state->tx_tilemap = tilemap_create(machine, get_fix_info,tilemap_scan_rows,8,8,64,32);
+
+ tilemap_set_transmask(state->fg_tilemap, 0, 0xffff, 0x8000);
+ tilemap_set_transmask(state->fg_tilemap, 1, 0x80ff, 0xff00);
+ tilemap_set_transparent_pen(state->tx_tilemap, 3);
+ tilemap_set_transparent_pen(state->bg_tilemap, 15);
+
+ state->sprite_flipy_mask = 0x80;
+ state->sprite_pri_mask = 0x10;
}
@@ -130,25 +130,25 @@ WRITE16_HANDLER( lastduel_flip_w )
{
flip_screen_set(space->machine, data & 0x01);
- coin_lockout_w(space->machine, 0,~data & 0x10);
- coin_lockout_w(space->machine, 1,~data & 0x20);
- coin_counter_w(space->machine, 0,data & 0x40);
- coin_counter_w(space->machine, 1,data & 0x80);
+ coin_lockout_w(space->machine, 0, ~data & 0x10);
+ coin_lockout_w(space->machine, 1, ~data & 0x20);
+ coin_counter_w(space->machine, 0, data & 0x40);
+ coin_counter_w(space->machine, 1, data & 0x80);
}
}
WRITE16_HANDLER( lastduel_scroll_w )
{
- static UINT16 scroll[8];
+ lastduel_state *state = (lastduel_state *)space->machine->driver_data;
- data = COMBINE_DATA(&scroll[offset]);
+ data = COMBINE_DATA(&state->scroll[offset]);
switch (offset)
{
- case 0: tilemap_set_scrolly(fg_tilemap,0,data); break;
- case 1: tilemap_set_scrollx(fg_tilemap,0,data); break;
- case 2: tilemap_set_scrolly(bg_tilemap,0,data); break;
- case 3: tilemap_set_scrollx(bg_tilemap,0,data); break;
- case 7: tilemap_priority=data; break;
+ case 0: tilemap_set_scrolly(state->fg_tilemap, 0, data); break;
+ case 1: tilemap_set_scrollx(state->fg_tilemap, 0, data); break;
+ case 2: tilemap_set_scrolly(state->bg_tilemap, 0, data); break;
+ case 3: tilemap_set_scrollx(state->bg_tilemap, 0, data); break;
+ case 7: state->tilemap_priority = data; break;
default:
logerror("Unmapped video write %d %04x\n", offset, data);
break;
@@ -157,45 +157,57 @@ WRITE16_HANDLER( lastduel_scroll_w )
WRITE16_HANDLER( lastduel_scroll1_w )
{
- COMBINE_DATA(&lastduel_scroll1[offset]);
- tilemap_mark_tile_dirty(fg_tilemap,offset/2);
+ lastduel_state *state = (lastduel_state *)space->machine->driver_data;
+
+ COMBINE_DATA(&state->scroll1[offset]);
+ tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
}
WRITE16_HANDLER( lastduel_scroll2_w )
{
- COMBINE_DATA(&lastduel_scroll2[offset]);
- tilemap_mark_tile_dirty(bg_tilemap,offset/2);
+ lastduel_state *state = (lastduel_state *)space->machine->driver_data;
+
+ COMBINE_DATA(&state->scroll2[offset]);
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
}
WRITE16_HANDLER( lastduel_vram_w )
{
- COMBINE_DATA(&lastduel_vram[offset]);
- tilemap_mark_tile_dirty(tx_tilemap,offset);
+ lastduel_state *state = (lastduel_state *)space->machine->driver_data;
+
+ COMBINE_DATA(&state->vram[offset]);
+ tilemap_mark_tile_dirty(state->tx_tilemap, offset);
}
WRITE16_HANDLER( madgear_scroll1_w )
{
- COMBINE_DATA(&lastduel_scroll1[offset]);
- tilemap_mark_tile_dirty(fg_tilemap,offset & 0x7ff);
+ lastduel_state *state = (lastduel_state *)space->machine->driver_data;
+
+ COMBINE_DATA(&state->scroll1[offset]);
+ tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x7ff);
}
WRITE16_HANDLER( madgear_scroll2_w )
{
- COMBINE_DATA(&lastduel_scroll2[offset]);
- tilemap_mark_tile_dirty(bg_tilemap,offset & 0x7ff);
+ lastduel_state *state = (lastduel_state *)space->machine->driver_data;
+
+ COMBINE_DATA(&state->scroll2[offset]);
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0x7ff);
}
WRITE16_HANDLER( lastduel_palette_word_w )
{
+ lastduel_state *state = (lastduel_state *)space->machine->driver_data;
+
int red, green, blue, bright;
- data = COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]);
+ data = COMBINE_DATA(&state->paletteram[offset]);
// Brightness parameter interpreted same way as CPS1
- bright = 0x10 + (data&0x0f);
+ bright = 0x10 + (data & 0x0f);
- red = ((data>>12)&0x0f) * bright * 0x11 / 0x1f;
- green = ((data>>8 )&0x0f) * bright * 0x11 / 0x1f;
- blue = ((data>>4 )&0x0f) * bright * 0x11 / 0x1f;
+ red = ((data >> 12) & 0x0f) * bright * 0x11 / 0x1f;
+ green = ((data >> 8) & 0x0f) * bright * 0x11 / 0x1f;
+ blue = ((data >> 4) & 0x0f) * bright * 0x11 / 0x1f;
palette_set_color (space->machine, offset, MAKE_RGB(red, green, blue));
}
@@ -206,33 +218,38 @@ WRITE16_HANDLER( lastduel_palette_word_w )
***************************************************************************/
-static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri)
+static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri )
{
+ lastduel_state *state = (lastduel_state *)machine->driver_data;
+
UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
int offs;
- if (!sprite_pri_mask)
- if (pri == 1) return; /* only low priority sprites in lastduel */
+ if (!state->sprite_pri_mask)
+ if (pri == 1)
+ return; /* only low priority sprites in lastduel */
- for(offs=0x400-4;offs>=0;offs-=4)
+ for (offs = 0x400 - 4; offs >= 0; offs -= 4)
{
- int attr,sy,sx,flipx,flipy,code,color;
+ int attr, sy, sx, flipx, flipy, code, color;
- attr = buffered_spriteram16[offs+1];
- if (sprite_pri_mask) /* only madgear seems to have this */
+ attr = buffered_spriteram16[offs + 1];
+ if (state->sprite_pri_mask) /* only madgear seems to have this */
{
- if (pri==1 && (attr & sprite_pri_mask)) continue;
- if (pri==0 && !(attr & sprite_pri_mask)) continue;
+ if (pri == 1 && (attr & state->sprite_pri_mask))
+ continue;
+ if (pri == 0 && !(attr & state->sprite_pri_mask))
+ continue;
}
code = buffered_spriteram16[offs];
- sx = buffered_spriteram16[offs+3] & 0x1ff;
- sy = buffered_spriteram16[offs+2] & 0x1ff;
+ sx = buffered_spriteram16[offs + 3] & 0x1ff;
+ sy = buffered_spriteram16[offs + 2] & 0x1ff;
if (sy > 0x100)
sy -= 0x200;
flipx = attr & 0x20;
- flipy = attr & sprite_flipy_mask; /* 0x40 for lastduel, 0x80 for madgear */
+ flipy = attr & state->sprite_flipy_mask; /* 0x40 for lastduel, 0x80 for madgear */
color = attr & 0x0f;
if (flip_screen_get(machine))
@@ -254,34 +271,38 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( lastduel )
{
- tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
- tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER1,0);
- draw_sprites(screen->machine,bitmap,cliprect,0);
- tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER0,0);
- draw_sprites(screen->machine,bitmap,cliprect,1);
- tilemap_draw(bitmap,cliprect,tx_tilemap,0,0);
+ lastduel_state *state = (lastduel_state *)screen->machine->driver_data;
+
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_LAYER1, 0);
+ draw_sprites(screen->machine, bitmap, cliprect, 0);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_LAYER0, 0);
+ draw_sprites(screen->machine, bitmap, cliprect, 1);
+ tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0);
return 0;
}
VIDEO_UPDATE( madgear )
{
- if (tilemap_priority)
+ lastduel_state *state = (lastduel_state *)screen->machine->driver_data;
+
+ if (state->tilemap_priority)
{
- tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_OPAQUE,0);
- draw_sprites(screen->machine,bitmap,cliprect,0);
- tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER0,0);
- tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
- draw_sprites(screen->machine,bitmap,cliprect,1);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_LAYER1 | TILEMAP_DRAW_OPAQUE, 0);
+ draw_sprites(screen->machine, bitmap, cliprect, 0);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_LAYER0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
+ draw_sprites(screen->machine, bitmap, cliprect, 1);
}
else
{
- tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_OPAQUE,0);
- tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER1,0);
- draw_sprites(screen->machine,bitmap,cliprect,0);
- tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER0,0);
- draw_sprites(screen->machine,bitmap,cliprect,1);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_OPAQUE, 0);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_LAYER1, 0);
+ draw_sprites(screen->machine, bitmap, cliprect, 0);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_LAYER0, 0);
+ draw_sprites(screen->machine, bitmap, cliprect, 1);
}
- tilemap_draw(bitmap,cliprect,tx_tilemap,0,0);
+ tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0);
return 0;
}
@@ -292,5 +313,5 @@ VIDEO_EOF( lastduel )
/* Spriteram is always 1 frame ahead, suggesting buffering. I can't find
a register to control this so I assume it happens automatically
every frame at the end of vblank */
- buffer_spriteram16_w(space,0,0,0xffff);
+ buffer_spriteram16_w(space, 0, 0, 0xffff);
}
diff --git a/src/mame/video/lwings.c b/src/mame/video/lwings.c
index 4ea60f2fb0d..2cb998a159b 100644
--- a/src/mame/video/lwings.c
+++ b/src/mame/video/lwings.c
@@ -7,13 +7,7 @@
***************************************************************************/
#include "driver.h"
-#include "lwings.h"
-
-UINT8 *lwings_fgvideoram;
-UINT8 *lwings_bg1videoram;
-
-static int bAvengersHardware, bg2_image;
-static tilemap *fg_tilemap, *bg1_tilemap, *bg2_tilemap;
+#include "includes/lwings.h"
/***************************************************************************
@@ -28,10 +22,9 @@ static TILEMAP_MAPPER( get_bg2_memory_offset )
static TILE_GET_INFO( get_fg_tile_info )
{
- int code, color;
-
- code = lwings_fgvideoram[tile_index];
- color = lwings_fgvideoram[tile_index + 0x400];
+ lwings_state *state = (lwings_state *)machine->driver_data;
+ int code = state->fgvideoram[tile_index];
+ int color = state->fgvideoram[tile_index + 0x400];
SET_TILE_INFO(
0,
code + ((color & 0xc0) << 2),
@@ -41,10 +34,9 @@ static TILE_GET_INFO( get_fg_tile_info )
static TILE_GET_INFO( lwings_get_bg1_tile_info )
{
- int code, color;
-
- code = lwings_bg1videoram[tile_index];
- color = lwings_bg1videoram[tile_index + 0x400];
+ lwings_state *state = (lwings_state *)machine->driver_data;
+ int code = state->bg1videoram[tile_index];
+ int color = state->bg1videoram[tile_index + 0x400];
SET_TILE_INFO(
1,
code + ((color & 0xe0) << 3),
@@ -54,26 +46,27 @@ static TILE_GET_INFO( lwings_get_bg1_tile_info )
static TILE_GET_INFO( trojan_get_bg1_tile_info )
{
- int code, color;
-
- code = lwings_bg1videoram[tile_index];
- color = lwings_bg1videoram[tile_index + 0x400];
+ lwings_state *state = (lwings_state *)machine->driver_data;
+ int code = state->bg1videoram[tile_index];
+ int color = state->bg1videoram[tile_index + 0x400];
code += (color & 0xe0)<<3;
SET_TILE_INFO(
1,
code,
- bAvengersHardware ? ((color & 7) ^ 6) : (color & 7),
+ state->bg2_avenger_hw ? ((color & 7) ^ 6) : (color & 7),
((color & 0x10) ? TILE_FLIPX : 0));
+
tileinfo->group = (color & 0x08) >> 3;
}
static TILE_GET_INFO( get_bg2_tile_info )
{
+ lwings_state *state = (lwings_state *)machine->driver_data;
int code, color;
UINT8 *rom = memory_region(machine, "gfx5");
int mask = memory_region_length(machine, "gfx5") - 1;
- tile_index = (tile_index + bg2_image * 0x20) & mask;
+ tile_index = (tile_index + state->bg2_image * 0x20) & mask;
code = rom[tile_index];
color = rom[tile_index + 1];
SET_TILE_INFO(
@@ -91,29 +84,35 @@ static TILE_GET_INFO( get_bg2_tile_info )
VIDEO_START( lwings )
{
- fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,32,32);
- bg1_tilemap = tilemap_create(machine, lwings_get_bg1_tile_info,tilemap_scan_cols, 16,16,32,32);
+ lwings_state *state = (lwings_state *)machine->driver_data;
- tilemap_set_transparent_pen(fg_tilemap,3);
+ state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ state->bg1_tilemap = tilemap_create(machine, lwings_get_bg1_tile_info, tilemap_scan_cols, 16, 16, 32, 32);
+
+ tilemap_set_transparent_pen(state->fg_tilemap, 3);
}
VIDEO_START( trojan )
{
- fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,32,32);
- bg1_tilemap = tilemap_create(machine, trojan_get_bg1_tile_info,tilemap_scan_cols, 16,16,32,32);
- bg2_tilemap = tilemap_create(machine, get_bg2_tile_info, get_bg2_memory_offset, 16,16,32,16);
+ lwings_state *state = (lwings_state *)machine->driver_data;
+
+ state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ state->bg1_tilemap = tilemap_create(machine, trojan_get_bg1_tile_info,tilemap_scan_cols, 16, 16, 32, 32);
+ state->bg2_tilemap = tilemap_create(machine, get_bg2_tile_info, get_bg2_memory_offset, 16, 16, 32, 16);
- tilemap_set_transparent_pen(fg_tilemap,3);
- tilemap_set_transmask(bg1_tilemap,0,0xffff,0x0001); /* split type 0 is totally transparent in front half */
- tilemap_set_transmask(bg1_tilemap,1,0xf07f,0x0f81); /* split type 1 has pens 7-11 opaque in front half */
+ tilemap_set_transparent_pen(state->fg_tilemap, 3);
+ tilemap_set_transmask(state->bg1_tilemap, 0, 0xffff, 0x0001); /* split type 0 is totally transparent in front half */
+ tilemap_set_transmask(state->bg1_tilemap, 1, 0xf07f, 0x0f81); /* split type 1 has pens 7-11 opaque in front half */
- bAvengersHardware = 0;
+ state->bg2_avenger_hw = 0;
}
VIDEO_START( avengers )
{
+ lwings_state *state = (lwings_state *)machine->driver_data;
+
VIDEO_START_CALL(trojan);
- bAvengersHardware = 1;
+ state->bg2_avenger_hw = 1;
}
/***************************************************************************
@@ -124,44 +123,47 @@ VIDEO_START( avengers )
WRITE8_HANDLER( lwings_fgvideoram_w )
{
- lwings_fgvideoram[offset] = data;
- tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff);
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ state->fgvideoram[offset] = data;
+ tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
}
WRITE8_HANDLER( lwings_bg1videoram_w )
{
- lwings_bg1videoram[offset] = data;
- tilemap_mark_tile_dirty(bg1_tilemap,offset & 0x3ff);
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ state->bg1videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg1_tilemap, offset & 0x3ff);
}
WRITE8_HANDLER( lwings_bg1_scrollx_w )
{
- static UINT8 scroll[2];
-
- scroll[offset] = data;
- tilemap_set_scrollx(bg1_tilemap,0,scroll[0] | (scroll[1] << 8));
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ state->scroll_x[offset] = data;
+ tilemap_set_scrollx(state->bg1_tilemap, 0, state->scroll_x[0] | (state->scroll_x[1] << 8));
}
WRITE8_HANDLER( lwings_bg1_scrolly_w )
{
- static UINT8 scroll[2];
-
- scroll[offset] = data;
- tilemap_set_scrolly(bg1_tilemap,0,scroll[0] | (scroll[1] << 8));
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ state->scroll_y[offset] = data;
+ tilemap_set_scrolly(state->bg1_tilemap, 0, state->scroll_y[0] | (state->scroll_y[1] << 8));
}
WRITE8_HANDLER( trojan_bg2_scrollx_w )
{
- tilemap_set_scrollx(bg2_tilemap,0,data);
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+ tilemap_set_scrollx(state->bg2_tilemap, 0, data);
}
WRITE8_HANDLER( trojan_bg2_image_w )
{
- if (bg2_image != data)
+ lwings_state *state = (lwings_state *)space->machine->driver_data;
+
+ if (state->bg2_image != data)
{
- bg2_image = data;
- tilemap_mark_all_tiles_dirty(bg2_tilemap);
+ state->bg2_image = data;
+ tilemap_mark_all_tiles_dirty(state->bg2_tilemap);
}
}
@@ -172,10 +174,9 @@ WRITE8_HANDLER( trojan_bg2_image_w )
***************************************************************************/
-INLINE int is_sprite_on(UINT8 *buffered_spriteram, int offs)
+INLINE int is_sprite_on( UINT8 *buffered_spriteram, int offs )
{
- int sx,sy;
-
+ int sx, sy;
sx = buffered_spriteram[offs + 3] - 0x100 * (buffered_spriteram[offs + 1] & 0x01);
sy = buffered_spriteram[offs + 2];
@@ -183,22 +184,21 @@ INLINE int is_sprite_on(UINT8 *buffered_spriteram, int offs)
return sx || sy;
}
-static void lwings_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
+static void lwings_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
UINT8 *buffered_spriteram = machine->generic.buffered_spriteram.u8;
int offs;
-
- for (offs = machine->generic.spriteram_size - 4;offs >= 0;offs -= 4)
+ for (offs = machine->generic.spriteram_size - 4; offs >= 0; offs -= 4)
{
if (is_sprite_on(buffered_spriteram, offs))
{
- int code,color,sx,sy,flipx,flipy;
-
+ int code, color, sx, sy, flipx, flipy;
sx = buffered_spriteram[offs + 3] - 0x100 * (buffered_spriteram[offs + 1] & 0x01);
sy = buffered_spriteram[offs + 2];
- if (sy > 0xf8) sy-=0x100;
+ if (sy > 0xf8)
+ sy -= 0x100;
code = buffered_spriteram[offs] | (buffered_spriteram[offs + 1] & 0xc0) << 2;
color = (buffered_spriteram[offs + 1] & 0x38) >> 3;
flipx = buffered_spriteram[offs + 1] & 0x02;
@@ -220,29 +220,29 @@ static void lwings_draw_sprites(running_machine *machine, bitmap_t *bitmap, cons
}
}
-static void trojan_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
+static void trojan_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
+ lwings_state *state = (lwings_state *)machine->driver_data;
UINT8 *buffered_spriteram = machine->generic.buffered_spriteram.u8;
int offs;
-
- for (offs = machine->generic.spriteram_size - 4;offs >= 0;offs -= 4)
+ for (offs = machine->generic.spriteram_size - 4; offs >= 0; offs -= 4)
{
if (is_sprite_on(buffered_spriteram, offs))
{
- int code,color,sx,sy,flipx,flipy;
-
+ int code, color, sx, sy, flipx, flipy;
sx = buffered_spriteram[offs + 3] - 0x100 * (buffered_spriteram[offs + 1] & 0x01);
sy = buffered_spriteram[offs + 2];
- if (sy > 0xf8) sy-=0x100;
+ if (sy > 0xf8)
+ sy -= 0x100;
code = buffered_spriteram[offs] |
((buffered_spriteram[offs + 1] & 0x20) << 4) |
((buffered_spriteram[offs + 1] & 0x40) << 2) |
((buffered_spriteram[offs + 1] & 0x80) << 3);
color = (buffered_spriteram[offs + 1] & 0x0e) >> 1;
- if( bAvengersHardware )
+ if (state->bg2_avenger_hw)
{
flipx = 0; /* Avengers */
flipy = ~buffered_spriteram[offs + 1] & 0x10;
@@ -271,19 +271,23 @@ static void trojan_draw_sprites(running_machine *machine, bitmap_t *bitmap, cons
VIDEO_UPDATE( lwings )
{
- tilemap_draw(bitmap,cliprect,bg1_tilemap,0,0);
- lwings_draw_sprites(screen->machine,bitmap,cliprect);
- tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
+ lwings_state *state = (lwings_state *)screen->machine->driver_data;
+
+ tilemap_draw(bitmap, cliprect, state->bg1_tilemap, 0, 0);
+ lwings_draw_sprites(screen->machine, bitmap, cliprect);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
VIDEO_UPDATE( trojan )
{
- tilemap_draw(bitmap,cliprect,bg2_tilemap,0,0);
- tilemap_draw(bitmap,cliprect,bg1_tilemap,TILEMAP_DRAW_LAYER1,0);
- trojan_draw_sprites(screen->machine,bitmap,cliprect);
- tilemap_draw(bitmap,cliprect,bg1_tilemap,TILEMAP_DRAW_LAYER0,0);
- tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
+ lwings_state *state = (lwings_state *)screen->machine->driver_data;
+
+ tilemap_draw(bitmap, cliprect, state->bg2_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg1_tilemap, TILEMAP_DRAW_LAYER1, 0);
+ trojan_draw_sprites(screen->machine, bitmap, cliprect);
+ tilemap_draw(bitmap, cliprect, state->bg1_tilemap, TILEMAP_DRAW_LAYER0, 0);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
diff --git a/src/mame/video/redclash.c b/src/mame/video/redclash.c
index 46d1dc03e07..920d6966b0b 100644
--- a/src/mame/video/redclash.c
+++ b/src/mame/video/redclash.c
@@ -7,11 +7,7 @@
***************************************************************************/
#include "driver.h"
-
-static int star_speed;
-static int gfxbank;
-
-static tilemap *fg_tilemap;
+#include "includes/ladybug.h"
/***************************************************************************
@@ -21,6 +17,7 @@ static tilemap *fg_tilemap;
schematics show a different resistor network.
***************************************************************************/
+
PALETTE_INIT( redclash )
{
int i;
@@ -104,15 +101,19 @@ PALETTE_INIT( redclash )
WRITE8_HANDLER( redclash_videoram_w )
{
- space->machine->generic.videoram.u8[offset] = data;
- tilemap_mark_tile_dirty(fg_tilemap, offset);
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+
+ state->videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->fg_tilemap, offset);
}
WRITE8_HANDLER( redclash_gfxbank_w )
{
- if (gfxbank != (data & 0x01))
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+
+ if (state->gfxbank != (data & 0x01))
{
- gfxbank = data & 0x01;
+ state->gfxbank = data & 0x01;
tilemap_mark_all_tiles_dirty_all(space->machine);
}
}
@@ -122,8 +123,8 @@ WRITE8_HANDLER( redclash_flipscreen_w )
flip_screen_set(space->machine, data & 0x01);
}
-void redclash_set_stars_enable( UINT8 on ); //temp
-void redclash_set_stars_speed( UINT8 speed ); //temp
+void redclash_set_stars_enable( running_machine *machine, UINT8 on ); //temp
+void redclash_set_stars_speed( running_machine *machine, UINT8 speed ); //temp
/*
star_speed:
@@ -138,47 +139,57 @@ star_speed:
*/
WRITE8_HANDLER( redclash_star0_w )
{
- star_speed = (star_speed & ~1) | ((data & 1) << 0);
- redclash_set_stars_speed(star_speed);
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+
+ state->star_speed = (state->star_speed & ~1) | ((data & 1) << 0);
+ redclash_set_stars_speed(space->machine, state->star_speed);
}
WRITE8_HANDLER( redclash_star1_w )
{
- star_speed = (star_speed & ~2) | ((data & 1) << 1);
- redclash_set_stars_speed(star_speed);
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+
+ state->star_speed = (state->star_speed & ~2) | ((data & 1) << 1);
+ redclash_set_stars_speed(space->machine, state->star_speed);
}
+
WRITE8_HANDLER( redclash_star2_w )
{
- star_speed = (star_speed & ~4) | ((data & 1) << 2);
- redclash_set_stars_speed(star_speed);
+ ladybug_state *state = (ladybug_state *)space->machine->driver_data;
+
+ state->star_speed = (state->star_speed & ~4) | ((data & 1) << 2);
+ redclash_set_stars_speed(space->machine, state->star_speed);
}
+
WRITE8_HANDLER( redclash_star_reset_w )
{
- redclash_set_stars_enable(1);
+ redclash_set_stars_enable(space->machine, 1);
}
static TILE_GET_INFO( get_fg_tile_info )
{
- int code = machine->generic.videoram.u8[tile_index];
- int color = (machine->generic.videoram.u8[tile_index] & 0x70) >> 4; // ??
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ int code = state->videoram[tile_index];
+ int color = (state->videoram[tile_index] & 0x70) >> 4; // ??
SET_TILE_INFO(0, code, color, 0);
}
VIDEO_START( redclash )
{
- fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows,
- 8, 8, 32, 32);
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
- tilemap_set_transparent_pen(fg_tilemap, 0);
+ state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ tilemap_set_transparent_pen(state->fg_tilemap, 0);
}
-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 = machine->generic.spriteram.u8;
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ UINT8 *spriteram = state->spriteram;
int i, offs;
- for (offs = machine->generic.spriteram_size - 0x20;offs >= 0;offs -= 0x20)
+ for (offs = state->spriteram_size - 0x20; offs >= 0; offs -= 0x20)
{
i = 0;
while (i < 0x20 && spriteram[offs + i] != 0)
@@ -199,7 +210,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
{
case 3: /* 24x24 */
{
- int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((gfxbank & 1) << 4);
+ int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((state->gfxbank & 1) << 4);
drawgfx_transpen(bitmap,cliprect,machine->gfx[3],
code,
@@ -218,7 +229,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
case 2: /* 16x16 */
if (spriteram[offs + i] & 0x20) /* zero hour spaceships */
{
- int code = ((spriteram[offs + i + 1] & 0xf8) >> 3) + ((gfxbank & 1) << 5);
+ int code = ((spriteram[offs + i + 1] & 0xf8) >> 3) + ((state->gfxbank & 1) << 5);
int bank = (spriteram[offs + i + 1] & 0x02) >> 1;
drawgfx_transpen(bitmap,cliprect,machine->gfx[4+bank],
@@ -229,7 +240,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
}
else
{
- int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((gfxbank & 1) << 4);
+ int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((state->gfxbank & 1) << 4);
drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
code,
@@ -248,7 +259,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
break;
case 0:
-popmessage("unknown sprite size 0");
+ popmessage("unknown sprite size 0");
break;
}
}
@@ -256,15 +267,16 @@ popmessage("unknown sprite size 0");
}
}
-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 )
{
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
int offs;
for (offs = 0; offs < 0x20; offs++)
{
-// sx =machine->generic.videoram.u8offs];
- int sx = 8 * offs + (machine->generic.videoram.u8[offs] & 0x07); /* ?? */
- int sy = 0xff - machine->generic.videoram.u8[offs + 0x20];
+// sx = state->videoramoffs];
+ int sx = 8 * offs + (state->videoram[offs] & 0x07); /* ?? */
+ int sy = 0xff - state->videoram[offs + 0x20];
if (flip_screen_get(machine))
{
@@ -290,44 +302,38 @@ static void draw_bullets(running_machine *machine, bitmap_t *bitmap, const recta
* starfield on alternate frames, and then offseting them
*/
-static UINT8 stars_enable = 0;
-static UINT8 stars_speed = 0;
-static UINT32 stars_state = 0;
-static UINT16 stars_offset = 0;
-
/* This line can reset the LFSR to zero and disables the star generator */
-void redclash_set_stars_enable( UINT8 on )
-{
- if ((stars_enable == 0) && (on == 1))
+void redclash_set_stars_enable( running_machine *machine, UINT8 on )
+{ ladybug_state *state = (ladybug_state *)machine->driver_data;
+
+ if ((state->stars_enable == 0) && (on == 1))
{
- stars_offset = 0;
+ state->stars_offset = 0;
}
- stars_enable = on;
+
+ state->stars_enable = on;
}
/* This sets up which starfield to draw and the offset, */
/* To be called from VIDEO_EOF() */
-void redclash_update_stars_state(void)
+void redclash_update_stars_state( running_machine *machine )
{
- static UINT8 count = 0;
-
- if (stars_enable == 0)
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ if (state->stars_enable == 0)
return;
- count++;
- count%=2;
+ state->stars_count++;
+ state->stars_count %= 2;
- if (count == 0)
+ if (state->stars_count == 0)
{
- stars_offset += ((stars_speed*2) - 0x09);
- stars_offset %= 256*256;
- stars_state = 0;
+ state->stars_offset += ((state->stars_speed * 2) - 0x09);
+ state->stars_offset %= 256 * 256;
+ state->stars_state = 0;
}
else
- {
- stars_state = 0x1fc71;
- }
+ state->stars_state = 0x1fc71;
}
/* Set the speed register (3 bits) */
@@ -343,9 +349,10 @@ void redclash_update_stars_state(void)
* 7 right/up fast (+5/2 pix per frame)
*/
-void redclash_set_stars_speed( UINT8 speed )
+void redclash_set_stars_speed( running_machine *machine, UINT8 speed )
{
- stars_speed = speed;
+ ladybug_state *state = (ladybug_state *)machine->driver_data;
+ state->stars_speed = speed;
}
/* Draw the stars */
@@ -353,33 +360,35 @@ void redclash_set_stars_speed( UINT8 speed )
/* Space Raider doesn't use the Va bit, and it is also set up to */
/* window the stars to a certain x range */
-void redclash_draw_stars(bitmap_t *bitmap, const rectangle *cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx)
+void redclash_draw_stars( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx )
{
+ ladybug_state *redclash = (ladybug_state *)machine->driver_data;
int i;
UINT8 tempbit, feedback, star_color, xloc, yloc;
UINT32 state;
- UINT8 hcond,vcond;
+ UINT8 hcond, vcond;
- if (stars_enable == 0)
+ if (redclash->stars_enable == 0)
return;
- state = stars_state;
+ state = redclash->stars_state;
- for(i=0;i<256*256;i++)
+ for(i = 0; i < 256 * 256; i++)
{
- xloc = (stars_offset+i)%256;
- yloc = ((stars_offset+i)/256)%256;
+ xloc = (redclash->stars_offset + i) % 256;
+ yloc = ((redclash->stars_offset + i) /256 ) % 256;
if ((state & 0x10000) == 0)
tempbit = 1;
else
tempbit = 0;
+
if ((state & 0x00020) != 0)
feedback = tempbit ^ 1;
else
feedback = tempbit ^ 0;
- hcond = ((xloc+8) & 0x10) >> 4;
+ hcond = ((xloc + 8) & 0x10) >> 4;
// sraider doesn't have Va hooked up
if (sraider)
@@ -387,8 +396,7 @@ void redclash_draw_stars(bitmap_t *bitmap, const rectangle *cliprect, UINT8 pale
else
vcond = yloc & 0x01;
- if (xloc >= cliprect->min_x && xloc <= cliprect->max_x &&
- yloc >= cliprect->min_y && yloc <= cliprect->max_y)
+ if (xloc >= cliprect->min_x && xloc <= cliprect->max_x && yloc >= cliprect->min_y && yloc <= cliprect->max_y)
{
if ((hcond ^ vcond) == 0)
{
@@ -396,31 +404,33 @@ void redclash_draw_stars(bitmap_t *bitmap, const rectangle *cliprect, UINT8 pale
if (((state & 0x000ff) == 0x000ff) && (feedback == 0))
{
/* used by space raider */
- if ((xloc>=firstx) && (xloc<=lastx))
+ if ((xloc >= firstx) && (xloc <= lastx))
{
star_color = (state >> 9) & 0x1f;
- *BITMAP_ADDR16(bitmap, yloc, xloc) = palette_offset+star_color;
+ *BITMAP_ADDR16(bitmap, yloc, xloc) = palette_offset + star_color;
}
}
}
}
/* update LFSR state */
- state = ((state<<1) & 0x1fffe) | feedback;
+ state = ((state << 1) & 0x1fffe) | feedback;
}
}
VIDEO_EOF( redclash )
{
- redclash_update_stars_state();
+ redclash_update_stars_state(machine);
}
VIDEO_UPDATE( redclash )
{
+ ladybug_state *state = (ladybug_state *)screen->machine->driver_data;
+
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
- redclash_draw_stars(bitmap, cliprect, 0x60, 0, 0x00, 0xff);
+ redclash_draw_stars(screen->machine, bitmap, cliprect, 0x60, 0, 0x00, 0xff);
draw_sprites(screen->machine, bitmap, cliprect);
draw_bullets(screen->machine, bitmap, cliprect);
- tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
diff --git a/src/mame/video/yunsung8.c b/src/mame/video/yunsung8.c
index 531ba249803..610230085f2 100644
--- a/src/mame/video/yunsung8.c
+++ b/src/mame/video/yunsung8.c
@@ -28,16 +28,7 @@ Note: if MAME_DEBUG is defined, pressing Z with:
***************************************************************************/
#include "driver.h"
-
-/* Variables that driver has access to: */
-
-UINT8 *yunsung8_videoram_0, *yunsung8_videoram_1;
-int yunsung8_layers_ctrl;
-
-/* Variables only used here: */
-
-static tilemap *tilemap_0, *tilemap_1;
-static int yunsung8_videobank;
+#include "includes/yunsung8.h"
/***************************************************************************
@@ -48,61 +39,79 @@ static int yunsung8_videobank;
WRITE8_HANDLER( yunsung8_videobank_w )
{
- yunsung8_videobank = data;
+ yunsung8_state *state = (yunsung8_state *)space->machine->driver_data;
+ state->videobank = data;
}
READ8_HANDLER( yunsung8_videoram_r )
{
+ yunsung8_state *state = (yunsung8_state *)space->machine->driver_data;
int bank;
/* Bit 1 of the bankswitching register contols the c000-c7ff
area (Palette). Bit 0 controls the c800-dfff area (Tiles) */
- if (offset < 0x0800) bank = yunsung8_videobank & 2;
- else bank = yunsung8_videobank & 1;
+ if (offset < 0x0800)
+ bank = state->videobank & 2;
+ else
+ bank = state->videobank & 1;
- if (bank) return yunsung8_videoram_0[offset];
- else return yunsung8_videoram_1[offset];
+ if (bank)
+ return state->videoram_0[offset];
+ else
+ return state->videoram_1[offset];
}
WRITE8_HANDLER( yunsung8_videoram_w )
{
+ yunsung8_state *state = (yunsung8_state *)space->machine->driver_data;
+
if (offset < 0x0800) // c000-c7ff Banked Palette RAM
{
- int bank = yunsung8_videobank & 2;
+ int bank = state->videobank & 2;
UINT8 *RAM;
int color;
- if (bank) RAM = yunsung8_videoram_0;
- else RAM = yunsung8_videoram_1;
+ if (bank)
+ RAM = state->videoram_0;
+ else
+ RAM = state->videoram_1;
RAM[offset] = data;
color = RAM[offset & ~1] | (RAM[offset | 1] << 8);
/* BBBBBGGGGGRRRRRx */
- palette_set_color_rgb(space->machine, offset/2 + (bank ? 0x400:0), pal5bit(color >> 0), pal5bit(color >> 5), pal5bit(color >> 10));
+ palette_set_color_rgb(space->machine, offset / 2 + (bank ? 0x400 : 0), pal5bit(color >> 0), pal5bit(color >> 5), pal5bit(color >> 10));
}
else
{
int tile;
- int bank = yunsung8_videobank & 1;
-
- if (offset < 0x1000) tile = (offset-0x0800); // c800-cfff: Banked Color RAM
- else tile = (offset-0x1000)/2; // d000-dfff: Banked Tiles RAM
-
- if (bank) { yunsung8_videoram_0[offset] = data;
- tilemap_mark_tile_dirty(tilemap_0, tile); }
- else { yunsung8_videoram_1[offset] = data;
- tilemap_mark_tile_dirty(tilemap_1, tile); }
+ int bank = state->videobank & 1;
+
+ if (offset < 0x1000)
+ tile = (offset - 0x0800); // c800-cfff: Banked Color RAM
+ else
+ tile = (offset - 0x1000) / 2; // d000-dfff: Banked Tiles RAM
+
+ if (bank)
+ {
+ state->videoram_0[offset] = data;
+ tilemap_mark_tile_dirty(state->tilemap_0, tile);
+ }
+ else
+ {
+ state->videoram_1[offset] = data;
+ tilemap_mark_tile_dirty(state->tilemap_1, tile);
+ }
}
}
WRITE8_HANDLER( yunsung8_flipscreen_w )
{
- tilemap_set_flip_all(space->machine, (data & 1) ? (TILEMAP_FLIPX|TILEMAP_FLIPY) : 0);
+ tilemap_set_flip_all(space->machine, (data & 1) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
}
@@ -127,8 +136,9 @@ WRITE8_HANDLER( yunsung8_flipscreen_w )
static TILE_GET_INFO( get_tile_info_0 )
{
- int code = yunsung8_videoram_0[0x1000+tile_index * 2 + 0] + yunsung8_videoram_0[0x1000+tile_index * 2 + 1] * 256;
- int color = yunsung8_videoram_0[0x0800+ tile_index] & 0x07;
+ yunsung8_state *state = (yunsung8_state *)machine->driver_data;
+ int code = state->videoram_0[0x1000 + tile_index * 2 + 0] + state->videoram_0[0x1000 + tile_index * 2 + 1] * 256;
+ int color = state->videoram_0[0x0800 + tile_index] & 0x07;
SET_TILE_INFO(
0,
code,
@@ -143,8 +153,9 @@ static TILE_GET_INFO( get_tile_info_0 )
static TILE_GET_INFO( get_tile_info_1 )
{
- int code = yunsung8_videoram_1[0x1000+ tile_index * 2 + 0] + yunsung8_videoram_1[0x1000+tile_index * 2 + 1] * 256;
- int color = yunsung8_videoram_1[0x0800+ tile_index] & 0x3f;
+ yunsung8_state *state = (yunsung8_state *)machine->driver_data;
+ int code = state->videoram_1[0x1000 + tile_index * 2 + 0] + state->videoram_1[0x1000 + tile_index * 2 + 1] * 256;
+ int color = state->videoram_1[0x0800 + tile_index] & 0x3f;
SET_TILE_INFO(
1,
code,
@@ -165,13 +176,12 @@ static TILE_GET_INFO( get_tile_info_1 )
VIDEO_START( yunsung8 )
{
- tilemap_0 = tilemap_create( machine, get_tile_info_0, tilemap_scan_rows,
- 8,8, DIM_NX_0, DIM_NY_0 );
+ yunsung8_state *state = (yunsung8_state *)machine->driver_data;
- tilemap_1 = tilemap_create( machine, get_tile_info_1, tilemap_scan_rows,
- 8,8, DIM_NX_1, DIM_NY_1 );
+ state->tilemap_0 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 8, 8, DIM_NX_0, DIM_NY_0 );
+ state->tilemap_1 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 8, 8, DIM_NX_1, DIM_NY_1 );
- tilemap_set_transparent_pen(tilemap_1,0);
+ tilemap_set_transparent_pen(state->tilemap_1, 0);
}
@@ -186,7 +196,8 @@ VIDEO_START( yunsung8 )
VIDEO_UPDATE( yunsung8 )
{
- int layers_ctrl = (~yunsung8_layers_ctrl) >> 4;
+ yunsung8_state *state = (yunsung8_state *)screen->machine->driver_data;
+ int layers_ctrl = (~state->layers_ctrl) >> 4;
#ifdef MAME_DEBUG
if (input_code_pressed(screen->machine, KEYCODE_Z))
@@ -198,9 +209,13 @@ if (input_code_pressed(screen->machine, KEYCODE_Z))
}
#endif
- if (layers_ctrl&1) tilemap_draw(bitmap,cliprect, tilemap_0, 0,0);
- else bitmap_fill(bitmap,cliprect,0);
+ if (layers_ctrl & 1)
+ tilemap_draw(bitmap, cliprect, state->tilemap_0, 0, 0);
+ else
+ bitmap_fill(bitmap, cliprect, 0);
+
+ if (layers_ctrl & 2)
+ tilemap_draw(bitmap, cliprect, state->tilemap_1, 0, 0);
- if (layers_ctrl&2) tilemap_draw(bitmap,cliprect, tilemap_1, 0,0);
return 0;
}