heap_state.h
games/tbs/include/heap_state.h on GitHub
Unions
HeapState
union HeapState
The heap's 64 work slots, the first two holding the next free EWRAM and IWRAM addresses.
| Field | Declared as | |
|---|---|---|
nextEwram, nextIwram, blocks, heap | struct { void *nextEwram; ///< the EWRAM pool's next free byte, up to 0x02040000 void *nextIwram; ///< the IWRAM pool's next free byte, up to the heap's end void *blocks[62]; ///< heap slots 2 to 63; not named by TBS code } heap | |
slots | void *slots[64] | Each slot's block once allocated, else null; slots 0 and 1 are the pool pointers. |
Used by ItemMenu_Run, MemAlloc, Runtime_AllocateBlock, Runtime_AllocateHeapBlock, Runtime_BumpAllocateAlternatePool, Runtime_GetRemainingEwram, Runtime_GetRemainingIwram, Runtime_InitializeHeap, System_VBlankHandler, UiText_DecodeMessage, offsetof.
Enumerations
HeapSlot
enum HeapSlot
| Value | = | |
|---|---|---|
HEAP_SLOT_TRANSFORM_STACK | 2 | The 3D transform's one saved level. |
HEAP_SLOT_MENU_CONTROL | 6 | |
HEAP_SLOT_MAP | 8 | |
HEAP_SLOT_BATTLE | 9 | |
HEAP_SLOT_CAMERA | 12 | |
HEAP_SLOT_WINDOW | 15 | |
HEAP_SLOT_EVENT | 27 | |
HEAP_SLOT_FIELD_BLEND | 30 | The field's colour blend work (gFieldBlendWork): the struct FieldBlendWork the storm's lightning and BattleFx_StartBufferBlend allocate. |
HEAP_SLOT_TRANSITION | 31 | |
HEAP_SLOT_PALETTE_BUFFER | 32 | The colour buffer (gPaletteBufferWork) that moves the BG and OBJ palettes toward target colours: the struct BattleEffectBuffers BattleEffect_InitializeBuffers allocates on scene load, or the title intro's struct PaletteFade. |
HEAP_SLOT_BATTLE_EFFECT | 39 | |
HEAP_SLOT_BATTLE_CANVAS | 40 | |
HEAP_SLOT_BATTLE_SHEET | 41 | |
HEAP_SLOT_BATTLE_BACKGROUND | 44 | |
HEAP_SLOT_BLITTER | 46 | |
HEAP_SLOT_BLITTER_ALTERNATE | 47 | |
HEAP_SLOT_TEMP_RENDERER | 49 | Copied field row drawer or window tile decoder, released after each call. |
HEAP_SLOT_SAVE | 51 | |
HEAP_SLOT_FRAME_SCRATCH | 52 | Lives for one frame: WaitFrames builds the OAM list in it, and the field sprite decoder keeps its code there between its own uses. |
HEAP_SLOT_FRAME_UPLOADER | 53 | |
HEAP_SLOT_MENU | 55 |
Macros
WORK_SLOT
#define WORK_SLOT(n) (*(gWorkSlot + (n)))
Reads slots through their own addresses; adjacent slots are reached by offsets. (gWorkSlot[n] instead addresses from the table's start.)
Used by BattleBackground_Load, BattleCamera_SetRange, BattleFx_AdvanceBg2OnInterval, BattleFx_AdvanceScrollOnInterval, BattleFx_ArmBg2AffineHBlankDma, BattleFx_ArmPaletteHBlankDma, BattleFx_BeginCanvasLayer, BattleFx_ClearActorTimers, BattleFx_DrawStreaks, BattleFx_EndCanvasLayer, BattleFx_HideBg1AndRestoreBackdrop, BattleFx_OpenCanvasLayer, BattleFx_PlaceFormationObjects, BattleFx_ProbeKeysForExtendedActor, BattleFx_RunAstralBlast, BattleFx_RunBind, BattleFx_RunCastingImpact, BattleFx_RunDrain, BattleFx_RunFire, BattleFx_RunFroth, BattleFx_RunGround, BattleFx_RunKite, BattleFx_RunMoteFountain, BattleFx_RunOrbitingSkulls, BattleFx_RunQuake, BattleFx_RunShiningStar, BattleFx_RunStatBoost, BattleFx_RunTableEffect, BattleFx_RunTriangleStrike, BattleFx_SetupCanvasTileMap, BattleFx_SpawnObjects, BattleFx_WipeCanvas, BattlePres_RunEntryTransition, BattlePres_RunEscape, BattlePres_UpdateHBlankScroll, BattlePresentation_DispatchAction, BattlePresentation_RunUnitTransition, BattlePresentation_UpdateCamera, Battle_PlaceActorsByFormationKind, Camera_ApplyShake and 36 more.