Prev: 7AE2 Up: Map Next: 7B5A
7AF4: Deal with Sam when he's being carried by a gangster or policeman
Used by the routine at 74D8 when bit 0 at 7FFC is set (by the routine at 71DD), indicating that Sam is being carried by a gangster or policeman.
7AF4 LD HL,$0001 Set Sam's main action timer to 1 (so that we come here on the next pass through the main loop) and his midstride/mid-action timer to 0
7AF7 LD ($E608),HL
First we need to determine who is carrying Sam.
7AFA LD HL,$D700 Point HL at byte 0x00 of character 0xD7's buffer
7AFD LD B,$0F We will check characters 0xD7-0xE5
7AFF LD A,(HL) A=character's animatory state
7B00 AND $78 A=character's base animatory state (bits 0-2 and 7 reset)
7B02 CP $18 0x18: Is this character a policeman carrying Sam?
7B04 JR Z,$7B28 Jump if so
7B06 CP $28 0x28: Is this character a gangster carrying Sam?
7B08 JR Z,$7B28 Jump if so
7B0A INC H Next character
7B0B DJNZ $7AFF Jump back until we find who's carrying Sam
No one is carrying Sam at the moment. Whoever was carrying him must have just dropped him.
7B0D LD L,$02 Point HL at byte 0x02 of Sam's buffer
7B0F LD A,(HL) A=Sam's y-coordinate
7B10 CP $13 Set the carry flag if it's less than 19
7B12 LD B,$01 B=1 indicates that Sam is being dropped off the roof of a building
7B14 JP C,$FB55 Jump if Sam's being dropped off the roof of a building
Sam is being dropped by a policeman onto the floor of the jail cell.
7B17 XOR A Clear all of Sam's status flags at 7FFC
7B18 LD ($7FFC),A
7B1B LD L,$08 Set Sam's main action timer to 8
7B1D LD (HL),$08
7B1F CALL $E9C8 Update the SRB for Sam's current animatory state and location
7B22 AND $80 Sam's new animatory state is 0x00 (bit 7 of A is reset, because Sam's always facing left when he's dropped here)
7B24 INC D Drop him one level (to the floor)
7B25 JP $E9D5 Update Sam's animatory state and location and update the SRB
Sam is still being carried by a gangster or policeman. Calculate Sam's new animatory state and location (which depend on those of his carrier).
7B28 LD L,$04 Point HL at byte 0x04 of Sam's carrier's buffer
7B2A LD A,(HL) A=carrier's z-coordinate
7B2B LD ($E604),A Set Sam's z-coordinate to the same value
7B2E LD L,$00 Point HL at byte 0x00 of Sam's carrier's buffer
7B30 LD C,$05 Animatory state 0x05: Sam being carried (facing left)
7B32 LD E,$FF E=-1
7B34 BIT 0,(HL) Is Sam's carrier midstride?
7B36 JR Z,$7B3B Jump if not
7B38 DEC E E=-2
7B39 LD C,$02 Animatory state 0x02: Sam standing (facing left)
7B3B LD A,E A=-2 if Sam's carrier is midstride, -1 otherwise
7B3C BIT 7,(HL) Is Sam's carrier facing left?
7B3E JR Z,$7B44 Jump if so
7B40 SET 7,C C=0x82 or 0x85 (animatory states of Sam being carried, facing right)
7B42 NEG A=2 if Sam's carrier is midstride, 1 otherwise
7B44 INC L Add Sam's carrier's x-coordinate to obtain Sam's x-coordinate
7B45 ADD A,(HL)
7B46 LD E,A Copy this to E
7B47 INC L D=Sam's carrier's y-coordinate
7B48 LD D,(HL)
7B49 DEC D Decrement it to obtain Sam's y-coordinate
7B4A LD A,C A=Sam's animatory state
7B4B PUSH AF Save Sam's animatory state briefly
7B4C PUSH DE Save Sam's new coordinates
7B4D LD H,$E6 0xE6=Sam
7B4F CALL $E9C8 Update the SRB for Sam's current animatory state and location
7B52 POP DE Restore Sam's new coordinates to DE
7B53 POP AF Restore Sam's animatory state to A
7B54 CALL $E9D5 Update Sam's animatory state and location and update the SRB
7B57 JP $EC83 Scroll the screen left, right, up or down if necessary
Prev: 7AE2 Up: Map Next: 7B5A