ref: 45c41795f517f420bc0b6cef4d061f767d90915c
parent: 14a35baa3fdc794c3a4f037530554768926e6465
author: Bryan Bishop <[email protected]>
date: Fri Apr 27 12:33:37 EDT 2012
possibly fix preprocessor/checkmoney issues
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -1407,7 +1407,29 @@
size = 3
max_value = 0x0F423F
should_be_decimal = True
+ def parse(self):
+ MultiByteParam.parse(self)
+ # in the rom as xxyyzz
+ self.x = self.bytes[0]
+ self.y = self.bytes[1]
+ self.z = self.bytes[2]
+ def to_asm(self):
+ return str(self.x + self.y << 8 + self.z << 16)
+ #this is used by the preprocessor
+ @staticmethod
+ def from_asm(value):
+ #max is 0F423F
+ #z = 0x0F ; y = 0x42 ; x = 0x3F
+ #999999 = x + (y << 8) + (z << 16)
+
+ value = int(value)
+
+ x = (value & 0x0000FF)
+ y = (value & 0x00FF00) >> 8
+ z = (value & 0xFF0000) >> 16
+
+ return str(x) + "\ndb "+str(y)+"\ndb "+str(z)
class CoinByteParam(MultiByteParam):
size = 2
--- a/preprocessor.py
+++ b/preprocessor.py
@@ -10,7 +10,8 @@
PeopleEvent, \
DataByteWordMacro, \
PointerLabelBeforeBank, \
- PointerLabelAfterBank
+ PointerLabelAfterBank, \
+ MoneyByteParam
macros = command_classes + \
[Warp, XYTrigger, Signpost, PeopleEvent, DataByteWordMacro]
@@ -450,6 +451,8 @@
elif param_klass.byte_type == "dw":
if param_klass.size == 2:
allowed_length += 1 # just label
+ elif param_klass == MoneyByteParam:
+ allowed_length += 1
elif param_klass.size == 3:
allowed_length += 2 # bank and label
else:
@@ -488,12 +491,15 @@
# write the pointer second
sys.stdout.write("dw " + params[index+1] + "\n")
index += 2
- elif size == 3 and issubclass(param_klass, PointerLabelAfterBank):
+ elif size == 3 and (issubclass(param_klass, PointerLabelAfterBank):
# write the pointer first
sys.stdout.write("dw " + params[index] + "\n")
# write the bank second
sys.stdout.write("db " + params[index+1] + "\n")
index += 2
+ elif size == 3 and issubclass(param_klass, MoneyByteParam):
+ sys.stdout.write("db " + MoneyByteParam.from_asm(params[index]) + "\n")
+ index += 1
else:
raise Exception, "dunno what to do with this macro " + \
"param (" + str(param_klass) + ") " + "on this line: " + \