Well here's "my" flood-fill...(I didn't write it of course...it's translated from an old BASIC book, which explains the GOSUBs and GOTOs...)

DEFINT A-Z

'$DYNAMIC

DECLARE SUB Fill (FillX, FillY, CurrentColor)

CONST FillBuffer = 1000 'Increase for more complicated fills

CONST MinX = 0

CONST MinY = 0

CONST MaxX = 319

CONST MaxY = 199

SCREEN 13

CIRCLE (100, 50), 40

LINE (50, 50)-(200, 150), 4, B

Fill 50, 40, 1

Fill 100, 40, 9

Fill 60, 60, 2

Fill 100, 60, 12

SUB Fill (FillX, FillY, CurrentColor)

IF FillX < MinX OR FillX > MaxX THEN EXIT SUB

IF FillY < MinY OR FillY > MaxY THEN EXIT SUB

DIM Refs(FillBuffer, 1)

x2 = 0

y2 = 0

x3 = 0

y3 = 0

v = 0

v1 = 0

v2 = 0

v3 = 0

v4 = 0

cb = POINT(FillX, FillY)

GOSUB FillLine

IF v2 = 0 THEN EXIT SUB

v4 = 0

FillSomeMore:

FillX = Refs(v4, 0)

FillY = Refs(v4, 1)

GOSUB FillLine

v4 = v4 + 1

IF v4 > (v2 - 1) THEN

v2 = 0

EXIT SUB

ELSE

GOTO FillSomeMore

END IF

FillLine:

v = POINT(FillX, FillY)

IF v = CurrentColor THEN RETURN

IF v <> cb AND v <> CurrentColor THEN RETURN

v1 = 0: v3 = 0

x3 = FillX

y3 = FillY

GOTO PlotA

Check:

IF v <> cb AND v <> CurrentColor THEN

GOTO GetB

ELSE

GOTO PlotA

END IF

PlotA:

PSET (FillX, FillY), CurrentColor

GOSUB LookUp

GOSUB LookDown

FillX = FillX + 1

IF FillX > MaxX THEN

GOTO GetB

ELSE

GOTO GetA

END IF

GetA:

v = POINT(FillX, FillY)

GOTO Check

GetB:

FillX = x3: FillY = y3

v = POINT(FillX, FillY)

PlotB:

IF v <> cb AND v <> CurrentColor THEN RETURN

PSET (FillX, FillY), CurrentColor

GOSUB LookUp

GOSUB LookDown

FillX = FillX - 1

IF FillX < MinX THEN RETURN

v = POINT(FillX, FillY)

GOTO PlotB

LookUp:

IF FillY < MinY + 1 THEN RETURN

x2 = FillX

y2 = FillY - 1

v = POINT(x2, y2)

IF v <> cb AND v <> CurrentColor THEN

v1 = 0

RETURN

END IF

IF v = CurrentColor THEN RETURN

IF v1 = 1 THEN RETURN

Refs(v2, 0) = x2

Refs(v2, 1) = y2

v2 = v2 + 1

v1 = 1

RETURN

LookDown:

IF FillY > MaxY - 1 THEN RETURN

x2 = FillX

y2 = FillY + 1

v = POINT(x2, y2)

IF v <> cb AND v <> CurrentColor THEN

v3 = 0

RETURN

END IF

IF v = CurrentColor THEN RETURN

IF v3 = 1 THEN RETURN

Refs(v2, 0) = x2

Refs(v2, 1) = y2

v2 = v2 + 1

v3 = 1

RETURN

END SUB