From de39f7c6ff487f02d1914cc4a3260817287207c5 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 23 Mar 2014 02:07:21 -0400 Subject: 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. --- pokemontools/crystal.py | 17 ++++++++++------- 1 file 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 -- cgit v1.2.3