Prev: 86A1 Up: Map Next: 8733
8701: Draw Sprite
Load the actor's cached (old) sprite, work out the new sprite position, and XOR both onto the screen through XORSpriteLoop.
Input
IX Actor slot
Before After DrawSprite After ColouriseSprite
jetman-before jetman-drawn jetman-coloured
Load the cached sprite, then XOR it onto the screen.
DrawSprite 8701 CALL LoadSpriteScratch Call LoadSpriteScratch.
8704 EXX Switch to the shadow registers.
8705 CALL PositionSprite Call PositionSprite.
8708 EXX Switch back to the normal registers.
Compare the cached Y position with the actor Y.
8709 LD A,($5E56) Subtract the actor Y from SpriteCachedY.
870C SUB (IX+$04)
870F JP Z,XORSpriteLoop_Write Jump to XORSpriteLoop_Write if they match.
8712 JP M,DrawSprite_ActorMovedDown Jump to DrawSprite_ActorMovedDown if the actor has moved down (the result is negative).
8715 LD C,A Store the row difference in the row counter.
8716 LD A,($5E5A) Jump to XORSpriteLoop_Write if the difference is taller than the old sprite's rows in SpriteCachedRows.
8719 CP C
871A JP C,XORSpriteLoop_Write
871D SUB C Subtract it from SpriteCachedRows and jump to XORSpriteLoop.
871E LD ($5E5A),A
8721 JP XORSpriteLoop
DrawSprite_ActorMovedDown 8724 EXX Switch register sets and negate the row difference.
8725 NEG
8727 LD C,A
8728 LD A,($5E59) Jump to XORSpriteLoop_FinishSprite if the difference is taller than the new sprite's rows in SpriteRowsLeft.
872B CP C
872C JP C,XORSpriteLoop_FinishSprite
872F SUB C Subtract it from the row count and jump to XORSpriteLoop_NextPair.
8730 JP XORSpriteLoop_NextPair
Prev: 86A1 Up: Map Next: 8733