public void ExecuteFrame() { while (CyclesCount < CPU_CYCLES) { int cycles = Cpu.ExecuteCycle(); int divisorAmount = Cpu.DoubleSpeed ? 2 : 1; int dmaCycles = Dma.CopyData(); cycles *= 4; Timer.Tick(cycles + dmaCycles); Input.Tick(); Ppu.Tick((cycles + dmaCycles) / divisorAmount); Apu.Tick((cycles + dmaCycles) / divisorAmount); CyclesCount += cycles / divisorAmount; } CyclesCount -= CPU_CYCLES; }