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 // mazinger
#include "cave.h" #include "cave.h"
#include "watchdog.h"
#include "msm6295.h" #include "msm6295.h"
#include "burn_ym2203.h" #include "burn_ym2203.h"
#include "bitswap.h" #include "bitswap.h"
@ -77,7 +78,7 @@ static void UpdateIRQStatus()
SekSetIRQLine(1, nIRQPending ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE); SekSetIRQLine(1, nIRQPending ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
} }
UINT8 __fastcall mazingerReadByte(UINT32 sekAddress) static UINT8 __fastcall mazingerReadByte(UINT32 sekAddress)
{ {
switch (sekAddress) { switch (sekAddress) {
case 0x800002: case 0x800002:
@ -92,7 +93,7 @@ UINT8 __fastcall mazingerReadByte(UINT32 sekAddress)
return 0; return 0;
} }
void __fastcall mazingerWriteByte(UINT32 sekAddress, UINT8 byteValue) static void __fastcall mazingerWriteByte(UINT32 sekAddress, UINT8 byteValue)
{ {
switch (sekAddress) { 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) { switch (sekAddress) {
case 0x300000: case 0x300000:
@ -148,7 +149,7 @@ UINT16 __fastcall mazingerReadWord(UINT32 sekAddress)
return 0; 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 >= 0x30000a && sekAddress <= 0x300066) return;
if (sekAddress >= 0x30006a && sekAddress <= 0x30006c) return; if (sekAddress >= 0x30006a && sekAddress <= 0x30006c) return;
@ -167,7 +168,7 @@ void __fastcall mazingerWriteWord(UINT32 sekAddress, UINT16 wordValue)
nCaveSpriteBank = wordValue; nCaveSpriteBank = wordValue;
return; return;
case 0x300068: case 0x300068:
// Watchdog reset(?) BurnWatchdogWrite();
return; return;
case 0x30006e: case 0x30006e:
SoundLatch = wordValue; SoundLatch = wordValue;
@ -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); CavePalWriteByte(sekAddress & 0xffff, byteValue);
} }
void __fastcall mazingerWriteWordPalette(UINT32 sekAddress, UINT16 wordValue) static void __fastcall mazingerWriteWordPalette(UINT32 sekAddress, UINT16 wordValue)
{ {
CavePalWriteWord(sekAddress & 0xffff, wordValue); CavePalWriteWord(sekAddress & 0xffff, wordValue);
} }
UINT8 __fastcall mazingerZIn(UINT16 nAddress) static UINT8 __fastcall mazingerZIn(UINT16 nAddress)
{ {
nAddress &= 0xFF; nAddress &= 0xFF;
@ -241,7 +242,7 @@ UINT8 __fastcall mazingerZIn(UINT16 nAddress)
return 0; return 0;
} }
void __fastcall mazingerZOut(UINT16 nAddress, UINT8 nValue) static void __fastcall mazingerZOut(UINT16 nAddress, UINT8 nValue)
{ {
nAddress &= 0xFF; nAddress &= 0xFF;
@ -249,8 +250,7 @@ void __fastcall mazingerZOut(UINT16 nAddress, UINT8 nValue)
case 0x00: { case 0x00: {
DrvZ80Bank = nValue & 0x07; DrvZ80Bank = nValue & 0x07;
ZetMapArea(0x4000, 0x7FFF, 0, RomZ80 + (DrvZ80Bank * 0x4000)); ZetMapMemory(RomZ80 + (DrvZ80Bank * 0x4000), 0x4000, 0x7FFF, MAP_ROM);
ZetMapArea(0x4000, 0x7FFF, 2, RomZ80 + (DrvZ80Bank * 0x4000));
return; return;
} }
@ -293,7 +293,7 @@ void __fastcall mazingerZOut(UINT16 nAddress, UINT8 nValue)
} }
} }
UINT8 __fastcall mazingerZRead(UINT16 a) static UINT8 __fastcall mazingerZRead(UINT16 a)
{ {
switch (a) { switch (a) {
default: { default: {
@ -304,7 +304,7 @@ UINT8 __fastcall mazingerZRead(UINT16 a)
return 0; return 0;
} }
void __fastcall mazingerZWrite(UINT16 a, UINT8 d) static void __fastcall mazingerZWrite(UINT16 a, UINT8 d)
{ {
switch (a) { switch (a) {
default: { default: {
@ -338,23 +338,29 @@ static INT32 DrvExit()
return 0; return 0;
} }
static INT32 DrvDoReset() static INT32 DrvDoReset(INT32 clear_mem)
{ {
if (clear_mem) {
memset (RamStart, 0, RamEnd - RamStart);
}
SekOpen(0); SekOpen(0);
SekReset(); SekReset();
SekRun(10000); // Need to run for a bit and reset to make it start - Watchdog would force reset?
SekReset();
SekClose(); SekClose();
ZetOpen(0); ZetOpen(0);
ZetReset(); ZetReset();
BurnYM2203Reset();
ZetClose(); ZetClose();
BurnYM2203Reset();
MSM6295Reset(0); MSM6295Reset(0);
EEPROMReset(); EEPROMReset();
BurnWatchdogResetEnable();
HiscoreReset();
nVideoIRQ = 1; nVideoIRQ = 1;
nSoundIRQ = 1; nSoundIRQ = 1;
nUnknownIRQ = 1; nUnknownIRQ = 1;
@ -403,13 +409,13 @@ inline static INT32 CheckSleep(INT32)
static INT32 DrvFrame() static INT32 DrvFrame()
{ {
INT32 nCyclesVBlank; INT32 nCyclesVBlank;
INT32 nInterleave = 80; INT32 nInterleave = 80;
INT32 nCyclesSegment; INT32 nCyclesSegment;
BurnWatchdogUpdate();
if (DrvReset) { // Reset machine if (DrvReset) { // Reset machine
DrvDoReset(); DrvDoReset(1);
} }
// Compile digital inputs // Compile digital inputs
@ -615,10 +621,11 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
SCAN_VAR(DrvOkiBank1); SCAN_VAR(DrvOkiBank1);
SCAN_VAR(DrvOkiBank2); SCAN_VAR(DrvOkiBank2);
BurnWatchdogScan(nAction);
if (nAction & ACB_WRITE) { if (nAction & ACB_WRITE) {
ZetOpen(0); ZetOpen(0);
ZetMapArea(0x4000, 0x7FFF, 0, RomZ80 + (DrvZ80Bank * 0x4000)); ZetMapMemory(RomZ80 + (DrvZ80Bank * 0x4000), 0x4000, 0x7FFF, MAP_ROM);
ZetMapArea(0x4000, 0x7FFF, 2, RomZ80 + (DrvZ80Bank * 0x4000));
ZetClose(); ZetClose();
memcpy(MSM6295ROM + 0x00000, MSM6295ROMSrc + 0x20000 * DrvOkiBank1, 0x20000); memcpy(MSM6295ROM + 0x00000, MSM6295ROMSrc + 0x20000 * DrvOkiBank1, 0x20000);
@ -633,11 +640,7 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
static void DrvFMIRQHandler(INT32, INT32 nStatus) static void DrvFMIRQHandler(INT32, INT32 nStatus)
{ {
if (nStatus & 1) { ZetSetIRQLine(0, (nStatus) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
ZetSetIRQLine(0xff, CPU_IRQSTATUS_ACK);
} else {
ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
}
} }
static INT32 drvZInit() static INT32 drvZInit()
@ -650,19 +653,12 @@ static INT32 drvZInit()
ZetSetWriteHandler(mazingerZWrite); ZetSetWriteHandler(mazingerZWrite);
// ROM bank 1 // ROM bank 1
ZetMapArea (0x0000, 0x3FFF, 0, RomZ80 + 0x0000); // Direct Read from ROM ZetMapMemory(RomZ80 + 0x0000, 0x0000, 0x3FFF, MAP_ROM);
ZetMapArea (0x0000, 0x3FFF, 2, RomZ80 + 0x0000); // Direct Fetch from ROM
// ROM bank 2 // ROM bank 2
ZetMapArea (0x4000, 0x7FFF, 0, RomZ80 + 0x4000); // Direct Read from ROM ZetMapMemory(RomZ80 + 0x4000, 0x4000, 0x7FFF, MAP_ROM);
ZetMapArea (0x4000, 0x7FFF, 2, RomZ80 + 0x4000); //
// RAM // RAM
ZetMapArea (0xc000, 0xc7FF, 0, RamZ80 + 0x0000); // Direct Read from RAM ZetMapMemory(RamZ80 + 0x0000, 0xc000, 0xc7FF, MAP_RAM);
ZetMapArea (0xc000, 0xc7FF, 1, RamZ80 + 0x0000); // Direct Write to RAM ZetMapMemory(RamZ80 + 0x0800, 0xf800, 0xffFF, MAP_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); //
ZetClose(); ZetClose();
return 0; return 0;
@ -725,6 +721,8 @@ static INT32 DrvInit()
CaveTileInitLayer(0, 0x400000, 8, 0x0000); CaveTileInitLayer(0, 0x400000, 8, 0x0000);
CaveTileInitLayer(1, 0x400000, 6, 0x4400); CaveTileInitLayer(1, 0x400000, 6, 0x4400);
BurnWatchdogInit(DrvDoReset, 180 /*NOT REALLY*/);
BurnYM2203Init(1, 4000000, &DrvFMIRQHandler, 0); BurnYM2203Init(1, 4000000, &DrvFMIRQHandler, 0);
BurnTimerAttachZet(4000000); BurnTimerAttachZet(4000000);
BurnYM2203SetRoute(0, BURN_SND_YM2203_YM2203_ROUTE, 0.60, BURN_SND_ROUTE_BOTH); BurnYM2203SetRoute(0, BURN_SND_YM2203_YM2203_ROUTE, 0.60, BURN_SND_ROUTE_BOTH);
@ -737,11 +735,11 @@ static INT32 DrvInit()
MSM6295SetRoute(0, 2.00, BURN_SND_ROUTE_BOTH); MSM6295SetRoute(0, 2.00, BURN_SND_ROUTE_BOTH);
EEPROMInit(&eeprom_interface_93C46); EEPROMInit(&eeprom_interface_93C46);
if (!EEPROMAvailable()) EEPROMFill(DefEEPROM,0, 0x80); if (!EEPROMAvailable()) EEPROMFill(DefEEPROM, 0, 0x80);
bDrawScreen = true; bDrawScreen = true;
DrvDoReset(); // Reset machine DrvDoReset(1); // Reset machine
return 0; return 0;
} }
@ -793,7 +791,7 @@ struct BurnDriver BurnDrvmazinger = {
"mazinger", NULL, NULL, NULL, "1994", "mazinger", NULL, NULL, NULL, "1994",
"Mazinger Z (World, ver. 94/06/27)\0", NULL, "Banpresto / Dynamic Pl. Toei Animation", "Cave", "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, 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, NULL, mazingerRomInfo, mazingerRomName, NULL, NULL, mazingerInputInfo, NULL,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
&CaveRecalcPalette, 0x8000, 240, 384, 3, 4 &CaveRecalcPalette, 0x8000, 240, 384, 3, 4
@ -803,7 +801,7 @@ struct BurnDriver BurnDrvmazingerj = {
"mazingerj", "mazinger", NULL, NULL, "1994", "mazingerj", "mazinger", NULL, NULL, "1994",
"Mazinger Z (Japan, ver. 94/06/27)\0", NULL, "Banpresto / Dynamic Pl. Toei Animation", "Cave", "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, 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, NULL, mazingerjRomInfo, mazingerjRomName, NULL, NULL, mazingerInputInfo, NULL,
DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan,
&CaveRecalcPalette, 0x8000, 240, 384, 3, 4 &CaveRecalcPalette, 0x8000, 240, 384, 3, 4