diff --git a/config/43U/symbols.txt b/config/43U/symbols.txt index 0d6a0a5c..11a476be 100644 --- a/config/43U/symbols.txt +++ b/config/43U/symbols.txt @@ -17727,12 +17727,20 @@ __vt__Q39textinput4util9Animation = .data:0x8165D258; // type:object size:0x24 @STRING@GetTextColor__Q34nw4r3lyt7TextBoxCFUl = .data:0x8165D28C; // type:object size:0x41 data:string scT_prdc_Text_00 = .data:0x8165D2D0; // type:object size:0xF data:string scP_prdc_scrl_Left = .data:0x8165D2E0; // type:object size:0x11 data:string -scCandidatePaneData = .data:0x8165D2F8; // type:object size:0x68C -scPaneNameTable = .data:0x8165D984; // type:object size:0x84 -scW_predictWindow = .data:0x8165DA08; // type:object size:0x10 data:string -scN_predictInput = .data:0x8165DA18; // type:object size:0xF data:string -scW_OnOff_Area = .data:0x8165DA28; // type:object size:0xD data:string -scN_prdc_Texts = .data:0x8165DA38; // type:object size:0xD data:string +scCandidatePaneData = .data:0x8165D2F8; // type:object size:0x680 +@9934 = .data:0x8165D978; // type:object size:0x9 scope:local data:string +@9935 = .data:0x8165D984; // type:object size:0x9 scope:local data:string +@9936 = .data:0x8165D990; // type:object size:0xB scope:local data:string +@9937 = .data:0x8165D99C; // type:object size:0xB scope:local data:string +@9938 = .data:0x8165D9A8; // type:object size:0xA scope:local data:string +@9939 = .data:0x8165D9B4; // type:object size:0x11 scope:local data:string +@9940 = .data:0x8165D9C8; // type:object size:0x11 scope:local data:string +@9941 = .data:0x8165D9DC; // type:object size:0x11 scope:local data:string +@9942 = .data:0x8165D9F0; // type:object size:0x11 scope:local data:string +@9943 = .data:0x8165DA08; // type:object size:0x10 scope:local data:string +@10036 = .data:0x8165DA18; // type:object size:0xF scope:local data:string +@10037 = .data:0x8165DA28; // type:object size:0xD scope:local data:string +@10041 = .data:0x8165DA38; // type:object size:0xD scope:local data:string @10530 = .data:0x8165DA48; // type:object size:0x1C scope:local @6761 = .data:0x8165DA64; // type:object size:0xF scope:local data:string @6762 = .data:0x8165DA74; // type:object size:0xF scope:local data:string diff --git a/src/keyboard/tiCandidateBox.cpp b/src/keyboard/tiCandidateBox.cpp index dc369de7..0f9e2a5b 100644 --- a/src/keyboard/tiCandidateBox.cpp +++ b/src/keyboard/tiCandidateBox.cpp @@ -62,7 +62,6 @@ namespace textinput { struct CandidatePaneData { PaneToAnimation panes[26]; - char tail[12]; }; extern "C" const CandidatePaneData scCandidatePaneData __attribute__((aligned(8))) = {{ @@ -196,22 +195,7 @@ namespace textinput { 6, NULL, {&csAninationFile[0], &csAninationFile[8], &csAninationFile[9], &csAninationFile[10], &csAninationFile[11], &csAninationFile[12]}}, - }, {"P_OffBtn"}}; - - extern "C" char scPaneNameTable[132] = - "B_OffBtn\0\0\0\0" - "P_JPOffBtn\0\0" - "P_CNOffBtn\0\0" - "P_CNOnBtn\0\0\0" - "B_prdc_scrl_Left\0\0\0\0" - "P_prdc_scrl_Left\0\0\0\0" - "B_prdc_scrl_Rght\0\0\0\0" - "P_prdc_scrl_Rght\0\0\0\0" - "\0\0\0"; - extern "C" char scW_predictWindow[16] = "W_predictWindow"; - extern "C" char scN_predictInput[15] = "N_predictInput"; - extern "C" char scW_OnOff_Area[13] = "W_OnOff_Area"; - extern "C" char scN_prdc_Texts[13] = "N_prdc_Texts"; + }}; void CandidateBoxCaller::Candidates::addCandidate(const wchar_t* wcString) { wcsncpy(szwcPredicted[mNumCandidate], wcString, ARRAY_LENGTH(szwcPredicted[0])); @@ -383,27 +367,20 @@ namespace textinput { mTextArea.Init(); mOnOffButton.Create(this); mOnOffButton.Init(); - const char* paneNames = scPaneNameTable; - const char* leftScrollBoundName = paneNames + 48; - const char* leftScrollPaneName = paneNames + 68; - mLeftScroll.Create(this, leftScrollPaneName, leftScrollBoundName); - const char* rightScrollBoundName = paneNames + 88; - const char* rightScrollPaneName = paneNames + 108; - mRightScroll.Create(this, rightScrollPaneName, rightScrollBoundName); + mLeftScroll.Create(this, "P_prdc_scrl_Left", "B_prdc_scrl_Left"); + mRightScroll.Create(this, "P_prdc_scrl_Rght", "B_prdc_scrl_Rght"); mLeftScroll.Init(); mRightScroll.Init(); - const char* windowName = scW_predictWindow; - mTextWindow.Create(this, windowName); + mTextWindow.Create(this, "W_predictWindow"); init(); } void LayoutByNW4R::createAnmPane_(MEMAllocator* allocator) { - CandidateTextAnmPane* pane; - u16 j; + const char* forceAddName; u16 i; for (i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) { - pane = NULL; const PaneToAnimation& p = scCandidatePaneData.panes[i]; + CandidateTextAnmPane* pane = NULL; switch (p.type) { case KT_ScrollButton: { void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(CandidateScrollAnmPane)); @@ -430,9 +407,8 @@ namespace textinput { nw4r::ut::List_Append(&mAnmPanes, pane); - const char* forceAddName = p.forceAddName; - u32 animationCount = p.count; - for (j = 0; j < animationCount; j++) { + forceAddName = p.forceAddName; + for (u16 j = 0; j < p.count; j++) { const AnimationFile* const& animation = p.pAnims[j]; void* pResource = mpMultiArcResourceAccessor->GetResource(0, animation->fileName); AnimTransformPane* transform = @@ -448,7 +424,7 @@ namespace textinput { } void LayoutByNW4R::init() { - searchAnmPane(scN_predictInput)->changeAnimation(ANM_Normal); + searchAnmPane("N_predictInput")->changeAnimation(ANM_Normal); Base::setInvalid(false); setActive(true); setOnOff(false); @@ -461,7 +437,7 @@ namespace textinput { mpLayout->CalculateMtx(mDrawInfo); if (meLanguage == KR) { mTextWindow.SetVisible(false); - getPane(scW_OnOff_Area)->SetVisible(false); + getPane("W_OnOff_Area")->SetVisible(false); } else if (meLanguage == CN) { setOnOff(true); mTextWindow.SetVisible(true); @@ -471,16 +447,16 @@ namespace textinput { } else { mTextWindow.ChangeAnimation(ANM_Normal); } - getPane(scW_OnOff_Area)->SetVisible(false); + getPane("W_OnOff_Area")->SetVisible(false); } else { - getPane(scW_OnOff_Area)->SetVisible(true); + getPane("W_OnOff_Area")->SetVisible(true); } } void LayoutByNW4R::draw() { - getPane(scN_prdc_Texts)->SetVisible(false); + getPane("N_prdc_Texts")->SetVisible(false); nw4rmanager::Layout::draw(); - getPane(scN_prdc_Texts)->SetVisible(true); + getPane("N_prdc_Texts")->SetVisible(true); if (!isInvalid()) { mTextArea.Draw(mDrawInfo); } @@ -490,8 +466,8 @@ namespace textinput { nw4rmanager::Layout::calc(); mTextArea.Calc(); if (mbAnimOn) { - getPane(scN_prdc_Texts)->Animate(0); - getPane(scN_prdc_Texts)->CalculateMtx(mDrawInfo); + getPane("N_prdc_Texts")->Animate(0); + getPane("N_prdc_Texts")->CalculateMtx(mDrawInfo); } } @@ -499,7 +475,7 @@ namespace textinput { Base::setLanguage(language); init(); // Maybe inlines, maybe not - nw4r::math::VEC3 pos = searchAnmPane(scW_predictWindow)->getPane()->GetTranslate(); + nw4r::math::VEC3 pos = searchAnmPane("W_predictWindow")->getPane()->GetTranslate(); if (meLanguage == CN || meLanguage == KR) { Base::checkValidation(); // Potentially an inline @@ -514,7 +490,7 @@ namespace textinput { pos.x = 202.0f; } - searchAnmPane(scW_predictWindow)->getPane()->SetTranslate(pos); + searchAnmPane("W_predictWindow")->getPane()->SetTranslate(pos); if (meLanguage == CN) { mTextArea.ApplyFontScale(1.2f); } else if (meLanguage == KR) { @@ -631,7 +607,7 @@ namespace textinput { current = reinterpret_cast(reinterpret_cast(current) + sizeof(current->szwcPredicted[0])); } } - gui::PaneComponent* p = mpPaneManager->searchPaneComponent(isOn() ? scB_OnBtn : scPaneNameTable); + gui::PaneComponent* p = mpPaneManager->searchPaneComponent(isOn() ? scB_OnBtn : "B_OffBtn"); if (p != NULL) { p->lockInitialize(true); } @@ -1009,7 +985,7 @@ namespace textinput { mpBoundingPane[i]->setListener(this); } mpTextAreaPane = mgr->searchPaneComponent("N_prdcTextArea"); - mpTextsPane = mgr->searchPaneComponent(scN_prdc_Texts); + mpTextsPane = mgr->searchPaneComponent("N_prdc_Texts"); mSize = mpTextBoxPane[0]->getTextPane()->GetFontSize(); mpTextAreaPane->setListener(this); } @@ -1494,7 +1470,7 @@ namespace textinput { if (mgr()->isInScroll() && event != gui::EventHandler::ON_LEFT && event != gui::EventHandler::ON_POINT) { return; } - if (!mgr()->searchAnmPane(scW_predictWindow)->isInAnimation() || event == gui::EventHandler::ON_LEFT) { + if (!mgr()->searchAnmPane("W_predictWindow")->isInAnimation() || event == gui::EventHandler::ON_LEFT) { if (!mgr()->isInvalid()) { switch (event) { case gui::EventHandler::ON_TRIG: @@ -1645,7 +1621,7 @@ namespace textinput { if (mgr()->isInScroll() && event != gui::EventHandler::ON_LEFT && event != gui::EventHandler::ON_POINT) { return; } - if (!mgr()->searchAnmPane(scW_predictWindow)->isInAnimation() || event == gui::EventHandler::ON_LEFT) { + if (!mgr()->searchAnmPane("W_predictWindow")->isInAnimation() || event == gui::EventHandler::ON_LEFT) { if (!mgr()->isInvalid()) { switch (event) { case gui::EventHandler::ON_TRIG: @@ -1691,15 +1667,15 @@ namespace textinput { mpOnPictPane = mgr->searchPaneComponent(scP_OnBtn); mpOnBoundPane = mgr->searchPaneComponent(scB_OnBtn); mpOnAnmPane = static_cast(layout->searchAnmPane(scP_OnBtn)); - mpOffPictPane = mgr->searchPaneComponent(scCandidatePaneData.tail); - mpOffBoundPane = mgr->searchPaneComponent(scPaneNameTable); - mpOffAnmPane = static_cast(layout->searchAnmPane(scCandidatePaneData.tail)); + mpOffPictPane = mgr->searchPaneComponent("P_OffBtn"); + mpOffBoundPane = mgr->searchPaneComponent("B_OffBtn"); + mpOffAnmPane = static_cast(layout->searchAnmPane("P_OffBtn")); - layout->getLayout()->GetRootPane()->FindPaneByName(scCandidatePaneData.tail)->GetMaterial()->GetTexture(&mOffTexDefault, 0); - layout->getLayout()->GetRootPane()->FindPaneByName(scPaneNameTable + 12)->GetMaterial()->GetTexture(&mOffTexJP, 0); - layout->getLayout()->GetRootPane()->FindPaneByName(scPaneNameTable + 24)->GetMaterial()->GetTexture(&mOffTexCN, 0); + layout->getLayout()->GetRootPane()->FindPaneByName("P_OffBtn")->GetMaterial()->GetTexture(&mOffTexDefault, 0); + layout->getLayout()->GetRootPane()->FindPaneByName("P_JPOffBtn")->GetMaterial()->GetTexture(&mOffTexJP, 0); + layout->getLayout()->GetRootPane()->FindPaneByName("P_CNOffBtn")->GetMaterial()->GetTexture(&mOffTexCN, 0); layout->getLayout()->GetRootPane()->FindPaneByName(scP_OnBtn)->GetMaterial()->GetTexture(&mOnTexDefault, 0); - layout->getLayout()->GetRootPane()->FindPaneByName(scPaneNameTable + 36)->GetMaterial()->GetTexture(&mOnTexCN, 0); + layout->getLayout()->GetRootPane()->FindPaneByName("P_CNOnBtn")->GetMaterial()->GetTexture(&mOnTexCN, 0); mpOffBoundPane->setListener(this); mpOnBoundPane->setListener(this); @@ -1755,7 +1731,7 @@ namespace textinput { if (mgr()->isInScroll() && event != gui::EventHandler::ON_LEFT && event != gui::EventHandler::ON_POINT) { return; } - if (!mgr()->searchAnmPane(scW_predictWindow)->isInAnimation() || event == gui::EventHandler::ON_LEFT) { + if (!mgr()->searchAnmPane("W_predictWindow")->isInAnimation() || event == gui::EventHandler::ON_LEFT) { OnOffAnmPane* p; if (&component == mpOnBoundPane) { p = mpOnAnmPane; diff --git a/tools/decomp-assist/opus-game.attempts.md b/tools/decomp-assist/opus-game.attempts.md new file mode 100644 index 00000000..618dd2d5 --- /dev/null +++ b/tools/decomp-assist/opus-game.attempts.md @@ -0,0 +1,96 @@ +# opus-game attempts (worktree sol-high, base origin/main 77cf3598) + +Units: iplCardSequence, odh, tiInputForm, tiCandidateBox. Diff counts are odiff.py (differing / total). + +## tiCandidateBox + +### create (278/356, size 0x590 vs 0x580) -> EXACT 0/352 +Evidence: target addresses every pane-name string directly off the .data base +(r30+0x6a8, +0x6b4, +0x6c0, ...). Ours CSE'd `scPaneNameTable` and +`&scCandidatePaneData` into sub-bases (+0x28, +0x6b4). In the inlined +UIButton::Create the target holds both name args in saved registers instead of +rematerializing the address, which is how MWCC treats string-literal args. +1. Pass scroll/window names directly, no paneNames locals: 268/353. +2. Split scPaneNameTable into separate char arrays: 278/352 (equal size, sub-bases remain). +3. Names as string literals (B_OffBtn ... P_prdc_scrl_Rght): literals emitted after the + named globals, in the target's order; 287/354. +4. Also W_predictWindow, N_predictInput, W_OnOff_Area, N_prdc_Texts and the + "P_OffBtn" tail of scCandidatePaneData as literals: 0/352, .data bytes identical. + symbols.txt: scCandidatePaneData size 0x68C -> 0x680; scPaneNameTable and the four + named strings replaced by local literal labels at the same addresses. Total data + unchanged; unit data 100%; DOL SHA1 unchanged. + +### createAnmPane_ (64/216) +mwdbg trace + regsim (127/127 reproduced). Named locals colored in reverse +declaration order; `animationCount` cannot reach r31 by order (regsim 0/1). +1. Loop bound `j < p.count` (count becomes a compiler temp -> r31): 86/216 but count now r31. +2. Declare forceAddName, i at top; p, pane in loop; j in for: 41/216. All named locals match; + left: animation-address temp r30 vs r23 and the hoisted constant temps shifted by one. +3. `p.pAnims[j]` at each use instead of the reference: 149/220 (reloads). Reverted. +4. forceAddName declared in the loop: 82/216. Reverted. +5. Pointer to slot `const AnimationFile* const* animation = &p.pAnims[j]`: 41 (no change). Reverted. +6. `animations = p.pAnims` hoisted, `animations[j]`: 86. Reverted. +Retrace after step 2: named locals all match; the only mismatch is the unnamed +animation-address temp (ours r30, target r23), numbered after the LICM constant temps. +Declaration order cannot move it. Kept steps 1-2 (64 -> 41) in the create commit. + +## tiInputForm (best: opus-game.best.tiInputForm.diff, apply with patch -p0) + +### create (153/356) +Register-blind diff showed one structural spot: target evaluates the +`getLanguageTextPane() ? textBox : "T_2l_TextBox"` name before loading mpLayout. +1. Name hoisted into a local before FindPaneByName: 153 (MWCC still loads mpLayout first). +2. Use the existing `selectInputTextName(*this, mpLanguageData)` helper (moved above create): + 146/356, now register-only (register-blind diff identical). Unit still 219/221, data 100%. +3. Drop `count` local (loop bound `button.count`): 179, count not hoisted here. Reverted. +mwdbg + regsim on step 2: reproduces 138/138; best 7/10 wanted registers with named +locals only and 7/10 even with temps. Structural: target puts LICM constants (li 0, lis +vtable) in r20/r21/r31 between named locals. Not fixable by declaration order. + +### calcCursorPos (43/326) +FPR tie plus scheduling. scale.x/scale.y FPRs swapped (ours x=f31, target x=f30); the +SRA'd fields are numbered by first use. +1. GetHeight() instead of bottom-top: 43 (no change). +2. Compute `right` before `lineBottom`: 41, scale FPRs match, but schedule order flips + (target computes the height product first) and fuzzy drops 93.05 -> 93.03. Not kept. +3. Named scaleX/scaleY locals: 235. Reverted. + +## iplCardSequence (best: opus-game.best.iplCardSequence.diff, apply with patch -p0) + +### loadCardFileIcons (436/512, 0x7f4 vs 0x800) -> best 406/512 (91.34% -> 93.34%) +Register-blind structural diff lines 41 -> 28. +1. `hasTlut = FALSE` initialized with the other counters before the speed loop: 419. +2. No-icon branch: store unk_0x01 before `iconImageSize = 0`: 408. +3. iconCount declared after the unk_0x02 store: 408 (struct 36). +4. `goto closeFile` -> `return result` (target's `bge; b epilogue` pairs, result stays in r3): 406, struct 28. +5. Tail `if (result < 0) return result;` instead of closeFile/closeFileSuccess labels: 406 (same, cleaner). +Tried without gain: iconCount u32/int, icon u32, `iconOffset[icon + 1]` (worse), +NONE-case spellings (array copy with [iconCount - 1], `(&...)[-1]`, `+ iconCount`, paletteSize after pointer). +Evidence for the rest: the target never sets paletteSize on the switch default path (r6 is +not initialized before the loop; default jumps straight to the iconCount < 7 test), so the +original read a stale paletteSize for format 3. Dropping the default assignment gives 404 +and size 508, but that is an uninitialized read, so not kept. Remaining structure: NONE case +pointer formed as sThread + (iconCount + slot/file offset + 0x10000 - 0x6fb4), and +iconOffset[iconCount + 1] computed as ((iconCount + 1) << 2) without folding into +4. + +### cardThreadMain (78/301) +mwdbg + regsim: reproduces 109/109; 9/9 wanted only with @-temps interleaved, 7/9 with +named locals only. One structural spot: the validity reply. Target copies command (mr r4, r19) +then rlwimi from validState (r25); ours coalesces the reply with command and inserts the +hoisted constant 1 (r29). PCode: `mr r72, r40; rlwimi r72, r71` with r71 the hoisted const; +r40 -> r72 coalesced because command dies there. +Tried: OR-expression reply (const-folds to ori 0x100: 261), mask-and-or (77), named +OSMessage local (78), validState BOOL/u8 (79/78), helper param u8/BOOL, command u8 (78). + +## odh + +### LineConv11 (12/146) +mwdbg + regsim: 77/77 reproduced; best 6/10 wanted (pixelSource r29, hi byte r8, +pixel r25, RGBA8 pointer r30) -> structural register tie. Plus lfs f7 / lis 0x4330 order. +Tried: split pointer add (15), &source[...] (12), operand order of the pointer sum (12), +pixel assembled from [0] first (12). + +### huffmanDecoder (171/306) +Traced only. Target keeps sourceCursor in a volatile reg (r12) and bitOffset in r31; ours +the reverse, from the decomp's reuse of bitIndex/tableIndex/bitCountAndMask for several +values. Not attempted further this round.