Merge pull request #5412 from JosJuice/small-boot-simplifications

Boot: Small simplifications and formatting cleanup
This commit is contained in:
Leo Lam 2017-05-13 12:55:58 +02:00 committed by GitHub
commit 460459fb7d
2 changed files with 28 additions and 50 deletions

View File

@ -275,7 +275,6 @@ bool CBoot::BootUp()
switch (_StartupPara.m_BootType)
{
// GCM and Wii
case SConfig::BOOT_ISO:
{
DVDInterface::SetVolumeName(_StartupPara.m_strFilename);
@ -291,16 +290,9 @@ bool CBoot::BootUp()
_StartupPara.bWii = pVolume.GetVolumeType() == DiscIO::Platform::WII_DISC;
// HLE BS2 or not
if (_StartupPara.bHLE_BS2)
{
// We HLE the bootrom if requested or if LLEing it fails
if (_StartupPara.bHLE_BS2 || !Load_BS2(_StartupPara.m_strBootROM))
EmulatedBS2(_StartupPara.bWii);
}
else if (!Load_BS2(_StartupPara.m_strBootROM))
{
// If we can't load the bootrom file we HLE it instead
EmulatedBS2(_StartupPara.bWii);
}
PatchEngine::LoadPatches();
@ -325,7 +317,6 @@ bool CBoot::BootUp()
break;
}
// DOL
case SConfig::BOOT_DOL:
{
CDolLoader dolLoader(_StartupPara.m_strFilename);
@ -353,13 +344,13 @@ bool CBoot::BootUp()
if (!EmulatedBS2(dolWii))
{
if (dolLoader.IsWii())
if (dolWii)
HID4.SBE = 1;
SetupBAT(dolWii);
// 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.
if (dolLoader.IsWii())
if (dolWii)
SetupWiiMemory(0x000000010000003a);
dolLoader.Load();
@ -372,7 +363,6 @@ bool CBoot::BootUp()
break;
}
// ELF
case SConfig::BOOT_ELF:
{
// load image or create virtual drive from directory
@ -408,7 +398,6 @@ bool CBoot::BootUp()
break;
}
// Wii WAD
case SConfig::BOOT_WII_NAND:
Boot_WiiWAD(_StartupPara.m_strFilename);
@ -429,15 +418,12 @@ bool CBoot::BootUp()
// Bootstrap 2 (AKA: Initial Program Loader, "BIOS")
case SConfig::BOOT_BS2:
{
if (Load_BS2(_StartupPara.m_strBootROM))
{
if (LoadMapFromFilename())
HLE::PatchFunctions();
}
else
{
if (!Load_BS2(_StartupPara.m_strBootROM))
return false;
}
if (LoadMapFromFilename())
HLE::PatchFunctions();
break;
}

View File

@ -167,15 +167,16 @@ bool CBoot::EmulatedBS2_GC(bool skip_app_loader)
if (DVDInterface::IsDiscInside())
DVDRead(/*offset*/ 0x00000000, /*address*/ 0x00000000, 0x20, false); // write disc info
PowerPC::HostWrite_U32(0x0D15EA5E,
0x80000020); // Booted from bootrom. 0xE5207C22 = booted from jtag
PowerPC::HostWrite_U32(Memory::REALRAM_SIZE,
0x80000028); // Physical Memory Size (24MB on retail)
// TODO determine why some games fail when using a retail ID. (Seem to take different EXI paths,
// see Ikaruga for example)
PowerPC::HostWrite_U32(
0x10000006,
0x8000002C); // Console type - DevKit (retail ID == 0x00000003) see YAGCD 4.2.1.1.2
// Booted from bootrom. 0xE5207C22 = booted from jtag
PowerPC::HostWrite_U32(0x0D15EA5E, 0x80000020);
// Physical Memory Size (24MB on retail)
PowerPC::HostWrite_U32(Memory::REALRAM_SIZE, 0x80000028);
// Console type - DevKit (retail ID == 0x00000003) see YAGCD 4.2.1.1.2
// TODO: determine why some games fail when using a retail ID.
// (Seem to take different EXI paths, see Ikaruga for example)
PowerPC::HostWrite_U32(0x10000006, 0x8000002C);
const bool ntsc = DiscIO::IsNTSC(SConfig::GetInstance().m_region);
PowerPC::HostWrite_U32(ntsc ? 0 : 1, 0x800000CC); // Fake the VI Init of the IPL (YAGCD 4.2.1.4)
@ -193,27 +194,19 @@ bool CBoot::EmulatedBS2_GC(bool skip_app_loader)
PresetTimeBaseTicks();
// HIO checks this
// PowerPC::HostWrite_U16(0x8200, 0x000030e6); // Console type
// PowerPC::HostWrite_U16(0x8200, 0x000030e6); // Console type
if (!DVDInterface::IsDiscInside())
return false;
// Setup pointers like real BS2 does
if (ntsc)
{
// StackPointer, used to be set to 0x816ffff0
PowerPC::ppcState.gpr[1] = 0x81566550;
// Global pointer to Small Data Area 2 Base (haven't seen anything use it...meh)
PowerPC::ppcState.gpr[2] = 0x81465cc0;
// Global pointer to Small Data Area Base (Luigi's Mansion's apploader uses it)
PowerPC::ppcState.gpr[13] = 0x81465320;
}
else
{
PowerPC::ppcState.gpr[1] = 0x815edca8;
PowerPC::ppcState.gpr[2] = 0x814b5b20;
PowerPC::ppcState.gpr[13] = 0x814b4fc0;
}
// StackPointer, used to be set to 0x816ffff0
PowerPC::ppcState.gpr[1] = ntsc ? 0x81566550 : 0x815edca8;
// Global pointer to Small Data Area 2 Base (haven't seen anything use it...meh)
PowerPC::ppcState.gpr[2] = ntsc ? 0x81465cc0 : 0x814b5b20;
// Global pointer to Small Data Area Base (Luigi's Mansion's apploader uses it)
PowerPC::ppcState.gpr[13] = ntsc ? 0x81465320 : 0x814b4fc0;
if (skip_app_loader)
return false;
@ -313,9 +306,7 @@ bool CBoot::SetupWiiMemory(u64 ios_title_id)
Memory::Write_U32(0x00000000, 0x000030f0); // Apploader
if (!IOS::HLE::GetIOS()->BootIOS(ios_title_id))
{
return false;
}
Memory::Write_U8(0x80, 0x0000315c); // OSInit
Memory::Write_U16(0x0000, 0x000030e0); // PADInit
@ -329,6 +320,7 @@ bool CBoot::SetupWiiMemory(u64 ios_title_id)
{
Memory::Write_U32(0x00000000, i);
}
return true;
}