Prev: 653E Up: Map Next: 6585
6558: Determine Sam's location
Used by the routines at 710E, 7190 and 7222. Returns with Sam's x-, y- and z-coordinates (adjusted appropriately if Sam is falling, rolling, somersaulting or being carried) in E, D and A.
6558 LD DE,($E601) Collect Sam's x- and y-coordinates in E and D
655C LD A,($7FFC) Pick up Sam's status flags from 7FFC
655F BIT 3,A Is Sam rolling or somersaulting?
6561 JR NZ,$656F Jump if so
6563 AND $81 Is Sam either being carried by a gangster or policeman, or falling from the roof of a building?
6565 LD A,($E604) Return with A holding Sam's z-coordinate if not
6568 RET Z
Sam is either being carried by a policeman, or falling from the roof of a building.
6569 LD A,$02 2=behind people on the sidewalk
656B LD DE,$26A8 D=38, E=168 (out of reach)
656E RET
Sam is rolling or somersaulting.
656F LD A,($E600) A=Sam's animatory state
6572 AND $7F Discard bit 7 (the direction bit)
6574 CP $0F Is Sam horizontal at the moment (animatory state 0x0F or 0x1F)?
6576 JR C,$657A Jump if not
6578 INC E Add 2 to Sam's x-coordinate if he's horizontal
6579 INC E
657A LD A,E A=x+2 if Sam's horizontal, or x otherwise (where x is Sam's x-coordinate)
657B CALL $EB05 Reset the carry flag if Sam is on or above the sidewalk, or set it if he's on or above the road
657E ADC A,$22 D=34 if Sam's on or above the sidewalk, 35 if he's on or above the road
6580 SUB E
6581 LD D,A
6582 LD A,$04 4=outside
6584 RET
Prev: 653E Up: Map Next: 6585