Alchemy
Loading...
Searching...
No Matches

heap_state.h

Go to the documentation of this file.
1#ifndef ALCHEMY_HEAP_STATE_H
2#define ALCHEMY_HEAP_STATE_H
3
4/// @file
5/// The heap's work slots and HeapState.
6
7#include "types.h"
8#include "static_assert.h"
9
10extern void *gWorkSlot[64];
11
12/// Reads slots through their own addresses; adjacent slots are reached by
13/// offsets. (gWorkSlot[n] instead addresses from the table's start.)
14#define WORK_SLOT(n) (*(gWorkSlot + (n)))
15
16/// The heap's 64 work slots, the first two holding the next free EWRAM and
17/// IWRAM addresses.
18union HeapState {
19 struct {
20 void *nextEwram; ///< the EWRAM pool's next free byte, up to 0x02040000
21 void *nextIwram; ///< the IWRAM pool's next free byte, up to the heap's end
22 void *blocks[62]; ///< heap slots 2 to 63; not named by TBS code
24 /// Each slot's block once allocated, else null; slots 0 and 1 are the pool
25 /// pointers.
26 void *slots[64];
27};
28
29STATIC_ASSERT(sizeof(union HeapState) == 0x100);
30STATIC_ASSERT(offsetof(union HeapState, heap.nextIwram) == 4);
31STATIC_ASSERT(offsetof(union HeapState, heap.blocks) == 8);
32
34 HEAP_SLOT_TRANSFORM_STACK = 2, ///< The 3D transform's one saved level.
48 /// Copied field row drawer or window tile decoder, released after each call.
51 /// Lives for one frame: WaitFrames builds the OAM list in it, and the field
52 /// sprite decoder keeps its code there between its own uses.
56};
57
58#endif
HeapSlot
Definition heap_state.h:33
@ HEAP_SLOT_BATTLE_EFFECT
Definition heap_state.h:42
@ HEAP_SLOT_BLITTER_ALTERNATE
Definition heap_state.h:47
@ HEAP_SLOT_BATTLE_BACKGROUND
Definition heap_state.h:45
@ HEAP_SLOT_MENU
Definition heap_state.h:55
@ HEAP_SLOT_MAP
Definition heap_state.h:36
@ HEAP_SLOT_BATTLE_SHEET
Definition heap_state.h:44
@ HEAP_SLOT_SAVE
Definition heap_state.h:50
@ HEAP_SLOT_MENU_CONTROL
Definition heap_state.h:35
@ HEAP_SLOT_CAMERA
Definition heap_state.h:38
@ HEAP_SLOT_BLITTER
Definition heap_state.h:46
@ HEAP_SLOT_WINDOW
Definition heap_state.h:39
@ HEAP_SLOT_FRAME_UPLOADER
Definition heap_state.h:54
@ HEAP_SLOT_FRAME_SCRATCH
Lives for one frame: WaitFrames builds the OAM list in it, and the field sprite decoder keeps its cod...
Definition heap_state.h:53
@ HEAP_SLOT_TEMP_RENDERER
Copied field row drawer or window tile decoder, released after each call.
Definition heap_state.h:49
@ HEAP_SLOT_BATTLE
Definition heap_state.h:37
@ HEAP_SLOT_BATTLE_CANVAS
Definition heap_state.h:43
@ HEAP_SLOT_TRANSITION
Definition heap_state.h:41
@ HEAP_SLOT_EVENT
Definition heap_state.h:40
@ HEAP_SLOT_TRANSFORM_STACK
The 3D transform's one saved level.
Definition heap_state.h:34
void * gWorkSlot[]
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
void * blocks[62]
heap slots 2 to 63; not named by TBS code
void * nextIwram
the IWRAM pool's next free byte, up to the heap's end
void * nextEwram
the EWRAM pool's next free byte, up to 0x02040000
The integer types, TRUE, UNUSED and the fixed-address macros.
The heap's 64 work slots, the first two holding the next free EWRAM and IWRAM addresses.
Definition heap_state.h:18
void * slots[64]
Each slot's block once allocated, else null; slots 0 and 1 are the pool pointers.
Definition heap_state.h:26
struct HeapState::@141110302170060006222316322227346102017231370075 heap