Prev: 34465 Up: Map Next: 34611
34561: 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 34561 CALL LoadSpriteScratch Call LoadSpriteScratch.
34564 EXX Switch to the shadow registers.
34565 CALL PositionSprite Call PositionSprite.
34568 EXX Switch back to the normal registers.
Compare the cached Y position with the actor Y.
34569 LD A,(24150) Subtract the actor Y from SpriteCachedY.
34572 SUB (IX+4)
34575 JP Z,XORSpriteLoop_Write Jump to XORSpriteLoop_Write if they match.
34578 JP M,DrawSprite_ActorMovedDown Jump to DrawSprite_ActorMovedDown if the actor has moved down (the result is negative).
34581 LD C,A Store the row difference in the row counter.
34582 LD A,(24154) Jump to XORSpriteLoop_Write if the difference is taller than the old sprite's rows in SpriteCachedRows.
34585 CP C
34586 JP C,XORSpriteLoop_Write
34589 SUB C Subtract it from SpriteCachedRows and jump to XORSpriteLoop.
34590 LD (24154),A
34593 JP XORSpriteLoop
DrawSprite_ActorMovedDown 34596 EXX Switch register sets and negate the row difference.
34597 NEG
34599 LD C,A
34600 LD A,(24153) Jump to XORSpriteLoop_FinishSprite if the difference is taller than the new sprite's rows in SpriteRowsLeft.
34603 CP C
34604 JP C,XORSpriteLoop_FinishSprite
34607 SUB C Subtract it from the row count and jump to XORSpriteLoop_NextPair.
34608 JP XORSpriteLoop_NextPair
Prev: 34465 Up: Map Next: 34611