Fixed occasional error with debug, and modified frame swapper

This commit is contained in:
transistor 2021-12-23 19:32:15 -08:00
parent f08c4fc4a9
commit 825331df39
3 changed files with 8 additions and 3 deletions

View File

@ -92,6 +92,10 @@ impl FrameSwapper {
pub fn to_boxed(swapper: FrameSwapper) -> Box<dyn WindowUpdater> {
Box::new(swapper)
}
pub fn swap(&mut self) {
std::mem::swap(&mut self.current.lock().unwrap().bitmap, &mut self.previous.lock().unwrap().bitmap);
}
}
impl WindowUpdater for FrameSwapper {
@ -104,8 +108,6 @@ impl WindowUpdater for FrameSwapper {
}
fn update_frame(&mut self, width: u32, _height: u32, bitmap: &mut [u32]) {
std::mem::swap(&mut self.current.lock().unwrap().bitmap, &mut self.previous.lock().unwrap().bitmap);
if let Ok(frame) = self.previous.lock() {
for y in 0..frame.height {
for x in 0..frame.width {

View File

@ -652,6 +652,7 @@ impl Steppable for Ym7101 {
system.get_interrupt_controller().set(true, 6, 30)?;
}
self.swapper.swap();
let mut frame = self.swapper.current.lock().unwrap();
self.state.draw_frame(&mut frame);

View File

@ -154,7 +154,9 @@ impl System {
if self.debug_enabled.get() {
let top = self.event_queue[self.event_queue.len() - 1].device.clone();
if top.borrow_mut().as_debuggable().map(|debug| debug.debugging_enabled()).unwrap_or(false) {
self.debugger.borrow_mut().run_debugger(&self, top.clone()).unwrap();
if let Err(err) = self.debugger.borrow_mut().run_debugger(&self, top.clone()) {
println!("Error: {:?}", err);
}
}
}
}