Prev: B9CB Up: Map Next: BA0D
B9DA: XOR Sprite Loop
Used by the routines at RemoveEntity, DrawEntity 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 B9DA LD A,C Fetch the row count of the old sprite.
B9DB AND A Set the flags.
B9DC JR Z,XORSpriteLoop_NewOnly Jump to XORSpriteLoop_NewOnly if there are no rows left.
B9DE DEC C Decrease the row count.
B9DF CALL DrawOldEntityRow Draw a row of the old sprite.
Draw a row of the new sprite, if it has any rows left.
B9E2 EXX Switch to the registers of the new sprite.
B9E3 LD A,C Fetch the row count of the new sprite.
B9E4 AND A Set the flags.
B9E5 JR Z,XORSpriteLoop_OldRow Jump to XORSpriteLoop_OldRow if there are no rows left.
XORSpriteLoop_NewRow B9E7 DEC C Decrease the row count.
B9E8 CALL DrawNewEntityRow Draw a row of the new sprite.
XORSpriteLoop_OldRow B9EB EXX Switch to the registers of the old sprite.
B9EC JR XORSpriteLoop Jump to XORSpriteLoop to draw the next pair of rows.
The old sprite has no rows left, so draw the rest of the new sprite.
XORSpriteLoop_NewOnly B9EE EXX Switch to the registers of the new sprite.
B9EF LD A,C Fetch the row count of the new sprite.
B9F0 AND A Set the flags.
B9F1 JR NZ,XORSpriteLoop_NewRow Jump to XORSpriteLoop_NewRow if there are rows left.
This entry point is used by the routine at DisplayEntity_NewLower.
XORSpriteLoop_Done B9F3 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 B9F4 LD A,($96A3) Fetch the number of rows of the old sprite from Old_Sprite_Row_Count.
B9F7 LD C,A Copy the number of rows to C.
B9F8 LD A,($96A4) Fetch the number of rows of the new sprite from New_Sprite_Row_Count.
B9FB OR C Combine it with the number of rows of the old sprite.
B9FC RET Z Return if there are no rows left to draw.
B9FD XOR A A=00.
B9FE LD ($96A3),A Write A to Old_Sprite_Row_Count.
BA01 EXX Switch to the registers of the new sprite.
BA02 LD A,($96A4) Fetch the number of rows of the new sprite from New_Sprite_Row_Count.
BA05 LD C,A Copy the number of rows to C.
BA06 XOR A A=00.
This entry point is used by the routine at DisplayEntity_NewLower.
XORSpriteLoop_StoreNew BA07 LD ($96A4),A Write A to New_Sprite_Row_Count.
BA0A EXX Switch to the registers of the old sprite.
BA0B JR XORSpriteLoop Jump to XORSpriteLoop to start drawing rows.
View the equivalent code in;
Prev: B9CB Up: Map Next: BA0D