diff options
author | quou <quou@disroot.org> | 2024-10-01 23:12:46 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-10-01 23:12:46 +1000 |
commit | 6c5ba07bdba2de9d903e42f264be488661975855 (patch) | |
tree | 2ec08592a39b133287efa03714dfad89d072870e | |
parent | 5331a6aafbbd03d53918b53565b81dac14ec30ca (diff) |
Pad asset files to align properly.
-rw-r--r-- | convanim.c | 3 | ||||
-rw-r--r-- | convcom.c | 14 | ||||
-rw-r--r-- | convimg.c | 3 | ||||
-rw-r--r-- | intermediate/hud.bmp | bin | 5022 -> 9906 bytes |
4 files changed, 20 insertions, 0 deletions
@@ -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); +} + @@ -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 Binary files differindex c1850bd..e2793ab 100644 --- a/intermediate/hud.bmp +++ b/intermediate/hud.bmp |