diff --git a/src/bus.rs b/src/bus.rs index cb49ca3..6481c90 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -73,16 +73,14 @@ impl Bus { self.timer.step(cycles); self.sound.step(cycles); } + pub(crate) fn step_dma(&mut self, pending: Cycle) { let pending_cycles: u32 = pending.into(); for _ in 0..pending_cycles { - match self.ppu.dma.clock() { - Some((src_addr, dest_addr)) => { - let byte = self.read_byte(src_addr); - self.write_byte(dest_addr, byte); - } - None => {} + if let Some((src_addr, dest_addr)) = self.ppu.dma.clock() { + let byte = self.read_byte(src_addr); + self.write_byte(dest_addr, byte); } } } diff --git a/src/cartridge.rs b/src/cartridge.rs index cf3a059..c339794 100644 --- a/src/cartridge.rs +++ b/src/cartridge.rs @@ -29,9 +29,9 @@ impl Cartridge { } fn detect_mbc(memory: &[u8]) -> Box { - let ram_size = Self::find_ram_size(&memory); - let bank_count = Self::find_bank_count(&memory); - let mbc_kind = Self::find_mbc(&memory); + let ram_size = Self::find_ram_size(memory); + let bank_count = Self::find_bank_count(memory); + let mbc_kind = Self::find_mbc(memory); let ram_byte_count = ram_size.as_byte_count(); match mbc_kind { diff --git a/src/gui.rs b/src/gui.rs index 94134ce..21c3804 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -182,8 +182,7 @@ impl Egui { ui.monospace(format!("{:#04X}", game_boy.register(Register::A))); ui.label("F"); - let flag: u8 = game_boy.register(Register::Flag).into(); - ui.monospace(format!("{:#04X}", flag)); + ui.monospace(format!("{:#04X}", game_boy.register(Register::Flag))); }); ui.horizontal(|ui| { diff --git a/src/main.rs b/src/main.rs index 267010e..a7667dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,7 @@ fn main() -> Result<()> { .expect("Failed to load ROM"); let default_title = "DMG-01 Emulator"; - let cartridge_title = game_boy.rom_title().unwrap_or(&default_title); + let cartridge_title = game_boy.rom_title().unwrap_or(default_title); // Initialize Gamepad Support let mut gilrs = Gilrs::new().expect("Failed to initialize Gilrs"); @@ -205,7 +205,7 @@ fn create_window(event_loop: &EventLoop<()>, title: &str) -> Result { .with_title(title) .with_inner_size(size) .with_min_inner_size(size) - .build(&event_loop)?) + .build(event_loop)?) } fn handle_gamepad_input(game_boy: &mut LR35902, event: GamepadEvent) { diff --git a/src/ppu/dma.rs b/src/ppu/dma.rs index 2dfdd40..3eabbb4 100644 --- a/src/ppu/dma.rs +++ b/src/ppu/dma.rs @@ -89,7 +89,7 @@ impl Default for DmaControl { impl DmaControl { pub(crate) fn update(&mut self, byte: u8, state: &mut DmaState) { - let left = (byte as u16) << 8 | 0x0000; + let left = (byte as u16) << 8; let right = (byte as u16) << 8 | 0x009F; self.repr = byte;