Prev: 9719 Up: Map Next: 975B
9728: XOR Sprite Loop
Used by the routines at DrawEntity, RemoveEntity and DisplayEntity.
Draws the old sprite and the new sprite a row at a time, alternating between the two, until every row of both has been drawn. The set of registers that is current on entry belongs to the old sprite, which is drawn by DrawOldEntityRow. The other set belongs to the new sprite, which is drawn by DrawNewEntityRow.
In each set HL is the screen address of the next row (the sprites are drawn from the bottom row upwards), DE points at the pixel data and B is the page of the shift table. C counts the rows that remain.
When both counts reach zero, the counts that are held in Old_Sprite_Row_Count (old sprite) and New_Sprite_Row_Count (new sprite) are loaded and the whole process repeats. The routine returns when those are zero as well. This allows the rows that have no partner to be drawn first (see DisplayEntity).
Draw a row of the old sprite, if it has any rows left.
XORSpriteLoop 9728 LD A,C Fetch the row count of the old sprite.
9729 AND A Jump to XORSpriteLoop_NewOnly if there are no rows left.
972A JR Z,XORSpriteLoop_NewOnly
972C DEC C Decrease the row count.
972D CALL DrawOldEntityRow Draw a row of the old sprite.
Draw a row of the new sprite, if it has any rows left.
9730 EXX Switch to the registers of the new sprite.
9731 LD A,C Fetch the row count of the new sprite.
9732 AND A Jump to XORSpriteLoop_OldRow if there are no rows left.
9733 JR Z,XORSpriteLoop_OldRow
XORSpriteLoop_NewRow 9735 DEC C Decrease the row count.
9736 CALL DrawNewEntityRow Draw a row of the new sprite.
XORSpriteLoop_OldRow 9739 EXX Switch to the registers of the old sprite.
973A JR XORSpriteLoop Jump back to XORSpriteLoop to draw the next pair of rows.
XORSpriteLoop_NewOnly 973C EXX Switch to the registers of the new sprite.
973D LD A,C Fetch the row count of the new sprite.
973E AND A Jump to XORSpriteLoop_NewRow if there are rows left.
973F JR NZ,XORSpriteLoop_NewRow
This entry point is used by the routine at DisplayEntity_NewLower.
XORSpriteLoop_Done 9741 EXX Switch to the registers of the old sprite.
This entry point is used by the routine at DisplayEntity.
Both of the counts are zero. Load the row counts that were stored by the preparation routines and go round again, unless they are zero too.
XORSpriteLoop_Reload 9742 LD A,($8EE2) Fetch the number of rows of the old sprite from Old_Sprite_Row_Count.
9745 LD C,A Copy the number of rows to C.
9746 LD A,($8EE3) Fetch the number of rows of the new sprite from New_Sprite_Row_Count.
9749 OR C Combine it with the number of rows of the old sprite.
974A RET Z Return if there are no rows left to draw.
974B XOR A Write 00 to Old_Sprite_Row_Count.
974C LD ($8EE2),A
974F EXX Switch to the registers of the new sprite.
9750 LD A,($8EE3) Fetch the number of rows of the new sprite from New_Sprite_Row_Count.
9753 LD C,A Copy the number of rows to C.
9754 XOR A Set the number of rows to store to 00.
This entry point is used by the routine at DisplayEntity_NewLower.
XORSpriteLoop_StoreNew 9755 LD ($8EE3),A Store A in New_Sprite_Row_Count.
9758 EXX Switch to the registers of the old sprite.
9759 JR XORSpriteLoop Jump back to XORSpriteLoop to start drawing rows.
View the equivalent code in;
Prev: 9719 Up: Map Next: 975B