diff --git a/src/device/cop1.rs b/src/device/cop1.rs index 1441674..98e007a 100644 --- a/src/device/cop1.rs +++ b/src/device/cop1.rs @@ -359,7 +359,8 @@ 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 { diff --git a/src/device/cpu_instructions.rs b/src/device/cpu_instructions.rs index 1dad9e8..57b608d 100644 --- a/src/device/cpu_instructions.rs +++ b/src/device/cpu_instructions.rs @@ -345,7 +345,8 @@ 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, @@ -429,7 +430,8 @@ 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, diff --git a/src/device/rdram.rs b/src/device/rdram.rs index 77685d1..df8ed5c 100644 --- a/src/device/rdram.rs +++ b/src/device/rdram.rs @@ -82,5 +82,5 @@ pub fn init(device: &mut device::Device) -> (*mut u8, usize) { } pub fn rdram_calculate_cycles(length: u64) -> u64 { - 31 + (length / 3)// https://hcs64.com/dma.html, https://github.com/rasky/n64-systembench + 31 + (length / 3) // https://hcs64.com/dma.html, https://github.com/rasky/n64-systembench } diff --git a/src/device/rsp_su_instructions.rs b/src/device/rsp_su_instructions.rs index 9a31ab8..64b95e2 100644 --- a/src/device/rsp_su_instructions.rs +++ b/src/device/rsp_su_instructions.rs @@ -486,7 +486,8 @@ 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,7 +937,8 @@ 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; } diff --git a/src/device/rsp_vu_instructions.rs b/src/device/rsp_vu_instructions.rs index ee51a96..214456c 100644 --- a/src/device/rsp_vu_instructions.rs +++ b/src/device/rsp_vu_instructions.rs @@ -1275,7 +1275,8 @@ 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 @@ -1370,7 +1371,8 @@ 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 diff --git a/src/device/tlb.rs b/src/device/tlb.rs index b6bb9e9..d32bfbb 100644 --- a/src/device/tlb.rs +++ b/src/device/tlb.rs @@ -38,7 +38,8 @@ 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] = @@ -135,7 +136,8 @@ pub fn probe(device: &mut device::Device) { if e.region != (device.cpu.cop0.regs[device::cop0::COP0_ENTRYHI_REG as usize] >> 62) as u8 { continue; } - if e.g == 0 && e.asid != device.cpu.cop0.regs[device::cop0::COP0_ENTRYHI_REG as usize] as u8 { + if e.g == 0 && e.asid != device.cpu.cop0.regs[device::cop0::COP0_ENTRYHI_REG as usize] as u8 + { continue; } device.cpu.cop0.regs[device::cop0::COP0_INDEX_REG as usize] = pos as u64; @@ -184,8 +186,11 @@ pub fn tlb_unmap(device: &mut device::Device, index: u64) { pub fn tlb_map(device: &mut device::Device, index: u64) { let e = &mut device.cpu.cop0.tlb_entries[index as usize]; - if e.v_even != 0 && e.start_even < e.end_even - && !(e.start_even >= 0x80000000 && e.end_even < 0xC0000000) && e.phys_even < 0x20000000 { + if e.v_even != 0 + && e.start_even < e.end_even + && !(e.start_even >= 0x80000000 && e.end_even < 0xC0000000) + && e.phys_even < 0x20000000 + { let mut i = e.start_even; while i < e.end_even { device.cpu.cop0.tlb_lut_r[(i >> 12) as usize].address = @@ -204,8 +209,11 @@ pub fn tlb_map(device: &mut device::Device, index: u64) { } } - if e.v_odd != 0 && e.start_odd < e.end_odd - && !(e.start_odd >= 0x80000000 && e.end_odd < 0xC0000000) && e.phys_odd < 0x20000000 { + if e.v_odd != 0 + && e.start_odd < e.end_odd + && !(e.start_odd >= 0x80000000 && e.end_odd < 0xC0000000) + && e.phys_odd < 0x20000000 + { let mut i = e.start_odd; while i < e.end_odd { device.cpu.cop0.tlb_lut_r[(i >> 12) as usize].address = diff --git a/src/ui/audio.rs b/src/ui/audio.rs index a48da04..96153b8 100644 --- a/src/ui/audio.rs +++ b/src/ui/audio.rs @@ -23,10 +23,12 @@ 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; } diff --git a/src/ui/video.rs b/src/ui/video.rs index 30b1211..e4df252 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -30,7 +30,7 @@ pub fn init(ui: &mut ui::Ui, rdram_ptr: *mut u8, rdram_size: usize, fullscreen: pub fn update_screen() -> u8 { // when the window is closed, running is set to 0 - + unsafe { rdp_update_screen() } } @@ -41,7 +41,6 @@ pub fn set_register(reg: u32, value: u32) { } pub fn process_rdp_list(dpc_regs: &mut [u32; 8], sp_dmem: &mut [u8; 8192]) -> u64 { - unsafe { rdp_process_commands(dpc_regs, sp_dmem) } }