![]() |
Routines |
| Prev: 8A15 | Up: Map | Next: 8A80 |
|
The handler for the witch (sprite IDs 90 to 93). The counter at offset 0D is counted down from 10 and when it reaches zero the witch gets a new random velocity (see RandomiseVelocity) with the Y velocity halved. The sprite faces right when the X velocity is not negative, and the bottom bit of the counter animates it. The movement itself is done by MoveCreature.
|
||||||||
| HandlerWitch | 8A2F | CALL StoreEntity | Call StoreEntity to save the position of the witch. | |||||
| 8A32 | LD A,($EA91) | Fetch the room of the player from PlayerRoom. | ||||||
| 8A35 | CP (IX+$01) | Jump to CountDownCreature if the witch is not in the same room as the player. | ||||||
| 8A38 | JP NZ,CountDownCreature | |||||||
| 8A3B | LD HL,$5E25 | Point HL at the number of creatures at NumCreatures. | ||||||
| 8A3E | INC (HL) | Increment the number of creatures by one. | ||||||
| 8A3F | CALL CheckPlayerTouch | Call CheckPlayerTouch to check whether the entity is touching the player. | ||||||
| 8A42 | DEC E | Jump to HandleTouchingCreature if the witch touched the player. | ||||||
| 8A43 | JP Z,HandleTouchingCreature | |||||||
| 8A46 | CALL CheckWeaponHit | Call CheckWeaponHit to check whether the weapon has hit the entity. | ||||||
| 8A49 | DEC E | Jump to PopCreature if the witch was hit by a weapon. | ||||||
| 8A4A | JP Z,PopCreature | |||||||
| 8A4D | DEC (IX+$0D) | Decrease the counter at offset 0D by one. | ||||||
| 8A50 | JR NZ,HandlerWitch_SetSprite | Jump to HandlerWitch_SetSprite if it is not zero. | ||||||
| 8A52 | CALL RandomiseVelocity | Call RandomiseVelocity to give the creature a new random velocity. | ||||||
| 8A55 | SRA (IX+$09) | Halve the Y velocity, keeping its sign. | ||||||
| 8A59 | LD (IX+$0D),$10 | Set the counter to 10. | ||||||
|
Choose the sprite, which depends on the direction of travel and the counter.
|
||||||||
| HandlerWitch_SetSprite | 8A5D | LD A,(IX+$00) | Fetch the sprite ID of the witch. | |||||
| 8A60 | AND %11111100 | Keep only bits 2-7. | ||||||
| 8A62 | BIT 7,(IX+$08) | Jump to HandlerWitch_Animate if the X velocity is negative. | ||||||
| 8A66 | JR NZ,HandlerWitch_Animate | |||||||
| 8A68 | ADD A,$02 | Add 02 to use the sprites facing right. | ||||||
| HandlerWitch_Animate | 8A6A | LD C,A | Keep the base sprite ID in C. | |||||
| 8A6B | LD A,(IX+$0D) | Fetch the counter. | ||||||
| 8A6E | RRA | Halve the counter. | ||||||
| 8A6F | AND %00000001 | Keep only bit 0. | ||||||
| 8A71 | ADD A,C | Add the animation frame to the base sprite ID. | ||||||
| 8A72 | LD (IX+$00),A | Update the sprite ID of the witch. | ||||||
| 8A75 | LD DE,($5E1D) | Fetch the size of the room from CurrentRoom_Width. | ||||||
| 8A79 | LD (IX+$05),$43 | Set the attribute of the entity to INK:MAGENTA, PAPER:BLACK (BRIGHT). | ||||||
| 8A7D | JP MoveCreature | Jump to MoveCreature to move the creature. | ||||||
| Prev: 8A15 | Up: Map | Next: 8A80 |