Boot: Split out some code to a new function SetupGCMemory

Just like the existing function SetupWiiMemory.
This commit is contained in:
JosJuice 2017-08-01 15:23:44 +02:00
parent a8606f5d13
commit fea75d045c
3 changed files with 26 additions and 23 deletions

View File

@ -324,18 +324,19 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
SetDefaultDisc(); SetDefaultDisc();
SetupMSR();
SetupBAT(config.bWii);
if (config.bWii) if (config.bWii)
{ {
HID4.SBE = 1; HID4.SBE = 1;
SetupMSR();
SetupBAT(config.bWii);
// 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(nullptr, 0x000000010000003a); SetupWiiMemory(nullptr, 0x000000010000003a);
} }
else else
{ {
EmulatedBS2_GC(nullptr, true); SetupGCMemory();
} }
PC = executable.reader->GetEntryPoint(); PC = executable.reader->GetEntryPoint();

View File

@ -107,6 +107,7 @@ private:
static bool EmulatedBS2(bool is_wii, const DiscIO::Volume* volume); static bool EmulatedBS2(bool is_wii, const DiscIO::Volume* volume);
static bool Load_BS2(const std::string& boot_rom_filename); static bool Load_BS2(const std::string& boot_rom_filename);
static void SetupGCMemory();
static bool SetupWiiMemory(const DiscIO::Volume* volume, u64 ios_title_id); static bool SetupWiiMemory(const DiscIO::Volume* volume, u64 ios_title_id);
}; };

View File

@ -152,25 +152,8 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::Volume& volume)
return true; return true;
} }
// __________________________________________________________________________________________________ void CBoot::SetupGCMemory()
// GameCube Bootstrap 2 HLE:
// copy the apploader to 0x81200000
// execute the apploader, function by function, using the above utility.
bool CBoot::EmulatedBS2_GC(const DiscIO::Volume* volume, bool skip_app_loader)
{ {
INFO_LOG(BOOT, "Faking GC BS2...");
SetupMSR();
SetupBAT(/*is_wii*/ false);
// Write necessary values
// Here we write values to memory that the apploader does not take care of. Game info goes
// to 0x80000000 according to YAGCD 4.2.
// It's possible to boot DOL and ELF files without a disc inserted
if (volume)
DVDRead(*volume, /*offset*/ 0x00000000, /*address*/ 0x00000000, 0x20, DiscIO::PARTITION_NONE);
// Booted from bootrom. 0xE5207C22 = booted from jtag // Booted from bootrom. 0xE5207C22 = booted from jtag
PowerPC::HostWrite_U32(0x0D15EA5E, 0x80000020); PowerPC::HostWrite_U32(0x0D15EA5E, 0x80000020);
@ -182,8 +165,8 @@ bool CBoot::EmulatedBS2_GC(const DiscIO::Volume* volume, bool skip_app_loader)
// (Seem to take different EXI paths, see Ikaruga for example) // (Seem to take different EXI paths, see Ikaruga for example)
PowerPC::HostWrite_U32(0x10000006, 0x8000002C); PowerPC::HostWrite_U32(0x10000006, 0x8000002C);
const bool ntsc = DiscIO::IsNTSC(SConfig::GetInstance().m_region); // Fake the VI Init of the IPL (YAGCD 4.2.1.4)
PowerPC::HostWrite_U32(ntsc ? 0 : 1, 0x800000CC); // Fake the VI Init of the IPL (YAGCD 4.2.1.4) PowerPC::HostWrite_U32(DiscIO::IsNTSC(SConfig::GetInstance().m_region) ? 0 : 1, 0x800000CC);
PowerPC::HostWrite_U32(0x01000000, 0x800000d0); // ARAM Size. 16MB main + 4/16/32MB external PowerPC::HostWrite_U32(0x01000000, 0x800000d0); // ARAM Size. 16MB main + 4/16/32MB external
// (retail consoles have no external ARAM) // (retail consoles have no external ARAM)
@ -199,10 +182,28 @@ bool CBoot::EmulatedBS2_GC(const DiscIO::Volume* volume, bool skip_app_loader)
// HIO checks this // HIO checks this
// PowerPC::HostWrite_U16(0x8200, 0x000030e6); // Console type // PowerPC::HostWrite_U16(0x8200, 0x000030e6); // Console type
}
// __________________________________________________________________________________________________
// GameCube Bootstrap 2 HLE:
// copy the apploader to 0x81200000
// execute the apploader, function by function, using the above utility.
bool CBoot::EmulatedBS2_GC(const DiscIO::Volume* volume, bool skip_app_loader)
{
INFO_LOG(BOOT, "Faking GC BS2...");
SetupMSR();
SetupBAT(/*is_wii*/ false);
SetupGCMemory();
if (!volume) if (!volume)
return false; return false;
DVDRead(*volume, /*offset*/ 0x00000000, /*address*/ 0x00000000, 0x20, DiscIO::PARTITION_NONE);
const bool ntsc = DiscIO::IsNTSC(SConfig::GetInstance().m_region);
// Setup pointers like real BS2 does // Setup pointers like real BS2 does
// StackPointer, used to be set to 0x816ffff0 // StackPointer, used to be set to 0x816ffff0