Boot: Avoid ppcState global.

This commit is contained in:
Admiral H. Curtiss
2023-01-10 04:22:04 +01:00
parent 51e7980d95
commit 94455ee9e1
3 changed files with 111 additions and 94 deletions

View File

@ -458,22 +458,23 @@ bool CBoot::Load_BS2(Core::System& system, const std::string& boot_rom_filename)
memory.CopyToEmu(0x01200000, data.data() + 0x100, 0x700);
memory.CopyToEmu(0x01300000, data.data() + 0x820, 0x1AFE00);
PowerPC::ppcState.gpr[3] = 0xfff0001f;
PowerPC::ppcState.gpr[4] = 0x00002030;
PowerPC::ppcState.gpr[5] = 0x0000009c;
auto& ppc_state = system.GetPPCState();
ppc_state.gpr[3] = 0xfff0001f;
ppc_state.gpr[4] = 0x00002030;
ppc_state.gpr[5] = 0x0000009c;
PowerPC::ppcState.msr.FP = 1;
PowerPC::ppcState.msr.DR = 1;
PowerPC::ppcState.msr.IR = 1;
ppc_state.msr.FP = 1;
ppc_state.msr.DR = 1;
ppc_state.msr.IR = 1;
PowerPC::ppcState.spr[SPR_HID0] = 0x0011c464;
PowerPC::ppcState.spr[SPR_IBAT3U] = 0xfff0001f;
PowerPC::ppcState.spr[SPR_IBAT3L] = 0xfff00001;
PowerPC::ppcState.spr[SPR_DBAT3U] = 0xfff0001f;
PowerPC::ppcState.spr[SPR_DBAT3L] = 0xfff00001;
SetupBAT(/*is_wii*/ false);
ppc_state.spr[SPR_HID0] = 0x0011c464;
ppc_state.spr[SPR_IBAT3U] = 0xfff0001f;
ppc_state.spr[SPR_IBAT3L] = 0xfff00001;
ppc_state.spr[SPR_DBAT3U] = 0xfff0001f;
ppc_state.spr[SPR_DBAT3L] = 0xfff00001;
SetupBAT(system, /*is_wii*/ false);
PowerPC::ppcState.pc = 0x81200150;
ppc_state.pc = 0x81200150;
return true;
}
@ -543,16 +544,18 @@ bool CBoot::BootUp(Core::System& system, std::unique_ptr<BootParameters> boot)
SetDefaultDisc();
SetupMSR();
SetupHID(config.bWii);
SetupBAT(config.bWii);
auto& ppc_state = system.GetPPCState();
SetupMSR(ppc_state);
SetupHID(ppc_state, config.bWii);
SetupBAT(system, config.bWii);
CopyDefaultExceptionHandlers(system);
if (config.bWii)
{
// 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;
ppc_state.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.
@ -572,7 +575,7 @@ bool CBoot::BootUp(Core::System& system, std::unique_ptr<BootParameters> boot)
SConfig::OnNewTitleLoad();
PowerPC::ppcState.pc = executable.reader->GetEntryPoint();
ppc_state.pc = executable.reader->GetEntryPoint();
if (executable.reader->LoadSymbols())
{