Prev: 43046 Up: Map Next: 43153
43059: Move Dome
The handler for entity types 12 to 15, which are the domes. A dome is the slower of the two types of enemy that wander about at random; it can take up to 32 steps in a frame.
Input
IX Entity
MoveDome 43059 CALL NextSpriteNumber Move on to the next sprite using NextSpriteNumber.
43062 CALL RemoveDistantEntity Remove the entity if it is far from the camera using RemoveDistantEntity.
43065 CALL GetPosition Fetch the position of the entity.
43068 LD B,32 The dome can take up to 32 steps in this frame.
This entry point is used by the routine at MoveSaucer.
This entry point is shared by both kinds of enemy.
MoveEnemy_Step 43070 CALL TryMove Take a step using TryMove.
43073 JR NZ,MoveEnemy_Turn Jump if the enemy has been blocked.
43075 CALL CheckEnemyOverlap Check whether the enemy has run into another entity using CheckEnemyOverlap.
43078 JR C,MoveEnemy_Collide Jump if it has, to turn it round.
43080 LD A,E Jump if the enemy is not at the start of a cell.
43081 OR L
43082 JR NZ,MoveEnemy_Store
43084 LD A,(IX+7) Fetch the time and direction of the enemy...
43087 SUB 16 ...take away one cell...
43089 LD (IX+7),A ...and store it.
43092 AND 240 Jump to choose a new direction if the time has run out.
43094 JR Z,MoveEnemy_Turn
43096 LD A,B Loop back to take another step if there are steps left.
43097 AND A
43098 JR NZ,MoveEnemy_Step
MoveEnemy_Store 43100 CALL SetPosition Store the position of the enemy using SetPosition.
43103 JP AddEntity Jump to AddEntity.
MoveEnemy_Turn 43106 LD A,(IX+7) Fetch the time and direction of the enemy...
43109 AND 15 ...keep the direction only...
43111 LD (IX+7),A ...and store it.
43114 LD A,(38421) Fetch the frame counter...
43117 AND 3 ...and use it as a random direction.
43119 CP (IX+7) Compare it with the current direction.
43122 JR NZ,MoveDome_NewDirection Jump if they are different.
43124 INC A Otherwise turn a quarter of a turn.
43125 AND 3 Keep the direction within four.
MoveDome_NewDirection 43127 LD C,A Keep the new direction.
43128 LD A,(38423) Fetch the random number...
43131 AND 240 ...and use the upper bits as the time to keep going in this direction.
43133 JR NZ,MoveDome_SetTime
43135 OR 16 Use a time of one cell if that is zero.
MoveDome_SetTime 43137 OR C Combine the time with the new direction...
43138 LD (IX+7),A ...and store them.
43141 JR MoveEnemy_Store Jump back to store the position.
MoveEnemy_Collide 43143 CALL ReverseDirection Turn the enemy round using ReverseDirection.
43146 CALL AddEntity Draw it using AddEntity.
43149 RET NC Return if it is off the screen.
43150 JP MakeBumpSound Make the sound of a bump using MakeBumpSound.
Prev: 43046 Up: Map Next: 43153