From 6c5ba07bdba2de9d903e42f264be488661975855 Mon Sep 17 00:00:00 2001 From: quou Date: Tue, 1 Oct 2024 23:12:46 +1000 Subject: Pad asset files to align properly. --- convanim.c | 3 +++ convcom.c | 14 ++++++++++++++ convimg.c | 3 +++ intermediate/hud.bmp | Bin 5022 -> 9906 bytes 4 files changed, 20 insertions(+) create mode 100644 convcom.c diff --git a/convanim.c b/convanim.c index 80a1b4a..0be693e 100644 --- a/convanim.c +++ b/convanim.c @@ -4,6 +4,8 @@ #include #include +#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 #include +#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 Binary files a/intermediate/hud.bmp and b/intermediate/hud.bmp differ -- cgit v1.2.3-54-g00ecf