public void UpdateCore() { DIVTicks += CPUTicks; if (DIVTicks >= 0x40) { DIVTicks -= 0x40; memory.memory[0xFF04] = (memory.memory[0xFF04] + 1) & 0xFF; // inc DIV } long timedTicks = CPUTicks / multiplier; LCDTicks += timedTicks; lcd.ScanLine(lcd.currentScanLine); audioTicks += timedTicks; if (audioTicks >= Settings.audioGranularity) { emulatorTicks += audioTicks; if (emulatorTicks >= Settings.machineCyclesPerLoop) { if ((stopEmulator & 1) == 0) { if (screen.drewBlank == 0) { screen.DrawToCanvas(); } } stopEmulator |= 1; emulatorTicks = 0; } audioTicks = 0; } if (TIMAEnabled) { timerTicks += CPUTicks; while (timerTicks >= TACClocker) { timerTicks -= TACClocker; if (memory.memory[0xFF05] == 0xFF) { memory.memory[0xFF05] = memory.memory[0xFF06]; memory.memory[0xFF0F] |= 0x4; // set IF bit 2 } else { ++memory.memory[0xFF05]; } } } }