Prev: BF3D Up: Map Next: BFAB
BF83: Fill Window
Fills a rectangle of the screen buffer, or of the attribute buffer, with a byte. The rows of the rectangle are 20 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 BF83 PUSH AF Stash the byte on the stack.
BF84 LD A,B Fetch the width.
BF85 NEG Make it negative.
BF87 AND %00000111 Keep only bits 0 to 2.
BF89 ADD A,A Multiply it by two.
BF8A LD ($BF96),A Write the offset to BF96.
BF8D LD A,$20 Set A to 20.
BF8F SUB B Subtract the width.
BF90 LD E,A Keep it in E.
BF91 LD D,$00 Set D to 00.
BF93 LD B,C Set B to the height.
BF94 POP AF Restore the byte from the stack.
Fill one line, then step to the next.
FillWindow_Line BF95 JR FillWindow_Line Jump into the stores.
BF97 LD (HL),A Store the byte.
BF98 INC HL Move on to the next byte.
BF99 LD (HL),A Store the byte.
BF9A INC HL Move on to the next byte.
BF9B LD (HL),A Store the byte.
BF9C INC HL Move on to the next byte.
BF9D LD (HL),A Store the byte.
BF9E INC HL Move on to the next byte.
BF9F LD (HL),A Store the byte.
BFA0 INC HL Move on to the next byte.
BFA1 LD (HL),A Store the byte.
BFA2 INC HL Move on to the next byte.
BFA3 LD (HL),A Store the byte.
BFA4 INC HL Move on to the next byte.
BFA5 LD (HL),A Store the byte.
BFA6 INC HL Move on to the next byte.
BFA7 ADD HL,DE Move on to the start of the next line.
BFA8 DJNZ FillWindow_Line Jump to FillWindow_Line until all of the lines have been filled.
BFAA RET Return.
Prev: BF3D Up: Map Next: BFAB