Prev: 28882 Up: Map Next: 28985
28929: Display Entity
Used by the routines at HandlerExplosion, HandlerCar and PlaceObject.
Erases the sprite of an actor from where it was last drawn (the old state held in the actor buffer at Actor_Position_X) and draws it at its new position. Both sprites are handled a line at a time by MaskSprite, but if the old and the new Y positions are different then the lines of one sprite that stick out below the other are handled first.
Before After
display-entity-before display-entity-after
Input
IX Actor entity
DisplayEntity 28929 LD A,(24098) Fetch the sprite ID of the old sprite (Actor_SpriteID).
28932 AND A Jump to DrawEntity if there is no old sprite, as there is nothing to erase.
28933 JP Z,DrawEntity
28936 CALL PrepareActorSprite Call PrepareActorSprite to prepare the new sprite.
28939 EXX Switch to the shadow registers (to keep the new sprite).
28940 CALL PrepareOldSprite Call PrepareOldSprite to prepare the old sprite.
28943 LD A,(24097) A=Actor_Position_Y (the old Y position).
28946 SUB (IX+2) Subtract the new Y position.
28949 JP Z,ActorUpdateSize Jump to ActorUpdateSize if the old and new Y positions are the same.
28952 JP M,DisplayEntity_NewLower Jump to DisplayEntity_NewLower if the new sprite is lower down than the old sprite.
28955 LD C,A C=the number of lines that the old sprite sticks out below the new sprite.
28956 LD A,(24101) A=CurrentSpriteHeight (the number of lines in the old sprite).
28959 CP C Jump to ActorUpdateSize if the old sprite has fewer lines than this.
28960 JP C,ActorUpdateSize
28963 SUB C Subtract the lines that stick out.
28964 LD (24101),A Write the number of lines left to CurrentSpriteHeight.
28967 JP MaskSprite Jump to MaskSprite to erase the lines that stick out.
The new sprite is lower down, so it has some lines to draw before any lines are erased.
DisplayEntity_NewLower 28970 EXX Switch to the shadow registers (the new sprite).
28971 NEG Make the result positive.
28973 LD C,A C=the number of lines that the new sprite sticks out below the old sprite.
28974 LD A,(24102) A=HeightLines (the number of lines in the new sprite).
28977 CP C Jump to ActorUpdateSizeFlipReg if the new sprite has fewer lines than this.
28978 JP C,ActorUpdateSizeFlipReg
28981 SUB C Subtract the lines that stick out.
28982 JP ActorUpdateHeightAndMask Jump to ActorUpdateHeightAndMask to store the number of lines left and to draw the lines that stick out.
View the equivalent code in;
Prev: 28882 Up: Map Next: 28985