aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-10-01 23:12:46 +1000
committerquou <quou@disroot.org>2024-10-01 23:12:46 +1000
commit6c5ba07bdba2de9d903e42f264be488661975855 (patch)
tree2ec08592a39b133287efa03714dfad89d072870e
parent5331a6aafbbd03d53918b53565b81dac14ec30ca (diff)
Pad asset files to align properly.
-rw-r--r--convanim.c3
-rw-r--r--convcom.c14
-rw-r--r--convimg.c3
-rw-r--r--intermediate/hud.bmpbin5022 -> 9906 bytes
4 files changed, 20 insertions, 0 deletions
diff --git a/convanim.c b/convanim.c
index 80a1b4a..0be693e 100644
--- a/convanim.c
+++ b/convanim.c
@@ -4,6 +4,8 @@
#include <stdlib.h>
#include <string.h>
+#include "convcom.c"
+
#define max_rects 32
const char* next_line(const char* line) {
@@ -73,6 +75,7 @@ int main(int argc, char** argv) {
fwrite(&fc, 1, 4, outfile);
fwrite(&speed, 1, 4, outfile);
fwrite(rects, fc, sizeof r, outfile);
+ pad_file(8 + fc * sizeof r, outfile);
fclose(outfile);
}
return 0;
diff --git a/convcom.c b/convcom.c
new file mode 100644
index 0000000..b3818c9
--- /dev/null
+++ b/convcom.c
@@ -0,0 +1,14 @@
+#include "config.h"
+
+int align_size(int s, int a) {
+ return (s + (a - 1)) & -a;
+}
+
+void pad_file(int size, FILE* outfile) {
+ const char n = 0;
+ int as = align_size(size, allocation_default_alignment);
+ int i = as - size;
+ for (; i; i--)
+ fwrite(&n, 1, 1, outfile);
+}
+
diff --git a/convimg.c b/convimg.c
index 631a8b1..6de5086 100644
--- a/convimg.c
+++ b/convimg.c
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <string.h>
+#include "convcom.c"
+
typedef struct {
unsigned char r, g, b, a;
} Colour;
@@ -89,6 +91,7 @@ int main(int argc, char** argv) {
fwrite(&bmp_w, 1, 2, outfile);
fwrite(&bmp_h, 1, 2, outfile);
fwrite(bitmap, 1, bs, outfile);
+ pad_file(4 + bs, outfile);
free(buffer);
end:
diff --git a/intermediate/hud.bmp b/intermediate/hud.bmp
index c1850bd..e2793ab 100644
--- a/intermediate/hud.bmp
+++ b/intermediate/hud.bmp
Binary files differ