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.
This commit is contained in:
Léo Lam 2017-12-06 20:26:16 +01:00
parent ecd7191b5a
commit 520039ab28
1 changed files with 7 additions and 0 deletions

View File

@ -335,6 +335,13 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
if (config.bWii) 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, // 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. // we default to IOS58, which is the version used by the Homebrew Channel.
SetupWiiMemory(); SetupWiiMemory();