Very clever I must say Now we have 42 free characters to use for another feature.
With 42 characters we can easily do any of your suggestions maybe except the middle line (but it would be really cool to get it in there).
I used 11 precious characters to make the mountains taller. It looks a bit better I think:
1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:V=14:SCREEN2,3,0:FORX=0TO2:FORY=0TO31:R=16-Y\2:LINE(R-(X-1)*((SIN(Y^.8/6)-(Y<16))*6-R-2)+(X<2),X*32+Y)-STEP(Y+1,0):NEXTY,X 2 N=14336:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*32+(IAND48)\2+(IAND448)*8):NEXT:SCREEN1:S$="OI1F20407FJCF7FJ70OIC02010F0J98F0J70RI0F101F2F1F19SJ8040J80TI060F09gI3":KEYOFF:LOCATE8,1:PRINT"PLEASE WAIT!":FORO=1TO71:A$=MID$(S$,O,2) 3 R=Q:Q=ASC(A$)-73:Y=VAL("&H"+A$):O=O-(Q<0):FORD=0TO-(R>0)*R:VPOKEN+I,Y:I=I-(Y>0ORR>0):NEXTD,O:X=V:R=N\2:FORI=256TO1023:VPOKE7952+I,85:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:VPOKE6432+(IAND63),228+8*(IAND3)-(IAND32) 4 W=2^(IAND7):J=(I\32AND1)*127\W:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WAND255:J=8-(IAND32)\8:VPOKEI,(JANDI)*255\J:NEXT:FORK=1TO13:FORH=0TO31:VPOKE6464+H+K*32,-(K<9ORH0:-:D=D*D\96:PRINTUSING"SPEED:##0kmh RANK:###";S;N\128-82:-:F=B:IFC<TTHENC=V+T+TMOD99:B=(R-T>99)*(1-CMOD3) 6 S=S-(S<18ANDSTRIG(0))*2+(S>0):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*H,95),V,4*B+W+1:PUTSPRITE3+W,(W*H,127),V,4*F+3+W:NEXT:-:T=T+S-1:PUTSPRITE1,(115-(D<34)*((24-D)*B+F*10)+(E-64)*D\225,-Y*(98+D)-31),-6*(T 0)*(N\4-V):SOUND8,U:SOUND9,U:PUTSPRITE0,(116-(36-X)*D\126,68+D),-(D>0),S-D\24:LOCATE6,4:PRINTMID$(Z$+"Race Over Time ="+STR$(Z/10)+"s"+Z$,NMOD42+1,S):-:NEXT:SCREEN0
you can remove S=15 from line 7 and substite the S vars in line 8 with the number 15, which will safe another 3 characters. It would be interesting to check if you could get some var set to 128, so you can replace that value three times.
Arjan: are you implying that you can actually READ this stuff? You're crazy!!
BTW: The source is brilliant. Up till now, I've always thought what was possible in BASIC. I guess I was wrong
S is actually used in the error callback to scroll the grass. It icontrols the speed
of the car. Maybe it is ok to use the speed the car had just before the end demo
and replace occurances of S with 15 on line 8.
For constants with three digits we need four occurances in order to save space
by replacing them with a variable. It may be possible to change some other
constants to 128 in order to do this optimization.
well, NYYRIKKI did a better job at decrypting the sourcecode I'm just suggesting some micro-optimizations...
We've done quite a few micro-optimizations. If we get a couple more of them
we'll have enough space to add for example a center line
ah indeed, I missed the last - in line 8
btw, 255 is occurring 4 times in the code
Yeah, now we have pretty good packing ratio. For example the last three letters "gI3" actually define last 31 bytes
(30*0 + 1*3)
NY: so, what's new in your packing (in words)? Why was the 6-bit-per-byte packing of dvik not used anymore, btw? Or is it now compressed 8-bit per byte packing?
manuel, I removed my packing when NYYRIKKI changed the road generation.
The packing with my 6-bit version is a bit better but the code to unpack requires
more characters. So when we only need to pack the car sprite data, NYYRIKKIs
method is more efficient code space wise.
I saved another 13 characters on my lunch break . here is an update:
1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:V=14:SCREEN2,3,0:FORX=0TO2:FORY=0TO31:R=16-Y\2:LINE(R-(X-1)*((SIN(Y^.8/6)-(Y<16))*6-R-2)+(X<2),X*32+Y)-STEP(Y+1,0):NEXTY,X 2 N=14336:U=255:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*32+(IAND48)\2+(IAND448)*8):NEXT:SCREEN1:S$="OI1F20407FJCF7FJ70OIC02010F0J98F0J70RI0F101F2F1F19SJ8040J80TI060F09gI3":KEYOFF:LOCATE8,1:PRINT"PLEASE WAIT!":FORO=1TO71:A$=MID$(S$,O,2) 3 R=K:K=ASC(A$)-73:Y=VAL("&H"+A$):O=O-(K<0):FORW=0TO-(R>0)*R:VPOKEN+I,Y:I=I-(Y>0ORR>0):NEXTW,O:X=V:R=N\2:FORI=256TO1023:VPOKE7952+I,85:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:O=IAND32:VPOKE6432+(IAND63),228+8*(IAND3)-O 4 W=2^(IAND7):J=O*127\W\32:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WANDU:J=8-O\8:VPOKEI,(JANDI)*U\J:NEXT:FORK=1TO13:FORH=0TO31:VPOKE6464+H+K*32,-(K<9ORH0:-:D=D*D\96:PRINTUSING"SPEED:##0kmh RANK:###";S;N\128-82:-:F=B:IFC<TTHENC=V+T+TMOD99:B=(R-T>99)*(1-CMOD3) 6 S=S-(S<18ANDSTRIG(0))*2+(S>0):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*H,95),V,4*B+W+1:PUTSPRITE3+W,(W*H,127),V,4*F+3+W:NEXT:-:T=T+S-1:PUTSPRITE1,(115-(D<34)*((24-D)*B+F*10)+(E-64)*D\225,-Y*(98+D)-31),-6*(T 0)*(N\4-V):SOUND8,O:SOUND9,O:PUTSPRITE0,(116-(36-X)*D\126,68+D),-(D>0),S-D\24:LOCATE6,4:PRINTMID$(Z$+"Race Over Time ="+STR$(Z/10)+"s"+Z$,NMOD42+1,S):-:NEXT:SCREEN0