this brings back memories (Amiga hand logo code) with a working flood fill

Started by braxtonrivers, July 09, 2020, 01:24:27

Previous topic - Next topic

braxtonrivers

I found this yesterday, wow it sure brings back fond memories, I had no idea that the early Amiga 1.x boot screens were hand coded.

here is a BlitzMax-NG version, hand coded in as few bytes as possible, pretty impressive for the time.

Edit:
apologies I forgot to put where I originally found it, it was quite an interesting read, this is where I found the embedded data and description method used for the vector drawing.
https://retrocomputing.stackexchange.com/questions/13897/why-was-the-kickstart-1-x-insert-floppy-graphic-so-bad

Edit:
Added PixmapFill so it should look a little more as we all remember, credits go to Curtastic for his Small Fast Easy Flood Fill which was converted from BlitzBasic to BlitzMax-NG, the others would not fill correctly whereas this appears to work without issue.
https://www.mojolabs.nz/codearcs.php?code=314


SuperStrict

Framework brl.glmax2d

Local Data:Int[]=[$FF,$01,$23,$0B,$3A,$0B,$3A,$21,$71,$21,$71,$0B,$7D,$0B,$88,$16,$88,$5E,$7F,$5E,$7F,$38,$40,$38, ..
$3E,$36,$35,$36,$34,$38,$2D,$38,$2D,$41,$23,$48,$23,$0B,$FE,$02,$25,$45,$FF,$01,$21,$48,$21,$0A, ..
$7E,$0A,$8A,$16,$8A,$5F,$56,$5F,$56,$64,$52,$6C,$4E,$71,$4A,$74,$44,$7D,$3C,$81,$3C,$8C,$0A,$8C, ..
$0A,$6D,$09,$6D,$09,$51,$0D,$4B,$14,$45,$15,$41,$19,$3A,$1E,$37,$21,$36,$21,$36,$1E,$38,$1A,$3A, ..
$16,$41,$15,$45,$0E,$4B,$0A,$51,$0A,$6C,$0B,$6D,$0B,$8B,$28,$8B,$28,$76,$30,$76,$34,$72,$34,$5F, ..
$32,$5C,$32,$52,$41,$45,$41,$39,$3E,$37,$3B,$37,$3E,$3A,$3E,$41,$3D,$42,$36,$42,$33,$3F,$2A,$46, ..
$1E,$4C,$12,$55,$12,$54,$1E,$4B,$1A,$4A,$17,$47,$1A,$49,$1E,$4A,$21,$48,$FF,$01,$32,$3D,$34,$36, ..
$3C,$37,$3D,$3A,$3D,$41,$36,$41,$32,$3D,$FF,$01,$33,$5C,$33,$52,$42,$45,$42,$39,$7D,$39,$7D,$5E, ..
$34,$5E,$33,$5A,$FF,$01,$3C,$0B,$6F,$0B,$6F,$20,$3C,$20,$3C,$0B,$FF,$01,$60,$0E,$6B,$0E,$6B,$1C, ..
$60,$1C,$60,$0E,$FE,$03,$3E,$1F,$FF,$01,$62,$0F,$69,$0F,$69,$1B,$62,$1B,$62,$0F,$FE,$02,$63,$1A, ..
$FF,$01,$2F,$39,$32,$39,$32,$3B,$2F,$3F,$2F,$39,$FF,$01,$29,$8B,$29,$77,$30,$77,$35,$72,$35,$69, ..
$39,$6B,$41,$6B,$41,$6D,$45,$72,$49,$72,$49,$74,$43,$7D,$3B,$80,$3B,$8B,$29,$8B,$FF,$01,$35,$5F, ..
$35,$64,$3A,$61,$35,$5F,$FF,$01,$39,$62,$35,$64,$35,$5F,$4A,$5F,$40,$69,$3F,$69,$41,$67,$3C,$62, ..
$39,$62,$FF,$01,$4E,$5F,$55,$5F,$55,$64,$51,$6C,$4E,$70,$49,$71,$46,$71,$43,$6D,$43,$6A,$4E,$5F, ..
$FF,$01,$44,$6A,$44,$6D,$46,$70,$48,$70,$4C,$6F,$4D,$6C,$49,$69,$44,$6A,$FF,$01,$36,$68,$3E,$6A, ..
$40,$67,$3C,$63,$39,$63,$36,$65,$36,$68,$FF,$01,$7E,$0B,$89,$16,$89,$5E,$FE,$01,$22,$0B,$FE,$01, ..
$3B,$0B,$FE,$01,$61,$0F,$FE,$01,$6A,$1B,$FE,$01,$70,$0F,$FE,$01,$7E,$5E,$FE,$01,$4B,$60,$FE,$01, ..
$2E,$39,$FF,$FF]

Graphics 800,800
SetClsColor $FF,$FF,$FF
Cls

Global DefAmigaOS13Palette:Int[]=[$FFFFFF,$0,$7777CC,$BBBBBB]

Local AmigaHand:TPixmap

Local offsetx:Int=70,offsety:Int=40

Local c:Int=0,b1:Int,b2:Int,scale:Float=4.5
Local x:Int=-1,y:Int=-1,oldx:Int=-1,oldy:Int=-1
Repeat
b1=Data[c];c:+1;b2=Data[c];c:+1
If b1=$FF And b2=$FF Then Exit
If b1=$FF
x=-1;y=-1;oldx=-1;oldy=-1
SetColor ((DefAmigaOS13Palette[b2] Shr 16) & $FF),((DefAmigaOS13Palette[b2] Shr 8) & $FF),(DefAmigaOS13Palette[b2] & $FF)
ElseIf b1=$FE
x=Data[c];c:+1;y=Data[c];c:+1
AmigaHand=PixmapFill(Int(offsetx+(x*scale)),Int(offsety+(y*scale)),DefAmigaOS13Palette[b2])
DrawPixmap AmigaHand,0,0
x=-1;y=-1;oldx=-1;oldy=-1
Else
If x<>-1 Then oldx=x
If y<>-1 Then oldy=y
x=b1;y=b2
If x<>-1 And y<>-1 And oldx<>-1 And oldy<>-1 Then DrawLine offsetx+(oldx*scale),offsety+(oldy*scale),offsetx+(x*scale),offsety+(y*scale)
EndIf
Until c>Data.length

Flip
WaitKey
End

Type TPixel
Field x:Int
Field y:Int
End Type

Function PixmapFill:TPixmap(StartX:Int,StartY:Int,FillColorRGB:Int,PixmapToFill:TPixmap=Null)
Local PixelList:TList=New TList
Local NewX:Int,NewY:Int
If Not PixmapToFill Then PixmapToFill=GrabPixmap(0,0,GraphicsWidth(),GraphicsHeight())
Local MaxPixX:Int=PixmapWidth(PixmapToFill),MaxPixY:Int=PixmapHeight(PixmapToFill)
If StartX>=0 And StartY>=0 And StartX<MaxPixX And StartY<MaxPixY Then
Local FillOverRGB:Int=ReadPixel(PixmapToFill,StartX,StartY) & $FFFFFF
Local newPixel:TPixel=New TPixel
NewPixel.x=StartX
NewPixel.y=StartY
ListAddLast PixelList,NewPixel
WritePixel PixmapToFill,StartX,StartY,FillColorRGB
FillColorRGB=ReadPixel(PixmapToFill,StartX,StartY)
If FillOverRGB<>FillColorRGB Then
Local FillMap:Int[MaxPixX,MaxPixY]
FillMap[StartX,StartY]=1
Repeat
For Local i:TPixel=EachIn PixelList
For Local dir:Int=0 To 7
NewX=i.x+((dir=0)-(dir=2))-((dir=4)-(dir=6))
NewY=i.y+((dir=1)-(dir=3))-((dir=5)-(dir=7))
If NewX>=0 And NewY>=0 And NewX<MaxPixX And NewY<MaxPixY Then
If FillMap[NewX,NewY]=0 Then
FillMap[NewX,NewY]=1
If ReadPixel(PixmapToFill,NewX,NewY) & $FFFFFF=FillOverRGB Then
WritePixel PixmapToFill,NewX,NewY,FillcolorRGB
Local NewPixel:TPIxel=New TPixel
NewPixel.x=NewX
NewPixel.y=NewY
ListAddLast PixelList,NewPixel
EndIf
EndIf
EndIf
Next
ListRemoveFirst PixelList
Next
Until Not ListGetFirst(PixelList)
EndIf
EndIf
Return PixmapToFill
End Function


Juiceter


Henri

Interesting information and a nice backstory. The link helped :-)

For those interested I picked up a youtube link demonstrating the drawing process along with Amos code:



-Henri
- Got 01100011 problems, but the bit ain't 00000001

braxtonrivers

#3
Thanks Henri, the video was very interesting, yes I have to agree adding the link does help, and who doesn't like a good back story!

Finally got around to adding a working PixmapFill thanks to Curtastic.