Autor
| Free your creativity - IOMBCC
| dvik msx master Mensajes: 1299 | Publicado: Abril 23 2005, 04:30   | I've made a few optimizations. I was almost able to fit the center line into the size limits.
I found quite a few more characters (about 170) and I made two versions of
the code. One withthe center line and one without (that can be filled with nice features).
So here is the one with center line:
1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:SCREEN2,3,0:N=14336:V=32:FORX=-1TO1:FORY=0TO31:M=16-Y\2:W=V+X*V+Y:LINE(M-X*((SIN(Y^.8/6)-(Y<16))*6-M-2)+(X<1),W)-STEP(Y+1,0)
2 PRESET(16-X*(Y\5-6),-W*(Y>17)):NEXTY,X:U=255:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*V+(IAND48)\2+(IAND448)*8):NEXT:SCREEN1:KEYOFF:FORY=0TOU:VPOKEY,(YAND16)*(Y\VOR254)\(8^(Y\8AND1))\16:P(Y\V)=50-15*(Y\96AND1):NEXT:R=N\2:FORO=0TO73:Y=0
3 FORM=MTOM+1:Y=Y*96+(ASC(MID$("3##B#C#c$B'r$B&s3#%##C#3%S';%S&s;##2#3#B#R#B#<=c'##c'#@C#)#2#,s##&wfw:w3w4w$Is%kIsIc%sIcIt%kItIl%sIlDD%q#-#.%qDDDS%q#5#6%qDSDK%q#5#6%qDKDC%q#-#.%qDC",M))-35):NEXT:FORK=KTOK+Y\256:VPOKEK+N+I+8335*(O>V),YANDU
4 NEXTK,O:FORI=256TO1023:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:O=IANDV:VPOKE6432+(IAND63),228+8*(IAND3)-O:W=2^(IAND7):J=O*127\W\V:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WANDU:J=8-O\8:VPOKEI,(JANDI)*U\J:NEXT:SOUND3,14:TIME=0
5 VPOKE1209,U:FORW=8TO9:PUTSPRITEW,(80+64*W,159),14,W-2:SOUNDW,14:NEXT:FORT=2TOR:SOUND1,83:G=G+F*S\2:LOCATE1,1:D=96-(NAND127):Y=D>0:-:D=D*D\96:PRINTUSING"SPEED:##0kmh RANK:###";S;N\128-82:-:F=B:IFC<TTHENC=9+T+TMOD99:B=(R-T>99)*(1-CMOD3)
6 S=S-(S<18ANDSTRIG(0))*2+(S>0):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*V,95),14,4*B+W+1:PUTSPRITE3+W,(W*V,127),14,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<R),15-D\25:M=(X>72)-(X<0):O=STICK(0)
7 -:GOSUB8:S=S*((X-15-E\3)\15<>0ORD<73)*(M=0):SOUND0,U-S*9:E=NAND128:X=X+5*(M+(O=7)-(O=3))-S*B\4:N=N+9-S:-:FORW=8216TO8219:G=G+8AND31:VPOKEW,86+(GAND16):VPOKE4+W,85+G\24:NEXT:-:PUTSPRITE0,(X+80,156),1,12:GOSUB8:NEXT:Z=TIME\(6-PEEK(43)\128)
8 A=A+S\2:FORW=0TO1:VPOKE8193+W,A\9+WAND1OR238:NEXT:IFT<RTHENRETURNELSES=15:Z$=SPACE$(S):FORN=0TO244:D=88-3*N: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
And here is the one without:
1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:KEYOFF:SCREEN2,3,0:U=255:V=32:FORX=-1TO1:FORY=0TO31:M=16-Y\2:LINE(M-X*((SIN(Y^.8/6)-(Y<16))*6-M-2)+(X<1),V+X*V+Y)-STEP(Y+1,0)
2 P(Y\4)=50-15*(Y\12AND1):NEXTY,X:N=14336:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*V+(IAND48)\2+(IAND448)*8):NEXT:S$="3##B#C#c$B'r$B&s3#%##C#3%S';%S&s;##2#3#B#R#B#<=c'##c'#@C#)#2#,s##&wfw:w3w4w$w3w#w4w,DD0CDDDS0CDSDK0CDKDC0CDC":SOUND3,14
3 SCREEN1:FORO=0TO53:Y=0:FORM=MTOM+1:Y=Y*96+(ASC(MID$(S$,M))-35):NEXT:FORK=KTOK+Y\256:VPOKEK+N+I+8335*(O>V),YANDU:NEXTK,O:FORI=256TO1023:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:O=IANDV:VPOKE6432+(IAND63),228+8*(IAND3)-O
4 W=2^(IAND7):J=O*U\W\64:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WANDU:J=8-O\8:VPOKEI,(JANDI)*U\J:NEXT:R=N\2:VPOKE8192,14:VPOKE1209,U:FORW=8TO9:PUTSPRITEW,(80+64*W,159),14,W-2:SOUNDW,14:NEXT:TIME=0:FORT=2TOR:-:PUTSPRITE0,(X+80,156),1,12:SOUND1,83
5 G=G+F*S\2:LOCATE1,1:D=96-(NAND127):Y=D>0:-:D=D*D\96:PRINTUSING"SPEED:##0kmh RANK:###";S;N\128-82:-:FORW=8216TO8219:G=G+8AND31:VPOKEW,86+(GAND16):VPOKE4+W,85+G\24:NEXT:O=STICK(0):T=T+S-1:-:F=B:IFC<TTHENC=9+T+TMOD99:B=(R-T>99)*(1-CMOD3)
6 S=S-(S<18ANDSTRIG(0))*2+(S>0):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*V,95),14,4*B+W+1:PUTSPRITE3+W,(W*V,127),14,4*F+3+W:NEXT:-:PUTSPRITE1,(115-(D<34)*((24-D)*B+F*10)+(E-64)*D\225,-Y*(98+D)-31),-6*(T<R),15-D\25:M=(X>72)-(X<0):E=NAND128:N=N+9-S
7 -:S=S*((X-15-E\3)\15<>0ORD<73)*(M=0):SOUND0,U-S*9:X=X+5*(M+(O=7)-(O=3))-S*B\4:-:NEXT:S=15:Z$=SPACE$(S)+"Race Over Time ="+STR$((TIME\(6-PEEK(43)\128))/10)+"s":FORN=0TOU:D=88-3*N:LOCATE6,4:PUTSPRITE0,(116-(36-X)*D\126,68+D),-(D>0),S-D\24
8 -:PRINTMID$(Z$+Z$,NMOD38+1,S):SOUND9ANDNOR8,-(D>0)*D\6:NEXT:SCREEN0
The reason why I made one without center line is that I don't think it is smooth
enough and maybe we should do something else like a nice intro, or one of the
other features NYYRIKKI suggested. | | NYYRIKKI msx master Mensajes: 1474 | Publicado: Abril 25 2005, 15:43   |
You have rewritten this code lately so much, that it is hard to follow your changes anymore. You have really managed to squeeze this.
If you want to take all characters out, I think, that you can optimize most of the errors.  Example: Y=D>0:-: can be written as Y=D>0(:
| | NYYRIKKI msx master Mensajes: 1474 | Publicado: Abril 25 2005, 16:10   | Character generator:
FORI=UTO1023
| | NYYRIKKI msx master Mensajes: 1474 | Publicado: Abril 25 2005, 16:28   |
S=15 does not help... To make it help, it should be in the beginning of proram and should use another variable name. If you place it after DEFINTA-Y, line will be too long, but maybe you find a way to relocate U=255...
| | dvik msx master Mensajes: 1299 | Publicado: Abril 25 2005, 17:39   | I'm pretty satisfied with the packing now. The big change was to put the
landscape data RLE encoded. That saved quite a lot. Other than that I think I got rid of one for loop.
I had to move code around quite a lot to make the lines 239 chacaracters.
I looked a bit more at it and I can't really think of more optimizations and I don't
really think it is necessary.
I prefer the second version without a center line so if you have any ideas of
things to put into the game (I also thought of a "get ready, get set, go" text
before the game starts) go ahead. This time I promise not to do anymore
changes.
| | dvik msx master Mensajes: 1299 | Publicado: Abril 25 2005, 17:48   | Another feature that may be nice is the possibility to start a new game after the race is over and maybe disable the screen while generating the vdp data and
maybe disable CTRL-BREAK.
I think a couple of small features to touch the game up is worth more than the
white center line. What do you think?
| | snout
 msx legend Mensajes: 4991 | Publicado: Abril 26 2005, 12:47   | I think it's your call, Nyyrikki.  | | NYYRIKKI msx master Mensajes: 1474 | Publicado: Abril 27 2005, 11:59   | I know... I'm sorry, but I don't have much time this week.. I'm anyway not going to forget this project...
I also thought, that maybe we could make it possible to drive also to grass, but then speed should drop. I suggest, we implement Lo/Hi gear and break. Let's see how much we have then free space left...
| | dvik msx master Mensajes: 1299 | Publicado: Junio 05 2005, 23:51   | Nyyrikki, have you thought anything more about the rally game? I've been busy with other things lately
but we should try to finish it up. I'm actually quite happy with the latest version posted (the one without
the white center line).
| | NYYRIKKI msx master Mensajes: 1474 | Publicado: Junio 06 2005, 08:46   | I have not forget this project, but no I have not done anything (yet)... Somehow after a while this looks pretty messy
| | AuroraMSX
 msx master Mensajes: 1216 | Publicado: Junio 06 2005, 09:37   | Quote:
| Somehow after a while this looks pretty messy 
|
Obfuscated, I'd say  | | NYYRIKKI msx master Mensajes: 1474 | Publicado: Diciembre 27 2005, 17:48   | Hey, I just found one old routine, that I made long time ago... It fits here perfectly!
This program detects, what CPU mode you are running your MSX tR
10 ONERRORGOTO30.75:ONINTERVAL=2GOSUB20OR10:DEFSTRR:INTERVALON:RZ="R800"
20 R="Z80":NEXT:FORSI=0TO20:NEXT:ER=ER+1:IFER<3THENRETURNELSEWHATSHOULDIDO
30 IF0=SITHENRESUMENEXTELSEIFERRXOR3THENPRINTRELSEPRINTRZ
40 CLEAR:END:OR:WHAT ;-)
| | snout
 msx legend Mensajes: 4991 | Publicado: Diciembre 23 2006, 20:49   | I think I requested it somewhere else before, but err... how about making a 'final' of the racing game, Nyyrikki? ^_^
| | NYYRIKKI msx master Mensajes: 1474 | Publicado: Octubre 29 2007, 21:55   | Yeah... ok...
First not optimized and not very well working version with breaks (down) and gears (space). Acceleration is now on UP-key.
1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:KEYOFF:SCREEN2,3,0:U=255:V=32:FORX=-1TO1:FORY=0TO31:M=16-Y\2:LINE(M-X*((SIN(Y^.8/6)-(Y<16))*6-M-2)+(X<1),V+X*V+Y)-STEP(Y+1,0)
2 P(Y\4)=50-15*(Y\12AND1):NEXTY,X:N=14336:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*V+(IAND48)\2+(IAND448)*8):NEXT:S$="3##B#C#c$B'r$B&s3#%##C#3%S';%S&s;##2#3#B#R#B#<=c'##c'#@C#)#2#,s##&wfw:w3w4w$w3w#w4w,DD0CDDDS0CDSDK0CDKDC0CDC":SOUND3,14
3 SCREEN1:FORO=0TO53:Y=0:FORM=MTOM+1:Y=Y*96+(ASC(MID$(S$,M))-35):NEXT:FORK=KTOK+Y\256:VPOKEK+N+I+8335*(O>V),YANDU:NEXTK,O:FORI=UTO1023:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:O=IANDV:VPOKE6432+(IAND63),228+8*(IAND3)-O
4 W=2^(IAND7):J=O*U\W\64:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WANDU:J=8-O\8:VPOKEI,(JANDI)*U\J:NEXT:R=N\2:VPOKE8192,14:VPOKE1209,U:FORW=8TO9:PUTSPRITEW,(80+64*W,159),14,W-2:SOUNDW,14:NEXT:TIME=0:FORT=2TOR:-:PUTSPRITE0,(X+80,156),1,12:SOUND1,83
5 G=G+F*S\2:LOCATE1,1:D=96-(NAND127):Y=D>0(:D=D*D\96:PRINTUSING"SPEED:##0kmh "+CHR$(76-L*4)+" RANK:###";S;N\128-82(:FORW=8216TO8219:G=G+8AND31:VPOKEW,86+(GAND16):VPOKE4+W,85+G\24:NEXT:Q=O:O=PEEK(-1043):T=T+S-1(:F=B:IFC<TTHENC=9+T+TMOD99
6 B=(R-T>99)*(1-CMOD3):L=LXOR(1-(OAND1)AND(OXORQAND1))
7 S=S-(S<18AND0=(OAND32))*(2-(S<7ANDL=0)-(S>6ANDL=1))+(S>0)+((S>1)AND0=(OAND64))):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*V,95),14,4*B+W+1:PUTSPRITE3+W,(W*V,127),14,4*F+3+W:NEXT:PUTSPRITE1,(115-(D<34)*((24-D)*B+F*10)+(E-64)*D\225,-Y*(98+D)-31),-6*(T<R),15-D\25
8 M=(X>72)-(X<0):E=NAND128:N=N+9-S:-:S=S*((X-15-E\3)\15<>0ORD<73)*(M=0):SOUND0,U-S*9:X=X+5*(M-(0=(OAND128))+(0=(OAND16)))-S*B\4:-:NEXT:S=15:Z$=SPACE$(S)+"Race Over Time ="+STR$((TIME\(6-PEEK(43)\128))/10)+"s":FORN=0TOU:D=88-3*N:LOCATE6,4
9 PUTSPRITE0,(116-(36-X)*D\126,68+D),-(D>0),S-D\24:-:PRINTMID$(Z$+Z$,NMOD38+1,S):SOUND9ANDNOR8,-(D>0)*D\6:NEXT:SCREEN0
changes in variables:
O=keyboard status
Q=old keyboard status
L=GEAR
... not very good implementation, but I quess you have to start with something  Dvik, it's your turn
| | NYYRIKKI msx master Mensajes: 1474 | Publicado: Octubre 29 2007, 23:52   | Hmm... here is much better gas, brake and gear handler...
S=S-((0=(OAND32))*(2-(S<9ANDL=0)-(S>8ANDL=1)))+(0=(OAND64)):S=-(S>0)*(S-1)+(S>14+L*6)*(L+2) | |
| |
| |