![]() |
Routines |
| Prev: E734 | Up: Map | Next: E806 |
|
Used by the routine at FILL_WHOLE_BYTE.
The inner loop of the flood fill that the room codes $E6-$FF start (DO_ROOM_COMMAND) and FILL_NEXT_SEED feeds with runs to fill. It walks leftwards along one row from the right-hand end of an unfilled run until it meets a pixel that is already set in the clean copy of the screen (LOADING_TUNE, the fill's map of what bounds it and what it has done) or the left edge of the screen. Each pixel is set in the clean copy, so that the fill never comes back to it, and set or cleared on the screen from the texture: the texture replaces whatever was drawn there.
As it goes it watches the rows above and below. Where a clear pixel follows a set one there, a run opens, and its row and column are pushed on the machine stack for FILL_NEXT_SEED to fill later; bits 0 (above) and 1 (below) of E remember that a run is open, so that a long run is pushed once rather than at every pixel. A run in a row off the screen (above the top or below the bottom, where the pointers land in other memory) may be pushed too, and FILL_NEXT_SEED throws it away. When the mask in D moves into the next byte to the left, FILL_BYTE_TO_LEFT moves every pointer a byte left and FILL_WHOLE_BYTE may paint the whole byte at once.
Krumlinde's name (Fill_NextPixel). The entry at FILL_THIS_PIXEL is where FILL_NEXT_SEED starts a run.
|
||||||||||||||||||
| FILL_NEXT_PIXEL | E7B2 | LD A,C | the left edge of the screen ends the run: on to the next (FILL_NEXT_SEED) | |||||||||||||||
| E7B3 | AND A | |||||||||||||||||
| E7B4 | JP Z,FILL_NEXT_SEED | |||||||||||||||||
| E7B7 | DEC C | one pixel left; into the next byte when the mask wraps round | ||||||||||||||||
| E7B8 | RLC D | |||||||||||||||||
| E7BA | CALL C,FILL_BYTE_TO_LEFT | |||||||||||||||||
|
This entry point is used by the routine at FILL_NEXT_SEED.
|
||||||||||||||||||
| FILL_THIS_PIXEL | E7BD | LD HL,(STEP_AXES) | already set in the clean copy: the run ends here | |||||||||||||||
| E7C0 | LD A,D | |||||||||||||||||
| E7C1 | AND (HL) | |||||||||||||||||
| E7C2 | JP NZ,FILL_NEXT_SEED | |||||||||||||||||
| E7C5 | LD A,D | set it there, so that the fill never comes back | ||||||||||||||||
| E7C6 | OR (HL) | |||||||||||||||||
| E7C7 | LD (HL),A | |||||||||||||||||
| E7C8 | LD A,D | the screen's pixel: set where the texture has a 1, cleared where it has a 0 | ||||||||||||||||
| E7C9 | EXX | |||||||||||||||||
| E7CA | LD D,A | |||||||||||||||||
| E7CB | AND E | |||||||||||||||||
| E7CC | JR NZ,FILL_NEXT_PIXEL_0 | |||||||||||||||||
| E7CE | LD A,D | |||||||||||||||||
| E7CF | CPL | |||||||||||||||||
| E7D0 | AND (HL) | |||||||||||||||||
| E7D1 | JR FILL_NEXT_PIXEL_1 | |||||||||||||||||
| FILL_NEXT_PIXEL_0 | E7D3 | OR (HL) | ||||||||||||||||
| FILL_NEXT_PIXEL_1 | E7D4 | LD (HL),A | ||||||||||||||||
| E7D5 | EXX | the row above: is a run open there? | ||||||||||||||||
| E7D6 | LD HL,(WORK_RECORD) | |||||||||||||||||
| E7D9 | LD A,D | |||||||||||||||||
| E7DA | BIT 0,E | |||||||||||||||||
| E7DC | JR NZ,FILL_NEXT_PIXEL_2 | |||||||||||||||||
| E7DE | AND (HL) | no: a clear pixel above opens one; push its row and column | ||||||||||||||||
| E7DF | JR NZ,FILL_NEXT_PIXEL_3 | |||||||||||||||||
| E7E1 | INC B | |||||||||||||||||
| E7E2 | PUSH BC | |||||||||||||||||
| E7E3 | SET 0,E | |||||||||||||||||
| E7E5 | DEC B | |||||||||||||||||
| E7E6 | JR FILL_NEXT_PIXEL_3 | |||||||||||||||||
| FILL_NEXT_PIXEL_2 | E7E8 | AND (HL) | yes: a set pixel above closes it | |||||||||||||||
| E7E9 | JR Z,FILL_NEXT_PIXEL_3 | |||||||||||||||||
| E7EB | RES 0,E | |||||||||||||||||
| FILL_NEXT_PIXEL_3 | E7ED | LD HL,(WORK_HEADING) | the row below, the same way | |||||||||||||||
| E7F0 | LD A,D | |||||||||||||||||
| E7F1 | BIT 1,E | |||||||||||||||||
| E7F3 | JR NZ,FILL_NEXT_PIXEL_4 | |||||||||||||||||
| E7F5 | AND (HL) | none open: a clear pixel below opens one | ||||||||||||||||
| E7F6 | JR NZ,FILL_NEXT_PIXEL | |||||||||||||||||
| E7F8 | DEC B | |||||||||||||||||
| E7F9 | PUSH BC | |||||||||||||||||
| E7FA | SET 1,E | |||||||||||||||||
| E7FC | INC B | |||||||||||||||||
| E7FD | JR FILL_NEXT_PIXEL | |||||||||||||||||
| FILL_NEXT_PIXEL_4 | E7FF | AND (HL) | one open: a set pixel closes it | |||||||||||||||
| E800 | JR Z,FILL_NEXT_PIXEL | |||||||||||||||||
| E802 | RES 1,E | |||||||||||||||||
| E804 | JR FILL_NEXT_PIXEL | |||||||||||||||||
| Prev: E734 | Up: Map | Next: E806 |