From 5dac65f52e7e420e8d8a488368c7c8a7f6c6fe18 Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Tue, 5 Dec 2023 09:20:57 -0500 Subject: Fix some minor instances of undefined behavior --- src/ARMJIT_Memory.cpp | 34 ++++++++++++++++++++++------------ 1 file 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(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(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(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(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(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(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]) -- cgit v1.2.3