private void ExecuteStep() { long op = 0; while (stopEmulator == 0) { op = memory.Read(cpu.programCounter); if (!skipPCIncrement) { cpu.programCounter = (cpu.programCounter + 1) & 0xFFFF; } skipPCIncrement = false; CPUTicks = TICKTables.primary[op]; //Debug.Log(op + " " + CPUTicks + " " + programCounter); MainVM.Execute(this, op); switch (untilEnable) { case 1: IME = true; untilEnable--; break; case 2: untilEnable--; break; } if (IME) { RunInterrupt(); } UpdateCore(); } }
public void Run() { try { if ((stopEmulator & 2) == 0) { if ((stopEmulator & 1) == 1) { stopEmulator = 0; clock.Update(); if (!halt) { ExecuteStep(); } else { CPUTicks = 1; MainVM.Execute(this, 0x76); RunInterrupt(); UpdateCore(); ExecuteStep(); } } else { throw new Exception("restarted core"); } } } catch (Exception e) { if (e.Message != "HALT_OVERRUN") { Debug.LogError(e.Message + " " + e.StackTrace); } } }