Prev: A576 Up: Map Next: A5EA
A5A7: Check Shot Hit
Used by the routines at MoveSpark, FinishRobotTurn and MoveRobotHorizontally.
Checks whether an entity (a shot, or the robot) has run into an enemy. If it has, then both are turned into smoke and the player is awarded some points.
Input
IX Entity
Output
IY The enemy that has been hit
CheckShotHit A5A7 LD B,$0A There are ten enemies to check.
A5A9 LD IY,$96D0 Point IY at EnemyEntities.
CheckShotHit_Next A5AD PUSH BC Save the counter.
A5AE LD A,(IY+$00) Fetch the type of the enemy.
A5B1 AND A Jump if the entity is not in use.
A5B2 JR Z,CheckShotHit_Skip
A5B4 SUB $38 Jump if it is smoke or a sprite of a materialising enemy (types 38 to 4F).
A5B6 CP $18
A5B8 JR C,CheckShotHit_Skip
A5BA LD BC,$C0C0 Use C0 as the distance in both directions.
A5BD CALL ComparePositions Compare the positions using ComparePositions.
A5C0 JR C,CheckShotHit_Hit Jump if they overlap.
CheckShotHit_Skip A5C2 LD BC,$0010 Each entity is 10 bytes long.
A5C5 ADD IY,BC Move on to the next one.
A5C7 POP BC Restore the counter.
A5C8 DJNZ CheckShotHit_Next Loop back until every enemy has been checked.
A5CA RET Return.
CheckShotHit_Hit A5CB POP BC Discard the counter.
A5CC LD A,(IX+$00) Fetch the type of the entity that has hit the enemy...
A5CF LD (IX+$05),A ...and keep it.
A5D2 LD ($9638),IY Keep the address of the enemy that was hit.
A5D6 LD A,(IY+$00) Fetch the type of the enemy...
A5D9 LD (IY+$05),A ...and keep it.
A5DC LD A,$38 Turn the shot into smoke...
A5DE LD (IX+$00),A
A5E1 LD (IY+$00),A ...and the enemy too.
A5E4 LD BC,$0123 Add 0123 points...
A5E7 JP AddPointsToScore Jump to AddPointsToScore.
Prev: A576 Up: Map Next: A5EA