Prev: 877C Up: Map Next: 87B9
8787: Draw Actor Sprite
Reload the actor graphic and XOR it via FetchAndDraw.
Input
IX Actor slot
Before After DrawActorSprite After ColouriseSprite
rover-before rover-drawn rover-coloured
Reload the actor graphic and XOR it via FetchAndDraw.
DrawActorSprite 8787 CALL LoadSpritePointers Call LoadSpritePointers.
878A EXX Switch to the shadow registers.
878B CALL FetchAndDraw Call FetchAndDraw.
878E EXX Switch back to the normal registers.
Compare the cached screen MSB with the actor Y.
DrawActorSprite_Fetch 878F LD A,($5E56) Subtract the actor Y from SpriteCachedY.
8792 SUB (IX+$04)
8795 JP Z,ContinueSpriteWrite_Row Jump to ContinueSpriteWrite_Row if they match.
8798 JP M,DrawActorSprite_Draw Jump to DrawActorSprite_Draw if the result is negative.
879B LD C,A Store the row difference in the row counter.
879C LD A,($5E5A) Jump to ContinueSpriteWrite_Row if the difference is taller than the old sprite's rows in SpriteCachedRows.
879F CP C
87A0 JP C,ContinueSpriteWrite_Row
87A3 SUB C Subtract it from SpriteCachedRows and jump to WriteSpriteRow.
87A4 LD ($5E5A),A
87A7 JP WriteSpriteRow
DrawActorSprite_Draw 87AA EXX Switch register sets and negate the row difference.
87AB NEG
87AD LD C,A
87AE LD A,($5E59) Jump to ContinueSpriteWrite_Next if the difference is taller than the new sprite's rows in SpriteRowsLeft.
87B1 CP C
87B2 JP C,ContinueSpriteWrite_Next
87B5 SUB C Subtract it from the row count and jump to ContinueSpriteWrite_Done.
87B6 JP ContinueSpriteWrite_Done
Prev: 877C Up: Map Next: 87B9