-
Notifications
You must be signed in to change notification settings - Fork 47
/
fr_tileset_fixer.py
54 lines (47 loc) · 1.77 KB
/
fr_tileset_fixer.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
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python3
from sys import argv
import os, subprocess, struct
if __name__ == '__main__':
is_secondary = argv[2] == "1"
path = os.sep.join([os.curdir, 'data', 'tilesets', 'primary' if not is_secondary else 'secondary', argv[1]])
with open(os.sep.join([path, 'metatile_attributes.bin']), 'rb') as f:
data = f.read()
num_metatiles = int(len(data) / 4)
new_data = bytearray(num_metatiles * 2)
for i in range(0, num_metatiles):
behavior = data[i * 4]
if behavior >= 0x9C and behavior <= 0x9D: # window
behavior = 0x88
elif behavior == 0x81: # bookshelf
behavior = 0xE2
elif behavior >= 0x6C and behavior <= 0x6F: # staircase
behavior -= 0x40
elif behavior >= 0x89 and behavior <= 0x8B: # dishes, sink, drawers
behavior = 0
elif behavior == 0x97: # computer
behavior = 0
elif behavior == 0x9B: # coffee mug
behavior = 0
elif behavior == 0x84: # signpost
behavior = 0x7E
elif behavior == 0x90: # fridge
behavior = 0
elif behavior == 0x94: # picture
behavior = 0
elif behavior == 0x2A: # stairs
behavior = 0
elif behavior == 0x87: # pokemon center
behavior = 0x81
elif behavior == 0x88: # pokemon mart
behavior = 0x82
elif behavior == 0x23: # ice
behavior = 0x20
elif behavior == 0x71: # union room teleport warp
behavior = 0x70
new_data[i * 2] = behavior
bg = data[i * 4 + 3]
if bg & 0x20 == 0x20:
bg = 0x10
new_data[i * 2 + 1] = bg
with open(os.sep.join([path, 'metatile_attributes.bin']), 'wb+') as f:
f.write(new_data)