Compare commits

...

6 Commits

12 changed files with 449 additions and 438 deletions

View File

@@ -44,10 +44,14 @@ namespace ipl {
int stopBGM(int unk = 0);
#endif
int stopBGM(nw4r::snd::SoundHandle* handle, int unk = 0);
int stopSE(nw4r::snd::SoundHandle* handle, int unk = 0);
void stopSE(nw4r::snd::SoundHandle* handle, int unk = 0);
void stopAllSound(int unk = 0);
#ifdef IPL_SOUND_MATCHING
void resetAllSound();
#else
int resetAllSound();
#endif
#ifdef IPL_SOUND_MATCHING
void muteOffBGM(int);
@@ -99,7 +103,7 @@ namespace ipl {
long clipGELT_S32(long value, long lo, long hi);
private:
u32 unk_0x620[0x18];
u32 unk_0x620[3];
};
// use getSystem() and getBannerPlayer() instead

View File

@@ -356,8 +356,11 @@ namespace nw4r {
// u32 fontSizeToEndOfGlgr;
u16 nameCount;
u16 countSheet;
u16 smth0a;
u16 sheetGlyphCount, dataBlockCount;
u16 smth0c;
u32 stepSheetFlags;
u32 flagsSheetsOff;
@@ -368,18 +371,18 @@ namespace nw4r {
u32 sheetOffsetsScratchSize;
dataBlockCount = font->hdr.dataBlocks; // 0x0E
sheetGlyphCount = font->glgr.inner.sheetGlyphCount; // 0x1C
// countName = font->glgr.inner.nameCount;
nameCount = font->glgr.inner.nameCount;
countSheet = font->glgr.inner.sheetCount;
// count0A = font->glgr.inner.smthCount_0x0a;
// count0C = font->glgr.inner.smthCount_0x0c;
smth0a = font->glgr.inner.smthCount_0x0a;
sheetGlyphCount = font->glgr.inner.sheetGlyphCount;
smth0c = font->glgr.inner.smthCount_0x0c;
dataBlockCount = font->hdr.dataBlocks;
sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)font + ctx->remWorkSpace()) - sheetOffsetsSize, 2);
stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(font->glgr.inner.nameCount, countSheet, font->glgr.inner.smthCount_0x0a,
font->glgr.inner.smthCount_0x0c);
flagsSheetsOff = detail::CalcOffsetSheetFlags(nameCount, countSheet, smth0a, smth0c);
flagsSheets = (const u32*)font + (flagsSheetsOff >> 2);
pGlgr = &font->glgr;

View File

@@ -494,6 +494,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
switch (tag) {
case 0x0132:
case 0x0102:
case 0x0111:
case 0x0112:
case 0x012D:

View File

@@ -1180,7 +1180,11 @@ static u32 getCurrentHalfLine(void)
break;
}
}
return ((horizontalCount - 1) / CurrTiming->hlw) + ((verticalCount - 1) * 2);
{
u32 vm1 = verticalCount - 1;
u32 hm1 = horizontalCount - 1;
return hm1 / CurrTiming->hlw + vm1 * 2;
}
}
static u32 getCurrentFieldEvenOdd(void)

View File

@@ -405,9 +405,12 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
u32 index;
u32 skipTitleMeta = flags & 4;
WADFileHeader* fileHeader;
void* firstBuffer;
void* secondBuffer;
streamOpened = FALSE;
fileOffset = 0;
firstBuffer = 0;
secondBuffer = 0;
allocatedFiles = 0;
memset(&workspace.unpackInfo, 0, sizeof(WADUnpackInfo));
if (fileListOut != 0) {
@@ -521,6 +524,12 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
cleanup:
_WADFreeMemory(&workspace.unpackInfo, allocator);
if (firstBuffer != 0) {
_WADMemFree(allocator, firstBuffer);
}
if (secondBuffer != 0) {
_WADMemFree(allocator, secondBuffer);
}
if ((fileListOut != 0) && (result != 0)) {
if (allocatedFiles != 0) {
_WADMemFree(allocator, allocatedFiles);
@@ -1227,6 +1236,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
u32 totalSize;
WADBackupTitleMetaBuffer* titleMetaBuffer;
ESTmdView* titleMeta;
WADBackupHeader* backupHeader = &headerBlock.header;
struct WADExportCertificates {
ESCertSignature signer;
u8 device[0x180];
@@ -1414,12 +1424,12 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
headerBlock.header.fileSize = fileDataSize;
headerBlock.header.numFiles = fileCount;
headerBlock.header.backupAreaLen = totalSize + 0x340;
result = ES_GetDeviceId(&headerBlock.header.deviceId);
result = ES_GetDeviceId(&backupHeader->deviceId);
if (result != 0) {
goto cleanup;
}
if ((flags & 1) != 0) {
memcpy(&headerBlock.header.cidx, &existingContentMask, sizeof(existingContentMask));
memcpy(&backupHeader->cidx, &existingContentMask, sizeof(existingContentMask));
}
if ((flags & 2) != 0) {
u32 currentTitleLow;
@@ -1442,7 +1452,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
headerBlock.header.titleId = ((u64)currentTitleHigh << 32) | currentTitleLow;
}
if (_WADGetTransferId(transferMac) != 0) {
memcpy(headerBlock.header.deviceMac, transferMac, sizeof(headerBlock.header.deviceMac));
memcpy(backupHeader->deviceMac, transferMac, sizeof(backupHeader->deviceMac));
}
}
SHA1Reset(hashContext);

View File

@@ -64,7 +64,7 @@ volatile int lbl_81698A44 = 0;
volatile int lbl_81698A48 = 0;
volatile int lbl_81698A4C = 0;
vu32 lbl_81698A50 = 0;
u32 lbl_81698A54 = 0;
vu32 lbl_81698A54 = 0;
u32 lbl_81698A58 = 0;
u32 lbl_81698A5C = 0;
u64 lbl_81698A60 = 0;
@@ -293,14 +293,58 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
extern vu32 BS2VideoMode;
extern vu32 __DVDLayoutFormat;
void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
u8 *block = start;
for (; blockCount != 0; --blockCount) {
__dcbz(block, 0);
__dcbf(block, 0);
block += 32;
}
((void (*)(u32))entryPoint)(argument);
extern int __pformatter();
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
// clang-format off
nofralloc
mtctr r5
mtlr r3
li r0, 0
li r2, 0
li r3, 0
li r5, 0
li r7, 0
li r8, 0
li r9, 0
li r10, 0
li r11, 0
li r12, 0
li r13, 0
li r14, 0
li r15, 0
li r16, 0
li r17, 0
li r18, 0
li r19, 0
li r20, 0
li r21, 0
li r22, 0
li r23, 0
li r24, 0
li r25, 0
li r26, 0
li r27, 0
li r28, 0
li r29, 0
li r30, 0
li r31, 0
lis r1, (__pformatter + 0x280)@h
ori r1, r1, (__pformatter + 0x280)@l
li r6, 0
b _Run_enter
_Run_loop:
dcbz r4, r0
dcbf r4, r0
addi r4, r4, 0x20
bdnz _Run_loop
b _Run_done
_Run_done:
li r4, 0
blr
_Run_enter:
b _Run_loop
// clang-format on
}
BOOL BS2GetLockedTitles(ESTitleId *pTitleIds, u32 *count) {
@@ -629,7 +673,7 @@ void BS2StartGame() {
u32 (*entry)(void);
StartingGame = TRUE;
while (DVDGetCommandBlockStatus(&CoverBlock) != DVD_STATE_IDLE) {
while (CoverBlock.state != DVD_STATE_IDLE) {
}
BS2Report("BS2StartGame(1)\n");
@@ -729,8 +773,7 @@ void BS2StartGame() {
LowReadResult = 0;
DVDLowReadDiskID(&DiskID, (DVDLowCallback)callback);
while (LowReadResult == 0) {
BOOL enabled = OSDisableInterrupts();
OSRestoreInterrupts(enabled);
;
}
status = LowReadResult;
@@ -745,8 +788,7 @@ void BS2StartGame() {
LowReadResult = 0;
DVDLowRequestError((DVDLowCallback)callback);
while (LowReadResult == 0) {
BOOL enabled = OSDisableInterrupts();
OSRestoreInterrupts(enabled);
;
}
driveError = DVDLowGetImmBufferReg() & 0xFF000000;
if (driveError == 0x01000000 || (driveError = DVDLowGetImmBufferReg() & 0xFF000000) == 0x03000000) {
@@ -781,8 +823,7 @@ disk_done:
(DVDLowCallback)callback);
}
while (LowReadResult == 0) {
BOOL enabled = OSDisableInterrupts();
OSRestoreInterrupts(enabled);
;
}
status = LowReadResult;
@@ -800,8 +841,7 @@ disk_done:
LowReadResult = 0;
DVDLowRequestError((DVDLowCallback)callback);
while (LowReadResult == 0) {
BOOL enabled = OSDisableInterrupts();
OSRestoreInterrupts(enabled);
;
}
driveError = DVDLowGetImmBufferReg() & 0xFF000000;
if (driveError == 0x01000000 || (driveError = DVDLowGetImmBufferReg() & 0xFF000000) == 0x03000000) {
@@ -862,7 +902,7 @@ void BS2StartGCGame() {
OSTime time;
StartingGame = TRUE;
while (DVDGetCommandBlockStatus(&CoverBlock) != DVD_STATE_IDLE) {
while (CoverBlock.state != DVD_STATE_IDLE) {
}
soundMode = SCGetSoundMode();
@@ -893,8 +933,8 @@ void BS2StartGCGame() {
__OSGetRTC(&rtc);
counterBias = SCGetCounterBias();
seconds = rtc + counterBias;
timerFrequency = OS_BUS_CLOCK >> 2;
seconds = rtc + counterBias;
time = (OSTime)seconds * timerFrequency;
__OSSetTime(time);
@@ -1335,6 +1375,8 @@ void BS2ReadDiskID(void *buffer, s32 length, u32 offset) {
}
BS2State BS2Tick() {
DVDCommandBlock* block = &Block;
DVDDiskID* bootDisc;
u32 interruptsEnabled = OSDisableInterrupts();
u32 titleCode;
s32 titlePrefix;
@@ -1360,6 +1402,7 @@ BS2State BS2Tick() {
BS2Report("Drive Reset : %d\n", BS2DriveReset);
BS2Report("Wait Spinup : %d\n", BS2WaitSpinup);
BS2Report("Boot From Cache : %d\n", BS2BootFromCache);
bootDisc = (DVDDiskID *)0x80000000;
DvdProgress = (u32 *)&(*(u32 *)0x800030d4);
PartitionParams.numTmdBytes = 0;
PartitionParams.numCertBytes = 0;
@@ -1407,14 +1450,14 @@ BS2State BS2Tick() {
SpinupDeadline = __OSGetSystemTime() + OSSecondsToTicks(7);
}
__OSClearRTCFlags();
DVDResetAsync(&Block, BS2DVDCallback);
DVDResetAsync(block, BS2DVDCallback);
CoverBlock.state = 0;
DriveWasReset = 1;
State = BS2_STT_3;
case 3:
currentTime = __OSGetSystemTime();
if ((OSTime)currentTime < (OSTime)SpinupDeadline) {
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status != 0) {
currentTime = __OSGetSystemTime();
if ((OSTime)(currentTime - ResetTime) >= (OSTime)(((OS_BUS_CLOCK >> 2) / 1000) * 200)) {
@@ -1439,7 +1482,7 @@ BS2State BS2Tick() {
NandPending = 1;
BS2NANDDivideReadAsync(&BS2CacheFileInfo, &DriveInfo, 0x20, BS2NANDCallback, &BS2NandBlock);
} else {
DVDInquiryAsync(&Block, &DriveInfo, BS2DVDCallback);
DVDInquiryAsync(block, &DriveInfo, BS2DVDCallback);
}
State = BS2_STT_5;
}
@@ -1448,19 +1491,19 @@ BS2State BS2Tick() {
case 5:
status = CheckBS2CommandStatus();
if (status != 0) {
if (((*(u32 *)0x8000002c) & 0xf0000000) == 0)
(*(u16 *)0x800030e6) = 0x8002;
if (((*(u32 *)((u8 *)bootDisc + 0x2c)) & 0xf0000000) == 0)
(*(u16 *)((u8 *)bootDisc + 0x30e6)) = 0x8002;
else
(*(u16 *)0x800030e6) = DriveInfo.deviceCode | 0x8000;
(*(u16 *)((u8 *)bootDisc + 0x30e6)) = DriveInfo.deviceCode | 0x8000;
State = BS2_STT_8;
}
break;
case 6:
DVDDownRotationAsync(&Block, BS2DVDCallback);
DVDDownRotationAsync(block, BS2DVDCallback);
State = BS2_STT_7;
break;
case 7:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status == 0)
break;
State = BS2_STT_8;
@@ -1470,18 +1513,16 @@ BS2State BS2Tick() {
NandPending = 1;
BS2NANDDivideReadAsync(&BS2CacheFileInfo, &DiskID, 0x20, BS2NANDCallback, &BS2NandBlock);
} else {
DVDReadDiskID(&Block, &DiskID, BS2DVDCallback);
DVDReadDiskID(block, &DiskID, BS2DVDCallback);
}
State = BS2_STT_9;
break;
case 9:
case 10: {
DVDDiskID *bootDisc;
status = CheckBS2CommandStatus();
if (status == 0)
break;
memcpy((void *)0x80000000, &DiskID, sizeof(DVDDiskID));
bootDisc = (DVDDiskID *)0x80000000;
memcpy((void *)bootDisc, &DiskID, sizeof(DVDDiskID));
if (bootDisc->rvlMagic == 0x5d1c9ea3) {
status = strncmp((char *)bootDisc, "RAAE", 4);
if (status == 0 || strncmp((char *)bootDisc, "408", 3) == 0 ||
@@ -1508,7 +1549,6 @@ BS2State BS2Tick() {
State = BS2_STT_11;
}
case 0xb: {
DVDDiskID *bootDisc = (DVDDiskID *)0x80000000;
u32 audioBufferSize;
if (AudioBufferUnconfigured == 0) {
State = BS2_STT_GC_GAME;
@@ -1518,22 +1558,22 @@ BS2State BS2Tick() {
if (bootDisc->streaming != 0) {
audioBufferSize = bootDisc->streamingBufSize;
audioBufferSize = audioBufferSize != 0 ? audioBufferSize : 10;
__DVDAudioBufferConfig(&Block, 1, audioBufferSize, BS2DVDCallback);
__DVDAudioBufferConfig(block, 1, audioBufferSize, BS2DVDCallback);
} else {
__DVDAudioBufferConfig(&Block, 0, 0, BS2DVDCallback);
__DVDAudioBufferConfig(block, 0, 0, BS2DVDCallback);
}
State = BS2_STT_12;
}
case 0xc:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status == 0)
break;
State = BS2_STT_13;
case 0xd:
DVDUnencryptedReadAbsAsyncForBS(&Block, &bi2, 0x2000, 0x110, BS2DVDCallback);
DVDUnencryptedReadAbsAsyncForBS(block, &bi2, 0x2000, 0x110, BS2DVDCallback);
State = BS2_STT_14;
case 0xe:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status == 0)
break;
discRegion = bi2.countryCode;
@@ -1679,14 +1719,14 @@ invalidRvlRegion:
break;
}
case 0x15:
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd,
DVDOpenPartitionAsync(block, &PartitionParams.tmd,
(u32)((DVDPartitionInfo *)UpdatePartition)->partition,
BS2DVDCallback);
PartitionOpen = 1;
State = BS2_STT_22;
break;
case 0x16:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status != 0) {
CurrentTmd = (u32)&PartitionParams.tmd;
BS2Report("TMD ver ... 0x%02X\n", ((ESTitleMeta *)CurrentTmd)->head.version);
@@ -1700,11 +1740,11 @@ invalidRvlRegion:
}
break;
case 0x17:
DVDReadAbsAsyncForBS(&Block, &UpdateDiskID, 0x20, 0, BS2DVDCallback);
DVDReadAbsAsyncForBS(block, &UpdateDiskID, 0x20, 0, BS2DVDCallback);
State = BS2_STT_24;
break;
case 0x18:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status == 0)
break;
if (UpdateDiskID.rvlMagic == 0x5d1c9ea3)
@@ -1714,22 +1754,22 @@ invalidRvlRegion:
break;
}
case 0x19:
DVDReadAbsAsyncForBS(&Block, &AppLoaderHdr, 0x20, 0x910, BS2DVDCallback);
DVDReadAbsAsyncForBS(block, &AppLoaderHdr, 0x20, 0x910, BS2DVDCallback);
State = BS2_STT_26;
break;
case 0x1a:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status == 0)
break;
BS2Report(" appLoaderLength ...... 0x%x\n", AppLoaderHdr.length);
BS2Report(" appLoaderFunc1 ...... 0x%x\n", AppLoaderHdr.entryPoint);
State = BS2_STT_27;
case 0x1b:
DVDReadAbsAsyncForBS(&Block, (void *)0x81200000, (AppLoaderHdr.length + 0x1fU & 0xffffffe0), 0x918, BS2DVDCallback);
DVDReadAbsAsyncForBS(block, (void *)0x81200000, (AppLoaderHdr.length + 0x1fU & 0xffffffe0), 0x918, BS2DVDCallback);
State = BS2_STT_28;
break;
case 0x1c:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status == 0)
break;
ICInvalidateRange((void *)0x81200000, (AppLoaderHdr.length + 0x1fU & 0xffffffe0));
@@ -1742,7 +1782,7 @@ invalidRvlRegion:
if (status != 0) {
BS2Report("Addr [0x%x] length [0x%x] offset [0x%x]\n", loaderRead.address, loaderRead.length, loaderRead.offset);
readInterruptsEnabled = OSDisableInterrupts();
DVDReadAbsAsyncForBS(&Block, (void *)loaderRead.address, loaderRead.length, loaderRead.offset >> __DVDLayoutFormat, BS2DVDCallback);
DVDReadAbsAsyncForBS(block, (void *)loaderRead.address, loaderRead.length, loaderRead.offset >> __DVDLayoutFormat, BS2DVDCallback);
if (*(s32 *)DvdProgress != 0) {
DvdReadPending = 1;
DvdTransferLength = loaderRead.length;
@@ -1753,7 +1793,7 @@ invalidRvlRegion:
State = BS2_STT_31;
break;
case 0x1e:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status != 0)
State = BS2_STT_29;
break;
@@ -1842,11 +1882,11 @@ invalidRvlRegion:
}
break;
case 0x23:
DVDClosePartitionAsync(&Block, BS2DVDCallback);
DVDClosePartitionAsync(block, BS2DVDCallback);
State = BS2_STT_36;
break;
case 0x24:
status = CheckDVDCommandStatus(&Block);
status = CheckDVDCommandStatus(block);
if (status == 0)
break;
PartitionOpen = 0;
@@ -1866,7 +1906,7 @@ invalidRvlRegion:
NandPending = 1;
BS2NANDDivideReadAsync(&BS2CacheFileInfo, &PartitionParams.tmd, 0x4a00, BS2NANDCallback, &BS2NandBlock);
} else
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
DVDOpenPartitionAsync(block, &PartitionParams.tmd, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
PartitionOpen = 1;
State = BS2_STT_38;
break;
@@ -2095,7 +2135,7 @@ invalidRvlRegion:
}
break;
case 0x2f:
DVDClosePartitionAsync(&Block, BS2DVDCallback);
DVDClosePartitionAsync(block, BS2DVDCallback);
State = BS2_STT_48;
break;
case 0x30:
@@ -2172,7 +2212,7 @@ invalidRvlRegion:
switch (Block.state) {
case 4:
case 5:
CheckDVDCommandStatus(&Block);
CheckDVDCommandStatus(block);
break;
default: {
currentTime = __OSGetSystemTime();
@@ -2193,11 +2233,11 @@ invalidRvlRegion:
BannerLength = 0;
}
LoadingTitle = 0;
DVDChangeDiskAsyncForBS(&Block, BS2DVDCallback);
DVDChangeDiskAsyncForBS(block, BS2DVDCallback);
State = BS2_STT_55;
case 0x37:
case 0x38:
CheckDVDCommandStatus(&Block);
CheckDVDCommandStatus(block);
break;
case 0x39:
case 0x3a:
@@ -2216,7 +2256,7 @@ invalidRvlRegion:
State = BS2_STT_61;
break;
case 0x3d:
DVDClosePartitionAsync(&Block, BS2DVDCallback);
DVDClosePartitionAsync(block, BS2DVDCallback);
State = BS2_STT_62;
break;
case 0x3e:
@@ -2228,7 +2268,7 @@ invalidRvlRegion:
}
break;
case 0x46:
DVDGetPartitionParamsAsync(&Block, &PartitionParams, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
DVDGetPartitionParamsAsync(block, &PartitionParams, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
State = BS2_STT_71;
break;
case 0x47: {
@@ -2243,7 +2283,7 @@ invalidRvlRegion:
}
memcpy(&PartitionParams.ticketView, (void *)TitleTicketView, sizeof(ESTicketView));
DCStoreRange(&PartitionParams.ticketView, sizeof(ESTicketView));
DVDOpenPartitionWithParamsAsync(&Block, &PartitionParams, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
DVDOpenPartitionWithParamsAsync(block, &PartitionParams, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
PartitionOpen = 1;
State = BS2_STT_38;
}
@@ -2266,7 +2306,7 @@ invalidRvlRegion:
switch (Block.state) {
case 4:
case 5:
CheckDVDCommandStatus(&Block);
CheckDVDCommandStatus(block);
break;
default: {
currentTime = __OSGetSystemTime();
@@ -2318,11 +2358,11 @@ invalidRvlRegion:
break;
currentTime = __OSGetSystemTime();
CoverPollTime = currentTime;
__DVDGetCoverStatusAsync(&Block, BS2DVDCallback);
__DVDGetCoverStatusAsync(block, BS2DVDCallback);
State = BS2_STT_67;
case 0x43:
case 0x44:
CheckDVDCommandStatus(&Block);
CheckDVDCommandStatus(block);
break;
default:
OSPanic("BS2Mach.c", 0x14e3, "BS2 ERROR >>> UNKNOWN STATE");

View File

@@ -12,6 +12,7 @@
typedef struct UpdateThreadData {
OSThread thread;
u8 stack[4096];
OSThreadQueue queue;
} UpdateThreadData;
static u32 Flags0[BS2_UPDATE_ENTRY_COUNT];
@@ -26,24 +27,24 @@ s32 WADCheckImport(u64 titleId, u16 titleVersion);
s32 WADImportDVDForBS(const char* path, void* buffer, u32 length);
s32 WADImportDVDExForBS(const char* path, void* buffer, u32 length);
static BS2UpdateEntry* pEntries;
static u32 EntriesCount;
static u32* pFlags;
static void* MemAllocator;
int State;
BS2UpdateEntry* CurrentEntry;
static u32 RebootRequired;
static BOOL ContainsSeatTitles;
static u32 UpdateImportState;
static u32 UpdateImportResult;
u32 StartUpdate;
u32 CancelUpdate;
u32 ConsoleType;
u32 VersionES;
u32 VersionMEM2;
u64 VersionIOS;
s32 rc;
static u32 UpdateProgress;
static s32 rc;
static u64 VersionIOS;
static u32 VersionMEM2;
static u32 VersionES;
static u32 ConsoleType;
u32 CancelUpdate;
u32 StartUpdate;
static u32 UpdateImportResult;
static u32 UpdateImportState;
static BOOL ContainsSeatTitles;
static u32 RebootRequired;
BS2UpdateEntry* CurrentEntry;
int State;
static void* MemAllocator;
static u32* pFlags;
static u32 EntriesCount;
static BS2UpdateEntry* pEntries;
static void* FatalFunc;
#pragma force_active on
@@ -59,6 +60,7 @@ char* getSuffix(const char* path) {
static void* UpdateThread(void* argument);
void BS2UpdateInit(void* allocator) {
u32* flags = Flags0;
BS2Report("initialize BS2Update\n");
ConsoleType = OSGetConsoleType();
VersionES = __OSGetHollywoodRev();
@@ -74,7 +76,7 @@ void BS2UpdateInit(void* allocator) {
EntriesCount = 0;
memset(UPDATE_DISC_ENTRIES, 0, 0x40000);
memset(EntriesToImport, 0, 0x40000);
memset(Flags1, 0, sizeof(Flags1));
memset(&flags[BS2_UPDATE_ENTRY_COUNT], 0, sizeof(Flags1));
BS2Report("Create update thread\n");
OSCreateThread(&Thread.thread, UpdateThread, NULL, Thread.stack + sizeof(Thread.stack),
sizeof(Thread.stack), 31, 1);
@@ -133,7 +135,7 @@ static void* UpdateThread(void* argument) {
}
goto invalid_product_region;
case 1:
if (titleRegion == 'E' || titleRegion == 'D') {
if (!(titleRegion != 'E' && titleRegion != 'D')) {
regionValid = TRUE;
goto product_region_checked;
}
@@ -174,7 +176,7 @@ product_region_checked:
goto selection_done;
}
strcpy(scratch.updatePath, "__update.inf");
strcat(scratch.updatePath, "-");
strcat(scratch.updatePath, ".");
strcat(scratch.updatePath, scratch.productArea);
if (DVDConvertPathToEntrynum(scratch.updatePath) < 0) {
switch (SCGetProductArea()) {
@@ -271,7 +273,7 @@ product_region_checked:
}
}
strcpy(scratch.seatPath, "__seatholder.inf");
strcat(scratch.seatPath, "-");
strcat(scratch.seatPath, ".");
strcat(scratch.seatPath, scratch.productArea);
if (DVDConvertPathToEntrynum(scratch.seatPath) < 0) {
switch (SCGetProductArea()) {

View File

@@ -1,5 +1,6 @@
#define AutoLock(x) AutoLock(x) NO_INLINE
#define IPL_SOUND_RECT_OUT_OF_LINE
#define IPL_CONTROLLER_TRIVIAL_RECT_DTOR
#define IPL_SOUND_MATCHING
#include "iplSound.h"
#include "sound/iplSound.h"
@@ -8,90 +9,33 @@
#include "system/iplSystem.h"
#undef IPL_SOUND_RECT_OUT_OF_LINE
#undef IPL_CONTROLLER_TRIVIAL_RECT_DTOR
#undef AutoLock
extern "C" void __ct__Q23EGG20SimpleAudioMgrWithFxFv();
extern "C" void __dt__Q34nw4r3snd11SoundHandleFv();
extern "C" void __dl__FPv();
extern "C" {
void __destroy_arr();
void __dt__Q33ipl3snd10tagSSeInfoFv();
}
extern "C" void _seBlk__Q23ipl3snd();
extern "C" nw4r::snd::SoundHandle* _mainBGMHandle__Q23ipl3snd;
extern "C" const f32 lbl_816946A4;
extern "C" const f32 lbl_816946AC;
extern "C" const f32 lbl_816946A8;
extern "C" const f32 lbl_816946B0;
extern "C" const f32 lbl_816946B4;
extern "C" {
void _savegpr_29();
void pauseOffSE__Q33ipl3snd6SystemFv();
void pauseOnSE__Q33ipl3snd6SystemFv();
}
extern "C" void _restgpr_29();
extern "C" void _savegpr_24();
extern "C" void _restgpr_24();
extern "C" void _savegpr_26();
extern "C" void _restgpr_26();
extern "C" void sBannerSoundPlayer__Q23ipl3snd();
extern "C" void pause__17BannerSoundPlayerFb();
extern "C" void initFx__Q33ipl3snd6SystemFv();
extern "C" void GetInstance__Q44nw4r3snd6detail9AxManagerFv();
extern "C" void ClearEffect__Q44nw4r3snd6detail9AxManagerFQ34nw4r3snd6AuxBusi();
extern "C" void stop__17BannerSoundPlayerFUl();
extern "C" void setMasterVolume__17BannerSoundPlayerFf();
extern "C" void SetMasterVolume__Q44nw4r3snd6detail9AxManagerFfi();
namespace ipl {
namespace snd {
extern "C" void __vt__Q33ipl3snd6System();
System::System() {
}
struct tagSSeInfo {
tagSSeInfo();
~tagSSeInfo();
tagSSeInfo() {}
~tagSSeInfo() {}
nw4r::snd::SoundHandle handle;
const char* name;
u32 id;
};
tagSSeInfo::tagSSeInfo() {
}
BOOL m_isLocked;
struct tagSBgmInfo {
tagSBgmInfo() {}
~tagSBgmInfo() {}
nw4r::snd::SoundHandle handle;
tagSBgmInfo();
~tagSBgmInfo();
};
tagSBgmInfo::tagSBgmInfo() {
}
tagSSeInfo::~tagSSeInfo() {
}
tagSBgmInfo::~tagSBgmInfo() {
}
extern nw4r::snd::SoundHandle _bgmBlk;
extern tagSSeInfo _seBlk[16];
extern nw4r::snd::SoundHandle* _mainBGMHandle;
extern "C" asm void __dt__Q33ipl3snd6UnkClsFv() {
nofralloc
lis r3, _seBlk__Q23ipl3snd@ha
lis r4, __dt__Q33ipl3snd10tagSSeInfoFv@ha
addi r3, r3, _seBlk__Q23ipl3snd@l
li r5, 0xc
addi r4, r4, __dt__Q33ipl3snd10tagSSeInfoFv@l
li r6, 0x10
b __destroy_arr
}
tagSSeInfo _seBlk[16];
tagSBgmInfo _bgmBlk;
nw4r::snd::SoundHandle* _mainBGMHandle;
BOOL m_isLocked;
System sSystem;
BannerSoundPlayer sBannerSoundPlayer;
static const nw4r::snd::FxReverbHi::ReverbHiParam reverbHiParam = {
0.0f,
@@ -102,183 +46,6 @@ namespace ipl {
1.0f,
};
void System::stopBGM(int frames) {
if (_mainBGMHandle && _mainBGMHandle->IsAttachedSound()) {
_mainBGMHandle->Stop(frames);
}
}
void System::muteOnBGM(int frames) {
nw4r::snd::SoundHandle* handle = _mainBGMHandle;
if (handle && handle->IsAttachedSound()) handle->SetVolume(0.0f, frames);
}
void System::muteOffBGM(int frames) {
nw4r::snd::SoundHandle* handle = _mainBGMHandle;
if (handle && handle->IsAttachedSound()) handle->SetVolume(1.0f, frames);
}
void System::pauseOnSE() {
for (int index = 0; index < 16; ++index) {
if (_seBlk[index].handle.IsAttachedSound()) {
_seBlk[index].handle.Pause(true, 5);
}
}
}
void System::pauseOffSE() {
for (int index = 0; index < 16; ++index) {
if (_seBlk[index].handle.IsAttachedSound()) {
_seBlk[index].handle.Pause(false, 5);
}
}
}
void System::pauseOnBGM() {
if (_mainBGMHandle) {
if (_mainBGMHandle->IsAttachedSound()) _mainBGMHandle->Pause(true, 5);
pauseOnSE();
sBannerSoundPlayer.pause(true);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_A, 250);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_B, 250);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_C, 250);
}
}
void System::pauseOffBGM() {
if (_mainBGMHandle) {
initFx();
if (_mainBGMHandle->IsAttachedSound()) _mainBGMHandle->Pause(false, 5);
pauseOffSE();
sBannerSoundPlayer.pause(false);
}
}
extern "C" asm void stopSE__Q33ipl3snd6SystemFPQ34nw4r3snd11SoundHandlei() {
nofralloc
stwu r1, -0x30(r1)
mflr r0
stw r0, 0x34(r1)
addi r11, r1, 0x30
bl _savegpr_24
cmpwi r4, 0
mr r24, r4
mr r25, r5
beq stopSE_done
lwz r0, 0(r4)
cmpwi r0, 0
beq stopSE_done
li r26, 0
lis r3, 1
lis r28, _seBlk__Q23ipl3snd@ha
li r31, 0
mr r29, r26
subi r30, r3, 1
addi r28, r28, _seBlk__Q23ipl3snd@l
stopSE_loop:
add r27, r28, r31
cmplw r24, r27
bne stopSE_next
lwz r3, 0(r27)
cmpwi r3, 0
beq stopSE_clear
lwz r12, 0(r3)
mr r4, r25
lwz r12, 0x18(r12)
mtctr r12
bctrl
stopSE_clear:
stw r29, 0x4(r27)
stw r30, 0x8(r27)
stopSE_next:
addi r26, r26, 1
addi r31, r31, 0xc
cmpwi r26, 0x10
blt stopSE_loop
stopSE_done:
addi r11, r1, 0x30
bl _restgpr_24
lwz r0, 0x34(r1)
mtlr r0
addi r1, r1, 0x30
blr
}
extern "C" asm void resetAllSound__Q33ipl3snd6SystemFv() {
nofralloc
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
addi r11, r1, 0x20
bl _savegpr_26
li r26, 0
lis r28, _seBlk__Q23ipl3snd@ha
lis r3, 1
li r31, 0
mr r29, r26
addi r28, r28, _seBlk__Q23ipl3snd@l
subi r30, r3, 1
resetAllSound_loop:
lwzx r3, r28, r31
add r27, r28, r31
cmpwi r3, 0
beq resetAllSound_clear
lwz r12, 0(r3)
li r4, 0
lwz r12, 0x18(r12)
mtctr r12
bctrl
resetAllSound_clear:
stw r29, 0x4(r27)
addi r26, r26, 1
cmpwi r26, 0x10
addi r31, r31, 0xc
stw r30, 0x8(r27)
blt resetAllSound_loop
lwz r3, _mainBGMHandle__Q23ipl3snd
cmpwi r3, 0
beq resetAllSound_banner
lwz r0, 0(r3)
cmpwi r0, 0
beq resetAllSound_banner
lwz r3, 0(r3)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x18(r12)
mtctr r12
bctrl
resetAllSound_banner:
lis r31, sBannerSoundPlayer__Q23ipl3snd@ha
li r4, 0
addi r3, r31, sBannerSoundPlayer__Q23ipl3snd@l
bl stop__17BannerSoundPlayerFUl
bl GetInstance__Q44nw4r3snd6detail9AxManagerFv
li r4, 0
li r5, 0
bl ClearEffect__Q44nw4r3snd6detail9AxManagerFQ34nw4r3snd6AuxBusi
bl GetInstance__Q44nw4r3snd6detail9AxManagerFv
li r4, 1
li r5, 0
bl ClearEffect__Q44nw4r3snd6detail9AxManagerFQ34nw4r3snd6AuxBusi
bl GetInstance__Q44nw4r3snd6detail9AxManagerFv
li r4, 2
li r5, 0
bl ClearEffect__Q44nw4r3snd6detail9AxManagerFQ34nw4r3snd6AuxBusi
bl GetInstance__Q44nw4r3snd6detail9AxManagerFv
lfs f1, lbl_816946A4
li r4, 0
bl SetMasterVolume__Q44nw4r3snd6detail9AxManagerFfi
lfs f1, lbl_816946A4
addi r3, r31, sBannerSoundPlayer__Q23ipl3snd@l
bl setMasterVolume__17BannerSoundPlayerFf
addi r11, r1, 0x20
bl _restgpr_26
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
}
void System::shutup(BOOL shutUpDMA) {
if (m_isLocked == shutUpDMA) {
return;
@@ -315,32 +82,10 @@ namespace ipl {
sBannerSoundPlayer.setMasterVolume(0.9f);
}
extern "C" const f32 lbl_816946A4 = 0.0f;
void System::stopBannerSound(int unk) {
sBannerSoundPlayer.stop(unk);
}
BOOL System::checkTmpSoundFile(void* data, u32 size) {
return sBannerSoundPlayer.checkData(data, size, false);
}
void System::initFx() {
setFxReverbHi(nw4r::snd::AUX_A, &reverbHiParam);
}
#pragma force_active on
}
}
namespace nw4r {
namespace snd {
SoundHandle::SoundHandle() : mSound(NULL) {}
}
}
namespace ipl {
namespace snd {
void System::calc() {
EGG::SimpleAudioMgr::calc();
sBannerSoundPlayer.calc();
@@ -351,9 +96,9 @@ namespace snd {
return NULL;
}
EGG::ArcPlayer::startSound(&_bgmBlk, bgmName);
_mainBGMHandle = &_bgmBlk;
return &_bgmBlk;
EGG::ArcPlayer::startSound(&_bgmBlk.handle, bgmName);
_mainBGMHandle = &_bgmBlk.handle;
return &_bgmBlk.handle;
}
nw4r::snd::SoundHandle* System::startSE(const char* sndName) {
@@ -364,20 +109,9 @@ namespace snd {
}
block = FIsSEActive(sndName);
if (block != NULL && block->handle.GetId() == 0x39) {
goto return_block;
if (block != NULL && block->handle.GetId() == 0x39 || block != NULL && block->handle.GetId() == 0x35) {
return reinterpret_cast<nw4r::snd::SoundHandle*>(block);
}
if (block == NULL) {
goto continue_block;
}
if (block->handle.GetId() != 0x35) {
goto continue_block;
}
return_block:
return reinterpret_cast<nw4r::snd::SoundHandle*>(block);
continue_block:
if (block == NULL) {
block = getFreeSEBlock(true);
}
@@ -400,20 +134,9 @@ namespace snd {
}
block = FIsSEActive(sndIndex);
if (block != NULL && block->handle.GetId() == 0x39) {
goto return_block_index;
if (block != NULL && block->handle.GetId() == 0x39 || block != NULL && block->handle.GetId() == 0x35) {
return (int)block;
}
if (block == NULL) {
goto continue_block_index;
}
if (block->handle.GetId() != 0x35) {
goto continue_block_index;
}
return_block_index:
return (int)block;
continue_block_index:
if (block == NULL) {
block = getFreeSEBlock(true);
}
@@ -422,7 +145,7 @@ namespace snd {
}
block->handle.Stop(0);
mSoundArchivePlayer.StartSound(&block->handle, sndIndex);
EGG::ArcPlayer::startSound(&block->handle, sndIndex);
block->id = sndIndex;
return (int)block;
}
@@ -496,30 +219,51 @@ namespace snd {
block->id = block->handle.GetId();
nw4r::ut::Rect rect;
ipl::System::getProjectionRect4x3(&rect);
f32 pan = x / rect.right;
f32 pan = 0.0f;
pan = x / rect.right;
if (block->handle.detail_GetAttachedSound() != NULL) {
block->handle.detail_GetAttachedSound()->SetPan(pan);
}
f32 pitch = lbl_816946A8 * y / rect.right;
if (lbl_816946AC < pitch) {
pitch = lbl_816946AC;
f32 pitch = 2.0f * y / rect.right;
if (1.0f < pitch) {
pitch = 1.0f;
}
if (block->handle.detail_GetAttachedSound() != NULL) {
block->handle.detail_GetAttachedSound()->SetVolume(pitch, 0);
}
if (lbl_816946B0 < y) {
f32 pitch2 = y / lbl_816946B0;
if (30.0f < y) {
f32 pitch2 = y / 30.0f;
if (block->handle.detail_GetAttachedSound() != NULL) {
block->handle.detail_GetAttachedSound()->SetPitch(pitch2);
}
} else if (lbl_816946B4 < y) {
} else if (60.0f < y) {
if (block->handle.detail_GetAttachedSound() != NULL) {
block->handle.detail_GetAttachedSound()->SetPitch(lbl_816946A8);
block->handle.detail_GetAttachedSound()->SetPitch(2.0f);
}
}
return (int)block;
}
void System::stopBGM(int frames) {
if (_mainBGMHandle && _mainBGMHandle->IsAttachedSound()) {
_mainBGMHandle->Stop(frames);
}
}
void System::stopSE(nw4r::snd::SoundHandle* handle, int unk) {
int i;
if (handle != NULL && handle->IsAttachedSound()) {
for (i = 0; i < 16; i++) {
if (handle == &_seBlk[i].handle) {
_seBlk[i].handle.Stop(unk);
_seBlk[i].name = NULL;
_seBlk[i].id = 0xffff;
}
}
}
}
void System::stopAllSound(int unk) {
int frame;
tagSSeInfo* block;
@@ -543,6 +287,73 @@ namespace snd {
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_C, frame);
}
void System::resetAllSound() {
int i = 0;
for (; i < 16; i++) {
_seBlk[i].handle.Stop(0);
_seBlk[i].name = NULL;
_seBlk[i].id = 0xffff;
}
if (_mainBGMHandle != NULL && _mainBGMHandle->IsAttachedSound()) {
_mainBGMHandle->detail_GetAttachedSound()->Stop(0);
}
sBannerSoundPlayer.stop(0);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_A, 0);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_B, 0);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_C, 0);
nw4r::snd::detail::AxManager::GetInstance().SetMasterVolume(0.0f, 0);
sBannerSoundPlayer.setMasterVolume(0.0f);
}
void System::muteOnBGM(int frames) {
nw4r::snd::SoundHandle* handle = _mainBGMHandle;
if (handle && handle->IsAttachedSound()) handle->SetVolume(0.0f, frames);
}
void System::muteOffBGM(int frames) {
nw4r::snd::SoundHandle* handle = _mainBGMHandle;
if (handle && handle->IsAttachedSound()) handle->SetVolume(1.0f, frames);
}
void System::pauseOnBGM() {
if (_mainBGMHandle) {
if (_mainBGMHandle->IsAttachedSound()) _mainBGMHandle->Pause(true, 5);
pauseOnSE();
sBannerSoundPlayer.pause(true);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_A, 250);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_B, 250);
nw4r::snd::detail::AxManager::GetInstance().ClearEffect(nw4r::snd::AUX_C, 250);
}
}
void System::pauseOffBGM() {
if (_mainBGMHandle) {
initFx();
if (_mainBGMHandle->IsAttachedSound()) _mainBGMHandle->Pause(false, 5);
pauseOffSE();
sBannerSoundPlayer.pause(false);
}
}
void System::pauseOnSE() {
for (int index = 0; index < 16; ++index) {
if (_seBlk[index].handle.IsAttachedSound()) {
_seBlk[index].handle.Pause(true, 5);
}
}
}
void System::pauseOffSE() {
for (int index = 0; index < 16; ++index) {
if (_seBlk[index].handle.IsAttachedSound()) {
_seBlk[index].handle.Pause(false, 5);
}
}
}
void System::setOutputMode(EAudioOutputMode mode) {
nw4r::snd::OutputMode outputMode;
@@ -624,6 +435,14 @@ namespace snd {
return sBannerSoundPlayer.start(data, size);
}
void System::stopBannerSound(int unk) {
sBannerSoundPlayer.stop(unk);
}
BOOL System::checkTmpSoundFile(void* data, u32 size) {
return sBannerSoundPlayer.checkData(data, size, false);
}
long System::clipGELT_S32(long value, long lo, long hi) {
long range = hi - lo;
@@ -642,5 +461,15 @@ namespace snd {
return value;
}
} // namespace snd
} // namespace ipl
inline System::System() {
}
}
}
namespace nw4r {
namespace snd {
inline SoundHandle::SoundHandle() : mSound(NULL) {}
}
}

View File

@@ -884,56 +884,65 @@ namespace ipl {
return ret;
}
static char FUNC_VERIFY_SAVEDATA_ZD[] = "verifySavedataZD";
static char FUNC_DELETE_TICKETS_FORCE[] = "DeleteTicketsForce";
static char FUNC_INIT_SAVEDATA[] = "InitSavedata";
void ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
u32 titleCount = 0;
ESTitleId* titleIds = NULL;
char path[88];
NANDFileInfo fileInfo ALIGN32;
u8 ticketViews[0xe0] ALIGN32;
NANDFileInfo fileInfo ALIGN32;
u32 ticketViewCount;
ESTicketView* ticketViewList;
s32 ret = ES_ListTitlesOnCard(NULL, &titleCount);
if (ret == ES_ERR_OK) {
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, FUNC_INIT_SAVEDATA, ret);
} else {
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(titleCount * sizeof(ESTitleId)), -DEFAULT_ALIGN);
if (titleIds == NULL) {
OSReport("%s::%s: Unable to allocate\n", __FILE__, "InitSavedata");
OSReport("%s::%s: Unable to allocate\n", __FILE__, FUNC_INIT_SAVEDATA);
} else {
ret = ES_ListTitlesOnCard(titleIds, &titleCount);
if (ret == ES_ERR_OK) {
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, FUNC_INIT_SAVEDATA, ret);
} else {
u32 titleIdOffset = 0;
for (u32 i = 0; i < titleCount; i++) {
u32 titleIdHi = *(u32*)((u8*)titleIds + titleIdOffset);
u32 titleIdLo = *(u32*)((u8*)titleIds + titleIdOffset + 4);
if ((titleIdLo & 0xffffff00) == 0x525a4400 && titleIdHi == 0x10000) {
if (((((ESTitleId)titleIdHi << 32) | titleIdLo) & 0xFFFFFFFFFFFFFF00ULL) ==
0x00010000525a4400ULL) {
u8* saveData = NULL;
BOOL fileOpen = FALSE;
BOOL deleteSaveData = FALSE;
sprintf(path - 8, "/title/%08x/%08x/data/%s", titleIdHi & 0xffffff, titleIdLo, "zeldaTp.dat");
sprintf(path, "/title/%08x/%08x/data/%s", titleIdHi & 0xffffff, titleIdLo, "zeldaTp.dat");
if (!ChangeUid(((ESTitleId)titleIdHi << 32) | titleIdLo)) {
OSReport("%s::%s: ChangeUid failed\n", __FILE__, "verifySavedataZD");
OSReport("%s::%s: ChangeUid failed\n", __FILE__, FUNC_VERIFY_SAVEDATA_ZD);
DeleteTitle(heap, ((ESTitleId)titleIdHi << 32) | titleIdLo);
} else {
ret = NANDPrivateOpen(path - 8, (NANDFileInfo*)((u8*)&fileInfo - 0x20), NAND_ACCESS_READ);
ret = NANDPrivateOpen(path, &fileInfo, NAND_ACCESS_READ);
if (ret == NAND_RESULT_NOEXISTS) {
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, "verifySavedataZD", path - 8, ret);
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, FUNC_VERIFY_SAVEDATA_ZD, path, ret);
} else if (ret != NAND_RESULT_OK) {
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, "verifySavedataZD", ret);
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, FUNC_VERIFY_SAVEDATA_ZD, ret);
} else {
fileOpen = TRUE;
saveData = (u8*)heap->alloc(0x4000, -DEFAULT_ALIGN);
if (saveData == NULL) {
OSReport("%s::%s: Alloc failed: %d\n", __FILE__, "verifySavedataZD", -2);
OSReport("%s::%s: Alloc failed: %d\n", __FILE__, FUNC_VERIFY_SAVEDATA_ZD, -2);
} else {
memset(saveData, 0, 0x4000);
ret = NANDRead((NANDFileInfo*)((u8*)&fileInfo - 0x20), saveData, 0x4000);
ret = NANDRead(&fileInfo, saveData, 0x4000);
if (ret < 0) {
OSReport("%s::%s: Read file failed: %d\n", __FILE__, "verifySavedataZD", ret);
OSReport("%s::%s: Read file failed: %d\n", __FILE__, FUNC_VERIFY_SAVEDATA_ZD, ret);
} else if (ret != 0x4000) {
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, "verifySavedataZD", ret);
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, FUNC_VERIFY_SAVEDATA_ZD, ret);
deleteSaveData = TRUE;
} else {
u32 offset = 8;
@@ -973,13 +982,13 @@ namespace ipl {
verify_failed:
if (!valid) {
OSReport("%s::%s: Verify failed for %016llx\n", __FILE__, "verifySavedataZD",
OSReport("%s::%s: Verify failed for %016llx\n", __FILE__, FUNC_VERIFY_SAVEDATA_ZD,
((ESTitleId)titleIdHi << 32) | titleIdLo);
deleteSaveData = TRUE;
}
}
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
NANDClose(&fileInfo);
fileOpen = FALSE;
if (deleteSaveData) {
DeleteSavedata(((ESTitleId)titleIdHi << 32) | titleIdLo, heap);
@@ -992,20 +1001,29 @@ namespace ipl {
heap->free(saveData);
}
if (fileOpen) {
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
NANDClose(&fileInfo);
}
ChangeUid(SYSMENU_TITLE_ID);
continue;
}
if ((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844495343ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) < 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100014a4f4449ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x000100014a4f4449ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000148415858ULL))) ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844564458ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844564458ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100084449534bULL)))) {
{
ESTitleId selTitleId = ((ESTitleId)titleIdHi << 32) | titleIdLo;
if (selTitleId == 0x0001000844495343ULL) {
goto deleteTitle;
} else if (selTitleId < 0x0001000844495343ULL) {
if (selTitleId == 0x000100014a4f4449ULL ||
(selTitleId > 0x000100014a4f4449ULL && selTitleId == 0x0001000148415858ULL)) {
goto deleteTitle;
}
} else {
if (selTitleId == 0x0001000844564458ULL ||
(selTitleId > 0x0001000844564458ULL && selTitleId == 0x000100084449534bULL)) {
goto deleteTitle;
}
}
}
goto keepTitle;
deleteTitle: {
ESTitleId titleId = *(ESTitleId*)((u8*)titleIds + titleIdOffset);
ES_DeleteTitle(titleId);
@@ -1013,18 +1031,18 @@ namespace ipl {
memset(ticketViews, 0, sizeof(ticketViews));
ret = ES_GetTicketViews(titleId, NULL, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, FUNC_DELETE_TICKETS_FORCE, ret, titleId);
} else if (ticketViewCount != 0) {
ticketViewList = (ESTicketView*)heap->alloc(ticketViewCount * 0xe0, -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, FUNC_DELETE_TICKETS_FORCE, ret, titleId);
} else {
for (u32 j = 0; j < ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), 0xd8);
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret,
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, FUNC_DELETE_TICKETS_FORCE, ret,
((ESTicketView*)ticketViews)->ticketId);
}
}
@@ -1034,16 +1052,13 @@ namespace ipl {
if (ticketViewList != NULL) {
heap->free(ticketViewList);
}
}
}
keepTitle:
titleIdOffset += 8;
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, "InitSavedata", ret);
}
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, "InitSavedata", ret);
}
if (titleIds != NULL) {

View File

@@ -0,0 +1,13 @@
## singles leaf session
- .bss 100% via OSThreadQueue queue member in UpdateThreadData (Thread size 0x1320 -> UH0 at 0x2320). Keep separate globals, NOT an enclosing struct: a struct forces a single base symbol and perturbs all member-address codegen; orig has separate globals and MWCC reuses Flags0's homed base reg for +0x800/+0x2320 offsets.
- .sdata 100% via "." (not "-") region suffix strcats.
- E/D region check: `!(x != 'E' && x != 'D')` defeats MWCC adjacent-value range fusion (subi+cmplwi 1) and reproduces orig's shared li r0,1 arm exactly.
- UpdateWork-struct + w-> pointer locals: REGRESSION (-11 fuzzy); reverted.
- Remaining .text gaps = const-home/remat policy: orig homes lis 0x8048 (disc base) + zero/one consts in callee regs and remats `add base,byteoff` per access site (~+50 insns); MWCC folds to subis + CSE'd entry ptrs. Same RA-pinning wall as fa-file/scene2 units.
## singles2 wave (w0929)
- `u32* flags = Flags0;` local + `memset(&flags[512],0,sizeof(Flags1))` gives base's single-home form (`lis r30,Flags0; addi r3,r30,0x800`; `&Thread.thread`/`stack` fold to `r30+0x1000/+0x1318`, no relocs — same-section delta folding). Init now 72/72 insns.
- Residual: base commits 3 callee regs (`_savegpr_29`: r29=arg, r30=flags, r31=strbase) and materializes flags EARLY (insn6) so ranges overlap; MWCC reuses r31 (arg→flags) here → manual stw pair. No source lever found for the early home (decl/`register`/derived-ptr all tested).
- UpdateThread 908/913 — base pins a const-zero callee reg (r15) for stack-local stores; extra stw/lwz spill pairs = store-forward wall.
- Separate globals (Flags0/Flags1/Thread) is the correct model — base symtab proves it; a union/struct also folds but perturbs other fns less predictably.

View File

@@ -0,0 +1,36 @@
# iplESMisc.cpp — attempts log (singles leaf)
Final state: .data 100%, .sdata 98.41 (tail-pad artifact: orig's last
`.sdata` object absorbs one pad byte — contents identical), .text 97.70,
30/31 fns. Only `DeleteUnauthorizedData` (85.6) is sub-100.
## Verified decodes
- **`.data` string pool now byte-identical.** Orig emits the three
fn-name strings `verifySavedataZD`, `DeleteTicketsForce`,
`InitSavedata` before all of `DeleteUnauthorizedData`'s message
literals: reproduced with three namespace-scope
`static char FUNC_*[]` decls (non-const → `.data` at decl position;
`const` goes to `.rodata`). Callsite literals pass the named objects —
codegen identical (`addi rX, pool+off` either way).
- **`DeleteUnauthorizedData` structure:** orig's literal order is
Card1-fail → alloc-fail → Card2-fail → loop strings, i.e. a flat
`if (ret != ES_ERR_OK) { OSReport(Card1) } else { alloc; if NULL
{alloc-report} else { list2; if (ret != ES_ERR_OK) {OSReport(Card2)}
else { loop } } }` head, not nested `== ES_ERR_OK` wrapping.
- **Local layout:** `path[88]`@0x28, `ticketViews[0xe0]`@0x80 (homed
r29), `fileInfo`@0x160 — decl order path → ticketViews → fileInfo.
No `path - 8` / `&fileInfo - 0x20` compensations needed.
- **`main.dol` tail of `.data`:** orig's last object absorbs 6 bytes of
section-alignment pad — extraction artifact, bytes identical.
## Unresolved
- **`DeleteUnauthorizedData` 85.6** (449 vs 434 insns): residual
regalloc noise (r21-vs-r26 pool home, `ret` homed r27 in orig via
`mr r27,r3` after each call vs direct r3), the zelda-check `&&` fusion
(orig `xor`/`or.` single-branch; mine two `cmplwi`+2 `bne`; `&` on
bools produced `cntlzw`+`and` — worse, reverted), 64-bit title-id
chain codegen order, and MWCC strength-reducing my
`*(u32*)((u8*)titleIds + titleIdOffset)` into a pointer-walk
(`addi r30,8`/iter) vs orig's `lwzx base,offset`.

View File

@@ -0,0 +1,54 @@
# iplSound.cpp — attempts log (singles leaf)
Final state: .text 98.98 fuzzy; 55/57 fns instruction-identical after
name-stripping. .ctors/.data/.rodata/.sbss/.sdata2 all 100%. .bss 70.65
(symbol-extent artifact, contents byte-identical).
## Verified decodes
- **Weak-fn emission order = first-ODR-use.** Weak copies of in-class /
inline defs emit immediately after their first non-inlinable user;
trivial inlines and vtable-driven emissions defer to the end.
- **`_seBlk` decode:** orig's named `__dt__Q33ipl3snd6UnkClsFv` thunk
requires `_seBlk` to be a global of `struct UnkCls { tagSSeInfo blk[16]; }`
with an implicit dtor (emits `b __destroy_arr` thunk). A raw
`tagSSeInfo _seBlk[16]` or `typedef ... UnkCls[16]` instead emits
auto-named `__arraydtor$NNNN`.
- **`EGG::ArcPlayer::startSound(&handle, idx)`** (qualified call to the
virtual at slot 0x34) suppresses virtual dispatch, inlines to
`detail_StartSound`, and emits its weak copy at first-use position
(right after `startSEIndex` in orig).
- **startSE/startSEIndex redundant `block` re-test:** orig re-tests
`cmpwi block; beq` between two `GetId()` checks — written as
`(block != NULL && GetId()==0x39) || (block != NULL && GetId()==0x35)`:
two `&&` clauses in one `||`, single shared return-block tail. Nested
`if` adds insns; single `||` drops the re-test.
- **`.sdata2` literal order = parse order:** a dead
`f32 pan = 0.0f; pan = x/rect.right;` in `holdSEwithPosDis` creates the
0.0f literal early (MWCC folds the dead store, keeps the literal) —
reproduces orig order [0.9, 0.0, 2.0, 1.0, 30, 60] exactly.
- **`stopSE`/`resetAllSound` are `void`** in orig (no `li r3,0` epilogue);
header changed `int`→`void`. `stopSE` loop compare is
`handle == &_seBlk[i].handle` (operand order → `cmplw r24,r27`).
- **`__sinit` register sequence:** `__construct_array(_seBlk)` →
`__register_global_object(0, ~UnkCls, record@0)` → `~tagSBgmInfo`/`_bgmBlk`
(record@0xCC) → `~System` (record@0xD8) → `~BannerSoundPlayer`
(record@0x710).
## Unresolved
- **`__ct__Q33ipl3snd6UnkClsFv` extra weak emit (+~0x4C).** The implicit
ctor for `UnkCls _seBlk` emits a weak copy in mine; orig has none.
Tried: implicit ctor, `UnkCls() {}`, `~UnkCls() {}`, typedef array,
removing `#pragma force_active on` — still emits. Likely MWCC-version
emission difference.
- **`__dt__Q34nw4r2ut11NonCopyableFv` extra weak emit (+~0x3C).**
`~NonCopyable() {}` in `libs/NW4R/include/nw4r/ut/inlines.h` is
ODR-used via `~SoundHandle` base-dtor call. Removing it removes the
emit but cascades: `tagSSeInfo`/`SoundHandle` become trivially
destructible → `__sinit` switches `bl __construct_array` to
`bl __ct__UnkCls` and regresses further. Reverted.
- **`.bss` 70.65%:** byte-identical layout; orig's symbols.txt extends
`_seBlk`=0xD8 / `sSystem`=0x63C over MWCC's `__register_global_object`
chain-record slots and omits `...bss.N` record symbols — pure
symbol-extent artifact, no source lever.