Skip to content

Commit

Permalink
boot: add ability to load game rom in memory
Browse files Browse the repository at this point in the history
  • Loading branch information
choffmann committed May 18, 2024
1 parent 7974729 commit 39d4cce
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 46 deletions.
7 changes: 6 additions & 1 deletion gameboy-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ use gameboy_lib::Gameboy;
fn main() {
println!("{}", std::env::current_dir().unwrap().display());
let boot_rom = load_boot_rom();
let mut gameboy: Gameboy = Gameboy::new(boot_rom);
let rom = load_rom("./roms/tetris.gb");
let mut gameboy: Gameboy = Gameboy::new(boot_rom, rom);
gameboy.start();
}

fn load_boot_rom() -> Vec<u8> {
return std::fs::read("./boot_roms/dmg_boot.bin").expect("Error while reading boot rom");
}

fn load_rom(file: &str) -> Vec<u8> {
return std::fs::read(file).expect("Error while reading rom");
}
2 changes: 1 addition & 1 deletion gameboy-lib/src/cpu/command/misc_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<'a> MiscCommand<'a> {
}

fn nop(&mut self) -> u16 {
self.cpu.pc.wrapping_add(0)
self.cpu.pc.wrapping_add(1)
}

fn swap(&mut self, from: &Register) -> u16 {
Expand Down
Loading

0 comments on commit 39d4cce

Please sign in to comment.