Prev: 6670 Up: Map Next: 66F0
66D8: Check whether Sam is within firing range of the sniper
Used by the routine at 621E. Returns with the zero flag set if the sniper (who is not visible at this point) has an x-coordinate that would place him on screen and at least 8 x-coordinates away from Sam.
Input
H 0xE3 (sniper)
66D8 LD L,$01 Point HL at byte 0x01 of the sniper's buffer
This entry point is used by the routine at 62DB with HL pointing at byte 0x01 of the sniper's buffer.
66DA LD A,($E601) A=Sam's x-coordinate
66DD SUB (HL) Subtract the sniper's x-coordinate
66DE JR NC,$66E2 Jump if the result is non-negative
66E0 NEG Negate the (negative) result
66E2 CP $08 Is Sam less than 8 x-coordinates away from the sniper?
66E4 RET C Return with the zero flag reset if so
66E5 LD A,($7FFE) A=x-coordinate of the leftmost column of the play area on screen
66E8 SUB $02 Is the sniper off-screen to the left or right?
66EA SUB (HL)
66EB ADD A,$20
66ED RET NC Return with the zero flag reset if so
66EE XOR A Set the zero flag
66EF RET
Prev: 6670 Up: Map Next: 66F0