![]() |
Routines |
| Prev: 34350 | Up: Map | Next: 34546 |
|
The handler for the spikey (sprite IDs 94 and 95) and the ghost (104 and 105). The counter at offset 10 runs from -7 up to 6 and half of it is added to the Y position, which makes the creature bob up and down as it moves. A new random velocity is chosen every time that the counter wraps round. The movement itself is done by MoveCreature.
|
||||||||
| HandlerSpikey | 34418 | CALL StoreEntity | Call StoreEntity to save the position of the creature. | |||||
| 34421 | LD A,(60049) | Fetch the room of the player from PlayerRoom. | ||||||
| 34424 | CP (IX+1) | Jump to CountDownCreature if the creature is not in the same room as the player. | ||||||
| 34427 | JP NZ,CountDownCreature | |||||||
| 34430 | LD HL,24101 | Point HL at the number of creatures at NumCreatures. | ||||||
| 34433 | INC (HL) | Increment the number of creatures by one. | ||||||
| 34434 | LD (IX+15),0 | Write 0 to offset 15 of the creature, so it is not removed. | ||||||
| 34438 | CALL CheckPlayerTouch | Call CheckPlayerTouch to check whether the entity is touching the player. | ||||||
| 34441 | DEC E | Jump to HandleTouchingCreature if the creature touched the player. | ||||||
| 34442 | JP Z,HandleTouchingCreature | |||||||
| 34445 | CALL CheckWeaponHit | Call CheckWeaponHit to check whether the weapon has hit the entity. | ||||||
| 34448 | DEC E | Jump to PopCreature if the creature was hit by a weapon. | ||||||
| 34449 | JP Z,PopCreature | |||||||
|
Animate the creature by changing the sprite every other step.
|
||||||||
| 34452 | LD A,(IX+10) | Fetch the bobbing counter from offset 10. | ||||||
| 34455 | RRA | Halve the bobbing counter. | ||||||
| 34456 | AND %00000001 | Keep only bit 0. | ||||||
| 34458 | LD C,A | Keep the animation frame in C. | ||||||
| 34459 | LD A,(IX+0) | Fetch the sprite ID of the creature. | ||||||
| 34462 | AND %11111110 | Reset bit 0. | ||||||
| 34464 | ADD A,C | Add the animation frame to the sprite ID. | ||||||
| 34465 | LD (IX+0),A | Update the sprite ID of the creature. | ||||||
| 34468 | LD DE,(24093) | Fetch the size of the room from CurrentRoom_Width. | ||||||
|
Move on to the next step of the bobbing. A new velocity is chosen when the counter reaches 7.
|
||||||||
| 34472 | INC (IX+10) | Increment the bobbing counter. | ||||||
| 34475 | LD A,(IX+10) | Fetch the bobbing counter. | ||||||
| 34478 | CP 7 | Jump to HandlerSpikey_Bob unless it has reached 7. | ||||||
| 34480 | JR NZ,HandlerSpikey_Bob | |||||||
| 34482 | CALL RandomiseVelocity | Call RandomiseVelocity to give the creature a new random velocity. | ||||||
| 34485 | LD (IX+10),249 | Set the bobbing counter to -7. | ||||||
|
Add half of the counter to the Y position of the creature and keep it inside the room.
|
||||||||
| HandlerSpikey_Bob | 34489 | SRA A | Halve the counter, keeping its sign. | |||||
| 34491 | ADD A,(IX+4) | Add the Y position of the creature. | ||||||
| 34494 | LD C,A | Keep the new Y position in C. | ||||||
| 34495 | SUB 104 | Subtract 104 (the vertical centre of the room). | ||||||
| 34497 | JP P,HandlerSpikey_CheckBottom | Jump to HandlerSpikey_CheckBottom if the new position is below the centre. | ||||||
| 34500 | NEG | Make the distance from the centre positive. | ||||||
| 34502 | CP D | Jump to HandlerSpikey_Store if the new position is still inside the room. | ||||||
| 34503 | JR C,HandlerSpikey_Store | |||||||
| 34505 | LD (IX+9),2 | Set the Y velocity of the creature to 2. | ||||||
| 34509 | SET 1,(IX+6) | Set bit 1 of the direction of the creature, so it is heading down. | ||||||
| 34513 | BIT 7,(IX+10) | Jump to HandlerSpikey_Store if the bobbing counter is positive. | ||||||
| 34517 | JR Z,HandlerSpikey_Store | |||||||
| 34519 | LD (IX+10),0 | Reset the bobbing counter to 0. | ||||||
| HandlerSpikey_Store | 34523 | LD (IX+4),C | Update the Y position of the creature. | |||||
| 34526 | JP MoveCreature | Jump to MoveCreature to move the creature. | ||||||
| HandlerSpikey_CheckBottom | 34529 | CP D | Jump to HandlerSpikey_Store if the new position is still inside the room. | |||||
| 34530 | JR C,HandlerSpikey_Store | |||||||
| 34532 | RES 1,(IX+6) | Reset bit 1 of the direction of the creature, so it is heading up. | ||||||
| 34536 | LD (IX+9),254 | Set the Y velocity of the creature to -2. | ||||||
| 34540 | LD (IX+10),249 | Set the bobbing counter to -7. | ||||||
| 34544 | JR HandlerSpikey_Store | Jump to HandlerSpikey_Store to store the Y position of the creature. | ||||||
| Prev: 34350 | Up: Map | Next: 34546 |