summaryrefslogtreecommitdiff
path: root/tools/nitrogfx/util.c
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2020-06-07 16:21:48 -0400
committerGitHub <noreply@github.com>2020-06-07 16:21:48 -0400
commit5dfe3440383dd530bda24985f802d8c94bb452b8 (patch)
tree20c57f7d5282f0c3d272b47c4647742581258110 /tools/nitrogfx/util.c
parentc5a0d49cbae5047021e4f036366cf87ba97da566 (diff)
parent5f9e55a24bd8430ed6384c737ed29f949f3c8a6c (diff)
Merge pull request #142 from red031000/master
nitrogfx nclr (palette) support
Diffstat (limited to 'tools/nitrogfx/util.c')
-rw-r--r--tools/nitrogfx/util.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/nitrogfx/util.c b/tools/nitrogfx/util.c
index 87abeb31..73a128a1 100644
--- a/tools/nitrogfx/util.c
+++ b/tools/nitrogfx/util.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
+#include <stdint.h>
#include <errno.h>
#include <limits.h>
#include "global.h"
@@ -122,3 +123,26 @@ void WriteWholeFile(char *path, void *buffer, int bufferSize)
fclose(fp);
}
+
+void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder)
+{
+ unsigned char header[0x10] =
+ { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00 };
+ //magic number
+ memcpy(header, magicNumber, 4);
+
+ //byte order
+ if (!byteorder)
+ {
+ memset(header + 4, 0, 2);
+ }
+
+ //size
+ size += 0x10; //add header size
+ header[8] = size & 0xFF;
+ header[9] = (size >> 8) & 0xFF;
+ header[10] = (size >> 16) & 0xFF;
+ header[11] = (size >> 24) & 0xFF;
+
+ fwrite(header, 1, 0x10, fp);
+}