Prev: 62606 Up: Map Next: 62733
62608: Drawing Fill
Used by the routine at Drawing.
Flood-fills from the pen and stores the ink at 62987.
DrawingFill 62608 LD (62987),A Store the ink, save the pen and the picture pointer, and push the 176 end marker.
62611 PUSH DE
62612 PUSH HL
62613 LD HL,176
62616 PUSH HL Save the end marker and read the pixel under the pen.
DrawingFill_0 62617 CALL KeepOnlyBitsThatAreSet
62620 JR NZ,DrawingFill_Next Go to DrawingFill_Next if the pixel under the pen is already set.
62622 CALL StepPenLeft Step the pen left and try that pixel again until the left edge.
62625 JR NZ,DrawingFill_0
62627 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 62629 CALL PlotPixel Plot this pixel, then step the pen right.
62632 CALL StepPenRight
DrawingFill_RecordDrawingPen 62635 LD HL,0 Clear the two bytes that remember a seed.
62638 LD (62606),HL
DrawingFill_Loop 62641 CALL StepPenUp Go to DrawingFill_DrawingPenStep if the pen is already at the top edge.
62644 LD A,0
62646 JR Z,DrawingFill_DrawingPenStep
62648 CALL KeepOnlyBitsThatAreSet Jump ahead to DrawingFill_StepPen if the pixel under the pen is already set.
62651 LD A,0
62653 JR NZ,DrawingFill_StepPen
62655 LD A,(62606) Jump to DrawingFill_StepPen if a seed is already saved for this row.
62658 AND A
62659 JR NZ,DrawingFill_StepPen
62661 PUSH DE Save this spot as a seed and note it in A.
62662 LD A,1
DrawingFill_StepPen 62664 PUSH AF Save that note, step the pen down.
62665 CALL StepPenDown
62668 POP AF Restore the note from the stack.
DrawingFill_DrawingPenStep 62669 LD (62606),A Store the note and step the pen down.
62672 CALL StepPenDown
62675 LD A,0 Go to DrawingFill_DrawingPenDrawing, with A=0 if the pen could not step down.
62677 JR Z,DrawingFill_DrawingPenDrawing
62679 CALL KeepOnlyBitsThatAreSet Jump ahead to DrawingFill_StepPenUp if the pixel under the pen is already set.
62682 LD A,0
62684 JR NZ,DrawingFill_StepPenUp
62686 LD A,(62607) Jump to DrawingFill_StepPenUp if a seed is already saved for this row.
62689 AND A
62690 JR NZ,DrawingFill_StepPenUp
62692 PUSH DE Save this spot as a seed and note it in A.
62693 LD A,1
DrawingFill_StepPenUp 62695 PUSH AF Save the note, step the pen up.
62696 CALL StepPenUp
62699 POP AF Restore the note from the stack.
DrawingFill_DrawingPenDrawing 62700 LD (62607),A Store the note in the other pen byte and plot this pixel.
62703 CALL PlotPixel
62706 CALL StepPenRight Go to DrawingFill_ByteMatchesMarker if the pen is already at the right edge.
62709 JR Z,DrawingFill_ByteMatchesMarker
62711 CALL KeepOnlyBitsThatAreSet Jump back to DrawingFill_Loop if the pixel under the pen is clear.
62714 JR Z,DrawingFill_Loop
62716 CALL PlotPixel Plot this pixel.
DrawingFill_ByteMatchesMarker 62719 POP DE Take the next seed off the stack, and go back to DrawingFill_0 until the 176 end marker, pushed at the start of the fill, comes off.
62720 LD A,E
62721 CP 176
62723 JR NZ,DrawingFill_0
62725 LD A,0 Clear the drawing ink.
62727 LD (62987),A
62730 POP HL Restore the picture pointer and the pen from the stack.
62731 POP DE
62732 RET Return.
Prev: 62606 Up: Map Next: 62733