Prev: 35409 Up: Map Next: 35560
35420: Mask Sprite
XOR the old (cached) image of a masked sprite off the screen and its new image on, row by row, using the remaining row counts in SpriteCachedRows (old image) and SpriteRowsLeft (new image).
Input
HL Screen address
DE Graphic pointer
Draw remaining rows from the current masked pair.
MaskSprite 35420 LD A,C Jump to MaskSprite_TryShadow if the row counter is zero.
35421 AND A
35422 JR Z,MaskSprite_TryShadow
35424 DEC C Decrease the row counter and draw the next row of the old image.
35425 CALL MaskSprite_LoadMask
35428 EXX Switch to the shadow registers.
35429 LD A,C Jump to MaskSprite_NextSide if the shadow row counter is zero.
35430 AND A
35431 JR Z,MaskSprite_NextSide
MaskSprite_Loop 35433 DEC C Decrease the shadow row counter and draw the next row of the new image.
35434 CALL MaskSprite_LoadMaskAgain
MaskSprite_NextSide 35437 EXX Switch back and loop to MaskSprite.
35438 JR MaskSprite
MaskSprite_TryShadow 35440 EXX Switch to the shadow registers.
35441 LD A,C Jump to MaskSprite_Loop if the shadow row counter is still live.
35442 AND A
35443 JR NZ,MaskSprite_Loop
Finish the sprite if any rows remain to be erased or drawn.
MaskSprite_FinishSprite 35445 EXX Switch back to the normal registers.
This entry point is used by the routine at DrawObjectSprite.
MaskSprite_TestRemaining 35446 LD A,(24154) Return if both SpriteCachedRows and SpriteRowsLeft are zero.
35449 LD C,A
35450 LD A,(24153)
35453 OR C
35454 RET Z
35455 XOR A Write 0 to SpriteCachedRows and switch register sets.
35456 LD (24154),A
35459 EXX
35460 LD A,(24153) Load the remaining row count and clear A.
35463 LD C,A
35464 XOR A
This entry point is used by the routine at DrawObjectSprite.
MaskSprite_StoreRowCount 35465 LD (24153),A Write the remaining row count to SpriteRowsLeft.
35468 EXX Switch back and loop to MaskSprite.
35469 JR MaskSprite
Reached by the self-modified shift (operand 242) when the mask is byte-aligned: only one screen byte is XORed.
35471 EX DE,HL Switch the pair and jump to MaskSprite_XORSecond.
35472 EX (SP),HL
35473 JR MaskSprite_XORSecond
Load and shift the next mask byte for a row of the old image.
MaskSprite_LoadMask 35475 PUSH HL Load the next mask byte from DE.
35476 EX DE,HL
35477 PUSH DE
35478 LD D,0
35480 LD E,(HL)
35481 INC HL
35482 EX DE,HL
MaskSprite_ShiftMask 35483 JR MaskSprite_ShiftMask Self-modifying shift. The operand is written by 35678.
35485 ADD HL,HL Shift the mask left into pixel alignment.
35486 ADD HL,HL
35487 ADD HL,HL
35488 ADD HL,HL
35489 ADD HL,HL
35490 ADD HL,HL
35491 ADD HL,HL
35492 EX DE,HL
MaskSprite_XORFirst 35493 EX (SP),HL XOR the first mask byte onto the screen.
35494 LD A,D
35495 XOR (HL)
35496 LD (HL),A
35497 INC L
35498 LD A,L Fetch the new column.
35499 AND %00011111 Keep only bits 0-4.
35501 JR Z,MaskSprite_MoveUp Jump to MaskSprite_MoveUp if the row wrapped.
MaskSprite_XORSecond 35503 LD A,E XOR the second mask byte onto the screen.
35504 XOR (HL)
35505 LD (HL),A
Step the screen address up one pixel line.
MaskSprite_MoveUp 35506 POP DE Restore the graphic pointer and screen address.
35507 POP HL
35508 DEC H Move up one pixel.
35509 LD A,H
35510 CPL
35511 AND %00000111 Keep only bits 0-2.
35513 RET NZ Return if a character-row boundary was not crossed.
35514 LD A,L Subtract 32 from the column address.
35515 SUB 32
35517 LD L,A
35518 RET C Return if that wrapped into the previous third.
35519 LD A,H Add 8 to the line byte.
35520 ADD A,8
35522 LD H,A
35523 RET Return.
Reached by the self-modified shift (operand 242) when the mask is byte-aligned: only one screen byte is XORed.
35524 EX DE,HL Switch the pair and jump to MaskSprite_XORSecond.
35525 EX (SP),HL
35526 JR MaskSprite_XORSecond
Load and shift the next mask byte for a row of the new image.
MaskSprite_LoadMaskAgain 35528 PUSH HL Load the next mask byte from DE.
35529 EX DE,HL
35530 PUSH DE
35531 LD D,0
35533 LD E,(HL)
35534 INC HL
35535 EX DE,HL
MaskSprite_ShiftAndPlace 35536 JR MaskSprite_ShiftAndPlace Self-modifying shift. The operand is written by PositionMaskSprite_StoreShift.
35538 ADD HL,HL Shift the mask left into pixel alignment and jump to MaskSprite_XORFirst.
35539 ADD HL,HL
35540 ADD HL,HL
35541 ADD HL,HL
35542 ADD HL,HL
35543 ADD HL,HL
35544 ADD HL,HL
35545 EX DE,HL
35546 JR MaskSprite_XORFirst
35548 CALL PositionSprite Call PositionSprite, clear SpriteCachedRows and jump to MaskSprite.
35551 EXX
35552 XOR A
35553 LD (24154),A
35556 LD C,A
35557 JP MaskSprite
View the equivalent code in;
Prev: 35409 Up: Map Next: 35560