| Routines

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

Used by the routine at 74D8 when bit 1 at 7FFC is set (by the routine at 7500, using the event entry at 60D8), indicating that Sam has been immobilised after meeting Lana in his office.
Input
H | 0xE6 (Sam)
6100 | LD L,$08 | Set Sam's main action timer (in byte 0x08 of his buffer) to 8
6102 | LD (HL),L
6103 | LD L,$0D | Byte 0x0D of Sam's buffer holds 0 if Sam has only just met Lana, or 1 otherwise
6105 | LD A,(HL)
6106 | AND A | Has Sam only just met Lana in his office?
6107 | JR NZ,$6112 | Jump if not
6109 | INC (HL) | Increment byte 0x0D of Sam's buffer so that we don't come here again
610A | LD A,$49 | Message 0x49: 'I STARED AT THE LOVELY LANA...'
610C | LD ($7FD2),A | Store the message number at 7FD2 (so that we can check when it has been displayed)
610F | JP $75CA | 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.
6112 | LD BC,$0200 | B=2 (2 policemen), C=0 (will count the number of immobilised policemen)
6115 | LD D,$DE | Character 0xDE is the first policeman
6117 | LD E,$09 | Point DE at byte 0x09 of the policeman's buffer
6119 | INC C | Assume that this policeman is already immobilised
611A | LD A,(DE) | A=MSB of the policeman's current primary command routine
611B | CP $E7 | Is it the MSB of E70B (RET)?
611D | JR Z,$613A | Jump if so (this policeman is already immobilised)
611F | DEC C | Decrement C because this policeman is not yet immobilised
6120 | LD E,$02 | A=policeman's y-coordinate
6122 | LD A,(DE)
6123 | CP $13 | Is the policeman on the third floor of a building?
6125 | JR NZ,$613A | Jump to consider the next policeman if not
6127 | DEC E | E=0x01
6128 | LD A,(DE) | A=policeman's x-coordinate
6129 | CP $EF | Consider the next policeman unless this one is in Sam's office
612B | JR NC,$613A
612D | CP $E0
612F | JR C,$613A
6131 | LD A,$E7 | Place E70B (RET) into bytes 0x08 and 0x09 of the policeman's buffer, thus immobilising him
6133 | LD E,$09
6135 | LD (DE),A
6136 | LD A,$0B
6138 | DEC E
6139 | LD (DE),A
613A | INC D | Point DE at the next policeman's buffer
613B | DJNZ $6117 | Jump back until both policemen have been checked
Now C holds the number of policemen that have been immobilised in Sam's office.
613D | PUSH BC | Save the number of immobilised policemen briefly
613E | CALL $78FC | Check whether message 0x49 ('I STARED AT THE LOVELY LANA...') is still in the message queue
6141 | POP BC | Restore the number of immobilised policemen to C
6142 | RET Z | Return unless the entire message has been displayed
6143 | LD A,C | A=number of immobilised policemen
6144 | AND A | Is it at least one?
6145 | JR NZ,$6152 | Jump if so
6147 | LD HL,$0000 | Set the number of bucks (stored at 7F9E) to 0
614A | LD ($7F9E),HL
614D | LD A,$4B | Message 0x4B: 'SHE FIRED'
614F | JP $7AD5 | Display the cutscene with this message, and then prepare to enter demo mode