You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-09-08 08:13:02 -07:00
wram.py: allow space definitions using constants
This commit is contained in:
@@ -23,17 +23,33 @@ def read_bss_sections(bss):
|
|||||||
'start': address,
|
'start': address,
|
||||||
'labels': [],
|
'labels': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
elif ':' in line:
|
elif ':' in line:
|
||||||
# the only labels that don't use :s so far are enders,
|
# rgbds allows labels without :, but prefer convention
|
||||||
# which we typically don't want to end up in the output
|
|
||||||
label = line[:line.find(':')]
|
label = line[:line.find(':')]
|
||||||
if ';' not in label:
|
if ';' not in label:
|
||||||
section['labels'] += [{'label': label, 'address': address, 'length': 0}]
|
section['labels'] += [{
|
||||||
|
'label': label,
|
||||||
|
'address': address,
|
||||||
|
'length': 0,
|
||||||
|
}]
|
||||||
|
|
||||||
elif line[:3] == 'ds ':
|
elif line[:3] == 'ds ':
|
||||||
length = eval(line[3:line.find(';')].replace('$','0x'))
|
length = eval(line[3:line.find(';')].replace('$','0x'))
|
||||||
address += length
|
address += length
|
||||||
if section['labels']:
|
# adjacent labels use the same space
|
||||||
section['labels'][-1]['length'] += length
|
for label in section['labels'][::-1]:
|
||||||
|
if label['length'] == 0:
|
||||||
|
label['length'] = length
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
elif 'EQU' in line:
|
||||||
|
# some space is defined using constants
|
||||||
|
name, value = line.split('EQU')
|
||||||
|
name, value = name.strip(), value.strip().replace('$','0x').replace('%','0b')
|
||||||
|
globals()[name] = eval(value)
|
||||||
|
|
||||||
sections.append(section)
|
sections.append(section)
|
||||||
return sections
|
return sections
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user