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

chore: better ram path support

parent 67d95c93
No related branches found
No related tags found
1 merge request!28Support for .sav RAM files loading in SDL
Pipeline #3044 passed
...@@ -70,6 +70,7 @@ pub struct Emulator { ...@@ -70,6 +70,7 @@ pub struct Emulator {
audio: Option<Audio>, audio: Option<Audio>,
title: &'static str, title: &'static str,
rom_path: String, rom_path: String,
ram_path: String,
logic_frequency: u32, logic_frequency: u32,
visual_frequency: f32, visual_frequency: f32,
next_tick_time: f32, next_tick_time: f32,
...@@ -89,6 +90,7 @@ impl Emulator { ...@@ -89,6 +90,7 @@ impl Emulator {
audio: None, audio: None,
title: TITLE, title: TITLE,
rom_path: String::from("invalid"), rom_path: String::from("invalid"),
ram_path: String::from("invalid"),
logic_frequency: GameBoy::CPU_FREQ, logic_frequency: GameBoy::CPU_FREQ,
visual_frequency: GameBoy::VISUAL_FREQ, visual_frequency: GameBoy::VISUAL_FREQ,
next_tick_time: 0.0, next_tick_time: 0.0,
...@@ -204,7 +206,7 @@ impl Emulator { ...@@ -204,7 +206,7 @@ impl Emulator {
pub fn load_rom(&mut self, path: Option<&str>) { pub fn load_rom(&mut self, path: Option<&str>) {
let rom_path: &str = path.unwrap_or(&self.rom_path); 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( let rom = self.system.load_rom_file(
rom_path, rom_path,
if Path::new(&ram_path).exists() { if Path::new(&ram_path).exists() {
...@@ -223,6 +225,7 @@ impl Emulator { ...@@ -223,6 +225,7 @@ impl Emulator {
.unwrap(); .unwrap();
} }
self.rom_path = String::from(rom_path); self.rom_path = String::from(rom_path);
self.ram_path = ram_path;
} }
pub fn reset(&mut self) { pub fn reset(&mut self) {
......
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