Prev: E4C9 Up: Map Next: E528
E4CD: 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 E4CD CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
E4CE POP DE
E4CF LD L,E Clear the screen bits under the part of the mask which is in this byte.
E4D0 OR (HL)
E4D1 CPL
E4D2 LD L,D Add the part of the pixels which is in this byte.
E4D3 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.
E4D4 LD (BC),A Store the byte and move on to the next.
E4D5 INC BC
E4D6 INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
E4D7 LD L,E
E4D8 LD A,(BC)
E4D9 CPL Clear the screen bits under the part of the mask which has moved into it.
E4DA OR (HL)
E4DB CPL
E4DC LD L,D Add the part of the pixels which has moved into it.
E4DD OR (HL)
E4DE DEC H Point H back at the first table.
The jump starts here for four columns.
DrawShiftedColumns_Four E4DF CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
E4E0 POP DE
E4E1 LD L,E Clear the screen bits under the part of the mask which is in this byte.
E4E2 OR (HL)
E4E3 CPL
E4E4 LD L,D Add the part of the pixels which is in this byte.
E4E5 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.
E4E6 LD (BC),A Store the byte and move on to the next.
E4E7 INC BC
E4E8 INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
E4E9 LD L,E
E4EA LD A,(BC)
E4EB CPL Clear the screen bits under the part of the mask which has moved into it.
E4EC OR (HL)
E4ED CPL
E4EE LD L,D Add the part of the pixels which has moved into it.
E4EF OR (HL)
E4F0 DEC H Point H back at the first table.
The jump starts here for three columns.
DrawShiftedColumns_Three E4F1 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
E4F2 POP DE
E4F3 LD L,E Clear the screen bits under the part of the mask which is in this byte.
E4F4 OR (HL)
E4F5 CPL
E4F6 LD L,D Add the part of the pixels which is in this byte.
E4F7 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.
E4F8 LD (BC),A Store the byte and move on to the next.
E4F9 INC BC
E4FA INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
E4FB LD L,E
E4FC LD A,(BC)
E4FD CPL Clear the screen bits under the part of the mask which has moved into it.
E4FE OR (HL)
E4FF CPL
E500 LD L,D Add the part of the pixels which has moved into it.
E501 OR (HL)
E502 DEC H Point H back at the first table.
The jump starts here for two columns.
DrawShiftedColumns_Two E503 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
E504 POP DE
E505 LD L,E Clear the screen bits under the part of the mask which is in this byte.
E506 OR (HL)
E507 CPL
E508 LD L,D Add the part of the pixels which is in this byte.
E509 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.
E50A LD (BC),A Store the byte and move on to the next.
E50B INC BC
E50C INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
E50D LD L,E
E50E LD A,(BC)
E50F CPL Clear the screen bits under the part of the mask which has moved into it.
E510 OR (HL)
E511 CPL
E512 LD L,D Add the part of the pixels which has moved into it.
E513 OR (HL)
E514 DEC H Point H back at the first table.
The jump starts here for one column.
DrawShiftedColumns_One E515 CPL Invert the screen byte, and fetch the mask into E and the pixels into D.
E516 POP DE
E517 LD L,E Clear the screen bits under the part of the mask which is in this byte.
E518 OR (HL)
E519 CPL
E51A LD L,D Add the part of the pixels which is in this byte.
E51B 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.
E51C LD (BC),A Store the byte and move on to the next.
E51D INC BC
E51E INC H Point H at the table for the bits which move into the next byte, and fetch that screen byte.
E51F LD L,E
E520 LD A,(BC)
E521 CPL Clear the screen bits under the part of the mask which has moved into it.
E522 OR (HL)
E523 CPL
E524 LD L,D Add the part of the pixels which has moved into it.
E525 OR (HL)
E526 DEC H Point H back at the first table.
DrawShiftedColumns_Last E527 LD (BC),A Put the part of the last character that is left over in the screen buffer.
View the equivalent code in;
Prev: E4C9 Up: Map Next: E528