mirror of
https://github.com/Candygoblen123/SwiftNES.git
synced 2024-11-09 14:36:24 -06:00
Compare commits
No commits in common. "af3be8d93d97a2e9f84aa55ad66eed605724da67" and "59e7559d775b6f434ff22fcedf8478b857a55085" have entirely different histories.
af3be8d93d
...
59e7559d77
@ -40,16 +40,9 @@ let keyMap = [
|
|||||||
SDLK_s : JoypadButton.BUTTON_B
|
SDLK_s : JoypadButton.BUTTON_B
|
||||||
]
|
]
|
||||||
|
|
||||||
var timer = Date.now.addingTimeInterval(0.01666)
|
|
||||||
var frame = Frame()
|
var frame = Frame()
|
||||||
let bus = Bus(rom: rom, joypad1: joypad1) { ppu in
|
let bus = Bus(rom: rom, joypad1: joypad1) { ppu in
|
||||||
Render.render(ppu, frame: frame)
|
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_UpdateTexture(texture, nil, frame.data, 256 * 3)
|
||||||
SDL_RenderCopy(canvas, texture, nil, nil)
|
SDL_RenderCopy(canvas, texture, nil, nil)
|
||||||
SDL_RenderPresent(canvas)
|
SDL_RenderPresent(canvas)
|
||||||
|
Loading…
Reference in New Issue
Block a user