Prev: 40598 Up: Map Next: 40654
40603: XOR Sprite Loop
Used by the routines at DrawEntity, RemoveEntity and DisplayEntity.
XORs the old sprite and the new sprite onto the screen one row at a time, working up from the bottom row. The row counters are in C and C' (in the normal and the shadow register sets), and each register set holds the screen address in HL and the sprite data address in DE for one of the two sprites. When the counters run out, any rows left over in Old_Sprite_Row_Count and New_Sprite_Row_Count are drawn.
Drawing a sprite a second time erases it, so the old sprite is removed from where it was and the new sprite is drawn where it is now.
XORSpriteLoop 40603 LD A,C Fetch the number of rows of the old sprite that are left.
40604 AND A Jump to XORSpriteLoop_Swap if there are no rows of the old sprite left to draw.
40605 JR Z,XORSpriteLoop_Swap
40607 DEC C Decrease the row counter by one.
40608 CALL DrawOldSpriteRow Call DrawOldSpriteRow to draw the old sprite row.
40611 EXX Switch to the shadow registers.
40612 LD A,C Fetch the number of rows of the new sprite that are left.
40613 AND A Jump to XORSpriteLoop_Next if there are no rows of the new sprite left to draw.
40614 JR Z,XORSpriteLoop_Next
XORSpriteLoop_Actor 40616 DEC C Decrease the row counter by one.
40617 CALL DrawActorSpriteRow Call DrawActorSpriteRow to draw the new sprite row.
XORSpriteLoop_Next 40620 EXX Switch to the normal registers.
40621 JR XORSpriteLoop Jump to XORSpriteLoop to draw the sprites onto the screen.
XORSpriteLoop_Swap 40623 EXX Switch to the shadow registers.
40624 LD A,C Fetch the number of rows of the new sprite that are left.
40625 AND A Jump to XORSpriteLoop_Actor if there are more rows of the new sprite to draw.
40626 JR NZ,XORSpriteLoop_Actor
This entry point is used by the routine at DisplayEntity.
XORSpriteLoop_Restore 40628 EXX Switch to the normal registers.
This entry point is used by the routine at DisplayEntity.
Fetch the number of rows left over from the old sprite and the new sprite. If there are none then the drawing is finished.
XORSpriteLoop_Remaining 40629 LD A,(24088) Fetch the number of old sprite rows from Old_Sprite_Row_Count and keep it in C.
40632 LD C,A
40633 LD A,(24089) Fetch the number of new sprite rows from New_Sprite_Row_Count.
40636 OR C Return if there are no rows left to draw.
40637 RET Z
40638 XOR A A=0.
40639 LD (24088),A Update the number of old sprite rows in Old_Sprite_Row_Count.
40642 EXX Switch to the shadow registers.
40643 LD A,(24089) Fetch the number of new sprite rows from New_Sprite_Row_Count and keep it in C.
40646 LD C,A
40647 XOR A A=0.
This entry point is used by the routine at DisplayEntity.
XORSpriteLoop_Continue 40648 LD (24089),A Update the number of new sprite rows in New_Sprite_Row_Count.
40651 EXX Switch to the normal registers.
40652 JR XORSpriteLoop Jump to XORSpriteLoop to draw the sprites onto the screen.
View the equivalent code in;
Prev: 40598 Up: Map Next: 40654