diff --git a/frontends/sdl/src/main.rs b/frontends/sdl/src/main.rs index 0e7e630f4aad35dc17b04bc8e758694b54878706..d1fdf4a0c1e8f883318eadc7e23c42d08aba3c0c 100644 --- a/frontends/sdl/src/main.rs +++ b/frontends/sdl/src/main.rs @@ -474,7 +474,7 @@ fn main() { // parses the provided command line arguments and uses them to // obtain structured values let args = Args::parse(); - let mode: GameBoyMode = GameBoyMode::from_str(&args.mode); + let mode: GameBoyMode = GameBoyMode::from_string(&args.mode); // creates a new Game Boy instance and loads both the boot ROM // and the initial game ROM to "start the engine" diff --git a/src/gb.rs b/src/gb.rs index 5f8b01c3ebe7900103e51b00f6dfe9e86ee494c1..867e6b0f0cd681ed74e10e5ac36d55f47aecf715 100644 --- a/src/gb.rs +++ b/src/gb.rs @@ -66,7 +66,7 @@ impl GameBoyMode { } } - pub fn from_str(value: &str) -> GameBoyMode { + pub fn from_string(value: &str) -> GameBoyMode { match value { "dmg" => GameBoyMode::Dmg, "cgb" => GameBoyMode::Cgb, @@ -627,19 +627,25 @@ impl GameBoy { } pub fn description(&self, column_length: usize) -> String { + let version_l = format!("{:width$}", "Version", width = column_length); + let mode_l = format!("{:width$}", "Mode", width = column_length); + let clock_l = format!("{:width$}", "Clock", width = column_length); + let ram_size_l = format!("{:width$}", "RAM Size", width = column_length); + let vram_size_l = format!("{:width$}", "VRAM Size", width = column_length); + let serial_l = format!("{:width$}", "Serial", width = column_length); format!( "{} {}\n{} {}\n{} {}\n{} {}\n{} {}\n{} {}", - format!("{:width$}", "Version", width = column_length), + version_l, VERSION, - format!("{:width$}", "Mode", width = column_length), + mode_l, self.mode(), - format!("{:width$}", "Clock", width = column_length), + clock_l, self.clock_freq_s(), - format!("{:width$}", "RAM Size", width = column_length), + ram_size_l, self.ram_size(), - format!("{:width$}", "VRAM Size", width = column_length), + vram_size_l, self.vram_size(), - format!("{:width$}", "Serial", width = column_length), + serial_l, self.serial_i().device().description(), ) } diff --git a/src/rom.rs b/src/rom.rs index c9acccf5538fa5e1264da0fe17532f121218dd07..f829363271fe3c004c4f98fab7fc6f4ef46e4cc9 100644 --- a/src/rom.rs +++ b/src/rom.rs @@ -503,17 +503,22 @@ impl Cartridge { } pub fn description(&self, column_length: usize) -> String { + let name_l = format!("{:width$}", "Name", width = column_length); + let type_l = format!("{:width$}", "Type", width = column_length); + let rom_size_l = format!("{:width$}", "ROM Size", width = column_length); + let ram_size_l = format!("{:width$}", "RAM Size", width = column_length); + let cgb_l = format!("{:width$}", "CGB Mode", width = column_length); format!( "{} {}\n{} {}\n{} {}\n{} {}\n{} {}", - format!("{:width$}", "Name", width = column_length), + name_l, self.title(), - format!("{:width$}", "Type", width = column_length), + type_l, self.rom_type(), - format!("{:width$}", "ROM Size", width = column_length), + rom_size_l, self.rom_size(), - format!("{:width$}", "RAM Size", width = column_length), + ram_size_l, self.ram_size(), - format!("{:width$}", "CGB Mode", width = column_length), + cgb_l, self.cgb_flag() ) }