fix: apply clippy suggestions

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-06-06 21:30:08 -05:00
parent c428e934d8
commit d623800005
5 changed files with 11 additions and 14 deletions

View File

@ -73,16 +73,14 @@ impl Bus {
self.timer.step(cycles); self.timer.step(cycles);
self.sound.step(cycles); self.sound.step(cycles);
} }
pub(crate) fn step_dma(&mut self, pending: Cycle) { pub(crate) fn step_dma(&mut self, pending: Cycle) {
let pending_cycles: u32 = pending.into(); let pending_cycles: u32 = pending.into();
for _ in 0..pending_cycles { for _ in 0..pending_cycles {
match self.ppu.dma.clock() { if let Some((src_addr, dest_addr)) = self.ppu.dma.clock() {
Some((src_addr, dest_addr)) => { let byte = self.read_byte(src_addr);
let byte = self.read_byte(src_addr); self.write_byte(dest_addr, byte);
self.write_byte(dest_addr, byte);
}
None => {}
} }
} }
} }

View File

@ -29,9 +29,9 @@ impl Cartridge {
} }
fn detect_mbc(memory: &[u8]) -> Box<dyn MemoryBankController> { fn detect_mbc(memory: &[u8]) -> Box<dyn MemoryBankController> {
let ram_size = Self::find_ram_size(&memory); let ram_size = Self::find_ram_size(memory);
let bank_count = Self::find_bank_count(&memory); let bank_count = Self::find_bank_count(memory);
let mbc_kind = Self::find_mbc(&memory); let mbc_kind = Self::find_mbc(memory);
let ram_byte_count = ram_size.as_byte_count(); let ram_byte_count = ram_size.as_byte_count();
match mbc_kind { match mbc_kind {

View File

@ -182,8 +182,7 @@ impl Egui {
ui.monospace(format!("{:#04X}", game_boy.register(Register::A))); ui.monospace(format!("{:#04X}", game_boy.register(Register::A)));
ui.label("F"); ui.label("F");
let flag: u8 = game_boy.register(Register::Flag).into(); ui.monospace(format!("{:#04X}", game_boy.register(Register::Flag)));
ui.monospace(format!("{:#04X}", flag));
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {

View File

@ -67,7 +67,7 @@ fn main() -> Result<()> {
.expect("Failed to load ROM"); .expect("Failed to load ROM");
let default_title = "DMG-01 Emulator"; 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 // Initialize Gamepad Support
let mut gilrs = Gilrs::new().expect("Failed to initialize Gilrs"); let mut gilrs = Gilrs::new().expect("Failed to initialize Gilrs");
@ -205,7 +205,7 @@ fn create_window(event_loop: &EventLoop<()>, title: &str) -> Result<Window> {
.with_title(title) .with_title(title)
.with_inner_size(size) .with_inner_size(size)
.with_min_inner_size(size) .with_min_inner_size(size)
.build(&event_loop)?) .build(event_loop)?)
} }
fn handle_gamepad_input(game_boy: &mut LR35902, event: GamepadEvent) { fn handle_gamepad_input(game_boy: &mut LR35902, event: GamepadEvent) {

View File

@ -89,7 +89,7 @@ impl Default for DmaControl {
impl DmaControl { impl DmaControl {
pub(crate) fn update(&mut self, byte: u8, state: &mut DmaState) { 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; let right = (byte as u16) << 8 | 0x009F;
self.repr = byte; self.repr = byte;