/***************************************************************************

						  -= Power Instinct =-
							(C) 1993 Atlus

				driver by	Luca Elia (l.elia@tin.it)

CPU:	MC68000
Sound:	OKIM6295

- Note:	To enter test mode press F2 (Test)
		Use 9 (Service Coin) to change page.

TODO:
- sprites flip y (not used by the game)


***************************************************************************/

#include "driver.h"
#include "vidhrdw/generic.h"

/* Variables that vidhrdw has access to */

/* Variables defined in vidhrdw */
extern data16_t *powerins_vram_0, *powerins_vctrl_0;
extern data16_t *powerins_vram_1, *powerins_vctrl_1;

/* Functions defined in vidhrdw */

WRITE16_HANDLER( powerins_flipscreen_w );
WRITE16_HANDLER( powerins_tilebank_w );

WRITE16_HANDLER( powerins_paletteram16_w );

WRITE16_HANDLER( powerins_vram_0_w );
WRITE16_HANDLER( powerins_vram_1_w );

VIDEO_START( powerins );
VIDEO_UPDATE( powerins );


/***************************************************************************

								Memory Maps

***************************************************************************/

static int oki_bank;

static WRITE16_HANDLER( powerins_okibank_w )
{
	if (ACCESSING_LSB)
	{
		unsigned char *RAM = memory_region(REGION_SOUND1);
		int new_bank = data & 0x7;

		if (new_bank != oki_bank)
		{
			oki_bank = new_bank;
			memcpy(&RAM[0x30000],&RAM[0x40000 + 0x10000*new_bank],0x10000);
		}
	}
}

static WRITE_HANDLER( powerina_okibank_w )
{
	/* The OKI6295 ROM space is divided in four banks, each one indepentently
	   controlled. The sample table at the beginning of the addressing space is
	   divided in four pages as well, banked together with the sample data. */

	#define TABLESIZE 0x100
	#define BANKSIZE 0x10000

	int chip	=	offset / 4;
	int banknum	=	offset % 4;

	unsigned char *rom	=	memory_region(REGION_SOUND1 + chip);
	int size			=	memory_region_length(REGION_SOUND1 + chip) - 0x40000;

	int bankaddr		=	data * BANKSIZE;

	if (Machine->sample_rate == 0)	return;

	if (bankaddr >= size)
	{
		bankaddr %= size;
logerror("CPU #1 - PC %06X: chip %d bank %X<-%02X\n",activecpu_get_pc(),chip,banknum,data);
	}

	/* copy the samples */
	if (banknum == 0)		/* skip table */
		memcpy(rom + banknum * BANKSIZE+0x400,rom + 0x40000 + bankaddr+0x400,BANKSIZE-0x400);
	else
		memcpy(rom + banknum * BANKSIZE,rom + 0x40000 + bankaddr,BANKSIZE);

	/* and also copy the samples address table (only for chip #1) */
	rom += banknum * TABLESIZE;
	memcpy(rom,rom + 0x40000 + bankaddr,TABLESIZE);
}

static WRITE16_HANDLER( powerina_soundlatch_w )
{
	if (ACCESSING_LSB)
	{
		soundlatch_w(0, data & 0xff);
	}
}

static READ_HANDLER( powerina_fake_ym2203_r )
{
	return 0x01;
}

static MEMORY_READ16_START( powerins_readmem )
	{ 0x000000, 0x0fffff, MRA16_ROM					},	// ROM
	{ 0x100000, 0x100001, input_port_0_word_r		},	// Coins + Start Buttons
	{ 0x100002, 0x100003, input_port_1_word_r		},	// P1 + P2
	{ 0x100008, 0x100009, input_port_2_word_r		},	// DSW 1
	{ 0x10000a, 0x10000b, input_port_3_word_r		},	// DSW 2
	{ 0x10003e, 0x10003f, OKIM6295_status_0_lsb_r	},	// OKI Status
	{ 0x120000, 0x120fff, MRA16_RAM					},	// Palette
/**/{ 0x130000, 0x130007, MRA16_RAM					},	// VRAM 0 Control
	{ 0x140000, 0x143fff, MRA16_RAM					},	// VRAM 0
	{ 0x170000, 0x170fff, MRA16_RAM					},	// VRAM 1
	{ 0x180000, 0x18ffff, MRA16_RAM					},	// RAM + Sprites
MEMORY_END

static MEMORY_WRITE16_START( powerins_writemem )
	{ 0x000000, 0x0fffff, MWA16_ROM								},	// ROM
	{ 0x100014, 0x100015, powerins_flipscreen_w					},	// Flip Screen
	{ 0x100016, 0x100017, MWA16_NOP								},	// ? always 1
	{ 0x100018, 0x100019, powerins_tilebank_w					},	// Tiles Banking (VRAM 0)
	{ 0x10001e, 0x10001f, powerina_soundlatch_w					},	// Sound Latch
	{ 0x100030, 0x100031, powerins_okibank_w					},	// Sound
	{ 0x10003e, 0x10003f, OKIM6295_data_0_lsb_w					},	//
	{ 0x120000, 0x120fff, powerins_paletteram16_w, &paletteram16	},	// Palette
	{ 0x130000, 0x130007, MWA16_RAM, &powerins_vctrl_0			},	// VRAM 0 Control
	{ 0x140000, 0x143fff, powerins_vram_0_w, &powerins_vram_0	},	// VRAM 0
	{ 0x170000, 0x170fff, powerins_vram_1_w, &powerins_vram_1	},	// VRAM 1
	{ 0x171000, 0x171fff, powerins_vram_1_w						},	// Mirror of VRAM 1?
	{ 0x180000, 0x18ffff, MWA16_RAM, &spriteram16				},	// RAM + Sprites
MEMORY_END

/* There is an hidden test mode screen (set 18ff08 to 4 during test mode)
   that calls the data writtent to $10001e "sound code".
   This is a bootleg, so the original may have a sound CPU */

static MEMORY_READ_START( readmem_snd )
	{ 0x0000, 0xbfff, MRA_ROM },
	{ 0xc000, 0xdfff, MRA_RAM },
	{ 0xe000, 0xe000, soundlatch_r },
MEMORY_END

static MEMORY_WRITE_START( writemem_snd )
	{ 0x0000, 0xbfff, MWA_ROM },
	{ 0xc000, 0xdfff, MWA_RAM },
//	{ 0xe000, 0xe000, MWA_NOP }, // ? written only once ?
//	{ 0xe001, 0xe001, MWA_NOP }, // ?
MEMORY_END

static PORT_READ_START( readport_snd )
	{ 0x00, 0x00, YM2203_status_port_0_r },
	{ 0x01, 0x01, YM2203_read_port_0_r },
	{ 0x80, 0x80, OKIM6295_status_0_r },
	{ 0x88, 0x88, OKIM6295_status_1_r },
PORT_END

static PORT_WRITE_START( writeport_snd )
	{ 0x00, 0x00, YM2203_control_port_0_w },
	{ 0x01, 0x01, YM2203_write_port_0_w },
	{ 0x80, 0x80, OKIM6295_data_0_w },
	{ 0x88, 0x88, OKIM6295_data_1_w },
	{ 0x90, 0x97, powerina_okibank_w },
PORT_END

static PORT_READ_START( readportb_snd )
	{ 0x00, 0x00, powerina_fake_ym2203_r },
	{ 0x01, 0x01, MRA_NOP },
	{ 0x80, 0x80, OKIM6295_status_0_r },
	{ 0x88, 0x88, OKIM6295_status_1_r },
PORT_END

static PORT_WRITE_START( writeportb_snd )
	{ 0x00, 0x00, MWA_NOP },
	{ 0x01, 0x01, MWA_NOP },
	{ 0x80, 0x80, OKIM6295_data_0_w },
	{ 0x88, 0x88, OKIM6295_data_1_w },
	{ 0x90, 0x97, powerina_okibank_w },
PORT_END

/***************************************************************************

								Input Ports

***************************************************************************/

INPUT_PORTS_START( powerins )
	PORT_START	// IN0 - $100000 - Coins
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1    )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2    )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_START1   )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START2   )
	PORT_BITX(0x0020, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN  )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN  )

	PORT_START	// IN1 - $100002 - Player 1 & 2
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT	 | IPF_PLAYER1 )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER1 )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER1 )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER1 )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER1 )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3        | IPF_PLAYER1 )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4        | IPF_PLAYER1 )

	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT	 | IPF_PLAYER2 )
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER2 )
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER2 )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1        | IPF_PLAYER2 )
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2        | IPF_PLAYER2 )
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3        | IPF_PLAYER2 )
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4        | IPF_PLAYER2 )

	PORT_START	// IN2 - $100008 - DSW 1
	PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Free_Play ) )
	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x000e, 0x000e, DEF_STR( Coin_A ) )
	PORT_DIPSETTING(      0x0008, DEF_STR( 4C_1C ) )
	PORT_DIPSETTING(      0x0004, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(      0x000c, DEF_STR( 2C_1C ) )
//	PORT_DIPSETTING(      0x0000, DEF_STR( 2C_1C ) ) /* 2C to start, 1C to continue */
	PORT_DIPSETTING(      0x000e, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
	PORT_DIPSETTING(      0x000a, DEF_STR( 1C_3C ) )
	PORT_DIPSETTING(      0x0002, DEF_STR( 1C_4C ) )
	PORT_DIPNAME( 0x0070, 0x0070, DEF_STR( Coin_B ) )
	PORT_DIPSETTING(      0x0040, DEF_STR( 4C_1C ) )
	PORT_DIPSETTING(      0x0020, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(      0x0060, DEF_STR( 2C_1C ) )
//	PORT_DIPSETTING(      0x0000, DEF_STR( 2C_1C ) ) /* 2C to start, 1C to continue */
	PORT_DIPSETTING(      0x0070, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
	PORT_DIPSETTING(      0x0050, DEF_STR( 1C_3C ) )
	PORT_DIPSETTING(      0x0010, DEF_STR( 1C_4C ) )
	PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On )  )

	PORT_START	// IN3 - $10000a - DSW 2
	PORT_DIPNAME( 0x0001, 0x0001, "Coin Chutes" )
	PORT_DIPSETTING(      0x0001, "1 Chute" )
	PORT_DIPSETTING(      0x0000, "2 Chutes" )
	PORT_DIPNAME( 0x0002, 0x0002, "Join In Mode" )
	PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0002, DEF_STR( On ) )
/*
	In "Join In" mode, a second player can join even if one player has aready
	begun to play.  Please refer to chart below:

	Join In Mode	Credit			Join In		Game Over
	-----------------------------------------------------------------------------------------------
	Join In ON	1C per Player		Anytime		Winner of VS Plays Computer
	Join In OFF	1C = VS Mode 2 players	Cannot		After win VS Game Over for both players

*/
	PORT_DIPNAME( 0x0004, 0x0000, DEF_STR( Demo_Sounds ) )
	PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0008, 0x0008, "Allow Continue" )
	PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0008, DEF_STR( On ) )
	PORT_DIPNAME( 0x0010, 0x0010, "Blood Color" )
	PORT_DIPSETTING(      0x0010, "Red" )
	PORT_DIPSETTING(      0x0000, "Blue" )
	PORT_DIPNAME( 0x0020, 0x0020, "Game Time" )
	PORT_DIPSETTING(      0x0020, "Normal" )
	PORT_DIPSETTING(      0x0000, "Short" )
	PORT_DIPNAME( 0x00c0, 0x00c0, DEF_STR( Difficulty ) )
	PORT_DIPSETTING(      0x0040, "Easy" )
	PORT_DIPSETTING(      0x00c0, "Normal" )
	PORT_DIPSETTING(      0x0080, "Hard" )
	PORT_DIPSETTING(      0x0000, "Hardest" )
INPUT_PORTS_END



/***************************************************************************

								Graphics Layouts

***************************************************************************/

/* 8x8x4 tiles */
static struct GfxLayout layout_8x8x4 =
{
	8,8,
	RGN_FRAC(1,1),
	4,
	{0,1,2,3},
	{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4},
	{0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32},
	8*8*4
};


/* 16x16x4 tiles (made of four 8x8 tiles) */
static struct GfxLayout layout_16x16x4 =
{
	16,16,
	RGN_FRAC(1,1),
	4,
	{0,1,2,3},
	{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4,
	 128*4,129*4,130*4,131*4,132*4,133*4,134*4,135*4},
	{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},
	16*16*4
};


/* 16x16x4 tiles (made of four 8x8 tiles). The bytes are swapped */
static struct GfxLayout layout_16x16x4_swap =
{
	16,16,
	RGN_FRAC(1,1),
	4,
	{0,1,2,3},
	{2*4,3*4,0*4,1*4,6*4,7*4,4*4,5*4,
	 130*4,131*4,128*4,129*4,134*4,135*4,132*4,133*4},
	{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},
	16*16*4
};


static struct GfxDecodeInfo powerins_gfxdecodeinfo[] =
{
	{ REGION_GFX1, 0, &layout_16x16x4,      0x000, 0x20 }, // [0] Tiles
	{ REGION_GFX2, 0, &layout_8x8x4,        0x200, 0x10 }, // [1] Tiles
	{ REGION_GFX3, 0, &layout_16x16x4_swap, 0x400, 0x40 }, // [2] Sprites
	{ -1 }
};






/***************************************************************************

								Machine Drivers

***************************************************************************/

MACHINE_INIT( powerins )
{
	oki_bank = -1;	// samples bank "unitialised"
}

static void powerins_irqhandler(int irq)
{
	cpu_set_irq_line(1,0,irq ? ASSERT_LINE : CLEAR_LINE);
}

static struct YM2203interface powerins_ym2203_interface =
{
	1,
	12000000 / 8,	/* ? */
	{ YM2203_VOL(50,50) },
	{ 0 },
	{ 0 },
	{ 0 },
	{ 0 },
	{ powerins_irqhandler }
};

static struct OKIM6295interface powerins_okim6295_interface =
{
	2,
	{ 16000000/4/165, 16000000/4/165 },		/* 4 Mhz */
	{ REGION_SOUND1, REGION_SOUND2 },
	{ 100, 100 }
};

static struct OKIM6295interface powerina_okim6295_interface =
{
	1,
	{ 6000 },		/* ? */
	{ REGION_SOUND1 },
	{ 100 }
};

static MACHINE_DRIVER_START( powerins )

	/* basic machine hardware */
	MDRV_CPU_ADD(M68000, 12000000)	/* ? (it affects the game's speed!) */
	MDRV_CPU_MEMORY(powerins_readmem,powerins_writemem)
	MDRV_CPU_VBLANK_INT(irq4_line_hold,1)

	MDRV_CPU_ADD(Z80, 6000000) /* 6 MHz */
	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)
	MDRV_CPU_MEMORY(readmem_snd,writemem_snd)
	MDRV_CPU_PORTS(readport_snd,writeport_snd)

	MDRV_FRAMES_PER_SECOND(56)
	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)

	MDRV_MACHINE_INIT(powerins)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(320, 256)
	MDRV_VISIBLE_AREA(0, 320-1, 0+16, 256-16-1)
	MDRV_GFXDECODE(powerins_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(2048)

	MDRV_VIDEO_START(powerins)
	MDRV_VIDEO_UPDATE(powerins)

	/* sound hardware */
	MDRV_SOUND_ADD_TAG("ym2203", YM2203, powerins_ym2203_interface)
	MDRV_SOUND_ADD_TAG("okim6295", OKIM6295, powerins_okim6295_interface)
MACHINE_DRIVER_END

static MACHINE_DRIVER_START( powerina )

	/* basic machine hardware */
	MDRV_CPU_ADD(M68000, 12000000)	/* ? (it affects the game's speed!) */
	MDRV_CPU_MEMORY(powerins_readmem,powerins_writemem)
	MDRV_CPU_VBLANK_INT(irq4_line_hold,1)

	MDRV_FRAMES_PER_SECOND(60)
	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)

	MDRV_MACHINE_INIT(powerins)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(320, 256)
	MDRV_VISIBLE_AREA(0, 320-1, 0+16, 256-16-1)
	MDRV_GFXDECODE(powerins_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(2048)

	MDRV_VIDEO_START(powerins)
	MDRV_VIDEO_UPDATE(powerins)

	/* sound hardware */
	MDRV_SOUND_ADD_TAG("sound", OKIM6295, powerina_okim6295_interface)
MACHINE_DRIVER_END

static MACHINE_DRIVER_START( powerinb )

	/* basic machine hardware */
	MDRV_CPU_ADD(M68000, 12000000)	/* ? (it affects the game's speed!) */
	MDRV_CPU_MEMORY(powerins_readmem,powerins_writemem)
	MDRV_CPU_VBLANK_INT(irq4_line_hold,1)

	MDRV_CPU_ADD(Z80, 6000000) /* 6 MHz */
	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)
	MDRV_CPU_MEMORY(readmem_snd,writemem_snd)
	MDRV_CPU_PORTS(readportb_snd,writeportb_snd)
	MDRV_CPU_PERIODIC_INT(irq0_line_hold, 120)	// YM2203 rate is at 150??

	MDRV_FRAMES_PER_SECOND(60)
	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)

	MDRV_MACHINE_INIT(powerins)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(320, 256)
	MDRV_VISIBLE_AREA(0, 320-1, 0+16, 256-16-1)
	MDRV_GFXDECODE(powerins_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(2048)

	MDRV_VIDEO_START(powerins)
	MDRV_VIDEO_UPDATE(powerins)

	MDRV_SOUND_ADD_TAG("sound", OKIM6295, powerins_okim6295_interface)
MACHINE_DRIVER_END



/***************************************************************************

								ROMs Loading

***************************************************************************/



/***************************************************************************

								Power Instinct

Location     Device       File ID     Checksum
----------------------------------------------
             27C240        ROM1         4EA1    [ MAIN PROGRAM ]
             27C240        ROM2         FE60    [ PROGRAM DATA ]
             27C010        ROM3         B9F7    [  CHARACTER   ]
             27C040        ROM4         2780    [  BACKGROUND  ]
             27C040        ROM5         98E0    [   PCM DATA   ]
            23C1600        ROM6         D9E9    [  BACKGROUND  ]
            23C1600        ROM7         8B04    [  MOTION OBJ  ]
            23C1600        ROM8         54B2    [  MOTION OBJ  ]
            23C1600        ROM9         C7C8    [  MOTION OBJ  ]
            23C1600        ROM10        852A    [  MOTION OBJ  ]

Notes:  This archive is of a bootleg version
        The main program is encrypted, using PLDs

Brief hardware overview
-----------------------

Main processor  -  68000
                -  TPC1020AFN-084C (CPLD)

Sound processor -  Main processor
                -  K-665-9249      (M6295)

***************************************************************************/

ROM_START( powerins )
	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* 68000 Code */
	ROM_LOAD16_WORD_SWAP( "93095-3j.u108", 0x00000, 0x80000, 0x3050a3fb )
	ROM_LOAD16_WORD_SWAP( "93095-4.u109",  0x80000, 0x80000, 0xd3d7a782 )

	ROM_REGION( 0x20000, REGION_CPU2, 0 )		/* Z80 Code */
	ROM_LOAD( "93095-2.u90",  0x00000, 0x20000, 0x4b123cc6 )

	ROM_REGION( 0x280000, REGION_GFX1, ROMREGION_DISPOSE )	/* Layer 0 */
	ROM_LOAD( "93095-5.u16",  0x000000, 0x100000, 0xb1371808 )
	ROM_LOAD( "93095-6.u17",  0x100000, 0x100000, 0x29c85d80 )
	ROM_LOAD( "93095-7.u18",  0x200000, 0x080000, 0x2dd76149 )

	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Layer 1 */
	ROM_LOAD( "93095-1.u15",  0x000000, 0x020000, 0x6a579ee0 )

	ROM_REGION( 0x800000, REGION_GFX3, ROMREGION_DISPOSE )	/* Sprites */
	ROM_LOAD( "93095-12.u116", 0x000000, 0x100000, 0x35f3c2a3 )
	ROM_LOAD( "93095-13.u117", 0x100000, 0x100000, 0x1ebd45da )
	ROM_LOAD( "93095-14.u118", 0x200000, 0x100000, 0x760d871b )
	ROM_LOAD( "93095-15.u119", 0x300000, 0x100000, 0xd011be88 )
	ROM_LOAD( "93095-16.u120", 0x400000, 0x100000, 0xa9c16c9c )
	ROM_LOAD( "93095-17.u121", 0x500000, 0x100000, 0x51b57288 )
	ROM_LOAD( "93095-18.u122", 0x600000, 0x100000, 0xb135e3f2 )
	ROM_LOAD( "93095-19.u123", 0x700000, 0x100000, 0x67695537 )

	ROM_REGION( 0x240000, REGION_SOUND1, 0 )	/* 8 bit adpcm (banked) */
	ROM_LOAD( "93095-10.u48", 0x040000, 0x100000, 0x329ac6c5 )
	ROM_LOAD( "93095-11.u49", 0x140000, 0x100000, 0x75d6097c )

	ROM_REGION( 0x240000, REGION_SOUND2, 0 )	/* 8 bit adpcm (banked) */
	ROM_LOAD( "93095-8.u46",  0x040000, 0x100000, 0xf019bedb )
	ROM_LOAD( "93095-9.u47",  0x140000, 0x100000, 0xadc83765 )

	ROM_REGION( 0x0220, REGION_PROMS, 0 )		/* unknown */
	ROM_LOAD( "22.u81",       0x000000, 0x0020, 0x67d5ec4b )
	ROM_LOAD( "21.u71",       0x000020, 0x0100, 0x182cd81f )
	ROM_LOAD( "20.u54",       0x000100, 0x0100, 0x38bd0e2f )
ROM_END

ROM_START( powerina )
	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* 68000 Code */
	ROM_LOAD16_WORD_SWAP( "rom1", 0x000000, 0x080000, 0xb86c84d6 )
	ROM_LOAD16_WORD_SWAP( "rom2", 0x080000, 0x080000, 0xd3d7a782 )

	ROM_REGION( 0x280000, REGION_GFX1, ROMREGION_DISPOSE )	/* Layer 0 */
	ROM_LOAD( "rom6",  0x000000, 0x200000, 0xb6c10f80 )
	ROM_LOAD( "rom4",  0x200000, 0x080000, 0x2dd76149 )

	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Layer 1 */
	ROM_LOAD( "rom3",  0x000000, 0x020000, 0x6a579ee0 )

	ROM_REGION( 0x800000, REGION_GFX3, ROMREGION_DISPOSE )	/* Sprites */
	ROM_LOAD( "rom10", 0x000000, 0x200000, 0xefad50e8 )
	ROM_LOAD( "rom9",  0x200000, 0x200000, 0x08229592 )
	ROM_LOAD( "rom8",  0x400000, 0x200000, 0xb02fdd6d )
	ROM_LOAD( "rom7",  0x600000, 0x200000, 0x92ab9996 )

	ROM_REGION( 0x090000, REGION_SOUND1, 0 )	/* 8 bit adpcm (banked) */
	ROM_LOAD( "rom5", 0x000000, 0x030000, 0x88579c8f )
	ROM_CONTINUE(     0x040000, 0x050000 )
ROM_END

/***************************************************************************

Power Instinct
Atlus, 1993

This is a bootleg US version with different sound hardware to the existing bootleg set.
The PCB is very large and has 2 plug-in daughterboards and many MASK ROMs.
The addition of the contents of the MASK ROMs would probably equal the contents of presumably
larger MASK ROMs found on the original PCB....

PCB Layout

|-------------------------------------------------------------|
|   M6295    4A 5A                             62256  62256   |
|   M6295    4B 5B                             62256  62256   |
|            4C 5C                             62256  62256   |
|            4D 5D                             62256  62256   |
| Z80        16MHz                             62256  62256   |
| 1F                                           62256  62256   |
| 6264       6116                              62256  62256   |
|            6116                              62256  62256   |
|J                                                            |
|A                                                            |
|M                                                            |
|M                                                            |
|A                                    82S123  11G 12G 13G  14G|
|                                             11I             |
|                           TPC1020  6116     11J             |
|DSW1        6116  6N                6116     11K     13K     |
|DSW2        6116              6264           11L     13L  14M|
|                      82S147  6264           11O     13O  14N|
|                                             11P 12P 13P  14P|
|      2Q    62256                            11Q     13Q     |
|      2R    62256                                    13R     |
|      68000                                                  |
| 12MHz              14.31818MHz                              |
|-------------------------------------------------------------|

Notes:
      68000 clock: 12.000MHz
      Z80 clock  :  6.000MHz
      M6295 clock:  4.000MHz (both); sample rate = 4000000/165 (both)
      VSync      :  60Hz

      ROMs 1F and 6N are 1M MASK (MX27C1000), all other ROMs are 4M MASK (MX27C4000).
      ROMS at 5* are located on a plug-in daughterboard.
      ROMS at 11*, 12*, 13G, 13P and 14* are located on a plug-in daughterboard.
      82S123 and 82S147 are PROMs.

***************************************************************************/

ROM_START( powerinb )
	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* 68000 Code */
	ROM_LOAD16_BYTE( "2q.bin", 0x000000, 0x80000, 0x11bf3f2a )
	ROM_LOAD16_BYTE( "2r.bin", 0x000001, 0x80000, 0xd8d621be )

	ROM_REGION( 0x20000, REGION_CPU2, 0 )		/* Z80 Code */
	ROM_LOAD( "1f.bin",  0x000000, 0x20000, 0x4b123cc6 )

	ROM_REGION( 0x280000, REGION_GFX1, ROMREGION_DISPOSE )	/* Layer 0 */
	ROM_LOAD( "13k.bin", 0x000000, 0x80000, 0x1975b4b8 )
	ROM_LOAD( "13l.bin", 0x080000, 0x80000, 0x376e4919 )
	ROM_LOAD( "13o.bin", 0x100000, 0x80000, 0x0d5ff532 )
	ROM_LOAD( "13q.bin", 0x180000, 0x80000, 0x99b25791 )
	ROM_LOAD( "13r.bin", 0x200000, 0x80000, 0x2dd76149 )

	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Layer 1 */
	ROM_LOAD( "6n.bin", 0x000000, 0x20000, 0x6a579ee0 )

	ROM_REGION( 0x800000, REGION_GFX3, ROMREGION_DISPOSE )	/* Sprites */
	ROM_LOAD16_BYTE( "14g.bin", 0x000000, 0x80000, 0x8b9b89c9 )
	ROM_LOAD16_BYTE( "11g.bin", 0x000001, 0x80000, 0x4d127bdf )
	ROM_LOAD16_BYTE( "13g.bin", 0x100000, 0x80000, 0x298eb50e )
	ROM_LOAD16_BYTE( "11i.bin", 0x100001, 0x80000, 0x57e6d283 )
	ROM_LOAD16_BYTE( "12g.bin", 0x200000, 0x80000, 0xfb184167 )
	ROM_LOAD16_BYTE( "11j.bin", 0x200001, 0x80000, 0x1b752a4d )
	ROM_LOAD16_BYTE( "14m.bin", 0x300000, 0x80000, 0x2f26ba7b )
	ROM_LOAD16_BYTE( "11k.bin", 0x300001, 0x80000, 0x0263d89b )
	ROM_LOAD16_BYTE( "14n.bin", 0x400000, 0x80000, 0xc4633294 )
	ROM_LOAD16_BYTE( "11l.bin", 0x400001, 0x80000, 0x5e4b5655 )
	ROM_LOAD16_BYTE( "14p.bin", 0x500000, 0x80000, 0x4d4b0e4e )
	ROM_LOAD16_BYTE( "11o.bin", 0x500001, 0x80000, 0x7e9f2d2b )
	ROM_LOAD16_BYTE( "13p.bin", 0x600000, 0x80000, 0x0e7671f2 )
	ROM_LOAD16_BYTE( "11p.bin", 0x600001, 0x80000, 0xee59b1ec )
	ROM_LOAD16_BYTE( "12p.bin", 0x700000, 0x80000, 0x9ab1998c )
	ROM_LOAD16_BYTE( "11q.bin", 0x700001, 0x80000, 0x1ab0c88a )

	ROM_REGION( 0x240000, REGION_SOUND1, 0 )	/* 8 bit adpcm (banked) */
	ROM_LOAD( "4a.bin", 0x040000, 0x80000, 0x8cd6824e )
	ROM_LOAD( "4b.bin", 0x0c0000, 0x80000, 0xe31ae04d )
	ROM_LOAD( "4c.bin", 0x140000, 0x80000, 0xc4c9f599 )
	ROM_LOAD( "4d.bin", 0x1c0000, 0x80000, 0xf0a9f0e1 )

	ROM_REGION( 0x240000, REGION_SOUND2, 0 )	/* 8 bit adpcm (banked) */
	ROM_LOAD( "5a.bin", 0x040000, 0x80000, 0x62557502 )
	ROM_LOAD( "5b.bin", 0x0c0000, 0x80000, 0xdbc86bd7 )
	ROM_LOAD( "5c.bin", 0x140000, 0x80000, 0x5839a2bd )
	ROM_LOAD( "5d.bin", 0x1c0000, 0x80000, 0x446f9dc3 )

	ROM_REGION( 0x0220, REGION_PROMS, 0 )		/* unknown */
	ROM_LOAD( "82s123.bin", 0x0000, 0x0020, 0x67d5ec4b )
	ROM_LOAD( "82s147.bin", 0x0020, 0x0200, 0xd7818542 )
ROM_END

/* set only contained the 2 program roms */
ROM_START( powernjb )
	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* 68000 Code */
	/* 32_WORD on a 68k? strange, maybe the bootleg was just hooked up in an unusual way */
	ROM_LOAD32_WORD( "j21.a3", 0x000000, 0x80000, 0x59594382 )
	ROM_LOAD32_WORD( "j22.a3", 0x000002, 0x80000, 0x598e47e3 )

	ROM_REGION( 0x20000, REGION_CPU2, 0 )		/* Z80 Code */
	ROM_LOAD( "1f.bin",  0x000000, 0x20000, 0x4b123cc6 )

	ROM_REGION( 0x280000, REGION_GFX1, ROMREGION_DISPOSE )	/* Layer 0 */
	ROM_LOAD( "13k.bin", 0x000000, 0x80000, 0x1975b4b8 )
	ROM_LOAD( "13l.bin", 0x080000, 0x80000, 0x376e4919 )
	ROM_LOAD( "13o.bin", 0x100000, 0x80000, 0x0d5ff532 )
	ROM_LOAD( "13q.bin", 0x180000, 0x80000, 0x99b25791 )
	ROM_LOAD( "13r.bin", 0x200000, 0x80000, 0x2dd76149 )

	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )	/* Layer 1 */
	ROM_LOAD( "6n.bin", 0x000000, 0x20000, 0x6a579ee0 )

	ROM_REGION( 0x800000, REGION_GFX3, ROMREGION_DISPOSE )	/* Sprites */
	ROM_LOAD16_BYTE( "14g.bin", 0x000000, 0x80000, 0x8b9b89c9 )
	ROM_LOAD16_BYTE( "11g.bin", 0x000001, 0x80000, 0x4d127bdf )
	ROM_LOAD16_BYTE( "13g.bin", 0x100000, 0x80000, 0x298eb50e )
	ROM_LOAD16_BYTE( "11i.bin", 0x100001, 0x80000, 0x57e6d283 )
	ROM_LOAD16_BYTE( "12g.bin", 0x200000, 0x80000, 0xfb184167 )
	ROM_LOAD16_BYTE( "11j.bin", 0x200001, 0x80000, 0x1b752a4d )
	ROM_LOAD16_BYTE( "14m.bin", 0x300000, 0x80000, 0x2f26ba7b )
	ROM_LOAD16_BYTE( "11k.bin", 0x300001, 0x80000, 0x0263d89b )
	ROM_LOAD16_BYTE( "14n.bin", 0x400000, 0x80000, 0xc4633294 )
	ROM_LOAD16_BYTE( "11l.bin", 0x400001, 0x80000, 0x5e4b5655 )
	ROM_LOAD16_BYTE( "14p.bin", 0x500000, 0x80000, 0x4d4b0e4e )
	ROM_LOAD16_BYTE( "11o.bin", 0x500001, 0x80000, 0x7e9f2d2b )
	ROM_LOAD16_BYTE( "13p.bin", 0x600000, 0x80000, 0x0e7671f2 )
	ROM_LOAD16_BYTE( "11p.bin", 0x600001, 0x80000, 0xee59b1ec )
	ROM_LOAD16_BYTE( "12p.bin", 0x700000, 0x80000, 0x9ab1998c )
	ROM_LOAD16_BYTE( "11q.bin", 0x700001, 0x80000, 0x1ab0c88a )

	ROM_REGION( 0x240000, REGION_SOUND1, 0 )	/* 8 bit adpcm (banked) */
	ROM_LOAD( "4a.bin", 0x040000, 0x80000, 0x8cd6824e )
	ROM_LOAD( "4b.bin", 0x0c0000, 0x80000, 0xe31ae04d )
	ROM_LOAD( "4c.bin", 0x140000, 0x80000, 0xc4c9f599 )
	ROM_LOAD( "4d.bin", 0x1c0000, 0x80000, 0xf0a9f0e1 )

	ROM_REGION( 0x240000, REGION_SOUND2, 0 )	/* 8 bit adpcm (banked) */
	ROM_LOAD( "5a.bin", 0x040000, 0x80000, 0x62557502 )
	ROM_LOAD( "5b.bin", 0x0c0000, 0x80000, 0xdbc86bd7 )
	ROM_LOAD( "5c.bin", 0x140000, 0x80000, 0x5839a2bd )
	ROM_LOAD( "5d.bin", 0x1c0000, 0x80000, 0x446f9dc3 )

	ROM_REGION( 0x0220, REGION_PROMS, 0 )		/* unknown */
	ROM_LOAD( "82s123.bin", 0x0000, 0x0020, 0x67d5ec4b )
	ROM_LOAD( "82s147.bin", 0x0020, 0x0200, 0xd7818542 )
ROM_END

GAME( 1993, powerins, 0,        powerins, powerins, 0, ROT0, "Atlus", "Gouketsuji Ichizoku (Japan)" )
GAME( 1993, powerina, powerins, powerina, powerins, 0, ROT0, "Atlus", "Power Instinct (USA, bootleg set 1)" )
GAME( 1993, powerinb, powerins, powerinb, powerins, 0, ROT0, "Atlus", "Power Instinct (USA, bootleg set 2)" )
GAME( 1993, powernjb, powerins, powerinb, powerins, 0, ROT0, "Atlus", "Gouketsuji Ichizoku (Japan, bootleg)" )
