From 40a7d70e68e13793a4c620c0c203ad810c4d69cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sun, 30 Jul 2023 12:26:13 +0100 Subject: [PATCH] chore: support for pending cycles --- frontends/libretro/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontends/libretro/src/lib.rs b/frontends/libretro/src/lib.rs index 5fcd455e..d07906c0 100644 --- a/frontends/libretro/src/lib.rs +++ b/frontends/libretro/src/lib.rs @@ -30,6 +30,7 @@ use crate::consts::{REGION_NTSC, RETRO_API_VERSION}; static mut EMULATOR: Option<GameBoy> = None; static mut KEY_STATES: Option<HashMap<RetroJoypad, bool>> = None; static mut FRAME_BUFFER: [u8; FRAME_BUFFER_RGB155_SIZE] = [0x00; FRAME_BUFFER_RGB155_SIZE]; +static mut PENDING_CYCLES: u32 = 0_u32; static mut ENVIRONMENT_CALLBACK: Option<extern "C" fn(u32, *const c_void) -> bool> = None; static mut VIDEO_REFRESH_CALLBACK: Option<extern "C" fn(*const u8, c_uint, c_uint, usize)> = None; @@ -220,7 +221,7 @@ pub extern "C" fn retro_run() { let mut last_frame = emulator.ppu_frame(); - let mut counter_cycles = 0_u32; + let mut counter_cycles = unsafe { PENDING_CYCLES }; let cycle_limit = (GameBoy::CPU_FREQ as f32 * emulator.multiplier() as f32 / GameBoy::VISUAL_FREQ) .round() as u32; @@ -229,7 +230,7 @@ pub extern "C" fn retro_run() { // limits the number of ticks to the typical number // of cycles expected for the current logic cycle if counter_cycles >= cycle_limit { - //pending_cycles = counter_cycles - cycle_limit; + unsafe { PENDING_CYCLES = counter_cycles - cycle_limit }; break; } -- GitLab