ref: c42b254081033bbb54ba56cb96ead7439d8452c8
parent: b597af7c57033acd1acf468e48b7140c9f390ef0
author: Bryan Bishop <[email protected]>
date: Sat Apr 21 12:11:00 EDT 2012
fix bug parsing INCBIN lines
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -4492,7 +4492,7 @@
return incbins
-def AsmSection:
+class AsmSection:
def __init__(self, line):
self.bank_id = None
self.line = line
@@ -4499,7 +4499,7 @@
self.parse()
def parse(self):
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
start_address = bank_id * 0x4000
end_address = (bank_id * 0x4000) + 0x4000 - 1
@@ -4524,7 +4524,7 @@
for line in asm_list:
if line[0:6] == "INCBIN" or line[1:6] == "INCBIN":
thing = Incbin(line, bank=bank)
- if line[0:7] == "SECTION":
+ elif line[0:7] == "SECTION":
thing = AsmSection(line)
bank = thing.bank_id
else:
@@ -4543,6 +4543,8 @@
# 2) find which object goes after it
found = False
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
if object.address <= start_address <= object.last_address and isinstance(object, Incbin):
#split up the incbin into three segments