Prev: 40863 Up: Map Next: 40955
40906: Display Entity
Used by the routine at HandlerKnight.
Erases the sprite from the position recorded by StoreEntity and draws it at the new position held by the entity. The old and the new sprite are processed together so that the screen lines which they share are updated in step.
Input
IX The entity
DisplayEntity 40906 CALL PrepDraw2 Prepare the new sprite with PrepDraw2.
40909 EXX Switch to the shadow registers.
40910 CALL PrepDraw23 Prepare the old sprite with PrepDraw23.
Compare the vertical position of the old sprite with the new one.
DisplayEntity_Compare 40913 LD A,(24087) Fetch the previous Y position from Previous_Y_Position.
40916 SUB (IX+4) Subtract the new vertical position.
40919 JP Z,XORSpriteLoop_Remaining Jump to XORSpriteLoop_Remaining if they are the same.
40922 JP M,DisplayEntity_NewLower Jump to DisplayEntity_NewLower if the new sprite is lower down the screen.
The old sprite is lower down. Draw the rows of it which the new sprite does not cover first.
40925 LD C,A Fetch the number of rows.
40926 LD A,(24088) Fetch the number of old sprite rows from Old_Sprite_Row_Count.
40929 CP C Jump to XORSpriteLoop_Remaining if the sprites do not overlap.
40930 JP C,XORSpriteLoop_Remaining
40933 SUB C Subtract the rows which are about to be drawn.
40934 LD (24088),A Write the number of rows remaining to Old_Sprite_Row_Count.
40937 JP XORSpriteLoop Jump to XORSpriteLoop to draw the sprites onto the screen.
The new sprite is lower down. Draw the rows of it which the old sprite does not cover first.
DisplayEntity_NewLower 40940 EXX Switch to the shadow registers.
40941 NEG Make the number of rows positive.
40943 LD C,A Fetch the number of rows.
40944 LD A,(24089) Fetch the number of new sprite rows from New_Sprite_Row_Count.
40947 CP C Jump to XORSpriteLoop_Restore if the sprites do not overlap.
40948 JP C,XORSpriteLoop_Restore
40951 SUB C Subtract the rows which are about to be drawn.
40952 JP XORSpriteLoop_Continue Jump to XORSpriteLoop_Continue to write the number of rows remaining to New_Sprite_Row_Count.
View the equivalent code in;
Prev: 40863 Up: Map Next: 40955