Prev: CE84 Up: Map Next: CF30
CEE2: Update Entities
Used by the routines at RunFrame and RunGame.
Updates each of the entities that are not the player, or all of them if the player is not of type 01. An entity that is of type 0C or 10 is always kept. Any other entity is checked every eighth frame and is removed if it is a long way out of view. The entity is animated with AnimateEntity and then the routine for its type is run, using the table at EntityHandlers.
UpdateEntities CEE2 LD IX,$B566 Point IX at the entity after the player.
CEE6 LD B,$0B Set the number of entities to 0B leaving out the player.
CEE8 LD A,($B540) Fetch the type of the player.
CEEB DEC A Compare it with the player type, 01.
CEEC JR Z,UpdateEntities_Loop Jump to UpdateEntities_Loop if the player is still a player.
CEEE LD IX,$B540 Point IX at Entities.
CEF2 INC B Include the player in the count.
This entry point is used by the routine at UpdateNextEntity.
UpdateEntities_Loop CEF3 PUSH BC Save the entity count.
CEF4 LD A,(IX+$00) Fetch the type of the entity.
CEF7 AND A Test it.
CEF8 JR Z,UpdateNextEntity Jump to UpdateNextEntity if the entity is not in use.
CEFA PUSH AF Save the type.
CEFB CP $0C Jump to UpdateEntities_Animate if the entity is a disc.
CEFD JR Z,UpdateEntities_Animate
CEFF CP $10 Jump to UpdateEntities_Animate if the entity is a spider.
CF01 JR Z,UpdateEntities_Animate
CF03 LD A,($A2DD) Fetch the frame counter.
CF06 AND %00000111 Keep the low three bits.
CF08 JR NZ,UpdateEntities_Animate Jump to UpdateEntities_Animate unless this is every eighth frame.
CF0A LD BC,$0020 Set the margin to 20.
CF0D CALL TestEntityVisible Test whether the entity is within the view.
CF10 JR NZ,UpdateEntities_Animate Jump to UpdateEntities_Animate if it is within the view.
CF12 SET 7,(IX+$01) Hide the entity.
CF16 LD (IX+$00),$00 Remove the entity.
CF1A POP AF Restore the type.
CF1B JR UpdateNextEntity Jump to the next entity.
UpdateEntities_Animate CF1D CALL AnimateEntity Animate the entity.
CF20 POP AF Jump to the update routine for the type of the entity.
CF21 PUSH IX
CF23 ADD A,A
CF24 LD C,A
CF25 LD B,$00
CF27 LD HL,$993B
CF2A ADD HL,BC
CF2B LD A,(HL)
CF2C INC HL
CF2D LD H,(HL)
CF2E LD L,A
CF2F JP (HL)
Prev: CE84 Up: Map Next: CF30