Prev: 75CC Up: Map Next: 761A
75D0: Draw Sprite Rows
Used by the routines at SetUpPreviousSprite and DrawSprite.
Erases the previous sprite and draws the new one, one pixel row at a time, working up the screen from the bottom row. The main registers hold the previous sprite and the shadow registers hold the new sprite. A row of the previous sprite is cleared by ANDing the screen with the inverted sprite data. A row of the new sprite is ORed onto the screen.
The first pass handles the rows where only one of the two sprites has any data. The heights at 5E10 and 5E11 then give the rows both sprites have in common, which are done on the second pass.
Input
B Sprite width in bytes
C Number of rows left to process
DE Address into a sprite
HL Address in the screen buffer
MaskSprite 75D0 LD A,C A=the number of rows left of the previous sprite.
75D1 AND A Set the flags.
75D2 JR Z,MaskSprite_NewOnly Jump to MaskSprite_NewOnly if there are no more rows of the previous sprite.
75D4 DEC C Decrease the row counter by one.
75D5 PUSH BC Stash the counter and the screen address on the stack.
75D6 PUSH HL
Clear one row of the previous sprite from the screen.
MaskSprite_Erase 75D7 LD A,(DE) Fetch a byte of the sprite.
75D8 CPL Invert it.
75D9 AND (HL) Remove the sprite pixels from the screen.
75DA LD (HL),A Write the result back to the screen.
75DB INC DE Move onto the next byte of the sprite.
75DC INC L Move onto the next column.
75DD DJNZ MaskSprite_Erase Decrease the width counter by one and loop back to MaskSprite_Erase until the whole row of the sprite has been erased.
75DF POP HL Restore the screen address from the stack.
75E0 CALL ScreenPosition1PixelAbove Move up one pixel row.
75E3 POP BC Restore the counter from the stack.
Switch to the new sprite.
MaskSprite_Draw 75E4 EXX Switch to the shadow registers.
75E5 LD A,C A=the number of rows left of the new sprite.
75E6 AND A Set the flags.
75E7 JR Z,MaskSprite_Next Jump to MaskSprite_Next if there are no more rows of the new sprite.
MaskSprite_Draw_Row 75E9 DEC C Decrease the row counter by one.
75EA PUSH BC Stash the counter and the screen address on the stack.
75EB PUSH HL
Draw one row of the new sprite onto the screen.
MaskSprite_Draw_Loop 75EC LD A,(DE) Fetch a byte of the sprite.
75ED OR (HL) Combine it with the screen.
75EE LD (HL),A Write the result back to the screen.
75EF INC DE Move onto the next byte of the sprite.
75F0 INC L Move onto the next column.
75F1 DJNZ MaskSprite_Draw_Loop Decrease the width counter by one and loop back to MaskSprite_Draw_Loop until the whole row of the sprite has been drawn.
75F3 POP HL Restore the screen address from the stack.
75F4 CALL ScreenPosition1PixelAbove Move up one pixel row.
75F7 POP BC Restore the counter from the stack.
MaskSprite_Next 75F8 EXX Switch back to the previous sprite.
75F9 JR MaskSprite Jump back to MaskSprite to do the next pair of rows.
There are no more rows of the previous sprite, so only the new sprite is left to draw.
MaskSprite_NewOnly 75FB EXX Switch to the new sprite.
75FC LD A,C A=the number of rows left of the new sprite.
75FD AND A Set the flags.
75FE JR NZ,MaskSprite_Draw_Row Jump to MaskSprite_Draw_Row if there are rows to draw.
This entry point is used by the routine at SetUpPreviousSprite.
Both sprites have been drawn as far as their rows go.
MaskSprite_Finish 7600 EXX Switch back to the previous sprite.
This entry point is used by the routine at SetUpPreviousSprite.
MaskSprite_Finish_Previous 7601 LD A,($5E10) Fetch the remaining row count of the previous sprite from 5E10 and keep it in C.
7604 LD C,A
7605 LD A,($5E11) Fetch the remaining row count of the new sprite from 5E11.
7608 OR C Combine them.
7609 RET Z Return if there are no rows left on either sprite.
760A XOR A Clear 5E10 so that it is only used once.
760B LD ($5E10),A
760E EXX Switch to the new sprite.
760F LD A,($5E11) Fetch the remaining row count from 5E11 and keep the remaining row count of the new sprite in C.
7612 LD C,A
7613 XOR A A=00.
This entry point is used by the routine at SetUpPreviousSprite.
MaskSprite_Finish_ClearNew 7614 LD ($5E11),A Write 00 to 5E11 so that it is only used once.
7617 EXX Switch back to the previous sprite.
7618 JR MaskSprite Jump to MaskSprite to process the rows both sprites have.
Prev: 75CC Up: Map Next: 761A