Kickstart floppy image on the ZX Spectrum (Next)

Recently, I came across a sort of “competition” on the Retro Programming by RetroCampus Facebook group, in which members were posting reproductions, coded in BASIC for 8-bit computers, of the iconic “insert Workbench floppy” image shown by Amiga‘s Kickstart at the computer boot.

Deepening the topic, I learned that this image not a bitmap, as I would have expected; instead it is a vector image, drawn on the screen using the simple algorithm described in this article:

  • Read the image data, 2 bytes at a time
  • If both bytes are 255 (0xFF), stop.
  • If the first byte is 255 and the second is not 255, start drawing a polyline using the color specified in the second byte.
    All subsequent pairs of bytes will be the x, y coordinates of the vertices of the line.
  • If the first byte is 254 (0xFE), fill an area with the color specified in the second byte, starting from the point whose x, y coordinates correspond to the next pair of bytes.

The choice of vector graphics was probably dictated by storage space limitations in the Kickstart ROM.

The simplicity of the algorithm has therefore allowed the proliferation of implementations in BASIC language on several home computers, such as Commodore 64/128/16 and Sinclair ZX Spectrum, using the original image data from the the Kickstart code.

So, I couldn’t help coding my own version, obviously for the ZX Spectrum. Here is the listing; the image data starts at line 1000:

10 CLS
20 RESTORE 1000
30 READ X,Y
40 IF X=255 AND Y=255 THEN STOP
50 IF X=255 THEN READ X0,Y0: PLOT X0,175-Y0: GO TO 30
60 IF X=254 THEN READ X,Y: GO TO 30
70 DRAW X-X0, Y0-Y: LET X0=X: LET Y0=Y
80 GO TO 30
1000 DATA 255, 1, 35, 11, 58, 11, 58, 33, 113, 33, 113, 11, 125, 11, 136, 22, 136, 94, 127, 94, 127, 56, 64, 56
1001 DATA 62, 54, 53, 54, 52, 56, 45, 56, 45, 65, 35, 72, 35, 11, 254, 2, 37, 69, 255, 1, 33, 72, 33, 10
1002 DATA 126, 10, 138, 22, 138, 95, 86, 95, 86, 100, 82, 108, 78, 113, 74, 116, 68, 125, 60, 129, 60, 140, 10, 140
1003 DATA 10, 109, 9, 109, 9, 81, 13, 75, 20, 69, 21, 65, 25, 58, 30, 55, 33, 54, 33, 54, 30, 56, 26, 58
1004 DATA 22, 65, 21, 69, 14, 75, 10, 81, 10, 108, 11, 109, 11, 139, 40, 139, 40, 118, 48, 118, 52, 114, 52, 95
1005 DATA 50, 92, 50, 82, 65, 69, 65, 57, 62, 55, 59, 55, 62, 58, 62, 65, 61, 66, 54, 66, 51, 63, 42, 70
1006 DATA 30, 76, 18, 85, 18, 84, 30, 75, 26, 74, 23, 71, 26, 73, 30, 74, 33, 72, 255, 1, 50, 61, 52, 54
1007 DATA 60, 55, 61, 58, 61, 65, 54, 65, 50, 61, 255, 1, 51, 92, 51, 82, 66, 69, 66, 57, 125, 57, 125, 94
1008 DATA 52, 94, 51, 90, 255, 1, 60, 11, 111, 11, 111, 32, 60, 32, 60, 11, 255, 1, 96, 14, 107, 14, 107, 28
1009 DATA 96, 28, 96, 14, 254, 3, 62, 31, 255, 1, 98, 15, 105, 15, 105, 27, 98, 27, 98, 15, 254, 2, 99, 26
1010 DATA 255, 1, 47, 57, 50, 57, 50, 59, 47, 63, 47, 57, 255, 1, 41, 139, 41, 119, 48, 119, 53, 114, 53, 105
1011 DATA 57, 107, 65, 107, 65, 109, 69, 114, 73, 114, 73, 116, 67, 125, 59, 128, 59, 139, 41, 139, 255, 1, 53, 95
1012 DATA 53, 100, 58, 97, 53, 95, 255, 1, 57, 98, 53, 100, 53, 95, 74, 95, 64, 105, 63, 105, 65, 103, 60, 98
1013 DATA 57, 98, 255, 1, 78, 95, 85, 95, 85, 100, 81, 108, 78, 112, 73, 113, 70, 113, 67, 109, 67, 106, 78, 95
1014 DATA 255, 1, 68, 106, 68, 109, 70, 112, 72, 112, 76, 111, 77, 108, 73, 105, 68, 106, 255, 1, 54, 104, 62, 106
1015 DATA 64, 103, 60, 99, 57, 99, 54, 101, 54, 104, 255, 1, 126, 11, 137, 22, 137, 94, 254, 1, 34, 11, 254, 1
1016 DATA 59, 11, 254, 1, 97, 15, 254, 1, 106, 27, 254, 1, 112, 15, 254, 1, 126, 94, 254, 1, 75, 96, 254, 1
1017 DATA 46, 57, 255, 255

And here is the result:

Amiga Kickstart "Insert Workbench Floppy" image on the ZX Spectrum
Amiga Kickstart “Insert Workbench Floppy” image on the ZX Spectrum

Then, starting from this program, I made a ZX Spectrum Next version, taking advantage of the Layer 2 graphics mode. For the flood fill, I adapted the implementation, by an anonymous author, reported in the A Fast Well-Behaved Pattern Flood Fill article by Alvin Albrecht. The flood fill routine spans from line 1000 to 1050, while now the image data starts at line 2000:

10 GO SUB 1500
20 RESTORE 2000
30 READ X,Y
40 IF X=255 AND Y=255 THEN INK 1: PRINT AT 10,7;"NextZXOS";AT 22,0:STOP
50 IF X=255 THEN INK Y: READ X0,Y0: PLOT X0,Y0: GO TO 30
60 IF X=254 THEN INK Y: READ X,Y: LET FX=X: LET FY=Y: GO SUB 1000: GO TO 30
70 DRAW X-X0, Y-Y0: LET X0=X: LET Y0=Y
80 GO TO 30
1000 PLOT FX,FY
1010 POINT (FX+1),FY TO Z: IF Z=255 THEN LET FX=FX+1 : GO SUB 1000 : LET FX=FX-1
1020 POINT (FX-1),FY TO Z: IF Z=255 THEN LET FX=FX-1 : GO SUB 1000 : LET FX=FX+1
1030 POINT FX,(FY+1) TO Z: IF Z=255 THEN LET FY=FY+1 : GO SUB 1000 : LET FY=FY-1
1040 POINT FX,(FY-1) TO Z: IF Z=255 THEN LET FY=FY-1 : GO SUB 1000 : LET FY=FY+1
1050 RETURN
1500 REM ZX SPECTRUM NEXT INITIALIZATION
1510 RUN AT 3: LAYER 2,1: CLS: PALETTE DIM 9
1520 LAYER PALETTE 0,0,%@111111111
1530 LAYER PALETTE 0,1,%@000000000
1540 LAYER PALETTE 0,2,%@011011101
1550 LAYER PALETTE 0,3,%@101101101
1900 RETURN
2000 DATA 255, 1, 35, 11, 58, 11, 58, 33, 113, 33, 113, 11, 125, 11, 136, 22, 136, 94, 127, 94, 127, 56, 64, 56
2001 DATA 62, 54, 53, 54, 52, 56, 45, 56, 45, 65, 35, 72, 35, 11, 254, 2, 37, 69, 255, 1, 33, 72, 33, 10
2002 DATA 126, 10, 138, 22, 138, 95, 86, 95, 86, 100, 82, 108, 78, 113, 74, 116, 68, 125, 60, 129, 60, 140, 10, 140
2003 DATA 10, 109, 9, 109, 9, 81, 13, 75, 20, 69, 21, 65, 25, 58, 30, 55, 33, 54, 33, 54, 30, 56, 26, 58
2004 DATA 22, 65, 21, 69, 14, 75, 10, 81, 10, 108, 11, 109, 11, 139, 40, 139, 40, 118, 48, 118, 52, 114, 52, 95
2005 DATA 50, 92, 50, 82, 65, 69, 65, 57, 62, 55, 59, 55, 62, 58, 62, 65, 61, 66, 54, 66, 51, 63, 42, 70
2006 DATA 30, 76, 18, 85, 18, 84, 30, 75, 26, 74, 23, 71, 26, 73, 30, 74, 33, 72, 255, 1, 50, 61, 52, 54
2007 DATA 60, 55, 61, 58, 61, 65, 54, 65, 50, 61, 255, 1, 51, 92, 51, 82, 66, 69, 66, 57, 125, 57, 125, 94
2008 DATA 52, 94, 51, 90, 255, 1, 60, 11, 111, 11, 111, 32, 60, 32, 60, 11, 255, 1, 96, 14, 107, 14, 107, 28
2009 DATA 96, 28, 96, 14, 254, 3, 62, 31, 255, 1, 98, 15, 105, 15, 105, 27, 98, 27, 98, 15, 254, 2, 99, 26
2010 DATA 255, 1, 47, 57, 50, 57, 50, 59, 47, 63, 47, 57, 255, 1, 41, 139, 41, 119, 48, 119, 53, 114, 53, 105
2011 DATA 57, 107, 65, 107, 65, 109, 69, 114, 73, 114, 73, 116, 67, 125, 59, 128, 59, 139, 41, 139, 255, 1, 53, 95
2012 DATA 53, 100, 58, 97, 53, 95, 255, 1, 57, 98, 53, 100, 53, 95, 74, 95, 64, 105, 63, 105, 65, 103, 60, 98
2013 DATA 57, 98, 255, 1, 78, 95, 85, 95, 85, 100, 81, 108, 78, 112, 73, 113, 70, 113, 67, 109, 67, 106, 78, 95
2014 DATA 255, 1, 68, 106, 68, 109, 70, 112, 72, 112, 76, 111, 77, 108, 73, 105, 68, 106, 255, 1, 54, 104, 62, 106
2015 DATA 64, 103, 60, 99, 57, 99, 54, 101, 54, 104, 255, 1, 126, 11, 137, 22, 137, 94, 254, 1, 34, 11, 254, 1
2016 DATA 59, 11, 254, 1, 97, 15, 254, 1, 106, 27, 254, 1, 112, 15, 254, 1, 126, 94, 254, 1, 75, 96, 254, 1
2017 DATA 46, 57, 255, 255

The result is identical to the original Amiga picture:

Amiga Kickstart "Insert Workbench Floppy" image on the ZX Spectrum Next
Amiga Kickstart “Insert Workbench Floppy” image on the ZX Spectrum Next

You can try the ZX Spectrum version by yourself. Enjoy!

Leggi in Italiano

Leave a comment

Your email address will not be published. Required fields are marked *