summaryrefslogtreecommitdiffstats
path: root/src/mame/drivers/fcombat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/fcombat.c')
-rw-r--r--src/mame/drivers/fcombat.c237
1 files changed, 131 insertions, 106 deletions
diff --git a/src/mame/drivers/fcombat.c b/src/mame/drivers/fcombat.c
index a72f9777643..48f5e2b6ce8 100644
--- a/src/mame/drivers/fcombat.c
+++ b/src/mame/drivers/fcombat.c
@@ -31,104 +31,20 @@ inputs + notes by stephh
#include "driver.h"
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
-
-
-/* this is compied from Exerion, but it should be correct */
-#define FCOMBAT_MASTER_CLOCK (20000000)
-#define FCOMBAT_CPU_CLOCK (FCOMBAT_MASTER_CLOCK / 6)
-#define FCOMBAT_AY8910_CLOCK (FCOMBAT_CPU_CLOCK / 2)
-#define FCOMBAT_PIXEL_CLOCK (FCOMBAT_MASTER_CLOCK / 3)
-#define FCOMBAT_HCOUNT_START (0x58)
-#define FCOMBAT_HTOTAL (512-FCOMBAT_HCOUNT_START)
-#define FCOMBAT_HBEND (12*8) /* ?? */
-#define FCOMBAT_HBSTART (52*8) /* ?? */
-#define FCOMBAT_VTOTAL (256)
-#define FCOMBAT_VBEND (16)
-#define FCOMBAT_VBSTART (240)
-
-
-PALETTE_INIT( fcombat );
-VIDEO_START( fcombat );
-VIDEO_UPDATE( fcombat );
-
-WRITE8_HANDLER( fcombat_videoreg_w );
-
-extern UINT8 fcombat_cocktail_flip;
-extern int fcombat_sh;
-extern int fcombat_sv;
+#include "fcombat.h"
static INPUT_CHANGED( coin_inserted )
{
+ fcombat_state *state = (fcombat_state *)field->port->machine->driver_data;
+
/* coin insertion causes an NMI */
- cputag_set_input_line(field->port->machine, "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
+ cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
}
-static INPUT_PORTS_START( fcombat )
- PORT_START("IN0") /* player 1 inputs (muxed on 0xe000) */
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
- PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
- PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
- PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
- PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
-
- PORT_START("IN1") /* player 2 inputs (muxed on 0xe000) */
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
- PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
- PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
- PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
- PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
-
- PORT_START("DSW0") /* dip switches (0xe100) */
- PORT_DIPNAME( 0x07, 0x02, DEF_STR( Lives ) )
- PORT_DIPSETTING( 0x00, "1" )
- PORT_DIPSETTING( 0x01, "2" )
- PORT_DIPSETTING( 0x02, "3" )
- PORT_DIPSETTING( 0x03, "4" )
- PORT_DIPSETTING( 0x04, "5" )
- PORT_DIPSETTING( 0x07, "Infinite (Cheat)")
- PORT_DIPNAME( 0x18, 0x00, DEF_STR( Bonus_Life ) )
- PORT_DIPSETTING( 0x00, "10000" )
- PORT_DIPSETTING( 0x08, "20000" )
- PORT_DIPSETTING( 0x10, "30000" )
- PORT_DIPSETTING( 0x18, "40000" )
- PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
- PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x20, DEF_STR( On ) )
- PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unused ) )
- PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x40, DEF_STR( On ) )
- PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
- PORT_DIPSETTING( 0x00, DEF_STR( Upright ) )
- PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) )
-
- PORT_START("DSW1") /* dip switches/VBLANK (0xe200) */
- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK )
- PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) ) // related to vblank
- PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x02, DEF_STR( On ) )
- PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )
- PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) )
- PORT_DIPSETTING( 0x04, DEF_STR( 1C_2C ) )
- PORT_DIPSETTING( 0x08, DEF_STR( 1C_3C ) )
- PORT_DIPSETTING( 0x0c, DEF_STR( 1C_4C ) )
- PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
-
- PORT_START("COIN")
- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED(coin_inserted, 0)
-INPUT_PORTS_END
-
-
/* is it protection? */
-
static READ8_HANDLER( fcombat_protection_r )
{
/* Must match ONE of these values after a "and $3E" intruction :
@@ -145,8 +61,9 @@ static READ8_HANDLER( fcombat_protection_r )
static READ8_HANDLER( fcombat_port01_r )
{
+ fcombat_state *state = (fcombat_state *)space->machine->driver_data;
/* the cocktail flip bit muxes between ports 0 and 1 */
- return fcombat_cocktail_flip ? input_port_read(space->machine, "IN1") : input_port_read(space->machine, "IN0");
+ return state->cocktail_flip ? input_port_read(space->machine, "IN1") : input_port_read(space->machine, "IN0");
}
@@ -154,40 +71,44 @@ static READ8_HANDLER( fcombat_port01_r )
static WRITE8_HANDLER(e900_w)
{
- fcombat_sh=data;
+ fcombat_state *state = (fcombat_state *)space->machine->driver_data;
+ state->fcombat_sh = data;
}
static WRITE8_HANDLER(ea00_w)
{
- fcombat_sv=(fcombat_sv&0xff00)|data;
+ fcombat_state *state = (fcombat_state *)space->machine->driver_data;
+ state->fcombat_sv = (state->fcombat_sv & 0xff00) | data;
}
static WRITE8_HANDLER(eb00_w)
{
- fcombat_sv=(fcombat_sv&0xff)|(data<<8);
+ fcombat_state *state = (fcombat_state *)space->machine->driver_data;
+ state->fcombat_sv = (state->fcombat_sv & 0xff) | (data << 8);
}
// terrain info (ec00=x, ed00=y, return val in e300
-static int tx=0,ty=0;
-
static WRITE8_HANDLER(ec00_w)
{
- tx=data;
+ fcombat_state *state = (fcombat_state *)space->machine->driver_data;
+ state->tx = data;
}
static WRITE8_HANDLER(ed00_w)
{
- ty=data;
+ fcombat_state *state = (fcombat_state *)space->machine->driver_data;
+ state->ty = data;
}
static READ8_HANDLER(e300_r)
{
- int wx=(tx+fcombat_sh)/16;
- int wy=(ty*2+fcombat_sv)/16;
+ fcombat_state *state = (fcombat_state *)space->machine->driver_data;
+ int wx = (state->tx + state->fcombat_sh) / 16;
+ int wy = (state->ty * 2 + state->fcombat_sv) / 16;
- return memory_region(space->machine, "user2")[wx*32*16+wy];
+ return memory_region(space->machine, "user2")[wx * 32 * 16 + wy];
}
static WRITE8_HANDLER(ee00_w)
@@ -198,8 +119,8 @@ static WRITE8_HANDLER(ee00_w)
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0xc000, 0xc7ff) AM_RAM
- AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size)
- AM_RANGE(0xd800, 0xd8ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
+ AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE_MEMBER(fcombat_state, videoram) AM_SIZE(&videoram_size)
+ AM_RANGE(0xd800, 0xd8ff) AM_RAM AM_BASE_MEMBER(fcombat_state, spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0xe000, 0xe000) AM_READ(fcombat_port01_r)
AM_RANGE(0xe100, 0xe100) AM_READ_PORT("DSW0")
AM_RANGE(0xe200, 0xe200) AM_READ_PORT("DSW1")
@@ -232,6 +153,73 @@ ADDRESS_MAP_END
/*************************************
*
+ * Input ports
+ *
+ *************************************/
+
+static INPUT_PORTS_START( fcombat )
+ PORT_START("IN0") /* player 1 inputs (muxed on 0xe000) */
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
+ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
+ PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
+ PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
+ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
+
+ PORT_START("IN1") /* player 2 inputs (muxed on 0xe000) */
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
+ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
+ PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
+ PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
+ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
+
+ PORT_START("DSW0") /* dip switches (0xe100) */
+ PORT_DIPNAME( 0x07, 0x02, DEF_STR( Lives ) )
+ PORT_DIPSETTING( 0x00, "1" )
+ PORT_DIPSETTING( 0x01, "2" )
+ PORT_DIPSETTING( 0x02, "3" )
+ PORT_DIPSETTING( 0x03, "4" )
+ PORT_DIPSETTING( 0x04, "5" )
+ PORT_DIPSETTING( 0x07, "Infinite (Cheat)")
+ PORT_DIPNAME( 0x18, 0x00, DEF_STR( Bonus_Life ) )
+ PORT_DIPSETTING( 0x00, "10000" )
+ PORT_DIPSETTING( 0x08, "20000" )
+ PORT_DIPSETTING( 0x10, "30000" )
+ PORT_DIPSETTING( 0x18, "40000" )
+ PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
+ PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x20, DEF_STR( On ) )
+ PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unused ) )
+ PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x40, DEF_STR( On ) )
+ PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
+ PORT_DIPSETTING( 0x00, DEF_STR( Upright ) )
+ PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) )
+
+ PORT_START("DSW1") /* dip switches/VBLANK (0xe200) */
+ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK )
+ PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) ) // related to vblank
+ PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x02, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )
+ PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) )
+ PORT_DIPSETTING( 0x04, DEF_STR( 1C_2C ) )
+ PORT_DIPSETTING( 0x08, DEF_STR( 1C_3C ) )
+ PORT_DIPSETTING( 0x0c, DEF_STR( 1C_4C ) )
+ PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
+
+ PORT_START("COIN")
+ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED(coin_inserted, 0)
+INPUT_PORTS_END
+
+
+/*************************************
+ *
* Graphics layouts
*
*************************************/
@@ -277,14 +265,51 @@ GFXDECODE_END
*
*************************************/
+static MACHINE_START( fcombat )
+{
+ fcombat_state *state = (fcombat_state *)machine->driver_data;
+
+ state->maincpu = devtag_get_device(machine, "maincpu");
+
+ state_save_register_global(machine, state->cocktail_flip);
+ state_save_register_global(machine, state->char_palette);
+ state_save_register_global(machine, state->sprite_palette);
+ state_save_register_global(machine, state->char_bank);
+ state_save_register_global(machine, state->fcombat_sh);
+ state_save_register_global(machine, state->fcombat_sv);
+ state_save_register_global(machine, state->tx);
+ state_save_register_global(machine, state->ty);
+}
+
+static MACHINE_RESET( fcombat )
+{
+ fcombat_state *state = (fcombat_state *)machine->driver_data;
+
+ state->cocktail_flip = 0;
+ state->char_palette = 0;
+ state->sprite_palette = 0;
+ state->char_bank = 0;
+ state->fcombat_sh = 0;
+ state->fcombat_sv = 0;
+ state->tx = 0;
+ state->ty = 0;
+}
+
static MACHINE_DRIVER_START( fcombat )
+ /* driver data */
+ MDRV_DRIVER_DATA(fcombat_state)
+
+ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 10000000/3)
MDRV_CPU_PROGRAM_MAP(main_map)
MDRV_CPU_ADD("audiocpu", Z80, 10000000/3)
MDRV_CPU_PROGRAM_MAP(audio_map)
+ MDRV_MACHINE_START(fcombat)
+ MDRV_MACHINE_RESET(fcombat)
+
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
@@ -390,8 +415,8 @@ static DRIVER_INIT( fcombat )
for (oldaddr = 0; oldaddr < 32; oldaddr++)
{
- memcpy(&dst[oldaddr*32*8*2],&src[oldaddr*32*8],32*8);
- memcpy(&dst[oldaddr*32*8*2+32*8],&src[oldaddr*32*8+0x2000],32*8);
+ memcpy(&dst[oldaddr * 32 * 8 * 2], &src[oldaddr * 32 * 8], 32 * 8);
+ memcpy(&dst[oldaddr * 32 * 8 * 2 + 32 * 8], &src[oldaddr * 32 * 8 + 0x2000], 32 * 8);
}
@@ -402,8 +427,8 @@ static DRIVER_INIT( fcombat )
for (oldaddr = 0; oldaddr < 32; oldaddr++)
{
- memcpy(&dst[oldaddr*32*8*2],&src[oldaddr*32*8],32*8);
- memcpy(&dst[oldaddr*32*8*2+32*8],&src[oldaddr*32*8+0x2000],32*8);
+ memcpy(&dst[oldaddr * 32 * 8 * 2], &src[oldaddr * 32 * 8], 32 * 8);
+ memcpy(&dst[oldaddr * 32 * 8 * 2 + 32 * 8], &src[oldaddr * 32 * 8 + 0x2000], 32 * 8);
}
free(temp);
@@ -441,4 +466,4 @@ ROM_START( fcombat )
ROM_LOAD( "fcprom_c.a9", 0x0220, 0x0100, CRC(768ac120) SHA1(ceede1d6cbeae08da96ef52bdca2718a839d88ab) ) /* bg char mixer */
ROM_END
-GAME( 1985, fcombat, 0, fcombat, fcombat, fcombat, ROT90, "Jaleco", "Field Combat", GAME_WRONG_COLORS )
+GAME( 1985, fcombat, 0, fcombat, fcombat, fcombat, ROT90, "Jaleco", "Field Combat", GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )