Fix cycle counting in CPU.

This commit is contained in:
Christian Speckner 2018-05-22 00:18:07 +02:00
parent ed6eae6a67
commit ae0faaabfc
1 changed files with 5 additions and 2 deletions

View File

@ -240,12 +240,13 @@ inline bool M6502::_execute(uInt32 cycles)
M6532& riot = mySystem->m6532();
#endif
uInt32 currentCycles = 0;
uInt64 previousCycles = mySystem->cycles();
uInt64 currentCycles = 0;
// Loop until execution is stopped or a fatal error occurs
for(;;)
{
for(; !myExecutionStatus && (currentCycles < cycles * SYSTEM_CYCLES_PER_CPU); currentCycles += SYSTEM_CYCLES_PER_CPU)
while (!myExecutionStatus && currentCycles < cycles * SYSTEM_CYCLES_PER_CPU)
{
#ifdef DEBUGGER_SUPPORT
if(myJustHitReadTrapFlag || myJustHitWriteTrapFlag)
@ -297,6 +298,8 @@ inline bool M6502::_execute(uInt32 cycles)
myExecutionStatus |= FatalErrorBit;
}
currentCycles = (mySystem->cycles() - previousCycles);
#ifdef DEBUGGER_SUPPORT
if(myStepStateByInstruction)
{