| Routines

31414: Increment the score and decrement Sam's cash supply at regular intervals

Used by the routine at 61440. Increments the score and decrements Sam's cash supply every 5.12s. Displays the endgame cutscene and enters demo mode if Sam runs out of money.
31414 | LD A,(32750) | Collect the current game mode (0-4) from 32750
31417 | AND A | Is it demo mode?
31418 | RET Z | Return if so
31419 | LD HL,(23672) | Collect the two least significant bytes of the system variable FRAMES in HL
31422 | LD DE,(32724) | DE=two least significant bytes of the system variable FRAMES as they were the last time the score was incremented
31426 | LD BC,65280 | BC=-256
31429 | SBC HL,DE | Was the score last incremented at least 5.12s ago?
31431 | ADD HL,BC
31432 | RET NC | Return if not
31433 | LD HL,(23672) | Collect the two least significant bytes of the system variable FRAMES in HL
31436 | LD (32724),HL | Store these bytes at 32724 for comparison next time
31439 | CALL 28337 | Increment the score and decrement Sam's cash supply
31442 | RET NZ | Return unless Sam has no money left
31443 | LD A,34 | Message 34: 'I WAS BROKE AGAIN...'
This entry point is used by the routines at 24832, 26002 and 64338.
31445 | PUSH AF | Save the message number briefly
31446 | LD A,57 | A=57, D=8, E=216: the top-left corner of the cutscene window will be at (224,19), with Sam at (229,19) (in his office)
31448 | LD DE,2264
This entry point is used by the routines at 31642 and 63662.
31451 | CALL 30822 | Prepare for the cutscene
31454 | POP AF | Restore the cutscene message number to A
31455 | JP 30989 | Display the cutscene