-
Notifications
You must be signed in to change notification settings - Fork 0
/
girafarig.py
42 lines (34 loc) · 1.1 KB
/
girafarig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
"""
Super basic simple stupid script to interpolate 1bpp font graphics from smeargle/porygon
"""
def main():
if len(sys.argv) != 3:
raise ValueError("syntax is girafarig.py infile.bin outfile.bin")
in_filename = sys.argv[1]
outfile = sys.argv[2]
with open(in_filename, "rb") as binary_file:
# Read the whole file at once
data = bytearray(binary_file.read())
output = bytearray(len(data))
read_base = 0
while read_base < len(data):
# process row
for i in range(0x10):
top_half_origin = read_base + (i*0x08)
bot_half_origin = read_base + (i*0x08) + 0x80
top_half_dest = read_base + (i*0x10)
bot_half_dest = read_base + (i*0x10) + 0x08
# process character
q = 1
for j in range(0x08):
top_half = data[top_half_origin+j]
bot_half = data[bot_half_origin+j]
output[top_half_dest+j] = top_half
output[bot_half_dest+j] = bot_half
read_base += 0x100
with open(outfile, "wb") as out:
out.write(output)
print ("Done")
if __name__ == '__main__':
main()