Prev: F48E Up: Map Next: F50D
F490: Drawing Fill
Used by the routine at Drawing.
Flood-fills from the pen and stores the ink at F60B.
DrawingFill F490 LD ($F60B),A Store the ink, save the pen and the picture pointer, and push the B0 end marker.
F493 PUSH DE
F494 PUSH HL
F495 LD HL,$00B0
F498 PUSH HL Save the end marker and read the pixel under the pen.
DrawingFill_0 F499 CALL KeepOnlyBitsThatAreSet
F49C JR NZ,DrawingFill_Next Go to DrawingFill_Next if the pixel under the pen is already set.
F49E CALL StepPenLeft Step the pen left and try that pixel again until the left edge.
F4A1 JR NZ,DrawingFill_0
F4A3 JR DrawingFill_RecordDrawingPen No set pixel to the left, so start filling from DrawingFill_RecordDrawingPen.
Plot this pixel and step the pen right.
DrawingFill_Next F4A5 CALL PlotPixel Plot this pixel, then step the pen right.
F4A8 CALL StepPenRight
DrawingFill_RecordDrawingPen F4AB LD HL,$0000 Clear the two bytes that remember a seed.
F4AE LD ($F48E),HL
DrawingFill_Loop F4B1 CALL StepPenUp Go to DrawingFill_DrawingPenStep if the pen is already at the top edge.
F4B4 LD A,$00
F4B6 JR Z,DrawingFill_DrawingPenStep
F4B8 CALL KeepOnlyBitsThatAreSet Jump ahead to DrawingFill_StepPen if the pixel under the pen is already set.
F4BB LD A,$00
F4BD JR NZ,DrawingFill_StepPen
F4BF LD A,($F48E) Jump to DrawingFill_StepPen if a seed is already saved for this row.
F4C2 AND A
F4C3 JR NZ,DrawingFill_StepPen
F4C5 PUSH DE Save this spot as a seed and note it in A.
F4C6 LD A,$01
DrawingFill_StepPen F4C8 PUSH AF Save that note, step the pen down.
F4C9 CALL StepPenDown
F4CC POP AF Restore the note from the stack.
DrawingFill_DrawingPenStep F4CD LD ($F48E),A Store the note and step the pen down.
F4D0 CALL StepPenDown
F4D3 LD A,$00 Go to DrawingFill_DrawingPenDrawing, with A=00 if the pen could not step down.
F4D5 JR Z,DrawingFill_DrawingPenDrawing
F4D7 CALL KeepOnlyBitsThatAreSet Jump ahead to DrawingFill_StepPenUp if the pixel under the pen is already set.
F4DA LD A,$00
F4DC JR NZ,DrawingFill_StepPenUp
F4DE LD A,($F48F) Jump to DrawingFill_StepPenUp if a seed is already saved for this row.
F4E1 AND A
F4E2 JR NZ,DrawingFill_StepPenUp
F4E4 PUSH DE Save this spot as a seed and note it in A.
F4E5 LD A,$01
DrawingFill_StepPenUp F4E7 PUSH AF Save the note, step the pen up.
F4E8 CALL StepPenUp
F4EB POP AF Restore the note from the stack.
DrawingFill_DrawingPenDrawing F4EC LD ($F48F),A Store the note in the other pen byte and plot this pixel.
F4EF CALL PlotPixel
F4F2 CALL StepPenRight Go to DrawingFill_ByteMatchesMarker if the pen is already at the right edge.
F4F5 JR Z,DrawingFill_ByteMatchesMarker
F4F7 CALL KeepOnlyBitsThatAreSet Jump back to DrawingFill_Loop if the pixel under the pen is clear.
F4FA JR Z,DrawingFill_Loop
F4FC CALL PlotPixel Plot this pixel.
DrawingFill_ByteMatchesMarker F4FF POP DE Take the next seed off the stack, and go back to DrawingFill_0 until the B0 end marker, pushed at the start of the fill, comes off.
F500 LD A,E
F501 CP $B0
F503 JR NZ,DrawingFill_0
F505 LD A,$00 Clear the drawing ink.
F507 LD ($F60B),A
F50A POP HL Restore the picture pointer and the pen from the stack.
F50B POP DE
F50C RET Return.
Prev: F48E Up: Map Next: F50D