|
NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
|
Provides high-level heap management utilities built on top of the EGG heap system.
The mHeap namespace wraps and extends the functionality of the EGG heap framework, providing helper functions for creating and managing different heap types used by the game.
It supports:
It also manages various game-specific heaps:
Enumerations | |
| enum | AllocOptBit_t { OPT_NONE = 0 , OPT_CLEAR_ALLOC = BIT_FLAG(0) , OPT_DEBUG_FILL = BIT_FLAG(1) , OPT_THREAD_SAFE = BIT_FLAG(2) } |
| Bit flags controlling heap allocation behavior. These flags are translated into internal MEM heap flags via GetOptFlag(). More... | |
| enum | GAME_HEAP_e { GAME_HEAP_DEFAULT , GAME_HEAP_MEM1 , GAME_HEAP_MEM2 , GAME_HEAP_COUNT } |
| The identifiers for the predefined game heaps. More... | |
Functions | |
| u16 | GetOptFlag (AllocOptBit_t opt) |
| Converts the allocation option bits to internal MEM heap flags. | |
| EGG::Heap * | setCurrentHeap (EGG::Heap *heap) |
| Sets the specified heap as the current heap. | |
| void | saveCurrentHeap () |
| Saves the currently active heap. The saved heap can later be restored using restoreCurrentHeap(). | |
| void | restoreCurrentHeap () |
| Restores the previously saved heap as current. | |
| size_t | expHeapCost (size_t size, ulong align) |
| Calculates the total required size for an expandable heap, including internal overhead. | |
| size_t | frmHeapCost (size_t size, ulong align) |
| Calculates the total required size for a frame heap, including internal overhead. | |
| size_t | untHeapCost (size_t size, ulong count, ulong align) |
| Calculates the total required size for an unit heap, including internal overhead. | |
| void | destroyFrmHeap (EGG::FrmHeap *heap) |
| Destroys a frame heap. | |
| size_t | adjustFrmHeap (EGG::FrmHeap *heap) |
| Adjusts a frame heap to release unused memory. | |
| EGG::ExpHeap * | createExpHeap (size_t size, EGG::Heap *parent, const char *name, ulong align, AllocOptBit_t opt) |
| Creates an expandable heap. | |
| EGG::FrmHeap * | createFrmHeapToCurrent (size_t size, EGG::Heap *parent, const char *name, ulong align, AllocOptBit_t opt) |
| Creates a frame heap and sets it as current. | |
| EGG::FrmHeap * | createFrmHeap (size_t size, EGG::Heap *parent, const char *name, ulong align, AllocOptBit_t opt) |
| Creates a frame heap. | |
| EGG::UnitHeap * | createUntHeap (size_t size, ulong count, EGG::Heap *parent, const char *name, ulong align, AllocOptBit_t opt) |
| Creates a unit heap. | |
| bool | isValidGameHeapId (u32 idx) |
| EGG::Heap * | createHeap (size_t size, EGG::Heap *parent, const char *name) |
| Creates a generic expandable heap, with fast allocation mode and thread-safe de/allocation. | |
| EGG::Heap * | createGameHeap (int idx, size_t size, EGG::Heap *parent) |
| Creates a game heap. | |
| EGG::Heap * | createGameHeap1 (size_t size, EGG::Heap *parent) |
| Creates the MEM1 game heap. See createGameHeap(). | |
| EGG::Heap * | createGameHeap2 (size_t size, EGG::Heap *parent) |
| Creates the MEM2 game heap. See createGameHeap(). | |
| EGG::Heap * | createArchiveHeap (size_t size, EGG::Heap *parent) |
| Creates the archive heap. See createHeap(). | |
| EGG::Heap * | createCommandHeap (size_t size, EGG::Heap *parent) |
| Creates the DVD command heap. See createHeap(). | |
| EGG::Heap * | createDylinkHeap (size_t size, EGG::Heap *parent) |
| Creates the REL linking heap. See createHeap(). | |
| EGG::Heap * | createAssertHeap (EGG::Heap *parent) |
| Creates the assert heap. | |
Variables | |
| u8 | g_DefaultGameHeapId = GAME_HEAP_MEM1 |
| The default game heap to be used if one isn't specified. | |
| const char *const | s_GameHeapNames [GAME_HEAP_COUNT] |
| The game heap names. | |
| EGG::Heap * | s_SavedCurrentHeap |
| The saved current heap. | |
| EGG::Heap * | g_gameHeaps [GAME_HEAP_COUNT] |
| The game heaps. | |
| EGG::Heap * | g_archiveHeap |
| The archive resource heap. | |
| EGG::Heap * | g_commandHeap |
| The DVD command heap. | |
| EGG::Heap * | g_dylinkHeap |
| The REL linking heap. | |
| EGG::Heap * | g_assertHeap |
| The assert heap. | |
| enum mHeap::AllocOptBit_t |
Bit flags controlling heap allocation behavior. These flags are translated into internal MEM heap flags via GetOptFlag().
Definition at line 28 of file m_heap.hpp.
| enum mHeap::GAME_HEAP_e |
The identifiers for the predefined game heaps.
Definition at line 37 of file m_heap.hpp.
| u16 mHeap::GetOptFlag | ( | AllocOptBit_t | opt | ) |
Converts the allocation option bits to internal MEM heap flags.
| opt | The allocation option bits. |
Definition at line 19 of file m_heap.cpp.
| EGG::Heap * mHeap::setCurrentHeap | ( | EGG::Heap * | heap | ) |
Sets the specified heap as the current heap.
| heap | The heap to become current. |
Definition at line 37 of file m_heap.cpp.
| void mHeap::saveCurrentHeap | ( | ) |
Saves the currently active heap. The saved heap can later be restored using restoreCurrentHeap().
Definition at line 172 of file m_heap.cpp.
| void mHeap::restoreCurrentHeap | ( | ) |
Restores the previously saved heap as current.
Definition at line 176 of file m_heap.cpp.
| size_t mHeap::expHeapCost | ( | size_t | size, |
| ulong | align ) |
Calculates the total required size for an expandable heap, including internal overhead.
| size | The requested usable size. |
| align | The lignment requirement. |
Definition at line 71 of file m_heap.cpp.
| size_t mHeap::frmHeapCost | ( | size_t | size, |
| ulong | align ) |
Calculates the total required size for a frame heap, including internal overhead.
| size | The requested usable size. |
| align | The lignment requirement. |
Definition at line 125 of file m_heap.cpp.
| size_t mHeap::untHeapCost | ( | size_t | size, |
| ulong | count, | ||
| ulong | align ) |
Calculates the total required size for an unit heap, including internal overhead.
| size | The requested usable size. |
| count | The number of units. |
| align | The lignment requirement. |
Definition at line 154 of file m_heap.cpp.
| void mHeap::destroyFrmHeap | ( | EGG::FrmHeap * | heap | ) |
Destroys a frame heap.
| heap | The frame heap to destroy, or nullptr . |
Definition at line 105 of file m_heap.cpp.
| size_t mHeap::adjustFrmHeap | ( | EGG::FrmHeap * | heap | ) |
Adjusts a frame heap to release unused memory.
| heap | The frame heap to adjust, or nullptr . |
0 if the adjust operation failed. Definition at line 111 of file m_heap.cpp.
| EGG::ExpHeap * mHeap::createExpHeap | ( | size_t | size, |
| EGG::Heap * | parent, | ||
| const char * | name, | ||
| ulong | align, | ||
| AllocOptBit_t | opt ) |
Creates an expandable heap.
| size | The size of the heap, or -1 to use all space available. |
| parent | The parent heap. |
| name | The heap name, or nullptr . |
| align | The heap alignment (minimum 0x20). |
| opt | The allocation options. |
nullptr on failure. Definition at line 41 of file m_heap.cpp.
| EGG::FrmHeap * mHeap::createFrmHeapToCurrent | ( | size_t | size, |
| EGG::Heap * | parent, | ||
| const char * | name, | ||
| ulong | align, | ||
| AllocOptBit_t | opt ) |
Creates a frame heap and sets it as current.
| size | The size of the heap, or -1 to use all space available. |
| parent | The parent heap. |
| name | The heap name, or nullptr . |
| align | The heap alignment (minimum 0x20). |
| opt | The allocation options. |
nullptr on failure. Definition at line 181 of file m_heap.cpp.
| EGG::FrmHeap * mHeap::createFrmHeap | ( | size_t | size, |
| EGG::Heap * | parent, | ||
| const char * | name, | ||
| ulong | align, | ||
| AllocOptBit_t | opt ) |
Creates a frame heap.
| size | The size of the heap, or -1 to use all space available. |
| parent | The parent heap. |
| name | The heap name, or nullptr . |
| align | The heap alignment (minimum 0x20). |
| opt | The allocation options. |
nullptr on failure. Definition at line 75 of file m_heap.cpp.
| EGG::UnitHeap * mHeap::createUntHeap | ( | size_t | size, |
| ulong | count, | ||
| EGG::Heap * | parent, | ||
| const char * | name, | ||
| ulong | align, | ||
| AllocOptBit_t | opt ) |
Creates a unit heap.
| size | The size of the heap, or -1 to use all space available. |
| count | The number of units. |
| parent | The parent heap. |
| name | The heap name, or nullptr . |
| align | The heap alignment (minimum 0x20). |
| opt | The allocation options. |
nullptr on failure. Definition at line 129 of file m_heap.cpp.
|
inline |
Definition at line 134 of file m_heap.hpp.
| EGG::Heap * mHeap::createHeap | ( | size_t | size, |
| EGG::Heap * | parent, | ||
| const char * | name ) |
Creates a generic expandable heap, with fast allocation mode and thread-safe de/allocation.
| size | The heap size. |
| parent | The parent heap. |
| name | The heap name, or nullptr . |
nullptr on failure. Definition at line 158 of file m_heap.cpp.
| EGG::Heap * mHeap::createGameHeap | ( | int | idx, |
| size_t | size, | ||
| EGG::Heap * | parent ) |
Creates a game heap.
| idx | The game heap index. |
| size | The heap size. |
| parent | The parent heap. |
nullptr if invalid index. Definition at line 190 of file m_heap.cpp.
| EGG::Heap * mHeap::createGameHeap1 | ( | size_t | size, |
| EGG::Heap * | parent ) |
Creates the MEM1 game heap. See createGameHeap().
Definition at line 203 of file m_heap.cpp.
| EGG::Heap * mHeap::createGameHeap2 | ( | size_t | size, |
| EGG::Heap * | parent ) |
Creates the MEM2 game heap. See createGameHeap().
Definition at line 207 of file m_heap.cpp.
| EGG::Heap * mHeap::createArchiveHeap | ( | size_t | size, |
| EGG::Heap * | parent ) |
Creates the archive heap. See createHeap().
Definition at line 211 of file m_heap.cpp.
| EGG::Heap * mHeap::createCommandHeap | ( | size_t | size, |
| EGG::Heap * | parent ) |
Creates the DVD command heap. See createHeap().
Definition at line 216 of file m_heap.cpp.
| EGG::Heap * mHeap::createDylinkHeap | ( | size_t | size, |
| EGG::Heap * | parent ) |
Creates the REL linking heap. See createHeap().
Definition at line 221 of file m_heap.cpp.
| EGG::Heap * mHeap::createAssertHeap | ( | EGG::Heap * | parent | ) |
Creates the assert heap.
The size is determined automatically using EGG::AssertHeap::getMinSizeForCreate().
Definition at line 226 of file m_heap.cpp.
|
extern |
The default game heap to be used if one isn't specified.
Definition at line 4 of file m_heap.cpp.
|
extern |
The game heap names.
Definition at line 5 of file m_heap.cpp.
|
extern |
The saved current heap.
Definition at line 11 of file m_heap.cpp.
|
extern |
The game heaps.
Definition at line 13 of file m_heap.cpp.
|
extern |
The archive resource heap.
Definition at line 14 of file m_heap.cpp.
|
extern |
The DVD command heap.
Definition at line 15 of file m_heap.cpp.
|
extern |
The REL linking heap.
Definition at line 16 of file m_heap.cpp.
|
extern |
The assert heap.
Definition at line 17 of file m_heap.cpp.