mirror of
https://github.com/FranLMSP/snes.git
synced 2026-08-03 08:30:01 -04:00
Restart emulation as soon as a ROM is loaded
This commit is contained in:
@@ -34,9 +34,14 @@ impl Emulator {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
pub fn reset_vector(&mut self) {
|
||||
self.cpu.reset_vector(&mut self.bus);
|
||||
}
|
||||
|
||||
pub fn hard_reset(&mut self) {
|
||||
self.cpu = CPU::new();
|
||||
self.bus = Bus::new();
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Emulator {
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn build_cpu_debug_controls(ctx: &egui::Context, cpu_debug_options: &mut CPU
|
||||
ui.monospace("Vectors:");
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Reset").clicked() {
|
||||
emulator.reset();
|
||||
emulator.reset_vector();
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
|
||||
@@ -11,9 +11,15 @@ pub fn build_menu_bar(emulator: &mut Emulator, ui: &mut egui::Ui, state: &mut Ap
|
||||
if let Some(path) = rfd::FileDialog::new().pick_file() {
|
||||
let picked_path = path.display().to_string();
|
||||
match emulator.bus.rom.load(&picked_path) {
|
||||
Ok(_) => println!("Loaded ROM"),
|
||||
Ok(_) => {
|
||||
emulator.hard_reset();
|
||||
state.emulation_state.is_paused = false;
|
||||
state.emulation_state.one_tick_per_frame = false;
|
||||
emulator.reset_vector();
|
||||
println!("Loaded ROM");
|
||||
},
|
||||
Err(err) => println!("Error loading the ROM: {}", err),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user