From 011f7789e040f581e3fe2d42ba7262b23132559b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 25 Feb 2021 16:18:58 +0100 Subject: [PATCH] IOS: Clear 0-0x3fff when setting up low MEM1 constants Low MEM1 is cleared by IOS before all the other constants are written. This will overwrite the Gecko code handler but it should be fine because HLE::Reload (which will set up the code handler hook again) will be called after a title change is detected. --- Source/Core/Core/IOS/IOS.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index 50b586e343..b8301b3f66 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -137,6 +137,12 @@ static bool SetupMemory(u64 ios_title_id, MemorySetupType setup_type) return true; } + // This region is typically used to store constants (e.g. game ID, console type, ...) + // and system information (see below). + constexpr u32 LOW_MEM1_REGION_START = 0; + constexpr u32 LOW_MEM1_REGION_SIZE = 0x3fff; + Memory::Memset(LOW_MEM1_REGION_START, 0, LOW_MEM1_REGION_SIZE); + Memory::Write_U32(target_imv->mem1_physical_size, ADDR_MEM1_SIZE); Memory::Write_U32(target_imv->mem1_simulated_size, ADDR_MEM1_SIM_SIZE); Memory::Write_U32(target_imv->mem1_end, ADDR_MEM1_END);