Prev: D08F Up: Map Next: D120
D0B9: Draw Lines
Used by the routine at PrintSprite.
Draws the lines of a sprite one after the other. For each line the code jumps into the unrolled code, at a place that depends on the width of the sprite, and that is set by the jump that is changed by PrintSprite. The code for a sprite that is not on a byte boundary takes a pair of bytes off the stack, which are the mask and the data, shifts them across the two bytes of the buffer that they fall into with the table of shifted bytes in H, and keeps what is left of the second byte to go with the next pair. A sprite on a byte boundary jumps into DrawAlignedColumns instead.
Jump into the unrolled columns.
DrawLines D0B9 EX AF,AF' Copy A to A'.
D0BA LD A,(BC) Fetch the first byte of the buffer.
DrawLines_Jump D0BB JR DrawLines_Jump Jump into the unrolled columns.
The patched jump at DrawLines_Jump lands here when the sprite is five columns wide.
DrawLines_FirstPair D0BD POP DE Draw the first pair of a sprite that has five.
D0BE LD L,E
D0BF AND (HL)
D0C0 LD L,D
D0C1 XOR (HL)
D0C2 CPL
D0C3 LD (BC),A
D0C4 INC BC
D0C5 INC H
D0C6 LD L,E
D0C7 LD A,(BC)
D0C8 AND (HL)
D0C9 LD L,D
D0CA XOR (HL)
D0CB CPL
D0CC DEC H
D0CD POP DE Draw the second pair of a sprite that has four or five.
D0CE LD L,E
D0CF AND (HL)
D0D0 LD L,D
D0D1 XOR (HL)
D0D2 CPL
D0D3 LD (BC),A
D0D4 INC BC
D0D5 INC H
D0D6 LD L,E
D0D7 LD A,(BC)
D0D8 AND (HL)
D0D9 LD L,D
D0DA XOR (HL)
D0DB CPL
D0DC DEC H
D0DD POP DE Draw the third pair of a sprite that has three or more.
D0DE LD L,E
D0DF AND (HL)
D0E0 LD L,D
D0E1 XOR (HL)
D0E2 CPL
D0E3 LD (BC),A
D0E4 INC BC
D0E5 INC H
D0E6 LD L,E
D0E7 LD A,(BC)
D0E8 AND (HL)
D0E9 LD L,D
D0EA XOR (HL)
D0EB CPL
D0EC DEC H
D0ED POP DE Draw the fourth pair of a sprite that has two or more.
D0EE LD L,E
D0EF AND (HL)
D0F0 LD L,D
D0F1 XOR (HL)
D0F2 CPL
D0F3 LD (BC),A
D0F4 INC BC
D0F5 INC H
D0F6 LD L,E
D0F7 LD A,(BC)
D0F8 AND (HL)
D0F9 LD L,D
D0FA XOR (HL)
D0FB CPL
D0FC DEC H
D0FD POP DE Draw the last pair.
D0FE LD L,E
D0FF AND (HL)
D100 LD L,D
D101 XOR (HL)
D102 CPL
D103 LD (BC),A
D104 INC BC
D105 INC H
D106 LD L,E
D107 LD A,(BC)
D108 AND (HL)
D109 LD L,D
D10A XOR (HL)
D10B CPL
D10C DEC H
D10D LD (BC),A Write the last byte of the line.
This entry point is used by the routine at DrawAlignedColumns.
Step on to the next line. The aligned columns jump here after their last column.
DrawLines_Next D10E LD A,C Fetch C.
DrawLines_Step D10F ADD A,$00 Add the step, which is changed for the width of the sprite.
D111 LD C,A Copy it to C.
D112 LD A,B Fetch B.
D113 ADC A,$00 Add 00 with carry.
D115 LD B,A Copy it to B.
D116 EX AF,AF' Fetch A'.
D117 DEC A Decrement A.
D118 JP NZ,DrawLines Jump to DrawLines if it is not zero.
D11B LD SP,($5B09) Fetch SavedStackPointer and return.
D11F RET
View the equivalent code in;
Prev: D08F Up: Map Next: D120