From f814eac4d6e52be25b76bda85a78d99f4fc6f951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sun, 23 Jul 2023 23:00:00 +0100 Subject: [PATCH] chore: better ram path support --- frontends/sdl/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontends/sdl/src/main.rs b/frontends/sdl/src/main.rs index 2fcab56b..8a103653 100644 --- a/frontends/sdl/src/main.rs +++ b/frontends/sdl/src/main.rs @@ -70,6 +70,7 @@ pub struct Emulator { audio: Option<Audio>, title: &'static str, rom_path: String, + ram_path: String, logic_frequency: u32, visual_frequency: f32, next_tick_time: f32, @@ -89,6 +90,7 @@ impl Emulator { audio: None, title: TITLE, rom_path: String::from("invalid"), + ram_path: String::from("invalid"), logic_frequency: GameBoy::CPU_FREQ, visual_frequency: GameBoy::VISUAL_FREQ, next_tick_time: 0.0, @@ -204,7 +206,7 @@ impl Emulator { pub fn load_rom(&mut self, path: Option<&str>) { let rom_path: &str = path.unwrap_or(&self.rom_path); - let ram_path = replace_ext(rom_path, "sav").unwrap_or("".to_string()); + let ram_path = replace_ext(rom_path, "sav").unwrap_or("invalid".to_string()); let rom = self.system.load_rom_file( rom_path, if Path::new(&ram_path).exists() { @@ -223,6 +225,7 @@ impl Emulator { .unwrap(); } self.rom_path = String::from(rom_path); + self.ram_path = ram_path; } pub fn reset(&mut self) { -- GitLab