summaryrefslogtreecommitdiff
path: root/tools/utils.c
diff options
context:
space:
mode:
authorTyler McGavran <tyler.taggerung@gmail.com>2023-02-07 00:52:34 -0500
committerGitHub <noreply@github.com>2023-02-06 22:52:34 -0700
commit3a99685c2f79bf3e6b166b2a11ba36a43293b1ef (patch)
tree115e68ef1c1a7abe48f2ea800a27d12feb835b40 /tools/utils.c
parent533d03587564467da0701665fd858078b1bf4238 (diff)
Clean up some more bin2c calls from the Makefile (#286)
* Remove some bin2c calls from the Makefile * Found a way to make n64graphics use shared tluts * Added an option that makes n64graphics operate in a mode where it takes an image and tlut (as pngs) and spits out the appropriate CI8 indices inc.c form * Turns out all the TLUTs for Lakitu are kept in one place, far away from the textures that use them * Names some textures and tluts * Pretty helpful actually, helped identify where a few different objects types are initialized. Should be a little useful to whoever dives into the object stuff more deeply * Minor cleanup in n64graphics * Added some comments, gave more appropriate names to some variables. * Leaving the new mode argument as `-Z` for now Signed-off-by: Taggerung <tyler.taggerung@gmail.com> * Textures compile using makefile rules * Patched n64 graphics memory leak and ci output * Added memset16safe to initialize ci palettes to magic numbers (transparent pixels). --------- Signed-off-by: Taggerung <tyler.taggerung@gmail.com> Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
Diffstat (limited to 'tools/utils.c')
-rw-r--r--tools/utils.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/utils.c b/tools/utils.c
index ccf462b8e..b4f0ccd6d 100644
--- a/tools/utils.c
+++ b/tools/utils.c
@@ -37,6 +37,23 @@ float read_f32_be(unsigned char *buf)
return ret.f;
}
+void *memset16safe(void *m, uint16_t val, size_t count)
+{
+ char *buf = m;
+ union
+ {
+ uint8_t d8[2];
+ uint16_t d16;
+ }u16 = {.d16 = val};
+
+ while(count--)
+ {
+ *buf++ = u16.d8[0];
+ *buf++ = u16.d8[1];
+ }
+ return m;
+}
+
int is_power2(unsigned int val)
{
while (((val & 1) == 0) && (val > 1)) {