| Routines

28295: Adjust Sam's cash supply and print the new amount

Used by the routines at 31594, 31642 and 64338. Returns with the zero flag set if Sam has run out of money.
Input
A | N/10 (N=number of bucks to subtract)
28295 | LD E,A | A=N
28296 | ADD A,A
28297 | ADD A,A
28298 | ADD A,E
28299 | ADD A,A
This entry point is used by the routine at 30458 with A=2.
28300 | LD D,255 | Prepare DE for subtraction
28302 | NEG | A=-N
28304 | JR 28308 |
This entry point is used by the routines at 25039, 28760 and 30211 with A holding the number of bucks to add to Sam's cash supply.
28306 | LD D,0 | Prepare DE for addition
28308 | LD E,A | Now DE=number of bucks to add (may be negative)
This entry point is used by the routine at 28337 with DE=65535 (-1).
28309 | LD HL,(32670) | Collect the current number of bucks from 32670
28312 | ADD HL,DE | Adjust the number
28313 | INC H | Is the result negative?
28314 | JR NZ,28319 | Jump if not
28316 | LD HL,256 | Set HL up so that the next instruction reduces it to 0
28319 | DEC H | Restore the value of HL (if it was non-negative), or set it to 0 (if it was negative)
28320 | LD A,H | Set the zero flag if the number of bucks is now 0
28321 | OR L
28322 | PUSH AF | Save the zero flag temporarily
28323 | LD (32670),HL | Store the new amount at 32670
28326 | LD DE,20728 | DE=display file address
28329 | CALL 28186 | Print the number of bucks
28332 | POP AF | Restore the zero flag
28333 | RET |