From 520039ab2899c85eba30edd9ca83e50fd2b04219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 6 Dec 2017 20:26:16 +0100 Subject: [PATCH] Boot: Use values from libogc for booting Wii homebrew Set HID0, HID4, GPR1 to values that are used by libogc for initialisation. This makes boots more similar to a launch from the HBC or another loader, since normally the registers have already been initialised by the loader. This fixes a crash in homebrew that assume GPR1 points to a correct location and attempt to use it before initialising registers. --- Source/Core/Core/Boot/Boot.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 0c8f12c045..96baaa9e05 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -335,6 +335,13 @@ bool CBoot::BootUp(std::unique_ptr boot) if (config.bWii) { + PowerPC::ppcState.spr[SPR_HID0] = 0x0011c464; + PowerPC::ppcState.spr[SPR_HID4] = 0x82000000; + + // Set a value for the SP. It doesn't matter where this points to, + // as long as it is a valid location. This value is taken from a homebrew binary. + PowerPC::ppcState.gpr[1] = 0x8004d4bc; + // Because there is no TMD to get the requested system (IOS) version from, // we default to IOS58, which is the version used by the Homebrew Channel. SetupWiiMemory();