-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathoverworld_ripper.py
More file actions
28 lines (22 loc) · 860 Bytes
/
overworld_ripper.py
File metadata and controls
28 lines (22 loc) · 860 Bytes
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
#!/usr/bin/python3
from sys import argv
import os, subprocess, struct
def gbagfx(params):
subprocess.call([os.sep.join([os.curdir, 'tools', 'gbagfx', 'gbagfx'])] + params)
def create_pal(path, data):
with open(path + '.gbapal', 'wb+') as f:
f.write(data)
gbagfx([path + '.gbapal', path + '.pal'])
def create_image(path, data):
with open(path + ".4bpp", 'wb+') as f:
f.write(data)
gbagfx([path + ".4bpp", path + ".png", "-width", "18", "-mwidth", "2", "-mheight", "4", "-palette", path + ".gbapal"])
if __name__ == '__main__':
with open(argv[1], 'rb') as f:
f.seek(int(argv[2], base=16))
image_data = f.read(64 * 4 * 9)
f.seek(int(argv[3], base=16))
pal_data = f.read(32)
path = os.sep.join([os.curdir, argv[4]])
create_pal(path, pal_data)
create_image(path, image_data)