Prev: AB01 Up: Map Next: AB74
AB36: Test Actor Hurting Player
Tests whether an actor is touching the player, and if so whether the actor hurts the player. The test is only made when the player has the normal colour of 47 (see TestOrchidTouched) and is in the same room as the actor.
If the player is walking, or is attacking in the direction away from the actor, then they are hit and the direction they are hit in is written to 9704 (01 if bit 0 of D is set, or 02 otherwise). If the player is attacking towards the actor then the actor is hit and no hit direction is written.
Input
B How far above the actor the player can be
C How far to the right of the actor the player can be
D Bit 0 is set if the hit direction should be 01
IX Actor record
Output
F Carry flag set if the actor is touching the player
TestActorHurtingPlayer AB36 LD A,($9707) Fetch the colour of the player from 9707.
AB39 SUB $47 Subtract 47 (the normal colour).
AB3B AND A Return if the player does not have the normal colour.
AB3C RET NZ
This entry point is used by the routine at HandlerGuardian.
TestActorHurtingPlayer_Room AB3D LD A,($9703) Fetch the room of the player from 9703.
AB40 SUB (IX+$01) Subtract the room of the actor.
AB43 AND A Return if the actor is in a different room to the player.
AB44 RET NZ
AB45 CALL TestPlayerTouchingActor Test whether the player is touching the actor.
See Immunity.
AB48 RET NC Return if the player is not touching the actor.
AB49 LD A,($9702) Fetch the sprite ID of the player from ImmortalData.
AB4C SUB $10 Subtract 10 (the first Sabreman sprite ID).
AB4E CP $10 Jump to TestActorHurtingPlayer_Hit if the player is walking.
AB50 JR C,TestActorHurtingPlayer_Hit
AB52 BIT 3,A Jump to TestActorHurtingPlayer_Right if the player is attacking to the right (bit 3 of the sprite ID is set).
AB54 JR NZ,TestActorHurtingPlayer_Right
The player is attacking to the left.
AB56 LD A,($9705) Fetch the X position of the player from 9705.
AB59 SUB (IX+$03) Subtract the X position of the actor.
AB5C JR NC,TestActorHurtingPlayer_Touching Jump to TestActorHurtingPlayer_Touching if the actor is to the left of the player.
Hurt the player.
TestActorHurtingPlayer_Hit AB5E BIT 0,D Test whether the hit direction should be 01 (bit 0 of D).
AB60 LD A,$01 Set the hit direction in A to 01.
AB62 JR NZ,TestActorHurtingPlayer_Direction Jump to TestActorHurtingPlayer_Direction if bit 0 of D is set.
AB64 INC A Set the hit direction in A to 02.
TestActorHurtingPlayer_Direction AB65 LD ($9704),A Store the hit direction in 9704.
TestActorHurtingPlayer_Touching AB68 SCF Set the carry flag (the actor is touching the player).
AB69 RET Return.
The player is attacking to the right.
TestActorHurtingPlayer_Right AB6A LD A,($9705) Fetch the X position of the player from 9705.
AB6D SUB (IX+$03) Subtract the X position of the actor.
AB70 JR C,TestActorHurtingPlayer_Touching Jump to TestActorHurtingPlayer_Touching if the actor is to the right of the player.
AB72 JR TestActorHurtingPlayer_Hit Jump to TestActorHurtingPlayer_Hit to hurt the player.
Prev: AB01 Up: Map Next: AB74