From 1c5ad3999afa5591ec8fcbcadf4797514c390031 Mon Sep 17 00:00:00 2001 From: transistor Date: Sun, 7 Apr 2024 19:52:10 -0700 Subject: [PATCH] Minor fixes --- emulator/core/src/error.rs | 6 ++++++ emulator/cpus/m68k/src/moa.rs | 15 +++++++++++---- emulator/frontends/minifb/src/bin/moa-trs80.rs | 2 +- todo.txt | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/emulator/core/src/error.rs b/emulator/core/src/error.rs index ff1ea22..6cdc985 100644 --- a/emulator/core/src/error.rs +++ b/emulator/core/src/error.rs @@ -71,3 +71,9 @@ impl From> for Error { Self::Other("other".to_string()) } } + +impl From for Error { + fn from(err: fmt::Error) -> Self { + Self::Other(format!("{:?}", err)) + } +} diff --git a/emulator/cpus/m68k/src/moa.rs b/emulator/cpus/m68k/src/moa.rs index d7b4b13..e65d939 100644 --- a/emulator/cpus/m68k/src/moa.rs +++ b/emulator/cpus/m68k/src/moa.rs @@ -86,11 +86,18 @@ impl Debuggable for M68k { } } - fn print_current_step(&mut self, _system: &System) -> Result<(), Error> { + fn print_current_step(&mut self, system: &System) -> Result<(), Error> { + let mut bus = system.bus.borrow_mut(); + let mut adapter: BusAdapter = + BusAdapter::new(&mut *bus, |addr| addr as u64, |err| err); + // TODO this is called by the debugger, but should be called some other way - //let _ = self.decoder.decode_at(&mut self.bus, true, self.state.pc); - //self.decoder.dump_decoded(&mut self.bus); - //self.dump_state(); + let mut decoder = M68kDecoder::new(self.info.chip, true, self.state.pc); + decoder.decode_at(&mut adapter, &mut M68kBusPort::default(), true, self.state.pc)?; + decoder.dump_decoded(system.clock, &mut adapter); + let mut writer = String::new(); + self.dump_state(&mut writer)?; + println!("{}", writer); Ok(()) } diff --git a/emulator/frontends/minifb/src/bin/moa-trs80.rs b/emulator/frontends/minifb/src/bin/moa-trs80.rs index f5cc7a1..0b1ef3a 100644 --- a/emulator/frontends/minifb/src/bin/moa-trs80.rs +++ b/emulator/frontends/minifb/src/bin/moa-trs80.rs @@ -8,7 +8,7 @@ fn main() { Arg::new("ROM") .short('r') .long("rom") - .action(ArgAction::SetTrue) + .action(ArgAction::Set) .value_name("FILE") .help("ROM file to load at the start of memory"), ) diff --git a/todo.txt b/todo.txt index dca2502..fdaee8f 100644 --- a/todo.txt +++ b/todo.txt @@ -1,7 +1,7 @@ -* fix the Z80 dumping functions * fix the Z80 reset and bus_request signals * the emulator_hal_memory should throw an error when an access will straddle the end of memory? Or should it autowrap? +* fix the m68k dumping functions * convert computie system to use the new moa-system library crate to replace the old core crate * change package names to drop the 's', so moa-systems-computie becomes moa-system-computie