📄 d_opwolf.cpp
字号:
}
if (a>=0x0f000a&&a<=0x0f000b)
{
return opwolfInput[1]; // input b/dip b?
}
if (a==0x380000/*&&a<=0x380001*/)
{
return 0xff - opwolfDip[0]; //dip a??
}
if (a==0x380002/*&&a<=0x380003*/)
{
return 0x70 + opwolfDip[1]; //dip b??
}
switch (a)
{
case 0x3e0003:
return tc0140_comm_r();
default:
// bprintf(PRINT_NORMAL, "read w%x\n",a);
return 0;
}
}
unsigned char __fastcall opwolfReadByte(unsigned int a)
{
if (a>=0x0ff000&&a<=0x0fffff)
{
int offset=a-0x0ff000;
// bprintf(PRINT_NORMAL, "cchip returns %x at %x\n",z802_ram[offset],offset);
return z802_ram[offset/2]; // cchip bootleg
}
if (a>=0x0f0008&&a<=0x0f0009)
{
return opwolfInput[0]; // input a/dip a?
}
if (a>=0x0f000a&&a<=0x0f000b)
{
return opwolfInput[1]; // input b/dip b?
}
switch (a)
{
case 0x3e0002:
return tc0140_comm_r();
case 0x3e0003:
return tc0140_comm_r();
default:
// bprintf(PRINT_NORMAL, "read b%x\n",a);
return 0;
}
}
void __fastcall opwolfWriteWord(unsigned int a,unsigned short d)
{
if (a>=0x0ff000&&a<=0x0fffff)
{
int offset=a-0x0ff000;
// bprintf(PRINT_NORMAL, "cchip returns %x at %x\n",z802_ram[offset],offset);
z802_ram[offset/2]=d; // cchip bootleg
return;
}
switch (a){
case 0xc20000:
if (PC080SN_ctrl_word_0[0]&0x01) {
d= -d;
}
p1scrolly=-d;
return;
case 0xc20002:
if (PC080SN_ctrl_word_0[0]&0x01) {
d= -d;
}
p2scrolly=-d;
return;
case 0xc40000:
if (PC080SN_ctrl_word_0[0]&0x01) {
d= -d;
}
p1scrollx=-d;
return;
case 0xc40002:
if (PC080SN_ctrl_word_0[0]&0x01) {
d= -d;
}
p2scrollx=-d;
return;
default:
return;
}
}
void __fastcall opwolfWriteByte(unsigned int a,unsigned char d)
{
if (a>=0x0ff000&&a<=0x0fffff)
{
int offset=a-0x0ff000;
// bprintf(PRINT_NORMAL, "cchip returns %x at %x\n",z802_ram[offset],offset);
z802_ram[offset/2]=d; // cchip bootleg
return;
}
switch (a)
{
case 0x3e0000:
tc0140_port_w(d);
return;
case 0x3e0001:
tc0140_port_w(d);
return;
case 0x3e0002:
tc0140_comm_w(d);
return;
case 0x3e0003:
tc0140_comm_w(d);
return;
default:
// bprintf(PRINT_NORMAL, "write b%x at %x\n",d,a);
return;
}
}
static int drvDoReset()
{
SekOpen(0);
SekReset();
SekClose();
ZetOpen(0);
ZetReset();
ZetRun(4000000/60);
ZetClose();
ZetOpen(1);
ZetReset();
ZetClose();
BurnYM2151Reset();
MSM5205Reset(0);
MSM5205Reset(1);
return 0;
}
int opwolfInit()
{
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
// ----------------- Cpu 1 68k ------------------------
SekInit(0, 0x68000); // Allocate 1 68000
SekOpen(0);
SekMapMemory( Rom ,0x000000,0x03ffff,SM_ROM); // 68000 Rom
SekMapMemory(opwolf_ram,0x100000,0x107fff,SM_RAM);
SekMapMemory(opwolf_src_pal,0x200000,0x200fff,SM_RAM);
SekMapMemory(PC090OJ_spritectrl,0x380000,0x380003,SM_WRITE);
SekMapMemory(opwolf_ram+0x8000,0x3c0000,0x3c0001,SM_RAM); //0x3010
SekMapMemory(PC080SN_word_0,0xc00000,0xc0ffff,SM_RAM);
SekMapMemory(PC080SN_ctrl_word_0,0xc50000,0xc50003,SM_WRITE);
SekMapMemory(PC090OJ_word_0,0xd00000,0xd03fff,SM_RAM);
SekSetWriteWordHandler(0, opwolfWriteWord);
SekSetReadWordHandler(0, opwolfReadWord);
SekSetReadByteHandler(0, opwolfReadByte);
SekSetWriteByteHandler(0, opwolfWriteByte);
SekClose();
// ----------------- Cpu 2 Z80 ------------------------
ZetInit(2);
ZetOpen(0);
ZetSetReadHandler(opwolfZ80Read);
ZetSetWriteHandler(opwolfZ80Write);
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 (0x8000,0x8FFF,0,z80_ram);
ZetMapArea (0x8000,0x8FFF,2,z80_ram);
ZetMapArea (0x8000,0x8FFF,1,z80_ram);
// Callbacks
ZetMemCallback(0x9000, 0xd002, 0); // Read
ZetMemCallback(0x9000, 0xd002, 1); // Write
ZetMemEnd();
ZetReset();
ZetClose();
ZetOpen(1);
ZetSetReadHandler(opwolfZ802Read);
ZetSetWriteHandler(opwolfZ802Write);
ZetMapArea (0x0000,0x7fff,0,z802_rom);
ZetMapArea (0x0000,0x7fff,2,z802_rom);
// ZetMapArea (0x8800,0xbFFF,0,z802_ram);
// ZetMapArea (0x8800,0xbFFF,1,z802_ram);
// ZetMapArea (0x8800,0xbFFF,2,z802_ram);
ZetMapArea (0xc000,0xcfff,0,z802_ram);
ZetMapArea (0xc000,0xcfff,1,z802_ram);
ZetMapArea (0xc000,0xcfff,2,z802_ram);
ZetMemCallback(0xc000, 0x9800, 0); // Read
ZetMemCallback(0xc000, 0x9800, 1); // Write
ZetMemEnd();
ZetReset();
ZetClose();
//-------------------------------------------------
//-------- sound stuff ----------------------------
//---------- YM2151 Setup ----------------------
BurnYM2151Init(4000000, 50.0);
BurnYM2151SetIrqHandler(&opwolfYM2151IRQHandler);
BurnYM2151SetPortHandler(&opwolfBankSwitch);
nCurrentBank=-1;
MSM5205Init(0,8000, 100,1);
MSM5205Init(1,8000, 100,1);
//--------------------------------------------------
// ------- GFX Init -------------------
taito_pal=opwolf_pal;
init_taito_gfx();
//-------------------------------------
drvDoReset();
return 0;
}
int opwolfExit()
{
if(tsprites)
free(tsprites);
if(ttiles)
free(ttiles);
BurnYM2151Exit();
MSM5205Exit(0);
MSM5205Exit(1);
SekExit(); // Deallocate 68000
ZetExit();
if (Mem!=NULL)
free(Mem);
Mem=NULL;
return 0;
}
static int opwolfGFX()
{
PC080SN_bg();
PC090OJ_draw_sprites();
PC080SN_fg();
draw_gun(gun_x >> 8,gun_y >> 8);
return 0;
}
static int opwolfDraw()
{
opwolfPalUpdate();
opwolfGFX();
return 0;
}
int opwolfFrame()
{
if (drvReset) { // Reset machine
drvDoReset();
}
opwolfInpMake();
int nInterleave = 10;
SekNewFrame();
SekOpen(0);
ZetOpen(0);
nCyclesTotal[0] = 12000000/60;
nCyclesTotal[1] = 4000000/60;
nCyclesTotal[2] = 4000000/60;
rCyclesDone[0] =rCyclesDone[1] = rCyclesDone[2] = 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;
ZetClose();
ZetOpen(1);
nCurrentCPU = 2;
nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
nCyclesSegment = nNext - rCyclesDone[nCurrentCPU];
nCyclesSegment = ZetRun(nCyclesSegment);
ZetClose();
ZetOpen(0);
rCyclesDone[nCurrentCPU] += nCyclesSegment;
{
// Render sound segment
if (pBurnSoundOut) {
int nSegmentLength = nBurnSoundLen / nInterleave;
short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
BurnYM2151Render(pSoundBuf, nSegmentLength);
MSM5205Render(0,pSoundBuf, nSegmentLength); //this wrong??
MSM5205Render(1,pSoundBuf, nSegmentLength); //this wrong??
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);
MSM5205Render(0,pSoundBuf, nSegmentLength); //this wrong??
MSM5205Render(1,pSoundBuf, nSegmentLength); //this wrong??
}
}
}
SekSetIRQLine(5, SEK_IRQSTATUS_AUTO);
SekClose();
ZetClose();
ZetOpen(1);
ZetRaiseIrq(1);
ZetClose();
if (pBurnDraw) {
opwolfDraw(); // Draw screen if needed
}
return 0;
}
int opwolfScan(int /* nAction */,int* /* pnMin */)
{
return 1;
}
/// Rom information
static struct BurnRomInfo opwolfRomDesc[] = {
{ "opwlf.40", 0x10000, 0x3ffbfe3a, BRF_ESS | BRF_PRG }, // 0 68000 code (even)
{ "opwlf.30", 0x10000, 0xfdabd8a5, BRF_ESS | BRF_PRG }, // 1 (odd)
{ "opwlf.39", 0x10000, 0x216b4838, BRF_ESS | BRF_PRG }, // 0 68000 code (even)
{ "opwlf.29", 0x10000, 0xb71bc44c, BRF_ESS | BRF_PRG }, // 1 (odd)
{ "opwlf_s.10", 0x10000, 0x45c7ace3, BRF_GRA }, // 2 z80 code
{ "opwlfb.09", 0x08000, 0xab27a3dd, BRF_GRA }, // 2 z80 code bootleg cchip
{ "opwlf.13", 0x80000, 0xf6acdab1, BRF_GRA }, // 2 8x8 tile bitmaps
{ "opwlf.72", 0x80000, 0x89f889e5, BRF_GRA }, // 6 Sprite
{ "opwlf_s.21", 0x80000, 0xf3e19c64, BRF_GRA }, // adpcm
};
STD_ROM_PICK(opwolf);
STD_ROM_FN(opwolf);
struct BurnDriver BurnDrvopwolf = {
"opwolf", NULL, NULL, "1987",
"Operation Wolf\0", NULL, "Taito", "Custom Taito",
NULL, NULL, NULL, NULL,
1,2,HARDWARE_MISC_MISC,
NULL,opwolfRomInfo,opwolfRomName,opwolfInputInfo, opwolfDIPInfo,
opwolfInit,opwolfExit,opwolfFrame,NULL,opwolfScan,
&taitoRecalcPal,320,240,4,3
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -