![]() |
Routines |
| Prev: 8ADB | Up: Map | Next: 8B6A |
|
The handler for the hunchback (sprite IDs 9C to 9F). If he touches the player then TakeEnergyFromPlayer takes some energy. The velocities are set by SteerCreature, as the hunchback goes for the first item that is in his room (see FindItemInRoom). When he reaches it the item is removed. If there is nothing to go for he stays still, and if the player is not a character then he heads for a position in the room. The movement itself is done by MoveCreature.
|
||||||||
| HandlerHunchback | 8AFF | CALL StoreEntity | Call StoreEntity to save the position of the hunchback. | |||||
| 8B02 | CALL CheckPlayerTouch | Call CheckPlayerTouch to check whether the entity is touching the player. | ||||||
| 8B05 | DEC E | Call TakeEnergyFromPlayer if the hunchback touched the player. | ||||||
| 8B06 | CALL Z,TakeEnergyFromPlayer | |||||||
| 8B09 | XOR A | A=00 (no velocity). | ||||||
| 8B0A | LD (IX+$09),A | Set the Y velocity to zero. | ||||||
| 8B0D | LD (IX+$08),A | Set the X velocity to zero. | ||||||
| 8B10 | CALL FindItemInRoom | Call FindItemInRoom to look for an item. | ||||||
| 8B13 | DEC C | Jump to HandlerHunchback_Move if there is no item. | ||||||
| 8B14 | JP NZ,HandlerHunchback_Move | |||||||
| 8B17 | CALL SteerCreature | Call SteerCreature to head for the item. | ||||||
| 8B1A | LD A,C | Fetch which of the axes have been reached. | ||||||
| 8B1B | CP $03 | Jump to HandlerHunchback_SetSprite if the hunchback has not arrived. | ||||||
| 8B1D | JR NZ,HandlerHunchback_SetSprite | |||||||
|
The hunchback is at the item, so remove it.
|
||||||||
| 8B1F | CALL FindItemInRoom | Call FindItemInRoom to find the item again. | ||||||
| 8B22 | LD DE,$0004 | DE=0004 (the offset of the Y position within a record). | ||||||
| 8B25 | AND A | Reset the carry flag. | ||||||
| 8B26 | SBC HL,DE | Subtract DE from HL to get the address of the item. | ||||||
| 8B28 | PUSH IX | Stash the hunchback on the stack. | ||||||
| 8B2A | LD IX,$0000 | Make IX point at the item (copy HL to IX). | ||||||
| 8B2E | EX DE,HL | |||||||
| 8B2F | ADD IX,DE | |||||||
| 8B31 | LD A,($EA91) | Fetch the room of the player from PlayerRoom. | ||||||
| 8B34 | CP (IX+$01) | Compare it with the room of the item. | ||||||
| 8B37 | JR NZ,HandlerHunchback_Remove | Jump to HandlerHunchback_Remove if they are different. | ||||||
| 8B39 | CALL DrawEntity | Call DrawEntity to draw the item. | ||||||
| HandlerHunchback_Remove | 8B3C | LD (IX+$00),$00 | Write 00 to the sprite ID of the item. | |||||
| 8B40 | POP IX | Restore the hunchback from the stack. | ||||||
| 8B42 | JP HandlerHunchback_Move | Jump to HandlerHunchback_Move to move the hunchback. | ||||||
|
The hunchback is on the way, so choose the sprite.
|
||||||||
| HandlerHunchback_SetSprite | 8B45 | LD A,(IX+$00) | Fetch the sprite ID of the hunchback. | |||||
| 8B48 | AND %11111100 | Keep only bits 2-7. | ||||||
| 8B4A | LD C,A | Keep the base sprite ID in C. | ||||||
| 8B4B | LD A,($5E12) | Fetch the counter from CounterLow. | ||||||
| 8B4E | RRA | Divide the counter by four. | ||||||
| 8B4F | RRA | |||||||
| 8B50 | AND %00000011 | Keep only bits 0-1. | ||||||
| 8B52 | ADD A,C | Add the animation frame to the base sprite ID. | ||||||
| 8B53 | LD (IX+$00),A | Update the sprite ID of the hunchback. | ||||||
| 8B56 | LD DE,$3C3C | DE=3C3C (the area). | ||||||
|
If the player is a character then the hunchback moves, otherwise he heads for a position in the room.
|
||||||||
| HandlerHunchback_Move | 8B59 | LD A,($EA90) | Fetch the sprite ID of the player from Player. | |||||
| 8B5C | CP $31 | Jump to MoveCreature if the player is a character. | ||||||
| 8B5E | JP C,MoveCreature | |||||||
| 8B61 | LD DE,$3A58 | DE=3A58 (the target position). | ||||||
| 8B64 | CALL SteerCreature | Call SteerCreature to steer the creature towards its target. | ||||||
| 8B67 | JP MoveCreature | Jump to MoveCreature to move the creature. | ||||||
| Prev: 8ADB | Up: Map | Next: 8B6A |