timefor
New member
This is probably a simple one but for the life of me I can't find an example of this.
I'm trying to build a store type system and I need to check if the player's cash (myCash) which supports upto $999, is greater than or equal to XXX for the item. I can subtract the value easy enough. I've found examples when the value is a single digit. But how do I check higher value variables so I don't end up subtracting and looping the value around when it goes negative?
IE, If player has $10 or more, and the item costs $10 then, continue with transaction, otherwise branch and do something else.
I know this code isn't right, it's just what I've been poking around at for an hour now. Could someone point me in a direction please?
I'm trying to build a store type system and I need to check if the player's cash (myCash) which supports upto $999, is greater than or equal to XXX for the item. I can subtract the value easy enough. I've found examples when the value is a single digit. But how do I check higher value variables so I don't end up subtracting and looping the value around when it goes negative?
IE, If player has $10 or more, and the item costs $10 then, continue with transaction, otherwise branch and do something else.
I know this code isn't right, it's just what I've been poking around at for an hour now. Could someone point me in a direction please?
Code:
LDA myCash
CMP #$0A
BNE +noCash
SubtractValue #$03, myCash, #$01, #$01 ;;subtract $10
UpdateHudElement #$05 ;;myCash var
+noCash: