summaryrefslogtreecommitdiff
path: root/src/code/graphalloc.c
diff options
context:
space:
mode:
authorThar0 <17233964+Thar0@users.noreply.github.com>2022-05-22 21:39:46 +0100
committerThar0 <17233964+Thar0@users.noreply.github.com>2022-05-22 21:39:46 +0100
commit27b728da76caf10f5a85d920c93b214a3edd8e5f (patch)
tree8a4835711817863e770fe52c68c04cd936efeceb /src/code/graphalloc.c
parent61b579a9ed2bbb59c98003c219c94717b4d5ffd0 (diff)
parente67fb5cf16416248048fe331b4b4162e58794c0b (diff)
Merge branch 'master' of github.com:zeldaret/mm into ovl_En_Death
Diffstat (limited to 'src/code/graphalloc.c')
-rw-r--r--src/code/graphalloc.c29
1 files changed, 29 insertions, 0 deletions
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;
+}