diff options
author | Jesse Talavera-Greenberg <jesse@jesse.tg> | 2023-12-05 09:20:57 -0500 |
---|---|---|
committer | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2023-12-08 17:19:00 +0100 |
commit | 5dac65f52e7e420e8d8a488368c7c8a7f6c6fe18 (patch) | |
tree | f9ac696c804cc27a3a0789995112d4ce8127d7d4 | |
parent | bbecab6cb01706dab18cabed24aaa7458d280b61 (diff) |
Fix some minor instances of undefined behavior
-rw-r--r-- | src/ARMJIT_Memory.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/ARMJIT_Memory.cpp b/src/ARMJIT_Memory.cpp index 101e3b1..c8969ae 100644 --- a/src/ARMJIT_Memory.cpp +++ b/src/ARMJIT_Memory.cpp @@ -1073,15 +1073,19 @@ int ARMJIT_Memory::ClassifyAddress9(u32 addr) const noexcept } else { - auto& dsi = static_cast<DSi&>(NDS); // ONLY use this if ConsoleType == 1! - if (NDS.ConsoleType == 1 && addr >= 0xFFFF0000 && !(dsi.SCFG_BIOS & (1<<1))) + if (NDS.ConsoleType == 1) { - if ((addr >= 0xFFFF8000) && (dsi.SCFG_BIOS & (1<<0))) - return memregion_Other; + auto& dsi = static_cast<DSi&>(NDS); + if (addr >= 0xFFFF0000 && !(dsi.SCFG_BIOS & (1<<1))) + { + if ((addr >= 0xFFFF8000) && (dsi.SCFG_BIOS & (1<<0))) + return memregion_Other; - return memregion_BIOS9DSi; + return memregion_BIOS9DSi; + } } - else if ((addr & 0xFFFFF000) == 0xFFFF0000) + + if ((addr & 0xFFFFF000) == 0xFFFF0000) { return memregion_BIOS9; } @@ -1093,6 +1097,7 @@ int ARMJIT_Memory::ClassifyAddress9(u32 addr) const noexcept case 0x03000000: if (NDS.ConsoleType == 1) { + auto& dsi = static_cast<DSi&>(NDS); if (addr >= dsi.NWRAMStart[0][0] && addr < dsi.NWRAMEnd[0][0]) return memregion_NewSharedWRAM_A; if (addr >= dsi.NWRAMStart[0][1] && addr < dsi.NWRAMEnd[0][1]) @@ -1118,15 +1123,19 @@ int ARMJIT_Memory::ClassifyAddress9(u32 addr) const noexcept int ARMJIT_Memory::ClassifyAddress7(u32 addr) const noexcept { - auto& dsi = static_cast<DSi&>(NDS); - if (NDS.ConsoleType == 1 && addr < 0x00010000 && !(dsi.SCFG_BIOS & (1<<9))) + if (NDS.ConsoleType == 1) { - if (addr >= 0x00008000 && dsi.SCFG_BIOS & (1<<8)) - return memregion_Other; + auto& dsi = static_cast<DSi&>(NDS); + if (addr < 0x00010000 && !(dsi.SCFG_BIOS & (1<<9))) + { + if (addr >= 0x00008000 && dsi.SCFG_BIOS & (1<<8)) + return memregion_Other; - return memregion_BIOS7DSi; + return memregion_BIOS7DSi; + } } - else if (addr < 0x00004000) + + if (addr < 0x00004000) { return memregion_BIOS7; } @@ -1140,6 +1149,7 @@ int ARMJIT_Memory::ClassifyAddress7(u32 addr) const noexcept case 0x03000000: if (NDS.ConsoleType == 1) { + auto& dsi = static_cast<DSi&>(NDS); if (addr >= dsi.NWRAMStart[1][0] && addr < dsi.NWRAMEnd[1][0]) return memregion_NewSharedWRAM_A; if (addr >= dsi.NWRAMStart[1][1] && addr < dsi.NWRAMEnd[1][1]) |