Extreme Size-coding the Applesoft BASIC version of Hellmood's Starpath Intro





Details

Hellmood released an amazing 64-byte DOS intro "Starpath" at the Lovebyte 2025 size-coding demoparty. It makes an animated ray-marched path against a gradient sky with stars. All in 64 bytes.

I wanted to see if I could port this to Applesoft BASIC (Apple II), and what's more, have it fit in a Tweet (roughly 280 bytes) in honor of the sadly no-longer-existent AppleIIBasicBot.

Note this takes roughly 32 minutes to draw a frame on a stock Apple II (1MHz 6502). I do have faster assembly language versions that take roughly 8 seconds per frame but I'm not releasing those yet.

The Optimization Progression

Version 1 -- Direct Conversion of Hellmood's Code

This one is 630 bytes. Some notes:
0 GOTO 8:SPEED=$)%DEL$LRUSR:SPEED=$)%DEL$LRUSR
8 POKE 2068,9:DIM CL(32):FOR I=0 TO 31:READ CL(I):NEXT:GR:POKE 49234,0
30 FOR Y=0 TO 47:FOR X=0 TO 39:D=14
40 YP=Y*4*D:T=(X*6)-D:IF T>=0 THEN 70
50 C=11:A=(X*6)+YP
55 IF A>256 THEN A=A-256:GOTO 55
57 IF A<6 THEN 95
60 C=(C*16)+((Y*4)/16):C=C-160:GOTO 95
70 XP=T*D:POKE 2067,XP/256:POKE 2069,YP/256:CALL 2066:T=PEEK(36)
75 POKE2057,T:POKE2059,D+F:CALL 2056:C=PEEK(36):D=D+1
80 IF C<16 THEN 40
90 C=C-16
95 COLOR=CL(C):PLOT X,Y:NEXT X,Y:F=F+1:GOTO 30
97 DATA 0,5,0,5,5,5,10,10,5,5,10,10,7,7,15,15,1,2,1,2,3,9,3,9,13,12,13,12,4,4,4,4
100 REM APPLE II VERSION OF HELLMOOD'S 64B STARPATH

Version 2 -- First Size Optimization Pass

This next pass did some typical BASIC size optimization tricks.

Note that optimizing for overall filesize isn't the same as the on-disk filesize as that is tokenized (with keywords generally taking 1 byte). For this project I am going for overall filesize. This version is 444 bytes.

Things done here: Other tricks not used here:
0GOTO1:SPEED=$)%DEL$LRUSR:SPEED=$)%DEL$LRUSR
1P=2060:POKEP+8,9:DIML(16):FORI=0TO15:READL(I):NEXT:GR:POKE49234,0
2FORY=0TO47:FORX=0TO39:D=14
3Z=Y*4*D:T=(X*6)-D:IFT<0THENC=31:A=(X*6)+Z:GOTO7
4POKEP+7,(T*D)/256:POKEP+9,Z/256:CALLP+6:T=PEEK(36)
5POKEP-3,T:POKEP-1,D+F:CALLP-4:C=PEEK(36):D=D+1:IFC<16THEN3
6GOTO9:DATA0,5,10,5,10,7,15,15,2,1,3,9,13,12,4,4
7IFA>256THENA=A-256:GOTO7
8IFA>6THENC=(Y/4)+32
9COLOR=L((C-16)/2):PLOTX,Y:NEXTX,Y:F=F+1:GOTO2

Version 3 -- Optimization Pass 2

This version is 366 bytes. Changes:
0GOTO1:ONERR$)%)%DEL$LRUSRAFKFKHPPCBDJNM
1P=2056:POKEP+2,9:DIML(16):FORI=0TO14:L(I)=PEEK(P+I+11)-65:NEXT:GR:POKE49234,0
2FORY=0TO47:FORX=0TO39:D=I
3Z=Y*4*D:T=X*6-D:IFT<0THENC=31:A=X*6+Z:GOTO7
4POKE36,T*D/256:POKEP+3,Z/256:POKEP+5,D+F:CALLP:C=PEEK(36):D=D+1:IFC<16THEN3
6GOTO9
7IFA>256THENA=A-256:GOTO7
8IFA>6THENC=Y/4+32
9COLOR=L(C/2-8):PLOTX,Y:NEXTX,Y:F=F+1:GOTO2

Version 3 -- More extreme Optimization

This version is 306 bytes. Changes:
0P=2282:V=256:POKEP+5,9:GR
1FORY=0TO47:FORX=0TO39:D=14
2Z=Y*4*D:T=X*6-D:IFT<0THENC=31:A=X*6+Z:GOTO6
3POKE36,T*D/V:POKEP+6,Z/V:POKEP+8,D+F:CALLP:C=POS(0):D=D+1:IFC<16THEN2
4GOTO8
5A=A-V
6IFA>VTHEN5
7IFA>6THENC=Y/4+32
8COLOR=PEEK(C/2+P+6):PLOTX,Y:NEXTX,Y:F=F+1:GOTO1
9,RTAB(ONERR$)%)%DEL$LRUSR@EJEJGOOBACIML

Almost Final Version -- Fits in a Tweet

This is actually 281 bytes, but due to how twitter handles whitespace it actually will fit in a tweet. Do note (to be pedantic) the AppleIIbot had directives to specify how long to run before recording a movie, and these take up room we don't have. Also I think it maxed out at 99second delay and we'd need much longer that that to draw a full frame.

Also note that while this looks nice for a single frame, it's not an exact repo of the intro (due to the stars, as I'll explain later).

0P=2250:V=256:GR
1R=RND(-1):FORY=0TO47:FORX=0TO39:D=14
2T=X*6-D:IFT<0THEN7
3POKE36,T*D/V:POKEP+8,Y*4*D/V:POKEP+10,D+F:CALLP:C=POS(0):D=D+1:IFC<16THEN2
4GOTO8
7C=31:IFRND(1)*V>6THENC=Y/4+32
8COLOR=PEEK(C/2+P+9):PLOTX,Y:NEXTX,Y:F=F+1:GOTO1ONERR$,
2344))%DEL$,RTAB(LPUSRJEJGOOBACIML

Final Version -- Fits in a Tweet + Stable Stars

Final version, 277 bytes (234 bytes tokenized):
0P=2247:V=256:GR
1FORY=0TO47:FORX=0TO39:D=14
2T=X*6-D:IFT<0THEN7
3POKE36,T*D/V:POKEP+8,Y*4*D/V:POKEP+10,D+F:CALLP:C=POS(0):D=D+1:IFC<16THEN2
4GOTO8
7C=31:IFPEEK(X*Y+57E3)>2THENC=Y/4+32
8COLOR=PEEK(C/2+P+9):PLOTX,Y:NEXTX,Y:F=F+1:GOTO1ONERR$,
2344))%DEL$,RTAB(LPUSRJEJGOOBACIML

Failed Attempts

While doing this I tried a bunch of other things that were excessively clever but failed to improve the size:
Disk image: starpath.dsk (140k)
Other VMW Software Demos
Other Apple2 Projects
Back to the VMW Software Productions Page