Prev: 31458 Up: Map Next: 31578
31476: Deal with Sam when he's being carried by a gangster or policeman
Used by the routine at 29912 when bit 0 at 32764 is set (by the routine at 29149), indicating that Sam is being carried by a gangster or policeman.
31476 LD HL,1 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
31479 LD (58888),HL
First we need to determine who is carrying Sam.
31482 LD HL,55040 Point HL at byte 0 of character 215's buffer
31485 LD B,15 We will check characters 215-229
31487 LD A,(HL) A=character's animatory state
31488 AND 120 A=character's base animatory state (bits 0-2 and 7 reset)
31490 CP 24 24: Is this character a policeman carrying Sam?
31492 JR Z,31528 Jump if so
31494 CP 40 40: Is this character a gangster carrying Sam?
31496 JR Z,31528 Jump if so
31498 INC H Next character
31499 DJNZ 31487 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.
31501 LD L,2 Point HL at byte 2 of Sam's buffer
31503 LD A,(HL) A=Sam's y-coordinate
31504 CP 19 Set the carry flag if it's less than 19
31506 LD B,1 B=1 indicates that Sam is being dropped off the roof of a building
31508 JP C,64341 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.
31511 XOR A Clear all of Sam's status flags at 32764
31512 LD (32764),A
31515 LD L,8 Set Sam's main action timer to 8
31517 LD (HL),8
31519 CALL 59848 Update the SRB for Sam's current animatory state and location
31522 AND 128 Sam's new animatory state is 0 (bit 7 of A is reset, because Sam's always facing left when he's dropped here)
31524 INC D Drop him one level (to the floor)
31525 JP 59861 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).
31528 LD L,4 Point HL at byte 4 of Sam's carrier's buffer
31530 LD A,(HL) A=carrier's z-coordinate
31531 LD (58884),A Set Sam's z-coordinate to the same value
31534 LD L,0 Point HL at byte 0 of Sam's carrier's buffer
31536 LD C,5 Animatory state 5: Sam being carried (facing left)
31538 LD E,255 E=-1
31540 BIT 0,(HL) Is Sam's carrier midstride?
31542 JR Z,31547 Jump if not
31544 DEC E E=-2
31545 LD C,2 Animatory state 2: Sam standing (facing left)
31547 LD A,E A=-2 if Sam's carrier is midstride, -1 otherwise
31548 BIT 7,(HL) Is Sam's carrier facing left?
31550 JR Z,31556 Jump if so
31552 SET 7,C C=130 or 133 (animatory states of Sam being carried, facing right)
31554 NEG A=2 if Sam's carrier is midstride, 1 otherwise
31556 INC L Add Sam's carrier's x-coordinate to obtain Sam's x-coordinate
31557 ADD A,(HL)
31558 LD E,A Copy this to E
31559 INC L D=Sam's carrier's y-coordinate
31560 LD D,(HL)
31561 DEC D Decrement it to obtain Sam's y-coordinate
31562 LD A,C A=Sam's animatory state
31563 PUSH AF Save Sam's animatory state briefly
31564 PUSH DE Save Sam's new coordinates
31565 LD H,230 230=Sam
31567 CALL 59848 Update the SRB for Sam's current animatory state and location
31570 POP DE Restore Sam's new coordinates to DE
31571 POP AF Restore Sam's animatory state to A
31572 CALL 59861 Update Sam's animatory state and location and update the SRB
31575 JP 60547 Scroll the screen left, right, up or down if necessary
Prev: 31458 Up: Map Next: 31578