![]() |
Routines |
| Prev: A4DC | Up: Map | Next: A550 |
|
The handler for entity types 60 to 63, which are enemies that hunt for the robot. The enemy heads for the robot, and chooses a new direction when it is blocked.
|
||||||||
| MoveHunter | A4EC | CALL ToggleSprite | Move on to the next sprite using ToggleSprite. | |||||
| A4EF | CALL RemoveDistantEntity | Remove the enemy if it is far away from the camera using RemoveDistantEntity. | ||||||
| A4F2 | CALL GetPosition | Fetch the position of the enemy. | ||||||
| A4F5 | LD B,$40 | The enemy can take up to 40 steps in this frame. | ||||||
| MoveHunter_Step | A4F7 | CALL TryMove | Take a step using TryMove. | |||||
| A4FA | JR NZ,MoveHunter_Blocked | Jump if the enemy has been blocked by a cell. | ||||||
| A4FC | CALL CheckEnemyOverlap | Check whether another enemy is in the way using CheckEnemyOverlap. | ||||||
| A4FF | JR C,MoveHunter_Reverse | Jump if there is. | ||||||
| A501 | LD A,E | Jump if the enemy is not at the start of a cell. | ||||||
| A502 | OR L | |||||||
| A503 | JR NZ,MoveHunter_Store | |||||||
| A505 | CALL FindDirectionToRobot | Choose a direction towards the robot using FindDirectionToRobot... | ||||||
| A508 | LD (IX+$07),A | ...and store it. | ||||||
| A50B | LD A,B | Loop back to take another step if there are steps left. | ||||||
| A50C | AND A | |||||||
| A50D | JR NZ,MoveHunter_Step | |||||||
| MoveHunter_Store | A50F | CALL SetPosition | Store the new position of the enemy. | |||||
| A512 | CALL FaceEnemy | Face the enemy in the direction that it is heading using FaceEnemy. | ||||||
| A515 | JP AddEntity | Draw the enemy using AddEntity. | ||||||
| MoveHunter_Blocked | A518 | PUSH HL | Save the Y position. | |||||
| A519 | LD HL,($962E) | Fetch the address of the cell that blocked the enemy... | ||||||
| A51C | LD A,(HL) | ...and its type. | ||||||
| A51D | AND $0F | Keep the current type of the cell. | ||||||
| A51F | JR MoveHunter_Turn | Jump to choose a direction. | ||||||
|
This code is never run. It would have let the enemy pick up programs, like MoveThief.
|
||||||||
| MoveHunter_Unused | A521 | CP $06 | Jump to pick up the item if the cell is type 06... | |||||
| A523 | JR Z,MoveHunter_Unused_Pick | |||||||
| A525 | CP $07 | ...or type 07. | ||||||
| A527 | JR NZ,MoveHunter_Turn | |||||||
| MoveHunter_Unused_Pick | A529 | LD B,A | Keep the type. | |||||
| A52A | LD A,(IX+$08) | Fetch the item that the enemy is carrying. | ||||||
| A52D | AND A | Jump if it is carrying one already. | ||||||
| A52E | JR NZ,MoveHunter_Turn | |||||||
| A530 | LD (IX+$08),B | Store the item that it has picked up. | ||||||
| A533 | CALL EmptyCell | Remove it from the cell using EmptyCell. | ||||||
| A536 | POP HL | Restore the Y position. | ||||||
| A537 | JR MoveHunter_Store | Carry on. | ||||||
| MoveHunter_Turn | A539 | POP HL | Restore the Y position. | |||||
| A53A | CALL FindDirectionToRobot | Choose a direction towards the robot using FindDirectionToRobot... | ||||||
| A53D | LD (IX+$07),A | ...and store it. | ||||||
| A540 | JP AddEntity | Draw the enemy using AddEntity. | ||||||
|
The enemy is in the way of another enemy.
|
||||||||
| MoveHunter_Reverse | A543 | CALL ReverseDirection | Turn the enemy round using ReverseDirection. | |||||
| A546 | CALL FaceEnemy | Face the enemy in the direction that it is heading using FaceEnemy. | ||||||
| A549 | CALL AddEntity | Draw the enemy using AddEntity. | ||||||
| A54C | RET NC | Return if it was not drawn. | ||||||
| A54D | JP MakeBumpSound | Otherwise make a sound using MakeBumpSound. | ||||||
| Prev: A4DC | Up: Map | Next: A550 |