From 78a5a9790ae45698af0bd37284ebeee8505e2bcb Mon Sep 17 00:00:00 2001 From: John Breaux Date: Fri, 14 Apr 2023 16:33:54 -0500 Subject: [PATCH] Misc: clean up in preparation for merge --- justfile | 2 +- src/bin/chirp-minifb/main.rs | 34 +++++++++++++++++----------------- src/cpu/disassembler.rs | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/justfile b/justfile index aa9d205..496979f 100644 --- a/justfile +++ b/justfile @@ -14,7 +14,7 @@ debug rom: cargo run --bin chirp-minifb -- -d '{{rom}}' # Run at 2100000 instructions per frame, and output per-frame runtime statistics bench: - cargo run --bin chirp-minifb --release -- chip8Archive/roms/1dcell.ch8 -Ps10 -S21000000 -m xochip + cargo run --bin chirp-minifb --release -- chip8Archive/roms/1dcell.ch8 -Ps10 -S2100000 -m xochip flame rom: CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -F 15300 --open --bin chirp-minifb -- '{{rom}}' -s10 diff --git a/src/bin/chirp-minifb/main.rs b/src/bin/chirp-minifb/main.rs index 7038682..56f613e 100644 --- a/src/bin/chirp-minifb/main.rs +++ b/src/bin/chirp-minifb/main.rs @@ -19,6 +19,23 @@ use std::{ }; use ui::*; +pub fn main() -> Result<()> { + let options = Arguments::parse_args_default_or_exit(); + let state = State::new(options)?; + for result in state { + if let Err(e) = result { + eprintln!("{}", e.bold().red()); + break; + } + } + Ok(()) +} + +/// Parses a hexadecimal string into a u16 +fn parse_hex(value: &str) -> std::result::Result { + u16::from_str_radix(value, 16) +} + #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Options, Hash)] struct Arguments { #[options(help = "Load a ROM to run on Chirp.", required, free)] @@ -208,20 +225,3 @@ impl Iterator for State { Some(Ok(())) } } - -pub fn main() -> Result<()> { - let options = Arguments::parse_args_default_or_exit(); - let state = State::new(options)?; - for result in state { - if let Err(e) = result { - eprintln!("{}", e.bold().red()); - break; - } - } - Ok(()) -} - -/// Parses a hexadecimal string into a u16 -fn parse_hex(value: &str) -> std::result::Result { - u16::from_str_radix(value, 16) -} diff --git a/src/cpu/disassembler.rs b/src/cpu/disassembler.rs index 76c2e0b..e8b5092 100644 --- a/src/cpu/disassembler.rs +++ b/src/cpu/disassembler.rs @@ -154,7 +154,7 @@ impl Display for Insn { Insn::call { A } => write!(f, "call {A:03x}"), Insn::seb { B, x } => write!(f, "se #{B:02x}, v{x:X}"), Insn::sneb { B, x } => write!(f, "sne #{B:02x}, v{x:X}"), - Insn::se { y, x } => write!(f, "se v{x:X}, v{y:X}"), + Insn::se { y, x } => write!(f, "se v{y:X}, v{x:X}"), Insn::movb { B, x } => write!(f, "mov #{B:02x}, v{x:X}"), Insn::addb { B, x } => write!(f, "add #{B:02x}, v{x:X}"), Insn::mov { x, y } => write!(f, "mov v{y:X}, v{x:X}"), @@ -166,7 +166,7 @@ impl Display for Insn { Insn::shr { y, x } => write!(f, "shr v{y:X}, v{x:X}"), Insn::bsub { y, x } => write!(f, "bsub v{y:X}, v{x:X}"), Insn::shl { y, x } => write!(f, "shl v{y:X}, v{x:X}"), - Insn::sne { y, x } => write!(f, "sne v{x:X}, v{y:X}"), + Insn::sne { y, x } => write!(f, "sne v{y:X}, v{x:X}"), Insn::movI { A } => write!(f, "mov ${A:03x}, I"), Insn::jmpr { A } => write!(f, "jmp ${A:03x}+v0"), Insn::rand { B, x } => write!(f, "rand #{B:02x}, v{x:X}"),