mirror of
https://github.com/pret/pokemon-reverse-engineering-tools.git
synced 2026-08-28 13:14:10 -05:00
wram: try to determine addresses for section defs without any
This commit is contained in:
@@ -14,22 +14,48 @@ def make_wram_labels(wram_sections):
|
|||||||
wram_labels[label['address']] += [label['label']]
|
wram_labels[label['address']] += [label['label']]
|
||||||
return wram_labels
|
return wram_labels
|
||||||
|
|
||||||
|
def bracket_value(string, i=0):
|
||||||
|
return string.split('[')[1 + i*2].split(']')[0]
|
||||||
|
|
||||||
def read_bss_sections(bss):
|
def read_bss_sections(bss):
|
||||||
sections = []
|
sections = []
|
||||||
section = {
|
section = {
|
||||||
"labels": [],
|
|
||||||
}
|
}
|
||||||
address = None
|
address = None
|
||||||
if type(bss) is not list: bss = bss.split('\n')
|
if type(bss) is not list: bss = bss.split('\n')
|
||||||
for line in bss:
|
for line in bss:
|
||||||
line = line.lstrip()
|
line = line.lstrip()
|
||||||
if 'SECTION' in line:
|
if 'SECTION' == line[:7]:
|
||||||
if section: sections.append(section) # last section
|
if section: # previous
|
||||||
|
sections += [section]
|
||||||
|
|
||||||
|
section_def = line.split(',')
|
||||||
|
name = section_def[0].split('"')[1]
|
||||||
|
type_ = section_def[1].strip()
|
||||||
|
if len(section_def) > 2:
|
||||||
|
bank = bracket_value(section_def[2])
|
||||||
|
else:
|
||||||
|
bank = None
|
||||||
|
|
||||||
|
if '[' in type_:
|
||||||
|
address = int(bracket_value(type_).replace('$','0x'), 16)
|
||||||
|
else:
|
||||||
|
if address == None or bank != section['bank']:
|
||||||
|
for type__, addr in [
|
||||||
|
('VRAM', 0x8000),
|
||||||
|
('SRAM', 0xa000),
|
||||||
|
('WRAM0', 0xc000),
|
||||||
|
('WRAMX', 0xd000),
|
||||||
|
('HRAM', 0xff80),
|
||||||
|
]:
|
||||||
|
if type__ == type_ and section['type'] == type__:
|
||||||
|
address = addr
|
||||||
|
# else: keep going from this address
|
||||||
|
|
||||||
address = eval(line[line.find('[')+1:line.find(']')].replace('$','0x'))
|
|
||||||
section = {
|
section = {
|
||||||
'name': line.split('"')[1],
|
'name': name,
|
||||||
#'type': line.split(',')[1].split('[')[0].strip(),
|
'type': type_,
|
||||||
|
'bank': bank,
|
||||||
'start': address,
|
'start': address,
|
||||||
'labels': [],
|
'labels': [],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user