summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2012-04-21 16:11:00 -0500
committerBryan Bishop <kanzure@gmail.com>2012-04-21 16:11:00 -0500
commitbfa0ed8d6e9b67daaefe8836620ea71070f00d4c (patch)
tree2ce489410dd96afe882544c22ec0986953e99412
parentf484df40ce403766c4baa609ee71f5bb7804be12 (diff)
fix bug parsing INCBIN lines
original-commit-id: c42b254081033bbb54ba56cb96ead7439d8452c8
-rw-r--r--crystal.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/crystal.py b/crystal.py
index 9aefa18..2dd5907 100644
--- a/crystal.py
+++ b/crystal.py
@@ -4492,14 +4492,14 @@ class Incbin:
return incbins
-def AsmSection:
+class AsmSection:
def __init__(self, line):
self.bank_id = None
self.line = line
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 @@ class Asm:
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 @@ class Asm:
# 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