📄 d_twinhawk.cpp
字号:
/*
Part of FBAs Taito 68k hardware drivers
Credits: Mame team, Raine team
Coding by KEV, with help from Treble Winner and Jan_Klaassen
*/
#include "taito.h"
static unsigned char *Mem=NULL,*MemEnd=NULL;
static unsigned char *RamStart=NULL,*RamEnd=NULL;
static unsigned char *Rom=NULL;
static unsigned char *twinhawk_ram=NULL,*twinhawk_src_pal=NULL;
unsigned char *sysbvidattr=NULL,*sysbvidram=NULL;
static unsigned char drvReset = 0;
static unsigned char *z80_rom=NULL,*z80_ram=NULL;
static unsigned int *twinhawk_pal=NULL;
// Z80 ROM bank
static int Z80Bank=0;
static int nCurrentBank=0;
static int nCyclesTotal[2];
static int nCyclesSegment=0;
static unsigned char twinhawkInputPort0[8], twinhawkInputPort1[8], twinhawkInputPort2[8], twinhawkInputPort3[8];
unsigned char twinhawkInput[4]= {0,0,0,0};
static unsigned char twinhawkDip[2]= {0, 0};
static struct BurnInputInfo twinhawkInputList[]=
{
{"P1 Coin" , BIT_DIGITAL, twinhawkInputPort2 + 0, "p1 coin" },
{"P1 Start" , BIT_DIGITAL, twinhawkInputPort0 + 7, "p1 start" },
{"P1 Up" , BIT_DIGITAL, twinhawkInputPort0 + 0, "p1 up" },
{"P1 Down" , BIT_DIGITAL, twinhawkInputPort0 + 1, "p1 down" },
{"P1 Left" , BIT_DIGITAL, twinhawkInputPort0 + 2, "p1 left" },
{"P1 Right" , BIT_DIGITAL, twinhawkInputPort0 + 3, "p1 right" },
{"P1 Button 1" , BIT_DIGITAL, twinhawkInputPort0 + 4, "p1 fire 1" },
{"P1 Button 2" , BIT_DIGITAL, twinhawkInputPort0 + 5, "p1 fire 2" },
{"P1 Button 3" , BIT_DIGITAL, twinhawkInputPort0 + 6, "p1 fire 3" },
{"P2 Coin" , BIT_DIGITAL, twinhawkInputPort2 + 1, "p2 coin" },
{"P2 Start" , BIT_DIGITAL, twinhawkInputPort1 + 7, "p2 start" },
{"P2 Up" , BIT_DIGITAL, twinhawkInputPort1 + 0, "p2 up" },
{"P2 Down" , BIT_DIGITAL, twinhawkInputPort1 + 1, "p2 down" },
{"P2 Left" , BIT_DIGITAL, twinhawkInputPort1 + 2, "p2 left" },
{"P2 Right" , BIT_DIGITAL, twinhawkInputPort1 + 3, "p2 right" },
{"P2 Button 1" , BIT_DIGITAL, twinhawkInputPort1 + 4, "p2 fire 1" },
{"P2 Button 2" , BIT_DIGITAL, twinhawkInputPort1 + 5, "p2 fire 2" },
{"P2 Button 3" , BIT_DIGITAL, twinhawkInputPort1 + 6, "p2 fire 3" },
{"Reset" , BIT_DIGITAL, &drvReset , "reset"},
{"Service" , BIT_DIGITAL, twinhawkInputPort2 + 2, "service" },
{"Tilt" , BIT_DIGITAL, twinhawkInputPort2 + 3, "tilt" },
{"Dip 1" , BIT_DIPSWITCH, twinhawkDip + 0 , "dip" },
{"Dip 2" , BIT_DIPSWITCH, twinhawkDip + 1 , "dip" },
};
static struct BurnDIPInfo twinhawkDIPList[]=
{
// Defaults
{0x0f, 0xff, 0xff, 0xF6, NULL },
{0x10, 0xff, 0xff, 0x37, NULL },
// Dip 1
{0 , 0xfe, 0xff , 2 , "Cabinet" },
{0x0f, 0x01, 0x01, 0x01, "Cocktail" },
{0x0f, 0x01, 0x01, 0x00, "Upright" },
{0 , 0xfe, 0xff , 2 , "Flip Screen" },
{0x0f, 0x01, 0x02, 0x02, "Off" },
{0x0f, 0x01, 0x02, 0x00, "On" },
{0 , 0xfe, 0 , 2 , "Test Mode" },
{0x0f, 0x01, 0x04, 0x04, "Off" },
{0x0f, 0x01, 0x04, 0x00, "On" },
{0 , 0xfe, 0 , 2 , "Demo Sounds" },
{0x0f, 0x01, 0x08, 0x00, "Off" },
{0x0f, 0x01, 0x08, 0x08, "On" },
{0 , 0xfe, 0 , 4 , "Coin A" },
{0x0f, 0x01, 0x30, 0x00, "4 Coins 1 Credit" },
{0x0f, 0x01, 0x30, 0x10, "3 Coins 1 Credit" },
{0x0f, 0x01, 0x30, 0x20, "2 Coins 1 Credit" },
{0x0f, 0x01, 0x30, 0x30, "1 Coin 1 Credit" },
{0 , 0xfe, 0 , 4 , "Coin B" },
{0x0f, 0x01, 0xc0, 0xc0, "1 Coin 2 Credits" },
{0x0f, 0x01, 0xc0, 0x80, "1 Coin 3 Credits" },
{0x0f, 0x01, 0xc0, 0x40, "1 Coin 4 Credits" },
{0x0f, 0x01, 0xc0, 0x00, "1 Coin 6 Credits" },
// Dip 2
{0 , 0xfe, 0 , 4 , "Difficulty" },
{0x10, 0x01, 0x03, 0x02, "Easy" },
{0x10, 0x01, 0x03, 0x03, "Medium" },
{0x10, 0x01, 0x03, 0x01, "Hard" },
{0x10, 0x01, 0x03, 0x00, "Hardest" },
{0 , 0xfe, 0 , 2 , "Bonus Life" },
{0x10, 0x01, 0x04, 0x00, "None" },
{0x10, 0x01, 0x04, 0x04, "100k, 1000k" },
{0 , 0xfe, 0 , 2 , "Complete Bonus" },
{0x10, 0x01, 0x08, 0x00, "100k points" },
{0x10, 0x01, 0x08, 0x08, "1 Up" },
{0 , 0xfe, 0 , 4 , "Lives" },
{0x10, 0x01, 0x30, 0x10, "1" },
{0x10, 0x01, 0x30, 0x00, "2" },
{0x10, 0x01, 0x30, 0x30, "3" },
{0x10, 0x01, 0x30, 0x20, "4" },
{0 , 0xfe, 0 , 2 , "Language" },
{0x10, 0x01, 0x40, 0x00, "English" },
{0x10, 0x01, 0x40, 0x40, "Japanese" },
{0 , 0xfe, 0 , 2 , "Coin Type" },
{0x10, 0x01, 0x80, 0x00, "Type 1" },
{0x10, 0x01, 0x80, 0x80, "Type 2" },
};
STDDIPINFO(twinhawk);
STDINPUTINFO(twinhawk);
void twinhawkBankSwitch(unsigned int /*a*/, unsigned int data)
{
Z80Bank=(data-1) & 0x03;
unsigned char* nStartAddress = z80_rom + 0x4000+(Z80Bank*0x4000);
nCurrentBank = Z80Bank;
ZetMapArea(0x4000, 0x7FFF, 0, nStartAddress);
ZetMapArea(0x4000, 0x7FFF, 2, nStartAddress);
}
void twinhawkYM2151IRQHandler(int irq )
{
if (irq)
{
ZetRaiseIrq(1);
}
else
{
ZetLowerIrq();
}
}
int twinhawkInpMake()
{
twinhawkInput[0] = twinhawkInput[1] = 0xff;
twinhawkInput[2] = 0xff;
for (int i = 0; i < 8; i++) {
twinhawkInput[0] -= (twinhawkInputPort0[i] & 1) << i;
twinhawkInput[1] -= (twinhawkInputPort1[i] & 1) << i;
twinhawkInput[2] -= (twinhawkInputPort2[i] & 1) << i;
}
return 0;
}
inline static unsigned int CalcCol(unsigned short nColour)
{
int r, g, b;
r = (nColour & 0x001F) << 3; // Red
r |= r >> 5;
g = (nColour & 0x03E0) >> 2; // Green
g |= g >> 5;
b = (nColour & 0x7C00) >> 7; // Blue
b |= b >> 5;
return BurnHighCol(b, g, r, 0);
}
int twinhawkPalUpdate()
{
int i;
unsigned short* ps;
unsigned int* pd;
for (i = 0, ps = (unsigned short*)twinhawk_src_pal, pd = twinhawk_pal; i < 0x400; i++, ps++, pd++) {
*pd = CalcCol(*ps);
}
return 0;
}
////
// This routine is called first to determine how much memory is needed (MemEnd-(unsigned char *)0),
// and then to set up all the pointers
static int MemIndex()
{
unsigned char *Next; Next=Mem;
Rom =Next; Next+=0x40000; // 68000 program
z80_rom=Next; Next+=0x1c000;
RamStart =Next;
twinhawk_ram=Next; Next+=0xb000;
sysbvidattr=Next; Next+=0x1000;
sysbvidram=Next; Next+=0x4000;
twinhawk_src_pal=Next; Next+=0x1000;
twinhawk_pal=(unsigned int*)Next; Next += 0x800 * sizeof(unsigned int);
z80_ram=Next; Next+=0x2000;
RamEnd =Next;
MemEnd=Next;
return 0;
}
static int LoadRoms()
{
int nRet=0;
// Load program roms and byteswap
nRet=BurnLoadRom(Rom+0x00001,0,2); if (nRet!=0) return 1;
nRet=BurnLoadRom(Rom+0x00000,1,2); if (nRet!=0) return 1;
nRet=BurnLoadRom(z80_rom,2,1); // load z80 code rom
ttiles=(unsigned char *)malloc(0x400000);
memset(ttiles,0,16384*256);
SysxTempGfx=(unsigned char *)malloc(0x200000);
nRet=BurnLoadRom(SysxTempGfx,3,1);
nRet=BurnLoadRom(SysxTempGfx+0x80000,4,1);
nRet=BurnLoadRom(SysxTempGfx+0x100000,5,1);
nRet=BurnLoadRom(SysxTempGfx+0x180000,6,1);
return nRet;
}
unsigned char __fastcall twinhawkZ80Read(unsigned short a)
{
switch (a)
{
case (0xe000):
return BurnYM2151ReadStatus();
case (0xe001):
return BurnYM2151ReadStatus();
case (0xe201):
return tc0140_slave_comm_r();
default:
return 0;
}
}
void __fastcall twinhawkZ80Write(unsigned short a,unsigned char d)
{
switch (a)
{
case 0xe000:
BurnYM2151SelectRegister(d);
return;
case 0xe001:
BurnYM2151WriteRegister(d);
return;
case 0xe200:
tc0140_slave_port_w(d);
return;
case 0xe201:
tc0140_slave_comm_w(d);
return;
case 0xf200:
twinhawkBankSwitch(0,d);
default:
return;
}
}
unsigned short __fastcall twinhawkReadWord(unsigned int a)
{
if (a>=0x500000&&a<=0x50000f)
{
switch (a)
{
case 0x500000:
return 0xff; //readinputport (0) & 0x0f;
case 0x500002:
return 0xff;//(readinputport (0) & 0xf0) >> 4;
case 0x500004:
return 0xff;// readinputport (1) & 0x0f;
case 0x500006:
return 0xff;// (readinputport (1) & 0xf0) >> 4;
default:
return 0xFF;
}
}
if (a==0x900000)
{
return twinhawkInput[0];
}
if (a==0x900002)
{
return twinhawkInput[1];
}
if (a==0x900004)
{
return twinhawkInput[2];
}
if (a>=0x900000&&a<=0x90000f)
{
bprintf(PRINT_NORMAL, _T("input word read %x\n"),a);
return 0;
}
if (a==0x800002)
{
bprintf(PRINT_NORMAL, _T("sound word read %x\n"),a);
return 0xff;
}
if (a==0x800003)
{
bprintf(PRINT_NORMAL, _T("sound word read %x\n"),a);
return 0xff;
}
bprintf(PRINT_NORMAL, _T("unknown word read %x\n"),a);
return 0xFF;
}
unsigned char __fastcall twinhawkReadByte(unsigned int a)
{
if (a>=0x500000&&a<=0x50000f)
{
// bprintf(PRINT_NORMAL, "DSW byte read %x\n",a);
return 0xFF;
}
if (a==0x900001)
{
return twinhawkInput[0];
}
if (a==0x900003)
{
return twinhawkInput[1];
}
if (a==0x900005)
{
return twinhawkInput[2];
}
if (a>=0x900000&&a<=0x90000f)
{
bprintf(PRINT_NORMAL, _T("input byte read %x\n"),a);
return 0xff;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -