Skip to content

Commit

Permalink
Boot!
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Dec 14, 2023
1 parent f4471bd commit 7656cf8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@ pub const STEP_CYCLES: u32 = (STEP_TIME as f64 / (1000_f64 / CLOCK_FREQUENCY as
#[derive(Parser)]
struct Args {
rom_path: String,
boot_rom: String
}

#[tokio::main]
async fn main() -> Result<(), impl std::error::Error> {
let args = Args::parse();
let mut file = File::open(args.rom_path).expect("No ROM found!");
let mut boot = File::open(args.boot_rom).expect("No Boot ROM found!");
let mut buffer = Vec::new();
let mut boot_rom = Vec::new();

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

let nintendo_logo = &buffer[0x0104..=0x0133];
boot.read_to_end(&mut boot_rom).expect("Failed to read Boot ROM!");

// Display Nintendo Logo

// Run checksum
buffer[0..=0x00FF].copy_from_slice(boot_rom.as_slice());

// Get game name
let name_data = &buffer[0x0134..=0x0143];
Expand Down
4 changes: 3 additions & 1 deletion src/mmu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ impl MMU {

pub fn write(&mut self, a: u16, v: u8) {
match a {
0x0000..=0x7FFF => self.rom[a as usize] = v,
// TODO: MBC
0x0000..=0x7FFF => {}
0x8000..=0x9FFF => self.ppu.write(a, v),
// TODO: MBC
0xA000..=0xBFFF => {}
Expand All @@ -94,6 +95,7 @@ impl MMU {
// TODO: APU
0xFF10..=0xFF3F => {},
0xFF0F => self.intf = Interrupts::from_bits(v).unwrap(),
0xFF50 => {},
0xFF70 => self.wram_bank = match v & 0x07 { 0 => 1, n => n as usize },
0xFFFF => self.inte = Interrupts::from_bits_truncate(v),
_ => panic!("Write to unsupported address ({:#06x})!", a),
Expand Down
1 change: 1 addition & 0 deletions src/ppu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ impl PPU {
0xFF49 => self.op1,
0xFF4A => self.wy,
0xFF4B => self.wx,
0xFF4D => 0x00,
0xFF4F => 0xFE | self.ram_bank as u8,
_ => panic!("Read to unsupported PPU address ({:#06x})!", a),
}
Expand Down
2 changes: 1 addition & 1 deletion src/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Registers {
e: 0xD8,
h: 0x01,
l: 0x4D,
pc: 0x0100,
pc: 0x0000,
sp: 0xFFFE
}
},
Expand Down

0 comments on commit 7656cf8

Please sign in to comment.