Skip to content

Commit

Permalink
Fix crash getting game_name for CGB titles
Browse files Browse the repository at this point in the history
Will contain invalid characters, the range should be adjusted to remove these characters
  • Loading branch information
IsaacMarovitz committed May 3, 2024
1 parent 2764ecc commit e160993
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ fn main() {
file.read_to_end(&mut buffer).expect("Failed to read ROM!");

// Get game name
let name_data = &buffer[0x0134..=0x0143];
let index = name_data.iter().position(|&r| r == 0x00).unwrap();
let game_name = std::str::from_utf8(&name_data[0..index]).expect("Failed to get game name!");
let game_name = String::from_utf8_lossy(&buffer[0x0134..=0x0143]);
println!("Starting \"{}\" in {:?} Mode...", game_name, config.mode);

let panic = std::panic::take_hook();
Expand Down

0 comments on commit e160993

Please sign in to comment.