From b1b114e142f05443524d91b4127d9bf97fe75a28 Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Fri, 29 Oct 2021 19:30:48 +0100 Subject: Decompile graph.c (#274) * Decompiled, 1 non-matching, add some bss reordering helpers * Document stuff * Review suggestions * graphutil.c -> graphalloc.c * Try to fix fault callback warnings * Remove extra comments in GfxMasterList * char pad -> u32 pad Co-authored-by: Derek Hensley * Fix gameState Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Other suggestions Co-authored-by: Derek Hensley Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- src/code/graphalloc.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/code/graphalloc.c (limited to 'src/code/graphalloc.c') diff --git a/src/code/graphalloc.c b/src/code/graphalloc.c new file mode 100644 index 000000000..cbae8ebe4 --- /dev/null +++ b/src/code/graphalloc.c @@ -0,0 +1,29 @@ +#include "global.h" + +Gfx* Graph_GfxPlusOne(Gfx* gfx) { + return &gfx[1]; +} + +Gfx* Graph_BranchDlist(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* Graph_DlistAlloc(Gfx** gfx, size_t size) { + u8* start; + Gfx* end; + + size = ALIGN8(size); + start = (u8*)&(*gfx)[1]; + end = (Gfx*)(start + size); + gSPBranchList(*gfx, end); + + *gfx = end; + return start; +} -- cgit v1.2.3