Added debug tracking support to vez.cpp and zet.cpp

This commit is contained in:
Barry Harris 2011-12-08 15:34:58 +00:00
parent f09e11801e
commit 33420a2354
2 changed files with 257 additions and 4 deletions

View File

@ -145,26 +145,51 @@ void cpu_writemem20(UINT32 a, UINT8 d)
void VezSetReadHandler(UINT8 (__fastcall *pHandler)(UINT32)) void VezSetReadHandler(UINT8 (__fastcall *pHandler)(UINT32))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezSetReadHandler called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezSetReadHandler called when no CPU open\n"));
#endif
VezCurrentCPU->ReadHandler = pHandler; VezCurrentCPU->ReadHandler = pHandler;
} }
void VezSetWriteHandler(void (__fastcall *pHandler)(UINT32, UINT8)) void VezSetWriteHandler(void (__fastcall *pHandler)(UINT32, UINT8))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezSetWriteHandler called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezSetWriteHandler called when no CPU open\n"));
#endif
VezCurrentCPU->WriteHandler = pHandler; VezCurrentCPU->WriteHandler = pHandler;
} }
void VezSetReadPort(UINT8 (__fastcall *pHandler)(UINT32)) void VezSetReadPort(UINT8 (__fastcall *pHandler)(UINT32))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezSetReadPort called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezSetReadPort called when no CPU open\n"));
#endif
VezCurrentCPU->ReadPort = pHandler; VezCurrentCPU->ReadPort = pHandler;
} }
void VezSetWritePort(void (__fastcall *pHandler)(UINT32, UINT8)) void VezSetWritePort(void (__fastcall *pHandler)(UINT32, UINT8))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezSetWritePort called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezSetWritePort called when no CPU open\n"));
#endif
VezCurrentCPU->WritePort = pHandler; VezCurrentCPU->WritePort = pHandler;
} }
void VezSetDecode(UINT8 *table) void VezSetDecode(UINT8 *table)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezSetDecode called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezSetDcode called when no CPU open\n"));
#endif
if (VezCurrentCPU->decode) { if (VezCurrentCPU->decode) {
VezCurrentCPU->decode(table); VezCurrentCPU->decode(table);
} }
@ -172,12 +197,12 @@ void VezSetDecode(UINT8 *table)
INT32 VezInit(INT32 cpu, INT32 type, INT32 clock) INT32 VezInit(INT32 cpu, INT32 type, INT32 clock)
{ {
DebugCPU_VezInitted = 1;
if (cpu >= MAX_VEZ) { if (cpu >= MAX_VEZ) {
bprintf (0, _T("Only %d Vez available! Increase MAX_VEZ in vez.cpp.\n"), MAX_VEZ); bprintf (0, _T("Only %d Vez available! Increase MAX_VEZ in vez.cpp.\n"), MAX_VEZ);
} }
nOpenedCPU = cpu;
VezCPUContext[cpu] = (VezContext*)BurnMalloc(sizeof(VezContext)); VezCPUContext[cpu] = (VezContext*)BurnMalloc(sizeof(VezContext));
VezCurrentCPU = VezCPUContext[cpu]; VezCurrentCPU = VezCPUContext[cpu];
@ -248,6 +273,10 @@ INT32 VezInit(INT32 cpu, INT32 type)
void VezExit() void VezExit()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezExit called without init\n"));
#endif
for (INT32 i = 0; i < MAX_VEZ; i++) { for (INT32 i = 0; i < MAX_VEZ; i++) {
if (VezCPUContext[i]) { if (VezCPUContext[i]) {
BurnFree(VezCPUContext[i]); BurnFree(VezCPUContext[i]);
@ -259,10 +288,18 @@ void VezExit()
nVezCount = 0; nVezCount = 0;
nOpenedCPU = -1; nOpenedCPU = -1;
DebugCPU_VezInitted = 0;
} }
void VezOpen(INT32 nCPU) void VezOpen(INT32 nCPU)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezOpen called without init\n"));
if (nCPU > nCPUCount) bprintf(PRINT_ERROR, _T("VezOpen called with invalid index %x\n"), nCPU);
if (nOpenedCPU != -1) bprintf(PRINT_ERROR, _T("VezOpen called when CPU already open with index %x\n"), nCPU);
#endif
if (nCPU >= MAX_VEZ || nCPU < 0) nCPU = 0; if (nCPU >= MAX_VEZ || nCPU < 0) nCPU = 0;
nOpenedCPU = nCPU; nOpenedCPU = nCPU;
@ -272,6 +309,11 @@ void VezOpen(INT32 nCPU)
void VezClose() void VezClose()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezClose called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezClose called when no CPU open\n"));
#endif
nOpenedCPU = -1; nOpenedCPU = -1;
VezCurrentCPU->cpu_close(); VezCurrentCPU->cpu_close();
VezCurrentCPU = 0; VezCurrentCPU = 0;
@ -279,6 +321,10 @@ void VezClose()
void VezNewFrame() void VezNewFrame()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezNewFrame called without init\n"));
#endif
// should be separated? // should be separated?
v25_new_frame(); v25_new_frame();
nec_new_frame(); nec_new_frame();
@ -286,26 +332,51 @@ void VezNewFrame()
void VezRunEnd() void VezRunEnd()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezRunEnd called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezRunEnd called when no CPU open\n"));
#endif
VezCurrentCPU->runend(); VezCurrentCPU->runend();
} }
void VezIdle(INT32 cycles) void VezIdle(INT32 cycles)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezIdle called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezIdle called when no CPU open\n"));
#endif
VezCurrentCPU->idle(cycles); VezCurrentCPU->idle(cycles);
} }
UINT32 VezTotalCycles() UINT32 VezTotalCycles()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezTotalCycles called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezTotalCycles called when no CPU open\n"));
#endif
return VezCurrentCPU->total_cycles(); return VezCurrentCPU->total_cycles();
} }
INT32 VezGetActive() INT32 VezGetActive()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezGetActive called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezGetActive called when no CPU open\n"));
#endif
return nOpenedCPU; return nOpenedCPU;
} }
INT32 VezMemCallback(INT32 nStart,INT32 nEnd,INT32 nMode) INT32 VezMemCallback(INT32 nStart,INT32 nEnd,INT32 nMode)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezMemCallback called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezMemCallback called when no CPU open\n"));
#endif
nStart >>= VEZ_MEM_SHIFT; nStart >>= VEZ_MEM_SHIFT;
nEnd += VEZ_MEM_MASK; nEnd += VEZ_MEM_MASK;
nEnd >>= VEZ_MEM_SHIFT; nEnd >>= VEZ_MEM_SHIFT;
@ -329,6 +400,11 @@ INT32 VezMemCallback(INT32 nStart,INT32 nEnd,INT32 nMode)
INT32 VezMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem) INT32 VezMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezMapArea called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezMapArea called when no CPU open\n"));
#endif
INT32 s = nStart >> VEZ_MEM_SHIFT; INT32 s = nStart >> VEZ_MEM_SHIFT;
INT32 e = (nEnd + VEZ_MEM_MASK) >> VEZ_MEM_SHIFT; INT32 e = (nEnd + VEZ_MEM_MASK) >> VEZ_MEM_SHIFT;
@ -352,6 +428,11 @@ INT32 VezMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem)
INT32 VezMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem1, UINT8 *Mem2) INT32 VezMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem1, UINT8 *Mem2)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezMapArea called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezMapArea called when no CPU open\n"));
#endif
INT32 s = nStart >> VEZ_MEM_SHIFT; INT32 s = nStart >> VEZ_MEM_SHIFT;
INT32 e = (nEnd + VEZ_MEM_MASK) >> VEZ_MEM_SHIFT; INT32 e = (nEnd + VEZ_MEM_MASK) >> VEZ_MEM_SHIFT;
@ -367,11 +448,21 @@ INT32 VezMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem1, UINT8 *Mem2
INT32 VezReset() INT32 VezReset()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezReset called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezReset called when no CPU open\n"));
#endif
return VezCurrentCPU->cpu_reset(); return VezCurrentCPU->cpu_reset();
} }
INT32 VezRun(INT32 nCycles) INT32 VezRun(INT32 nCycles)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezRun called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezRun called when no CPU open\n"));
#endif
if (nCycles <= 0) return 0; if (nCycles <= 0) return 0;
return VezCurrentCPU->cpu_execute(nCycles); return VezCurrentCPU->cpu_execute(nCycles);
@ -379,6 +470,11 @@ INT32 VezRun(INT32 nCycles)
INT32 VezPc(INT32 n) INT32 VezPc(INT32 n)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezPc called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezPc called when no CPU open\n"));
#endif
if (n == -1) { if (n == -1) {
return VezCurrentCPU->get_pc(-1); return VezCurrentCPU->get_pc(-1);
} else { } else {
@ -392,6 +488,10 @@ INT32 VezPc(INT32 n)
INT32 VezScan(INT32 nAction) INT32 VezScan(INT32 nAction)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezScan called without init\n"));
#endif
if ((nAction & ACB_DRIVER_DATA) == 0) if ((nAction & ACB_DRIVER_DATA) == 0)
return 0; return 0;
@ -407,6 +507,11 @@ INT32 VezScan(INT32 nAction)
void VezSetIRQLineAndVector(const INT32 line, const INT32 vector, const INT32 status) void VezSetIRQLineAndVector(const INT32 line, const INT32 vector, const INT32 status)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_VezInitted) bprintf(PRINT_ERROR, _T("VezSetIRQLineAndVector called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("VezSetIRQLineAndVector called when no CPU open\n"));
#endif
if (status == VEZ_IRQSTATUS_AUTO) if (status == VEZ_IRQSTATUS_AUTO)
{ {
VezCurrentCPU->cpu_set_irq_line(line, vector, VEZ_IRQSTATUS_ACK); VezCurrentCPU->cpu_set_irq_line(line, vector, VEZ_IRQSTATUS_ACK);

View File

@ -112,26 +112,50 @@ UINT8 __fastcall ZetReadOpArg(UINT32 a)
void ZetSetReadHandler(UINT8 (__fastcall *pHandler)(UINT16)) void ZetSetReadHandler(UINT8 (__fastcall *pHandler)(UINT16))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSetReadHandler called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSetReadHandler called when no CPU open\n"));
#endif
ZetCPUContext[nOpenedCPU].ZetRead = pHandler; ZetCPUContext[nOpenedCPU].ZetRead = pHandler;
} }
void ZetSetWriteHandler(void (__fastcall *pHandler)(UINT16, UINT8)) void ZetSetWriteHandler(void (__fastcall *pHandler)(UINT16, UINT8))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSetWriteHandler called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSetWriteHandler called when no CPU open\n"));
#endif
ZetCPUContext[nOpenedCPU].ZetWrite = pHandler; ZetCPUContext[nOpenedCPU].ZetWrite = pHandler;
} }
void ZetSetInHandler(UINT8 (__fastcall *pHandler)(UINT16)) void ZetSetInHandler(UINT8 (__fastcall *pHandler)(UINT16))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSetInHandler called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSetInHandler called when no CPU open\n"));
#endif
ZetCPUContext[nOpenedCPU].ZetIn = pHandler; ZetCPUContext[nOpenedCPU].ZetIn = pHandler;
} }
void ZetSetOutHandler(void (__fastcall *pHandler)(UINT16, UINT8)) void ZetSetOutHandler(void (__fastcall *pHandler)(UINT16, UINT8))
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSetOutHandler called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSetOutHandler called when no CPU open\n"));
#endif
ZetCPUContext[nOpenedCPU].ZetOut = pHandler; ZetCPUContext[nOpenedCPU].ZetOut = pHandler;
} }
void ZetNewFrame() void ZetNewFrame()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetNewFrame called without init\n"));
#endif
for (INT32 i = 0; i < nCPUCount; i++) { for (INT32 i = 0; i < nCPUCount; i++) {
nZetCyclesDone[i] = 0; nZetCyclesDone[i] = 0;
} }
@ -140,6 +164,8 @@ void ZetNewFrame()
INT32 ZetInit(INT32 nCount) INT32 ZetInit(INT32 nCount)
{ {
DebugCPU_ZetInitted = 1;
nOpenedCPU = -1; nOpenedCPU = -1;
ZetCPUContext = (struct ZetExt *) malloc(nCount * sizeof(ZetExt)); ZetCPUContext = (struct ZetExt *) malloc(nCount * sizeof(ZetExt));
@ -174,8 +200,6 @@ INT32 ZetInit(INT32 nCount)
Z80SetCPUOpReadHandler(ZetReadOp); Z80SetCPUOpReadHandler(ZetReadOp);
Z80SetCPUOpArgReadHandler(ZetReadOpArg); Z80SetCPUOpArgReadHandler(ZetReadOpArg);
ZetOpen(0);
nCPUCount = nCount % MAX_Z80; nCPUCount = nCount % MAX_Z80;
nHasZet = nCount; nHasZet = nCount;
@ -202,6 +226,11 @@ void ZetWriteByte(UINT16 address, UINT8 data)
void ZetWriteRom(UINT16 address, UINT8 data) void ZetWriteRom(UINT16 address, UINT8 data)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetWriteRom called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetWriteRom called when no CPU open\n"));
#endif
if (nOpenedCPU < 0) return; if (nOpenedCPU < 0) return;
if (ZetCPUContext[nOpenedCPU].pZetMemMap[0x200 | (address >> 8)] != NULL) { if (ZetCPUContext[nOpenedCPU].pZetMemMap[0x200 | (address >> 8)] != NULL) {
@ -217,6 +246,11 @@ void ZetWriteRom(UINT16 address, UINT8 data)
void ZetClose() void ZetClose()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetClose called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetClose called when no CPU open\n"));
#endif
Z80GetContext(&ZetCPUContext[nOpenedCPU].reg); Z80GetContext(&ZetCPUContext[nOpenedCPU].reg);
nZetCyclesDone[nOpenedCPU] = nZetCyclesTotal; nZetCyclesDone[nOpenedCPU] = nZetCyclesTotal;
nZ80ICount[nOpenedCPU] = z80_ICount; nZ80ICount[nOpenedCPU] = z80_ICount;
@ -227,6 +261,12 @@ void ZetClose()
void ZetOpen(INT32 nCPU) void ZetOpen(INT32 nCPU)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetOpen called without init\n"));
if (nCPU >= nCPUCount) bprintf(PRINT_ERROR, _T("ZetOpen called with invalid index %x\n"), nCPU);
if (nOpenedCPU != -1) bprintf(PRINT_ERROR, _T("ZetOpen called when CPU already open with index %x\n"), nCPU);
#endif
Z80SetContext(&ZetCPUContext[nCPU].reg); Z80SetContext(&ZetCPUContext[nCPU].reg);
nZetCyclesTotal = nZetCyclesDone[nCPU]; nZetCyclesTotal = nZetCyclesDone[nCPU];
z80_ICount = nZ80ICount[nCPU]; z80_ICount = nZ80ICount[nCPU];
@ -237,11 +277,21 @@ void ZetOpen(INT32 nCPU)
INT32 ZetGetActive() INT32 ZetGetActive()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetGetActive called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetGetActive called when no CPU open\n"));
#endif
return nOpenedCPU; return nOpenedCPU;
} }
INT32 ZetRun(INT32 nCycles) INT32 ZetRun(INT32 nCycles)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetRun called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetRun called when no CPU open\n"));
#endif
if (nCycles <= 0) return 0; if (nCycles <= 0) return 0;
if (ZetCPUContext[nOpenedCPU].BusReq) { if (ZetCPUContext[nOpenedCPU].BusReq) {
@ -258,15 +308,28 @@ INT32 ZetRun(INT32 nCycles)
void ZetRunAdjust(INT32 /*nCycles*/) void ZetRunAdjust(INT32 /*nCycles*/)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetRunAdjust called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetRunAdjust called when no CPU open\n"));
#endif
} }
void ZetRunEnd() void ZetRunEnd()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetRunEnd called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetRunEnd called when no CPU open\n"));
#endif
} }
// This function will make an area callback ZetRead/ZetWrite // This function will make an area callback ZetRead/ZetWrite
INT32 ZetMemCallback(INT32 nStart, INT32 nEnd, INT32 nMode) INT32 ZetMemCallback(INT32 nStart, INT32 nEnd, INT32 nMode)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetMemCallback called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetMemCallback called when no CPU open\n"));
#endif
UINT8 cStart = (nStart >> 8); UINT8 cStart = (nStart >> 8);
UINT8 **pMemMap = ZetCPUContext[nOpenedCPU].pZetMemMap; UINT8 **pMemMap = ZetCPUContext[nOpenedCPU].pZetMemMap;
@ -290,11 +353,20 @@ INT32 ZetMemCallback(INT32 nStart, INT32 nEnd, INT32 nMode)
INT32 ZetMemEnd() INT32 ZetMemEnd()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetMemEnd called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetMemEnd called when no CPU open\n"));
#endif
return 0; return 0;
} }
void ZetExit() void ZetExit()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetExit called without init\n"));
#endif
Z80Exit(); Z80Exit();
if (ZetCPUContext) { if (ZetCPUContext) {
free(ZetCPUContext); free(ZetCPUContext);
@ -303,11 +375,18 @@ void ZetExit()
nCPUCount = 0; nCPUCount = 0;
nHasZet = -1; nHasZet = -1;
DebugCPU_ZetInitted = 0;
} }
INT32 ZetMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem) INT32 ZetMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetMapArea called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetMapArea called when no CPU open\n"));
#endif
UINT8 cStart = (nStart >> 8); UINT8 cStart = (nStart >> 8);
UINT8 **pMemMap = ZetCPUContext[nOpenedCPU].pZetMemMap; UINT8 **pMemMap = ZetCPUContext[nOpenedCPU].pZetMemMap;
@ -336,6 +415,11 @@ INT32 ZetMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem)
INT32 ZetMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem01, UINT8 *Mem02) INT32 ZetMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem01, UINT8 *Mem02)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetMapArea called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetMapArea called when no CPU open\n"));
#endif
UINT8 cStart = (nStart >> 8); UINT8 cStart = (nStart >> 8);
UINT8 **pMemMap = ZetCPUContext[nOpenedCPU].pZetMemMap; UINT8 **pMemMap = ZetCPUContext[nOpenedCPU].pZetMemMap;
@ -353,6 +437,11 @@ INT32 ZetMapArea(INT32 nStart, INT32 nEnd, INT32 nMode, UINT8 *Mem01, UINT8 *Mem
INT32 ZetReset() INT32 ZetReset()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetReset called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetReset called when no CPU open\n"));
#endif
Z80Reset(); Z80Reset();
return 0; return 0;
@ -360,6 +449,11 @@ INT32 ZetReset()
INT32 ZetPc(INT32 n) INT32 ZetPc(INT32 n)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetPc called without init\n"));
if (nOpenedCPU == -1 && n < 0) bprintf(PRINT_ERROR, _T("ZetPc called when no CPU open\n"));
#endif
if (n < 0) { if (n < 0) {
return ActiveZ80GetPC(); return ActiveZ80GetPC();
} else { } else {
@ -369,6 +463,11 @@ INT32 ZetPc(INT32 n)
INT32 ZetBc(INT32 n) INT32 ZetBc(INT32 n)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetBc called without init\n"));
if (nOpenedCPU == -1 && n < 0) bprintf(PRINT_ERROR, _T("ZetBc called when no CPU open\n"));
#endif
if (n < 0) { if (n < 0) {
return ActiveZ80GetBC(); return ActiveZ80GetBC();
} else { } else {
@ -378,6 +477,11 @@ INT32 ZetBc(INT32 n)
INT32 ZetDe(INT32 n) INT32 ZetDe(INT32 n)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetDe called without init\n"));
if (nOpenedCPU == -1 && n < 0) bprintf(PRINT_ERROR, _T("ZetDe called when no CPU open\n"));
#endif
if (n < 0) { if (n < 0) {
return ActiveZ80GetDE(); return ActiveZ80GetDE();
} else { } else {
@ -387,6 +491,11 @@ INT32 ZetDe(INT32 n)
INT32 ZetHL(INT32 n) INT32 ZetHL(INT32 n)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetHL called without init\n"));
if (nOpenedCPU == -1 && n < 0) bprintf(PRINT_ERROR, _T("ZetHL called when no CPU open\n"));
#endif
if (n < 0) { if (n < 0) {
return ActiveZ80GetHL(); return ActiveZ80GetHL();
} else { } else {
@ -396,6 +505,10 @@ INT32 ZetHL(INT32 n)
INT32 ZetScan(INT32 nAction) INT32 ZetScan(INT32 nAction)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetScan called without init\n"));
#endif
if ((nAction & ACB_DRIVER_DATA) == 0) { if ((nAction & ACB_DRIVER_DATA) == 0) {
return 0; return 0;
} }
@ -418,6 +531,11 @@ INT32 ZetScan(INT32 nAction)
void ZetSetIRQLine(const INT32 line, const INT32 status) void ZetSetIRQLine(const INT32 line, const INT32 status)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSetIRQLine called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSetIRQLine called when no CPU open\n"));
#endif
switch ( status ) { switch ( status ) {
case ZET_IRQSTATUS_NONE: case ZET_IRQSTATUS_NONE:
Z80SetIrqLine(0, 0); Z80SetIrqLine(0, 0);
@ -436,11 +554,21 @@ void ZetSetIRQLine(const INT32 line, const INT32 status)
void ZetSetVector(INT32 vector) void ZetSetVector(INT32 vector)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSetVector called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSetVector called when no CPU open\n"));
#endif
Z80Vector = vector; Z80Vector = vector;
} }
INT32 ZetNmi() INT32 ZetNmi()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetNmi called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetNmi called when no CPU open\n"));
#endif
Z80SetIrqLine(Z80_INPUT_LINE_NMI, 1); Z80SetIrqLine(Z80_INPUT_LINE_NMI, 1);
Z80Execute(0); Z80Execute(0);
Z80SetIrqLine(Z80_INPUT_LINE_NMI, 0); Z80SetIrqLine(Z80_INPUT_LINE_NMI, 0);
@ -453,6 +581,11 @@ INT32 ZetNmi()
INT32 ZetIdle(INT32 nCycles) INT32 ZetIdle(INT32 nCycles)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetIdle called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetIdle called when no CPU open\n"));
#endif
nZetCyclesTotal += nCycles; nZetCyclesTotal += nCycles;
return nCycles; return nCycles;
@ -460,16 +593,31 @@ INT32 ZetIdle(INT32 nCycles)
INT32 ZetSegmentCycles() INT32 ZetSegmentCycles()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSegmentCycles called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSegmentCycles called when no CPU open\n"));
#endif
return 0; return 0;
} }
INT32 ZetTotalCycles() INT32 ZetTotalCycles()
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetTotalCycles called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetTotalCycles called when no CPU open\n"));
#endif
return nZetCyclesTotal; return nZetCyclesTotal;
} }
void ZetSetBUSREQLine(INT32 nStatus) void ZetSetBUSREQLine(INT32 nStatus)
{ {
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetSetBUSREQLine called without init\n"));
if (nOpenedCPU == -1) bprintf(PRINT_ERROR, _T("ZetSetBUSREQLine called when no CPU open\n"));
#endif
if (nOpenedCPU < 0) return; if (nOpenedCPU < 0) return;
ZetCPUContext[nOpenedCPU].BusReq = nStatus; ZetCPUContext[nOpenedCPU].BusReq = nStatus;