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

	Double Dragon 3 					Technos Japan Corp 1990
	The Combatribes 					Technos Japan Corp 1990


	Notes:

	Both games have original and bootleg versions supported.
	Double Dragon 3 bootleg has some misplaced graphics, but I
	think this is how the real thing would look.
	Double Dragon 3 original cut scenes seem to fade a bit fast?
	Combatribes has sprite lag but it seems to be caused by poor
	programming and I think the original does the same.

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

#include "driver.h"
#include "cpu/z80/z80.h"
#include "cpu/m68000/m68000.h"
#include "vidhrdw/generic.h"

VIDEO_UPDATE( ddragon3 );
VIDEO_UPDATE( ctribe );
WRITE16_HANDLER( ddragon3_scroll16_w );

extern VIDEO_START( ddragon3 );

extern data16_t *ddragon3_bg_videoram16;
WRITE16_HANDLER( ddragon3_bg_videoram16_w );
READ16_HANDLER( ddragon3_bg_videoram16_r );

extern data16_t *ddragon3_fg_videoram16;
WRITE16_HANDLER( ddragon3_fg_videoram16_w );
READ16_HANDLER( ddragon3_fg_videoram16_r );

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

static WRITE_HANDLER( oki_bankswitch_w )
{
	OKIM6295_set_bank_base(0, (data & 1) * 0x40000);
}

static READ16_HANDLER( ddrago3b_io16_r )
{
	switch (offset)
	{
	case 0: return readinputport(0) + 256*((readinputport(3)&0x0f)|((readinputport(4)&0xc0)<<2));
	case 1: return readinputport(1) + 256*(readinputport(4)&0x3f);
	case 2: return readinputport(2) + 256*(readinputport(5)&0x3f);
	case 3: return (readinputport(5)&0xc0)<<2;
	}
	return ~0;
}

static READ16_HANDLER( ctribe_io16_r )
{
	switch (offset)
	{
	case 0: return readinputport(0) + 256*((readinputport(3)&0x0f)|((readinputport(4)&0xc0)<<2));
	case 1: return readinputport(1) + 256*(readinputport(4)&0x3f);
	case 2: return readinputport(2) + 256*(readinputport(5)&0x3f);
	case 3: return 256*(readinputport(5)&0xc0);
	}
	return ~0;
}

static READ16_HANDLER( ddragon3_io16_r )
{
	switch (offset)
	{
	case 0: return readinputport(0);
	case 1: return readinputport(1);
	case 2: return readinputport(2);
	case 3: return readinputport(3);

	default: logerror("INPUT 1800[%02x] \n", offset);
	}
	return ~0;
}

extern UINT16 ddragon3_vreg;

static INTERRUPT_GEN( ddragon3_cpu_interrupt ) { /* 6:0x177e - 5:0x176a */
	if( cpu_getiloops() == 0 ){
		cpu_set_irq_line(0, 6, HOLD_LINE);  /* VBlank */
	}
	else {
		cpu_set_irq_line(0, 5, HOLD_LINE); /* Input Ports */
	}
}

static data16_t reg[8];

static WRITE16_HANDLER( ddragon3_io16_w )
{
	COMBINE_DATA(&reg[offset]);

	switch (offset)
	{
	case 0:
	ddragon3_vreg = reg[0];
	break;

	case 1: /* soundlatch_w */
	soundlatch_w(1,reg[1]&0xff);
	cpu_set_irq_line( 1, IRQ_LINE_NMI, PULSE_LINE );
	break;

	case 2:
	/*	this gets written to on startup and at the end of IRQ6
	**	possibly trigger IRQ on sound CPU
	*/
	break;

	case 3:
	/*	this gets written to on startup,
	**	and at the end of IRQ5 (input port read) */
	break;

	case 4:
	/* this gets written to at the end of IRQ6 only */
	break;

	default:
	logerror("OUTPUT 1400[%02x] %08x, pc=%06x \n", offset,(unsigned)data, activecpu_get_pc() );
	break;
	}
}

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

static MEMORY_READ16_START( readmem )
	{ 0x000000, 0x07ffff, MRA16_ROM },
	{ 0x080000, 0x080fff, MRA16_RAM },	/* Foreground (32x32 Tiles - 4 by per tile) */
	{ 0x082000, 0x0827ff, MRA16_RAM },	/* Background (32x32 Tiles - 2 by per tile) */
	{ 0x100000, 0x100007, ddragon3_io16_r },
	{ 0x140000, 0x1405ff, MRA16_RAM },	/* Palette RAM */
	{ 0x180000, 0x180fff, MRA16_RAM },
	{ 0x1c0000, 0x1c3fff, MRA16_RAM },	/* working RAM */
MEMORY_END

static MEMORY_WRITE16_START( writemem )
	{ 0x000000, 0x07ffff, MWA16_ROM },
	{ 0x080000, 0x080fff, ddragon3_fg_videoram16_w, &ddragon3_fg_videoram16 },
	{ 0x082000, 0x0827ff, ddragon3_bg_videoram16_w, &ddragon3_bg_videoram16 },
	{ 0x0c0000, 0x0c000f, ddragon3_scroll16_w },
	{ 0x100000, 0x10000f, ddragon3_io16_w },
	{ 0x140000, 0x1405ff, paletteram16_xBBBBBGGGGGRRRRR_word_w, &paletteram16 },
	{ 0x180000, 0x180fff, MWA16_RAM, &spriteram16 }, /* Sprites (16 bytes per sprite) */
	{ 0x1c0000, 0x1c3fff, MWA16_RAM },
MEMORY_END

static MEMORY_READ16_START( dd3b_readmem )
	{ 0x000000, 0x07ffff, MRA16_ROM },
	{ 0x080000, 0x080fff, MRA16_RAM },	/* Foreground (32x32 Tiles - 4 by per tile) */
	{ 0x081000, 0x081fff, MRA16_RAM },
	{ 0x082000, 0x0827ff, MRA16_RAM },	/* Background (32x32 Tiles - 2 by per tile) */
	{ 0x100000, 0x1005ff, MRA16_RAM },	/* Palette RAM */
	{ 0x180000, 0x180007, ddrago3b_io16_r },
	{ 0x1c0000, 0x1c3fff, MRA16_RAM },	/* working RAM */
MEMORY_END

static MEMORY_WRITE16_START( dd3b_writemem )
	{ 0x000000, 0x07ffff, MWA16_ROM },
	{ 0x080000, 0x080fff, ddragon3_fg_videoram16_w, &ddragon3_fg_videoram16 },
	{ 0x081000, 0x081fff, MWA16_RAM, &spriteram16 }, /* Sprites (16 bytes per sprite) */
	{ 0x082000, 0x0827ff, ddragon3_bg_videoram16_w, &ddragon3_bg_videoram16 },
	{ 0x0c0000, 0x0c000f, ddragon3_scroll16_w },
	{ 0x100000, 0x1005ff, paletteram16_xBBBBBGGGGGRRRRR_word_w, &paletteram16 },
	{ 0x140000, 0x14000f, ddragon3_io16_w },
	{ 0x1c0000, 0x1c3fff, MWA16_RAM },
MEMORY_END

static MEMORY_READ16_START( ctribe_readmem )
	{ 0x000000, 0x07ffff, MRA16_ROM },
	{ 0x080000, 0x080fff, MRA16_RAM },	/* Foreground (32x32 Tiles - 4 by per tile) */
	{ 0x081000, 0x081fff, MRA16_RAM },
	{ 0x082000, 0x0827ff, MRA16_RAM },	/* Background (32x32 Tiles - 2 by per tile) */
	{ 0x100000, 0x1005ff, MRA16_RAM },	/* Palette RAM */
	{ 0x180000, 0x180007, ctribe_io16_r },
	{ 0x1c0000, 0x1c3fff, MRA16_RAM },	/* working RAM */
MEMORY_END

static MEMORY_WRITE16_START( ctribe_writemem )
	{ 0x000000, 0x07ffff, MWA16_ROM },
	{ 0x080000, 0x080fff, ddragon3_fg_videoram16_w, &ddragon3_fg_videoram16 },
	{ 0x081000, 0x081fff, MWA16_RAM, &spriteram16 }, /* Sprites (16 bytes per sprite) */
	{ 0x082000, 0x0827ff, ddragon3_bg_videoram16_w, &ddragon3_bg_videoram16 },
	{ 0x0c0000, 0x0c000f, ddragon3_scroll16_w },
	{ 0x100000, 0x1005ff, paletteram16_xxxxBBBBGGGGRRRR_word_w, &paletteram16 },
	{ 0x140000, 0x14000f, ddragon3_io16_w },
	{ 0x1c0000, 0x1c3fff, MWA16_RAM },
MEMORY_END

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

static MEMORY_READ_START( readmem_sound )
	{ 0x0000, 0xbfff, MRA_ROM },
	{ 0xc000, 0xc7ff, MRA_RAM },
	{ 0xc801, 0xc801, YM2151_status_port_0_r },
	{ 0xd800, 0xd800, OKIM6295_status_0_r },
	{ 0xe000, 0xe000, soundlatch_r },
MEMORY_END

static MEMORY_WRITE_START( writemem_sound )
	{ 0x0000, 0xbfff, MWA_ROM },
	{ 0xc000, 0xc7ff, MWA_RAM },
	{ 0xc800, 0xc800, YM2151_register_port_0_w },
	{ 0xc801, 0xc801, YM2151_data_port_0_w },
	{ 0xd800, 0xd800, OKIM6295_data_0_w },
	{ 0xe800, 0xe800, oki_bankswitch_w },
MEMORY_END

static MEMORY_READ_START( ctribe_readmem_sound )
	{ 0x0000, 0x7fff, MRA_ROM },
	{ 0x8000, 0x87ff, MRA_RAM },
	{ 0x8801, 0x8801, YM2151_status_port_0_r },
	{ 0x9800, 0x9800, OKIM6295_status_0_r },
	{ 0xa000, 0xa000, soundlatch_r },
MEMORY_END

static MEMORY_WRITE_START( ctribe_writemem_sound )
	{ 0x0000, 0x7fff, MWA_ROM },
	{ 0x8000, 0x87ff, MWA_RAM },
	{ 0x8800, 0x8800, YM2151_register_port_0_w },
	{ 0x8801, 0x8801, YM2151_data_port_0_w },
	{ 0x9800, 0x9800, OKIM6295_data_0_w },
MEMORY_END

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

INPUT_PORTS_START( ddrago3b )
	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_BUTTON2 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_BUTTON3 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON2 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON3 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START3 )

	PORT_START
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN3 )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN4 )

	PORT_START /* DSW1 */
	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
	PORT_DIPSETTING(	0x00, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(	0x01, DEF_STR( 2C_1C ) )
	PORT_DIPSETTING(	0x03, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(	0x02, DEF_STR( 1C_2C ) )
	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
	PORT_DIPSETTING(	0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(	0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, "Continue Discount" )
	PORT_DIPSETTING(	0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	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( Flip_Screen ) )
	PORT_DIPSETTING(	0x40, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
	PORT_DIPSETTING(	0x80, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )

	PORT_START /* DSW2 */
	PORT_DIPNAME( 0x03, 0x03, DEF_STR(Difficulty) )
	PORT_DIPSETTING(	0x02, "Easy" )
	PORT_DIPSETTING(	0x03, "Normal" )
	PORT_DIPSETTING(	0x01, "Hard" )
	PORT_DIPSETTING(	0x00, "Hardest" )
	PORT_DIPNAME( 0x04, 0x04, "P1 hurt P2" )
	PORT_DIPSETTING(	0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) /* timer speed? */
	PORT_DIPSETTING(	0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, "Test Mode" )
	PORT_DIPSETTING(	0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x20, 0x20, "Stage Clear Power" )
	PORT_DIPSETTING(	0x20, "0" )
	PORT_DIPSETTING(	0x00, "50" )
	PORT_DIPNAME( 0x40, 0x40, "Starting Power" )
	PORT_DIPSETTING(	0x00, "200" )
	PORT_DIPSETTING(	0x40, "230" )
	PORT_DIPNAME( 0x80, 0x80, "Simultaneous Players" )
	PORT_DIPSETTING(	0x80, "2" )
	PORT_DIPSETTING(	0x00, "3" )
INPUT_PORTS_END

INPUT_PORTS_START( ddragon3 )
	PORT_START /* 180000 (P1 Controls) */
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )

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

	PORT_START /* 180002 */
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN3 )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN4 )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START /* 180004 (P3 Controls) */
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON1 )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON2 )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON3 )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START3 )

	/* DSWA */
	PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Coinage ) )
	PORT_DIPSETTING(	  0x0000, "A" )
	PORT_DIPSETTING(	  0x0100, "B" )
	PORT_DIPSETTING(	  0x0200, "C" )
	PORT_DIPSETTING(	  0x0300, "D" )
	PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
	PORT_DIPSETTING(	  0x0400, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
	PORT_DIPSETTING(	  0x0800, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x1000, 0x1000, "Coin Statistics" )
	PORT_DIPSETTING(	  0x1000, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x2000, 0x0000, DEF_STR( Demo_Sounds ) )
	PORT_DIPSETTING(	  0x2000, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x4000, 0x4000, "Invert Screen" )
	PORT_DIPSETTING(	  0x4000, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(	  0x8000, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )

	PORT_START /* 180006 DSW */
	PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN )	/* fixes skipping through cut scenes without a button being pressed */
	PORT_DIPNAME( 0x0100, 0x0100, "Starting Power" )
	PORT_DIPSETTING(	  0x0000, "200" )
	PORT_DIPSETTING(	  0x0100, "230" )
	PORT_DIPNAME( 0x0200, 0x0200, "Simultaneous Players" )
	PORT_DIPSETTING(	  0x0200, "2" )
	PORT_DIPSETTING(	  0x0000, "3" )
	PORT_DIPNAME( 0x0400, 0x0400, "Stage Clear Power" )
	PORT_DIPSETTING(	  0x0400, "50" )
	PORT_DIPSETTING(	  0x0000, "0" )
	PORT_DIPNAME( 0x0800, 0x0800, "Test Mode?" )
	PORT_DIPSETTING(	  0x0800, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(	  0x1000, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x2000, 0x2000, "P1 hurt P2" )
	PORT_DIPSETTING(	  0x2000, DEF_STR( Off ) )
	PORT_DIPSETTING(	  0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0xc000, 0xc000, DEF_STR(Difficulty) )
	PORT_DIPSETTING(	  0x4000, "Easy" )
	PORT_DIPSETTING(	  0xc000, "Normal" )
	PORT_DIPSETTING(	  0x8000, "Hard" )
	PORT_DIPSETTING(	  0x0000, "Hardest" )
INPUT_PORTS_END

INPUT_PORTS_START( ctribe )
	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_BUTTON2 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPF_PLAYER2 | IPT_BUTTON3 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_RIGHT | IPF_8WAY )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_LEFT | IPF_8WAY )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_UP | IPF_8WAY )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_JOYSTICK_DOWN | IPF_8WAY )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON2 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPF_PLAYER3 | IPT_BUTTON3 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START3 )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )

	PORT_START /* DSW1 */
	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
	PORT_DIPSETTING(	0x00, DEF_STR( 3C_1C ) )
	PORT_DIPSETTING(	0x01, DEF_STR( 2C_1C ) )
	PORT_DIPSETTING(	0x03, DEF_STR( 1C_1C ) )
	PORT_DIPSETTING(	0x02, DEF_STR( 1C_2C ) )
	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
	PORT_DIPSETTING(	0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(	0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, "Continue Discount" )
	PORT_DIPSETTING(	0x10, DEF_STR( No ) )
	PORT_DIPSETTING(	0x00, DEF_STR( Yes ) )
	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( Flip_Screen ) )
	PORT_DIPSETTING(	0x40, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
	PORT_DIPSETTING(	0x80, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )

	PORT_START /* DSW2 */
	PORT_DIPNAME( 0x03, 0x03, DEF_STR(Difficulty) )
	PORT_DIPSETTING(	0x02, "Easy" )
	PORT_DIPSETTING(	0x03, "Normal" )
	PORT_DIPSETTING(	0x01, "Hard" )
	PORT_DIPSETTING(	0x00, "Hardest" )
	PORT_DIPNAME( 0x04, 0x04, "Timer Speed" )
	PORT_DIPSETTING(	0x04, "Normal" )
	PORT_DIPSETTING(	0x00, "Fast" )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(	0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, "Test Mode" )
	PORT_DIPSETTING(	0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x60, 0x60, "Stage Clear Power" )
	PORT_DIPSETTING(	0x60, "0" )
	PORT_DIPSETTING(	0x40, "50" )
	PORT_DIPSETTING(	0x20, "100" )
	PORT_DIPSETTING(	0x00, "150" )
	PORT_DIPNAME( 0x80, 0x80, "Simultaneous Players" )
	PORT_DIPSETTING(	0x80, "2" )
	PORT_DIPSETTING(	0x00, "3" )
INPUT_PORTS_END

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

static struct GfxLayout tile_layout =
{
	16,16,	/* 16*16 tiles */
	8192,	/* 8192 tiles */
	4,	/* 4 bits per pixel */
	{ 0, 0x40000*8, 2*0x40000*8 , 3*0x40000*8 },	/* the bitplanes are separated */
	{ 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	/* every tile takes 32 consecutive bytes */
};

static struct GfxLayout sprite_layout = {
	16,16,	/* 16*16 tiles */
	0x90000/32, /* 4096 tiles */
	4,	/* 4 bits per pixel */
	{ 0, 0x100000*8, 2*0x100000*8 , 3*0x100000*8 }, /* the bitplanes are separated */
	{ 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	/* every tile takes 32 consecutive bytes */
};

static struct GfxDecodeInfo ddragon3_gfxdecodeinfo[] =
{
	{ REGION_GFX1, 0, &tile_layout,   256, 32 },
	{ REGION_GFX2, 0, &sprite_layout,		0, 16 },
	{ -1 }
};

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

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

static struct YM2151interface ym2151_interface =
{
	1,			/* 1 chip */
	3579545,	/* Guess */
	{ YM3012_VOL(45,MIXER_PAN_LEFT,45,MIXER_PAN_RIGHT) },
	{ dd3_ymirq_handler }
};

static struct OKIM6295interface okim6295_interface =
{
	1,				/* 1 chip */
	{ 8500 },		/* frequency (Hz) */
	{ REGION_SOUND1 },	/* memory region */
	{ 47 }
};

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

static MACHINE_DRIVER_START( ddragon3 )

	/* basic machine hardware */
	MDRV_CPU_ADD(M68000, 12000000) /* Guess */
	MDRV_CPU_MEMORY(readmem,writemem)
	MDRV_CPU_VBLANK_INT(ddragon3_cpu_interrupt,2)

	MDRV_CPU_ADD(Z80, 3579545)
	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)	/* Guess */
	MDRV_CPU_MEMORY(readmem_sound,writemem_sound)

	MDRV_FRAMES_PER_SECOND(60)
	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(40*8, 32*8)
	MDRV_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
	MDRV_GFXDECODE(ddragon3_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(768)

	MDRV_VIDEO_START(ddragon3)
	MDRV_VIDEO_UPDATE(ddragon3)

	/* sound hardware */
	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
	MDRV_SOUND_ADD(YM2151, ym2151_interface)
	MDRV_SOUND_ADD(OKIM6295, okim6295_interface)
MACHINE_DRIVER_END

static MACHINE_DRIVER_START( ddrago3b )

	/* basic machine hardware */
	MDRV_CPU_ADD(M68000, 12000000) /* Guess */
	MDRV_CPU_MEMORY(dd3b_readmem,dd3b_writemem)
	MDRV_CPU_VBLANK_INT(ddragon3_cpu_interrupt,2)

	MDRV_CPU_ADD(Z80, 3579545)
	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)	/* Guess */
	MDRV_CPU_MEMORY(readmem_sound,writemem_sound)

	MDRV_FRAMES_PER_SECOND(60)
	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(40*8, 32*8)
	MDRV_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
	MDRV_GFXDECODE(ddragon3_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(768)

	MDRV_VIDEO_START(ddragon3)
	MDRV_VIDEO_UPDATE(ddragon3)

	/* sound hardware */
	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
	MDRV_SOUND_ADD(YM2151, ym2151_interface)
	MDRV_SOUND_ADD(OKIM6295, okim6295_interface)
MACHINE_DRIVER_END

static MACHINE_DRIVER_START( ctribe )

	/* basic machine hardware */
	MDRV_CPU_ADD(M68000, 12000000) /* Guess */
	MDRV_CPU_MEMORY(ctribe_readmem,ctribe_writemem)
	MDRV_CPU_VBLANK_INT(ddragon3_cpu_interrupt,2)

	MDRV_CPU_ADD(Z80, 3579545)
	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)	/* Guess */
	MDRV_CPU_MEMORY(ctribe_readmem_sound,ctribe_writemem_sound)

	MDRV_FRAMES_PER_SECOND(60)
	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(40*8, 32*8)
	MDRV_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
	MDRV_GFXDECODE(ddragon3_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(768)

	MDRV_VIDEO_START(ddragon3)
	MDRV_VIDEO_UPDATE(ctribe)

	/* sound hardware */
	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
	MDRV_SOUND_ADD(YM2151, ym2151_interface)
	MDRV_SOUND_ADD(OKIM6295, okim6295_interface)
MACHINE_DRIVER_END

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

ROM_START( ddragon3 )
	ROM_REGION( 0x80000, REGION_CPU1, 0 )	/* 64k for cpu code */
	ROM_LOAD16_BYTE( "30a14",   0x00001, 0x40000, 0xf42fe016 )
	ROM_LOAD16_BYTE( "30a15",   0x00000, 0x20000, 0xad50e92c )

	ROM_REGION( 0x10000, REGION_CPU2, 0 )	/* 64k for sound cpu code */
	ROM_LOAD( "dd3.06",    0x00000, 0x10000, 0x1e974d9b )

	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "dd3.f",   0x000000, 0x40000, 0x89d58d32 ) /* Background */
	ROM_LOAD( "dd3.e",   0x040000, 0x40000, 0x9bf1538e )
	ROM_LOAD( "dd3.b",   0x080000, 0x40000, 0x8f671a62 )
	ROM_LOAD( "dd3.a",   0x0c0000, 0x40000, 0x0f74ea1c )

	ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
	/* sprites	*/
	ROM_LOAD( "dd3.3e",   0x000000, 0x20000, 0x726c49b7 ) //4a
	ROM_LOAD( "dd3.3d",   0x020000, 0x20000, 0x37a1c335 ) //3a
	ROM_LOAD( "dd3.3c",   0x040000, 0x20000, 0x2bcfe63c ) //2a
	ROM_LOAD( "dd3.3b",   0x060000, 0x20000, 0xb864cf17 ) //1a
	ROM_LOAD( "dd3.3a",   0x080000, 0x10000, 0x20d64bea ) //5a

	ROM_LOAD( "dd3.2e",   0x100000, 0x20000, 0x8c71eb06 ) //4b
	ROM_LOAD( "dd3.2d",   0x120000, 0x20000, 0x3e134be9 ) //3b
	ROM_LOAD( "dd3.2c",   0x140000, 0x20000, 0xb4115ef0 ) //2b
	ROM_LOAD( "dd3.2b",   0x160000, 0x20000, 0x4639333d ) //1b
	ROM_LOAD( "dd3.2a",   0x180000, 0x10000, 0x785d71b0 ) //5b

	ROM_LOAD( "dd3.1e",   0x200000, 0x20000, 0x04420cc8 ) //4c
	ROM_LOAD( "dd3.1d",   0x220000, 0x20000, 0x33f97b2f ) //3c
	ROM_LOAD( "dd3.1c",   0x240000, 0x20000, 0x0f9a8f2a ) //2c
	ROM_LOAD( "dd3.1b",   0x260000, 0x20000, 0x15c91772 ) //1c
	ROM_LOAD( "dd3.1a",   0x280000, 0x10000, 0x15e43d12 ) //5c

	ROM_LOAD( "dd3.0e",   0x300000, 0x20000, 0x894734b3 ) //4d
	ROM_LOAD( "dd3.0d",   0x320000, 0x20000, 0xcd504584 ) //3d
	ROM_LOAD( "dd3.0c",   0x340000, 0x20000, 0x38e8a9ad ) //2d
	ROM_LOAD( "dd3.0b",   0x360000, 0x20000, 0x80c1cb74 ) //1d
	ROM_LOAD( "dd3.0a",   0x380000, 0x10000, 0x5a47e7a4 ) //5d

	ROM_REGION( 0x080000, REGION_SOUND1, 0 )	/* ADPCM Samples */
	ROM_LOAD( "dd3.j7",   0x000000, 0x40000, 0x3af21dbe )
	ROM_LOAD( "dd3.j8",   0x040000, 0x40000, 0xc28b53cd )

	ROM_REGION( 0x0100, REGION_PROMS, 0 )
	ROM_LOAD( "mb7114h.38", 0x0000, 0x0100, 0x113c7443 )
ROM_END

ROM_START( ddrago3j )
	ROM_REGION( 0x80000, REGION_CPU1, 0 )	/* 64k for cpu code */
	ROM_LOAD16_BYTE( "30j15",   0x00001, 0x40000, 0x40618cbc )
	ROM_LOAD16_BYTE( "30j14",   0x00000, 0x20000, 0x96827e80 )

	ROM_REGION( 0x10000, REGION_CPU2, 0 )	/* 64k for sound cpu code */
	ROM_LOAD( "dd3.06",    0x00000, 0x10000, 0x1e974d9b )

	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "dd3.f",   0x000000, 0x40000, 0x89d58d32 ) /* Background */
	ROM_LOAD( "dd3.e",   0x040000, 0x40000, 0x9bf1538e )
	ROM_LOAD( "dd3.b",   0x080000, 0x40000, 0x8f671a62 )
	ROM_LOAD( "dd3.a",   0x0c0000, 0x40000, 0x0f74ea1c )

	ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
	/* sprites  */
	ROM_LOAD( "dd3.3e",   0x000000, 0x20000, 0x726c49b7 ) //4a
	ROM_LOAD( "dd3.3d",   0x020000, 0x20000, 0x37a1c335 ) //3a
	ROM_LOAD( "dd3.3c",   0x040000, 0x20000, 0x2bcfe63c ) //2a
	ROM_LOAD( "dd3.3b",   0x060000, 0x20000, 0xb864cf17 ) //1a
	ROM_LOAD( "30j12-0",  0x080000, 0x10000, 0x1e9290d7 ) //5a

	ROM_LOAD( "dd3.2e",   0x100000, 0x20000, 0x8c71eb06 ) //4b
	ROM_LOAD( "dd3.2d",   0x120000, 0x20000, 0x3e134be9 ) //3b
	ROM_LOAD( "dd3.2c",   0x140000, 0x20000, 0xb4115ef0 ) //2b
	ROM_LOAD( "dd3.2b",   0x160000, 0x20000, 0x4639333d ) //1b
	ROM_LOAD( "30j11-0",  0x180000, 0x10000, 0x99195b2a ) //5b

	ROM_LOAD( "dd3.1e",   0x200000, 0x20000, 0x04420cc8 ) //4c
	ROM_LOAD( "dd3.1d",   0x220000, 0x20000, 0x33f97b2f ) //3c
	ROM_LOAD( "dd3.1c",   0x240000, 0x20000, 0x0f9a8f2a ) //2c
	ROM_LOAD( "dd3.1b",   0x260000, 0x20000, 0x15c91772 ) //1c
	ROM_LOAD( "30a10-0",  0x280000, 0x10000, 0xe3879b5d ) //5c

	ROM_LOAD( "dd3.0e",   0x300000, 0x20000, 0x894734b3 ) //4d
	ROM_LOAD( "dd3.0d",   0x320000, 0x20000, 0xcd504584 ) //3d
	ROM_LOAD( "dd3.0c",   0x340000, 0x20000, 0x38e8a9ad ) //2d
	ROM_LOAD( "dd3.0b",   0x360000, 0x20000, 0x80c1cb74 ) //1d
	ROM_LOAD( "30j9-0",   0x380000, 0x10000, 0x2759ae84 ) //5d

	ROM_REGION( 0x080000, REGION_SOUND1, 0 )	/* ADPCM Samples */
	ROM_LOAD( "dd3.j7",   0x000000, 0x40000, 0x3af21dbe )
	ROM_LOAD( "dd3.j8",   0x040000, 0x40000, 0xc28b53cd )

	ROM_REGION( 0x0100, REGION_PROMS, 0 )
	ROM_LOAD( "mb7114h.38", 0x0000, 0x0100, 0x113c7443 )
ROM_END

ROM_START( ddrago3b )
	ROM_REGION( 0x80000, REGION_CPU1, 0 )	/* 64k for cpu code */
	ROM_LOAD16_BYTE( "dd3.01",   0x00001, 0x20000, 0x68321d8b )
	ROM_LOAD16_BYTE( "dd3.03",   0x00000, 0x20000, 0xbc05763b )
	ROM_LOAD16_BYTE( "dd3.02",   0x40001, 0x20000, 0x38d9ae75 )
	/* No EVEN rom! */

	ROM_REGION( 0x10000, REGION_CPU2, 0 )	/* 64k for sound cpu code */
	ROM_LOAD( "dd3.06",    0x00000, 0x10000, 0x1e974d9b )

	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )
	/* Background */
	ROM_LOAD( "dd3.f",   0x000000, 0x40000, 0x89d58d32 )
	ROM_LOAD( "dd3.e",   0x040000, 0x40000, 0x9bf1538e )
	ROM_LOAD( "dd3.b",   0x080000, 0x40000, 0x8f671a62 )
	ROM_LOAD( "dd3.a",   0x0c0000, 0x40000, 0x0f74ea1c )

	ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
	/* sprites	*/
	ROM_LOAD( "dd3.3e",   0x000000, 0x20000, 0x726c49b7 ) //4a
	ROM_LOAD( "dd3.3d",   0x020000, 0x20000, 0x37a1c335 ) //3a
	ROM_LOAD( "dd3.3c",   0x040000, 0x20000, 0x2bcfe63c ) //2a
	ROM_LOAD( "dd3.3b",   0x060000, 0x20000, 0xb864cf17 ) //1a
	ROM_LOAD( "dd3.3a",   0x080000, 0x10000, 0x20d64bea ) //5a

	ROM_LOAD( "dd3.2e",   0x100000, 0x20000, 0x8c71eb06 ) //4b
	ROM_LOAD( "dd3.2d",   0x120000, 0x20000, 0x3e134be9 ) //3b
	ROM_LOAD( "dd3.2c",   0x140000, 0x20000, 0xb4115ef0 ) //2b
	ROM_LOAD( "dd3.2b",   0x160000, 0x20000, 0x4639333d ) //1b
	ROM_LOAD( "dd3.2a",   0x180000, 0x10000, 0x785d71b0 ) //5b

	ROM_LOAD( "dd3.1e",   0x200000, 0x20000, 0x04420cc8 ) //4c
	ROM_LOAD( "dd3.1d",   0x220000, 0x20000, 0x33f97b2f ) //3c
	ROM_LOAD( "dd3.1c",   0x240000, 0x20000, 0x0f9a8f2a ) //2c
	ROM_LOAD( "dd3.1b",   0x260000, 0x20000, 0x15c91772 ) //1c
	ROM_LOAD( "dd3.1a",   0x280000, 0x10000, 0x15e43d12 ) //5c

	ROM_LOAD( "dd3.0e",   0x300000, 0x20000, 0x894734b3 ) //4d
	ROM_LOAD( "dd3.0d",   0x320000, 0x20000, 0xcd504584 ) //3d
	ROM_LOAD( "dd3.0c",   0x340000, 0x20000, 0x38e8a9ad ) //2d
	ROM_LOAD( "dd3.0b",   0x360000, 0x20000, 0x80c1cb74 ) //1d
	ROM_LOAD( "dd3.0a",   0x380000, 0x10000, 0x5a47e7a4 ) //5d

	ROM_REGION( 0x080000, REGION_SOUND1, 0 )	/* ADPCM Samples */
	ROM_LOAD( "dd3.j7",   0x000000, 0x40000, 0x3af21dbe )
	ROM_LOAD( "dd3.j8",   0x040000, 0x40000, 0xc28b53cd )

	ROM_REGION( 0x0100, REGION_PROMS, 0 )
	ROM_LOAD( "mb7114h.38", 0x0000, 0x0100, 0x113c7443 )
ROM_END

ROM_START( ctribe )
	ROM_REGION( 0x80000, REGION_CPU1, 0 )	/* 64k for cpu code */
	ROM_LOAD16_BYTE( "ic-26",      0x00001, 0x20000, 0xc46b2e63 )
	ROM_LOAD16_BYTE( "ic-25",      0x00000, 0x20000, 0x3221c755 )
	ROM_LOAD16_BYTE( "ct_ep2.rom", 0x40001, 0x10000, 0x8c2c6dbd )
	/* No EVEN rom! */

	ROM_REGION( 0x10000, REGION_CPU2, 0 )	/* 64k for sound cpu code */
	ROM_LOAD( "ct_ep4.rom",   0x00000, 0x8000, 0x4346de13 )

	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "ct_mr7.rom",  0x000000, 0x40000, 0xa8b773f1 )    /* Background */
	ROM_LOAD( "ct_mr6.rom",  0x040000, 0x40000, 0x617530fc )
	ROM_LOAD( "ct_mr5.rom",  0x080000, 0x40000, 0xcef0a821 )
	ROM_LOAD( "ct_mr4.rom",  0x0c0000, 0x40000, 0xb84fda09 )

	ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
	ROM_LOAD( "ct_mr3.rom",  0x000000, 0x80000, 0x1ac2a461 )    /* Sprites */
	ROM_LOAD( "ct_ep5.rom",  0x080000, 0x10000, 0x972faddb )
	ROM_LOAD( "ct_mr2.rom",  0x100000, 0x80000, 0x8c796707 )
	ROM_LOAD( "ct_ep6.rom",  0x180000, 0x10000, 0xeb3ab374 )
	ROM_LOAD( "ct_mr1.rom",  0x200000, 0x80000, 0x1c9badbd )
	ROM_LOAD( "ct_ep7.rom",  0x280000, 0x10000, 0xc602ac97 )
	ROM_LOAD( "ct_mr0.rom",  0x300000, 0x80000, 0xba73c49e )
	ROM_LOAD( "ct_ep8.rom",  0x380000, 0x10000, 0x4da1d8e5 )

	ROM_REGION( 0x040000, REGION_SOUND1, 0 )	/* ADPCM Samples */
	ROM_LOAD( "ct_mr8.rom",   0x020000, 0x20000, 0x9963a6be )
	ROM_CONTINUE(			  0x000000, 0x20000 )
ROM_END

ROM_START( ctribe1 )
	ROM_REGION( 0x80000, REGION_CPU1, 0 )	/* 64k for cpu code */
	ROM_LOAD16_BYTE( "28a16-2.ic26", 0x00001, 0x20000, 0xf00f8443 )
	ROM_LOAD16_BYTE( "28a15-2.ic25", 0x00000, 0x20000, 0xdd70079f )
	ROM_LOAD16_BYTE( "ct_ep2.ic104", 0x40001, 0x10000, 0x8c2c6dbd )
	/* No EVEN rom! */

	ROM_REGION( 0x10000, REGION_CPU2, 0 )	/* 64k for sound cpu code */
	ROM_LOAD( "28a10-0.ic89", 0x00000, 0x8000, 0x4346de13 )

	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "28j7-0.ic11",  0x000000, 0x40000, 0xa8b773f1 )    /* Background */
	ROM_LOAD( "28j6-0.ic13",  0x040000, 0x40000, 0x617530fc )
	ROM_LOAD( "28j5-0.ic12",  0x080000, 0x40000, 0xcef0a821 )
	ROM_LOAD( "28j4-0.ic14",  0x0c0000, 0x40000, 0xb84fda09 )

	ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
	ROM_LOAD( "28j3-0.ic77",  0x000000, 0x80000, 0x1ac2a461 )    /* Sprites */
	ROM_LOAD( "28a14-0.ic60", 0x080000, 0x10000, 0x972faddb )
	ROM_LOAD( "28j2-0.ic78",  0x100000, 0x80000, 0x8c796707 )
	ROM_LOAD( "28a13-0.ic61", 0x180000, 0x10000, 0xeb3ab374 )
	ROM_LOAD( "28j1-0.ic97",  0x200000, 0x80000, 0x1c9badbd )
	ROM_LOAD( "28a12-0.ic85", 0x280000, 0x10000, 0xc602ac97 )
	ROM_LOAD( "28j0-0.ic98",  0x300000, 0x80000, 0xba73c49e )
	ROM_LOAD( "28a11-0.ic86", 0x380000, 0x10000, 0x4da1d8e5 )

	ROM_REGION( 0x040000, REGION_SOUND1, 0 ) /* ADPCM Samples */
	ROM_LOAD( "28j9-0.ic83", 0x00000, 0x20000, 0xf92a7f4a )
	ROM_LOAD( "28j8-0.ic82", 0x20000, 0x20000, 0x1a3a0b39 )

	ROM_REGION( 0x0100, REGION_PROMS, 0 )
	ROM_LOAD( "28.ic44", 0x0000, 0x0100, 0x964329ef )
ROM_END

ROM_START( ctribeb )
	ROM_REGION( 0x80000, REGION_CPU1, 0 )	/* 64k for cpu code */
	ROM_LOAD16_BYTE( "ct_ep1.rom", 0x00001, 0x20000, 0x9cfa997f )
	ROM_LOAD16_BYTE( "ct_ep3.rom", 0x00000, 0x20000, 0x2ece8681 )
	ROM_LOAD16_BYTE( "ct_ep2.rom", 0x40001, 0x10000, 0x8c2c6dbd )
	/* No EVEN rom! */

	ROM_REGION( 0x10000, REGION_CPU2, 0 )	/* 64k for sound cpu code */
	ROM_LOAD( "ct_ep4.rom",   0x00000, 0x8000, 0x4346de13 )

	ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE )
	ROM_LOAD( "ct_mr7.rom",  0x000000, 0x40000, 0xa8b773f1 )    /* Background */
	ROM_LOAD( "ct_mr6.rom",  0x040000, 0x40000, 0x617530fc )
	ROM_LOAD( "ct_mr5.rom",  0x080000, 0x40000, 0xcef0a821 )
	ROM_LOAD( "ct_mr4.rom",  0x0c0000, 0x40000, 0xb84fda09 )

	ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
	ROM_LOAD( "ct_mr3.rom",  0x000000, 0x80000, 0x1ac2a461 )    /* Sprites */
	ROM_LOAD( "ct_ep5.rom",  0x080000, 0x10000, 0x972faddb )
	ROM_LOAD( "ct_mr2.rom",  0x100000, 0x80000, 0x8c796707 )
	ROM_LOAD( "ct_ep6.rom",  0x180000, 0x10000, 0xeb3ab374 )
	ROM_LOAD( "ct_mr1.rom",  0x200000, 0x80000, 0x1c9badbd )
	ROM_LOAD( "ct_ep7.rom",  0x280000, 0x10000, 0xc602ac97 )
	ROM_LOAD( "ct_mr0.rom",  0x300000, 0x80000, 0xba73c49e )
	ROM_LOAD( "ct_ep8.rom",  0x380000, 0x10000, 0x4da1d8e5 )

	ROM_REGION( 0x040000, REGION_SOUND1, 0 )	/* ADPCM Samples */
	ROM_LOAD( "ct_mr8.rom",   0x020000, 0x20000, 0x9963a6be )
	ROM_CONTINUE(			  0x000000, 0x20000 )
ROM_END

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

GAMEX( 1990, ddragon3, 0,		 ddragon3, ddragon3, 0, ROT0, "Technos", "Double Dragon 3 - The Rosetta Stone", GAME_NO_COCKTAIL )
GAMEX( 1990, ddrago3j, ddragon3, ddragon3, ddragon3, 0, ROT0, "Technos", "Double Dragon 3 - The Rosetta Stone (Japan)", GAME_NO_COCKTAIL )
GAMEX( 1990, ddrago3b, ddragon3, ddrago3b, ddrago3b, 0, ROT0, "bootleg", "Double Dragon 3 - The Rosetta Stone (bootleg)", GAME_NO_COCKTAIL )
GAMEX( 1990, ctribe,   0,		 ctribe,   ctribe,	 0, ROT0, "Technos", "The Combatribes (US)", GAME_NO_COCKTAIL )
GAMEX( 1990, ctribe1,  ctribe,	 ctribe,   ctribe,	 0, ROT0, "Technos", "The Combatribes (US) - Set 1?", GAME_NO_COCKTAIL )
GAMEX( 1990, ctribeb,  ctribe,	 ctribe,   ctribe,	 0, ROT0, "bootleg", "The Combatribes (bootleg)", GAME_NO_COCKTAIL )


