Prev: 58569 Up: Map Next: 58664
58573: Draw Shifted Columns
The code that draws a row of a sprite that has been shifted by two, four or six pixels. There is a copy of the code for each of up to five characters, and the code is entered at the one that leaves the number of characters of the sprite, from DrawSpriteRow.
Each character takes a mask and pixels from the stack. The shifted halves of them come from the tables that BuildShiftTables builds, with the high byte of the address of the table in H, and the low byte of the address from the mask or the pixels. The part that goes into the first character of the screen buffer is combined with what is left over from the previous character, and the part that goes into the next character is kept for the next time.
Input
A The first byte of the row in the screen buffer
BC Address in the screen buffer
H Page of the table for the first parts of the shifted bytes
The jump starts here for five columns.
DrawShiftedColumns_Five 58573 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
58574 POP DE
58575 LD L,E Clear the screen bits under the part of the mask which is in this byte.
58576 OR (HL)
58577 CPL
58578 LD L,D Add the part of the pixels which is in this byte.
58579 OR (HL)
Put the byte in the screen buffer, move on to the next byte and point H at the table for the second parts.
58580 LD (BC),A Store the byte and move on to the next.
58581 INC BC
58582 INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
58583 LD L,E
58584 LD A,(BC)
58585 CPL Clear the screen bits under the part of the mask which has moved into it.
58586 OR (HL)
58587 CPL
58588 LD L,D Add the part of the pixels which has moved into it.
58589 OR (HL)
58590 DEC H Point H back at the first table.
The jump starts here for four columns.
DrawShiftedColumns_Four 58591 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
58592 POP DE
58593 LD L,E Clear the screen bits under the part of the mask which is in this byte.
58594 OR (HL)
58595 CPL
58596 LD L,D Add the part of the pixels which is in this byte.
58597 OR (HL)
Put the byte in the screen buffer, move on to the next byte and point H at the table for the second parts.
58598 LD (BC),A Store the byte and move on to the next.
58599 INC BC
58600 INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
58601 LD L,E
58602 LD A,(BC)
58603 CPL Clear the screen bits under the part of the mask which has moved into it.
58604 OR (HL)
58605 CPL
58606 LD L,D Add the part of the pixels which has moved into it.
58607 OR (HL)
58608 DEC H Point H back at the first table.
The jump starts here for three columns.
DrawShiftedColumns_Three 58609 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
58610 POP DE
58611 LD L,E Clear the screen bits under the part of the mask which is in this byte.
58612 OR (HL)
58613 CPL
58614 LD L,D Add the part of the pixels which is in this byte.
58615 OR (HL)
Put the byte in the screen buffer, move on to the next byte and point H at the table for the second parts.
58616 LD (BC),A Store the byte and move on to the next.
58617 INC BC
58618 INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
58619 LD L,E
58620 LD A,(BC)
58621 CPL Clear the screen bits under the part of the mask which has moved into it.
58622 OR (HL)
58623 CPL
58624 LD L,D Add the part of the pixels which has moved into it.
58625 OR (HL)
58626 DEC H Point H back at the first table.
The jump starts here for two columns.
DrawShiftedColumns_Two 58627 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
58628 POP DE
58629 LD L,E Clear the screen bits under the part of the mask which is in this byte.
58630 OR (HL)
58631 CPL
58632 LD L,D Add the part of the pixels which is in this byte.
58633 OR (HL)
Put the byte in the screen buffer, move on to the next byte and point H at the table for the second parts.
58634 LD (BC),A Store the byte and move on to the next.
58635 INC BC
58636 INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
58637 LD L,E
58638 LD A,(BC)
58639 CPL Clear the screen bits under the part of the mask which has moved into it.
58640 OR (HL)
58641 CPL
58642 LD L,D Add the part of the pixels which has moved into it.
58643 OR (HL)
58644 DEC H Point H back at the first table.
The jump starts here for one column.
DrawShiftedColumns_One 58645 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
58646 POP DE
58647 LD L,E Clear the screen bits under the part of the mask which is in this byte.
58648 OR (HL)
58649 CPL
58650 LD L,D Add the part of the pixels which is in this byte.
58651 OR (HL)
Put the byte in the screen buffer, move on to the next byte and point H at the table for the second parts.
58652 LD (BC),A Store the byte and move on to the next.
58653 INC BC
58654 INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
58655 LD L,E
58656 LD A,(BC)
58657 CPL Clear the screen bits under the part of the mask which has moved into it.
58658 OR (HL)
58659 CPL
58660 LD L,D Add the part of the pixels which has moved into it.
58661 OR (HL)
58662 DEC H Point H back at the first table.
DrawShiftedColumns_Last 58663 LD (BC),A Put the part of the last character that is left over in the screen buffer.
View the equivalent code in;
Prev: 58569 Up: Map Next: 58664