mirror of https://github.com/pret/pokecrystal.git
More example lines
This commit is contained in:
parent
78c818e4c9
commit
83f7400671
|
@ -28,7 +28,7 @@ def total_bank_size(type):
|
|||
def map_to_sym(input):
|
||||
# analogous to ";File generated by rgblink"
|
||||
yield ';File generated by sort_map.py\n'
|
||||
|
||||
|
||||
# ex: OAM:
|
||||
unused_rx = re.compile(r'^([A-Z]+):$')
|
||||
# ex: ROM Bank #1:
|
||||
|
@ -43,8 +43,8 @@ def map_to_sym(input):
|
|||
bank_type = None
|
||||
bank_number = None
|
||||
bank_size = 0
|
||||
bank_queue = []
|
||||
section_queue = []
|
||||
bank_lines = []
|
||||
section_lines = []
|
||||
|
||||
for line in input:
|
||||
|
||||
|
@ -58,8 +58,8 @@ def map_to_sym(input):
|
|||
bank_type = x.group(1)
|
||||
bank_number = '00'
|
||||
bank_size = 0
|
||||
del bank_queue[:]
|
||||
del section_queue[:]
|
||||
del bank_lines[:]
|
||||
del section_lines[:]
|
||||
continue
|
||||
|
||||
x = re.match(bank_rx, line)
|
||||
|
@ -72,22 +72,23 @@ def map_to_sym(input):
|
|||
if bank_type == 'WRAM':
|
||||
bank_type = 'WRAM0' if bank_number == '00' else 'WRAMX'
|
||||
bank_size = 0
|
||||
del bank_queue[:]
|
||||
del section_queue[:]
|
||||
del bank_lines[:]
|
||||
del section_lines[:]
|
||||
continue
|
||||
|
||||
x = re.match(section_rx, line)
|
||||
if x:
|
||||
# finish current section
|
||||
bank_queue.extend(sorted(section_queue))
|
||||
bank_lines.extend(sorted(section_lines))
|
||||
# start a new section
|
||||
start = x.group(1)
|
||||
end = x.group(2) or start
|
||||
size = x.group(3).zfill(4)
|
||||
name = x.group(4)
|
||||
bank_size += int(size, 16)
|
||||
bank_queue.append('; %s:%s-%s ($%s) %s\n' % (bank_number, start, end, size, name))
|
||||
del section_queue[:]
|
||||
# ex: ; ROMX $01 ($347B) ($0B85 free)
|
||||
bank_lines.append('; %s:%s-%s ($%s) %s\n' % (bank_number, start, end, size, name))
|
||||
del section_lines[:]
|
||||
continue
|
||||
|
||||
x = re.match(label_rx, line)
|
||||
|
@ -95,17 +96,19 @@ def map_to_sym(input):
|
|||
# add label to section
|
||||
address = x.group(1)
|
||||
label = x.group(2)
|
||||
section_queue.append('%s:%s %s\n' % (bank_number, address, label))
|
||||
# ex: 01:4025 PlaceWaitingText.Waiting
|
||||
section_lines.append('%s:%s %s\n' % (bank_number, address, label))
|
||||
continue
|
||||
|
||||
x = re.match(slack_rx, line)
|
||||
if x:
|
||||
# finish current section
|
||||
bank_queue.extend(sorted(section_queue))
|
||||
bank_lines.extend(sorted(section_lines))
|
||||
# finish current bank
|
||||
slack = int(x.group(1), 16)
|
||||
# ex: ; 01:4000-747A ($347B) bank1
|
||||
yield '; %s $%s ($%04X) ($%04X free)\n' % (bank_type, bank_number, bank_size, slack)
|
||||
for line in bank_queue:
|
||||
for line in bank_lines:
|
||||
yield line
|
||||
continue
|
||||
|
||||
|
@ -113,12 +116,10 @@ def main():
|
|||
if len(sys.argv) < 3:
|
||||
sys.stderr.write('Usage: %s pokecrystal.map sorted.sym\n' % sys.argv[0])
|
||||
sys.exit(1)
|
||||
input_filename = sys.argv[1]
|
||||
output_filename = sys.argv[2]
|
||||
with open(input_filename, 'r') as infile:
|
||||
with open(sys.argv[1], 'r') as infile:
|
||||
input = infile.readlines()
|
||||
output = map_to_sym(input)
|
||||
with open(output_filename, 'w') as outfile:
|
||||
with open(sys.argv[2], 'w') as outfile:
|
||||
outfile.writelines(output)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue