mirror of
https://github.com/pret/pokemon-reverse-engineering-tools.git
synced 2026-03-22 01:34:19 -05:00
wram: try to determine addresses for section defs without any
This commit is contained in:
parent
c57e0f0706
commit
0fd121a81e
|
|
@ -14,22 +14,48 @@ def make_wram_labels(wram_sections):
|
|||
wram_labels[label['address']] += [label['label']]
|
||||
return wram_labels
|
||||
|
||||
def bracket_value(string, i=0):
|
||||
return string.split('[')[1 + i*2].split(']')[0]
|
||||
|
||||
def read_bss_sections(bss):
|
||||
sections = []
|
||||
section = {
|
||||
"labels": [],
|
||||
}
|
||||
address = None
|
||||
if type(bss) is not list: bss = bss.split('\n')
|
||||
for line in bss:
|
||||
line = line.lstrip()
|
||||
if 'SECTION' in line:
|
||||
if section: sections.append(section) # last section
|
||||
if 'SECTION' == line[:7]:
|
||||
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 = {
|
||||
'name': line.split('"')[1],
|
||||
#'type': line.split(',')[1].split('[')[0].strip(),
|
||||
'name': name,
|
||||
'type': type_,
|
||||
'bank': bank,
|
||||
'start': address,
|
||||
'labels': [],
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user