![]() |
Routines |
| Prev: 83EA | Up: Map | Next: 84CD |
|
The handler for the pumpkin (sprite IDs 4C and 4D) and the spider (5C and 5D). If the player is in another room then CountDownCreature counts the creature down until it is removed. Otherwise the creature is counted and checked for being hit by a weapon (CheckWeaponHit) or touching the player (CheckPlayerTouch). Offset 06 of the creature holds the direction it is heading in (bit 0 is set for right and bit 1 is set for down). A new direction is chosen at random every sixteen steps, and the velocities at offsets 08 and 09 build up by one every other step towards 02 or -02. The movement itself is done by MoveCreature.
|
||||||||
| HandlerPumpkin | 845F | CALL StoreEntity | Call StoreEntity to save the position of the creature. | |||||
| 8462 | LD A,($EA91) | Fetch the room of the player from PlayerRoom. | ||||||
| 8465 | CP (IX+$01) | Jump to CountDownCreature if the creature is not in the same room as the player. | ||||||
| 8468 | JP NZ,CountDownCreature | |||||||
| 846B | LD HL,$5E25 | Point HL at the number of creatures at NumCreatures. | ||||||
| 846E | INC (HL) | Increment the number of creatures by one. | ||||||
|
Check whether the creature has been hit by a weapon or touched the player.
|
||||||||
| 846F | CALL CheckWeaponHit | Call CheckWeaponHit to check whether the weapon has hit the entity. | ||||||
| 8472 | DEC E | Jump to PopCreature if the creature was hit by a weapon. | ||||||
| 8473 | JP Z,PopCreature | |||||||
| 8476 | CALL CheckPlayerTouch | Call CheckPlayerTouch to check whether the entity is touching the player. | ||||||
| 8479 | DEC E | Jump to HandleTouchingCreature if the creature touched the player. | ||||||
| 847A | JP Z,HandleTouchingCreature | |||||||
| 847D | LD DE,($5E1D) | Fetch the size of the room from CurrentRoom_Width. | ||||||
| 8481 | LD (IX+$0F),$00 | Write 00 to offset 0F of the creature, so it is not removed. | ||||||
| 8485 | LD (IX+$05),$46 | Set the attribute of the entity to INK:YELLOW, PAPER:BLACK (BRIGHT). | ||||||
|
Choose a new direction every sixteen steps.
|
||||||||
| 8489 | LD A,(IX+$07) | Fetch the step counter of the creature. | ||||||
| 848C | AND %00001111 | Keep only bits 0-3. | ||||||
| 848E | JR NZ,HandlerPumpkin_Velocity | Jump to HandlerPumpkin_Velocity if the result is not zero. | ||||||
| 8490 | LD A,R | Fetch a random number (from the refresh register). | ||||||
| 8492 | AND %00000011 | Keep only bits 0-1. | ||||||
| 8494 | LD (IX+$06),A | Update the direction of the creature. | ||||||
|
Only change the velocities on every other step.
|
||||||||
| HandlerPumpkin_Velocity | 8497 | BIT 0,(IX+$07) | Jump to HandlerPumpkin_Animate if bit 0 of the step counter is set. | |||||
| 849B | JR NZ,HandlerPumpkin_Animate | |||||||
| 849D | BIT 0,(IX+$06) | Jump to MoveCreature_SlowLeft if the creature is not heading right. | ||||||
| 84A1 | JP Z,MoveCreature_SlowLeft | |||||||
| 84A4 | LD A,(IX+$08) | Fetch the X velocity of the creature. | ||||||
| 84A7 | CP $02 | Jump to HandlerPumpkin_VelocityY if it is already 02. | ||||||
| 84A9 | JR Z,HandlerPumpkin_VelocityY | |||||||
| 84AB | INC (IX+$08) | Increment the X velocity by one. | ||||||
|
This entry point is used by the routine at MoveCreature.
|
||||||||
| HandlerPumpkin_VelocityY | 84AE | BIT 1,(IX+$06) | Jump to MoveCreature_SlowUp if the creature is not heading down. | |||||
| 84B2 | JP Z,MoveCreature_SlowUp | |||||||
| 84B5 | LD A,(IX+$09) | Fetch the Y velocity of the creature. | ||||||
| 84B8 | CP $02 | Jump to HandlerPumpkin_Animate if it is already 02. | ||||||
| 84BA | JR Z,HandlerPumpkin_Animate | |||||||
| 84BC | INC (IX+$09) | Increment the Y velocity by one. | ||||||
|
This entry point is used by the routine at MoveCreature.
Move on to the next step, and animate the creature by changing its sprite.
|
||||||||
| HandlerPumpkin_Animate | 84BF | INC (IX+$07) | Increment the step counter of the creature. | |||||
| 84C2 | LD A,(IX+$07) | Fetch the step counter of the creature. | ||||||
| 84C5 | AND %00000001 | Keep only bit 0. | ||||||
| 84C7 | XOR (IX+$00) | Exclusive-or the sprite ID with A, which flips bit 0 of it on every other step. | ||||||
| 84CA | LD (IX+$00),A | Write the new sprite ID back to the creature. | ||||||
| Prev: 83EA | Up: Map | Next: 84CD |