diff --git a/config/43U/symbols.txt b/config/43U/symbols.txt index e124888a..affe0fd5 100644 --- a/config/43U/symbols.txt +++ b/config/43U/symbols.txt @@ -13963,7 +13963,7 @@ lbl_816152D0 = .rodata:0x816152D0; // type:object size:0x10 scope:local data:4by csAninationFile__Q29textinput12candidatebox = .rodata:0x816152E0; // type:object size:0x374 scope:local lbl_81615658 = .rodata:0x81615658; // type:object size:0xA0 scope:local data:4byte csAninationFile__Q29textinput7toolbar = .rodata:0x816156F8; // type:object size:0x1DC scope:local data:4byte -csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x268 scope:local +csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x264 scope:local csAninationFileForSign__Q39textinput8keyboard10signwindow = .rodata:0x81615B40; // type:object size:0x268 scope:local csPaneNameToControlKey__Q39textinput8keyboard10signwindow = .rodata:0x81615DA8; // type:object size:0x48 scope:local csLanguageDependencyData__Q39textinput8keyboard10signwindow = .rodata:0x81615DF0; // type:object size:0x50 scope:local @@ -22774,10 +22774,7 @@ lbl_81697824 = .sdata:0x81697824; // type:object size:0x8 data:string lbl_8169782C = .sdata:0x8169782C; // type:object size:0x8 data:string lbl_81697834 = .sdata:0x81697834; // type:object size:0x8 data:string lbl_8169783C = .sdata:0x8169783C; // type:object size:0x8 data:string -scCsFatalColorR = .sdata:0x81697844; // type:object size:0x1 data:byte -scCsFatalColorG = .sdata:0x81697845; // type:object size:0x1 data:byte -scCsFatalColorB = .sdata:0x81697846; // type:object size:0x1 data:byte -scCsFatalColorA = .sdata:0x81697847; // type:object size:0x1 data:byte +scCsFatalColor = .sdata:0x81697844; // type:object size:0x4 data:byte lbl_81697848 = .sdata:0x81697848; // type:object size:0x8 data:string lbl_81697850 = .sdata:0x81697850; // type:object size:0x6 data:string lbl_81697858 = .sdata:0x81697858; // type:object size:0x6 data:string diff --git a/src/channelScript/systemmenu/iplCSPane.cpp b/src/channelScript/systemmenu/iplCSPane.cpp index 86a8d1fc..956d763d 100644 --- a/src/channelScript/systemmenu/iplCSPane.cpp +++ b/src/channelScript/systemmenu/iplCSPane.cpp @@ -2,16 +2,13 @@ #include extern "C" char scCsFatalMsg[]; -extern "C" const u8 scCsFatalColorR; -extern "C" const u8 scCsFatalColorG; -extern "C" const u8 scCsFatalColorB; -extern "C" const u8 scCsFatalColorA; +extern "C" GXColor scCsFatalColor; #define NW4R_DB_ASSERT_H #define NW4R_ASSERT(x) \ { \ if (!(x)) { \ - GXColor front = {scCsFatalColorR, scCsFatalColorG, scCsFatalColorB, scCsFatalColorA}; \ + GXColor front = scCsFatalColor; \ GXColor back = {0, 0, 0, 0}; \ OSFatal(front, back, scCsFatalMsg); \ } \ @@ -622,13 +619,7 @@ namespace ipl { namespace pane { extern "C" char scCsFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted."; -#pragma push -#pragma section data_type ".sdata" - extern "C" __declspec(section ".sdata") const u8 scCsFatalColorR = 0xff; - extern "C" __declspec(section ".sdata") const u8 scCsFatalColorG = 0xff; - extern "C" __declspec(section ".sdata") const u8 scCsFatalColorB = 0xff; - extern "C" __declspec(section ".sdata") const u8 scCsFatalColorA = 0; -#pragma pop + extern "C" GXColor scCsFatalColor = {0xff, 0xff, 0xff, 0}; } } } diff --git a/src/keyboard/tiInputForm.cpp b/src/keyboard/tiInputForm.cpp index 10c7fde5..7db526cb 100644 --- a/src/keyboard/tiInputForm.cpp +++ b/src/keyboard/tiInputForm.cpp @@ -137,23 +137,20 @@ extern "C" asm void calc__Q39textinput9inputform4BaseFv(); extern "C" asm void calc__Q39textinput11nw4rmanager6LayoutFv(); extern "C" asm void draw__Q39textinput11nw4rmanager6LayoutFv(); extern "C" asm void searchPaneComponent__Q39textinput3gui11PaneManagerFPCc(); -#pragma push -#pragma section const_type ".data" -extern "C" const char scP_txtScrll_UP[]; -extern "C" const char scP_txtScrll_DOWN[]; -extern "C" const char scN_JPNUSAEUR[]; -extern "C" const char scN_separateBarAll[]; -extern "C" const char scT_2l_TextBox[]; -extern "C" const char scT_title_textJPN[]; -extern "C" const char scN_separateBarKOR[]; -extern "C" const char scT_2l_TextBoxKOR[]; -extern "C" const char scT_title_textKOR[]; -extern "C" const char scN_separateBarCHN[]; -extern "C" const char scT_2l_TextBoxCHN[]; -extern "C" const char scT_title_textCHN[]; +extern "C" char scP_txtScrll_UP[]; +extern "C" char scP_txtScrll_DOWN[]; +extern "C" char scN_JPNUSAEUR[]; +extern "C" char scN_separateBarAll[]; +extern "C" char scT_2l_TextBox[]; +extern "C" char scT_title_textJPN[]; +extern "C" char scN_separateBarKOR[]; +extern "C" char scT_2l_TextBoxKOR[]; +extern "C" char scT_title_textKOR[]; +extern "C" char scN_separateBarCHN[]; +extern "C" char scT_2l_TextBoxCHN[]; +extern "C" char scT_title_textCHN[]; extern "C" const char scN_KOR[]; extern "C" const char scN_CHN[]; -#pragma pop extern "C" const f32 scInputFormZeroF; extern "C" void _savegpr_20(); extern "C" void _restgpr_20(); @@ -321,8 +318,6 @@ struct InputFormAnimationFile { char fileName[0x40]; }; -#pragma push -#pragma section const_type ".rodata" extern "C" const InputFormAnimationFile csAninationFile__Q29textinput9inputform[8] = { {0, "fs_VK_textBox_a_normal.brlan"}, {1, "fs_VK_textBox_a_Foucus_IN.brlan"}, @@ -334,7 +329,6 @@ extern "C" const InputFormAnimationFile csAninationFile__Q29textinput9inputform[ {7, "fs_VK_textBox_a_Off.brlan"}, }; -#pragma section data_type ".rodata" extern "C" const VisiblePanes csVisiblePaneUEJ__Q29textinput9inputform = { 1, 2, {scN_JPNUSAEUR, NULL, NULL, NULL}, @@ -347,7 +341,7 @@ extern "C" const VisiblePanes csVisiblePaneKOR__Q29textinput9inputform = { {"N_CHN", scN_JPNUSAEUR, NULL, NULL}, }; -extern "C" const void* csVisiblePaneCHN__Q29textinput9inputform[10] = { +extern "C" const void* const csVisiblePaneCHN__Q29textinput9inputform[10] = { (const void*)0x00010002, "N_CHN", 0, @@ -380,11 +374,9 @@ extern "C" const LanguagePaneData csLanguageDependencyDataCHN__Q29textinput9inpu scT_2l_TextBoxCHN, scT_title_textCHN, }; -#pragma section data_type ".data" extern "C" const wchar_t pppURLCheck[2][10] = {L"http://", L"https://"}; -#pragma pop extern "C" const f32 scInputFormZeroF = 0.0f; extern "C" const f32 scInputForm640F = 640.0f; @@ -415,10 +407,8 @@ f32 sfColorPhase; bool mbHyphen = true; -#pragma push -#pragma section const_type ".data" -extern "C" const char scP_txtScrll_UP[] = "P_txtScrll_UP"; -extern "C" const char scP_txtScrll_DOWN[] = "P_txtScrll_DOWN"; +extern "C" char scP_txtScrll_UP[] = "P_txtScrll_UP"; +extern "C" char scP_txtScrll_DOWN[] = "P_txtScrll_DOWN"; struct ButtonAnimations { KeyType type; const char* paneName; @@ -427,7 +417,7 @@ struct ButtonAnimations { const InputFormAnimationFile* files[12]; }; -const ButtonAnimations csButtonAnimations[] = { +ButtonAnimations csButtonAnimations[] = { {KT_NormalButton, scP_txtScrll_UP, 8, NULL, { &csAninationFile__Q29textinput9inputform[0], &csAninationFile__Q29textinput9inputform[1], &csAninationFile__Q29textinput9inputform[2], &csAninationFile__Q29textinput9inputform[3], @@ -439,18 +429,20 @@ const ButtonAnimations csButtonAnimations[] = { &csAninationFile__Q29textinput9inputform[4], &csAninationFile__Q29textinput9inputform[5], &csAninationFile__Q29textinput9inputform[6], &csAninationFile__Q29textinput9inputform[7]}} }; -extern "C" const char scN_JPNUSAEUR[] = "N_JPNUSAEUR"; -extern "C" const char scN_separateBarAll[] = "N_separateBarAll"; -extern "C" const char scT_2l_TextBox[] = "T_2l_TextBox"; -extern "C" const char scT_title_textJPN[] = "T_title_textJPN"; -extern "C" const char scN_separateBarKOR[] = "N_separateBarKOR"; -extern "C" const char scT_2l_TextBoxKOR[] = "T_2l_TextBoxKOR"; -extern "C" const char scT_title_textKOR[] = "T_title_textKOR"; -extern "C" const char scN_separateBarCHN[] = "N_separateBarCHN"; -extern "C" const char scT_2l_TextBoxCHN[] = "T_2l_TextBoxCHN"; -extern "C" const char scT_title_textCHN[] = "T_title_textCHN"; +extern "C" char scN_JPNUSAEUR[] = "N_JPNUSAEUR"; +extern "C" char scN_separateBarAll[] = "N_separateBarAll"; +extern "C" char scT_2l_TextBox[] = "T_2l_TextBox"; +extern "C" char scT_title_textJPN[] = "T_title_textJPN"; +extern "C" char scN_separateBarKOR[] = "N_separateBarKOR"; +extern "C" char scT_2l_TextBoxKOR[] = "T_2l_TextBoxKOR"; +extern "C" char scT_title_textKOR[] = "T_title_textKOR"; +extern "C" char scN_separateBarCHN[] = "N_separateBarCHN"; +extern "C" char scT_2l_TextBoxCHN[] = "T_2l_TextBoxCHN"; +extern "C" char scT_title_textCHN[] = "T_title_textCHN"; bool DeadKeyStream::sbCompatibleFilterEnabled = true; +#pragma push +#pragma section const_type ".data" inline bool DeadKeyStream::isCompatible(wchar_t character) { const wchar_t excluded[] = { 0x00a4, 0x00ac, 0x00af, 0x00b2, 0x00b3, 0x00b6, 0x00b8, 0x00b9, @@ -462,6 +454,7 @@ inline bool DeadKeyStream::isCompatible(wchar_t character) { } return true; } +#pragma pop inline wchar_t DeadKeyStream::getChar() { wchar_t character = KPRGetChar(&mKPRQueue); @@ -1349,7 +1342,6 @@ void LayoutByNW4R::onCommand(INPUT_COMMAND command, void* data) { } -#pragma pop void EventHandler::onTiEvent(gui::PaneComponent* component, u32 event, Input* input) { char animationName[17]; diff --git a/src/keyboard/tiPredictLang.cpp b/src/keyboard/tiPredictLang.cpp index 0a02e14a..735faa1e 100644 --- a/src/keyboard/tiPredictLang.cpp +++ b/src/keyboard/tiPredictLang.cpp @@ -35,7 +35,6 @@ namespace textinput { {ANM_RollOver, "fs_prdicSelWidw_a_PRDC_Roll_over.brlan"}, {ANM_ToggleOff, "fs_prdicSelWidw_a_PRDC_toggle-OFF.brlan"}, {ANM_ToggleOn, "fs_prdicSelWidw_a_PRDC_toggle-ON.brlan"}}; - extern "C" __declspec(section ".rodata") const u32 tiPredictLang_rodata_pad = 0; static const PaneToAnimation csPaneToAnimation[] = { {KT_Whole, "N_PRDCkeytop_all", 3, NULL, {&csAninationFile[0], &csAninationFile[4], &csAninationFile[5]}}, diff --git a/src/scene/button/iplButton.cpp b/src/scene/button/iplButton.cpp index 62ba18d4..a54e4ecc 100644 --- a/src/scene/button/iplButton.cpp +++ b/src/scene/button/iplButton.cpp @@ -7,7 +7,7 @@ #include "iplSystem.h" -__declspec(section ".sdata") extern char scPaneName_B_Stop[]; +extern char scPaneName_B_Stop[7]; extern char scPaneName_T_Stop[]; extern "C" BOOL push_button_queue(void*, const void*); diff --git a/src/system/RsoSystem.cpp b/src/system/RsoSystem.cpp index ea384a8b..0568adad 100644 --- a/src/system/RsoSystem.cpp +++ b/src/system/RsoSystem.cpp @@ -1,7 +1,7 @@ #include #include -extern "C" const char scRsoFatalMsg[65]; +extern "C" char scRsoFatalMsg[]; extern GXColor scRsoFatalColor; #define NW4R_DB_ASSERT_H @@ -323,10 +323,6 @@ __declspec(export) void IplRso_symbolMaker() { GXColor scRsoFatalColor = {255, 255, 255, 0}; -extern "C" __declspec(section ".data") const char scRsoFatalMsg[65] = "Error#004\nAn error has occurred.\nThe system files are corrupted."; +extern "C" char scRsoFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted."; -extern "C" __declspec(section ".data") __declspec(align(1)) const f32 rso_data_pad_f32 = 0.0f; -extern "C" __declspec(section ".data") __declspec(align(1)) const u16 rso_data_pad_u16 = 0; -extern "C" __declspec(section ".data") __declspec(align(1)) const u8 rso_data_pad_u8 = 0; - -extern "C" __declspec(section ".sdata2") const f32 scRsoZeroF = 0.0f; +extern "C" const f32 scRsoZeroF = 0.0f; diff --git a/tools/decomp-assist/opus-sections.attempts.md b/tools/decomp-assist/opus-sections.attempts.md new file mode 100644 index 00000000..7e791721 --- /dev/null +++ b/tools/decomp-assist/opus-sections.attempts.md @@ -0,0 +1,39 @@ +# opus-sections: remove section-placement / padding tricks + +## 1. iplCSPane.cpp (scCsFatalColorR/G/B/A) +- plain non-const u8 x4: A (= 0) moves to .sbss -> rejected. +- local `GXColor front = {0xff,0xff,0xff,0}`: emitted as anonymous const in .sdata2 -> rejected. +- non-const global `GXColor scCsFatalColor = {0xff,0xff,0xff,0}` copied in the assert macro: + every section byte-identical to baseline, same lbz x4 / stb x4 copy. The four 1-byte + symbols were a split artefact; symbols.txt now has one 4-byte scCsFatalColor. SetTextColor 0/52, pool identical. ACCEPTED. + +## 2. tiInputForm.cpp (const_type/data_type pragma blocks) - PARTIAL +- scP_/scN_/scT_ strings and csButtonAnimations made non-const: they stay in .data on their own + (csButtonAnimations also becomes global, as in the target). csAninationFile/VisiblePanes/LanguagePaneData + /pppURLCheck are const and land in .rodata with no pragma. +- csVisiblePaneCHN was `const void*[10]` (non-const array of pointers -> .data); now `const void* const[10]`. +- Left: the 32-byte DeadKeyStream::isCompatible table (@6599, .data). Target copies it to the stack + every iteration (frame 0x100, lhz/sth x16), so it is a local array initializer image. Tried: + non-const local (.rodata), local `= L"..."` const and non-const (.rodata), file-scope `wchar_t*` + literal (pointer emitted in .sdata2, code changes), file-scope non-const static array (.data ok + but no stack copy, onCommand -240 bytes, onSpaceKeyHWKB -240 bytes), static const local (.rodata), + probe file on GC 1.0a..3.0a5.2 and Wii 0x4201_127..1.7: local initializer images always go to + .rodata. Kept one narrow `#pragma section const_type ".data"` around isCompatible only. +- Object identical to baseline except csButtonAnimations binding L->G (matches target). Pool identical. + +## 3. iplButton.cpp (scPaneName_B_Stop declspec) +- Definition is `char scPaneName_B_Stop[] = "B_Stop"` in iplFocusObject.cpp (7 bytes, .sdata). The + unsized extern made MWCC use lis/addi; declaring `extern char scPaneName_B_Stop[7];` gives the sda21 + access on its own. Object identical to baseline. ACCEPTED. + +## 4. RsoSystem.cpp (rso_data_pad_*, scRsoFatalMsg/scRsoZeroF declspecs) +- The 7 zero bytes after scRsoFatalMsg (0x41..0x48) have no owner: .data is 8-aligned and the next + unit's .data starts on 8, so dtk folds the alignment gap into this split. Removing the pads gives a + 65-byte .data; objdiff still reports .data 72/72, unit data 96/96, complete. +- scRsoFatalMsg is non-const `char[]` (like scCsFatalMsg) and lands in .data on its own; + scRsoZeroF is a plain const f32 and lands in .sdata2 on its own. Sections otherwise identical. ACCEPTED. + +## 5. tiPredictLang.cpp (tiPredictLang_rodata_pad) +- The .rodata word after csAninationFile (9 x 0x44 = 0x264) is the 8-byte alignment gap before the + next unit; dtk had sized the symbol 0x268 to cover it. Pad removed, symbols.txt size set to 0x264. + Unit data 2300/2300, .rodata 100%, pool identical. ACCEPTED.