Merge pull request #7296 from booto/apploader-exit-state

BS2Emu: Don't do a DVD Copy when AppLoaderMain returns 0
This commit is contained in:
Pierre Bourdon 2018-08-02 13:46:53 +02:00 committed by GitHub
commit 59d97c8e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 8 deletions

View File

@ -125,14 +125,19 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::Volume& volume)
// To give you an idea about where the stuff is located on the disc take a look at yagcd
// ch 13.
DEBUG_LOG(MASTER_LOG, "Call iAppLoaderMain");
do
PowerPC::ppcState.gpr[3] = 0x81300004;
PowerPC::ppcState.gpr[4] = 0x81300008;
PowerPC::ppcState.gpr[5] = 0x8130000c;
RunFunction(iAppLoaderMain);
// iAppLoaderMain returns 1 if the pointers in R3/R4/R5 were filled with values for DVD copy
// Typical behaviour is doing it once for each section defined in the DOL header. Some unlicensed
// titles don't have a properly constructed DOL and maintain a table of these values in apploader.
// iAppLoaderMain returns 0 when there are no more sections to copy.
while (PowerPC::ppcState.gpr[3] != 0x00)
{
PowerPC::ppcState.gpr[3] = 0x81300004;
PowerPC::ppcState.gpr[4] = 0x81300008;
PowerPC::ppcState.gpr[5] = 0x8130000c;
RunFunction(iAppLoaderMain);
u32 iRamAddress = PowerPC::Read_U32(0x81300004);
u32 iLength = PowerPC::Read_U32(0x81300008);
u32 iDVDOffset = PowerPC::Read_U32(0x8130000c) << (is_wii ? 2 : 0);
@ -141,7 +146,12 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::Volume& volume)
iRamAddress, iLength);
DVDRead(volume, iDVDOffset, iRamAddress, iLength, partition);
} while (PowerPC::ppcState.gpr[3] != 0x00);
PowerPC::ppcState.gpr[3] = 0x81300004;
PowerPC::ppcState.gpr[4] = 0x81300008;
PowerPC::ppcState.gpr[5] = 0x8130000c;
RunFunction(iAppLoaderMain);
}
// iAppLoaderClose
DEBUG_LOG(MASTER_LOG, "call iAppLoaderClose");