Prev: 86F2 Up: Map Next: 875F
871A: Handle Blob
The handler for the blob (sprite IDs 60 and 61). A new random velocity is chosen every 11 steps, by counting down the counter at offset 0D. The movement itself is done by MoveCreature.
Input
IX The blob entity
HandlerBlob 871A CALL StoreEntity Call StoreEntity to save the position of the blob.
871D LD A,($EA91) Fetch the room of the player from PlayerRoom.
8720 CP (IX+$01) Jump to CountDownCreature if the blob is not in the same room as the player.
8723 JP NZ,CountDownCreature
8726 LD HL,$5E25 Point HL at the number of creatures at NumCreatures.
8729 INC (HL) Increment the number of creatures by one.
872A LD (IX+$0F),$00 Write 00 to offset 0F of the blob, so it is not removed.
872E CALL CheckPlayerTouch Call CheckPlayerTouch to check whether the entity is touching the player.
8731 DEC E Jump to HandleTouchingCreature if the blob touched the player.
8732 JP Z,HandleTouchingCreature
8735 CALL CheckWeaponHit Call CheckWeaponHit to check whether the weapon has hit the entity.
8738 DEC E Jump to PopCreature if the blob was hit by a weapon.
8739 JP Z,PopCreature
873C LD DE,($5E1D) Fetch the size of the room from CurrentRoom_Width.
8740 DEC (IX+$0D) Decrease the counter at offset 0D by one.
8743 JR NZ,HandlerBlob_Animate Jump to HandlerBlob_Animate if it is not zero.
8745 LD (IX+$0D),$11 Set the counter to 11.
8749 CALL RandomiseVelocity Call RandomiseVelocity to give the creature a new random velocity.
Animate the blob by changing the sprite every other step.
HandlerBlob_Animate 874C LD A,(IX+$0D) Fetch the counter.
874F RRA Halve the counter.
8750 AND %00000001 Keep only bit 0.
8752 LD C,A Keep the animation frame in C.
8753 LD A,(IX+$00) Fetch the sprite ID of the blob.
8756 AND %11111110 Reset bit 0.
8758 ADD A,C Add the animation frame to the sprite ID.
8759 LD (IX+$00),A Update the sprite ID of the blob.
875C JP MoveCreature Jump to MoveCreature to move the creature.
Prev: 86F2 Up: Map Next: 875F