![]() |
Routines |
| Prev: 41491 | Up: Map | Next: 41602 |
|
The handler for entity types 80 to 83, the enemies that go after the programs. The enemy heads for the robot, and picks up any program (map cell type 6) that is in the way. If the enemy is shot then it drops the program.
|
||||||||
| MoveThief | 41496 | CALL NextSpriteNumber | Move on to the next sprite using NextSpriteNumber. | |||||
| 41499 | CALL RemoveDistantEntity | Remove the enemy if it is far away from the camera using RemoveDistantEntity. | ||||||
| 41502 | CALL GetPosition | Fetch the position of the enemy. | ||||||
| 41505 | LD B,64 | The enemy can take up to 64 steps in this frame. | ||||||
| MoveThief_Step | 41507 | CALL TryMove | Take a step using TryMove. | |||||
| 41510 | JR NZ,MoveThief_Blocked | Jump if the enemy has been blocked by a cell. | ||||||
| 41512 | CALL CheckEnemyOverlap | Check whether another enemy is in the way using CheckEnemyOverlap. | ||||||
| 41515 | JR C,MoveThief_Reverse | Jump if there is. | ||||||
| 41517 | LD A,E | Jump if the enemy is not at the start of a cell. | ||||||
| 41518 | OR L | |||||||
| 41519 | JR NZ,MoveThief_Store | |||||||
| 41521 | CALL FindDirectionToRobot | Choose a new direction using FindDirectionToRobot... | ||||||
| 41524 | LD (IX+7),A | ...and store it. | ||||||
| 41527 | LD A,B | Loop back to take another step if there are steps left. | ||||||
| 41528 | AND A | |||||||
| 41529 | JR NZ,MoveThief_Step | |||||||
| MoveThief_Store | 41531 | CALL SetPosition | Store the new position of the enemy. | |||||
| 41534 | JP AddEntity | Draw the enemy using AddEntity. | ||||||
|
The enemy has been blocked by a cell.
|
||||||||
| MoveThief_Blocked | 41537 | PUSH HL | Save the Y position. | |||||
| 41538 | LD HL,(38446) | Fetch the address of the cell that blocked the enemy... | ||||||
| 41541 | LD A,(HL) | ...and its type. | ||||||
| 41542 | AND 15 | Jump unless it is a program (type 6). | ||||||
| 41544 | CP 6 | |||||||
| 41546 | JR NZ,MoveThief_Skip | |||||||
| 41548 | LD B,A | Keep the type. | ||||||
| 41549 | LD A,(IX+8) | Fetch the item that the enemy is carrying. | ||||||
| 41552 | AND A | Jump if it is carrying one already. | ||||||
| 41553 | JR NZ,MoveThief_Skip | |||||||
| 41555 | CALL EmptyCell | Remove the program from the cell using EmptyCell... | ||||||
| 41558 | POP HL | ...after restoring the Y position... | ||||||
| 41559 | JR MoveThief_Store | ...and carry on. (The enemy has picked up the program, and takes it away.) | ||||||
| MoveThief_Skip | 41561 | POP HL | Restore the Y position. | |||||
| 41562 | LD A,(38421) | Fetch the frame counter. | ||||||
| 41565 | AND 1 | Test the lowest bit of the frame counter, and jump on every other frame to choose a direction towards the robot. | ||||||
| 41567 | JR Z,MoveThief_Towards | |||||||
| 41569 | LD A,(38423) | Otherwise fetch the random number... | ||||||
| 41572 | AND 3 | ...limited to 0-3... | ||||||
| 41574 | CP (IX+7) | ...and jump unless it is the direction that the enemy is already heading in. | ||||||
| 41577 | JR NZ,MoveThief_Direction | |||||||
| 41579 | INC A | Otherwise use the next direction. | ||||||
| 41580 | AND 3 | |||||||
| MoveThief_Direction | 41582 | LD (IX+7),A | Store the new direction. | |||||
| 41585 | JR MoveThief_Store | Carry on. | ||||||
| MoveThief_Towards | 41587 | CALL FindDirectionToRobot | Choose a direction towards the robot using FindDirectionToRobot. | |||||
| 41590 | JR MoveThief_Direction | Carry on. | ||||||
|
The enemy is in the way of another enemy.
|
||||||||
| MoveThief_Reverse | 41592 | CALL ReverseDirection | Turn the enemy round using ReverseDirection. | |||||
| 41595 | CALL AddEntity | Draw the enemy using AddEntity. | ||||||
| 41598 | RET NC | Return if it was not drawn. | ||||||
| 41599 | JP MakeBumpSound | Otherwise make a sound using MakeBumpSound. | ||||||
| Prev: 41491 | Up: Map | Next: 41602 |