Prev: 29453 Up: Map Next: 29560
29463: Test Flour Collision
Tests whether the actor has been hit by a flour shot (they are in the two actor slots after Charlie). A shot is within range if it is between 10 pixels to the left and 18 pixels to the right of the actor, and between 18 pixels above and 10 pixels below it. If it is then the actor is coloured white, bit 7 of its ID is set and the counter in byte 7 is set to 64. The speeds of the shot are copied to the actor, the shot is made to explode, and the rising tone is played.
Input
IX Actor
TestFlourCollision 29463 LD DE,8 Set the size of an actor to 8.
29466 LD HL,24381 Point HL at ActorFlourShots.
29469 LD B,2 Set the slot counter to 2 (the number of slots for flour shots).
TestFlourCollision_Loop 29471 PUSH HL Stash the address of the slot on the stack.
29472 LD A,(HL) Fetch the actor ID of the slot.
29473 AND A Is the slot empty?
29474 JR Z,TestFlourCollision_Next Jump to TestFlourCollision_Next if it is.
29476 CP 38 Jump to TestFlourCollision_Next if the shot has exploded.
29478 JR NC,TestFlourCollision_Next
29480 INC HL Move on to the horizontal co-ordinate of the shot.
29481 LD A,(HL) Fetch the horizontal co-ordinate of the shot.
29482 SUB (IX+1) Subtract the horizontal co-ordinate of the actor.
29485 JP P,TestFlourCollision_Right Jump to TestFlourCollision_Right if the shot is to the right of the actor.
29488 NEG Make the distance positive.
29490 LD C,10 Set the distance which is allowed to the left to 10.
29492 JR TestFlourCollision_Horizontal Jump to TestFlourCollision_Horizontal.
TestFlourCollision_Right 29494 LD C,18 Set the distance which is allowed to the right to 18.
TestFlourCollision_Horizontal 29496 CP C Compare the distance with the distance which is allowed.
29497 JR NC,TestFlourCollision_Next Jump to TestFlourCollision_Next if the shot is too far away.
29499 INC HL Move on to the vertical co-ordinate of the shot.
29500 LD A,(HL) Fetch the vertical co-ordinate of the shot.
29501 SUB (IX+2) Subtract the vertical co-ordinate of the actor.
29504 JP P,TestFlourCollision_Below Jump to TestFlourCollision_Below if the shot is below the actor.
29507 NEG Make the distance positive.
29509 LD C,18 Set the distance which is allowed above to 18.
29511 JR TestFlourCollision_Vertical Jump to TestFlourCollision_Vertical.
TestFlourCollision_Below 29513 LD C,10 Set the distance which is allowed below to 10.
TestFlourCollision_Vertical 29515 CP C Compare the distance with the distance which is allowed.
29516 JR C,TestFlourCollision_Hit Jump to TestFlourCollision_Hit if the shot has hit the actor.
TestFlourCollision_Next 29518 POP HL Restore the address of the slot from the stack.
29519 ADD HL,DE Move on to the next slot.
29520 DJNZ TestFlourCollision_Loop Decrease the slot counter by one and loop back to TestFlourCollision_Loop until both slots have been tried.
29522 RET Return.
The shot has hit the actor.
TestFlourCollision_Hit 29523 LD (IX+3),71 Set the actor colour to 71 (white).
29527 SET 7,(IX+0) Set bit 7 of the actor ID.
29531 LD (IX+7),64 Set the hit counter (byte 7 of the actor) to 64.
29535 INC HL Move on to the horizontal speed of the shot.
29536 INC HL
29537 LD A,(HL) Fetch the horizontal speed of the shot.
29538 LD (IX+4),A Update the horizontal speed of the actor.
29541 INC HL Move on to the vertical speed of the shot.
29542 LD A,(HL) Fetch the vertical speed of the shot.
29543 LD (IX+5),A Update the vertical speed of the actor.
29546 POP HL Restore the address of the shot from the stack.
29547 PUSH IX Save the pointer to the current actor on the stack.
29549 PUSH HL Save the address of the shot on the stack.
29550 POP IX Point IX at the shot.
29552 CALL ExplodeFlourShot Make the shot explode using ExplodeFlourShot.
29555 POP IX Restore the pointer to the current actor from the stack.
29557 JP PlayRisingTone Jump to PlayRisingTone to play the rising tone.
Prev: 29453 Up: Map Next: 29560