From 5989a1a49fc82160d85f5e4d7a950b83904b80b0 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Sun, 12 Feb 2023 17:21:24 +1100 Subject: [PATCH] title name w/mbc is more descriptive --- src/main.rs | 2 +- src/processor/memory/rom.rs | 2 +- src/processor/memory/rom/mbcs.rs | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index ac7e107..57d8630 100644 --- a/src/main.rs +++ b/src/main.rs @@ -99,7 +99,7 @@ fn main() { }; let mut window = Window::new( - format!("{} on MBC: {}", rom.get_title(), rom.mbc_type()).as_str(), + format!("{} on {}", rom.get_title(), rom.mbc_type()).as_str(), WIDTH * FACTOR, HEIGHT * FACTOR, WindowOptions::default(), diff --git a/src/processor/memory/rom.rs b/src/processor/memory/rom.rs index 5a76cb6..6de87ef 100644 --- a/src/processor/memory/rom.rs +++ b/src/processor/memory/rom.rs @@ -57,7 +57,7 @@ impl Rom { self.mbc.set_ram(address, data); } - pub fn mbc_type(&self) -> &str { + pub fn mbc_type(&self) -> String { self.mbc.mbc_type() } } diff --git a/src/processor/memory/rom/mbcs.rs b/src/processor/memory/rom/mbcs.rs index 07399fb..2b22087 100644 --- a/src/processor/memory/rom/mbcs.rs +++ b/src/processor/memory/rom/mbcs.rs @@ -5,7 +5,7 @@ pub(super) trait Mbc { fn get_ram(&self, address: Address) -> u8; fn set(&mut self, address: Address, data: u8); fn set_ram(&mut self, address: Address, data: u8); - fn mbc_type(&self) -> &str; + fn mbc_type(&self) -> String; } pub(super) struct None { @@ -31,8 +31,8 @@ impl Mbc for None { fn set(&mut self, _address: Address, _data: u8) {} - fn mbc_type(&self) -> &str { - "None" + fn mbc_type(&self) -> String { + String::from("None") } } @@ -155,8 +155,12 @@ impl Mbc for Mbc1 { } } - fn mbc_type(&self) -> &str { - "MBC1" + fn mbc_type(&self) -> String { + if let Some(ram) = &self.ram { + format!("{}KB MBC1 with {}KB RAM", self.rom_len / KB, ram.len() / KB) + } else { + format!("{}KB MBC1", self.rom_len / KB) + } } }