Routines
| Prev: F48E | Up: Map | Next: F50D |
F490: Fill the area around the pen in colour A
|
A scan-line flood fill: the colour goes to F60B, seeds are kept on the stack (a $00B0 marker ends them), and each row is filled left and right, seeding the rows above and below (F48E/$F48F).
How it works:
1. Keep the colour at F60B and put a marker on the stack.
2. From the seed, go left until the pixel is set or the edge is reached, colouring as it goes.
3. Work along the lines above and below: the first clear pixel of each run of clear pixels is pushed as a seed for later.
4. Pop seeds and repeat until the marker is reached.
|
||||||||||||||
| F490 | LD ($F60B),A | Store A in "Fill pattern for the picture interpreter" (F60B) - The colour to fill with | ||||||||||||
| F493 | PUSH DE | Save DE on the stack | ||||||||||||
| F494 | PUSH HL | Save HL on the stack | ||||||||||||
| F495 | LD HL,$00B0 | Load HL with $00B0 - A marker on the stack ($00B0: no line has E = $B0) under the seeds | ||||||||||||
| F498 | PUSH HL | Save HL on the stack | ||||||||||||
| F499 | CALL $F50D | Call the routine "Is the pixel under the pen set? (NZ if so)" (F50D) - From the seed, go left (D - 1) while the pixel is clear... | ||||||||||||
| F49C | JR NZ,$F4A5 | If the zero flag is clear, skip ahead to F4A5 | ||||||||||||
| F49E | CALL $F565 | Call F565 (inside "Move the pen one pixel (Z when it would...") | ||||||||||||
| F4A1 | JR NZ,$F499 | If the zero flag is clear, go back to F499 | ||||||||||||
| F4A3 | JR $F4AB | (stopped by the left edge, x = $80: start here) | ||||||||||||
| F4A5 | CALL $F5D2 | Call the routine "Plot the pen position in the current colour" (F5D2) - (stopped by a set pixel: colour it and step back right) | ||||||||||||
| F4A8 | CALL $F55E | Call F55E (inside "Move the pen one pixel (Z when it would...") | ||||||||||||
| F4AB | LD HL,$0000 | Load HL with $0000 - Nothing seeded yet on the lines either side | ||||||||||||
| F4AE | LD ($F48E),HL | Store HL in "Fill state" (F48E) | ||||||||||||
| F4B1 | CALL $F54A | Call the routine "Move the pen one pixel (Z when it would leave the..." (F54A) - Line E + 1 (none at the edge): a clear pixel starts a run there... | ||||||||||||
| F4B4 | LD A,$00 | Load A with $00 | ||||||||||||
| F4B6 | JR Z,$F4CD | If the zero flag is set, skip ahead to F4CD | ||||||||||||
| F4B8 | CALL $F50D | Call the routine "Is the pixel under the pen set? (NZ if so)" (F50D) | ||||||||||||
| F4BB | LD A,$00 | Load A with $00 | ||||||||||||
| F4BD | JR NZ,$F4C8 | If the zero flag is clear, skip ahead to F4C8 | ||||||||||||
| F4BF | LD A,($F48E) | Read "Fill state" (F48E) into A - ...and the first of each run is pushed as a seed (F48E) | ||||||||||||
| F4C2 | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||||
| F4C3 | JR NZ,$F4C8 | If A is not zero, skip ahead to F4C8 | ||||||||||||
| F4C5 | PUSH DE | Save DE on the stack | ||||||||||||
| F4C6 | LD A,$01 | Load A with $01 | ||||||||||||
| F4C8 | PUSH AF | Save AF on the stack | ||||||||||||
| F4C9 | CALL $F555 | Call F555 (inside "Move the pen one pixel (Z when it would...") - Back to the line | ||||||||||||
| F4CC | POP AF | Restore AF from the stack | ||||||||||||
| F4CD | LD ($F48E),A | Store A in "Fill state" (F48E) | ||||||||||||
| F4D0 | CALL $F555 | Call F555 (inside "Move the pen one pixel (Z when it would...") - The same for line E - 1 ($F48F) | ||||||||||||
| F4D3 | LD A,$00 | Load A with $00 | ||||||||||||
| F4D5 | JR Z,$F4EC | If the zero flag is set, skip ahead to F4EC | ||||||||||||
| F4D7 | CALL $F50D | Call the routine "Is the pixel under the pen set? (NZ if so)" (F50D) | ||||||||||||
| F4DA | LD A,$00 | Load A with $00 | ||||||||||||
| F4DC | JR NZ,$F4E7 | If the zero flag is clear, skip ahead to F4E7 | ||||||||||||
| F4DE | LD A,($F48F) | Read $F48F in "Fill state" into A | ||||||||||||
| F4E1 | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||||
| F4E2 | JR NZ,$F4E7 | If A is not zero, skip ahead to F4E7 | ||||||||||||
| F4E4 | PUSH DE | Save DE on the stack | ||||||||||||
| F4E5 | LD A,$01 | Load A with $01 | ||||||||||||
| F4E7 | PUSH AF | Save AF on the stack | ||||||||||||
| F4E8 | CALL $F54A | Call the routine "Move the pen one pixel (Z when it would leave the..." (F54A) - Back to the line | ||||||||||||
| F4EB | POP AF | Restore AF from the stack | ||||||||||||
| F4EC | LD ($F48F),A | Store A in $F48F in "Fill state" | ||||||||||||
| F4EF | CALL $F5D2 | Call the routine "Plot the pen position in the current colour" (F5D2) - Fill this pixel and move right | ||||||||||||
| F4F2 | CALL $F55E | Call F55E (inside "Move the pen one pixel (Z when it would...") | ||||||||||||
| F4F5 | JR Z,$F4FF | If the zero flag is set, skip ahead to F4FF | ||||||||||||
| F4F7 | CALL $F50D | Call the routine "Is the pixel under the pen set? (NZ if so)" (F50D) - Next pixel clear: carry on along the line | ||||||||||||
| F4FA | JR Z,$F4B1 | If the zero flag is set, go back to F4B1 | ||||||||||||
| F4FC | CALL $F5D2 | Set: colour it too, and the line is done | ||||||||||||
| F4FF | POP DE | Restore DE from the stack - Take the next seed, until the marker | ||||||||||||
| F500 | LD A,E | Copy E into A | ||||||||||||
| F501 | CP $B0 | Compare A with $B0 | ||||||||||||
| F503 | JR NZ,$F499 | If A differs from $B0, go back to F499 | ||||||||||||
| F505 | LD A,$00 | Load A with $00 - Restore the colour to 0 | ||||||||||||
| F507 | LD ($F60B),A | Store A in "Fill pattern for the picture interpreter" (F60B) | ||||||||||||
| F50A | POP HL | Restore HL from the stack | ||||||||||||
| F50B | POP DE | Restore DE from the stack | ||||||||||||
| F50C | RET | Return to the caller | ||||||||||||
| Prev: F48E | Up: Map | Next: F50D |