Prev: 6A05 Up: Map Next: 6A73
6A46: Test Charlie Collision
Tests whether the actor is within 0C pixels of Charlie, both horizontally and vertically. Charlie can only be hit while he has his hat on (his ID is 01 or 02). If he has been hit then the rising sweep sound is started.
Input
IX Actor
Output
E 01 if the actor has collided with Charlie, otherwise 00
See Immunity.
TestCharlieCollision 6A46 LD HL,$5F35 Point HL at Charlie's actor ID.
6A49 LD E,$00 Assume that there is no collision (E=00).
6A4B LD A,(HL) Fetch Charlie's ID.
6A4C AND %00111111 Keep only bits 0-5.
6A4E DEC A Is Charlie's ID 01?
6A4F JR Z,TestCharlieCollision_Horizontal Jump to TestCharlieCollision_Horizontal if Charlie's ID is 01.
6A51 DEC A Is Charlie's ID 02?
6A52 RET NZ Return if Charlie's ID is not 02.
TestCharlieCollision_Horizontal 6A53 INC HL Move on to Charlie's horizontal co-ordinate.
6A54 LD A,(HL) Fetch Charlie's horizontal co-ordinate.
6A55 SUB (IX+$01) Subtract the horizontal co-ordinate of the actor.
6A58 JP P,TestCharlieCollision_HorizontalDistance Jump to TestCharlieCollision_HorizontalDistance if the result is positive.
6A5B NEG Make the result positive.
TestCharlieCollision_HorizontalDistance 6A5D CP $0C Compare with 0C (the width of the collision area).
6A5F RET NC Return if the actor is too far away.
6A60 INC HL Move on to Charlie's vertical co-ordinate.
6A61 LD A,(HL) Fetch Charlie's vertical co-ordinate.
6A62 SUB (IX+$02) Subtract the vertical co-ordinate of the actor.
6A65 JP P,TestCharlieCollision_VerticalDistance Jump to TestCharlieCollision_VerticalDistance if the result is positive.
6A68 NEG Make the result positive.
TestCharlieCollision_VerticalDistance 6A6A CP $0C Compare with 0C (the height of the collision area).
6A6C RET NC Return if the actor is too far away.
6A6D CALL StartRisingSweep Start the rising sweep sound using StartRisingSweep.
6A70 LD E,$01 Flag that Charlie has been hit (E=01).
6A72 RET Return.
Prev: 6A05 Up: Map Next: 6A73