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 Serves as the bridge between the game's profile system and the dynamic module linking system.
34/// @ingroup bases
35namespace dDyl {
36
37 /// @brief An entry in the @ref DynamicNameTable "profile to module name table".
39 ProfileName mProf; ///< The profile name of this entry.
40 const char *mModuleName; ///< The name of the module to load for the profile, or @p nullptr if the profile is statically linked.
41 };
42
43 /**
44 * @brief First initialization step of the dynamic module system.
45 * @details Creates the necessary data structures and maps the profiles to the
46 * corresponding modules using the provided name table.
47 * @param profileCount The total number of profiles.
48 * @param pNameTable The profile to module name table.
49 * @param nNameTable The number of entries in @p pNameTable.
50 * @param heap The heap to be used for allocations.
51 * @return Always returns @p true .
52 */
53 bool cCc_Init(int profileCount, const DynamicName_t *pNameTable, int nNameTable, EGG::Heap *heap);
54
55 /**
56 * @brief Initializes the dynamic module system.
57 *
58 * The initialization occurs in two steps:
59 * - #Init, which is run synchronously.
60 * - DynamicModuleCallback::InitCallback, which is run asynchronously.
61 */
62 void InitAsync();
63
64 /// @brief Checks whether initialization has completed.
65 /// @return @p true if initialization is complete, else @p false .
66 bool InitAsyncIsDone();
67
68 /**
69 * @brief Links the module associated with the given profile.
70 * @decompnote{The original implementation has been stripped from the final
71 * binary. The reconstructed code has been added inside a never-executing block.}
72 * @param profile The profile whose module needs to be linked.
73 * @return Non-zero on success, else zero.
74 */
75 int LinkASync(ProfileName profile);
76
77 /**
78 * @brief Unlinks the module associated with the given profile.
79 * @decompnote{The original implementation has been stripped from the final
80 * binary. The reconstructed code has been added inside a never-executing block.}
81 * @param profile The profile whose module needs to be unlinked.
82 * @return @p true on success, else @p false .
83 */
84 bool Unlink(ProfileName profile);
85
86 extern DynamicModuleControlBase **pDMC; ///< A table that keeps track of which module is associated with each profile.
87 extern int nDMC; ///< The number of entries in #pDMC.
88
89 /// @brief The heap to be used for allocating the @ref DynamicModuleControlBase "module handlers"
90 /// and the @ref pDMC "profile to module table".
91 extern EGG::FrmHeap *cCc_frmHeap;
92 extern BOOL Initialized; ///< Whether the dynamic module system has finished initializing.
93 extern mDvd_callback_c *DVD; ///< The asynchronous DVD task used during the dynamic module system initialization.
94};
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 fProf::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:35
DynamicModuleControlBase ** pDMC
A table that keeps track of which module is associated with each profile.
Definition d_dylink.cpp:18
bool cCc_Init(int profileCount, const DynamicName_t *pNameTable, int nNameTable, EGG::Heap *heap)
First initialization step of the dynamic module system.
Definition d_dylink.cpp:24
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:38
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:40
ProfileName mProf
The profile name of this entry.
Definition d_dylink.hpp:39