Prev: 27141 Up: Map Next: 27251
27206: Test Charlie Collision
Tests whether the actor is within 12 pixels of Charlie, both horizontally and vertically. Charlie can only be hit while he has his hat on (his ID is 1 or 2). If he has been hit then the rising sweep sound is started.
Input
IX Actor
Output
E 1 if the actor has collided with Charlie, otherwise 0
See Immunity.
TestCharlieCollision 27206 LD HL,24373 Point HL at Charlie's actor ID.
27209 LD E,0 Assume that there is no collision (E=0).
27211 LD A,(HL) Fetch Charlie's ID.
27212 AND %00111111 Keep only bits 0-5.
27214 DEC A Is Charlie's ID 1?
27215 JR Z,TestCharlieCollision_Horizontal Jump to TestCharlieCollision_Horizontal if Charlie's ID is 1.
27217 DEC A Is Charlie's ID 2?
27218 RET NZ Return if Charlie's ID is not 2.
TestCharlieCollision_Horizontal 27219 INC HL Move on to Charlie's horizontal co-ordinate.
27220 LD A,(HL) Fetch Charlie's horizontal co-ordinate.
27221 SUB (IX+1) Subtract the horizontal co-ordinate of the actor.
27224 JP P,TestCharlieCollision_HorizontalDistance Jump to TestCharlieCollision_HorizontalDistance if the result is positive.
27227 NEG Make the result positive.
TestCharlieCollision_HorizontalDistance 27229 CP 12 Compare with 12 (the width of the collision area).
27231 RET NC Return if the actor is too far away.
27232 INC HL Move on to Charlie's vertical co-ordinate.
27233 LD A,(HL) Fetch Charlie's vertical co-ordinate.
27234 SUB (IX+2) Subtract the vertical co-ordinate of the actor.
27237 JP P,TestCharlieCollision_VerticalDistance Jump to TestCharlieCollision_VerticalDistance if the result is positive.
27240 NEG Make the result positive.
TestCharlieCollision_VerticalDistance 27242 CP 12 Compare with 12 (the height of the collision area).
27244 RET NC Return if the actor is too far away.
27245 CALL StartRisingSweep Start the rising sweep sound using StartRisingSweep.
27248 LD E,1 Flag that Charlie has been hit (E=1).
27250 RET Return.
Prev: 27141 Up: Map Next: 27251