Prev: 47578 Up: Map Next: 47756
47629: Draw Old Entity Row
Used by the routine at XORSpriteLoop.
Draws one row of the old sprite, using XOR, and moves up to the next row.
The row is drawn by unrolled code with one piece of 12 bytes for each byte of the row (up to eight bytes, with the last piece being longer so it can stop at the right of the screen). The operand of the jump at DrawOldEntityRow_0 is changed by PrepDraw23 so that the jump lands on the first piece that is needed. If the sprite is aligned to a character boundary the jump goes six bytes further in, which leaves out the first write.
Input
B Page of the shift table
C Number of rows left
DE Pointer to the pixel data
HL Screen address of the row
Output
C Number of rows left
DE Pointer to the next row of pixel data
HL Screen address of the next row
DrawOldEntityRow 47629 LD A,C Copy the row count to A.
47630 EX AF,AF' Store the row count in AF'.
47631 LD A,(DE) Fetch the first byte of the row.
47632 LD C,A Copy it to C to use as the index into the shift table.
47633 PUSH HL Stash the screen address on the stack.
DrawOldEntityRow_0 47634 JR DrawOldEntityRow_0 Jump into the unrolled code. The operand of this instruction is changed by PrepDraw23.
DrawOldEntityRow_Byte_1 47636 LD A,(DE) Byte 1 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47637 LD C,A
47638 LD A,(BC)
47639 XOR (HL)
47640 LD (HL),A
47641 INC L
DrawOldEntityRow_Byte_1_Right 47642 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data.
47643 LD A,(BC)
47644 XOR (HL)
47645 LD (HL),A
47646 DEC B
47647 INC DE
DrawOldEntityRow_Byte_2 47648 LD A,(DE) Byte 2 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47649 LD C,A
47650 LD A,(BC)
47651 XOR (HL)
47652 LD (HL),A
47653 INC L
DrawOldEntityRow_Byte_2_Right 47654 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data.
47655 LD A,(BC)
47656 XOR (HL)
47657 LD (HL),A
47658 DEC B
47659 INC DE
DrawOldEntityRow_Byte_3 47660 LD A,(DE) Byte 3 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47661 LD C,A
47662 LD A,(BC)
47663 XOR (HL)
47664 LD (HL),A
47665 INC L
DrawOldEntityRow_Byte_3_Right 47666 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data.
47667 LD A,(BC)
47668 XOR (HL)
47669 LD (HL),A
47670 DEC B
47671 INC DE
DrawOldEntityRow_Byte_4 47672 LD A,(DE) Byte 4 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47673 LD C,A
47674 LD A,(BC)
47675 XOR (HL)
47676 LD (HL),A
47677 INC L
DrawOldEntityRow_Byte_4_Right 47678 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data.
47679 LD A,(BC)
47680 XOR (HL)
47681 LD (HL),A
47682 DEC B
47683 INC DE
DrawOldEntityRow_Byte_5 47684 LD A,(DE) Byte 5 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47685 LD C,A
47686 LD A,(BC)
47687 XOR (HL)
47688 LD (HL),A
47689 INC L
DrawOldEntityRow_Byte_5_Right 47690 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data.
47691 LD A,(BC)
47692 XOR (HL)
47693 LD (HL),A
47694 DEC B
47695 INC DE
DrawOldEntityRow_Byte_6 47696 LD A,(DE) Byte 6 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47697 LD C,A
47698 LD A,(BC)
47699 XOR (HL)
47700 LD (HL),A
47701 INC L
DrawOldEntityRow_Byte_6_Right 47702 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data.
47703 LD A,(BC)
47704 XOR (HL)
47705 LD (HL),A
47706 DEC B
47707 INC DE
DrawOldEntityRow_Byte_7 47708 LD A,(DE) Byte 7 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47709 LD C,A
47710 LD A,(BC)
47711 XOR (HL)
47712 LD (HL),A
47713 INC L
DrawOldEntityRow_Byte_7_Right 47714 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen, then move on to the next byte of pixel data.
47715 LD A,(BC)
47716 XOR (HL)
47717 LD (HL),A
47718 DEC B
47719 INC DE
DrawOldEntityRow_Byte_8 47720 LD A,(DE) Byte 8 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
47721 LD C,A
47722 LD A,(BC)
47723 XOR (HL)
47724 LD (HL),A
47725 INC L
DrawOldEntityRow_Byte_8_Right 47726 LD A,L A=L.
47727 AND %00011111 Keep only bits 0-4.
47729 JR Z,DrawOldEntityRow_Byte_8_Next Jump to DrawOldEntityRow_Byte_8_Next if the first cell was at the right of the screen, as the second cell is then not written.
47731 INC B Look up the shifted byte for the cell to the right and XOR it onto the screen.
47732 LD A,(BC)
47733 XOR (HL)
47734 LD (HL),A
47735 DEC B
DrawOldEntityRow_Byte_8_Next 47736 INC DE Move on to the next byte of pixel data.
47737 EX AF,AF' Fetch the row count from AF'.
47738 LD C,A Copy the row count to C.
47739 POP HL Restore the screen address from the stack.
47740 DEC H Move up one pixel line.
47741 LD A,H A=H.
47742 CPL Flip the bits.
47743 AND %00000111 Keep only the pixel line bits (bits 0-2).
47745 RET NZ Return if the move up stayed inside the same character cell.
47746 LD A,L Subtract 32 from the low byte to move up to the previous character row.
47747 SUB 32
47749 LD L,A
47750 RET C Return if the move up stayed inside the same third of the screen.
47751 LD A,H Add 8 to the high byte to move up to the previous third of the screen.
47752 ADD A,8
47754 LD H,A
47755 RET Return.
View the equivalent code in;
Prev: 47578 Up: Map Next: 47756