Repository navigation
Channel: decompile utility and WiiConnect24 targets - #46
Merged
Merged
Conversation
Report for HAFE (79e0b8e - b6dc371)📈 Matched code: 81.26% (+1.13%, +17256 bytes) ✅ 43 new matches
...and 13 more new matches |
| for (;;) { | ||
| error = NWC24OpenLib(&gNWC24Work); | ||
|
|
||
| if (error != -0x16 && error != -0x1A && error != -0x1D) |
Member
There was a problem hiding this comment.
this should be changed to use the NWC24Err enum.
| static inline s32 CheckLib(WC24Task* task) { | ||
| s32 error = NWC24Check(2); | ||
|
|
||
| if (error != 0) |
| static inline s32 CloseLib(WC24Task* task) { | ||
| s32 error = NWC24CloseLib(); | ||
|
|
||
| if (error != 0) |
| opened = TRUE; | ||
|
|
||
| task->mResult = CheckLib(task); | ||
| if (task->mResult != 0) |
| break; | ||
|
|
||
| task->mState = 3; | ||
| if ((task->mResult = DownloadFiles(task, 1, 1)) == 0) |
Member
There was a problem hiding this comment.
== 0 should be == NWC24_OK
| task->mState = 3; | ||
| if ((task->mResult = DownloadFiles(task, 1, 1)) == 0) | ||
| break; | ||
| if (task->mResult == -1 && attempts != 1) { |
CodeWarrior doesn't mangle global variable names, so extern "C" on the channel's globals did nothing. Variables are now plain (extern const for the shared float constants, which need external linkage in C++). Game functions get normal C++ linkage; symbols.txt now uses their mangled names (FormatDigits__FlPll, WC24Alloc__FUll, ...), and the callers in System.cpp and SceneBase.cpp are updated. extern "C" stays only on the locally declared SDK C functions (SO*, NWC24*, SCGetIdleMode). Also note that SmoothApproach/SmoothApproachAngle are the addCalc idiom. The DOL still matches and no function regressed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| return 0; | ||
| } | ||
|
|
||
| s32 MapDownloadError(s32 error) { |
Member
There was a problem hiding this comment.
NWC24Err function, needs to be changed.
… into one TU
WiiConnect24Lifecycle.cpp, WiiConnect24Heap.cpp and WiiConnect24Code.cpp were
arbitrary splits of the same translation unit as WiiConnect24.cpp. Merge them:
WiiConnect24.cpp .text 0x80032610-0x80035BA8 (was four units)
InitDownloader, UpdateDownloader, ShutdownDownloader,
CWiiConnect24 methods, DownloaderThread, DownloadFiles,
CreateDownloadTasks, ExecuteDownloadTask, DeleteTaskFiles,
MapDownloadError, ReadCompressedFile, WC24Alloc, WC24Free
Proof that they share a TU: the merged unit still matches 100 % (17/17
functions, 13720/13720 bytes) and the DOL still matches.
Matching subtlety found while doing it: the globals must be *defined after*
the functions (extern declarations before them). With the definitions at the
top, MWCC's IPA addresses the .bss globals through one base register, which
shrank InitDownloader from 172 to 164 bytes and broke the DOL.
MapDownloadError is an NWC24Err function: the local is an NWC24Err from the
start and the mapping is written with the NWC24_ERR_* enumerators instead of
raw negative numbers, so no cast is needed at the return. The parameter stays
s32 because the target symbol is MapDownloadError__Fl and an enum parameter
would mangle as __F9NWC24Err.
The WC24 download helpers returned raw s32 codes that are, value for value, the NWC24Err codes, and MapDownloadError was typed on s32 even though it maps one NWC24 error to another. Untangle the two error domains: - MapDownloadError takes and returns NWC24Err (the symbol is now MapDownloadError__F8NWC24Err) and its mapping is written with the NWC24_ERR_* enumerators. - DownloadFiles, CreateDownloadTasks, ExecuteDownloadTask, DeleteTaskFiles and ReadCompressedFile return NWC24Err, and their results are NWC24_OK / NWC24_ERR_* instead of -1/-5/-7/-8/-9/-0xA. - NWC24 API results live in NWC24Err locals. Driver errors that used to share those locals now have their own s32 vfError / nandResult, and the NAND checks use NAND_RESULT_NOEXISTS / NAND_RESULT_OK. - The NWC24 comparisons use NWC24_ERR_NOT_FOUND and NWC24_OK, so SetTaskError no longer needs a cast. No instruction changed: the unit is still 17/17 functions and 13720/13720 bytes at 100 %, and the DOL still matches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
matched some.