Skip to content
Snippets Groups Projects
Verified Commit 539564fb authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

fix: vsync issue with SDL

parent 815f08c3
No related branches found
No related tags found
No related merge requests found
Pipeline #2189 passed
......@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
* Bug with ROM title that included 0x0 characters in it
* V-Sync issue with SDL
## [0.6.7] - 2023-02-13
......
......@@ -14,7 +14,7 @@ use util::Graphics;
use crate::util::surface_from_bytes;
/// The ration at which the logic of the Game Boy is
/// The ratio at which the logic of the Game Boy is
/// going to be run, increasing this value will provide
/// better emulator accuracy, please keep in mind that
/// the PPU will keep running at the same speed.
......@@ -224,6 +224,9 @@ impl Emulator {
let mut last_frame = 0xffffu16;
if current_time >= self.next_tick_time_i {
// calculates the number of cycles that are meant to be the target
// for the current "tick" operation this is basically the number of
// cycles per LCD roundtrip divided by the logic ratio
let cycle_limit = (GameBoy::LCD_CYCLES as f32 / self.logic_ratio) as u32;
loop {
......
......@@ -44,7 +44,12 @@ impl Graphics {
// creates an accelerated canvas to be used in the drawing
// then clears it so that is can be presented empty initially
let mut canvas = window.into_canvas().accelerated().build().unwrap();
let mut canvas = window
.into_canvas()
.accelerated()
.present_vsync()
.build()
.unwrap();
canvas.set_logical_size(width, height).unwrap();
canvas.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment