Prev: 96CB Up: Map Next: 9719
96F7: Display Entity
Used by the routine at Update_Object_Sprite.
Erases the sprite at its old position and draws it at the new one.
Both sprites are drawn with XOR, a row at a time, so that the rows are alternated between the two sprites and the screen is never without the sprite for long. If the sprites are offset vertically, the rows of the sprite that has no matching row in the other one are drawn first.
Before After DisplayEntity
display-entity-before display-entity-after
Input
IX Object record
DisplayEntity 96F7 CALL PrepDraw2 Prepare the registers for the sprite at its new position.
96FA EXX Switch to the registers of the old sprite.
96FB CALL PrepDraw23 Prepare the registers for the sprite at its old position.
96FE LD A,($8EE5) Fetch the old y position from Previous_Y_Position.
9701 SUB (IX+$03) Subtract the new y position of the object.
9704 JP Z,XORSpriteLoop_Reload Jump to XORSpriteLoop_Reload if the y position has not changed.
9707 JP M,DisplayEntity_NewLower Jump to DisplayEntity_NewLower if the sprite has moved down the screen.
The old sprite is lower than the new one, so draw the bottom rows of the old sprite on their own first.
970A LD C,A Copy the number of rows that stand alone to C.
970B LD A,($8EE2) Fetch the number of rows of the old sprite from Old_Sprite_Row_Count.
970E CP C Compare it with the number of rows that stand alone.
970F JP C,XORSpriteLoop_Reload Jump to XORSpriteLoop_Reload if the old sprite has no more rows than that, so that the sprites do not overlap and are each drawn in full.
9712 SUB C Subtract the number of rows that stand alone.
9713 LD ($8EE2),A Store the number of rows that remain.
9716 JP XORSpriteLoop Jump to XORSpriteLoop to draw those rows of the old sprite on their own.
View the equivalent code in;
Prev: 96CB Up: Map Next: 9719