Compare commits

..

No commits in common. "af3be8d93d97a2e9f84aa55ad66eed605724da67" and "59e7559d775b6f434ff22fcedf8478b857a55085" have entirely different histories.

View File

@ -40,16 +40,9 @@ let keyMap = [
SDLK_s : JoypadButton.BUTTON_B
]
var timer = Date.now.addingTimeInterval(0.01666)
var frame = Frame()
let bus = Bus(rom: rom, joypad1: joypad1) { ppu in
Render.render(ppu, frame: frame)
// wait here until 16.66 ms have passed
// i would use clock_nanosleep but that isn't available cross platform
if timer.timeIntervalSinceNow > 0 {
usleep(UInt32(timer.timeIntervalSinceNow * 1000000))
}
timer.addTimeInterval(0.01666)
SDL_UpdateTexture(texture, nil, frame.data, 256 * 3)
SDL_RenderCopy(canvas, texture, nil, nil)
SDL_RenderPresent(canvas)