![]() |
Routines |
| Prev: D1FD | Up: Map | Next: D2AD |
|
The handler of the object types A8 to AB, which are creatures that harm the player and wander about the room in the same way as RunWanderer. Bit 0 of the type is turned around each frame, to make the creature walk, and bit 1 is used to show which way it is going.
|
||||||||
|
Flip the walk frame, then move the creature.
|
||||||||
| RunFourFrameWanderer | D251 | CALL SetSpriteOffset_Minus16_Minus8 | Call SetSpriteOffset_Minus16_Minus8 to set the offsets of the sprite. | |||||
| D254 | CALL SetDeadlyFlags | Call SetDeadlyFlags to make the creature harm the player. | ||||||
| D257 | CALL ApplyGravityAndMove | Call ApplyGravityAndMove to apply gravity to the creature and move it. | ||||||
| D25A | LD A,(IX+$00) | Fetch the type of the creature. | ||||||
| D25D | XOR %00000001 | Turn bit 0 around. | ||||||
| D25F | LD (IX+$00),A | Set the type. | ||||||
| D262 | LD A,(IX+$03) | Jump to RunFourFrameWanderer_Test if the creature is at least 81 up. | ||||||
| D265 | CP $81 | |||||||
| D267 | JR NC,RunFourFrameWanderer_Test | |||||||
| D269 | LD (IX+$03),$81 | Put the creature at a height of 81. | ||||||
| D26D | LD (IX+$0B),$00 | Set the speed along z to zero. | ||||||
|
Pick a new direction when the creature is stopped.
|
||||||||
| RunFourFrameWanderer_Test | D271 | LD A,(IX+$09) | Jump to SetWipeAndDrawFlags to flag the creature as moved if it is moving. | |||||
| D274 | OR (IX+$0A) | |||||||
| D277 | JP NZ,SetWipeAndDrawFlags | |||||||
| D27A | LD A,R | Fetch a random number from the refresh register. | ||||||
| D27C | AND %00001000 | Keep bit 3. | ||||||
| D27E | SUB $04 | Make it FC or 04. | ||||||
| D280 | BIT 1,(IX+$0C) | Jump to RunFourFrameWanderer_AlongX if the creature was stopped along y. | ||||||
| D284 | JR NZ,RunFourFrameWanderer_AlongX | |||||||
| D286 | LD (IX+$0A),A | Set the speed along y. | ||||||
| D289 | SET 1,(IX+$00) | Set the bit of the type that goes with going forwards along y. | ||||||
| D28D | RES 6,(IX+$07) | Clear the flag for the sprite being mirrored. | ||||||
| D291 | JR RunFourFrameWanderer_Direction | Jump to RunFourFrameWanderer_Direction. | ||||||
| RunFourFrameWanderer_AlongX | D293 | LD (IX+$09),A | Set the speed along x. | |||||
| D296 | RES 1,(IX+$00) | Clear the bit of the type that goes with going forwards along x. | ||||||
| D29A | SET 6,(IX+$07) | Set the flag for the sprite being mirrored. | ||||||
| RunFourFrameWanderer_Direction | D29E | AND A | Jump to SetWipeAndDrawFlags to flag the creature as moved when it is going forwards. | |||||
| D29F | JP P,SetWipeAndDrawFlags | |||||||
| D2A2 | LD A,(IX+$00) | Fetch the type of the creature. | ||||||
| D2A5 | XOR %00000010 | Turn bit 1 of the type around, as the creature is going backwards. | ||||||
| D2A7 | LD (IX+$00),A | Set the type. | ||||||
| D2AA | JP SetWipeAndDrawFlags | Jump to SetWipeAndDrawFlags to flag the creature as moved. | ||||||
| Prev: D1FD | Up: Map | Next: D2AD |