ref: ac19eb28262800ab26ffd466c4f47b407f893ba5
parent: a53b5ae051d0d1d054da2ff0ee64247ea1663ee2
author: Bryan Bishop <[email protected]>
date: Wed May 16 14:33:24 EDT 2012
don't repeat-parse movement scripts, and set bank=1 for $4000 <= x <= $7FFF
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -1498,7 +1498,14 @@
if not label:
bank_part = ((self.prefix+"%.2x")%bank)
else:
- bank_part = "BANK("+label+")"
+ if "$" in label:
+ if 0x4000 <= caddress <= 0x7FFF:
+ #bank_part = "$%.2x" % (calculate_bank(self.parent.parent.address))
+ bank_part = "1"
+ else:
+ bank_part = "$%.2x" % (calculate_bank(caddress))
+ else:
+ bank_part = "BANK("+label+")"
#return the asm based on the order the bytes were specified to be in
if bank == "reverse": #pointer, bank
return pointer_part+", "+bank_part
@@ -1517,8 +1524,8 @@
class PointerLabelBeforeBank(PointerLabelParam):
bank = True #bank appears first, see calculate_pointer_from_bytes_at
size = 3
+ byte_type = "dw"
-
class PointerLabelAfterBank(PointerLabelParam):
bank = "reverse" #bank appears last, see calculate_pointer_from_bytes_at
size = 3
@@ -1744,7 +1751,10 @@
class MovementPointerLabelParam(PointerLabelParam):
def parse(self):
PointerLabelParam.parse(self)
- self.movement = ApplyMovementData(self.parsed_address, map_group=self.map_group, map_id=self.map_id, debug=self.debug)
+ if is_script_already_parsed_at(self.parsed_address):
+ self.movement = script_parse_table[self.parsed_address]
+ else:
+ self.movement = ApplyMovementData(self.parsed_address, map_group=self.map_group, map_id=self.map_id, debug=self.debug)
def get_dependencies(self, recompute=False, global_dependencies=set()):
if hasattr(self, "movement") and self.movement:
@@ -1868,7 +1878,7 @@
klass = param_type["class"]
#make an instance of this class, like SingleByteParam()
#or ItemLabelByte.. by making an instance, obj.parse() is called
- obj = klass(address=current_address, name=name, **self.args)
+ obj = klass(address=current_address, name=name, parent=self, **dict([(k,v) for (k, v) in self.args.items() if k not in ["parent"]]))
#save this for later
self.params[i] = obj
#increment our counters
@@ -2934,6 +2944,8 @@
self.map_group = kwargs["map_group"]
if "map_id" in kwargs.keys():
self.map_id = kwargs["map_id"]
+ if "parent" in kwargs.keys():
+ self.parent = kwargs["parent"]
#parse the script at the address
if "use_old_parse" in kwargs.keys() and kwargs["use_old_parse"] == True:
self.old_parse(**kwargs)
@@ -3029,7 +3041,7 @@
# create an instance of the command class and let it parse its parameter bytes
#print "about to parse command(script@"+hex(start_address)+"): " + str(scripting_command_class.macro_name)
- cls = scripting_command_class(address=current_address, force=force, map_group=map_group, map_id=map_id)
+ cls = scripting_command_class(address=current_address, force=force, map_group=map_group, map_id=map_id, parent=self)
#if self.debug:
# print cls.to_asm()
@@ -6067,7 +6079,7 @@
asm = Asm()
# start the insertion process
- asm.insert_multiple_with_dependencies(things)
+ asm.insert_with_dependencies(things)
# start dumping
asm.dump()