| Routines

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

Used by the routine at F000. 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.
7AB6 | LD A,($7FEE) | Collect the current game mode (0-4) from 7FEE
7AB9 | AND A | Is it demo mode?
7ABA | RET Z | Return if so
7ABB | LD HL,($5C78) | Collect the two least significant bytes of the system variable FRAMES in HL
7ABE | LD DE,($7FD4) | DE=two least significant bytes of the system variable FRAMES as they were the last time the score was incremented
7AC2 | LD BC,$FF00 | BC=-256
7AC5 | SBC HL,DE | Was the score last incremented at least 5.12s ago?
7AC7 | ADD HL,BC
7AC8 | RET NC | Return if not
7AC9 | LD HL,($5C78) | Collect the two least significant bytes of the system variable FRAMES in HL
7ACC | LD ($7FD4),HL | Store these bytes at 7FD4 for comparison next time
7ACF | CALL $6EB1 | Increment the score and decrement Sam's cash supply
7AD2 | RET NZ | Return unless Sam has no money left
7AD3 | LD A,$22 | Message 0x22: 'I WAS BROKE AGAIN...'
This entry point is used by the routines at 6100, 6592 and FB52.
7AD5 | PUSH AF | Save the message number briefly
7AD6 | LD A,$39 | 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)
7AD8 | LD DE,$08D8
This entry point is used by the routines at 7B9A and F8AE.
7ADB | CALL $7866 | Prepare for the cutscene
7ADE | POP AF | Restore the cutscene message number to A
7ADF | JP $790D | Display the cutscene