![]() |
Routines |
| Prev: 34695 | Up: Map | Next: 34861 |
|
The handler for the ghoul (sprite IDs 98 and 99). It is like HandlerPumpkin, but the weapon is checked before the player, and the direction at offset 6 is changed every eight steps. The velocities build up by one every other step towards 2 or -2. The movement itself is done by MoveCreature.
|
||||||||
| HandlerGhoul | 34726 | CALL StoreEntity | Call StoreEntity to save the position of the ghoul. | |||||
| 34729 | LD A,(60049) | Fetch the room of the player from PlayerRoom. | ||||||
| 34732 | CP (IX+1) | Jump to CountDownCreature if the ghoul is not in the same room as the player. | ||||||
| 34735 | JP NZ,CountDownCreature | |||||||
| 34738 | LD HL,24101 | Point HL at the number of creatures at NumCreatures. | ||||||
| 34741 | INC (HL) | Increment the number of creatures by one. | ||||||
| 34742 | CALL CheckWeaponHit | Call CheckWeaponHit to check whether the weapon has hit the entity. | ||||||
| 34745 | DEC E | Jump to PopCreature if the ghoul was hit by a weapon. | ||||||
| 34746 | JP Z,PopCreature | |||||||
| 34749 | CALL CheckPlayerTouch | Call CheckPlayerTouch to check whether the entity is touching the player. | ||||||
| 34752 | DEC E | Jump to HandleTouchingCreature if the ghoul touched the player. | ||||||
| 34753 | JP Z,HandleTouchingCreature | |||||||
| 34756 | LD DE,(24093) | Fetch the size of the room from CurrentRoom_Width. | ||||||
| 34760 | LD (IX+15),0 | Write 0 to offset 15 of the ghoul, so it is not removed. | ||||||
| 34764 | LD (IX+5),70 | Set the attribute of the entity to INK:YELLOW, PAPER:BLACK (BRIGHT). | ||||||
| 34768 | LD A,(IX+7) | Fetch the step counter from offset 7. | ||||||
| 34771 | AND %00000111 | Keep only bits 0-2. | ||||||
| 34773 | JR NZ,HandlerGhoul_Velocity | Jump to HandlerGhoul_Velocity if the result is not zero. | ||||||
| 34775 | LD A,R | Fetch a random number (from the refresh register). | ||||||
| 34777 | AND %00000011 | Keep only bits 0-1. | ||||||
| 34779 | LD (IX+6),A | Update the direction of the ghoul. | ||||||
| HandlerGhoul_Velocity | 34782 | BIT 0,(IX+7) | Jump to HandlerGhoul_Animate if bit 0 of the step counter is set. | |||||
| 34786 | JR NZ,HandlerGhoul_Animate | |||||||
| 34788 | BIT 0,(IX+6) | Jump to HandlerGhoul_SlowLeft if the ghoul is not heading right. | ||||||
| 34792 | JR Z,HandlerGhoul_SlowLeft | |||||||
| 34794 | LD A,(IX+8) | Fetch the X velocity of the ghoul. | ||||||
| 34797 | CP 2 | Jump to HandlerGhoul_VelocityY if it is already 2. | ||||||
| 34799 | JR Z,HandlerGhoul_VelocityY | |||||||
| 34801 | INC (IX+8) | Increment the X velocity by one. | ||||||
| HandlerGhoul_VelocityY | 34804 | BIT 1,(IX+6) | Jump to HandlerGhoul_SlowUp if the ghoul is not heading down. | |||||
| 34808 | JR Z,HandlerGhoul_SlowUp | |||||||
| 34810 | LD A,(IX+9) | Fetch the Y velocity of the ghoul. | ||||||
| 34813 | CP 2 | Jump to HandlerGhoul_Animate if it is already 2. | ||||||
| 34815 | JR Z,HandlerGhoul_Animate | |||||||
| 34817 | INC (IX+9) | Increment the Y velocity by one. | ||||||
|
Move on to the next step, and animate the ghoul by changing its sprite.
|
||||||||
| HandlerGhoul_Animate | 34820 | INC (IX+7) | Increment the step counter. | |||||
| 34823 | LD A,(IX+7) | Fetch the step counter. | ||||||
| 34826 | AND %00000001 | Keep only bit 0. | ||||||
| 34828 | XOR (IX+0) | Exclusive-or the sprite ID with A, which flips bit 0 of it on every other step. | ||||||
| 34831 | LD (IX+0),A | Write the new sprite ID back to the ghoul. | ||||||
| 34834 | JP MoveCreature | Jump to MoveCreature to move the creature. | ||||||
|
Speed up the X velocity towards -2 which is used when the ghoul is heading left.
|
||||||||
| HandlerGhoul_SlowLeft | 34837 | LD A,(IX+8) | Fetch the X velocity of the ghoul. | |||||
| 34840 | CP 254 | Jump to HandlerGhoul_VelocityY if it is already -2. | ||||||
| 34842 | JR Z,HandlerGhoul_VelocityY | |||||||
| 34844 | DEC (IX+8) | Decrease the X velocity by one. | ||||||
| 34847 | JR HandlerGhoul_VelocityY | Jump to HandlerGhoul_VelocityY to work out the vertical velocity of the ghoul. | ||||||
|
Speed up the Y velocity towards -2 which is used when the ghoul is heading up.
|
||||||||
| HandlerGhoul_SlowUp | 34849 | LD A,(IX+9) | Fetch the Y velocity of the ghoul. | |||||
| 34852 | CP 254 | Jump to HandlerGhoul_Animate if it is already -2. | ||||||
| 34854 | JR Z,HandlerGhoul_Animate | |||||||
| 34856 | DEC (IX+9) | Decrease the Y velocity by one. | ||||||
| 34859 | JR HandlerGhoul_Animate | Jump to HandlerGhoul_Animate to animate the ghoul. | ||||||
| Prev: 34695 | Up: Map | Next: 34861 |