Permalink
Browse files

Proper fix for z80 cpu core

  • Loading branch information...
barbudreadmon committed Feb 18, 2017
1 parent 1b7700c commit 310d3e2a8d9eb65e2495faae28302f497266ecb2
Showing with 22 additions and 29 deletions.
  1. +1 −7 src/burn/drv/neogeo/d_neogeo.cpp
  2. +15 −3 src/cpu/z80/z80.cpp
  3. +2 −0 src/cpu/z80/z80.h
  4. +4 −18 src/cpu/z80_intf.cpp
  5. +0 −1 src/cpu/z80_intf.h
@@ -11236,13 +11236,7 @@ STD_ROM_FN(s1945p)
static INT32 s1945pInit()
{
nNeoProtectionXor = 0x05;
INT32 rc = NeoInit();
if (!rc) {
ZetEnableRunEnd();
}
return rc;
return NeoInit();
}
struct BurnDriver BurnDrvs1945p = {
View
@@ -191,6 +191,7 @@ unsigned char Z80Vector = 0xff;
#define HALT Z80.halt
int z80_ICount;
static INT32 end_run;
static Z80_Regs Z80;
UINT32 EA;
@@ -3542,6 +3543,7 @@ int Z80Execute(int cycles)
{
z80_ICount = cycles;
Z80.cycles_left = cycles;
end_run = 0;
/* check for NMIs on the way in; they can only be set externally */
/* via timers, and can't be dynamically enabled, so it is safe */
@@ -3571,13 +3573,18 @@ int Z80Execute(int cycles)
// CALL_DEBUGGER(PCD);
R++;
EXEC_INLINE(op,ROP());
} while( z80_ICount > 0 );
} while( z80_ICount > 0 && !end_run );
if (!end_run) Z80.cycles_left = 0;
Z80.cycles_left = 0;
return cycles - z80_ICount;
}
void Z80StopExecute()
{
end_run = 1;
}
INT32 z80TotalCycles()
{
return Z80.cycles_left - z80_ICount;
@@ -3693,6 +3700,11 @@ int ActiveZ80GetI()
return Z80.i;
}
int ActiveZ80GetIM()
{
return Z80.im;
}
int ActiveZ80GetPrevPC()
{
return Z80.prvpc.d;
View
@@ -67,6 +67,7 @@ void Z80GetContext (void *dst);
void Z80SetContext (void *src);
int Z80Scan(int nAction);
INT32 z80TotalCycles();
void Z80StopExecute();
extern unsigned char Z80Vector;
extern void (*z80edfe_callback)(Z80_Regs *Regs);
@@ -92,6 +93,7 @@ int ActiveZ80GetBC();
int ActiveZ80GetDE();
int ActiveZ80GetHL();
int ActiveZ80GetI();
int ActiveZ80GetIM();
int ActiveZ80GetPrevPC();
void ActiveZ80SetIRQHold();
View
@@ -28,7 +28,6 @@ static INT32 nZetCyclesTotal;
static INT32 nZ80ICount[MAX_Z80];
static UINT32 Z80EA[MAX_Z80];
static INT32 bZetRunEndEnabled = 0;
static INT32 nOpenedCPU = -1;
static INT32 nCPUCount = 0;
INT32 nHasZet = -1;
@@ -399,29 +398,14 @@ void ZetRunAdjust(INT32 /*nCycles*/)
#endif
}
void ZetEnableRunEnd()
{
#if defined FBA_DEBUG
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetEnableRunEnd called without init\n"));
#endif
// enabling this is dangerous!! breaks timers etc. see notes in ZetRunEnd() below.
// Only enable this for special cases, such as Strikers 1945 Plus. Auto-Disabled on exit.
bZetRunEndEnabled = 1;
}
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
// ZetRunEnd() re-broken March 23, 2016. breaks YM irq's in many games:
// f.ex. karnov's revenge, haunted castle, and a few others that I forgot...
if (bZetRunEndEnabled) z80_ICount = 0;
Z80StopExecute();
}
// This function will make an area callback ZetRead/ZetWrite
@@ -459,15 +443,17 @@ void ZetExit()
if (!DebugCPU_ZetInitted) bprintf(PRINT_ERROR, _T("ZetExit called without init\n"));
#endif
if (!DebugCPU_ZetInitted) return;
Z80Exit();
for (INT32 i = 0; i < MAX_Z80; i++) {
if (ZetCPUContext[i]) {
BurnFree (ZetCPUContext[i]);
ZetCPUContext[i] = NULL;
}
}
bZetRunEndEnabled = 0;
nCPUCount = 0;
nHasZet = -1;
View
@@ -42,7 +42,6 @@ INT32 ZetHL(INT32 n);
INT32 ZetI(INT32 n);
INT32 ZetScan(INT32 nAction);
INT32 ZetRun(INT32 nCycles);
void ZetEnableRunEnd();
void ZetRunEnd();
void ZetSetIRQLine(const INT32 line, const INT32 status);
void ZetSetVector(INT32 vector);

0 comments on commit 310d3e2

Please sign in to comment.