Prev: 6E84 Up: Map Next: 6EAE
6E87: Adjust Sam's cash supply and print the new amount
Used by the routines at 7B6A, 7B9A and FB52. Returns with the zero flag set if Sam has run out of money.
Input
A N/10 (N=number of bucks to subtract)
6E87 LD E,A A=N
6E88 ADD A,A
6E89 ADD A,A
6E8A ADD A,E
6E8B ADD A,A
This entry point is used by the routine at 76FA with A=2.
6E8C LD D,$FF Prepare DE for subtraction
6E8E NEG A=-N
6E90 JR $6E94
This entry point is used by the routines at 61CF, 7058 and 7603 with A holding the number of bucks to add to Sam's cash supply.
6E92 LD D,$00 Prepare DE for addition
6E94 LD E,A Now DE=number of bucks to add (may be negative)
This entry point is used by the routine at 6EB1 with DE=FFFF (-1).
6E95 LD HL,($7F9E) Collect the current number of bucks from 7F9E
6E98 ADD HL,DE Adjust the number
6E99 INC H Is the result negative?
6E9A JR NZ,$6E9F Jump if not
6E9C LD HL,$0100 Set HL up so that the next instruction reduces it to 0
6E9F DEC H Restore the value of HL (if it was non-negative), or set it to 0 (if it was negative)
6EA0 LD A,H Set the zero flag if the number of bucks is now 0
6EA1 OR L
6EA2 PUSH AF Save the zero flag temporarily
6EA3 LD ($7F9E),HL Store the new amount at 7F9E
6EA6 LD DE,$50F8 DE=display file address
6EA9 CALL $6E1A Print the number of bucks
6EAC POP AF Restore the zero flag
6EAD RET
Prev: 6E84 Up: Map Next: 6EAE