Prev: 38603 Up: Map Next: 38681
38647: 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 38647 CALL PrepDraw2 Prepare the registers for the sprite at its new position.
38650 EXX Switch to the registers of the old sprite.
38651 CALL PrepDraw23 Prepare the registers for the sprite at its old position.
38654 LD A,(36581) Fetch the old y position from Previous_Y_Position.
38657 SUB (IX+3) Subtract the new y position of the object.
38660 JP Z,XORSpriteLoop_Reload Jump to XORSpriteLoop_Reload if the y position has not changed.
38663 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.
38666 LD C,A Copy the number of rows that stand alone to C.
38667 LD A,(36578) Fetch the number of rows of the old sprite from Old_Sprite_Row_Count.
38670 CP C Compare it with the number of rows that stand alone.
38671 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.
38674 SUB C Subtract the number of rows that stand alone.
38675 LD (36578),A Store the number of rows that remain.
38678 JP XORSpriteLoop Jump to XORSpriteLoop to draw those rows of the old sprite on their own.
View the equivalent code in;
Prev: 38603 Up: Map Next: 38681