pokemon/tools/parse/gfx_tilesets.py
2023-07-25 05:34:48 +00:00

18 lines
543 B
Python

from parse.maps_blocks import tokenize_block, flatten
def tokenize_lines(lines):
for line in lines:
if '_GFX:' in line or '_Block:' in line:
yield tokenize_block(line, delim='::')
def parse(prefix):
path = prefix / 'gfx/tilesets.asm'
with open(path) as f:
tokens = tokenize_lines(f.read().split('\n'))
l = list(flatten(tokens,
endings=['_GFX', '_Block'],
base_path='gfx/'))
d = dict(l)
assert len(l) == len(d)
return d