| Routines

24832: Deal with Sam while he's transfixed by Lana

Used by the routine at 29912 when bit 1 at 32764 is set (by the routine at 29952, using the event entry at 24792), indicating that Sam has been immobilised after meeting Lana in his office.
Input
H | 230 (Sam)
24832 | LD L,8 | Set Sam's main action timer (in byte 8 of his buffer) to 8
24834 | LD (HL),L
24835 | LD L,13 | Byte 13 of Sam's buffer holds 0 if Sam has only just met Lana, or 1 otherwise
24837 | LD A,(HL)
24838 | AND A | Has Sam only just met Lana in his office?
24839 | JR NZ,24850 | Jump if not
24841 | INC (HL) | Increment byte 13 of Sam's buffer so that we don't come here again
24842 | LD A,73 | Message 73: 'I STARED AT THE LOVELY LANA...'
24844 | LD (32722),A | Store the message number at 32722 (so that we can check when it has been displayed)
24847 | JP 30154 | Queue the message urgently
While Lana is transfixing Sam, we count the policemen who have shown up at Sam's office so far and been immobilised.
24850 | LD BC,512 | B=2 (2 policemen), C=0 (will count the number of immobilised policemen)
24853 | LD D,222 | Character 222 is the first policeman
24855 | LD E,9 | Point DE at byte 9 of the policeman's buffer
24857 | INC C | Assume that this policeman is already immobilised
24858 | LD A,(DE) | A=MSB of the policeman's current primary command routine
24859 | CP 231 | Is it the MSB of 59147 (RET)?
24861 | JR Z,24890 | Jump if so (this policeman is already immobilised)
24863 | DEC C | Decrement C because this policeman is not yet immobilised
24864 | LD E,2 | A=policeman's y-coordinate
24866 | LD A,(DE)
24867 | CP 19 | Is the policeman on the third floor of a building?
24869 | JR NZ,24890 | Jump to consider the next policeman if not
24871 | DEC E | E=1
24872 | LD A,(DE) | A=policeman's x-coordinate
24873 | CP 239 | Consider the next policeman unless this one is in Sam's office
24875 | JR NC,24890
24877 | CP 224
24879 | JR C,24890
24881 | LD A,231 | Place 59147 (RET) into bytes 8 and 9 of the policeman's buffer, thus immobilising him
24883 | LD E,9
24885 | LD (DE),A
24886 | LD A,11
24888 | DEC E
24889 | LD (DE),A
24890 | INC D | Point DE at the next policeman's buffer
24891 | DJNZ 24855 | Jump back until both policemen have been checked
Now C holds the number of policemen that have been immobilised in Sam's office.
24893 | PUSH BC | Save the number of immobilised policemen briefly
24894 | CALL 30972 | Check whether message 73 ('I STARED AT THE LOVELY LANA...') is still in the message queue
24897 | POP BC | Restore the number of immobilised policemen to C
24898 | RET Z | Return unless the entire message has been displayed
24899 | LD A,C | A=number of immobilised policemen
24900 | AND A | Is it at least one?
24901 | JR NZ,24914 | Jump if so
24903 | LD HL,0 | Set the number of bucks (stored at 32670) to 0
24906 | LD (32670),HL
24909 | LD A,75 | Message 75: 'SHE FIRED'
24911 | JP 31445 | Display the cutscene with this message, and then prepare to enter demo mode