Skip to content
Snippets Groups Projects
Verified Commit dc24a533 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

fix: title offset calculus

parent 214ea837
No related branches found
No related tags found
No related merge requests found
Pipeline #2178 passed
...@@ -59,7 +59,7 @@ impl Emulator { ...@@ -59,7 +59,7 @@ impl Emulator {
); );
self.graphics self.graphics
.window_mut() .window_mut()
.set_title(format!("{} - {}", TITLE, rom.title()).as_str()) .set_title(format!("{} [{}]", TITLE, rom.title()).as_str())
.unwrap(); .unwrap();
} }
......
...@@ -335,12 +335,11 @@ impl Cartridge { ...@@ -335,12 +335,11 @@ impl Cartridge {
pub fn set_title_offset(&mut self) { pub fn set_title_offset(&mut self) {
let mut offset: usize = 0; let mut offset: usize = 0;
for byte in &self.rom_data[0x0134..0x0143] { for byte in &self.rom_data[0x0134..=0x0143] {
if *byte != 0u8 { if *byte == 0u8 {
offset += 1; break;
continue;
} }
break; offset += 1;
} }
self.title_offset = 0x0134 + offset; self.title_offset = 0x0134 + offset;
} }
...@@ -354,7 +353,11 @@ impl Cartridge { ...@@ -354,7 +353,11 @@ impl Cartridge {
#[cfg_attr(feature = "wasm", wasm_bindgen)] #[cfg_attr(feature = "wasm", wasm_bindgen)]
impl Cartridge { impl Cartridge {
pub fn title(&self) -> String { pub fn title(&self) -> String {
String::from(std::str::from_utf8(&self.rom_data[0x0134..self.title_offset]).unwrap()) String::from(
std::str::from_utf8(&self.rom_data[0x0134..self.title_offset])
.unwrap()
.trim(),
)
} }
pub fn rom_type(&self) -> RomType { pub fn rom_type(&self) -> RomType {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment