NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_dylink.hpp
1#pragma once
2
4#include <game/cLib/c_dylink.hpp>
5#include <lib/egg/core/eggExpHeap.h>
6
7/// @copydoc DynamicModuleControl
8/// @ingroup bases
10public:
11 dDynamicModuleControl(const char *name, EGG::ExpHeap *heap); ///< @copydoc DynamicModuleControl::DynamicModuleControl
12 virtual ~dDynamicModuleControl(); ///< @copydoc DynamicModuleControl::~DynamicModuleControl
13
14 virtual bool do_link() override;
15};
16
17namespace DynamicModuleCallback {
18 /**
19 * @brief Second initialization step of the dynamic module system.
20 * @details The function performs the following remaining tasks:
21 * - Initializes the underlying dynamic module linking system.
22 * - Loads the string table file from disc.
23 * - Links the @ref s_ProfileDMC "d_profile module".
24 * @ingroup bases
25 * @note If the core module fails to link, the function enters an infinite loop.
26 * @note The return type is @p void* to satisfy the type required by mDvd_callback_c.
27 * @param self Unused (heap pointer passed through callback system).
28 * @return Always returns @p true .
29 */
30 void *InitCallback(void *self);
31}
32
33/// @brief An entry in the @ref DynamicNameTable "profile to module name table".
34/// @ingroup bases
35/// @unofficial
37 ProfileName mProf; ///< The profile name of this entry.
38 const char *mModuleName; ///< The name of the module to load for the profile, or @p nullptr if the profile is statically linked.
39};
40
41/// @brief Serves as the bridge between the game's profile system and the dynamic module linking system.
42/// @ingroup bases
43namespace dDyl {
44
45 /**
46 * @brief First initialization step of the dynamic module system.
47 * @details Creates the necessary data structures and maps the profiles to the
48 * corresponding modules using the provided name table.
49 * @unofficial
50 * @param profileCount The total number of profiles.
51 * @param pNameTable The profile to module name table.
52 * @param nNameTable The number of entries in @p pNameTable.
53 * @param heap The heap to be used for allocations.
54 * @return Always returns @p true .
55 */
56 bool Init(int profileCount, const sDynNameTableEntry *pNameTable, int nNameTable, EGG::Heap *heap);
57
58 /**
59 * @brief Initializes the dynamic module system.
60 *
61 * The initialization occurs in two steps:
62 * - #Init, which is run synchronously.
63 * - DynamicModuleCallback::InitCallback, which is run asynchronously.
64 */
65 void InitAsync();
66
67 /// @brief Checks whether initialization has completed.
68 /// @return @p true if initialization is complete, else @p false .
69 bool InitAsyncIsDone();
70
71 /**
72 * @brief Links the module associated with the given profile.
73 * @decompnote{The original implementation has been stripped from the final
74 * binary. The reconstructed code has been added inside a never-executing block.}
75 * @param profile The profile whose module needs to be linked.
76 * @return Non-zero on success, else zero.
77 */
78 int LinkASync(ProfileName profile);
79
80 /**
81 * @brief Unlinks the module associated with the given profile.
82 * @decompnote{The original implementation has been stripped from the final
83 * binary. The reconstructed code has been added inside a never-executing block.}
84 * @param profile The profile whose module needs to be unlinked.
85 * @return @p true on success, else @p false .
86 */
87 bool Unlink(ProfileName profile);
88
89 extern DynamicModuleControlBase **pDMC; ///< A table that keeps track of which module is associated with each profile.
90 extern int nDMC; ///< The number of entries in #pDMC.
91
92 /// @brief The heap to be used for allocating the @ref DynamicModuleControlBase "module handlers"
93 /// and the @ref pDMC "profile to module table".
94 extern EGG::FrmHeap *cCc_frmHeap;
95 extern BOOL Initialized; ///< Whether the dynamic module system has finished initializing.
96 extern mDvd_callback_c *DVD; ///< The asynchronous DVD task used during the dynamic module system initialization.
97};
Base class for managing a relocatable module.
Definition c_dylink.hpp:46
DynamicModuleControl(const char *name, EGG::ExpHeap *heap)
Constructs a new DynamicModuleControl.
Definition c_dylink.cpp:86
dDynamicModuleControl(const char *name, EGG::ExpHeap *heap)
Constructs a new DynamicModuleControl.
Definition d_dylink.cpp:125
virtual bool do_link() override
Module-specific implementation for linking the module, making it ready for use.
Definition d_dylink.cpp:127
virtual ~dDynamicModuleControl()
Destroys the DynamicModuleControl.
Definition d_dylink.cpp:123
void * InitCallback(void *self)
Second initialization step of the dynamic module system.
Definition d_dylink.cpp:84
u16 ProfileName
The name of a profile. Value is a fProfile::PROFILE_NAME_e.
Definition f_profile.hpp:32
Serves as the bridge between the game's profile system and the dynamic module linking system.
Definition d_dylink.hpp:43
bool Init(int profileCount, const sDynNameTableEntry *pNameTable, int nNameTable, EGG::Heap *heap)
First initialization step of the dynamic module system.
Definition d_dylink.cpp:24
DynamicModuleControlBase ** pDMC
A table that keeps track of which module is associated with each profile.
Definition d_dylink.cpp:18
EGG::FrmHeap * cCc_frmHeap
The heap to be used for allocating the module handlers and the profile to module table.
Definition d_dylink.cpp:20
void InitAsync()
Initializes the dynamic module system.
Definition d_dylink.cpp:106
int LinkASync(ProfileName profile)
Links the module associated with the given profile.
Definition d_dylink.cpp:73
bool InitAsyncIsDone()
Checks whether initialization has completed.
Definition d_dylink.cpp:111
int nDMC
The number of entries in pDMC.
Definition d_dylink.cpp:19
mDvd_callback_c * DVD
The asynchronous DVD task used during the dynamic module system initialization.
Definition d_dylink.cpp:22
bool Unlink(ProfileName profile)
Unlinks the module associated with the given profile.
Definition d_dylink.cpp:62
BOOL Initialized
Whether the dynamic module system has finished initializing.
Definition d_dylink.cpp:21
An entry in the profile to module name table.
Definition d_dylink.hpp:36
const char * mModuleName
The name of the module to load for the profile, or nullptr if the profile is statically linked.
Definition d_dylink.hpp:38
ProfileName mProf
The profile name of this entry.
Definition d_dylink.hpp:37