Skip to content

m_Do_main mostly matching for Wii versions#3165

Merged
TakaRikka merged 2 commits into
zeldaret:mainfrom
caseif:m_do_main-1
Jun 23, 2026
Merged

m_Do_main mostly matching for Wii versions#3165
TakaRikka merged 2 commits into
zeldaret:mainfrom
caseif:m_do_main-1

Conversation

@caseif

@caseif caseif commented May 28, 2026

Copy link
Copy Markdown
Contributor

This PR mostly matches m_Do_main for all Wii versions. The only remaining mismatches are crclr cr1eq instructions related to varargs calls. These can be fakematched for most versions by moving the vararg out to a variable, but this obviously breaks debug. I was able to link the file for RZDE01_02 with these fakematches, and presumably at least RZDJ01 and RZDP01 should also be linkable. RZDE01_00 is a little trickier to fakematch, so I haven't managed to link that version at all.

I've added a new PCH called dolzel_minimal which currently only pulls in JKRHeap.h. This allows the fake JKRHeap::dump_sort definition to be removed by fixing function ordering. I suspect this new PCH might be real in some capacity - the standard one won't work because the TU uses data pooling but Z2Calc::cNullVec and company aren't present, but at the same time I'm not aware of any other way to get MWCC to emit the JKRHeap function after __sinit.

@decomp-dev

decomp-dev Bot commented May 28, 2026

Copy link
Copy Markdown

Report for GZ2J01 (db28ce3 - 7783c52)

No changes

Report for RZDE01_02 (db28ce3 - 7783c52)

📈 Matched code: 54.67% (+0.01%, +1096 bytes)
📈 Matched data: 56.37% (+0.03%, +960 bytes)

✅ 8 new matches
Unit Item Bytes Before After
framework/m_Do/m_Do_main .data +722 8.89% 100.00%
framework/m_Do/m_Do_main main +150 71.08% 100.00%
framework/m_Do/m_Do_main .sdata +15 82.30% 100.00%
framework/m_Do/m_Do_main .sbss +12 88.89% 100.00%
framework/m_Do/m_Do_printf .sdata +8 0.00% 100.00%
framework/m_Do/m_Do_main LOAD_COPYDATE(void*) +1 99.67% 100.00%
framework/m_Do/m_Do_main __sinit_\m_Do_main_cpp +1 99.93% 100.00%
framework/m_Do/m_Do_printf OSReport_Error +1 99.92% 100.00%
📈 4 improvements in unmatched items
Unit Item Bytes Before After
framework/m_Do/m_Do_main main01() +1567 22.62% 99.41%
framework/m_Do/m_Do_main HeapCheck::heapDisplay() const 0 98.99% 99.10%
framework/m_Do/m_Do_printf OSReport_Warning 0 99.75% 99.83%
framework/d/d_cursor_mng .sbss -1 40.00% 50.00%

Report for ShieldD (db28ce3 - 7783c52)

📈 Matched code: 54.45% (+0.00%, +596 bytes)

✅ 1 new match
Unit Item Bytes Before After
framework/m_Do/m_Do_main main +69 88.46% 100.00%
📉 1 regression in an unmatched item
Unit Item Bytes Before After
framework/m_Do/m_Do_main .sdata2 -1 65.62% 62.50%

Report for Shield (db28ce3 - 7783c52)

📈 Matched code: 50.27% (+0.01%, +624 bytes)

✅ 1 new match
Unit Item Bytes Before After
framework/m_Do/m_Do_main debugDisplay() +23 96.46% 100.00%
📈 3 improvements in unmatched items
Unit Item Bytes Before After
framework/m_Do/m_Do_main main +97 78.88% 99.83%
framework/m_Do/m_Do_main .data +8 98.18% 99.25%
framework/m_Do/m_Do_main main01() 0 94.29% 94.31%

Report for GZ2P01 (db28ce3 - 7783c52)

No changes

Report for DZDE01 (db28ce3 - 7783c52)

📈 Matched code: 52.21% (+0.02%, +1964 bytes)
📈 Matched data: 55.16% (+0.03%, +992 bytes)

✅ 15 new matches
Unit Item Bytes Before After
framework/m_Do/m_Do_main .data +722 8.89% 100.00%
framework/m_Do/m_Do_main main +150 70.96% 100.00%
framework/m_Do/m_Do_main .sdata +18 82.85% 100.00%
framework/m_Do/m_Do_main .sbss +10 75.00% 100.00%
framework/m_Do/m_Do_printf .sbss +10 80.00% 100.00%
framework/m_Do/m_Do_printf .sdata +8 0.00% 100.00%
framework/m_Do/m_Do_main LOAD_COPYDATE(void*) +1 99.67% 100.00%
framework/m_Do/m_Do_main __sinit_\m_Do_main_cpp +1 99.93% 100.00%
framework/m_Do/m_Do_printf OSReportDisable +1 98.33% 100.00%
framework/m_Do/m_Do_printf OSReportEnable +1 98.33% 100.00%
framework/m_Do/m_Do_printf mDoPrintf_VReport +1 99.73% 100.00%
framework/m_Do/m_Do_printf OSReport_FatalError +1 99.83% 100.00%
framework/m_Do/m_Do_printf OSReport_Error +1 99.67% 100.00%
framework/m_Do/m_Do_printf OSReport_System +1 99.64% 100.00%
framework/m_Do/m_Do_controller_pad mDoCPd_c::create() +1 99.93% 100.00%
📈 7 improvements in unmatched items
Unit Item Bytes Before After
framework/m_Do/m_Do_main main01() +1567 22.60% 99.41%
framework/m_Do/m_Do_printf OSReport_Warning +1 99.50% 99.83%
framework/m_Do/m_Do_machine myExceptionCallback(unsigned short, OSContext*, unsigned long, unsigned long) +1 94.35% 94.45%
framework/m_Do/m_Do_main HeapCheck::heapDisplay() const 0 98.99% 99.10%
framework/m_Do/m_Do_graphic mDoGph_AfterOfDraw() 0 89.96% 90.00%
framework/m_Do/m_Do_machine mDoMch_Create() 0 82.34% 82.38%
framework/d/d_cursor_mng .sdata -1 36.53% 47.62%

Report for RZDJ01 (db28ce3 - 7783c52)

📈 Matched code: 53.84% (+0.01%, +1096 bytes)
📈 Matched data: 55.97% (+0.03%, +960 bytes)

✅ 8 new matches
Unit Item Bytes Before After
framework/m_Do/m_Do_main .data +722 8.89% 100.00%
framework/m_Do/m_Do_main main +150 71.08% 100.00%
framework/m_Do/m_Do_main .sdata +15 82.30% 100.00%
framework/m_Do/m_Do_main .sbss +12 88.89% 100.00%
framework/m_Do/m_Do_printf .sdata +8 0.00% 100.00%
framework/m_Do/m_Do_main LOAD_COPYDATE(void*) +1 99.67% 100.00%
framework/m_Do/m_Do_main __sinit_\m_Do_main_cpp +1 99.93% 100.00%
framework/m_Do/m_Do_printf OSReport_Error +1 99.92% 100.00%
📈 4 improvements in unmatched items
Unit Item Bytes Before After
framework/m_Do/m_Do_main main01() +1567 22.62% 99.41%
framework/m_Do/m_Do_main HeapCheck::heapDisplay() const 0 98.99% 99.10%
framework/m_Do/m_Do_printf OSReport_Warning 0 99.75% 99.83%
framework/d/d_cursor_mng .sbss -1 40.00% 50.00%

Report for RZDE01_00 (db28ce3 - 7783c52)

📈 Matched code: 47.05% (+0.01%, +984 bytes)
📈 Matched data: 53.99% (+0.00%, +136 bytes)

✅ 8 new matches
Unit Item Bytes Before After
framework/m_Do/m_Do_main main +165 67.03% 100.00%
framework/m_Do/m_Do_main .sdata +44 46.45% 100.00%
framework/m_Do/m_Do_main HeapCheck::getTargetHeapSize() +24 0.00% 100.00%
framework/m_Do/m_Do_main .sbss +12 88.89% 100.00%
framework/m_Do/m_Do_printf .sdata +8 0.00% 100.00%
framework/m_Do/m_Do_main HeapCheck::CheckHeap1() +1 99.76% 100.00%
framework/m_Do/m_Do_main LOAD_COPYDATE(void*) +1 99.67% 100.00%
framework/m_Do/m_Do_printf OSReport_Error +1 99.92% 100.00%
📈 5 improvements in unmatched items
Unit Item Bytes Before After
framework/m_Do/m_Do_main main01() +1665 15.95% 99.40%
framework/m_Do/m_Do_main .data +920 5.04% 97.07%
framework/m_Do/m_Do_main HeapCheck::heapDisplay() +443 0.00% 95.69%
framework/m_Do/m_Do_printf OSReport_Warning 0 99.67% 99.75%
framework/d/d_cursor_mng .sbss -1 40.00% 50.00%

Report for GZ2E01 (db28ce3 - 7783c52)

No changes

Report for RZDP01 (db28ce3 - 7783c52)

📈 Matched code: 53.71% (+0.01%, +1096 bytes)
📈 Matched data: 55.62% (+0.03%, +976 bytes)

✅ 9 new matches
Unit Item Bytes Before After
framework/m_Do/m_Do_main .data +722 8.89% 100.00%
framework/m_Do/m_Do_main main +150 71.08% 100.00%
framework/m_Do/m_Do_main .sdata +15 82.30% 100.00%
framework/m_Do/m_Do_main .sbss +12 88.89% 100.00%
framework/m_Do/m_Do_printf .sdata +8 0.00% 100.00%
framework/m_Do/m_Do_main LOAD_COPYDATE(void*) +1 99.67% 100.00%
framework/m_Do/m_Do_main __sinit_\m_Do_main_cpp +1 99.93% 100.00%
framework/m_Do/m_Do_printf OSReport_Error +1 99.92% 100.00%
framework/d/d_cursor_mng .sbss -4 83.33% 100.00%
📈 3 improvements in unmatched items
Unit Item Bytes Before After
framework/m_Do/m_Do_main main01() +1567 22.62% 99.41%
framework/m_Do/m_Do_main HeapCheck::heapDisplay() const 0 98.99% 99.10%
framework/m_Do/m_Do_printf OSReport_Warning 0 99.67% 99.75%

@caseif

caseif commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

The regression in ShieldD is due to signaling_NaN constants getting pulled in by the PCH (as they should), but with the wrong placement in .sdata2.

@LagoLunatic

Copy link
Copy Markdown
Contributor

I've added a new PCH called dolzel_minimal which currently only pulls in JKRHeap.h. This allows the fake JKRHeap::dump_sort definition to be removed by fixing function ordering. I suspect this new PCH might be real in some capacity - the standard one won't work because the TU uses data pooling but Z2Calc::cNullVec and company aren't present, but at the same time I'm not aware of any other way to get MWCC to emit the JKRHeap function after __sinit.

Because we know the d_ TUs used a PCH called dolzel.pch, I wonder if the m_Do_ TUs used a separate PCH called machine.pch? Maybe try using the new PCH in every m_Do_ TU for consistency, and if that doesn't break any of them rename the PCH to make it more clear that this one isn't related to dolzel.

@caseif

caseif commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

@LagoLunatic That's a good call, I've updated the branch with the change implemented. It doesn't seem to cause any regressions (after a small include change in m_Do_ext), so I think a machine-specific PCH is very likely to be real.

Comment thread include/m_Do/machine.h Outdated
Comment thread include/m_Do/machine.pch
Comment thread src/m_Do/m_Do_ext.cpp Outdated
@caseif

caseif commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

All noted issues should be fixed and the branch has been rebased on latest main.

@TakaRikka TakaRikka merged commit 8eae891 into zeldaret:main Jun 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants