BS2Emu: Don't do a DVDCopy when AppLdrMain returns 0

This commit is contained in:
booto 2018-08-02 01:30:25 -04:00
parent 14e156c292
commit f800f6343d
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");