Prev: 48957 Up: Map Next: 49067
49027: Fill Window
Fills a rectangle of the screen buffer, or of the attribute buffer, with a byte. The rows of the rectangle are 32 bytes apart. The loop is unrolled into eight stores, and the code jumps into the middle of them to store only as many bytes as the width of the rectangle (which can be no more than eight): the number of stores to skip is worked out and written into the operand of the jump at FillWindow_Line.
Input
A Byte to fill the rectangle with
B Width of the rectangle in bytes
C Height of the rectangle in lines
HL Address of the first byte
Work out how many stores to skip.
FillWindow 49027 PUSH AF Stash the byte on the stack.
49028 LD A,B Fetch the width.
49029 NEG Make it negative.
49031 AND %00000111 Keep only bits 0 to 2.
49033 ADD A,A Multiply it by two.
49034 LD (49046),A Write the offset to 49046.
49037 LD A,32 Set A to 32.
49039 SUB B Subtract the width.
49040 LD E,A Keep it in E.
49041 LD D,0 Set D to 0.
49043 LD B,C Set B to the height.
49044 POP AF Restore the byte from the stack.
Fill one line, then step to the next.
FillWindow_Line 49045 JR FillWindow_Line Jump into the stores.
49047 LD (HL),A Store the byte.
49048 INC HL Move on to the next byte.
49049 LD (HL),A Store the byte.
49050 INC HL Move on to the next byte.
49051 LD (HL),A Store the byte.
49052 INC HL Move on to the next byte.
49053 LD (HL),A Store the byte.
49054 INC HL Move on to the next byte.
49055 LD (HL),A Store the byte.
49056 INC HL Move on to the next byte.
49057 LD (HL),A Store the byte.
49058 INC HL Move on to the next byte.
49059 LD (HL),A Store the byte.
49060 INC HL Move on to the next byte.
49061 LD (HL),A Store the byte.
49062 INC HL Move on to the next byte.
49063 ADD HL,DE Move on to the start of the next line.
49064 DJNZ FillWindow_Line Jump to FillWindow_Line until all of the lines have been filled.
49066 RET Return.
Prev: 48957 Up: Map Next: 49067