Fix some minor instances of undefined behavior

This commit is contained in:
Jesse Talavera-Greenberg 2023-12-05 09:20:57 -05:00 committed by Nadia Holmquist Pedersen
parent bbecab6cb0
commit 5dac65f52e
1 changed files with 22 additions and 12 deletions

View File

@ -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)
{
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;
}
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
{
if (NDS.ConsoleType == 1)
{
auto& dsi = static_cast<DSi&>(NDS);
if (NDS.ConsoleType == 1 && addr < 0x00010000 && !(dsi.SCFG_BIOS & (1<<9)))
if (addr < 0x00010000 && !(dsi.SCFG_BIOS & (1<<9)))
{
if (addr >= 0x00008000 && dsi.SCFG_BIOS & (1<<8))
return memregion_Other;
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])