Skip to content

Commit

Permalink
Get Nintendo Logo buffer + Game name
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Nov 14, 2023
1 parent 5fe7cfe commit 74df6a4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::format;
use std::fs::File;
use std::io::Read;
use winit::{event_loop::EventLoop, window::WindowBuilder};
Expand All @@ -17,12 +18,21 @@ fn main() -> Result<(), impl std::error::Error> {

file.read_to_end(&mut buffer).expect("Failed to read ROM!");

println!("{:#04X?}", buffer);
let nintendo_logo = &buffer[0x0104..=0x0133];

// Display Nintendo Logo

// Run checksum

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!");
println!("Starting \"{game_name}\"...");

let event_loop = EventLoop::new().unwrap();

let window = WindowBuilder::new()
.with_title("gb-rs")
.with_title(format!("gb-rs - {:}", game_name))
.with_inner_size(winit::dpi::LogicalSize::new(160, 144))
.build(&event_loop)
.unwrap();
Expand Down

0 comments on commit 74df6a4

Please sign in to comment.