From 0d14f4c2e7e9c931dbbe393118da50654bfd2e90 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Fri, 22 Mar 2024 21:12:34 +0000 Subject: [PATCH] cargo: fmt Former-commit-id: 38a2a0b0d84bb995f4cc30696278d4883fe5b4dc Former-commit-id: 9867e49431810c5d48cb5ccbf5d18e2d01e428f3 --- arm7tdmi/src/cpu.rs | 9 ++++----- core/src/cartridge/builder.rs | 4 +++- core/src/cartridge/mod.rs | 5 ++++- core/src/gba.rs | 8 +++++--- core/src/gdb_support/gdb_thread.rs | 5 +---- core/src/iodev.rs | 16 ++++------------ core/src/sysbus.rs | 2 +- platform/rustboyadvance-sdl2/src/main.rs | 5 +++-- platform/rustboyadvance-sdl2/src/options.rs | 2 +- 9 files changed, 26 insertions(+), 30 deletions(-) diff --git a/arm7tdmi/src/cpu.rs b/arm7tdmi/src/cpu.rs index 297162c..3f4a1d8 100644 --- a/arm7tdmi/src/cpu.rs +++ b/arm7tdmi/src/cpu.rs @@ -1,10 +1,10 @@ use std::fmt; -use log::debug; -use serde::{Deserialize, Serialize}; +use ansi_term::Style; use bit::BitIndex; +use log::debug; use num::FromPrimitive; -use ansi_term::{Style}; +use serde::{Deserialize, Serialize}; use rustboyadvance_utils::{Shared, WeakPointer}; @@ -13,7 +13,6 @@ use super::reg_string; use super::{arm::ArmCond, psr::RegPSR, Addr, CpuMode, CpuState}; - use super::memory::{MemoryAccess, MemoryInterface}; use MemoryAccess::*; @@ -518,7 +517,7 @@ impl fmt::Debug for Arm7tdmiCore { let mut reg_name = reg_string(i).to_string(); reg_name.make_ascii_uppercase(); let entry = format!("\t{:-3} = 0x{:08x}", reg_name, gpr[i]); - write!( + write!( f, "{}{}", reg_normal_style.paint(entry), diff --git a/core/src/cartridge/builder.rs b/core/src/cartridge/builder.rs index a4075cd..2e369cb 100644 --- a/core/src/cartridge/builder.rs +++ b/core/src/cartridge/builder.rs @@ -222,7 +222,9 @@ fn detect_backup_type(bytes: &[u8]) -> Option { for i in 0..5 { let search = TwoWaySearcher::new(ID_STRINGS[i].as_bytes()); - if let Some(_) = search.search_in(bytes) { return Some(BackupType::from_u8(i as u8).unwrap()) } + if let Some(_) = search.search_in(bytes) { + return Some(BackupType::from_u8(i as u8).unwrap()); + } } None } diff --git a/core/src/cartridge/mod.rs b/core/src/cartridge/mod.rs index 154cbc6..70ef2a6 100644 --- a/core/src/cartridge/mod.rs +++ b/core/src/cartridge/mod.rs @@ -103,7 +103,10 @@ use super::sysbus::consts::*; pub const EEPROM_BASE_ADDR: u32 = 0x0DFF_FF00; fn is_gpio_access(addr: u32) -> bool { - matches!(addr & 0x1ff_ffff, GPIO_PORT_DATA | GPIO_PORT_DIRECTION | GPIO_PORT_CONTROL) + matches!( + addr & 0x1ff_ffff, + GPIO_PORT_DATA | GPIO_PORT_DIRECTION | GPIO_PORT_CONTROL + ) } impl BusIO for Cartridge { diff --git a/core/src/gba.rs b/core/src/gba.rs index 76731d7..3142b00 100644 --- a/core/src/gba.rs +++ b/core/src/gba.rs @@ -18,7 +18,7 @@ use super::timer::Timers; use super::sound::interface::DynAudioInterface; -use arm7tdmi::{Arm7tdmiCore}; +use arm7tdmi::Arm7tdmiCore; use rustboyadvance_utils::Shared; pub struct GameBoyAdvance { @@ -214,7 +214,8 @@ impl GameBoyAdvance { pub fn frame(&mut self) { static mut OVERSHOOT: usize = 0; unsafe { - OVERSHOOT = CYCLES_FULL_REFRESH.saturating_sub(self.run::(CYCLES_FULL_REFRESH - OVERSHOOT)); + OVERSHOOT = CYCLES_FULL_REFRESH + .saturating_sub(self.run::(CYCLES_FULL_REFRESH - OVERSHOOT)); } } @@ -222,7 +223,8 @@ impl GameBoyAdvance { fn frame_interruptible(&mut self) { static mut OVERSHOOT: usize = 0; unsafe { - OVERSHOOT = CYCLES_FULL_REFRESH.saturating_sub(self.run::(CYCLES_FULL_REFRESH - OVERSHOOT)); + OVERSHOOT = CYCLES_FULL_REFRESH + .saturating_sub(self.run::(CYCLES_FULL_REFRESH - OVERSHOOT)); } } diff --git a/core/src/gdb_support/gdb_thread.rs b/core/src/gdb_support/gdb_thread.rs index 61ff52e..2d3aa85 100644 --- a/core/src/gdb_support/gdb_thread.rs +++ b/core/src/gdb_support/gdb_thread.rs @@ -2,10 +2,7 @@ use std::sync::{Arc, Condvar, Mutex}; use arm7tdmi::{ gdb::wait_for_connection, - gdbstub::{ - conn::ConnectionExt, - stub::GdbStub, - }, + gdbstub::{conn::ConnectionExt, stub::GdbStub}, }; use crate::{GBAError, GameBoyAdvance}; diff --git a/core/src/iodev.rs b/core/src/iodev.rs index 7395df1..282a434 100644 --- a/core/src/iodev.rs +++ b/core/src/iodev.rs @@ -111,12 +111,8 @@ impl BusIO for IoDevices { REG_WIN1H => (io.gpu.win1.left as u16) << 8 | (io.gpu.win1.right as u16), REG_WIN0V => (io.gpu.win0.top as u16) << 8 | (io.gpu.win0.bottom as u16), REG_WIN1V => (io.gpu.win1.top as u16) << 8 | (io.gpu.win1.bottom as u16), - REG_WININ => { - (io.gpu.win1.flags.bits() << 8) | io.gpu.win0.flags.bits() - } - REG_WINOUT => { - (io.gpu.winobj_flags.bits() << 8) | io.gpu.winout_flags.bits() - } + REG_WININ => (io.gpu.win1.flags.bits() << 8) | io.gpu.win0.flags.bits(), + REG_WINOUT => (io.gpu.winobj_flags.bits() << 8) | io.gpu.winout_flags.bits(), REG_BLDCNT => io.gpu.bldcnt.read(), REG_BLDALPHA => io.gpu.bldalpha.read(), @@ -308,13 +304,9 @@ impl BusIO for IoDevices { fn write_8(&mut self, addr: Addr, value: u8) { match addr + IO_BASE { /* FIFO_A */ - 0x0400_00A0..=0x0400_00A3 => { - self.sound.write_fifo(0, value as i8) - } + 0x0400_00A0..=0x0400_00A3 => self.sound.write_fifo(0, value as i8), /* FIFO_B */ - 0x0400_00A4..=0x0400_00A7 => { - self.sound.write_fifo(1, value as i8) - } + 0x0400_00A4..=0x0400_00A7 => self.sound.write_fifo(1, value as i8), _ => { let t = self.read_16(addr & !1); let t = if addr & 1 != 0 { diff --git a/core/src/sysbus.rs b/core/src/sysbus.rs index 987242c..e3e4212 100644 --- a/core/src/sysbus.rs +++ b/core/src/sysbus.rs @@ -8,7 +8,7 @@ use super::cartridge::Cartridge; use super::dma::DmaNotifer; use super::iodev::{IoDevices, WaitControl}; use super::sched::*; -use arm7tdmi::{Arm7tdmiCore}; +use arm7tdmi::Arm7tdmiCore; use rustboyadvance_utils::{Shared, WeakPointer}; pub mod consts { diff --git a/platform/rustboyadvance-sdl2/src/main.rs b/platform/rustboyadvance-sdl2/src/main.rs index 806dbd2..48f55e3 100644 --- a/platform/rustboyadvance-sdl2/src/main.rs +++ b/platform/rustboyadvance-sdl2/src/main.rs @@ -42,7 +42,8 @@ fn load_bios(bios_path: &Path) -> Box<[u8]> { } fn main() -> Result<(), Box> { - fs::create_dir_all(LOG_DIR).unwrap_or_else(|_| panic!("could not create log directory ({})", LOG_DIR)); + fs::create_dir_all(LOG_DIR) + .unwrap_or_else(|_| panic!("could not create log directory ({})", LOG_DIR)); flexi_logger::Logger::with_env_or_str("info") .log_to_file() .directory(LOG_DIR) @@ -204,7 +205,7 @@ fn main() -> Result<(), Box> { } } Event::Quit { .. } => break 'running, - Event::DropFile { .. } => { + Event::DropFile { .. } => { todo!("impl DropFile again") } _ => {} diff --git a/platform/rustboyadvance-sdl2/src/options.rs b/platform/rustboyadvance-sdl2/src/options.rs index ae06bec..82339b7 100644 --- a/platform/rustboyadvance-sdl2/src/options.rs +++ b/platform/rustboyadvance-sdl2/src/options.rs @@ -1,4 +1,4 @@ -use std::{path::PathBuf}; +use std::path::PathBuf; use rustboyadvance_core::{ cartridge::{BackupType, GamepakBuilder},