NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
|
#include <game/framework/f_base.hpp>
The base class for all scenes, actors and various other processes.
fBase_c defines the core elements of a process, to provide common behaviour across all bases.
The most significant components are:
A base can be created by calling the createRoot or the createChild functions. Most subclasses provide their own implementations of these functions with additional parameters available; their use is recommended.
The overloaded new operator ensures that bases are zero-initialized (therefore initializing fields to zero is not necessary), while the delete operator is provided for convenience.
Bases can be deleted by calling deleteRequest on them. A base will be informed of its impending deletion when its deleteReady method is called. Please note that deleting a base will delete all its children as well.
A small iteration API is provided:
For conducting searches across the entire base tree, please refer to fManager_c.
The mGroupType field offers basic type information about a base:
No base inherits fBase_c directly.
The lifecycle of a base consists of multiple operations, whose behaviour can be overridden by any of the subclasses. Each operation has an associated linked list, containing all bases for which said operation is scheduled for the current frame. fBase_c (and fManager_c) manage operation scheduling internally, therefore developer interaction is not required.
Every operation is composed by three steps: pre
, do
and post
(each with their own methods). While the do
method is generally reserved for profile-specific behaviour, the pre
and post
methods are commonly used to supply shared behaviour in base classes.
The pre
and do
steps return a PACK_RESULT_e value, which is converted to a MAIN_STATE_e value to determine the result of the operation. Said value is then passed to the post
method, which acts accordingly.
pre step result | do step result | post argument |
---|---|---|
NOT_READY | N/A (not run) | CANCELED |
SUCCEEDED | NOT_READY | WAITING |
SUCCEEDED | SUCCEEDED | SUCCESS |
SUCCEEDED | FAILED | ERROR |
Operations are carried out by the commonPack function.
fBase_c defines four core operations:
create
runs immediately after construction, and can be used to set up the base or load resources for it. The operation result leads to three possible outcomes:
execute
serves as the base's own main loop, running every frame. This operation can be skipped by enabling the relevant PROC_DISABLE_e flag.draw
offers an alternative main loop specifically for rendering code. It also runs every frame, and can be skipped by enabling the relevant PROC_DISABLE_e flag.delete
runs immediately before destruction, and can be used to deallocate resources or remove links to other bases. This operation will not proceed until all the base's children are deleted.
connect
is an internal operation for process management that runs every frame along the aforementioned four; bases should not override it. See connectProc for more information on the tasks carried out in this operation.
Two additional unused list-like structures are present in the class: mpUnusedHelper and mUnusedList. Since the symbols for the related functions have not yet been cracked, it's difficult to tell what their purpose might have been.
Definition at line 119 of file f_base.hpp.
Public Types | |
enum | LIFECYCLE_e { CREATING , ACTIVE , DELETING } |
The possible lifecycle states. More... | |
enum | GROUP_TYPE_e { OTHER , SCENE , ACTOR } |
The possible group types. More... | |
enum | MAIN_STATE_e { CANCELED , ERROR , SUCCESS , WAITING } |
The possible operation results. More... | |
enum | PACK_RESULT_e { NOT_READY , SUCCEEDED , FAILED } |
The possible operation step results. More... | |
enum | PROC_DISABLE_e { ROOT_DISABLE_EXECUTE = BIT_FLAG(0) , DISABLE_EXECUTE = BIT_FLAG(1) , ROOT_DISABLE_DRAW = BIT_FLAG(2) , DISABLE_DRAW = BIT_FLAG(3) } |
Controls if the execute and draw operations should be skipped. More... | |
Public Member Functions | |
fBase_c () | |
Constructs a new base. | |
void | deleteRequest () |
Requests deletion of the base. | |
fBase_c * | getConnectParent () const |
Gets the base's parent. | |
fBase_c * | getConnectChild () const |
Gets the base's first child. | |
fBase_c * | getConnectBrNext () const |
Gets the base's next sibling. | |
bool | checkChildProcessCreateState () const |
Checks if the base has at least one child in the CREATING state. | |
Static Public Member Functions | |
static void * | operator new (size_t) |
new operator override for all bases. | |
static void | operator delete (void *) |
delete operator override for all bases. | |
static fBase_c * | createChild (ProfileName profName, fBase_c *parent, unsigned long param, u8 groupType) |
Creates a child base under the given parent. | |
static fBase_c * | createRoot (ProfileName profName, unsigned long param, u8 groupType) |
Creates a root base. | |
Public Attributes | |
fBaseID_e | mUniqueID |
The base's unique identifier. | |
u32 | mParam |
A bitfield that configures the base's behaviour. Its usage varies from profile to profile. | |
ProfileName | mProfName |
The base's profile name. | |
Protected Member Functions | |
bool | isProcControlFlag (u8 flag) const |
Checks if a flag is set in mProcControl. | |
void | setProcControlFlag (u8 flag) |
Sets a flag in mProcControl. | |
void | clearProcControlFlag (u8 flag) |
Clears a flag in mProcControl. | |
virtual int | create () |
do method for the create operation. | |
virtual int | preCreate () |
pre method for the create operation. | |
virtual void | postCreate (MAIN_STATE_e state) |
post method for the create operation. | |
virtual int | doDelete () |
do method for the delete operation. | |
virtual int | preDelete () |
pre method for the delete operation. | |
virtual void | postDelete (MAIN_STATE_e state) |
post method for the delete operation. | |
virtual int | execute () |
do method for the execute operation. | |
virtual int | preExecute () |
pre method for the execute operation. | |
virtual void | postExecute (MAIN_STATE_e state) |
post method for the execute operation. | |
virtual int | draw () |
do method for the draw operation. | |
virtual int | preDraw () |
pre method for the draw operation. | |
virtual void | postDraw (MAIN_STATE_e state) |
post method for the draw operation. | |
virtual void | deleteReady () |
Informs the base that it's about to be deleted. | |
virtual bool | entryFrmHeap (unsigned long size, EGG::Heap *parentHeap) |
[Unused]. Creates a heap of the given size for the base. | |
virtual bool | entryFrmHeapNonAdjust (unsigned long size, EGG::Heap *parentHeap) |
[Unused]. Creates a heap of the given size for the base. | |
virtual bool | createHeap () |
[Unused]. [Does nothing]. | |
virtual | ~fBase_c () |
Destroys the base. | |
Protected Attributes | |
u8 | mLifecycleState |
The base's lifecycle state. Value is a LIFECYCLE_e. | |
bool | mDeleteRequested |
If deletion of the base was requested, but the delete operation has not been scheduled yet. | |
bool | mDeferExecute |
If the create operation was completed, but scheduling the execute and draw operations isn't possible at this time. | |
bool | mDeferRetryCreate |
If the create operation has not been completed, and rescheduling it isn't possible at this time. | |
u8 | mGroupType |
The base's group type. Value is a GROUP_TYPE_e. | |
u8 | mProcControl |
The operations to be skipped. Value is a PROC_DISABLE_e. | |
fManager_c | mMng |
The base's process manager. | |
fBaHelper_c * | mpUnusedHelper |
[Unused]. See Unused Content. | |
fLiMgBa_c | mUnusedList |
[Unused]. See Unused Content. | |
EGG::FrmHeap * | mHeap |
[Unused]. The base's dedicated heap. | |
Static Protected Attributes | |
static int(* | sLoadAsyncCallback )() |
[Unused]. See Unused Content. | |
static void(* | sUnloadCallback )() |
[Unused]. See Unused Content. | |
Private Member Functions | |
int | createPack () |
Executes the create operation. See commonPack. | |
int | deletePack () |
Executes the delete operation. See commonPack. | |
int | executePack () |
Executes the execute operation. See commonPack. | |
int | drawPack () |
Executes the draw operation. See commonPack. | |
int | commonPack (int(fBase_c::*doFunc)(), int(fBase_c::*preFunc)(), void(fBase_c::*postFunc)(MAIN_STATE_e)) |
Executes an operation. See here for more details. | |
int | connectProc () |
Executes the connect operation. | |
void | runCreate () |
Kickstarts the base's lifecycle by running the create operation. | |
fBase_c * | getChildProcessCreateState () const |
Gets a child of the base in the CREATING state. | |
Static Private Member Functions | |
static void | setTmpCtData (ProfileName profName, fTrNdBa_c *connectParent, unsigned long param, u8 groupType) |
Sets temporary data to be used for the next base's construction. | |
static fBase_c * | fBase_make (ProfileName profName, fTrNdBa_c *connectParent, unsigned long param, u8 groupType) |
Internal function for base construction. | |
Static Private Attributes | |
static fBaseID_e | m_rootUniqueID = BASE_ID_FIRST |
Unique ID counter for base construction. See mUniqueID. | |
static u32 | m_tmpCtParam |
Temporary storage for the next constructed base's params. See mParam. | |
static ProfileName | m_tmpCtProfName |
Temporary storage for the next constructed base's profile name. See mProfName. | |
static u8 | m_tmpCtGroupType |
Temporary storage for the next constructed base's group type. See mGroupType. | |
static fTrNdBa_c * | m_tmpCtConnectParent |
Temporary storage for the next constructed base's parent connect node. | |
enum fBase_c::LIFECYCLE_e |
The possible lifecycle states.
Enumerator | |
---|---|
CREATING | The base's |
ACTIVE | The base is in the main execution cycle. |
DELETING | The base's |
Definition at line 123 of file f_base.hpp.
The possible group types.
Enumerator | |
---|---|
OTHER | The base is a generic process. |
SCENE | The base is a scene. |
ACTOR | The base is an actor. |
Definition at line 130 of file f_base.hpp.
The possible operation results.
Definition at line 137 of file f_base.hpp.
The possible operation step results.
Enumerator | |
---|---|
NOT_READY | The step could not completed at this time. |
SUCCEEDED | The step was completed successfully. |
FAILED | The step could not be completed. |
Definition at line 145 of file f_base.hpp.
Controls if the execute
and draw
operations should be skipped.
Definition at line 152 of file f_base.hpp.
fBase_c::fBase_c | ( | ) |
Constructs a new base.
Definition at line 15 of file f_base.cpp.
|
protectedvirtual |
Destroys the base.
Definition at line 57 of file f_base.cpp.
|
inlineprotected |
Checks if a flag is set in mProcControl.
Definition at line 187 of file f_base.hpp.
|
inlineprotected |
Sets a flag in mProcControl.
Definition at line 189 of file f_base.hpp.
|
inlineprotected |
Clears a flag in mProcControl.
Definition at line 191 of file f_base.hpp.
|
static |
new
operator override for all bases.
Bases are allocated in mHeap::g_gameHeaps[0] in a top-down direction, and are zero-initialized.
Definition at line 438 of file f_base.cpp.
|
static |
delete
operator override for all bases.
Definition at line 446 of file f_base.cpp.
|
protectedvirtual |
do
method for the create
operation.
Reimplemented in dControllerInformation_c, and dYesNoWindow_c.
Definition at line 88 of file f_base.cpp.
|
protectedvirtual |
pre
method for the create
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 92 of file f_base.cpp.
|
protectedvirtual |
post
method for the create
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 96 of file f_base.cpp.
|
protectedvirtual |
do
method for the delete
operation.
This method was renamed due to conflict with the delete
C++ keyword.
Reimplemented in dControllerInformation_c, and dYesNoWindow_c.
Definition at line 118 of file f_base.cpp.
|
protectedvirtual |
pre
method for the delete
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 126 of file f_base.cpp.
|
protectedvirtual |
post
method for the delete
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 142 of file f_base.cpp.
|
protectedvirtual |
do
method for the execute
operation.
Reimplemented in dControllerInformation_c, and dYesNoWindow_c.
Definition at line 168 of file f_base.cpp.
|
protectedvirtual |
pre
method for the execute
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 172 of file f_base.cpp.
|
protectedvirtual |
post
method for the execute
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 180 of file f_base.cpp.
|
protectedvirtual |
do
method for the draw
operation.
Reimplemented in dControllerInformation_c, and dYesNoWindow_c.
Definition at line 188 of file f_base.cpp.
|
protectedvirtual |
pre
method for the draw
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 192 of file f_base.cpp.
|
protectedvirtual |
post
method for the draw
operation.
Reimplemented in dBase_c, dBaseActor_c, dMdActor_c, dScene_c, and dWmActor_c.
Definition at line 200 of file f_base.cpp.
|
protectedvirtual |
Informs the base that it's about to be deleted.
Definition at line 208 of file f_base.cpp.
|
protectedvirtual |
[Unused]. Creates a heap of the given size for the base.
If the requested heap space is not available, the heap is adjusted to allocate all the available memory. If that also fails, the base is deleted.
size | The heap's size, or -1 to allocate all available space. |
parentHeap | The parent heap, or nullptr to use the current heap. |
Definition at line 324 of file f_base.cpp.
|
protectedvirtual |
[Unused]. Creates a heap of the given size for the base.
Unlike entryFrmHeap, the base is immediately deleted if the requested space is not available.
size | The heap's size, or -1 to allocate all available space. |
parentHeap | The parent heap, or nullptr to use the current heap. |
Definition at line 408 of file f_base.cpp.
|
protectedvirtual |
[Unused]. [Does nothing].
Definition at line 434 of file f_base.cpp.
void fBase_c::deleteRequest | ( | ) |
Requests deletion of the base.
Calling this function multiple times has no effect.
Definition at line 289 of file f_base.cpp.
fBase_c * fBase_c::getConnectParent | ( | ) | const |
Gets the base's parent.
Definition at line 303 of file f_base.cpp.
fBase_c * fBase_c::getConnectChild | ( | ) | const |
Gets the base's first child.
Definition at line 310 of file f_base.cpp.
fBase_c * fBase_c::getConnectBrNext | ( | ) | const |
Gets the base's next sibling.
Definition at line 317 of file f_base.cpp.
bool fBase_c::checkChildProcessCreateState | ( | ) | const |
Checks if the base has at least one child in the CREATING state.
Definition at line 479 of file f_base.cpp.
|
private |
Executes the create
operation. See commonPack.
Definition at line 122 of file f_base.cpp.
|
private |
Executes the delete
operation. See commonPack.
Definition at line 164 of file f_base.cpp.
|
private |
Executes the execute
operation. See commonPack.
Definition at line 184 of file f_base.cpp.
|
private |
Executes the draw
operation. See commonPack.
Definition at line 204 of file f_base.cpp.
|
private |
Executes an operation. See here for more details.
doFunc | The operation's do method. |
preFunc | The operation's pre method. |
postFunc | The operation's post method. |
Definition at line 66 of file f_base.cpp.
|
private |
Executes the connect
operation.
This operation carries out the following tasks:
execute
and draw
lists on priority changesDefinition at line 212 of file f_base.cpp.
|
private |
Kickstarts the base's lifecycle by running the create
operation.
Definition at line 450 of file f_base.cpp.
|
private |
Gets a child of the base in the CREATING state.
nullptr
if none is found. Definition at line 465 of file f_base.cpp.
|
static |
Creates a child base under the given parent.
profName | The base's profile name. |
parent | The base's parent. Must not be nullptr . |
param | The base's parameters. |
groupType | The base's group type. |
nullptr
. Definition at line 511 of file f_base.cpp.
|
static |
Creates a root base.
profName | The base's profile name. |
param | The base's parameters. |
groupType | The base's group type. |
nullptr
. Definition at line 518 of file f_base.cpp.
|
staticprivate |
Sets temporary data to be used for the next base's construction.
profName | The base's profile name. |
connectParent | The connect node of the base's parent, or nullptr . |
param | The base's parameters. |
groupType | The base's group type. |
Definition at line 483 of file f_base.cpp.
|
staticprivate |
Internal function for base construction.
profName | The base's profile name. |
connectParent | The parent base's connect node. |
param | The base's parameters. |
groupType | The base's group type. |
nullptr
. Definition at line 490 of file f_base.cpp.
fBaseID_e fBase_c::mUniqueID |
The base's unique identifier.
This value is incremented for every created base. Should it reach fBaseID_e::BASE_ID_MAX, the game will intentionally stall.
Definition at line 162 of file f_base.hpp.
u32 fBase_c::mParam |
A bitfield that configures the base's behaviour. Its usage varies from profile to profile.
Definition at line 163 of file f_base.hpp.
ProfileName fBase_c::mProfName |
The base's profile name.
Definition at line 164 of file f_base.hpp.
|
protected |
The base's lifecycle state. Value is a LIFECYCLE_e.
Definition at line 167 of file f_base.hpp.
|
protected |
If deletion of the base was requested, but the delete
operation has not been scheduled yet.
Definition at line 171 of file f_base.hpp.
|
protected |
If the create
operation was completed, but scheduling the execute
and draw
operations isn't possible at this time.
If true, scheduling will be deferred to the next connect
operation.
Definition at line 176 of file f_base.hpp.
|
protected |
If the create
operation has not been completed, and rescheduling it isn't possible at this time.
If true, rescheduling will be deferred to the next connect
operation.
Definition at line 181 of file f_base.hpp.
|
protected |
The base's group type. Value is a GROUP_TYPE_e.
Definition at line 183 of file f_base.hpp.
|
protected |
The operations to be skipped. Value is a PROC_DISABLE_e.
Definition at line 184 of file f_base.hpp.
|
protected |
The base's process manager.
Definition at line 193 of file f_base.hpp.
|
protected |
[Unused]. See Unused Content.
Definition at line 195 of file f_base.hpp.
|
protected |
[Unused]. See Unused Content.
Definition at line 196 of file f_base.hpp.
|
protected |
[Unused]. The base's dedicated heap.
Definition at line 199 of file f_base.hpp.
|
staticprotected |
[Unused]. See Unused Content.
Definition at line 374 of file f_base.hpp.
|
staticprotected |
[Unused]. See Unused Content.
Definition at line 375 of file f_base.hpp.
|
staticprivate |
Unique ID counter for base construction. See mUniqueID.
Definition at line 378 of file f_base.hpp.
|
staticprivate |
Temporary storage for the next constructed base's params. See mParam.
Definition at line 379 of file f_base.hpp.
|
staticprivate |
Temporary storage for the next constructed base's profile name. See mProfName.
Definition at line 380 of file f_base.hpp.
|
staticprivate |
Temporary storage for the next constructed base's group type. See mGroupType.
Definition at line 381 of file f_base.hpp.
|
staticprivate |
Temporary storage for the next constructed base's parent connect node.
Definition at line 382 of file f_base.hpp.