Skip to content

Channel: decompile utility and WiiConnect24 targets - #46

Merged
GuestDreemurr merged 15 commits into
doldecomp:mainfrom
ridvansan:connect24
Oct 21, 2026
Merged

GuestDreemurr merged 15 commits into
doldecomp:mainfrom
ridvansan:connect24

Conversation

@ridvansan

Copy link
Copy Markdown
Contributor

matched some.

@decomp-dev

decomp-dev Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Report for HAFE (79e0b8e - b6dc371)

📈 Matched code: 81.26% (+1.13%, +17256 bytes)
📈 Linked code: 75.79% (+1.13%, +17256 bytes)
Total data: 1813678 bytes (-9 bytes)
📈 Matched data: 56.00% (+6.64%, +120423 bytes)
📈 Linked data: 81.91% (+6.64%, +120423 bytes)

✅ 43 new matches
Unit Item Bytes Before After
main/WiiConnect24 .bss +119112 0.00% 100.00%
main/WiiConnect24 CreateDownloadTasks(WC24Task*, unsigned long, unsigned long, unsigned char, unsigned short, unsigned short, unsigned long*) +2516 0.00% 100.00%
main/WiiConnect24 DownloaderThread(void*) +2276 0.00% 100.00%
main/WiiConnect24 DownloadFiles(WC24Task*, unsigned long, unsigned long) +1556 0.00% 100.00%
main/WiiConnect24 .data +1153 0.00% 100.00%
main/WiiConnect24 CWiiConnect24::setWeather(const char*, const char*, unsigned long, unsigned long, unsigned long) +1096 0.00% 100.00%
main/WiiConnect24 CWiiConnect24::getWeather(void*, long long*, unsigned long*, void*, long long*, unsigned long*, const char*, const char*, unsigned long, unsigned long, unsigned long) +1092 0.00% 100.00%
main/WiiConnect24 CWiiConnect24::downloadWeatherForecast(void*, long long*, unsigned long*, unsigned long) +1056 0.00% 100.00%
main/WiiConnect24 CWiiConnect24::downloadWeatherShort(void*, long long*, unsigned long*, unsigned long) +1056 0.00% 100.00%
main/WiiConnect24 CWiiConnect24::deleteWeather() +1032 0.00% 100.00%
main/WeatherUtil FormatDigits(long, long*, long) +676 0.00% 100.00%
main/WiiConnect24 DeleteTaskFiles(WC24Task*, unsigned long, unsigned long) +476 0.00% 100.00%
main/WiiConnect24 ReadCompressedFile(WC24Task*, void*, void*, unsigned long, unsigned long*) +472 0.00% 100.00%
main/WeatherUtil GetUniversalMinutes() +400 0.00% 100.00%
main/WeatherUtil MinutesToCalendarTime(unsigned long, OSCalendarTime*) +396 0.00% 100.00%
main/WiiConnect24 ExecuteDownloadTask(WC24Task*, long, unsigned long, unsigned short) +384 0.00% 100.00%
main/WeatherUtil SmoothApproachAngle(float*, float, float, float, float) +296 0.00% 100.00%
main/DragScroll DragScroll::UpdateChan(long) +272 0.00% 100.00%
main/WeatherUtil FormatInt(long, wchar_t*) +260 0.00% 100.00%
main/WeatherUtil FormatNumber(long, wchar_t*, long, int) +252 0.00% 100.00%
main/WiiConnect24 MapDownloadError(NWC24Err) +240 0.00% 100.00%
main/WeatherUtil SmoothApproach(float*, float, float, float, float) +180 0.00% 100.00%
main/WiiConnect24 InitDownloader() +172 0.00% 100.00%
main/WiiConnect24 ShutdownDownloader(long) +144 0.00% 100.00%
main/DragScroll DragScroll::Update() +140 0.00% 100.00%
main/WiiConnect24 UpdateDownloader() +96 0.00% 100.00%
main/MtxUtil RotateMtxDeg(nw4r::math::MTX34*, float, float, float) +80 0.00% 100.00%
main/MtxUtil RotateX(float(*)[4], float) +76 0.00% 100.00%
main/MtxUtil RotateY(float(*)[4], float) +76 0.00% 100.00%
main/MtxUtil RotateZ(float(*)[4], float) +76 0.00% 100.00%

...and 13 more new matches

Comment thread src/WiiConnect24Download.cpp Outdated
for (;;) {
error = NWC24OpenLib(&gNWC24Work);

if (error != -0x16 && error != -0x1A && error != -0x1D)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be changed to use the NWC24Err enum.

Comment thread src/WiiConnect24Download.cpp Outdated
static inline s32 CheckLib(WC24Task* task) {
s32 error = NWC24Check(2);

if (error != 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be "!= NWC24_OK"

Comment thread src/WiiConnect24Download.cpp Outdated
static inline s32 CloseLib(WC24Task* task) {
s32 error = NWC24CloseLib();

if (error != 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here

Comment thread src/WiiConnect24Download.cpp Outdated
opened = TRUE;

task->mResult = CheckLib(task);
if (task->mResult != 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 should be NWC24_OK

Comment thread src/WiiConnect24Download.cpp Outdated
break;

task->mState = 3;
if ((task->mResult = DownloadFiles(task, 1, 1)) == 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== 0 should be == NWC24_OK

Comment thread src/WiiConnect24Download.cpp Outdated
task->mState = 3;
if ((task->mResult = DownloadFiles(task, 1, 1)) == 0)
break;
if (task->mResult == -1 && attempts != 1) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 is NWC24_ERR_FATAL

ridvansan and others added 13 commits October 21, 2026 20:52
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>
Comment thread src/WiiConnect24.cpp Outdated
return 0;
}

s32 MapDownloadError(s32 error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@GuestDreemurr
GuestDreemurr merged commit af3637e into doldecomp:main Oct 21, 2026
1 check 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.

2 participants