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

Appoooh memory map (preliminary)
Similar to Bank Panic

driver by Tatsuyuki Satoh


0000-9fff ROM
a000-dfff BANKED ROM
e000-e7ff RAM
e800-efff RAM??

write:
f000-f01f Sprite RAM #1
f020-f3ff Video  RAM #1
f420-f7ff Color  RAM #1
f800-f81f Sprite RAM #2
f820-fbff Video  RAM #2
fc20-ffff Color  RAM #2

I/O

read:
00  IN0
01  IN1
03  DSW
04  IN2

write:
00  SN76496 #1
01  SN76496 #2
02  SN76496 #3
03  MSM5205 address write
04  bit 0   = NMI enable
    bit 1   = flipscreen
    bit 2-3 = ?
    bit 4-5 = priority
    bit 6   = bank rom select
    bit 7   = ?
05  horizontal scroll ??

Credits:
- Tatsuyuki Satoh: MAME driver

16.08.2004 - TS - Added 'Robo Wres 2001'

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

#include "driver.h"
#include "appoooh.h"
#include "machine/segacrpt.h"

static unsigned char *adpcmptr = 0;
static int appoooh_adpcm_data;

static void appoooh_adpcm_int(int num)
{
	if( adpcmptr )
	{
		if( appoooh_adpcm_data==-1)
		{
			appoooh_adpcm_data = *adpcmptr++;
			MSM5205_data_w(0,appoooh_adpcm_data >> 4);
			if(appoooh_adpcm_data==0x70)
			{
				adpcmptr = 0;
				MSM5205_reset_w(0,1);
			}
		}else{
			MSM5205_data_w(0,appoooh_adpcm_data & 0x0f );
			appoooh_adpcm_data =-1;
		}
	}
}
/* adpcm address write */
static WRITE_HANDLER( appoooh_adpcm_w )
{
	unsigned char *RAM = memory_region(REGION_SOUND1);
	adpcmptr  = &RAM[data*256];
	MSM5205_reset_w(0,0);
	appoooh_adpcm_data=-1;
}



static MEMORY_READ_START( readmem )
	{ 0x0000, 0x9fff, MRA_ROM },
	{ 0xa000, 0xdfff, MRA_BANK1 },
	{ 0xe000, 0xe7ff, MRA_RAM },
	{ 0xe800, 0xefff, MRA_RAM }, /* RAM ? */
	{ 0xf000, 0xffff, MRA_RAM },
MEMORY_END

static MEMORY_WRITE_START( writemem )
	{ 0x0000, 0xdfff, MWA_ROM },
	{ 0xe000, 0xe7ff, MWA_RAM },
	{ 0xe800, 0xefff, MWA_RAM }, /* RAM ? */
	{ 0xf000, 0xf01f, MWA_RAM, &spriteram  },
	{ 0xf020, 0xf3ff, appoooh_fg_videoram_w, &appoooh_fg_videoram },
	{ 0xf420, 0xf7ff, appoooh_fg_colorram_w, &appoooh_fg_colorram },
	{ 0xf800, 0xf81f, MWA_RAM, &spriteram_2 },
	{ 0xf820, 0xfbff, appoooh_bg_videoram_w, &appoooh_bg_videoram },
	{ 0xfc20, 0xffff, appoooh_bg_colorram_w, &appoooh_bg_colorram },
MEMORY_END

static PORT_READ_START( readport )
	{ 0x00, 0x00, input_port_0_r },	/* IN0 */
	{ 0x01, 0x01, input_port_1_r },	/* IN1 */
	{ 0x03, 0x03, input_port_3_r },	/* DSW */
	{ 0x04, 0x04, input_port_2_r },	/* IN2 */
PORT_END

static PORT_WRITE_START( writeport )
	{ 0x00, 0x00, SN76496_0_w },
	{ 0x01, 0x01, SN76496_1_w },
	{ 0x02, 0x02, SN76496_2_w },
	{ 0x03, 0x03, appoooh_adpcm_w },
	{ 0x04, 0x04, appoooh_out_w  },
	{ 0x05, 0x05, appoooh_scroll_w }, /* unknown */
PORT_END



INPUT_PORTS_START( appoooh )
	PORT_START	/* IN0 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN1 )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN2 )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 )

	PORT_START	/* IN1 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL )

	PORT_START	/* IN2 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_COCKTAIL )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN3 )
	PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNKNOWN )	/* probably unused */

	PORT_START	/* DSW0 */
	PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) )
	PORT_DIPSETTING(    0x03, DEF_STR( 4C_1C ) )
	PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
	PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
	PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
	PORT_DIPSETTING(    0x06, DEF_STR( 1C_4C ) )
	PORT_DIPNAME( 0x18, 0x00, DEF_STR( Coin_B ) )
	PORT_DIPSETTING(    0x18, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x20, DEF_STR( On ) )
	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) )
	PORT_DIPSETTING(    0x40, DEF_STR( Upright ) )
	PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
	PORT_DIPNAME( 0x80, 0x00, DEF_STR( Difficulty ) )
	PORT_DIPSETTING(    0x00, "Easy" )
	PORT_DIPSETTING(    0x80, "Hard" )
INPUT_PORTS_END



static struct GfxLayout charlayout =
{
	8,8,	/* 8*8 characters */
	2048,	/* 2048 characters */
	3,	/* 3 bits per pixel */
	{ 2*2048*8*8, 1*2048*8*8, 0*2048*8*8 },	/* the bitplanes are separated */
	{ 7, 6, 5, 4, 3, 2, 1, 0 },
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
	8*8	/* every char takes 8 consecutive bytes */
};

static struct GfxLayout spritelayout =
{
	16,16,	/* 8*8 characters */
	512,	/* 512 characters */
	3,	/* 3 bits per pixel */
	{ 2*2048*8*8, 1*2048*8*8, 0*2048*8*8 },	/* the bitplanes are separated */
	{ 7, 6, 5, 4, 3, 2, 1, 0 ,
	  8*8+7,8*8+6,8*8+5,8*8+4,8*8+3,8*8+2,8*8+1,8*8+0},
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
	  16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8 },
	32*8	/* every char takes 8 consecutive bytes */
};

static struct GfxDecodeInfo gfxdecodeinfo[] =
{
	{ REGION_GFX1, 0, &charlayout,        0, 32 },
	{ REGION_GFX2, 0, &charlayout,     32*8, 32 },
	{ REGION_GFX1, 0, &spritelayout,      0, 32 },
	{ REGION_GFX2, 0, &spritelayout,   32*8, 32 },
	{ -1 } /* end of array */
};



static struct SN76496interface sn76496_interface =
{
	3,	/* 3 chips */
	{ 18432000/6, 18432000/6, 18432000/6 },	/* ??? */
	{ 30, 30, 30 }
};

static struct MSM5205interface msm5205_interface =
{
	1,					/* 1 chip             */
	384000,				/* 384KHz             */
	{ appoooh_adpcm_int },/* interrupt function */
	{ MSM5205_S64_4B },	/* 6KHz               */
	{ 50 }
};



static MACHINE_DRIVER_START( appoooh )

	/* basic machine hardware */
	MDRV_CPU_ADD(Z80,18432000/6)	/* ??? the main xtal is 18.432 MHz */
	MDRV_CPU_MEMORY(readmem,writemem)
	MDRV_CPU_PORTS(readport,writeport)
	MDRV_CPU_VBLANK_INT(nmi_line_pulse,1)

	MDRV_FRAMES_PER_SECOND(60)
	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(32*8, 32*8)
	MDRV_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
	MDRV_GFXDECODE(gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(32)
	MDRV_COLORTABLE_LENGTH(32*8+32*8)

	MDRV_PALETTE_INIT(appoooh)
	MDRV_VIDEO_START(appoooh)
	MDRV_VIDEO_UPDATE(appoooh)

	/* sound hardware */
	MDRV_SOUND_ADD(SN76496, sn76496_interface)
	MDRV_SOUND_ADD(MSM5205, msm5205_interface)
MACHINE_DRIVER_END

/*

Robo Wres 2001
Sega, (198x, possibly 1986?)

Top Board
---------
PCB No: 834-5990 SEGA 1986
CPU   : NEC D315-5179 (Z80?)
SOUND : OKI MSM5205 + Resonator 384kHz, SN76489 (x3)
RAM   : MB8128 (x1)
OTHER : Volume Pot (x2, labelled VOICE and SOUND)
PALs  : (x1, near EPR-7542.15D, labelled 315-5056)
PROMs : (x1, near EPR-7543.12B, labelled PR7571)
DIPSW : 8 position (x1)
DIPSW Info:

			1	2	3	4	5	6	7	8
-----------------------------------------------------------------------------------
Coin1  
        1Coin 1Credit	OFF	OFF	OFF
	2Coin 1Credit	ON	OFF	OFF
	3Coin 1Credit	OFF	ON	OFF
	4Coin 1Credit	ON	ON	OFF
	1Coin 2Credit	OFF	OFF	ON
	1Coin 3Credit	ON	OFF	ON
	1Coin 4Credit	OFF	ON	ON
	2Coin 3Credit	ON	ON	ON
-----------------------------------------------------------------------------------
Coin2
	1Coin 1Credit				OFF	OFF
	1Coin 2Credit				ON	OFF
	2Coin 1Credit				OFF	ON
	3Coin 1Credit				ON	ON
-----------------------------------------------------------------------------------
Demo Sound
	Off							OFF
	On							ON
-----------------------------------------------------------------------------------
Not Used								OFF	
-----------------------------------------------------------------------------------
Language
	Japanese								OFF
	English									ON
-----------------------------------------------------------------------------------




PCB Edge Connector Pinout		
-------------------------

Parts               Solder
Side                Side
--------------------------------
GND         A  1    GND 
GND         B  2    GND 
COIN 2      C  3    -
1P HOLD     D  4    2P HOLD
1P PUNCH    E  5    2P PUNCH
-           F  6    -
1P START    H  7    2P START
1P KICK     J  8    2P KICK
1P UP       K  9    2P UP
1P DOWN     L  10   2P DOWN
1P LEFT     M  11   2P LEFT
1P RIGHT    N  12   2P RIGHT
COUNTER 1   P  13   COIN 1
COUNTER 2   R  14   SERVICE
RED         S  15   GREEN
BLUE        T  16   SYNC
-           U  17   -
+5          V  18   +5
+5          W  19   +5
+12         X  20   +12
SPEAKER 1   Y  21   SPEAKER 2
SPEAKER GND Z  22   SPEAKER GND



Controls via 8-way Joystick and 3 buttons (Punch, Hold, Kick)



			Byte
ROMs  : 		C'sum (for Mike ;-)
----------------------------------------
EPR-7540.13D    27C256	6A13h
EPR-7541.14D      "	2723h
EPR-7542.15D      "	01E7h
EPR-7543.12B      "	6558h	

PR7571.10A      82s123	0A9Fh




Lower Board
-----------

PCB No: 837-5992
XTAL  : 18.432MHz
RAM   : MB8128 (x2), SONY CXK5813D-55 (x2)
PALs  : (x3, labelled 315-5054, 315-5053, 315-5203)
PROMs : (x2, one near EPR-7547.7D labelled PR7572, one near EPR-7544.7H labelled PR7573)

				Byte
ROMs  : 			C'Sum
-------------------------------------
EPR-7544.7H    27C256  \ 	ED1Ah
EPR-7545.6H      "      |	E6CAh
EPR-7546.5H      "      |	55EAh
EPR-7547.7D      "      | Gfx	EA3Fh
EPR-7548.6D      "      |	5D1Fh
EPR-7549.5D      "     /	16D1h

PR7572.7F      82s129		06F1h  \ Both have
PR7573.7G      82s129		06F1h  / identical contents

*/

INPUT_PORTS_START( robowres )
	PORT_START	/* IN0 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN1 )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN2 )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 )

	PORT_START	/* IN1 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL )

	PORT_START	/* IN2 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_COCKTAIL )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN3 )
	PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNKNOWN )	/* probably unused */

	PORT_START	/* DSW0 */
	PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) )
	PORT_DIPSETTING(    0x03, DEF_STR( 4C_1C ) )
	PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
	PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
	PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
	PORT_DIPSETTING(    0x06, DEF_STR( 1C_4C ) )
	PORT_DIPNAME( 0x18, 0x00, DEF_STR( Coin_B ) )
	PORT_DIPSETTING(    0x18, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x20, DEF_STR( On ) )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_DIPNAME( 0x10, 0x10, "Language" )
	PORT_DIPSETTING(    0x00, "Japanese" )
	PORT_DIPSETTING(    0x10, "English" )
INPUT_PORTS_END

static struct GfxLayout robowres_charlayout =
{
	8,8,
	RGN_FRAC(1,3),
	3,
	{ RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
	{ 7,6,5,4, 3,2,1,0 },
	{ 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8 },
	8*8
};

static struct GfxLayout robowres_spritelayout =
{
	16,16,
	RGN_FRAC(1,3),
	3,
	{ RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) },
	{ 7, 6, 5, 4, 3, 2, 1, 0 ,
	  8*8+7,8*8+6,8*8+5,8*8+4,8*8+3,8*8+2,8*8+1,8*8+0},
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
	  16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8 },
	32*8	/* every char takes 8 consecutive bytes */
};


static struct GfxDecodeInfo robowres_gfxdecodeinfo[] =
{
	{ REGION_GFX1, 0, &robowres_charlayout,        0, 32 },
	{ REGION_GFX2, 0, &robowres_charlayout,     	 0, 32 },
	{ REGION_GFX1, 0, &robowres_spritelayout,      0, 32 },
	{ REGION_GFX2, 0, &robowres_spritelayout,   	 0, 32 },
	{ -1 } /* end of array */
};

static MACHINE_DRIVER_START( robowres )

	/* basic machine hardware */
	MDRV_CPU_ADD(Z80,18432000/6)	/* ??? the main xtal is 18.432 MHz */
	MDRV_CPU_MEMORY(readmem,writemem)
	MDRV_CPU_PORTS(readport,writeport)
	MDRV_CPU_VBLANK_INT(nmi_line_pulse,1)

	MDRV_FRAMES_PER_SECOND(60)
	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(32*8, 32*8)
	MDRV_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
	MDRV_GFXDECODE(robowres_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(32)
	MDRV_COLORTABLE_LENGTH(32*8+32*8)

	MDRV_PALETTE_INIT(robowres)
	MDRV_VIDEO_START(appoooh)
	MDRV_VIDEO_UPDATE(robowres)

	/* sound hardware */
	MDRV_SOUND_ADD(SN76496, sn76496_interface)
	MDRV_SOUND_ADD(MSM5205, msm5205_interface)
MACHINE_DRIVER_END

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

  Game driver(s)

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

ROM_START( appoooh )
	ROM_REGION( 0x14000, REGION_CPU1, 0 )	/* 64k for code + 16k bank */
	ROM_LOAD( "epr-5906.bin", 0x00000, 0x2000, 0xfffae7fe )
	ROM_LOAD( "epr-5907.bin", 0x02000, 0x2000, 0x57696cd6 )
	ROM_LOAD( "epr-5908.bin", 0x04000, 0x2000, 0x4537cddc )
	ROM_LOAD( "epr-5909.bin", 0x06000, 0x2000, 0xcf82718d )
	ROM_LOAD( "epr-5910.bin", 0x08000, 0x2000, 0x312636da )
	ROM_LOAD( "epr-5911.bin", 0x0a000, 0x2000, 0x0bc2acaa ) /* bank0      */
	ROM_LOAD( "epr-5913.bin", 0x0c000, 0x2000, 0xf5a0e6a7 ) /* a000-dfff  */
	ROM_LOAD( "epr-5912.bin", 0x10000, 0x2000, 0x3c3915ab ) /* bank1     */
	ROM_LOAD( "epr-5914.bin", 0x12000, 0x2000, 0x58792d4a ) /* a000-dfff */

	ROM_REGION( 0x0c000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "epr-5895.bin", 0x00000, 0x4000, 0x4b0d4294 )	/* playfield #1 chars */
	ROM_LOAD( "epr-5896.bin", 0x04000, 0x4000, 0x7bc84d75 )
	ROM_LOAD( "epr-5897.bin", 0x08000, 0x4000, 0x745f3ffa )

	ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE )
	ROM_LOAD( "epr-5898.bin", 0x00000, 0x4000, 0xcf01644d )	/* playfield #2 chars */
	ROM_LOAD( "epr-5899.bin", 0x04000, 0x4000, 0x885ad636 )
	ROM_LOAD( "epr-5900.bin", 0x08000, 0x4000, 0xa8ed13f3 )

	ROM_REGION( 0x0220, REGION_PROMS, 0 )
	ROM_LOAD( "pr5921.prm",   0x0000, 0x020, 0xf2437229 ) 	/* palette */
	ROM_LOAD( "pr5922.prm",   0x0020, 0x100, 0x85c542bf ) 	/* charset #1 lookup table */
	ROM_LOAD( "pr5923.prm",   0x0120, 0x100, 0x16acbd53 ) 	/* charset #2 lookup table */

	ROM_REGION( 0xa000, REGION_SOUND1, 0 )	/* adpcm voice data */
	ROM_LOAD( "epr-5901.bin", 0x0000, 0x2000, 0x170a10a4 )
	ROM_LOAD( "epr-5902.bin", 0x2000, 0x2000, 0xf6981640 )
	ROM_LOAD( "epr-5903.bin", 0x4000, 0x2000, 0x0439df50 )
	ROM_LOAD( "epr-5904.bin", 0x6000, 0x2000, 0x9988f2ae )
	ROM_LOAD( "epr-5905.bin", 0x8000, 0x2000, 0xfb5cd70e )
ROM_END

ROM_START( robowres )
	ROM_REGION( 0x1c000*2, REGION_CPU1, 0 )	/* 64k for code + 16k bank */
	ROM_LOAD( "epr-7540.13d", 0x00000, 0x8000, 0xa2a54237 )
	ROM_LOAD( "epr-7541.14d", 0x08000, 0x6000, 0xcbf7d1a8 )
	ROM_CONTINUE(             0x10000, 0x2000 )
	ROM_LOAD( "epr-7542.15d", 0x14000, 0x8000, 0x3475fbd4 )
	ROM_COPY( REGION_CPU1, 0x16000, 0x10000, 0x4000 )
	
	ROM_REGION( 0x18000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "epr-7544.7h", 0x000000, 0x8000, 0x07b846ce )
	ROM_LOAD( "epr-7545.6h", 0x008000, 0x8000, 0xe99897be )
	ROM_LOAD( "epr-7546.5h", 0x010000, 0x8000, 0x1559235a )

	ROM_REGION( 0x18000, REGION_GFX2, ROMREGION_DISPOSE )
	ROM_LOAD( "epr-7547.7d", 0x00000, 0x8000, 0xb87ad4a4 )
	ROM_LOAD( "epr-7548.6d", 0x08000, 0x8000, 0x8b9c75b3 )
	ROM_LOAD( "epr-7549.5d", 0x10000, 0x8000, 0xf640afbb )

	ROM_REGION( 0x0220, REGION_PROMS, 0 )
	ROM_LOAD( "pr7571.10a",   0x00000, 0x0020, 0xe82c6d5c )
	ROM_LOAD( "pr7572.7f",   0x00020, 0x0100, 0x2b083d0c )
	ROM_LOAD( "pr7573.7g",   0x00120, 0x0100, 0x2b083d0c )
	
	ROM_REGION( 0x8000, REGION_SOUND1, 0 )	/* adpcm voice data */
	ROM_LOAD( "epr-7543.12b", 0x00000, 0x8000, 0x4d108c49 )
ROM_END

ROM_START( robowrb )
	ROM_REGION( 0x1c000*2, REGION_CPU1, 0 )	/* 64k for code + 16k bank */
	ROM_LOAD( "dg4.e13",      0x00000, 0x8000, 0xf7585d4f )
	ROM_LOAD( "epr-7541.14d", 0x08000, 0x6000, 0xcbf7d1a8 )
	ROM_CONTINUE(             0x10000, 0x2000 )
	ROM_LOAD( "epr-7542.15d", 0x14000, 0x8000, 0x3475fbd4 )
	ROM_COPY( REGION_CPU1, 0x16000, 0x10000, 0x4000 )
	
	ROM_LOAD( "dg1.f13",      0x1c000, 0x8000, 0xb724968d )
	ROM_COPY( REGION_CPU1,    0x08000, 0x24000, 0x14000 )

	ROM_REGION( 0x18000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "epr-7544.7h", 0x000000, 0x8000, 0x07b846ce )
	ROM_LOAD( "epr-7545.6h", 0x008000, 0x8000, 0xe99897be )
	ROM_LOAD( "epr-7546.5h", 0x010000, 0x8000, 0x1559235a )

	ROM_REGION( 0x18000, REGION_GFX2, ROMREGION_DISPOSE )
	ROM_LOAD( "epr-7547.7d", 0x00000, 0x8000, 0xb87ad4a4 )
	ROM_LOAD( "epr-7548.6d", 0x08000, 0x8000, 0x8b9c75b3 )
	ROM_LOAD( "epr-7549.5d", 0x10000, 0x8000, 0xf640afbb )

	ROM_REGION( 0x0220, REGION_PROMS, 0 )
	ROM_LOAD( "pr7571.10a",   0x00000, 0x0020, 0xe82c6d5c )
	ROM_LOAD( "pr7572.7f",   0x00020, 0x0100, 0x2b083d0c )
	ROM_LOAD( "pr7573.7g",   0x00120, 0x0100, 0x2b083d0c )
	
	ROM_REGION( 0x8000, REGION_SOUND1, 0 )	/* adpcm voice data */
	ROM_LOAD( "epr-7543.12b", 0x00000, 0x8000, 0x4d108c49 )
ROM_END



static DRIVER_INIT(robowres){
	robowres_decode();
}

static DRIVER_INIT(robowrb){
	unsigned char *rom = memory_region(REGION_CPU1);
	int diff = memory_region_length(REGION_CPU1) / 2;
	memory_set_opcode_base(0,rom+diff);
}


GAME( 1984, appoooh, 0, appoooh, appoooh, 0, ROT0, "[Sanritsu] Sega", "Appoooh" )
GAME( 1986, robowres, 0, 				robowres, robowres, robowres,	ROT0, "Sega", "Robo Wres 2001" )
GAME( 1986, robowrb,  robowres, robowres, robowres, robowrb,  ROT0, "bootleg", "Robo Wres 2001 (bootleg)" )
