![]() |
Routines |
| Prev: 53749 | Up: Map | Next: 53841 |
|
The handler of the object types 80 and 81, which are creatures that harm the player and wander about the room. A creature stays just above the floor, and walks along one axis at a time, at a speed of four. When it has no speed, because something has stopped it, it picks a new direction at random: along x if it was stopped along y, and along y if it was not. The lowest bit of its type and the flag for the sprite being mirrored are set to show which of the four ways it is going, to give the right picture.
|
||||||||
|
Move the creature and keep it just above the floor.
|
||||||||
| RunWanderer | 53757 | CALL SetSpriteOffset_Minus16_Minus8 | Call SetSpriteOffset_Minus16_Minus8 to set the offsets of the sprite. | |||||
| 53760 | CALL SetDeadlyFlags | Call SetDeadlyFlags to make the creature harm the player. | ||||||
| 53763 | CALL ApplyGravityAndMove | Call ApplyGravityAndMove to apply gravity to the creature and move it. | ||||||
| 53766 | LD A,(IX+3) | Jump to RunWanderer_Test if the creature is at least 129 up. | ||||||
| 53769 | CP 129 | |||||||
| 53771 | JR NC,RunWanderer_Test | |||||||
| 53773 | LD (IX+3),129 | Put the creature at a height of 129. | ||||||
| 53777 | LD (IX+11),0 | Set the speed along z to zero. | ||||||
|
Pick a new direction when the creature is stopped.
|
||||||||
| RunWanderer_Test | 53781 | LD A,(IX+9) | Jump to SetWipeAndDrawFlags to flag the creature as moved if it is moving. | |||||
| 53784 | OR (IX+10) | |||||||
| 53787 | JP NZ,SetWipeAndDrawFlags | |||||||
| 53790 | LD A,R | Fetch a random number from the refresh register. | ||||||
| 53792 | AND %00001000 | Keep bit 3. | ||||||
| 53794 | SUB 4 | Make it 252 or 4. | ||||||
| 53796 | BIT 1,(IX+12) | Jump to RunWanderer_AlongX if the creature was stopped along y. | ||||||
| 53800 | JR NZ,RunWanderer_AlongX | |||||||
| 53802 | LD (IX+10),A | Set the speed along y. | ||||||
| 53805 | SET 0,(IX+0) | Set the bit of the type that goes with going forwards along y. | ||||||
| 53809 | RES 6,(IX+7) | Clear the flag for the sprite being mirrored. | ||||||
| 53813 | JR RunWanderer_Direction | Jump to RunWanderer_Direction. | ||||||
| RunWanderer_AlongX | 53815 | LD (IX+9),A | Set the speed along x. | |||||
| 53818 | RES 0,(IX+0) | Clear the bit of the type that goes with going forwards along x. | ||||||
| 53822 | SET 6,(IX+7) | Set the flag for the sprite being mirrored. | ||||||
| RunWanderer_Direction | 53826 | AND A | Jump to SetWipeAndDrawFlags to flag the creature as moved when it is going forwards. | |||||
| 53827 | JP P,SetWipeAndDrawFlags | |||||||
| 53830 | LD A,(IX+0) | Fetch the type of the creature. | ||||||
| 53833 | XOR %00000001 | Turn the bit of the type around, as the creature is going backwards. | ||||||
| 53835 | LD (IX+0),A | Set the type. | ||||||
| 53838 | JP SetWipeAndDrawFlags | Jump to SetWipeAndDrawFlags to flag the creature as moved. | ||||||
| Prev: 53749 | Up: Map | Next: 53841 |