Prev: B969 Up: Map Next: B9CB
B9A9: Display Entity
Used by the routines at HandlerOrchid, DisplayActor and GamePlay_Start.
Moves an entity on the screen, by erasing the sprite at its old position (saved by StoreEntity) and drawing it at its 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 and ColourEntity
display-entity-before display-entity-after
Input
IX Actor record
DisplayEntity B9A9 CALL PrepDraw2 Prepare the registers for the sprite at its new position.
B9AC EXX Switch to the registers of the old sprite.
B9AD CALL PrepDraw23 Prepare the registers for the sprite at its old position.
B9B0 LD A,($96A1) Fetch the old Y position from Previous_Y_Position.
B9B3 SUB (IX+$04) Subtract the new Y position of the entity.
B9B6 JP Z,XORSpriteLoop_Reload Jump to XORSpriteLoop_Reload if the Y position has not changed.
B9B9 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.
B9BC LD C,A Copy the number of rows that stand alone to C.
B9BD LD A,($96A3) Fetch the number of rows of the old sprite from Old_Sprite_Row_Count.
B9C0 CP C Compare it with the number of rows that stand alone.
B9C1 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.
B9C4 SUB C Subtract the number of rows that stand alone.
B9C5 LD ($96A3),A Write the number of rows that remain to Old_Sprite_Row_Count.
B9C8 JP XORSpriteLoop Jump to XORSpriteLoop to draw those rows of the old sprite on their own.
View the equivalent code in;
Prev: B969 Up: Map Next: B9CB