Clippy fixes (#99)

This commit is contained in:
Logan McNaughton authored and GitHub committed 2024-12-31 22:15:39 +01:00
1 parent 2c60f6bf81
commit 415c3eca40
9 files changed
+20 -29

No files matched your search

+2 -2
View File
@@ -89,7 +89,7 @@ fn swap_rom(contents: Vec<u8>) -> Vec<u8> {
fn get_rom_contents(file_path: &std::path::Path) -> Vec<u8> {
let mut contents = vec![];
if file_path.extension().unwrap().to_ascii_lowercase() == "zip" {
if file_path.extension().unwrap().eq_ignore_ascii_case("zip") {
let zip_file = fs::File::open(file_path).unwrap();
let mut archive = zip::ZipArchive::new(zip_file).unwrap();
for i in 0..archive.len() {
@@ -106,7 +106,7 @@ fn get_rom_contents(file_path: &std::path::Path) -> Vec<u8> {
break;
}
}
} else if file_path.extension().unwrap().to_ascii_lowercase() == "7z" {
} else if file_path.extension().unwrap().eq_ignore_ascii_case("7z") {
let mut archive =
sevenz_rust::SevenZReader::open(file_path, sevenz_rust::Password::empty()).unwrap();
+1 -1
View File
@@ -159,7 +159,7 @@ pub fn af_rtc_write_block(device: &mut device::Device, block: usize, offset: usi
match device.pif.ram[block] {
0 => {
device.cart.rtc.control =
(device.pif.ram[offset + 1] as u16) << 8 | device.pif.ram[offset] as u16;
((device.pif.ram[offset + 1] as u16) << 8) | device.pif.ram[offset] as u16;
device.pif.ram[status] = 0x00;
}
1 => {
+2 -2
View File
@@ -75,7 +75,7 @@ pub fn pak_read_block(
channel: usize,
) {
let address =
(device.pif.ram[addr_acrc] as u16) << 8 | (device.pif.ram[addr_acrc + 1] & 0xe0) as u16;
((device.pif.ram[addr_acrc] as u16) << 8) | (device.pif.ram[addr_acrc + 1] & 0xe0) as u16;
let handler = device.pif.channels[channel].pak_handler;
if handler.is_some() {
@@ -94,7 +94,7 @@ pub fn pak_write_block(
channel: usize,
) {
let address =
(device.pif.ram[addr_acrc] as u16) << 8 | (device.pif.ram[addr_acrc + 1] & 0xe0) as u16;
((device.pif.ram[addr_acrc] as u16) << 8) | (device.pif.ram[addr_acrc + 1] & 0xe0) as u16;
let handler = device.pif.channels[channel].pak_handler;
if handler.is_some() {
+1 -2
View File
@@ -359,8 +359,7 @@ pub fn set_control_registers_fpu(device: &mut device::Device, index: u32, data:
device.cpu.cop1.fcr31 = data & FCR31_WRITE_MASK;
// the Cause bits are ANDed with the Enable bits to check for exceptions
// "Unimplemented Operation" has no Enable bit and always causes an exception
if (device.cpu.cop1.fcr31 & FCR31_CAUSE_MASK) >> 5
& (device.cpu.cop1.fcr31 & FCR31_ENABLE_MASK)
if ((device.cpu.cop1.fcr31 & FCR31_CAUSE_MASK) >> 5) & (device.cpu.cop1.fcr31 & FCR31_ENABLE_MASK)
!= 0
|| device.cpu.cop1.fcr31 & FCR31_CAUSE_UNIMP_BIT != 0
{
+4 -6
View File
@@ -345,13 +345,12 @@ pub fn lwl(device: &mut device::Device, opcode: u32) {
phys_address &= !3;
device.cpu.gpr[rt(opcode) as usize] = se32(
((device.cpu.gpr[rt(opcode) as usize] as u32) & mask
| device::memory::data_read(
((device.cpu.gpr[rt(opcode) as usize] as u32) & mask | (device::memory::data_read(
device,
phys_address,
device::memory::AccessSize::Word,
cached,
) << shift) as i32,
) << shift)) as i32,
)
}
@@ -430,13 +429,12 @@ pub fn lwr(device: &mut device::Device, opcode: u32) {
phys_address &= !3;
device.cpu.gpr[rt(opcode) as usize] = se32(
((device.cpu.gpr[rt(opcode) as usize] as u32) & (mask as u32)
| device::memory::data_read(
((device.cpu.gpr[rt(opcode) as usize] as u32) & (mask as u32) | (device::memory::data_read(
device,
phys_address,
device::memory::AccessSize::Word,
cached,
) >> shift) as i32,
) >> shift)) as i32,
)
}
+4 -5
View File
@@ -208,7 +208,7 @@ pub fn lw(device: &mut device::Device, opcode: u32) {
w[3] = device.rsp.mem[(address as usize + 3) & 0xFFF];
device.rsp.cpu.gpr[rt(opcode) as usize] =
(w[0] as u32) << 24 | (w[1] as u32) << 16 | (w[2] as u32) << 8 | (w[3] as u32)
((w[0] as u32) << 24) | ((w[1] as u32) << 16) | ((w[2] as u32) << 8) | (w[3] as u32)
}
pub fn lbu(device: &mut device::Device, opcode: u32) {
@@ -240,7 +240,7 @@ pub fn lwu(device: &mut device::Device, opcode: u32) {
w[3] = device.rsp.mem[(address as usize + 3) & 0xFFF];
device.rsp.cpu.gpr[rt(opcode) as usize] =
(w[0] as u32) << 24 | (w[1] as u32) << 16 | (w[2] as u32) << 8 | (w[3] as u32)
((w[0] as u32) << 24) | ((w[1] as u32) << 16) | ((w[2] as u32) << 8) | (w[3] as u32)
}
pub fn sb(device: &mut device::Device, opcode: u32) {
@@ -486,7 +486,7 @@ pub fn mfc2(device: &mut device::Device, opcode: u32) {
device.rsp.cpu.vpr[rd(opcode) as usize],
velement(opcode) + 1,
);
device.rsp.cpu.gpr[rt(opcode) as usize] = ((hi as u16) << 8 | (lo as u16)) as i16 as i32 as u32
device.rsp.cpu.gpr[rt(opcode) as usize] = (((hi as u16) << 8) | (lo as u16)) as i16 as i32 as u32
}
pub fn cfc2(device: &mut device::Device, opcode: u32) {
@@ -936,8 +936,7 @@ pub fn shv(device: &mut device::Device, opcode: u32) {
let mut offset = 0;
while offset < 8 {
let byte_val = element + offset * 2;
let value = get_vpr_byte(device.rsp.cpu.vpr[rt(opcode) as usize], byte_val) << 1
| get_vpr_byte(device.rsp.cpu.vpr[rt(opcode) as usize], byte_val + 1) >> 7;
let value = (get_vpr_byte(device.rsp.cpu.vpr[rt(opcode) as usize], byte_val) << 1) | (get_vpr_byte(device.rsp.cpu.vpr[rt(opcode) as usize], byte_val + 1) >> 7);
device.rsp.mem[((address + ((index + offset * 2) & 15) as u32) & 0xFFF) as usize] = value;
offset += 1;
}
+3 -5
View File
@@ -478,7 +478,7 @@ pub fn vmacq(device: &mut device::Device, opcode: u32) {
let mut n = 0;
while n < 8 {
let mut product =
(get_vpr_element(*acch, n) as i32) << 16 | (get_vpr_element(*accm, n) as i32);
((get_vpr_element(*acch, n) as i32) << 16) | (get_vpr_element(*accm, n) as i32);
if product < 0 && (product & (1 << 5)) == 0 {
product += 32
} else if product >= 32 && (product & (1 << 5)) == 0 {
@@ -1275,8 +1275,7 @@ pub fn vrcpl(device: &mut device::Device, opcode: u32) {
let mut result;
let vte = vte(device, vt(opcode), ve(opcode) as usize);
let input = if device.rsp.cpu.divdp {
(device.rsp.cpu.divin as i32) << 16
| get_vpr_element(device.rsp.cpu.vpr[vt(opcode) as usize], ve(opcode) as u8) as u16
((device.rsp.cpu.divin as i32) << 16) | get_vpr_element(device.rsp.cpu.vpr[vt(opcode) as usize], ve(opcode) as u8) as u16
as i32
} else {
get_vpr_element(device.rsp.cpu.vpr[vt(opcode) as usize], ve(opcode) as u8) as i16 as i32
@@ -1371,8 +1370,7 @@ pub fn vrsql(device: &mut device::Device, opcode: u32) {
let mut result;
let vte = vte(device, vt(opcode), ve(opcode) as usize);
let input = if device.rsp.cpu.divdp {
(device.rsp.cpu.divin as i32) << 16
| get_vpr_element(device.rsp.cpu.vpr[vt(opcode) as usize], ve(opcode) as u8) as u16
((device.rsp.cpu.divin as i32) << 16) | get_vpr_element(device.rsp.cpu.vpr[vt(opcode) as usize], ve(opcode) as u8) as u16
as i32
} else {
get_vpr_element(device.rsp.cpu.vpr[vt(opcode) as usize], ve(opcode) as u8) as i16 as i32
+1 -2
View File
@@ -38,8 +38,7 @@ pub fn read(device: &mut device::Device, index: u64) {
device.cpu.cop0.tlb_entries[index as usize].mask << 13;
device.cpu.cop0.regs[device::cop0::COP0_ENTRYHI_REG as usize] =
(device.cpu.cop0.tlb_entries[index as usize].region as u64) << 62
| device.cpu.cop0.tlb_entries[index as usize].vpn2 << 13
((device.cpu.cop0.tlb_entries[index as usize].region as u64) << 62) | (device.cpu.cop0.tlb_entries[index as usize].vpn2 << 13)
| (device.cpu.cop0.tlb_entries[index as usize].asid) as u64;
device.cpu.cop0.regs[device::cop0::COP0_ENTRYLO0_REG as usize] =
+2 -4
View File
@@ -23,12 +23,10 @@ pub fn play_audio(device: &mut device::Device, dram_addr: usize, length: u64) {
let mut i = 0;
while i < length as usize / 2 {
// Left channel
primary_buffer[i] = device.rdram.mem[dram_addr + (i * 2) + 2] as i16
| (device.rdram.mem[dram_addr + (i * 2) + 3] as i16) << 8;
primary_buffer[i] = device.rdram.mem[dram_addr + (i * 2) + 2] as i16 | ((device.rdram.mem[dram_addr + (i * 2) + 3] as i16) << 8);
// Right channel
primary_buffer[i + 1] = device.rdram.mem[dram_addr + (i * 2)] as i16
| (device.rdram.mem[dram_addr + (i * 2) + 1] as i16) << 8;
primary_buffer[i + 1] = device.rdram.mem[dram_addr + (i * 2)] as i16 | ((device.rdram.mem[dram_addr + (i * 2) + 1] as i16) << 8);
i += 2;
}