mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
cz80, improve cycle accounting
This commit is contained in:
parent
e0d5c83fd3
commit
85894ad406
4 changed files with 46 additions and 45 deletions
|
@ -275,23 +275,22 @@ Cz80_Check_Interrupt:
|
||||||
if (CPU->IRQState != CLEAR_LINE)
|
if (CPU->IRQState != CLEAR_LINE)
|
||||||
{
|
{
|
||||||
CHECK_INT
|
CHECK_INT
|
||||||
|
}
|
||||||
CPU->ICount -= CPU->ExtraCycles;
|
CPU->ICount -= CPU->ExtraCycles;
|
||||||
CPU->ExtraCycles = 0;
|
CPU->ExtraCycles = 0;
|
||||||
}
|
|
||||||
if (!CPU->HaltState)
|
if (!CPU->HaltState)
|
||||||
goto Cz80_Exec;
|
goto Cz80_Exec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else CPU->ICount = 0;
|
|
||||||
|
|
||||||
Cz80_Exec_End:
|
Cz80_Exec_End:
|
||||||
CPU->PC = PC;
|
CPU->PC = PC;
|
||||||
#if CZ80_ENCRYPTED_ROM
|
#if CZ80_ENCRYPTED_ROM
|
||||||
CPU->OPBase = OPBase;
|
CPU->OPBase = OPBase;
|
||||||
#endif
|
#endif
|
||||||
if (CPU->HaltState)
|
if (!(CPU->HaltState && CPU->ICount > 0))
|
||||||
CPU->ICount = 0;
|
|
||||||
cycles -= CPU->ICount;
|
cycles -= CPU->ICount;
|
||||||
|
CPU->ICount = 0;
|
||||||
#if !CZ80_EMULATE_R_EXACTLY
|
#if !CZ80_EMULATE_R_EXACTLY
|
||||||
zR = (zR + (cycles >> 2)) & 0x7f;
|
zR = (zR + (cycles >> 2)) & 0x7f;
|
||||||
#endif
|
#endif
|
||||||
|
@ -333,6 +332,11 @@ void Cz80_Set_IRQ(cz80_struc *CPU, INT32 line, INT32 state)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CPU->ICount > 0)
|
||||||
|
{
|
||||||
|
CPU->ICount -= CPU->ExtraCycles;
|
||||||
|
CPU->ExtraCycles = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -709,13 +709,10 @@ OP_EI:
|
||||||
zR++;
|
zR++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (CPU->IRQState)
|
|
||||||
{
|
|
||||||
afterEI = 1;
|
afterEI = 1;
|
||||||
CPU->ExtraCycles += 1 - CPU->ICount;
|
CPU->ExtraCycles += 1 - CPU->ICount;
|
||||||
CPU->ICount = 1;
|
CPU->ICount = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else zIFF2 = (1 << 2);
|
else zIFF2 = (1 << 2);
|
||||||
goto Cz80_Exec_nocheck;
|
goto Cz80_Exec_nocheck;
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ extern struct DrZ80 drZ80;
|
||||||
#define z80_int_assert(a) Cz80_Set_IRQ(&CZ80, 0, (a) ? ASSERT_LINE : CLEAR_LINE)
|
#define z80_int_assert(a) Cz80_Set_IRQ(&CZ80, 0, (a) ? ASSERT_LINE : CLEAR_LINE)
|
||||||
#define z80_nmi() Cz80_Set_IRQ(&CZ80, IRQ_LINE_NMI, 0)
|
#define z80_nmi() Cz80_Set_IRQ(&CZ80, IRQ_LINE_NMI, 0)
|
||||||
|
|
||||||
#define z80_cyclesLeft CZ80.ICount
|
#define z80_cyclesLeft (CZ80.ICount - CZ80.ExtraCycles)
|
||||||
#define z80_subCLeft(c) CZ80.ICount -= c
|
#define z80_subCLeft(c) CZ80.ICount -= c
|
||||||
#define z80_pc() Cz80_Get_Reg(&CZ80, CZ80_PC)
|
#define z80_pc() Cz80_Get_Reg(&CZ80, CZ80_PC)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue