if (CPU->IRQState != CLEAR_LINE)\r
{\r
CHECK_INT\r
- CPU->ICount -= CPU->ExtraCycles;\r
- CPU->ExtraCycles = 0;\r
}\r
+ CPU->ICount -= CPU->ExtraCycles;\r
+ CPU->ExtraCycles = 0;\r
if (!CPU->HaltState)\r
goto Cz80_Exec;\r
}\r
}\r
- else CPU->ICount = 0;\r
\r
Cz80_Exec_End:\r
CPU->PC = PC;\r
#if CZ80_ENCRYPTED_ROM\r
CPU->OPBase = OPBase;\r
#endif\r
- if (CPU->HaltState)\r
- CPU->ICount = 0;\r
- cycles -= CPU->ICount;\r
+ if (!(CPU->HaltState && CPU->ICount > 0))\r
+ cycles -= CPU->ICount;\r
+ CPU->ICount = 0;\r
#if !CZ80_EMULATE_R_EXACTLY\r
zR = (zR + (cycles >> 2)) & 0x7f;\r
#endif\r
#endif\r
}\r
}\r
+ if (CPU->ICount > 0)\r
+ {\r
+ CPU->ICount -= CPU->ExtraCycles;\r
+ CPU->ExtraCycles = 0;\r
+ }\r
}\r
\r
\r
zR++;\r
#endif\r
}\r
- if (CPU->IRQState)\r
- {\r
- afterEI = 1;\r
- CPU->ExtraCycles += 1 - CPU->ICount;\r
- CPU->ICount = 1;\r
- }\r
+ afterEI = 1;\r
+ CPU->ExtraCycles += 1 - CPU->ICount;\r
+ CPU->ICount = 1;\r
}\r
else zIFF2 = (1 << 2);\r
goto Cz80_Exec_nocheck;\r
#define IN(A) CPU->IN_Port(A)\r
#define OUT(A, D) CPU->OUT_Port(A, D)\r
\r
-#define CHECK_INT \\r
- if (zIFF1) \\r
- { \\r
- UINT32 IntVect; \\r
- \\r
- if (CPU->IRQState == HOLD_LINE) \\r
- CPU->IRQState = CLEAR_LINE; \\r
- \\r
- CPU->HaltState = 0; \\r
- zIFF1 = zIFF2 = 0; \\r
- IntVect = CPU->Interrupt_Callback(CPU->IRQLine); \\r
- \\r
- PUSH_16(zRealPC) \\r
- \\r
- if (zIM == 2) \\r
- { \\r
- IntVect = (IntVect & 0xff) | (zI << 8); \\r
- PC = READ_MEM16(IntVect); \\r
- CPU->ExtraCycles += 17; \\r
- } \\r
- else if (zIM == 1) \\r
- { \\r
- PC = 0x38; \\r
- CPU->ExtraCycles += 13; \\r
- } \\r
- else \\r
- { \\r
- PC = IntVect & 0x38; \\r
- CPU->ExtraCycles += 13; \\r
- } \\r
- \\r
- SET_PC(PC) \\r
+#define CHECK_INT \\r
+ if (zIFF1) \\r
+ { \\r
+ UINT32 IntVect; \\r
+ \\r
+ if (CPU->IRQState == HOLD_LINE) \\r
+ CPU->IRQState = CLEAR_LINE; \\r
+ \\r
+ CPU->HaltState = 0; \\r
+ zIFF1 = zIFF2 = 0; \\r
+ IntVect = CPU->Interrupt_Callback(CPU->IRQLine); \\r
+ \\r
+ PUSH_16(zRealPC) \\r
+ \\r
+ if (zIM == 2) \\r
+ { \\r
+ IntVect = (IntVect & 0xff) | (zI << 8); \\r
+ PC = READ_MEM16(IntVect); \\r
+ CPU->ExtraCycles += 17; \\r
+ } \\r
+ else if (zIM == 1) \\r
+ { \\r
+ PC = 0x38; \\r
+ CPU->ExtraCycles += 13; \\r
+ } \\r
+ else \\r
+ { \\r
+ PC = IntVect & 0x38; \\r
+ CPU->ExtraCycles += 13; \\r
+ } \\r
+ \\r
+ SET_PC(PC) \\r
}\r
#define z80_int_assert(a) Cz80_Set_IRQ(&CZ80, 0, (a) ? ASSERT_LINE : CLEAR_LINE)\r
#define z80_nmi() Cz80_Set_IRQ(&CZ80, IRQ_LINE_NMI, 0)\r
\r
-#define z80_cyclesLeft CZ80.ICount\r
+#define z80_cyclesLeft (CZ80.ICount - CZ80.ExtraCycles)\r
#define z80_subCLeft(c) CZ80.ICount -= c\r
#define z80_pc() Cz80_Get_Reg(&CZ80, CZ80_PC)\r
\r