Files
mm/src/code/gfxalloc.c
T
Anghelo Carvajal cd087d8511 Introduce a bunch of small new headers (#1649)
* regs.h

* gfxalloc.h

* z64inventory.h

* gfx.h

* graph.h

* z64olib.h

* z64elf_message.h

* fix missing include

* Include z64inventory.h on z64save.h

* fix bss

* Move PosRot to z64math.h

* So dumb

* Update src/overlays/actors/ovl_En_Kusa/z_en_kusa.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* review

* Remove graph.h

* bss

---------

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
2024-07-28 13:53:28 -07:00

32 lines
657 B
C

#include "gfxalloc.h"
#include "alignment.h"
Gfx* Gfx_Open(Gfx* gfx) {
return &gfx[1];
}
Gfx* Gfx_Close(Gfx* gfx, Gfx* dst) {
gSPBranchList(gfx, dst);
return dst;
}
/**
* Allocates a structure of `size` into the display list buffer`gfx`,
* returning a pointer to the start of the buffer.
* Since the alloc may not itself be display list commands, a BranchList
* command is used to step over this region.
*/
void* Gfx_Alloc(Gfx** gfxP, size_t size) {
u8* start;
Gfx* gfx;
size = ALIGN8(size);
start = (u8*)&(*gfxP)[1];
gfx = (Gfx*)(start + size);
gSPBranchList(*gfxP, gfx);
*gfxP = gfx;
return start;
}