cave/d_mazinger: add highscore (barbudreadmon), some updates

This commit is contained in:
dinkc64 2018-11-02 19:17:25 -04:00
parent cf6d780a31
commit d164941db5
1 changed files with 93 additions and 95 deletions

View File

@ -1,5 +1,6 @@
// mazinger
#include "cave.h"
#include "watchdog.h"
#include "msm6295.h"
#include "burn_ym2203.h"
#include "bitswap.h"
@ -77,7 +78,7 @@ static void UpdateIRQStatus()
SekSetIRQLine(1, nIRQPending ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
}
UINT8 __fastcall mazingerReadByte(UINT32 sekAddress)
static UINT8 __fastcall mazingerReadByte(UINT32 sekAddress)
{
switch (sekAddress) {
case 0x800002:
@ -92,7 +93,7 @@ UINT8 __fastcall mazingerReadByte(UINT32 sekAddress)
return 0;
}
void __fastcall mazingerWriteByte(UINT32 sekAddress, UINT8 byteValue)
static void __fastcall mazingerWriteByte(UINT32 sekAddress, UINT8 byteValue)
{
switch (sekAddress) {
@ -107,7 +108,7 @@ void __fastcall mazingerWriteByte(UINT32 sekAddress, UINT8 byteValue)
}
}
UINT16 __fastcall mazingerReadWord(UINT32 sekAddress)
static UINT16 __fastcall mazingerReadWord(UINT32 sekAddress)
{
switch (sekAddress) {
case 0x300000:
@ -127,7 +128,7 @@ UINT16 __fastcall mazingerReadWord(UINT32 sekAddress)
UpdateIRQStatus();
return nRet;
}
case 0x30006E:
if (SoundLatchReplyIndex > SoundLatchReplyMax) {
SoundLatchReplyIndex = 0;
@ -135,12 +136,12 @@ UINT16 __fastcall mazingerReadWord(UINT32 sekAddress)
return 0;
}
return SoundLatchReply[SoundLatchReplyIndex++];
case 0x800000:
return DrvInput[0] ^ 0xFFFF;
case 0x800002:
return (DrvInput[1] ^ 0xF7FF) | (EEPROMRead() << 11);
return (DrvInput[1] ^ 0xF7FF) | (EEPROMRead() << 11);
default: {
bprintf(PRINT_NORMAL, _T("Attempt to read word value of location %x\n"), sekAddress);
}
@ -148,12 +149,12 @@ UINT16 __fastcall mazingerReadWord(UINT32 sekAddress)
return 0;
}
void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
static void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
{
if (sekAddress >= 0x30000a && sekAddress <= 0x300066) return;
if (sekAddress >= 0x30006a && sekAddress <= 0x30006c) return;
if (sekAddress >= 0x300004 && sekAddress <= 0x300006) return;
switch (sekAddress) {
case 0x300000:
nCaveXOffset = wordValue;
@ -161,13 +162,13 @@ void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
case 0x300002:
nCaveYOffset = wordValue;
return;
case 0x300008:
// CaveSpriteBuffer();
nCaveSpriteBank = wordValue;
return;
case 0x300068:
// Watchdog reset(?)
BurnWatchdogWrite();
return;
case 0x30006e:
SoundLatch = wordValue;
@ -176,7 +177,7 @@ void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
ZetNmi();
nCyclesDone[1] += ZetRun(0x0400);
return;
case 0x600000:
CaveTileReg[1][0] = wordValue;
break;
@ -186,7 +187,7 @@ void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
case 0x600004:
CaveTileReg[1][2] = wordValue;
break;
case 0x700000:
CaveTileReg[0][0] = wordValue;
break;
@ -196,12 +197,12 @@ void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
case 0x700004:
CaveTileReg[0][2] = wordValue;
break;
case 0x900000:
wordValue >>= 8;
EEPROMWrite(wordValue & 0x04, wordValue & 0x02, wordValue & 0x08);
break;
default: {
bprintf(PRINT_NORMAL, _T("Attempt to write word value %x to location %x\n"), wordValue, sekAddress);
@ -209,17 +210,17 @@ void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
}
}
void __fastcall mazingerWriteBytePalette(UINT32 sekAddress, UINT8 byteValue)
static void __fastcall mazingerWriteBytePalette(UINT32 sekAddress, UINT8 byteValue)
{
CavePalWriteByte(sekAddress & 0xffff, byteValue);
}
void __fastcall mazingerWriteWordPalette(UINT32 sekAddress, UINT16 wordValue)
static void __fastcall mazingerWriteWordPalette(UINT32 sekAddress, UINT16 wordValue)
{
CavePalWriteWord(sekAddress & 0xffff, wordValue);
}
UINT8 __fastcall mazingerZIn(UINT16 nAddress)
static UINT8 __fastcall mazingerZIn(UINT16 nAddress)
{
nAddress &= 0xFF;
@ -228,11 +229,11 @@ UINT8 __fastcall mazingerZIn(UINT16 nAddress)
SoundLatchStatus |= 0x04;
return SoundLatch & 0xFF;
}
case 0x52: {
return BurnYM2203Read(0, 0);
}
default: {
bprintf(PRINT_NORMAL, _T("Z80 Port Read %x\n"), nAddress);
}
@ -241,19 +242,18 @@ UINT8 __fastcall mazingerZIn(UINT16 nAddress)
return 0;
}
void __fastcall mazingerZOut(UINT16 nAddress, UINT8 nValue)
static void __fastcall mazingerZOut(UINT16 nAddress, UINT8 nValue)
{
nAddress &= 0xFF;
switch (nAddress) {
case 0x00: {
DrvZ80Bank = nValue & 0x07;
ZetMapArea(0x4000, 0x7FFF, 0, RomZ80 + (DrvZ80Bank * 0x4000));
ZetMapArea(0x4000, 0x7FFF, 2, RomZ80 + (DrvZ80Bank * 0x4000));
ZetMapMemory(RomZ80 + (DrvZ80Bank * 0x4000), 0x4000, 0x7FFF, MAP_ROM);
return;
}
case 0x10:
if (SoundLatchReplyIndex > SoundLatchReplyMax) {
SoundLatchReplyMax = -1;
@ -262,38 +262,38 @@ void __fastcall mazingerZOut(UINT16 nAddress, UINT8 nValue)
SoundLatchReplyMax++;
SoundLatchReply[SoundLatchReplyMax] = nValue;
break;
case 0x50: {
BurnYM2203Write(0, 0, nValue);
return;
}
case 0x51: {
BurnYM2203Write(0, 1, nValue);
return;
}
case 0x70: {
MSM6295Write(0, nValue);
return;
}
case 0x74: {
DrvOkiBank1 = (nValue >> 0) & 0x03;
DrvOkiBank2 = (nValue >> 4) & 0x03;
memcpy(MSM6295ROM + 0x00000, MSM6295ROMSrc + 0x20000 * DrvOkiBank1, 0x20000);
memcpy(MSM6295ROM + 0x20000, MSM6295ROMSrc + 0x20000 * DrvOkiBank2, 0x20000);
return;
}
default: {
bprintf(PRINT_NORMAL, _T("Z80 Port Write %x, %x\n"), nAddress, nValue);
}
}
}
UINT8 __fastcall mazingerZRead(UINT16 a)
static UINT8 __fastcall mazingerZRead(UINT16 a)
{
switch (a) {
default: {
@ -304,7 +304,7 @@ UINT8 __fastcall mazingerZRead(UINT16 a)
return 0;
}
void __fastcall mazingerZWrite(UINT16 a, UINT8 d)
static void __fastcall mazingerZWrite(UINT16 a, UINT8 d)
{
switch (a) {
default: {
@ -325,9 +325,9 @@ static INT32 DrvExit()
SekExit(); // Deallocate 68000s
ZetExit();
BurnYM2203Exit();
SoundLatch = 0;
DrvZ80Bank = 0;
DrvOkiBank1 = 0;
@ -338,41 +338,47 @@ static INT32 DrvExit()
return 0;
}
static INT32 DrvDoReset()
static INT32 DrvDoReset(INT32 clear_mem)
{
if (clear_mem) {
memset (RamStart, 0, RamEnd - RamStart);
}
SekOpen(0);
SekReset();
SekRun(10000); // Need to run for a bit and reset to make it start - Watchdog would force reset?
SekReset();
SekClose();
ZetOpen(0);
ZetReset();
ZetClose();
BurnYM2203Reset();
ZetClose();
MSM6295Reset(0);
EEPROMReset();
BurnWatchdogResetEnable();
HiscoreReset();
nVideoIRQ = 1;
nSoundIRQ = 1;
nUnknownIRQ = 1;
nIRQPending = 0;
SoundLatch = 0;
DrvZ80Bank = 0;
DrvOkiBank1 = 0;
DrvOkiBank2 = 0;
SoundLatch = 0;
SoundLatchStatus = 0x0C;
memset(SoundLatchReply, 0, sizeof(SoundLatchReply));
SoundLatchReplyIndex = 0;
SoundLatchReplyMax = -1;
return 0;
}
@ -403,13 +409,13 @@ inline static INT32 CheckSleep(INT32)
static INT32 DrvFrame()
{
INT32 nCyclesVBlank;
INT32 nInterleave = 80;
INT32 nCyclesSegment;
BurnWatchdogUpdate();
if (DrvReset) { // Reset machine
DrvDoReset();
DrvDoReset(1);
}
// Compile digital inputs
@ -424,10 +430,10 @@ static INT32 DrvFrame()
SekNewFrame();
ZetNewFrame();
SekOpen(0);
ZetOpen(0);
nCyclesTotal[0] = (INT32)((INT64)16000000 * nBurnCPUSpeedAdjust / (0x0100 * CAVE_REFRESHRATE));
nCyclesTotal[1] = (INT32)(4000000 / CAVE_REFRESHRATE);
nCyclesDone[0] = nCyclesDone[1] = 0;
@ -455,7 +461,7 @@ static INT32 DrvFrame()
if (pBurnDraw != NULL) {
DrvDraw(); // Draw screen if needed
}
CaveSpriteBuffer();
UINT8 Temp = nCaveSpriteBank;
nCaveSpriteBank = nCaveSpriteBankDelay;
@ -466,26 +472,26 @@ static INT32 DrvFrame()
nUnknownIRQ = 0;
UpdateIRQStatus();
}
nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting
nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
} else {
nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment);
}
BurnTimerUpdate(i * (nCyclesTotal[1] / nInterleave));
}
SekClose();
BurnTimerEndFrame(nCyclesTotal[1]);
if (pBurnSoundOut) {
BurnYM2203Update(pBurnSoundOut, nBurnSoundLen);
MSM6295Render(0, pBurnSoundOut, nBurnSoundLen);
}
ZetClose();
return 0;
@ -547,7 +553,7 @@ static INT32 LoadRoms()
{
BurnLoadRom(Rom01 + 0x00000, 0, 1);
BurnLoadRom(Rom01 + 0x80000, 1, 1);
BurnLoadRom(RomZ80, 2, 1);
UINT8 *pTemp = (UINT8*)BurnMalloc(0x400000);
@ -561,7 +567,7 @@ static INT32 LoadRoms()
BurnLoadRom(CaveTileROM[0], 5, 1);
NibbleSwap2(CaveTileROM[0], 0x200000);
pTemp = (UINT8*)BurnMalloc(0x200000);
BurnLoadRom(pTemp, 6, 1);
for (INT32 i = 0; i < 0x0100000; i++) {
@ -572,7 +578,7 @@ static INT32 LoadRoms()
// Load MSM6295 ADPCM data
BurnLoadRom(MSM6295ROMSrc, 7, 1);
BurnLoadRom(DefEEPROM, 8, 1);
return 0;
@ -591,7 +597,7 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
if (nAction & ACB_VOLATILE) { // Scan volatile ram
memset(&ba, 0, sizeof(ba));
ba.Data = RamStart;
ba.Data = RamStart;
ba.nLen = RamEnd - RamStart;
ba.szName = "RAM";
BurnAcb(&ba);
@ -614,13 +620,14 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
SCAN_VAR(DrvZ80Bank);
SCAN_VAR(DrvOkiBank1);
SCAN_VAR(DrvOkiBank2);
BurnWatchdogScan(nAction);
if (nAction & ACB_WRITE) {
ZetOpen(0);
ZetMapArea(0x4000, 0x7FFF, 0, RomZ80 + (DrvZ80Bank * 0x4000));
ZetMapArea(0x4000, 0x7FFF, 2, RomZ80 + (DrvZ80Bank * 0x4000));
ZetMapMemory(RomZ80 + (DrvZ80Bank * 0x4000), 0x4000, 0x7FFF, MAP_ROM);
ZetClose();
memcpy(MSM6295ROM + 0x00000, MSM6295ROMSrc + 0x20000 * DrvOkiBank1, 0x20000);
memcpy(MSM6295ROM + 0x20000, MSM6295ROMSrc + 0x20000 * DrvOkiBank2, 0x20000);
@ -633,11 +640,7 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
static void DrvFMIRQHandler(INT32, INT32 nStatus)
{
if (nStatus & 1) {
ZetSetIRQLine(0xff, CPU_IRQSTATUS_ACK);
} else {
ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
}
ZetSetIRQLine(0, (nStatus) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
}
static INT32 drvZInit()
@ -650,19 +653,12 @@ static INT32 drvZInit()
ZetSetWriteHandler(mazingerZWrite);
// ROM bank 1
ZetMapArea (0x0000, 0x3FFF, 0, RomZ80 + 0x0000); // Direct Read from ROM
ZetMapArea (0x0000, 0x3FFF, 2, RomZ80 + 0x0000); // Direct Fetch from ROM
ZetMapMemory(RomZ80 + 0x0000, 0x0000, 0x3FFF, MAP_ROM);
// ROM bank 2
ZetMapArea (0x4000, 0x7FFF, 0, RomZ80 + 0x4000); // Direct Read from ROM
ZetMapArea (0x4000, 0x7FFF, 2, RomZ80 + 0x4000); //
ZetMapMemory(RomZ80 + 0x4000, 0x4000, 0x7FFF, MAP_ROM);
// RAM
ZetMapArea (0xc000, 0xc7FF, 0, RamZ80 + 0x0000); // Direct Read from RAM
ZetMapArea (0xc000, 0xc7FF, 1, RamZ80 + 0x0000); // Direct Write to RAM
ZetMapArea (0xc000, 0xc7FF, 2, RamZ80 + 0x0000); //
ZetMapArea (0xf800, 0xffFF, 0, RamZ80 + 0x0800); // Direct Read from RAM
ZetMapArea (0xf800, 0xffFF, 1, RamZ80 + 0x0800); // Direct Write to RAM
ZetMapArea (0xf800, 0xffFF, 2, RamZ80 + 0x0800); //
ZetMapMemory(RamZ80 + 0x0000, 0xc000, 0xc7FF, MAP_RAM);
ZetMapMemory(RamZ80 + 0x0800, 0xf800, 0xffFF, MAP_RAM);
ZetClose();
return 0;
@ -711,12 +707,12 @@ static INT32 DrvInit()
SekSetWriteByteHandler(0, mazingerWriteByte);
SekSetReadWordHandler(0, mazingerReadWord);
SekSetWriteWordHandler(0, mazingerWriteWord);
SekSetWriteWordHandler(1, mazingerWriteWordPalette);
SekSetWriteByteHandler(1, mazingerWriteBytePalette);
SekClose();
}
drvZInit();
CavePalInit(0x8000);
@ -724,24 +720,26 @@ static INT32 DrvInit()
CaveSpriteInit(2, 0x0800000);
CaveTileInitLayer(0, 0x400000, 8, 0x0000);
CaveTileInitLayer(1, 0x400000, 6, 0x4400);
BurnWatchdogInit(DrvDoReset, 180 /*NOT REALLY*/);
BurnYM2203Init(1, 4000000, &DrvFMIRQHandler, 0);
BurnTimerAttachZet(4000000);
BurnYM2203SetRoute(0, BURN_SND_YM2203_YM2203_ROUTE, 0.60, BURN_SND_ROUTE_BOTH);
BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_1, 0.20, BURN_SND_ROUTE_BOTH);
BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_2, 0.20, BURN_SND_ROUTE_BOTH);
BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_3, 0.20, BURN_SND_ROUTE_BOTH);
memcpy(MSM6295ROM, MSM6295ROMSrc, 0x40000);
MSM6295Init(0, 1056000 / 132, 1);
MSM6295SetRoute(0, 2.00, BURN_SND_ROUTE_BOTH);
EEPROMInit(&eeprom_interface_93C46);
if (!EEPROMAvailable()) EEPROMFill(DefEEPROM,0, 0x80);
if (!EEPROMAvailable()) EEPROMFill(DefEEPROM, 0, 0x80);
bDrawScreen = true;
DrvDoReset(); // Reset machine
DrvDoReset(1); // Reset machine
return 0;
}
@ -750,7 +748,7 @@ static INT32 DrvInit()
static struct BurnRomInfo mazingerRomDesc[] = {
{ "mzp-0.u24", 0x080000, 0x43a4279f, BRF_ESS | BRF_PRG }, // 0 CPU #0 code
{ "mzp-1.924", 0x080000, 0xdb40acba, BRF_ESS | BRF_PRG }, // 1
{ "mzs.u21", 0x020000, 0xc5b4f7ed, BRF_ESS | BRF_PRG }, // 2 Z80 Code
{ "bp943a-2.u56", 0x200000, 0x97e13959, BRF_GRA }, // 3 Sprite data
@ -760,7 +758,7 @@ static struct BurnRomInfo mazingerRomDesc[] = {
{ "bp943a-0.u63", 0x200000, 0xc1fed98a, BRF_GRA }, // 6 Layer 1 Tile data
{ "bp943a-4.u64", 0x080000, 0x3fc7f29a, BRF_SND }, // 7 MSM6295 #1 ADPCM data
{ "mazinger_world.nv", 0x0080, 0x4f6225c6, BRF_ESS | BRF_PRG },
};
@ -771,7 +769,7 @@ STD_ROM_FN(mazinger)
static struct BurnRomInfo mazingerjRomDesc[] = {
{ "mzp-0.u24", 0x080000, 0x43a4279f, BRF_ESS | BRF_PRG }, // 0 CPU #0 code
{ "mzp-1.924", 0x080000, 0xdb40acba, BRF_ESS | BRF_PRG }, // 1
{ "mzs.u21", 0x020000, 0xc5b4f7ed, BRF_ESS | BRF_PRG }, // 2 Z80 Code
{ "bp943a-2.u56", 0x200000, 0x97e13959, BRF_GRA }, // 3 Sprite data
@ -781,7 +779,7 @@ static struct BurnRomInfo mazingerjRomDesc[] = {
{ "bp943a-0.u63", 0x200000, 0xc1fed98a, BRF_GRA }, // 6 Layer 1 Tile data
{ "bp943a-4.u64", 0x080000, 0x3fc7f29a, BRF_SND }, // 7 MSM6295 #1 ADPCM data
{ "mazinger_japan.nv", 0x0080, 0xf84a2a45, BRF_ESS | BRF_PRG },
};
@ -793,7 +791,7 @@ struct BurnDriver BurnDrvmazinger = {
"mazinger", NULL, NULL, NULL, "1994",
"Mazinger Z (World, ver. 94/06/27)\0", NULL, "Banpresto / Dynamic Pl. Toei Animation", "Cave",
L"Mazinger Z\0\u30DE\u30B8\u30F3\u30AC\u30FC \uFF3A (World, ver. 94/06/27)\0", NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL |BDF_ORIENTATION_FLIPPED | BDF_16BIT_ONLY, 2, HARDWARE_CAVE_68K_Z80, GBF_VERSHOOT, 0,
BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED | BDF_16BIT_ONLY | BDF_HISCORE_SUPPORTED, 2, HARDWARE_CAVE_68K_Z80, GBF_VERSHOOT, 0,
NULL, mazingerRomInfo, mazingerRomName, NULL, NULL, mazingerInputInfo, NULL,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
&CaveRecalcPalette, 0x8000, 240, 384, 3, 4
@ -803,7 +801,7 @@ struct BurnDriver BurnDrvmazingerj = {
"mazingerj", "mazinger", NULL, NULL, "1994",
"Mazinger Z (Japan, ver. 94/06/27)\0", NULL, "Banpresto / Dynamic Pl. Toei Animation", "Cave",
L"Mazinger Z\0\u30DE\u30B8\u30F3\u30AC\u30FC \uFF3A (Japan, ver. 94/06/27)\0", NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL |BDF_ORIENTATION_FLIPPED | BDF_16BIT_ONLY, 2, HARDWARE_CAVE_68K_Z80, GBF_VERSHOOT, 0,
BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED | BDF_16BIT_ONLY | BDF_HISCORE_SUPPORTED, 2, HARDWARE_CAVE_68K_Z80, GBF_VERSHOOT, 0,
NULL, mazingerjRomInfo, mazingerjRomName, NULL, NULL, mazingerInputInfo, NULL,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
&CaveRecalcPalette, 0x8000, 240, 384, 3, 4