Prev: 857F Up: Map Next: 85D9
858E: XOR Sprite Loop
XOR the old sprite (normal registers) and the new sprite (shadow registers) onto the screen one row at a time, using C as each sprite's row counter. Any rows left in SpriteCachedRows and SpriteRowsLeft are then picked up.
Input
HL Screen address
DE Graphic pointer
Draw remaining rows from the current graphic pair.
XORSpriteLoop 858E LD A,C Jump to XORSpriteLoop_TryShadow if the row counter is zero.
858F AND A
8590 JR Z,XORSpriteLoop_TryShadow
8592 DEC C Decrease the row counter and XOR the next row of the old sprite.
8593 CALL XORSpriteLoop_LoadPair
8596 EXX Switch to the shadow registers.
8597 LD A,C Jump to XORSpriteLoop_NextSide if the shadow row counter is zero.
8598 AND A
8599 JR Z,XORSpriteLoop_NextSide
XORSpriteLoop_Loop 859B DEC C Decrease the shadow row counter and XOR the next row of the new sprite.
859C CALL PrepareSpriteWrite
XORSpriteLoop_NextSide 859F EXX Switch back and loop to XORSpriteLoop.
85A0 JR XORSpriteLoop
No more rows on this side; try the other register set.
XORSpriteLoop_TryShadow 85A2 EXX Switch to the shadow registers.
85A3 LD A,C Jump to XORSpriteLoop_Loop if the shadow row counter is still live.
85A4 AND A
85A5 JR NZ,XORSpriteLoop_Loop
Finish the sprites if either has rows left to draw.
XORSpriteLoop_FinishSprite 85A7 EXX Switch back to the normal registers.
This entry point is used by the routine at DrawSprite.
XORSpriteLoop_Write 85A8 LD A,($5E5A) Return if both SpriteCachedRows and SpriteRowsLeft are zero.
85AB LD C,A
85AC LD A,($5E59)
85AF OR C
85B0 RET Z
85B1 XOR A Write 00 to SpriteCachedRows and switch register sets.
85B2 LD ($5E5A),A
85B5 EXX
85B6 LD A,($5E59) Load the remaining row count and clear A.
85B9 LD C,A
85BA XOR A
This entry point is used by the routine at DrawSprite.
XORSpriteLoop_NextPair 85BB LD ($5E59),A Write the remaining row count to SpriteRowsLeft.
85BE EXX Switch back and loop to XORSpriteLoop.
85BF JR XORSpriteLoop
Copy of XORSpritePairUp for the old sprite. The self-modified jump at XORSpriteLoop_Shift lands here when the sprite is byte-aligned.
85C1 EX DE,HL XOR the graphic pair onto the screen and move up one pixel.
85C2 EX (SP),HL
85C3 LD A,D
85C4 XOR (HL)
85C5 LD (HL),A
85C6 INC L
85C7 LD A,E
85C8 XOR (HL)
85C9 LD (HL),A
85CA POP DE
85CB DEC L
85CC JP ScreenPosition1PixelAbove
XORSpriteLoop_LoadPair 85CF EX DE,HL Load the next graphic pair from DE.
85D0 PUSH DE
85D1 LD D,(HL)
85D2 INC HL
85D3 LD E,(HL)
85D4 INC HL
85D5 EX DE,HL
85D6 XOR A
XORSpriteLoop_Shift 85D7 JR XORSpriteLoop_Shift Self-modifying shift. The operand is written by 866A.
Prev: 857F Up: Map Next: 85D9