diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-04-26 22:29:51 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-04-26 22:29:51 +0200 |
commit | 4d58ddd03b22dab33f37d1916fc94e6d6a875c87 (patch) | |
tree | 942e1fc0a74c20a64637750d99da55d5dfa177bf /maps/mapprint.py | |
parent | f6272349aedb3c09e8e5a964f6ea4064bf9a2e0a (diff) |
debug maps
Diffstat (limited to 'maps/mapprint.py')
-rwxr-xr-x | maps/mapprint.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/maps/mapprint.py b/maps/mapprint.py new file mode 100755 index 0000000..4b56db6 --- /dev/null +++ b/maps/mapprint.py @@ -0,0 +1,24 @@ +import sys +from struct import unpack + +def mapprint(filename): + file = open(filename, 'rb') + contents = file.read() + file.close() + + width, height = unpack('>HH', contents[0:4]) + + for y in range(height): + for x in range(width): + nibble = x + y * width + byte = int(nibble / 2) + shift = byte * 2 - nibble + 1 + num = (contents[4 + byte] & (0xf << 4 * shift)) >> 4 * shift + print(" ─│┘──└┴│┐│┤┌┬├┼"[num], end='') + print("\n", end='') + +if __name__ == "__main__": + if len(sys.argv) > 1: + mapprint(sys.argv[1]) + else: + exit(1) |