From 368b3b843dbdaa03747cea6f222f0e4f1d61aa20 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Fri, 27 Apr 2012 16:33:37 -0500 Subject: possibly fix preprocessor/checkmoney issues original-commit-id: 45c41795f517f420bc0b6cef4d061f767d90915c --- crystal.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crystal.py b/crystal.py index bd13f6a..b2ae2e0 100644 --- a/crystal.py +++ b/crystal.py @@ -1407,7 +1407,29 @@ class MoneyByteParam(MultiByteParam): 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 -- cgit v1.2.3