Alchemy

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.

FieldDeclared as
nextEwram, nextIwram, blocks, heapstruct { 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
slotsvoid *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.

Line 18

Enumerations

HeapSlot

enum HeapSlot

Value=
HEAP_SLOT_TRANSFORM_STACK2The 3D transform's one saved level.
HEAP_SLOT_MENU_CONTROL6
HEAP_SLOT_MAP8
HEAP_SLOT_BATTLE9
HEAP_SLOT_CAMERA12
HEAP_SLOT_WINDOW15
HEAP_SLOT_EVENT27
HEAP_SLOT_FIELD_BLEND30The field's colour blend work (gFieldBlendWork): the struct FieldBlendWork the storm's lightning and BattleFx_StartBufferBlend allocate.
HEAP_SLOT_TRANSITION31
HEAP_SLOT_PALETTE_BUFFER32The 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_EFFECT39
HEAP_SLOT_BATTLE_CANVAS40
HEAP_SLOT_BATTLE_SHEET41
HEAP_SLOT_BATTLE_BACKGROUND44
HEAP_SLOT_BLITTER46
HEAP_SLOT_BLITTER_ALTERNATE47
HEAP_SLOT_TEMP_RENDERER49Copied field row drawer or window tile decoder, released after each call.
HEAP_SLOT_SAVE51
HEAP_SLOT_FRAME_SCRATCH52Lives 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_UPLOADER53
HEAP_SLOT_MENU55

Line 33

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.

Line 14

Globals, without a comment: gWorkSlot, offsetof, offsetof.

On this page