mirror of https://github.com/pret/pokecrystal.git
fix bug parsing INCBIN lines
This commit is contained in:
parent
b597af7c57
commit
c42b254081
|
@ -4492,14 +4492,14 @@ class Incbin:
|
||||||
|
|
||||||
return incbins
|
return incbins
|
||||||
|
|
||||||
def AsmSection:
|
class AsmSection:
|
||||||
def __init__(self, line):
|
def __init__(self, line):
|
||||||
self.bank_id = None
|
self.bank_id = None
|
||||||
self.line = line
|
self.line = line
|
||||||
self.parse()
|
self.parse()
|
||||||
def parse(self):
|
def parse(self):
|
||||||
line = self.line
|
line = self.line
|
||||||
bank_id = int(line.split("\"")[1].split("bank")[1])
|
bank_id = int(line.split("\"")[1].split("bank")[1], 16)
|
||||||
self.bank_id = bank_id
|
self.bank_id = bank_id
|
||||||
start_address = bank_id * 0x4000
|
start_address = bank_id * 0x4000
|
||||||
end_address = (bank_id * 0x4000) + 0x4000 - 1
|
end_address = (bank_id * 0x4000) + 0x4000 - 1
|
||||||
|
@ -4524,7 +4524,7 @@ class Asm:
|
||||||
for line in asm_list:
|
for line in asm_list:
|
||||||
if line[0:6] == "INCBIN" or line[1:6] == "INCBIN":
|
if line[0:6] == "INCBIN" or line[1:6] == "INCBIN":
|
||||||
thing = Incbin(line, bank=bank)
|
thing = Incbin(line, bank=bank)
|
||||||
if line[0:7] == "SECTION":
|
elif line[0:7] == "SECTION":
|
||||||
thing = AsmSection(line)
|
thing = AsmSection(line)
|
||||||
bank = thing.bank_id
|
bank = thing.bank_id
|
||||||
else:
|
else:
|
||||||
|
@ -4543,6 +4543,8 @@ class Asm:
|
||||||
# 2) find which object goes after it
|
# 2) find which object goes after it
|
||||||
found = False
|
found = False
|
||||||
for object in list(self.parts):
|
for object in list(self.parts):
|
||||||
|
#skip objects without a defined interval (like a comment line)
|
||||||
|
if not hasattr(object, "address") and hasattr(object, "last_address"): continue
|
||||||
#replace an incbin with three incbins, replace middle incbin with whatever
|
#replace an incbin with three incbins, replace middle incbin with whatever
|
||||||
if object.address <= start_address <= object.last_address and isinstance(object, Incbin):
|
if object.address <= start_address <= object.last_address and isinstance(object, Incbin):
|
||||||
#split up the incbin into three segments
|
#split up the incbin into three segments
|
||||||
|
|
Loading…
Reference in New Issue