Prev: 9728 Up: Map Next: 97E1
975B: 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 0C bytes for each byte of the row (up to nine bytes). The operand of the jump at DrawOldEntityRow_Jump 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
DE Pointer to the pixel data
HL Screen address of the row
C Number of rows left
Output
C Number of rows left
DE Pointer to the next row of pixel data
HL Screen address of the next row
DrawOldEntityRow 975B LD A,C Copy the row count to A.
975C EX AF,AF' Store the row count in AF'.
975D LD A,(DE) Fetch the first byte of the row.
975E LD C,A Copy it to C to use as the index into the shift table.
975F PUSH HL Stash the screen address on the stack.
DrawOldEntityRow_Jump 9760 JR DrawOldEntityRow_Jump Jump into the unrolled code. The operand of this instruction is changed by PrepDraw23.
DrawOldEntityRow_Byte_1 9762 LD A,(DE) Byte 1 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
9763 LD C,A
9764 LD A,(BC)
9765 XOR (HL)
9766 LD (HL),A
9767 INC L
DrawOldEntityRow_Byte_1_Right 9768 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.
9769 LD A,(BC)
976A XOR (HL)
976B LD (HL),A
976C DEC B
976D INC DE
DrawOldEntityRow_Byte_2 976E LD A,(DE) Byte 2 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
976F LD C,A
9770 LD A,(BC)
9771 XOR (HL)
9772 LD (HL),A
9773 INC L
DrawOldEntityRow_Byte_2_Right 9774 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.
9775 LD A,(BC)
9776 XOR (HL)
9777 LD (HL),A
9778 DEC B
9779 INC DE
DrawOldEntityRow_Byte_3 977A LD A,(DE) Byte 3 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
977B LD C,A
977C LD A,(BC)
977D XOR (HL)
977E LD (HL),A
977F INC L
DrawOldEntityRow_Byte_3_Right 9780 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.
9781 LD A,(BC)
9782 XOR (HL)
9783 LD (HL),A
9784 DEC B
9785 INC DE
DrawOldEntityRow_Byte_4 9786 LD A,(DE) Byte 4 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
9787 LD C,A
9788 LD A,(BC)
9789 XOR (HL)
978A LD (HL),A
978B INC L
DrawOldEntityRow_Byte_4_Right 978C 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.
978D LD A,(BC)
978E XOR (HL)
978F LD (HL),A
9790 DEC B
9791 INC DE
DrawOldEntityRow_Byte_5 9792 LD A,(DE) Byte 5 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
9793 LD C,A
9794 LD A,(BC)
9795 XOR (HL)
9796 LD (HL),A
9797 INC L
DrawOldEntityRow_Byte_5_Right 9798 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.
9799 LD A,(BC)
979A XOR (HL)
979B LD (HL),A
979C DEC B
979D INC DE
DrawOldEntityRow_Byte_6 979E LD A,(DE) Byte 6 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
979F LD C,A
97A0 LD A,(BC)
97A1 XOR (HL)
97A2 LD (HL),A
97A3 INC L
DrawOldEntityRow_Byte_6_Right 97A4 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.
97A5 LD A,(BC)
97A6 XOR (HL)
97A7 LD (HL),A
97A8 DEC B
97A9 INC DE
DrawOldEntityRow_Byte_7 97AA LD A,(DE) Byte 7 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
97AB LD C,A
97AC LD A,(BC)
97AD XOR (HL)
97AE LD (HL),A
97AF INC L
DrawOldEntityRow_Byte_7_Right 97B0 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.
97B1 LD A,(BC)
97B2 XOR (HL)
97B3 LD (HL),A
97B4 DEC B
97B5 INC DE
DrawOldEntityRow_Byte_8 97B6 LD A,(DE) Byte 8 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
97B7 LD C,A
97B8 LD A,(BC)
97B9 XOR (HL)
97BA LD (HL),A
97BB INC L
DrawOldEntityRow_Byte_8_Right 97BC 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.
97BD LD A,(BC)
97BE XOR (HL)
97BF LD (HL),A
97C0 DEC B
97C1 INC DE
DrawOldEntityRow_Byte_9 97C2 LD A,(DE) Byte 9 of the row: look up the shifted byte for the left cell and XOR it onto the screen.
97C3 LD C,A
97C4 LD A,(BC)
97C5 XOR (HL)
97C6 LD (HL),A
97C7 INC L
DrawOldEntityRow_Byte_9_Right 97C8 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.
97C9 LD A,(BC)
97CA XOR (HL)
97CB LD (HL),A
97CC DEC B
97CD INC DE
DrawOldEntityRow_Byte_9_Next 97CE EX AF,AF' Fetch the row count from AF'.
97CF LD C,A Copy the row count to C.
97D0 POP HL Restore the screen address from the stack.
97D1 DEC H Move up one pixel line.
97D2 LD A,H Fetch the inverse of the high byte of the address in A.
97D3 CPL
97D4 AND %00000111 Keep only the pixel line bits (bits 0-2).
97D6 RET NZ Return if the move up stayed inside the same character cell.
97D7 LD A,L Subtract 20 from the low byte to move up to the previous character row.
97D8 SUB $20
97DA LD L,A
97DB RET C Return if the move up stayed inside the same third of the screen.
97DC LD A,H Add 08 to the high byte to move up to the previous third of the screen.
97DD ADD A,$08
97DF LD H,A
97E0 RET Return.
View the equivalent code in;
Prev: 9728 Up: Map Next: 97E1