diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-03-22 15:15:10 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-03-22 15:15:10 +0100 |
commit | 8495bc3169939d034622dcbf6fb84016a7430ef2 (patch) | |
tree | 0967c9e5fc88f49eadf95049d082fef7eae9fcb5 /scripts | |
parent | 7f51cd925883bbf958baa289d4d19231667c9eba (diff) |
tilemap build system done
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/manifest2header.awk | 13 | ||||
-rwxr-xr-x | scripts/tilepack | 22 |
2 files changed, 35 insertions, 0 deletions
diff --git a/scripts/manifest2header.awk b/scripts/manifest2header.awk new file mode 100755 index 0000000..15cd682 --- /dev/null +++ b/scripts/manifest2header.awk @@ -0,0 +1,13 @@ +#!/bin/awk -f +BEGIN { + offset = 0 + print "#pragma once" +} +1 { + print "#define HH_TM_"toupper($1)"_OFFSET "offset + print "#define HH_TM_"toupper($1)"_SIZE "$2 + offset += $2 +} +END { + print "#define HH_TM_SIZE "offset +} diff --git a/scripts/tilepack b/scripts/tilepack new file mode 100755 index 0000000..aff417d --- /dev/null +++ b/scripts/tilepack @@ -0,0 +1,22 @@ +#!/bin/python3 +# read bytes from input and pack into ppu format +# each input sprite is 256 bytes + +import sys +import struct + +i = 0 +word = 0x0000 +for byte in sys.stdin.buffer.read(): + pixel_idx = i % 5 + word |= (byte & 0b111) << 3 * pixel_idx + + if i % 5 == 4 or i == 0xff: + sys.stdout.buffer.write(struct.pack('!H', word)) + word = 0x0000 + + i += 1 + if i > 0xff: i = 0 + +sys.stdout.buffer.flush() + |