![]() |
Routines |
| Prev: 806F | Up: Map | Next: 80EE |
|
Used by the routine at RUN_PICTURE.
A boundary fill that uses the machine stack as its queue of pending points: $0080 is pushed first as a sentinel, seed points are PUSHed as they are found, and the loop ends when the POP brings the sentinel back -- an E of $80 cannot otherwise occur, since y only goes up to 127.
Every neighbour test goes through PIXEL_SET, which recomputes the screen address from scratch, and a pixel gets tested from each of the four directions it can be reached from. That, rather than the plotting, is what makes a large fill slow.
|
||||||||||
| FLOOD_FILL | 8071 | LD (PLOT_INK),A | Remember the ink for PLOT_PIXEL | |||||||
| 8074 | PUSH DE | |||||||||
| 8075 | PUSH HL | |||||||||
| 8076 | LD HL,$0080 | The sentinel that ends the fill | ||||||||
| 8079 | PUSH HL | |||||||||
| FLOOD_FILL_0 | 807A | CALL PIXEL_SET | ||||||||
| 807D | JR NZ,FLOOD_FILL_1 | |||||||||
| 807F | CALL DEC_X | |||||||||
| 8082 | JR NZ,FLOOD_FILL_0 | |||||||||
| 8084 | JR FLOOD_FILL_2 | |||||||||
| FLOOD_FILL_1 | 8086 | CALL PLOT_PIXEL | ||||||||
| 8089 | CALL INC_X | |||||||||
| FLOOD_FILL_2 | 808C | LD HL,$0000 | ||||||||
| 808F | LD (SEEDED_ABOVE),HL | |||||||||
| FLOOD_FILL_3 | 8092 | CALL INC_Y | ||||||||
| 8095 | LD A,$00 | |||||||||
| 8097 | JR Z,FLOOD_FILL_5 | |||||||||
| 8099 | CALL PIXEL_SET | |||||||||
| 809C | LD A,$00 | |||||||||
| 809E | JR NZ,FLOOD_FILL_4 | |||||||||
| 80A0 | LD A,(SEEDED_ABOVE) | |||||||||
| 80A3 | AND A | |||||||||
| 80A4 | JR NZ,FLOOD_FILL_4 | |||||||||
| 80A6 | PUSH DE | |||||||||
| 80A7 | LD A,$01 | |||||||||
| FLOOD_FILL_4 | 80A9 | PUSH AF | ||||||||
| 80AA | CALL DEC_Y | |||||||||
| 80AD | POP AF | |||||||||
| FLOOD_FILL_5 | 80AE | LD (SEEDED_ABOVE),A | ||||||||
| 80B1 | CALL DEC_Y | |||||||||
| 80B4 | LD A,$00 | |||||||||
| 80B6 | JR Z,FLOOD_FILL_7 | |||||||||
| 80B8 | CALL PIXEL_SET | |||||||||
| 80BB | LD A,$00 | |||||||||
| 80BD | JR NZ,FLOOD_FILL_6 | |||||||||
| 80BF | LD A,(SEEDED_BELOW) | |||||||||
| 80C2 | AND A | |||||||||
| 80C3 | JR NZ,FLOOD_FILL_6 | |||||||||
| 80C5 | PUSH DE | |||||||||
| 80C6 | LD A,$01 | |||||||||
| FLOOD_FILL_6 | 80C8 | PUSH AF | ||||||||
| 80C9 | CALL INC_Y | |||||||||
| 80CC | POP AF | |||||||||
| FLOOD_FILL_7 | 80CD | LD (SEEDED_BELOW),A | ||||||||
| 80D0 | CALL PLOT_PIXEL | |||||||||
| 80D3 | CALL INC_X | |||||||||
| 80D6 | JR Z,FLOOD_FILL_8 | |||||||||
| 80D8 | CALL PIXEL_SET | |||||||||
| 80DB | JR Z,FLOOD_FILL_3 | |||||||||
| 80DD | CALL PLOT_PIXEL | |||||||||
| FLOOD_FILL_8 | 80E0 | POP DE | Sentinel back off the stack: the fill is done | |||||||
| 80E1 | LD A,E | |||||||||
| 80E2 | CP $80 | |||||||||
| 80E4 | JR NZ,FLOOD_FILL_0 | |||||||||
| 80E6 | LD A,$00 | |||||||||
| 80E8 | LD (PLOT_INK),A | |||||||||
| 80EB | POP HL | |||||||||
| 80EC | POP DE | |||||||||
| 80ED | RET | |||||||||
| Prev: 806F | Up: Map | Next: 80EE |