Skip to content

Decompile Game_16#167

Merged
AetiasHax merged 7 commits into
zeldaret:mainfrom
0Aurel:main
May 23, 2026
Merged

Decompile Game_16#167
AetiasHax merged 7 commits into
zeldaret:mainfrom
0Aurel:main

Conversation

@0Aurel
Copy link
Copy Markdown
Contributor

@0Aurel 0Aurel commented May 16, 2026

Closes #105

First PR on the project, let me know if anything needs fixing!

Copy link
Copy Markdown
Collaborator

@Yanis002 Yanis002 left a comment

Choose a reason for hiding this comment

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

just some ctor stuff, otherwise looks good to me

Comment thread src/16_Startup/Game/Game_16.cpp Outdated
Comment thread src/16_Startup/Game/Game_16.cpp Outdated
Comment on lines +16 to +17
func_ov016_0211fab8(mUnk_00c, (void (*)()) _ZN4Game13func_0202cf44Ev, this, 0);
_ZN11FadeControlC2Ev(&mFadeControl);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this looks a little bit wrong, C2 is a constructor used to initialise a base class when a class is derived from another, I think this ctor is probably like ARM Game::Game() : mModeId(1), mPrevModeId(1), mMode(NULL), mUnk_00c(Game::func_0202cf44, this, 0) {...}

mUnk_00c must be defined as:

typedef void (*UnkCallback)();
class Game_0c {
public:
    Game_0c(UnkCallback callback, void* param2, unk32 param3); // func_ov016_0211fab8
};

then for mFadeControl the type must be FadeControl, the class is already existing iirc, also Game::func_0202cf44 must be static, looks like it's a static function taking Game as a parameter according to what ghidra shows me

idk how much you know about c++ but basically I think this requires a ctor init list (iirc that's how it's called) to initialize members before those ctor calls

btw feel free to join the discord server if you have any questions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was curious about the fadecontrol stuff so: https://decomp.me/scratch/XfIou, I'm not sure if it's supposed to be derived or if the symbol is simply mislabeled, either way that scratch should be more explicit than my previous explanations

if you have any questions feel free to ask of course

@0Aurel 0Aurel marked this pull request as draft May 16, 2026 13:54
0Aurel added 3 commits May 16, 2026 16:22
Address Yanis' review comments:
- Make Game::func_0202cf44 static with Game* parameter to allow
  passing as callback pointer
- Replace raw mUnk_00c array with Game_0c class containing constructor
- Add Game_0c constructor with inline initialization calling func_ov016_0211fab8
- Add FadeControl_Derived1 class for mFadeControl member
- Use C++ initializer list in Game constructor for mModeId, mPrevModeId,
  mMode, mUnk_00c, and mFadeControl
@decomp-dev
Copy link
Copy Markdown

decomp-dev Bot commented May 16, 2026

Report for eur (0bb7400 - 5b73154)

📈 Matched code: 2.77% (+0.01%, +228 bytes)

✅ 3 new matches
Unit Item Bytes Before After
src/Main/Game/Game Game::func_0202cf44(Game*) +368 0.00% 100.00%
src/16_Startup/Game/Game_16 Game::func_ov016_0211fd68() +115 1.38% 100.00%
src/16_Startup/Game/Game_16 Game::Game() +89 21.36% 100.00%
🥀 1 broken match
Unit Item Bytes Before After
src/Main/Game/Game Game::func_0202cf44() -368 100.00% 0.00%

Report for usa (0bb7400 - 5b73154)

📈 Matched code: 2.75% (+0.01%, +228 bytes)

✅ 3 new matches
Unit Item Bytes Before After
src/Main/Game/Game Game::func_0202cf44(Game*) +368 0.00% 100.00%
src/16_Startup/Game/Game_16 Game::func_ov016_0211fd68() +115 1.38% 100.00%
src/16_Startup/Game/Game_16 Game::Game() +89 21.36% 100.00%
🥀 1 broken match
Unit Item Bytes Before After
src/Main/Game/Game Game::func_0202cf44() -368 100.00% 0.00%

Comment thread include/Game/Game.hpp Outdated
Comment thread include/Game/Game.hpp Outdated
Comment thread libs/nds/include/nds/system.h

void FadeControl::Register() {}
void FadeControl::Unregister() {}
FadeControl::FadeControl() {}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this change is confusing me a bit, is it not building with that defined in the source? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, the build was failing with it. I'm not sure why but I added it back in the last commit

- Use PAD macro in Game_0c instead of unk8 pad[]
- Pass 'this' instead of 'pad' to func_ov016_0211fab8
- Add FadeControl constructor that calls _ZN11FadeControlC2Ev
- FadeControl_Derived1 now uses empty constructor (base class ctor called automatically)
- Update mUnk_00c.pad to mUnk_00c.pad_0x00 (PAD macro creates named member)
- Add types.h include to nds/system.h
@0Aurel 0Aurel marked this pull request as ready for review May 16, 2026 20:04
Copy link
Copy Markdown
Collaborator

@Yanis002 Yanis002 left a comment

Choose a reason for hiding this comment

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

last thing I promise 🙏

Comment thread src/Main/Render/FadeControl.cpp Outdated
- Removed _ZN11FadeControlC2Ev call from FadeControl constructor
- FadeControl now has an empty constructor (called automatically by derived classes)
- FadeControl_Derived1 uses empty constructor which calls base class ctor
Copy link
Copy Markdown
Collaborator

@Yanis002 Yanis002 left a comment

Choose a reason for hiding this comment

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

🎉 💪

Copy link
Copy Markdown
Collaborator

@AetiasHax AetiasHax left a comment

Choose a reason for hiding this comment

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

One quick thing before merging, there's a broken match as you can see in the decomp.dev comment above. I put some instructions in my review comment.

Comment thread include/Game/Game.hpp
Changed mangled name from _ZN4Game13func_0202cf44Ev to
_ZN4Game13func_0202cf44EPS_ to reflect the function becoming
static with a Game* parameter.
@0Aurel 0Aurel requested a review from AetiasHax May 23, 2026 12:07
@AetiasHax AetiasHax merged commit 51640eb into zeldaret:main May 23, 2026
3 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.

src/16_Startup/Game/Game.cpp

3 participants