ref: d7ff5e5cebfb8349ef6b2263c227eb603e27f012
parent: e80f480da9dab91046b876ad02a47e6a2903b374
author: Bryan Bishop <[email protected]>
date: Sun Apr 8 08:19:03 EDT 2012
pass force=True/False and debug=True/False to command parsing
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -2212,7 +2212,7 @@
def _parse_script_pointer_bytes(self):
PointerLabelParam.parse(self)
address = calculate_pointer_from_bytes_at(self.address, bank=self.bank)
- self.script = parse_script_engine_script_at(address)
+ self.script = parse_script_engine_script_at(address, debug=self.debug, force=self.force, map_group=self.map_group, map_id=self.map_id)
ScriptPointerLabelParam.parse = _parse_script_pointer_bytes
ScriptPointerLabelBeforeBank.parse = _parse_script_pointer_bytes
ScriptPointerLabelAfterBank.parse = _parse_script_pointer_bytes
@@ -2221,18 +2221,18 @@
PointerLabelParam.parse(self)
address = calculate_pointer_from_bytes_at(self.address, bank=self.bank)
address2 = calculate_pointer_from_bytes_at(address, bank="reverse") #maybe not "reverse"?
- self.script = parse_script_engine_script_at(address2, origin=False)
+ self.script = parse_script_engine_script_at(address2, origin=False, map_group=self.map_group, map_id=self.map_id, force=self.force, debug=self.debug)
class AsmPointerParam(PointerLabelBeforeBank):
def parse(self):
PointerLabelBeforeBank.parse(self)
address = calculate_pointer_from_bytes_at(self.address, bank=self.bank) #3-byte pointer
- self.asm = parse_script_asm_at(address) #might end in some specific way?
+ self.asm = parse_script_asm_at(address, map_group=self.map_group, map_id=self.map_id, force=self.force, debug=self.debug) #might end in some specific way?
class PointerToAsmPointerParam(PointerLabelParam):
def parse(self):
PointerLabelParam.parse(self)
address = calculate_pointer_from_bytes_at(self.address, bank=self.bank) #2-byte pointer
address2 = calculate_pointer_from_bytes_at(address, bank="reverse") #maybe not "reverse"?
- self.asm = parse_script_asm_at(address) #might end in some specific way?
+ self.asm = parse_script_asm_at(address, map_group=self.map_group, map_id=self.map_id, force=self.force, debug=self.debug) #might end in some specific way?
class RAMAddressParam(MultiByteParam):
def to_asm(self):
address = calculate_pointer_from_bytes_at(self.address, bank=False)
@@ -2482,13 +2482,29 @@
class Command():
def __init__(self, address=None, *pargs, **kwargs):
- #raise Exception, "i don't think anything actually calls this?"
- self.params = {}
+ """params:
+ address - where the command starts
+ force - whether or not to force the script to be parsed (default False)
+ debug - are we in debug mode? default False
+ map_group
+ map_id
+ """
+ defaults = {"force": False, "debug": False, "map_group": None, "map_id": None}
if not is_valid_address(address):
raise Exception, "address is invalid"
+ #set up some variables
self.address = address
self.last_address = None
+ #params are where this command's byte parameters are stored
self.params = {}
+ #override default settings
+ defaults.update(kwargs)
+ #set everything
+ for (key, value) in defaults.items():
+ setattr(self, key, value)
+ #but also store these kwargs
+ self.args = defaults
+ #start parsing this command's parameter bytes
self.parse()
def to_asm(self):
#start with the rgbasm macro name for this command
@@ -2538,7 +2554,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)
+ obj = klass(address=current_address, name=name, **self.args)
#save this for later
self.params[i] = obj
#increment our counters
@@ -2639,7 +2655,7 @@
for command in commands:
asm_output += command.to_asm() + "\n"
raise Exception, "no command found? id: " + hex(cur_byte) + " at " + hex(current_address) + " asm is:\n" + asm_output
- cls = right_kls(address=current_address)
+ cls = right_kls(address=current_address, force=force, map_group=map_group, map_id=map_id)
print cls.to_asm()
end = cls.end
commands.append(cls)