mirror of
https://github.com/Candygoblen123/SwiftNES.git
synced 2024-11-21 17:46:23 -06:00
Compare commits
2 Commits
59e7559d77
...
af3be8d93d
Author | SHA1 | Date | |
---|---|---|---|
|
af3be8d93d | ||
|
df8be993f7 |
@ -40,9 +40,16 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user