WIP emulator state

This commit is contained in:
2023-05-07 23:08:23 -05:00
parent 356a963aee
commit 8333eb13cb
4 changed files with 34 additions and 3 deletions
+14 -1
View File
@@ -218,7 +218,9 @@ fn main() {
.pick_file()
{
match emulator.rom.load(&String::from(path.to_str().unwrap())) {
Ok(_) => {},
Ok(_) => {
state.emulation.is_paused = false;
},
Err(err) => {
state.error_message.show = true;
state.error_message.message = format!(
@@ -289,6 +291,17 @@ fn main() {
}
}
// Actually run the emulation
if !state.emulation.is_paused {
// We want to keep the emulator running
// as long as we are not at the end of the frame
while !emulator.is_frame_ending {
emulator.run()
}
// Reset the flag because otherwise the emulator will never continue running
emulator.is_frame_ending = false
}
// Render emulator framebuffer
{
let tex = renderer.textures.get_mut(texture_id).unwrap();
+14
View File
@@ -77,10 +77,23 @@ impl PPUDebug {
}
}
pub struct Emulation {
pub is_paused: bool,
}
impl Emulation {
pub fn new() -> Self {
Self {
is_paused: true,
}
}
}
pub struct State {
pub debug_options: DebugOptions,
pub error_message: ErrorMessage,
pub ppudebug: PPUDebug,
pub emulation: Emulation,
}
impl State {
@@ -89,6 +102,7 @@ impl State {
debug_options: DebugOptions::new(),
error_message: ErrorMessage::new(),
ppudebug: PPUDebug::new(),
emulation: Emulation::new(),
}
}
}