diff options
author | yenatch <yenatch@gmail.com> | 2014-03-23 02:07:21 -0400 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2014-03-23 02:12:26 -0400 |
commit | de39f7c6ff487f02d1914cc4a3260817287207c5 (patch) | |
tree | 6664336b6de3c1a9925a8e345c942dde95f010ee /pokemontools | |
parent | da0ccc6e1db8d6651521748d34bc79950acd09eb (diff) |
PointerLabelParam: Return valid (or at least informative) arguments.
PointerLabelParam.to_asm() returns a label by default.
If no label exists, instead return a bank and address.
This will not compile (maybe it ought to), but it
simplifies debugging.
Diffstat (limited to 'pokemontools')
-rw-r--r-- | pokemontools/crystal.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pokemontools/crystal.py b/pokemontools/crystal.py index 72d08a1..dac06be 100644 --- a/pokemontools/crystal.py +++ b/pokemontools/crystal.py @@ -909,26 +909,29 @@ class PointerLabelParam(MultiByteParam): # setup output bytes if the label was not found if not label: - #pointer_part = (", ".join([(self.prefix+"%.2x")%x for x in reversed(self.bytes[1:])])) - pointer_part = self.prefix+("%.2x"%self.bytes[1])+("%.2x"%self.bytes[0]) + if bank == True: + lo, hi = self.bytes[1:3] + else: + lo, hi = self.bytes[0:2] + pointer_part = "{0}{1:2x}{2:2x}".format(self.prefix, hi, lo) # bank positioning matters! if bank == True or bank == "reverse": # bank, pointer # possibly use BANK(LABEL) if we know the bank - if not label: - bank_part = ((self.prefix+"%.2x")%bank) + if label: + bank_part = "BANK({})".format(label) else: - if "$" in label: + if "$" in pointer_part: if 0x4000 <= caddress <= 0x7FFF: #bank_part = "$%.2x" % (pointers.calculate_bank(self.parent.parent.address)) bank_part = "1" else: bank_part = "$%.2x" % (pointers.calculate_bank(caddress)) else: - bank_part = "BANK("+label+")" + bank_part = ((self.prefix+"%.2x")%bank) # for labels, expand bank_part at build time if bank in ["reverse", True] and label: - return pointer_part + return label # return the asm based on the order the bytes were specified to be in elif bank == "reverse": # pointer, bank return pointer_part+", "+bank_part |