Core/IOS/IOS: Remove global system accessor from RAMOverrideForIOSMemoryValues()

We can allow passing in the memory instance instead of directly going for the
global system instance.
This commit is contained in:
Lioncache 2023-12-18 12:10:22 -05:00
parent a13bcd87d4
commit b8c657b06f
3 changed files with 9 additions and 10 deletions

View File

@ -592,7 +592,7 @@ bool CBoot::EmulatedBS2_Wii(Core::System& system, const Core::CPUThreadGuard& gu
return false;
// The Apploader probably just overwrote values needed for RAM Override. Run this again!
IOS::HLE::RAMOverrideForIOSMemoryValues(IOS::HLE::MemorySetupType::IOSReload);
IOS::HLE::RAMOverrideForIOSMemoryValues(memory, IOS::HLE::MemorySetupType::IOSReload);
// Warning: This call will set incorrect running game metadata if our volume parameter
// doesn't point to the same disc as the one that's inserted in the emulated disc drive!

View File

@ -140,8 +140,7 @@ static bool SetupMemory(Memory::MemoryManager& memory, u64 ios_title_id, MemoryS
memory.Write_U32(target_imv->ios_reserved_begin, ADDR_IOS_RESERVED_BEGIN);
memory.Write_U32(target_imv->ios_reserved_end, ADDR_IOS_RESERVED_END);
RAMOverrideForIOSMemoryValues(setup_type);
RAMOverrideForIOSMemoryValues(memory, setup_type);
return true;
}
@ -184,8 +183,7 @@ static bool SetupMemory(Memory::MemoryManager& memory, u64 ios_title_id, MemoryS
memory.Write_U32(target_imv->mem1_arena_end, ADDR_LEGACY_ARENA_HIGH);
memory.Write_U32(target_imv->mem1_simulated_size, ADDR_LEGACY_MEM_SIM_SIZE);
RAMOverrideForIOSMemoryValues(setup_type);
RAMOverrideForIOSMemoryValues(memory, setup_type);
return true;
}
@ -225,15 +223,12 @@ static void ReleasePPCAncast(Core::System& system)
system.GetPPCState().pc = ESPRESSO_ANCAST_LOCATION_VIRT + sizeof(EspressoAncastHeader);
}
void RAMOverrideForIOSMemoryValues(MemorySetupType setup_type)
void RAMOverrideForIOSMemoryValues(Memory::MemoryManager& memory, MemorySetupType setup_type)
{
// Don't touch anything if the feature isn't enabled.
if (!Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE))
return;
auto& system = Core::System::GetInstance();
auto& memory = system.GetMemory();
// Some unstated constants that can be inferred.
const u32 ipc_buffer_size =
memory.Read_U32(ADDR_IPC_BUFFER_END) - memory.Read_U32(ADDR_IPC_BUFFER_BEGIN);

View File

@ -23,6 +23,10 @@ namespace Core
{
class System;
}
namespace Memory
{
class MemoryManager;
}
namespace IOS::HLE
{
@ -109,7 +113,7 @@ enum class HangPPC : bool
Yes = true,
};
void RAMOverrideForIOSMemoryValues(MemorySetupType setup_type);
void RAMOverrideForIOSMemoryValues(Memory::MemoryManager& memory, MemorySetupType setup_type);
void WriteReturnValue(s32 value, u32 address);