⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d_twinhawk.cpp

📁 motorola ezx 平台下的fba模拟器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	}

	if (a==0x800002)
	{
		bprintf(PRINT_NORMAL, _T("sound byte read %x\n"),a);
		return 0xff;
	}

	if (a==0x800003)
	{
		return tc0140_comm_r();
	}
	bprintf(PRINT_NORMAL, _T("unknown byte read %x\n"),a);

	return 0xFF;
}

void __fastcall twinhawkWriteWord(unsigned int a,unsigned short d)
{
	if (a>=0x900000&&a<=0x90000f)
	{
//		bprintf(PRINT_NORMAL, "input word write %x\n",a);
	}
	if (a==0x800000)
	{
		bprintf(PRINT_NORMAL, _T("sound word write %x\n"),a);
	}

	if (a==0x800001)
	{
		bprintf(PRINT_NORMAL, _T("sound word write %x\n"),a);
	}

	if (a==0x800002)
	{
		bprintf(PRINT_NORMAL, _T("sound word write %x\n"),a);
	}

	if (a==0x800003)
	{
		bprintf(PRINT_NORMAL, _T("sound word write %x\n"),a);
	}
	if (a<=0xf03fff)
		bprintf(PRINT_NORMAL, _T("unknown word write %x %x\n"),a,d);

	return;
}

void __fastcall twinhawkWriteByte(unsigned int a,unsigned char d)
{
	if (a>=0x900000&&a<=0x90000f)
	{
//		bprintf(PRINT_NORMAL, "input byte write %x\n",a);
	}

	if (a==0x800000)
	{
		bprintf(PRINT_NORMAL, _T("sound byte write %x\n"),a);
	}

	if (a==0x800001)
	{
		tc0140_port_w(d);
	}

	if (a==0x800002)
	{
		bprintf(PRINT_NORMAL, _T("sound byte write %x\n"),a);
	}

	if (a==0x800003)
	{
		tc0140_comm_w(d);
	}

//	bprintf(PRINT_NORMAL, "unknown word byte %x %x\n",a,d);

	return;
}

static int drvDoReset()
{
	SekOpen(0);
	SekReset();
	SekClose();
	ZetOpen(0);
	ZetReset();
	ZetClose();
	ZetRun(4000000/60);
	BurnYM2151Reset();
	return 0;
}

int twinhawkInit()
{
	int nRet=0; int nLen=0;

	//--------------Allocate Memory-----------------
	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

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

	// Map in memory:
	// ----------------- Cpu 1 68k ------------------------
	SekInit(0, 0x68000); // Allocate 1 68000
	SekOpen(0);
	SekMapMemory(    Rom  ,0x000000,0x3ffff,SM_ROM); // 68000 Rom
	SekMapMemory(twinhawk_src_pal,0xb00000,0xb00FFF,SM_RAM);
	SekMapMemory(sysbvidattr,0xd00000,0xd00fff,SM_RAM);
	SekMapMemory(sysbvidram,0xe00000,0xe03fff,SM_RAM);
	SekMapMemory(twinhawk_ram,0xf00000,0xf03fff,SM_RAM);

	SekSetReadWordHandler(0, twinhawkReadWord);
	SekSetWriteWordHandler(0, twinhawkWriteWord);
	SekSetReadByteHandler(0, twinhawkReadByte);
	SekSetWriteByteHandler(0, twinhawkWriteByte);
	SekClose();
	// ------------------------------------------------
	// ----------------- Cpu 2 Z80 ------------------------
	ZetInit(1);
	ZetOpen(0);
	ZetSetReadHandler(twinhawkZ80Read);
	ZetSetWriteHandler(twinhawkZ80Write);
	ZetMapArea (0x0000,0x3FFF,0,z80_rom);
	ZetMapArea (0x0000,0x3FFF,2,z80_rom);
//	ZetMapArea (0x4000,0x7FFF,0,z80_rom+0x4000);
//	ZetMapArea (0x4000,0x7FFF,2,z80_rom+0x4000);
	ZetMapArea (0xc000,0xdfff,0,z80_ram);
	ZetMapArea (0xc000,0xdfff,2,z80_ram);
	ZetMapArea (0xc000,0xdfff,1,z80_ram);
	ZetMemEnd();
	ZetMemCallback(0xe000, 0xFFFF, 0);			// Read
	ZetMemCallback(0xe000, 0xFFFF, 1);			// Write
	ZetReset();
	ZetClose();
	//-------------------------------------------------

	//-------- sound stuff ----------------------------
	//---------- YM2151 Setup ----------------------
	BurnYM2151Init(4000000, 50.0);
	BurnYM2151SetIrqHandler(&twinhawkYM2151IRQHandler);
	nCurrentBank=-1;

	//--------------------------------------------------
	// ------- GFX Init -------------------
	taito_pal=twinhawk_pal;
	SysXInit(0);
	drvDoReset();
	return 0;
	}

int twinhawkExit()
{

	free(ttiles);
	BurnYM2151Exit();
	SekExit(); // Deallocate 68000
	ZetExit();
	if (Mem!=NULL)
		free(Mem);
	Mem=NULL;
	return 0;
}

static int twinhawkDraw()
{
	twinhawkPalUpdate();
	SysXBG();
	SysXSprites();
	return 0;
}

int twinhawkFrame()
{
	if (drvReset) {	// Reset machine
		drvDoReset();
	}

	twinhawkInpMake();

	int nInterleave =10;

	SekNewFrame();

	SekOpen(0);
	ZetOpen(0);
	nCyclesTotal[0] = 8000000/60;
	nCyclesTotal[1] = 4000000/60;
	rCyclesDone[0] = rCyclesDone[1] = 0;

	int nSoundBufferPos = 0;

	for (int i = 0; i < nInterleave; i++) {
    	int nCurrentCPU;
		int nNext;
		// Run 68000
		nCurrentCPU = 0;
		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;

		nCyclesSegment = nNext - rCyclesDone[nCurrentCPU];
		rCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
		// Run Z80
		nCurrentCPU = 1;

		nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
		nCyclesSegment = nNext - rCyclesDone[nCurrentCPU];

		nCyclesSegment = ZetRun(nCyclesSegment);
		rCyclesDone[nCurrentCPU] += nCyclesSegment;
		{
			// Render sound segment
			if (pBurnSoundOut) {
				int nSegmentLength = nBurnSoundLen / nInterleave;
				short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
				BurnYM2151Render(pSoundBuf, nSegmentLength);
				nSoundBufferPos += nSegmentLength;
			}
		}
	}

	{
		// Make sure the buffer is entirely filled.
		if (pBurnSoundOut) {
			int nSegmentLength = nBurnSoundLen - nSoundBufferPos;
			short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
			if (nSegmentLength) {
				BurnYM2151Render(pSoundBuf, nSegmentLength);
			}
		}
	}
	SekSetIRQLine(2, SEK_IRQSTATUS_AUTO);
	ZetClose();
	SekClose();

	if (pBurnDraw) {
		twinhawkDraw();														// Draw screen if needed
	}

	return 0;
}

int twinhawkScan(int /*nAction*/,int* /**pnMin*/)
{
	return 1;
}
// Twin Hawk (World)
/// Rom information
static struct BurnRomInfo twinhawkRomDesc[] = {
	{ "b87-11.bin",    0x20000, 0xfc84a399, BRF_ESS | BRF_PRG }, //  0 68000 code (even)
	{ "b87-10.bin",    0x20000, 0x17181706, BRF_ESS | BRF_PRG }, //  1            (odd)

	{ "b87-07",         0x8000, 0xe2e0efa0, BRF_GRA },			 //  2 z80 code

	{ "b87-02",        0x80000, 0x89ad43a0, BRF_GRA },			 //  2 8x8 tile bitmaps
	{ "b87-04",        0x80000, 0x958434b6, BRF_GRA },			 //  2 8x8 tile bitmaps
	{ "b87-01",        0x80000, 0x81e82ae1, BRF_GRA },			 //  2 8x8 tile bitmaps
	{ "b87-03",        0x80000, 0xce155ae0, BRF_GRA },			 //  2 8x8 tile bitmaps

};


STD_ROM_PICK(twinhawk);
STD_ROM_FN(twinhawk);

struct BurnDriver BurnDrvtwinhawk = {
	"twinhawk", NULL, NULL, "1989",
	"Twin Hawk (World)\0", NULL, "Taito Corporation Japan", "Taito X System",
	NULL, NULL, NULL, NULL,
	BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL,2,HARDWARE_MISC_MISC,
	NULL,twinhawkRomInfo,twinhawkRomName,twinhawkInputInfo, NULL,
	twinhawkInit,twinhawkExit,twinhawkFrame,NULL,twinhawkScan,
	&taitoRecalcPal,224,384,3,4
};

//Twin Hawk (US)
static struct BurnRomInfo twinhwkuRomDesc[] = {
	{ "b87-09.u6",     0x20000, 0x7e6267c7, BRF_ESS | BRF_PRG }, //  0 68000 code (even)
	{ "b87-08.u4",     0x20000, 0x31d9916f, BRF_ESS | BRF_PRG }, //  1            (odd)

	{ "b87-07",         0x8000, 0xe2e0efa0, BRF_GRA },			 //  2 z80 code

	{ "b87-02",        0x80000, 0x89ad43a0, BRF_GRA },			 //  2 8x8 tile bitmaps
	{ "b87-04",        0x80000, 0x958434b6, BRF_GRA },			 //  2 8x8 tile bitmaps
	{ "b87-01",        0x80000, 0x81e82ae1, BRF_GRA },			 //  2 8x8 tile bitmaps
	{ "b87-03",        0x80000, 0xce155ae0, BRF_GRA },			 //  2 8x8 tile bitmaps

};


STD_ROM_PICK(twinhwku);
STD_ROM_FN(twinhwku);

struct BurnDriver BurnDrvtwinhwku = {
	"twinhwku", "twinhawk", NULL, "1989",
	"Twin Hawk (US)\0", NULL, "Taito America Corporation", "Taito X System",
	NULL, NULL, NULL, NULL,
	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL,2,HARDWARE_MISC_MISC,
	NULL,twinhwkuRomInfo,twinhwkuRomName,twinhawkInputInfo, twinhawkDIPInfo,
	twinhawkInit,twinhawkExit,twinhawkFrame,NULL,twinhawkScan,
	&taitoRecalcPal,224,384,3,4
};

// Daisenpu (Japan)
static struct BurnRomInfo daisenpuRomDesc[]=
{
	{ "b87-06",0x20000, 0xcf236100, BRF_ESS | BRF_PRG }, //  0 68000 code (even)
	{ "b87-05",0x20000, 0x7f15edc7, BRF_ESS | BRF_PRG }, //  1            (odd)

	{ "b87-07",0x8000, 0xe2e0efa0,  BRF_GRA }, //  2 z80 code

	{ "b87-02",0x80000, 0x89ad43a0, BRF_GRA }, //  2 8x8 tile bitmaps
	{ "b87-04",0x80000, 0x958434b6, BRF_GRA }, //  2 8x8 tile bitmaps
	{ "b87-01",0x80000, 0x81e82ae1, BRF_GRA }, //  2 8x8 tile bitmaps
	{ "b87-03",0x80000, 0xce155ae0, BRF_GRA }, //  2 8x8 tile bitmaps
};

STD_ROM_PICK(daisenpu);
STD_ROM_FN(daisenpu);

struct BurnDriver BurnDrvdaisenpu = {
	"daisenpu", "twinhawk", NULL, "1989",
	"Daisenpu (Japan)\0", NULL, "Taito America Corporation", "Taito X System",
	NULL, NULL, NULL, NULL,
	BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL,2,HARDWARE_MISC_MISC,
	NULL,daisenpuRomInfo,daisenpuRomName,twinhawkInputInfo, twinhawkDIPInfo,
	twinhawkInit,twinhawkExit,twinhawkFrame,NULL,twinhawkScan,
	&taitoRecalcPal,224,384,3,4
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -