Esempio n. 1
0
static INT32 DrvInit()
{
	GenericTilesInit();

	AllMem = NULL;
	MemIndex();
	INT32 nLen = MemEnd - (UINT8 *)0;
	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
	memset(AllMem, 0, nLen);
	MemIndex();

	{
		if (BurnLoadRom(Drv68KROM  + 0x000000,  0, 1)) return 1;
		if (BurnLoadRom(Drv68KROM  + 0x080000,  1, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM  + 0x000000,  2, 2)) return 1;
		if (BurnLoadRom(DrvGfxROM  + 0x000001,  3, 2)) return 1;
		if (BurnLoadRom(DrvGfxROM  + 0x100000,  4, 2)) return 1;
		if (BurnLoadRom(DrvGfxROM  + 0x100001,  5, 2)) return 1;

		if (BurnLoadRom(YMZ280BROM + 0x000000,  6, 1)) return 1;
		if (BurnLoadRom(YMZ280BROM + 0x080000,  7, 1)) return 1;
		if (BurnLoadRom(YMZ280BROM + 0x100000,  8, 1)) return 1;
		if (BurnLoadRom(YMZ280BROM + 0x180000,  9, 1)) return 1;

		DrvGfxDecode();
	}

	SekInit(0, 0x68000);
	SekOpen(0);
	SekMapMemory(Drv68KROM,		0x000000, 0x0fffff, MAP_ROM);
	SekMapMemory(Drv68KRAM,		0x400000, 0x407fff, MAP_RAM);
	SekMapMemory(DrvPalRAM,		0xb00000, 0xb03fff, MAP_RAM);
	SekMapMemory(DrvPalRAM,		0xb04000, 0xb047ff, MAP_ROM);
	SekSetWriteWordHandler(0,	bishi_write_word);
	SekSetWriteByteHandler(0,	bishi_write_byte);
	SekSetReadWordHandler(0,	bishi_read_word);
	SekSetReadByteHandler(0,	bishi_read_byte);
	SekClose();

	K055555Init();
	K054338Init();

	K056832Init(DrvGfxROM, DrvGfxROMExp, 0x200000, bishi_tile_callback);
	K056832SetGlobalOffsets(29, 16);
	K056832SetLayerOffsets(0, -2, 0);
	K056832SetLayerOffsets(1,  2, 0);
	K056832SetLayerOffsets(2,  4, 0);
	K056832SetLayerOffsets(3,  6, 0);
	K056832SetLayerAssociation(0);

	YMZ280BInit(16934400, bishi_sound_irq);
	YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
	YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);

	DrvDoReset();

	return 0;
}
Esempio n. 2
0
int MiaInit()
{
	int nRet=0;
	int nLen=0;

  // Find out how much memory is needed
	Mem=NULL;
	MiaIndex();
	nLen=MemEnd-(unsigned char *)0;
	Mem=(unsigned char *)malloc(nLen);
	if (Mem==NULL)
		return 1;
	memset(Mem,0,nLen); // blank all memory
	MiaIndex(); // Index the allocated memory

	nRet=MiaLoadRoms();
	if (nRet!=0)
		return 1; // Load the roms into memory

  	SekInit(0,0x68000);	// Allocate 68000

	SekOpen(0);

	// Map in memory:
	// ----------------- Cpu 1 ------------------------
	SekMapMemory(    Tmnt68KROM01  ,0x000000,0x03FFFF,SM_ROM); // 68000 Rom
	SekMapMemory(    TmntRam06,0x040000,0x063FFF,SM_RAM);
	SekMapMemory(TmntRam08,0x080000,0x080FFF,SM_ROM); // Write goes through handler
	SekMapMemory(   PriRam,0x0c0000,0x0c00FF,SM_RAM);
	SekMapMemory(TmntRam10,0x100000,0x107FFF,SM_RAM);
	SekMapMemory(    K051960Ram,0x140000,0x1407FF,SM_RAM);
	SekSetReadWordHandler(0,TmntReadWord);
	SekSetWriteWordHandler(0,TmntWriteWord);
	SekSetReadByteHandler(0,TmntReadByte);
	SekSetWriteByteHandler(0,TmntWriteByte);

	// ------------------------------------------------
	SekReset(); 
	bInt5=0;
	SekClose();
	MiaReset();
	GenericTilesInit();
	TmntPalInit();
	return 0;
}
Esempio n. 3
0
static INT32 DrvInit()
{
	AllMem = NULL;
	MemIndex();
	INT32 nLen = MemEnd - (UINT8 *)0;
	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
	memset(AllMem, 0, nLen);
	MemIndex();

	{
		if (BurnLoadRom(DrvZ80ROM0 + 0x000000,  0, 1)) return 1;
		memmove (DrvZ80ROM0 + 0x10000, DrvZ80ROM0 + 0x08000, 0x78000);

		if (BurnLoadRom(DrvZ80ROM1 + 0x000000,  1, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM0 + 0x000000,  2, 1)) return 1;
		memcpy (DrvSndROM + 0x000000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x040000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x080000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x0c0000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x020000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x060000, DrvGfxROM0 + 0x020000, 0x020000);
		memcpy (DrvSndROM + 0x0a0000, DrvGfxROM0 + 0x040000, 0x020000);
		memcpy (DrvSndROM + 0x0e0000, DrvGfxROM0 + 0x060000, 0x020000);

		if (BurnLoadRom(DrvGfxROM0 + 0x000000,  3, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM0 + 0x020000,  4, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM0 + 0x040000,  5, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM0 + 0x060000,  6, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM1 + 0x000000,  7, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM1 + 0x020000,  8, 1)) return 1;

		DrvGfxDecode();
	}

	ZetInit(0);
	ZetOpen(0);
	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM0);
	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM0);
	ZetMapArea(0x8000, 0x87ff, 0, DrvPalRAM);
//	ZetMapArea(0x8000, 0x87ff, 1, DrvPalRAM);
	ZetMapArea(0x8000, 0x87ff, 2, DrvPalRAM);
	ZetMapArea(0x8800, 0x8fff, 0, DrvAttrRAM);
	ZetMapArea(0x8800, 0x8fff, 1, DrvAttrRAM);
	ZetMapArea(0x8800, 0x8fff, 2, DrvAttrRAM);
	ZetMapArea(0xa000, 0xbfff, 0, DrvZ80RAM0);
	ZetMapArea(0xa000, 0xbfff, 1, DrvZ80RAM0);
	ZetMapArea(0xa000, 0xbfff, 2, DrvZ80RAM0);
	ZetSetWriteHandler(speedspn_main_write);
	ZetSetOutHandler(speedspn_main_write_port);
	ZetSetInHandler(speedspn_main_read_port);
	ZetClose();

	ZetInit(1);
	ZetOpen(1);
	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM1);
	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM1);
	ZetMapArea(0x8000, 0x87ff, 0, DrvZ80RAM1);
	ZetMapArea(0x8000, 0x87ff, 1, DrvZ80RAM1);
	ZetMapArea(0x8000, 0x87ff, 2, DrvZ80RAM1);
	ZetSetWriteHandler(speedspn_sound_write);
	ZetSetReadHandler(speedspn_sound_read);
	ZetClose();

	MSM6295Init(0, 1122000 / 132, 0);
	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);

	DrvDoReset();

	GenericTilesInit();

	return 0;
}
Esempio n. 4
0
int TmntInit()
{
	int nRet=0; int nLen=0;

	// Find out how much memory is needed
	Mem=NULL;
	MemIndex();
	nLen=MemEnd-(unsigned char *)0;
	Mem=(unsigned char *)malloc(nLen);
	if (Mem==NULL)
		return 1;
	memset(Mem,0,nLen); // blank all memory
	MemIndex(); // Index the allocated memory

	TmntZ80Rom=(unsigned char *)malloc(0x08000);
	if (TmntZ80Rom==NULL) return 1;
	memset(TmntZ80Rom,0x11,0x08000);

	TmntZ80Ram=(unsigned char *)malloc(0x0800);
	if (TmntZ80Ram==NULL) return 1;
	memset(TmntZ80Ram,0x00,0x0800);

	nRet=LoadRoms();
	if (nRet!=0)
		return 1; // Load the roms into memory

  	SekInit(0,0x68000);	// Allocate 68000
	SekOpen(0);

	// Map in memory:
	// ----------------- Cpu 1 ------------------------
	SekMapMemory(Tmnt68KROM01, 0x000000,0x05FFFF, SM_ROM); // 68000 Rom
	SekMapMemory(TmntRam06,    0x060000,0x063FFF, SM_RAM);
	SekMapMemory(TmntRam08,    0x080000,0x080FFF, SM_ROM); // Write goes through handler
	SekMapMemory(PriRam,       0x0c0000,0x0c00FF, SM_RAM);
	SekMapMemory(TmntRam10,    0x100000,0x107FFF, SM_RAM);
	SekMapMemory(K051960Ram,   0x140400,0x1407FF, SM_RAM);

	SekSetReadWordHandler(0,TmntReadWord);
	SekSetWriteWordHandler(0,TmntWriteWord);
	SekSetReadByteHandler(0,TmntReadByte);
	SekSetWriteByteHandler(0,TmntWriteByte);
	// ------------------------------------------------
//	SekReset();
	SekClose();
	
	// Setup the Z80 emulation
	ZetInit(1);
	ZetOpen(0);
	ZetMapArea(0x0000, 0x7fff, 0, TmntZ80Rom);
	ZetMapArea(0x0000, 0x7fff, 2, TmntZ80Rom);
	ZetMapArea(0x8000, 0x87FF, 0, TmntZ80Ram);
	ZetMapArea(0x8000, 0x87FF,1, TmntZ80Ram);
	ZetMapArea(0x8000, 0x87FF, 2, TmntZ80Ram);
	ZetMemEnd();
	ZetSetInHandler(tmntZ80In);
	ZetSetOutHandler(tmntZ80Out);
	ZetSetReadHandler(tmntZ80Read);
	ZetSetWriteHandler(tmntZ80Write);
//	ZetReset();
	ZetClose();

	// sound stuff
	// ym2151
    	BurnYM2151Init(3579545, 50.0);
	BurnYM2151SetIrqHandler(&tmntYM2151IRQHandler);
//	BurnYM2151Reset();
	
	UPD7759Init(UPD7759_STANDARD_CLOCK, TmntSampleROM02);

	bInt5=0;
	GenericTilesInit();
	TmntPalInit();
	
	TmntReset();
	return 0;
}
Esempio n. 5
0
static int DrvInit()
{
	AllMem = NULL;
	MemIndex();
	int nLen = MemEnd - (unsigned char *)0;
	if ((AllMem = (unsigned char *)malloc(nLen)) == NULL) return 1;
	memset(AllMem, 0, nLen);
	MemIndex();

	{
		if (BurnLoadRom(DrvM6809ROM + 0x08000,  0, 1)) return 1;
		memcpy (DrvM6809ROM + 0x4000, DrvM6809ROM + 0xc000, 0x4000);
		if (BurnLoadRom(DrvM6809ROM + 0x0c000,  1, 1)) return 1;

		if (BurnLoadRom(DrvZ80ROM   + 0x00000,  2, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM0  + 0x00000,  3, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM1  + 0x00000,  4, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM1  + 0x08000,  5, 1)) return 1;

		if (BurnLoadRom(DrvColPROM  + 0x00000,  6, 1)) return 1;
		if (BurnLoadRom(DrvColPROM  + 0x00100,  7, 1)) return 1;
		if (BurnLoadRom(DrvColPROM  + 0x00200,  8, 1)) return 1;
		if (BurnLoadRom(DrvColPROM  + 0x00300,  9, 1)) return 1;
		if (BurnLoadRom(DrvColPROM  + 0x00400, 10, 1)) return 1;

		DrvPaletteInit();
		DrvGfxDecode();
	}

	M6809Init(1);
	M6809Open(0);
	M6809MapMemory(DrvColRAM,		0x0000, 0x07ff, M6809_RAM);
	M6809MapMemory(DrvVidRAM,		0x0800, 0x0fff, M6809_RAM);
	M6809MapMemory(DrvSprRAM,		0x1000, 0x1fff, M6809_RAM);
	M6809MapMemory(DrvM6809ROM + 0x04000,	0x4000, 0xffff, M6809_ROM);
	M6809SetWriteByteHandler(scotrsht_main_write);
	M6809SetReadByteHandler(scotrsht_main_read);
	M6809Close();

	ZetInit(1);
	ZetOpen(0);
	ZetMapArea(0x0000, 0x3fff, 0, DrvZ80ROM);
	ZetMapArea(0x0000, 0x3fff, 2, DrvZ80ROM);
	ZetMapArea(0x4000, 0x43ff, 0, DrvZ80RAM);
	ZetMapArea(0x4000, 0x43ff, 1, DrvZ80RAM);
	ZetMapArea(0x4000, 0x43ff, 2, DrvZ80RAM);
	ZetSetReadHandler(scotrsht_sound_read);
	ZetSetOutHandler(scotrsht_sound_out);
	ZetSetInHandler(scotrsht_sound_in);
	ZetMemEnd();
	ZetClose();

	BurnYM2203Init(1, 3072000, NULL, DrvSynchroniseStream, DrvGetTime, 0);
	BurnTimerAttachZet(3072000);

	DrvDoReset();

	GenericTilesInit();

	return 0;
}
Esempio n. 6
0
void DecSharedInit()
{
    GenericTilesInit();
}
Esempio n. 7
0
static INT32 DrvInit()
{
	BurnSetRefreshRate(60.00);

	AllMem = NULL;
	MemIndex();
	INT32 nLen = MemEnd - (UINT8 *)0;
	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
	memset(AllMem, 0, nLen);
	MemIndex();

	{
		if (BurnLoadRom(DrvZ80ROM  + 0x00000,  0, 1)) return 1;
		if (BurnLoadRom(DrvZ80ROM  + 0x10000,  1, 1)) return 1;

		if (BurnLoadRom(t5182ROM   + 0x00000,  2, 1)) return 1;
		if (BurnLoadRom(t5182ROM   + 0x08000,  3, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM0 + 0x00000,  4, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM0 + 0x02000,  5, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM1 + 0x10000,  6, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM1 + 0x00000,  7, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM1 + 0x30000,  8, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM1 + 0x20000,  9, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM2 + 0x00000, 10, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM2 + 0x10000, 11, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM2 + 0x20000, 12, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM2 + 0x30000, 13, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM3 + 0x00000, 14, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM3 + 0x08000, 15, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM4 + 0x00000, 16, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM4 + 0x04000, 17, 1)) return 1;

		if (BurnLoadRom(DrvColPROM + 0x00000, 18, 1)) return 1;
		if (BurnLoadRom(DrvColPROM + 0x00100, 19, 1)) return 1;
		if (BurnLoadRom(DrvColPROM + 0x00200, 20, 1)) return 1;
		if (BurnLoadRom(DrvColPROM + 0x00300, 21, 1)) return 1;

		decrypt_prg();
		decrypt_gfx();
		decrypt_snd();

		DrvGfxDecode();
		DrvPaletteInit();
	}

	ZetInit(0);
	ZetOpen(0);
	ZetMapMemory(DrvZ80ROM,		0x0000, 0x7fff, MAP_ROM);
	ZetMapMemory(DrvZ80ROMDec,	0x0000, 0x7fff, MAP_FETCHOP);
	ZetMapMemory(DrvPalRAM,		0xd000, 0xd3ff, MAP_ROM);
	ZetMapMemory(DrvScrollRAM,	0xd400, 0xd4ff, MAP_RAM);
	ZetMapMemory(DrvVidRAM,		0xd800, 0xdfff, MAP_RAM);
	ZetMapMemory(DrvZ80RAM,		0xe000, 0xefff, MAP_RAM);
	ZetMapMemory(DrvSprRAM,		0xf000, 0xffff, MAP_RAM);
	ZetSetWriteHandler(darkmist_main_write);
	ZetSetReadHandler(darkmist_main_read);
	ZetClose();

	t5182Init(1, 14318180/4);

	GenericTilesInit();

	DrvDoReset();

	return 0;
}
Esempio n. 8
0
static int CyvernInit()
{
	int nRet = 0, nLen;
	
	BurnSetRefreshRate(59.5971);

	// Allocate and Blank all required memory
	Mem = NULL;
	MemIndex();
	nLen = MemEnd - (unsigned char *)0;
	if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1;
	memset(Mem, 0, nLen);
	MemIndex();

	DrvTempRom = (unsigned char *)malloc(0x800000);

	// Load BIOS Rom
	nRet = BurnLoadRom(DrvBiosRom + 0x000000, 0, 1); if (nRet != 0) return 1;
	be_to_le(DrvBiosRom, 0x00080000);
	
	// Load Program Rom
	nRet = BurnLoadRom(DrvPrgRom  + 0x000000, 1, 2); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvPrgRom  + 0x000001, 2, 2); if (nRet != 0) return 1;
	be_to_le(DrvPrgRom, 0x00200000);
	
	free(DrvTempRom);
	
	// Setup the 68000 emulation
	Sh2Init(1);
	Sh2Open(0);
	Sh2MapMemory(DrvBiosRom           , 0x00000000, 0x0007ffff, SM_ROM);
	Sh2MapMemory(DrvSpriteRam         , 0x02000000, 0x02003fff, SM_RAM);
	Sh2MapMemory(DrvSpriteRegs        , 0x02100000, 0x0210003f, SM_RAM);
	Sh2MapMemory(DrvTileRegs          , 0x02400000, 0x0240007f, SM_RAM);
	Sh2MapMemory(DrvTileARam          , 0x02500000, 0x02503fff, SM_RAM);
	Sh2MapMemory(DrvTileBRam          , 0x02504000, 0x02507fff, SM_RAM);
	Sh2MapMemory(DrvTileLineRam       , 0x02600000, 0x02607fff, SM_RAM);
	Sh2MapMemory(DrvPaletteRegs       , 0x02a00000, 0x02a0001f, SM_RAM);
	Sh2MapMemory(DrvPaletteRam        , 0x02a40000, 0x02a5ffff, SM_RAM);
	Sh2MapMemory(DrvPrgRom            , 0x04000000, 0x041fffff, SM_ROM);
	Sh2MapMemory(DrvTileBTilesRam     , 0x04800000, 0x0483ffff, SM_RAM);
	Sh2MapMemory(DrvPrgRam            , 0x06000000, 0x06ffffff, SM_RAM);
//	Sh2MapMemory(DrvPrgRam            , 0x06000000, 0x06ffffff, SM_WRITE);
	Sh2MapMemory(DrvCacheRam          , 0xc0000000, 0xc0000fff, SM_RAM);
//	Sh2MapHandler(1                   , 0x06000028, 0x0600002b, SM_READ);
	Sh2SetReadByteHandler (0, CyvernReadByte);
	Sh2SetReadWordHandler (0, CyvernReadWord);
	Sh2SetReadLongHandler (0, CyvernReadLong);
	Sh2SetWriteByteHandler(0, CyvernWriteByte);
	Sh2SetWriteWordHandler(0, CyvernWriteWord);
	Sh2SetWriteLongHandler(0, CyvernWriteLong);
//	Sh2SetReadByteHandler (1, BiosSkipReadByte);
//	Sh2SetReadWordHandler (1, BiosSkipReadWord);
//	Sh2SetReadLongHandler (1, BiosSkipReadLong);
	Sh2Close();
	
	GenericTilesInit();

	// Reset the driver
	DrvDoReset();

	return 0;
}
Esempio n. 9
0
static int DrvInit(int nMcuType)
{
	int nRet = 0, nLen;

	// Allocate and Blank all required memory
	Mem = NULL;
	MemIndex();
	nLen = MemEnd - (unsigned char *)0;
	if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1;
	memset(Mem, 0, nLen);
	MemIndex();

	DrvTempRom = (unsigned char *)malloc(0x60000);

	// Load M6502 Program Roms
	nRet = BurnLoadRom(DrvM6502Rom + 0x00000, 0, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvM6502Rom + 0x08000, 1, 1); if (nRet != 0) return 1;
	
	// Load M6809 Program Roms
	nRet = BurnLoadRom(DrvM6809Rom + 0x00000, 2, 1); if (nRet != 0) return 1;
	
	// Load and decode the chars
	nRet = BurnLoadRom(DrvTempRom, 3, 1); if (nRet != 0) return 1;
	GfxDecode(0x400, 3, 8, 8, CharPlaneOffsets, CharXOffsets, CharYOffsets, 0x100, DrvTempRom, DrvChars);
	
	// Load and decode the tiles
	memset(DrvTempRom, 0, 0x60000);
	nRet = BurnLoadRom(DrvTempRom + 0x00000, 4, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x08000, 5, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x10000, 6, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x18000, 7, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x20000, 8, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x28000, 9, 1); if (nRet != 0) return 1;
	GfxDecode(0x100, 3, 16, 16, Tile1PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvTiles + (0x000 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile2PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvTiles + (0x100 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile3PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvTiles + (0x200 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile4PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvTiles + (0x300 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile1PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvTiles + (0x400 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile2PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvTiles + (0x500 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile3PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvTiles + (0x600 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile4PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvTiles + (0x700 * 16 * 16));
	
	// Load and decode the sprites
	memset(DrvTempRom, 0, 0x60000);
	nRet = BurnLoadRom(DrvTempRom + 0x00000, 10, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x08000, 11, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x10000, 12, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x18000, 13, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x20000, 14, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x28000, 15, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x30000, 16, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x38000, 17, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x40000, 18, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x48000, 19, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x50000, 20, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvTempRom + 0x58000, 21, 1); if (nRet != 0) return 1;
	GfxDecode(0x100, 3, 16, 16, Tile1PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvSprites + (0x000 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile2PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvSprites + (0x100 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile3PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvSprites + (0x200 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile4PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x00000, DrvSprites + (0x300 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile1PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvSprites + (0x400 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile2PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvSprites + (0x500 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile3PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvSprites + (0x600 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile4PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x18000, DrvSprites + (0x700 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile1PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x30000, DrvSprites + (0x800 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile2PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x30000, DrvSprites + (0x900 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile3PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x30000, DrvSprites + (0xa00 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile4PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x30000, DrvSprites + (0xb00 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile1PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x48000, DrvSprites + (0xc00 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile2PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x48000, DrvSprites + (0xd00 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile3PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x48000, DrvSprites + (0xe00 * 16 * 16));
	GfxDecode(0x100, 3, 16, 16, Tile4PlaneOffsets, TileXOffsets, TileYOffsets, 0x200, DrvTempRom + 0x48000, DrvSprites + (0xf00 * 16 * 16));
	
	// Load ADPCM Roms
	nRet = BurnLoadRom(DrvADPCMRom + 0x00000, 22, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvADPCMRom + 0x10000, 23, 1); if (nRet != 0) return 1;
	nRet = BurnLoadRom(DrvADPCMRom + 0x18000, 24, 1); if (nRet != 0) return 1;
		
	free(DrvTempRom);
	
	// Setup the M6502 emulation
	m6502Init(1);
	m6502Open(0);
	m6502MapMemory(DrvM6502Ram            , 0x0000, 0x17ff, M6502_RAM);
	m6502MapMemory(DrvVideoRam2           , 0x1800, 0x1fff, M6502_RAM);
	m6502MapMemory(DrvSpriteRam           , 0x2000, 0x27ff, M6502_RAM);
	m6502MapMemory(DrvVideoRam1           , 0x2800, 0x2fff, M6502_RAM);
	m6502MapMemory(DrvPaletteRam1         , 0x3000, 0x30ff, M6502_RAM);
	m6502MapMemory(DrvPaletteRam2         , 0x3100, 0x31ff, M6502_RAM);
	m6502MapMemory(DrvM6502Rom + 0x8000   , 0x4000, 0x7fff, M6502_ROM);
	m6502MapMemory(DrvM6502Rom            , 0x8000, 0xffff, M6502_ROM);
	m6502SetReadHandler(RenegadeReadByte);
	m6502SetWriteHandler(RenegadeWriteByte);
	m6502Close();
	
	// Setup the M6809 emulation
	M6809Init(1);
	M6809Open(0);
	M6809MapMemory(DrvM6809Ram          , 0x0000, 0x0fff, M6809_RAM);
	M6809MapMemory(DrvM6809Rom          , 0x8000, 0xffff, M6809_ROM);
	M6809SetReadByteHandler(RenegadeM6809ReadByte);
	M6809SetWriteByteHandler(RenegadeM6809WriteByte);
	M6809Close();
	
	if (nMcuType == MCU_TYPE_RENEGADE) {
		mcu_type = 0xda;
		mcu_encrypt_table = renegade_xor_table;
		mcu_encrypt_table_len = 0x37;
	}
	
	if (nMcuType == MCU_TYPE_KUNIOKUN) {
		mcu_type = 0x85;
		mcu_encrypt_table = kuniokun_xor_table;
		mcu_encrypt_table_len = 0x2a;
	}
	
	BurnYM3526Init(3000000, &DrvFMIRQHandler, &DrvSynchroniseStream, 1);
	BurnTimerAttachM6809YM3526(1500000);
	
	RenegadeADPCMInit(8000);
	
	GenericTilesInit();
	
	// Reset the driver
	DrvDoReset();

	return 0;
}