Compare commits

...

3 Commits

Author SHA1 Message Date
Devin AI
de9d58946d scene2: iplSDChannelSelect 112/129 fns (12 enqueue fns matched via values[2] removal, collectTitlesBySpecialChannels 361/361); kpr_lib once-union .sbss 100%; HermiteIntp<VEC3> template specialization decode; documented setEventHandler r5 + findAdjacentChannel ties
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-01 04:48:53 +00:00
Devin AI
66601d82d3 kpr + cdb: KPRProcessDeadKeys byte-identical, CDBIntArray flip to Matching
KPRProcessDeadKeys: u32 secondFallback (cmplwi), uninitialized firstFallback
(orig has no init insn), queue->text reads inlined (no 'first' local) - 90=90
byte-identical. KPRProcessAltKeypad: def-order fix for accumulator/leadingZero
homes (18 regname hunks remain - documented tie-break). .sbss layout decode:
fn-local statics emit first, file statics reverse-decl-order; orig's once is
file-scope-first but that breaks InitQueue scheduling - kept fn-local.
CDBIntArray objdiff 100% whole-unit - flip to Object(Matching).

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-01 03:49:56 +00:00
Devin AI
d09760ef8c cdb: CDBRecord dead-helper emission decode - data byte-identical, 28/29 fns
Decode MWCC literal-emission model: non-static dead fns emit literals at
def position (link-stripped in orig), statics emit at first-call. All
dead helper strings (reduce/setFileType/getFileType/gameCode/makerCode/
modifiedTime/modifiedCount/setName/getKeyword/getKey/calenderTime/
duplicate-panic/changeOwner-debug) now emit at exact orig offsets -
.data is byte-identical mod extraction tail pad.

Encrypt remains a register-home permutation tie-break (153 regname
diffs, instruction-count-equal): orig homes .data base in r25 vs r31,
params shifted by one.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-01 03:33:58 +00:00
9 changed files with 403 additions and 88 deletions

View File

@@ -1025,7 +1025,7 @@ config.libs = [
Object(NonMatching, "cdb/CDBRecord.c"),
Object(Matching, "cdb/CDBRecordFile.c"),
Object(Matching, "cdb/CDBRecordKey.c"),
Object(NonMatching, "cdb/CDBIntArray.c"),
Object(Matching, "cdb/CDBIntArray.c"),
Object(Matching, "cdb/CDBSystem.c"),
Object(Matching, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBFBridge.c"),

View File

@@ -225,6 +225,46 @@ namespace ipl {
};
#endif
#ifdef IPL_SD_CHANNEL_SELECT_CPP
} // namespace math
} // namespace ipl
#include "math/iplMathTypes.h"
namespace ipl {
namespace math {
template <>
class HermiteIntp<VEC3> : public utility::FrameController {
public:
HermiteIntp() {}
virtual ~HermiteIntp();
void init(const VEC3& start, const VEC3& end, f32 maxFrame, f32 param_5, f32 param_6, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f);
VEC3 get() const {
f32 frame = mFrame;
f32 inverseDuration = 1.0f / mMaxFrame;
VEC3 result =
(mStart * (1.0f + (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))))) -
(mEnd * (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))));
f32 frameSquared = frame * frame;
f32 cubic = inverseDuration * (inverseDuration * (frame * frameSquared));
f32 tangent = unkVal0 * (frame + (cubic -
inverseDuration * (2.0f * frame * frame))) +
unkVal1 * (cubic - inverseDuration * frameSquared);
result.x += tangent;
result.y += tangent;
result.z += tangent;
return result;
}
protected:
VEC3 mStart;
VEC3 mEnd;
f32 unkVal0;
f32 unkVal1;
};
#endif
} // namespace math
} // namespace ipl

View File

@@ -156,10 +156,10 @@ void KPRInitRegionUS(void) {
}
void KPRInitQueue(KPRQueue* queue) {
static u8 once;
if (!once) {
static union { u64 align; u8 flag; } once;
if (!once.flag) {
OSRegisterVersion(__KPRVersion);
once = TRUE;
once.flag = TRUE;
}
queue->mode = KPR_MODE_ALT_KEYPAD;
queue->oCount = 0;
@@ -244,10 +244,9 @@ u8 KPRLookAhead(KPRQueue* queue, u16* destination, u32 capacity) {
BOOL KPRProcessAltKeypad(KPRQueue* queue, u16 character) {
if (queue->altVal != 0) {
u32 leadingZero = queue->altVal & 0x80000000;
u32 accumulator = queue->altVal;
u32 accumulator = queue->altVal & 0x7FFFFFFF;
u32 value;
accumulator &= 0x7FFFFFFF;
u32 leadingZero = queue->altVal & 0x80000000;
queue->altVal = accumulator;
if (character >= 0xF130 && character <= 0xF139) {
if (accumulator > 0x6666666) {
@@ -302,7 +301,7 @@ BOOL KPRProcessAltKeypad(KPRQueue* queue, u16 character) {
void KPRProcessDeadKeys(KPRQueue* queue) {
int index;
int firstFallback;
int secondFallback;
u32 secondFallback;
if (queue->iCount == 1) {
for (index = 0; index < 107; ++index) {
if (queue->text[queue->oCount] == kprDeadKeyMap[index].accent) {
@@ -313,17 +312,15 @@ void KPRProcessDeadKeys(KPRQueue* queue) {
queue->iCount = 0;
return;
}
firstFallback = 0;
secondFallback = 107;
for (index = 0; index < 107; ++index) {
u16 first = queue->text[queue->oCount];
if (first == kprDeadKeyMap[index].accent && queue->text[queue->oCount + 1] == kprDeadKeyMap[index].base) {
if (queue->text[queue->oCount] == kprDeadKeyMap[index].accent && queue->text[queue->oCount + 1] == kprDeadKeyMap[index].base) {
queue->text[queue->oCount] = kprDeadKeyMap[index].composed;
queue->iCount = 0;
++queue->oCount;
return;
}
if (first == kprDeadKeyMap[index].accent && first == kprDeadKeyMap[index].base) {
if (queue->text[queue->oCount] == kprDeadKeyMap[index].accent && queue->text[queue->oCount] == kprDeadKeyMap[index].base) {
firstFallback = index;
}
if (queue->text[queue->oCount + 1] == kprDeadKeyMap[index].accent && queue->text[queue->oCount + 1] == kprDeadKeyMap[index].base) {

View File

@@ -48,6 +48,10 @@ CDBErr CDBRecordOpenReadOnly_(CDBRecord* record);
CDBErr CDBRecordClose_(CDBRecord* record);
CDBErr CDBRecordWrite_(CDBRecord* record, void* buffer, u32 size);
CDBErr CDBRecordRemove_(CDBRecord* record);
CDBErr CDBRecordGetFileSize_(CDBRecord* record, u32* size);
void CDBRecordDuplicate_(CDBRecord* dst, CDBRecord* src);
void CDBRecordPrivateChangeOwner_(CDBRecord* record, CDBRecordKey* key);
CDBErr CDBRecordBackupToSD_(CDBRecord* record);
CDBErr CDBRecordUpdateModifiedDate(CDBRecord* record);
CDBErr CDBRecordEncrypt(CDBRecord* record, void* buffer, CDBRecordKey* key, u32 size, u32* encryptedSize);
@@ -367,6 +371,19 @@ CDBErr CDBRecordSeek(CDBRecord* record, s32 offset, CDBSeek seek) {
return err;
}
CDBErr CDBRecordGetFileSize_(CDBRecord* record, u32* size) {
CDBErr err;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get file size of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
err = CDBRecordFileGetFileSize(record, size);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetDataSize(CDBRecord* record, u32* size) {
CDBErr err;
CDBLock();
@@ -380,6 +397,44 @@ CDBErr CDBRecordGetDataSize(CDBRecord* record, u32* size) {
return err;
}
CDBErr CDBRecordReduceFileSize_(CDBRecord* record, u32 size) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't reduce file size of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else if ((((CDBRecordDatabaseState*)((CDBDatabase*)record->unk_0x00)->instance)->openFlags & 2) == 0) {
CDBReportError("can't reduce file size of the record ; the record is opened as READONLY\n");
err = CDB_ERROR_26;
} else if (size <= CDB_RECORD_BUFFER_SIZE) {
CDBReportError("can't reduce file size of the record ; file size must be over %d bytes\n", CDB_RECORD_BUFFER_SIZE);
err = CDB_ERROR_1;
} else {
CDBAttrSetFileSize(&((CDBRecordFile*)record->file)->attr, size);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordReduceDataSize_(CDBRecord* record, u32 size) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't reduce data size of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else if ((((CDBRecordDatabaseState*)((CDBDatabase*)record->unk_0x00)->instance)->openFlags & 2) == 0) {
CDBReportError("can't reduce data size of the record ; the record is opened as READONLY\n");
err = CDB_ERROR_26;
} else if (!CDBRecordBelongedDBOpenedAsRW(record)) {
CDBReportError("can't reduce data size of the record; permission denied\n");
err = CDB_ERROR_ACCESS_DENIED;
} else {
CDBAttrSetFileSize(&((CDBRecordFile*)record->file)->attr, size + CDB_RECORD_BUFFER_SIZE);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordRemove(CDBRecord* record) {
CDBErr err;
CDBLock();
@@ -411,6 +466,155 @@ CDBErr CDBRecordRemove_(CDBRecord* record) {
return result;
}
CDBErr CDBRecordSetFileType_(CDBRecord* record, u32 type) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if ((((CDBRecordDatabaseState*)((CDBDatabase*)record->unk_0x00)->instance)->openFlags & 2) == 0) {
CDBReportError("can't set file type of the record; the database is opened as READONLY\n");
err = CDB_ERROR_26;
} else if (record->file == NULL) {
CDBReportError("can't set file type of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else if ((((CDBRecordFile*)record->file)->unk_0x1C) == 1) {
CDBReportError("can't set file type of the record ; the record is opened as READONLY\n");
err = CDB_ERROR_26;
} else if (record->key.location != CDB_FS_LOCATION_NAND) {
CDBReportError("can't set file type of the record ; the record must exsist on NAND\n");
err = CDB_ERROR_2;
} else {
CDBAttrSetFileType(&((CDBRecordFile*)record->file)->attr, type);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetFileType_(CDBRecord* record, u32* type) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get file type of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBAttrGetFileType(&((CDBRecordFile*)record->file)->attr, type);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetGameCode_(CDBRecord* record, char* gameCode) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get game code of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBAttrGetGameCode(&((CDBRecordFile*)record->file)->attr, gameCode);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetMakerCode_(CDBRecord* record, char* makerCode) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get maker code of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBAttrGetMakerCode(&((CDBRecordFile*)record->file)->attr, makerCode);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetModifiedTime_(CDBRecord* record, u32* modifiedTime) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get modified time of the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBAttrGetModifiedDate(&((CDBRecordFile*)record->file)->attr, modifiedTime);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetModifiedCount_(CDBRecord* record, u32* modifiedCount) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get modified count of the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
err = CDBAttrGetModifiedCount(&((CDBRecordFile*)record->file)->attr, modifiedCount);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordSetName_(CDBRecord* record, const char* name) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if ((((CDBRecordDatabaseState*)((CDBDatabase*)record->unk_0x00)->instance)->openFlags & 2) == 0) {
CDBReportError("can't set a name of the record; the database is opened as READONLY\n");
err = CDB_ERROR_26;
} else if (!CDBRecordBelongedDBOpenedAsRW(record)) {
CDBReportError("can't add keyword to the record; permission denied\n");
err = CDB_ERROR_ACCESS_DENIED;
} else if (record->file == NULL) {
CDBReportError("can't set a name of the record; the record is closed\n");
err = CDB_ERROR_27;
} else if ((((CDBRecordFile*)record->file)->unk_0x1C) == 1) {
CDBReportError("can't set a name of the record; the record is opened as READONLY\n");
err = CDB_ERROR_26;
} else {
CDBAttrSetName(&((CDBRecordFile*)record->file)->attr, name);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetKeyword_(CDBRecord* record, char* keyword) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get keyword from the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBAttrGetKeyword(&((CDBRecordFile*)record->file)->attr, keyword);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetKey_(CDBRecord* record, CDBRecordKey* key) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get key from the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBRecordKeyCopy(key, &((CDBRecordFile*)record->file)->key);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetCalenderTime_(CDBRecord* record, OSCalendarTime* time) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get calender time from the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBAttrGetCalenderTime(&((CDBRecordFile*)record->file)->attr, time);
}
CDBUnlock();
return err;
}
void CDBRecordGetTypeForce(CDBRecord* record, char* type) {
CDBLock();
CDBConvKeyStrToType(record->key.keyString, type);
@@ -455,7 +659,7 @@ CDBErr CDBRecordGetId(CDBRecord* record, CDBId* id) {
} else {
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get CDBId of the record ; the record is closed\n");
CDBReportError("can't get maker code of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBLock();
@@ -519,6 +723,17 @@ CDBErr CDBRecordUpdateModifiedDate(CDBRecord* record) {
return CDB_ERROR_OK;
}
void CDBRecordDuplicate_(CDBRecord* dst, CDBRecord* src) {
CDBRecordKeyCopy(&dst->key, &src->key);
dst->unk_0x00 = src->unk_0x00;
dst->file = src->file;
dst->cryptBuf = src->cryptBuf;
}
void CDBRecordDuplicatePanic_(void) {
OSPanic(__FILE__, __LINE__, "CDBRecordDuplicate invalud location\n");
}
CDBErr CDBRecordBackupToSD(CDBRecord* record) {
CDBErr err;
CDBLock();
@@ -600,10 +815,7 @@ CDBErr CDBRecordBackupToSD_(CDBRecord* record) {
}
CDBLock();
recordFile = localRecord.file;
CDBRecordKeyCopy(&record->key, &localRecord.key);
record->unk_0x00 = localRecord.unk_0x00;
record->file = localRecord.file;
record->cryptBuf = localRecord.cryptBuf;
CDBRecordDuplicate_(record, &localRecord);
CDBRecordKeyCopy(&recordFile->key, &localRecord.key);
CDBUnlock();
return CDB_ERROR_OK;
@@ -723,14 +935,7 @@ CDBErr CDBRecordEncrypt(CDBRecord* record, void* buffer, CDBRecordKey* key, u32
return CDB_ERROR_OK;
}
}
CDBLock();
if ((s32)record->file == 0) {
CDBReportError("can't get file size of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
err = CDBRecordFileGetFileSize(record, &fileSize);
}
CDBUnlock();
err = CDBRecordGetFileSize_(record, &fileSize);
CDBAttrSetFileSize(&recordFile->attr, fileSize);
if (err != CDB_ERROR_OK) {
return CDB_ERROR_OK;
@@ -814,6 +1019,19 @@ CDBErr CDBRecordEncrypt(CDBRecord* record, void* buffer, CDBRecordKey* key, u32
return CDB_ERROR_OK;
}
void CDBRecordPrivateChangeOwner_(CDBRecord* record, CDBRecordKey* key) {
CDBReport_(3);
OSReport("\x83\x74\x83\x40\x83\x43\x83\x8B\x96\xBC\x82\xCC\x89\xFC\xE2\x82\x82\xF0\x8C\x9F\x8F\x6F\n");
}
void CDBRecordPrivateChangeOwnerDebug_(CDBRecord* record, CDBRecordKey* key) {
OSReport("CDBRecordPrivateChangeOwner\n");
OSReport(" i_pre-wiiid = %lX\n", key->wiiId);
OSReport(" record-wiiid = %lX\n", record->key.wiiId);
OSReport("path =%s\n", (char*)key);
OSReport("path2=%s\n", (char*)&record->key);
}
CDBErr CDBRecordDecrypt(CDBRecord* record, void* buffer, u32 size, u32* dataSize, CDBRecordKey* key) {
CDBErr status;
int fileOffset;
@@ -821,9 +1039,9 @@ CDBErr CDBRecordDecrypt(CDBRecord* record, void* buffer, u32 size, u32* dataSize
u32 fileDataSize;
u32 fileSize;
u8 iv[16];
CDBRecordKey comparisonKey;
u8 digest[20] ATTRIBUTE_ALIGN(64);
u8 wiiIdKey[64] ATTRIBUTE_ALIGN(16);
CDBRecordKey comparisonKey;
NETHMACContext hmac;
CDBAttrSignature signature;
@@ -932,8 +1150,7 @@ CDBErr CDBRecordDecrypt(CDBRecord* record, void* buffer, u32 size, u32* dataSize
CDBAttrGetKeyStr((CDBAttr*)buffer, comparisonKey.keyString);
if (CDBRecordKeyCompareByDate(&comparisonKey, &record->key) != 0) {
if (CDBIsPrintDebugMessage(3)) {
CDBReport_(3);
OSReport("CDBRecordPrivateChangeOwner\n");
CDBRecordPrivateChangeOwner_(record, key);
}
return CDB_ERROR_32;
}

View File

@@ -54,7 +54,7 @@ namespace ipl {
void writeFourFlagBytes(u8* flags, u8 first, u8 second, u8 third, u8 fourth);
void setTitleRowColors(nw4r::lyt::TextBox* textBox, const nw4r::ut::Color& first,
const nw4r::ut::Color& second);
const nw4r::ut::Color& second) NO_INLINE;
static const char* sControlPaneNames[] = {
"A", "B", "B_BtnA",
@@ -1141,13 +1141,15 @@ namespace ipl {
void SDMemory::onDialogState21() {
const wchar_t* message = System::getMessage(mMessageId);
const wchar_t* blockCountMarker = wcsstr(message, L"***\n");
const wchar_t* blockCountMarker = wcsstr(message, L"****");
wchar_t* format = new (System::getMem2App(), -32) wchar_t[0x400];
wchar_t* dialogMessage = new (System::getMem2App(), -32) wchar_t[0x400];
if (blockCountMarker != NULL && message != NULL) {
format[0] = L'\0';
wcsncat(format, message, static_cast<u32>(blockCountMarker - message));
memset(format + 1, 1, 0);
wcsncat(format, message,
(reinterpret_cast<u32>(blockCountMarker) - reinterpret_cast<u32>(message)) >> 1);
wcscat(format, L"%d");
wcscat(format, blockCountMarker + 4);
@@ -1251,7 +1253,10 @@ namespace ipl {
void SDMemory::drawTransferTitles() {
const nw4r::math::VEC3& translation = mpDialogLayout->FindPaneByName("N_Memo")->GetTranslate();
nw4r::math::VEC3 memoPosition(translation.x, translation.y, translation.z);
nw4r::math::VEC3 memoPosition;
memoPosition.x = translation.x;
memoPosition.y = translation.y;
memoPosition.z = translation.z;
mpDialogLayout->FindPaneByName("header_header");
nw4r::lyt::Pane* bodyPane = mpDialogLayout->FindPaneByName("header_body");
@@ -1284,7 +1289,8 @@ namespace ipl {
mpDialogLayout->FindPaneByName("T_Header_body"));
s32 totalLines = lineCount + 1;
s32 lineIndex = 0;
while (lineIndex < totalLines) {
if (lineIndex < totalLines) {
do {
const wchar_t* lineEnd = wcsstr(messageLine, L"\n");
if (lineEnd == NULL) {
utility::layout::set_string(messageText, messageLine);
@@ -1305,6 +1311,7 @@ namespace ipl {
messageOffset -= bodyHeight;
++lineIndex;
} while (lineIndex < totalLines);
}
}
@@ -1328,14 +1335,20 @@ namespace ipl {
for (u32 titleIndex = 0; titleIndex < mTitleCount; ++titleIndex) {
utility::layout::set_string(titleText, mTitleNames[titleIndex]);
if (nandTitleIndex < mNandTitleCount && mTitleIds[titleIndex] == mNandTitleIds[nandTitleIndex]) {
nw4r::ut::Color activeTitleColor;
writeFourFlagBytes(&activeTitleColor.r, 0x34, 0xBE, 0xED, 0xFF);
GXColor gxActive;
writeFourFlagBytes(&gxActive.r, 0x34, 0xBE, 0xED, 0xFF);
++nandTitleIndex;
setTitleRowColors(titleText, activeTitleColor, activeTitleColor);
nw4r::ut::Color active0 = *reinterpret_cast<const nw4r::ut::Color*>(&gxActive);
setTitleRowColors(titleText,
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxActive)),
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxActive)));
} else {
nw4r::ut::Color inactiveTitleColor;
writeFourFlagBytes(&inactiveTitleColor.r, 0x64, 0x64, 0x64, 0xFF);
setTitleRowColors(titleText, inactiveTitleColor, inactiveTitleColor);
GXColor gxInactive;
writeFourFlagBytes(&gxInactive.r, 0x64, 0x64, 0x64, 0xFF);
nw4r::ut::Color inactive0 = *reinterpret_cast<const nw4r::ut::Color*>(&gxInactive);
setTitleRowColors(titleText,
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxInactive)),
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxInactive)));
}
nw4r::ut::Rect textRect = mpDialogLayout->getTextDrawRect("T_Letter");
@@ -1343,7 +1356,7 @@ namespace ipl {
s32 visibleRows = static_cast<s32>(static_cast<f32>(ceil(-rowTop / titleSizePane->GetSize().height)));
for (s32 row = 0; row < visibleRows; ++row) {
f32 rowY = bodyY + backgroundOffset;
if (rowY > -500.0f && rowY < 500.0f) {
if (-500.0f < rowY && rowY < 500.0f) {
nw4r::math::VEC2 translation(0.0f, backgroundOffset);
titleSizePane->SetTranslate(translation);
titleSizePane->CalculateMtx(*mpDialogLayout->getDrawInfo());
@@ -1351,7 +1364,7 @@ namespace ipl {
}
backgroundOffset -= rowHeight;
}
if (bodyY + titleOffset > -500.0f && bodyY + titleOffset < 500.0f) {
if (-500.0f < bodyY + titleOffset && bodyY + titleOffset < 500.0f) {
nw4r::math::VEC2 translation(0.0f, titleOffset);
titleText->SetTranslate(translation);
titleText->CalculateMtx(*mpDialogLayout->getDrawInfo());
@@ -1368,7 +1381,7 @@ namespace ipl {
++footerChild;
}
if (bodyY + backgroundOffset > -500.0f) {
if (-500.0f < bodyY + backgroundOffset) {
nw4r::math::VEC2 translation(0.0f, backgroundOffset);
footerPane->SetTranslate(translation);
footerPane->CalculateMtx(*mpDialogLayout->getDrawInfo());
@@ -1388,7 +1401,7 @@ namespace ipl {
}
void setTitleRowColors(nw4r::lyt::TextBox* textBox, const nw4r::ut::Color& first,
const nw4r::ut::Color& second) {
const nw4r::ut::Color& second) NO_INLINE {
textBox->SetTextColors(first, second);
}

View File

@@ -264,7 +264,6 @@ namespace ipl {
command.arguments.values[0] = 0;
command.arguments.values[1] = 0;
command.titleId = 0;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
}
@@ -274,7 +273,6 @@ namespace ipl {
command.arguments.values[0] = 0;
command.arguments.values[1] = 0;
command.titleId = 0;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -289,7 +287,6 @@ namespace ipl {
notice.arguments.values[0] = argument0;
notice.arguments.values[1] = argument1;
notice.titleId = titleId;
notice.arguments.values[2] = 0;
if (mNoticeQueue.capacity != mNoticeQueue.count) {
mNoticeQueue.notices[mNoticeQueue.writeIndex].copyFrom(notice);
++mNoticeQueue.writeIndex;
@@ -311,7 +308,6 @@ namespace ipl {
command.arguments.values[0] = 0;
command.arguments.values[1] = 0;
command.titleId = 0;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -326,7 +322,6 @@ namespace ipl {
command.arguments.values[0] = 0;
command.arguments.values[1] = 0;
command.titleId = 0;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -341,7 +336,6 @@ namespace ipl {
command.arguments.values[0] = 0;
command.arguments.values[1] = 0;
command.titleId = result;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -356,7 +350,6 @@ namespace ipl {
command.arguments.values[0] = value;
command.arguments.values[1] = (u32)&mFirstTitleCount;
command.titleId = ((u64)page << 32) | index;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -371,7 +364,6 @@ namespace ipl {
command.arguments.values[0] = 0;
command.arguments.values[1] = 0;
command.titleId = ((u64)page << 32) | index;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -386,7 +378,6 @@ namespace ipl {
command.arguments.values[0] = state;
command.arguments.values[1] = 0;
command.titleId = ((u64)page << 32) | index;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -401,7 +392,6 @@ namespace ipl {
command.arguments.values[0] = page;
command.arguments.values[1] = index;
command.titleId = 0;
command.arguments.values[2] = 0;
mCommandQueue.push(command);
return true;
}
@@ -1301,7 +1291,10 @@ namespace ipl {
blocks += mpNandTitleInfo[index].inode;
}
return bytes >= usage[0] && blocks >= usage[1];
if (bytes >= usage[0] && blocks >= usage[1]) {
return true;
}
return false;
}
void SDChannelSelect::getCurrentTitleUsage(s32* bytes, s32* blocks) const {
@@ -1453,48 +1446,60 @@ namespace ipl {
bool SDChannelSelect::collectTitlesBySpecialChannels(
const s32* firstUsage, const s32* secondUsage, ESTitleId* titleIds,
char* titleNames, u32* titleCount) {
s32 bytes;
s32 blocks;
getCurrentTitleUsage(&bytes, &blocks);
int hateUsageIndex = -1;
int hatePage = -1;
int hateChannelIndex = -1;
int hadeUsageIndex = -1;
int hadePage = -1;
int hadeChannelIndex = -1;
s32 bytes;
s32 blocks;
getCurrentTitleUsage(&bytes, &blocks);
for (u32 usageIndex = 0; usageIndex < mNandTitleCount; ++usageIndex) {
ESTitleId titleId = mpNandTitleInfo[usageIndex].curTitleId;
if (titleId == ES_TITLE_ID(0x00010001, 0x48415445)) {
int page;
int channelIndex;
hateUsageIndex = usageIndex;
System::getChannelManager()->hasChannel(
ES_TITLE_ID(0x00010001, 0x48415445), &hatePage, &hateChannelIndex);
ES_TITLE_ID(0x00010001, 0x48415445), &page, &channelIndex);
hatePage = page;
hateChannelIndex = channelIndex;
} else if (titleId == ES_TITLE_ID(0x00010001, 0x48414445)) {
int page;
int channelIndex;
hadeUsageIndex = usageIndex;
System::getChannelManager()->hasChannel(
ES_TITLE_ID(0x00010001, 0x48414445), &hadePage, &hadeChannelIndex);
ES_TITLE_ID(0x00010001, 0x48414445), &page, &channelIndex);
hadePage = page;
hadeChannelIndex = channelIndex;
}
}
*titleCount = 0;
for (int usageIndex = mNandTitleCount - 1; usageIndex >= 0; --usageIndex) {
ESTitleId titleId = mpNandTitleInfo[usageIndex].curTitleId;
if (titleId == 0x48415A41 || titleId == ES_TITLE_ID(0x00010001, 0x48415445) || titleId == ES_TITLE_ID(0x00010001, 0x48414445)) {
if (mpNandTitleInfo[usageIndex].curTitleId == 0x48415A41 ||
mpNandTitleInfo[usageIndex].curTitleId == ES_TITLE_ID(0x00010001, 0x48415445) ||
mpNandTitleInfo[usageIndex].curTitleId == ES_TITLE_ID(0x00010001, 0x48414445)) {
continue;
}
int page;
int channelIndex;
if (System::getChannelManager()->hasChannel(titleId, &page, &channelIndex) == 0) {
if (System::getChannelManager()->hasChannel(
mpNandTitleInfo[usageIndex].curTitleId, &page, &channelIndex) == 0) {
continue;
}
if (iplSavedata_813597A0(System::getSaveData(), titleId) != FALSE) {
if (iplSavedata_813597A0(System::getSaveData(),
mpNandTitleInfo[usageIndex].curTitleId) != FALSE) {
continue;
}
bytes += mpNandTitleInfo[usageIndex].size;
blocks += mpNandTitleInfo[usageIndex].inode;
titleIds[*titleCount] = titleId;
titleIds[*titleCount] = mpNandTitleInfo[usageIndex].curTitleId;
wchar_t* titleName = System::getChannelManager()->getTitleName(
page, channelIndex, 0);
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
@@ -1535,7 +1540,7 @@ namespace ipl {
if (hadeUsageIndex >= 0) {
bytes += mpNandTitleInfo[hadeUsageIndex].size;
blocks += mpNandTitleInfo[hadeUsageIndex].inode;
titleIds[*titleCount] = ES_TITLE_ID(0x00010001, 0x48414445);
titleIds[*titleCount] = mpNandTitleInfo[hadeUsageIndex].curTitleId;
wchar_t* titleName =
System::getChannelManager()->getTitleName(
hadePage, hadeChannelIndex, 0);
@@ -1550,7 +1555,7 @@ namespace ipl {
if (hateUsageIndex >= 0) {
bytes += mpNandTitleInfo[hateUsageIndex].size;
blocks += mpNandTitleInfo[hateUsageIndex].inode;
titleIds[*titleCount] = ES_TITLE_ID(0x00010001, 0x48415445);
titleIds[*titleCount] = mpNandTitleInfo[hateUsageIndex].curTitleId;
wchar_t* titleName =
System::getChannelManager()->getTitleName(
hatePage, hateChannelIndex, 0);
@@ -1691,7 +1696,7 @@ namespace ipl {
if (mState == 2 && !mpLayout->isPlaying(0)) {
SDButton* button = static_cast<SDButton*>(System::getSceneManager()->getScene(0x24));
if (button != NULL) {
button->setEventHandler(mpButtonEventHandler, NULL);
button->setEventHandler(mpButtonEventHandler);
mState = 3;
if (mCurrentPage > 0) {
button->initArrowAppearance(1, true);
@@ -2239,7 +2244,7 @@ namespace ipl {
mbRightArrowVisible = false;
}
button->setEventHandler(mpButtonEventHandler, NULL);
button->setEventHandler(mpButtonEventHandler);
TVRCManager::getHandle()->setEnable(TRUE);
snd::getSystem()->startBGM("WIPL_BGM_MENU");
clearNoticeQueue();
@@ -3458,7 +3463,7 @@ namespace ipl {
if (strcmp(paneName,
SDButton::smButtonName[SDButton::BTN_WII_MENU]) == 0) {
button->setEventHandler(NULL, NULL);
button->setEventHandler(NULL);
mpScene->mState = 4;
snd::getSystem()->startSE("WIPL_SE_DECIDE");
return;

View File

@@ -86,8 +86,15 @@ static inline void setMemoryTitleLists(SDMemory* memory, SDMemory::TitleRange sd
memory->setTitleLists(sdRange, nandRange);
}
extern "C" char lbl_81696E30[];
extern "C" char lbl_81696E37[];
static const char* sButtonNames[2] = {lbl_81696E30, lbl_81696E37};
static const int sCaptureSizes[2][2] = {{128, 96}, {176, 96}};
static const wchar_t sMissingTitle[] = L"???";
static const char* sButtonGroups[7] = {
"G_FocusBtnA", "G_FocusBtnB", "G_SelectBtnA", "G_SelectBtnB",
"G_OnOffBtnA", "G_OnOffBtnB", "G_OutBtn"
@@ -103,28 +110,27 @@ static const char* sButtonAnimationNames[6] = {
static const char* sBannerAnimationNames[3] = {
"banner.brlan", "banner_Start.brlan", "banner_Loop.brlan"
};
static const char* sTextNames[2] = {"T_BtnA", "T_BtnB"};
static const char* sButtonNames[2] = {"B_BtnA", "B_BtnB"};
static const char* sTexturePaneNames[3][4] = {
{"Fre_a", "Fre_d", "Fre_i", "Fre_l"},
{"Fre_e", "Fre_f", "Fre_g", "Fre_h"},
{"Fre_b", "Fre_c", "Fre_j", "Fre_k"}
};
static const char* sTextNames[2] = {"T_BtnA", "T_BtnB"};
class SDTitleButtonEventHandler : public SDButtonEventHandlerBase {
class SDTitlePaneEventHandler : public ::gui::EventHandler {
public:
SDTitleButtonEventHandler(SDChannelTitle* scene) : mpScene(scene) {}
virtual void onEventDerived(u32 component, u32 event, const controller::Interface* controller);
SDTitlePaneEventHandler(SDChannelTitle* scene) : mpScene(scene) {}
virtual void onEvent(u32 component, u32 event, void* data);
nw4r::lyt::Pane* getPane(u32 component) {
return static_cast< ::gui::PaneComponent*>(mpManager->getComponent(component))->getPane();
}
SDChannelTitle* mpScene;
};
class SDTitlePaneEventHandler : public ::gui::EventHandler {
class SDTitleButtonEventHandler : public SDButtonEventHandlerBase {
public:
SDTitlePaneEventHandler(SDChannelTitle* scene) : mpScene(scene) {}
virtual void onEvent(u32 component, u32 event, void* data);
SDTitleButtonEventHandler(SDChannelTitle* scene) : mpScene(scene) {}
virtual void onEventDerived(u32 component, u32 event, const controller::Interface* controller);
nw4r::lyt::Pane* getPane(u32 component) {
return static_cast< ::gui::PaneComponent*>(mpManager->getComponent(component))->getPane();
}
@@ -222,9 +228,8 @@ void SDChannelTitle::create() {
comment->SetString(System::getMessage(0xad));
iplSDChannelTitle_813E630C(this);
mpFade = new math::HermiteIntp<f32>();
const f32 fadeStart = 0.0f;
const f32 fadeEnd = 255.0f;
mpFade->init(fadeStart, fadeEnd, 10.0f, 0.0f, 0.0f);
static f32 fadeRange[2] = {0.0f, 255.0f};
mpFade->init(fadeRange[0], fadeRange[1], 28.0f, 0.0f, 0.0f);
mpFade->setAnmType(ANIM_TYPE_FORWARD);
mpScreenCapture = new (System::getTreasureHeap(), 32) utility::Capture(System::getTreasureHeap(), 0, 0,
System::getRenderModeObj()->fbWidth, System::getRenderModeObj()->efbHeight, GX_TF_RGB565);
@@ -560,7 +565,7 @@ extern "C" void iplSDChannelTitle_813E6424(SDChannelTitle* scene) {
if (channel->mStateFlags == 0) {
static_cast<nw4r::lyt::TextBox*>(scene->mpProgressLayout->FindPaneByName("T_title"))->SetString(iplSDChannelObj_813E4060(channel, 0));
} else {
static_cast<nw4r::lyt::TextBox*>(scene->mpProgressLayout->FindPaneByName("T_title"))->SetString(L"");
static_cast<nw4r::lyt::TextBox*>(scene->mpProgressLayout->FindPaneByName("T_title"))->SetString(sMissingTitle);
}
scene->mpProgressLayout->getAnim(0)->stop();
scene->mpProgressLayout->getAnim(0)->initAnmFrame();
@@ -1014,9 +1019,8 @@ extern "C" void iplSDChannelTitle_813E7A18(SDChannelTitle* scene) {
if (!scene->mScriptEnabled || scene->mScriptState == 4) {
if (scene->mpChannelSelect->prepareRestarting(scene->mPage)) {
scene->mpChannelSelect->startPageTransition(scene->mPage, scene->mIndex);
const f32 fadeStart = 255.0f;
const f32 fadeEnd = 0.0f;
scene->mpFade->init(fadeStart, fadeEnd, 10.0f, 0.0f, 0.0f);
static f32 fadeRange[2] = {0.0f, 255.0f};
scene->mpFade->init(fadeRange[0], fadeRange[1], 28.0f, 0.0f, 0.0f);
scene->mpFade->setAnmType(ANIM_TYPE_BACKWARD);
scene->mpFade->play();
scene->mState = 6;
@@ -1556,13 +1560,13 @@ void SDChannelTitle::startResetting() {
snd::getSystem()->resetAllSound();
}
void SDTitlePaneEventHandler::onEvent(u32 component, u32 event, void* data) {
iplSDChannelTitle_813E9004(this, component, event, static_cast<const controller::Interface*>(data));
}
void SDTitleButtonEventHandler::onEventDerived(u32 component, u32 event, const controller::Interface* controller) {
iplSDChannelTitle_813E92EC(this, component, event, controller);
}
void SDTitlePaneEventHandler::onEvent(u32 component, u32 event, void* data) {
iplSDChannelTitle_813E9004(this, component, event, static_cast<const controller::Interface*>(data));
}
}
}

View File

@@ -29,3 +29,33 @@ Additional Decrypt correction: restored 0x3E800 size limit, actual seek/read err
Remaining: CDBCryptBuffer 99.97479%, 119/119 instructions, three pool offsets; CDBRecordEncrypt 97.19014%, register allocation and one instruction; CDBRecordDecrypt 99.96789%, stack placement.
The four forced field accessors end with CDBUnlock and do not produce a CDBErr result. Their void declarations are gated by CDB_RECORD_IMPLEMENTATION, preserving all other translation units and avoiding fall-through non-void definitions.
## Wave: dead-helper emission decode (scene2 leaf)
Decoded MWCC literal-emission model via /tmp/tlit*.c experiments:
- Non-static fns emit literals + standalone .text bodies at DEF position, even uncalled.
- Static fns fully inlined at all call sites emit literals at FIRST-CALL parse position, no body.
- A call inside ANY runtime check materializes code at the inlined site — MWCC never
constant-folds `&local != NULL` (tlit10: `if(src==NULL)` w/ `&loc` arg emits addic+bne).
- A static called only from a body that never materializes emits literals but no .text.
Final structure (all helpers NON-STATIC dead impl fns at orig def positions):
- CDBRecordGetFileSize_ (def after Seek, before GetDataSize) -> emits @0x1b0
- ReduceFileSize_/ReduceDataSize_ before Remove -> 0x228-0x38c
- SetFileType_..GetCalenderTime_ before GetTypeForce -> 0x428-0x7d4
- CDBRecordDuplicate_ (pure key+field copies, called by BackupToSD_) -> inlines clean
- CDBRecordDuplicatePanic_ (dead, OSPanic __FILE__ pair) -> 0x8d8/0x8e4
- CDBRecordPrivateChangeOwner_ ({CDBReport_(3);OSReport(sjis)}, called by Decrypt) -> inlines
- CDBRecordPrivateChangeOwnerDebug_ (dead 5-OSReport debug block) -> 0x958-0x9b4
- Extra .text bodies of dead extern fns are score-neutral (objdiff counts orig fns only).
- Decrypt's first locked report = "can't get data size" (0x1ec, NOT modified-time; orig
Decrypt refs 0x1ec + SJIS 0x940 only). GetId refs 0x814 (CDBId) + 0x5b0 (maker code).
- Orig Encrypt refs base+0x1b0/0x1ec/0x178 (file-size/data-size/read reports, 3 refs ->
homes .data base in r25). Record struct field `file` is void* -> needs (CDBRecordFile*) cast.
Result: .data byte-identical (mod extraction tail pad), 28/29 fns at 100%.
Residual: CDBRecordEncrypt pure register-home permutation (153 diff lines, all REGNAME,
instruction-count-equal). Orig: base=r25, record=r26, buffer=r27, key/err=r24, size=r28,
encSize=r29, recordFile=r30, file=r31. Mine: base=r31, params shifted -1, key=r29.
Tried: recordFile decl order (worse, 159), recordFile load after memset (key->r24 fixed
but CR-field regressions, 155). Documented tie-break.

View File

@@ -0,0 +1,9 @@
## 2026-09-30 session (scene2 continued)
- collectTitlesBySpecialChannels: 361/361 exact via separate out-param temps + decl-after-call + per-use reloads. (committed earlier)
- 12/12 enqueue* fns matched by removing `values[2] = 0` stores — orig leaves SDChannelSelectCommand.values[2] uninit except in delete/command notices.
- findAdjacentChannel: tried `step`-first decl order — regressed (bne moved earlier); scheduler tie, reverted.
- **setEventHandler r5 mystery (documented):** orig calls `setEventHandler__Q33ipl5scene8SDButtonFPQ23gui12EventHandlerPQ23gui12EventHandler` (2-param) at 4 sites in iplSDChannelSelect + 2 in iplSDChannelTitle with r5 NEVER materialized (no li/lwz/mr r5 in the 4-insn window before bl; callee is non-static so this=r3, event=r4, optOutEvent=r5 garbage). MWCC always emits `li r5,0` for the =NULL default (verified: both `(h, NULL)` and `(h)` call forms emit it in mine). iplAddress.o Button callers DO emit `li r5,0` for the analogous Button decl. No C++ source model reproduces a 2-param bl with unset r5 (1-arg call to a defaulted 2-param decl emits the default; a 1-param decl would mangle differently). Left as `(h, NULL)` explicit; ~4 insn residual across create/selectChannel/initializeNormalPage/calcCommon/onEventDerived.
- kpr_lib: orig's `once$2281` is an 8-byte fn-local accessed via lbz/stb → decoded as `static union { u64 align; u8 flag; }` inside KPRInitQueue — gives size-8 `once$` + .sbss 0x10 and .sbss scored 100%. Orig's .sbss ordering [DeadKeys@0,Romaji@4,once@8] vs mine [once@0,Romaji@4,DeadKeys@8] is MWCC reverse-decl-order emission; objdiff .sbss scores 100 anyway. kpr_lib now 8/9 fns, all data 100.
- iplSDMemory: removed dead `#pragma inline_max_total_size` (no effect). drawTransferTitles: orig re-materializes f32 consts from sdata (`lfs f0,const@sda21`) where mine spills/reloads stack copies — frame-lever not found. create: 1064 vs 1060, mostly lbl_/@N symbol-name + r30/r31 data-base home.