Author
| Free your creativity - IOMBCC
|
AuroraMSX
 msx master Posts: 1249 | Posted: March 14 2005, 10:47   |
Quote:
| Has your A returned already? 
|
/me checks hind...
Yup. Everything in place
Thanx for your concern |
|
dvik msx master Posts: 1312 | Posted: March 15 2005, 06:47   |
Name: Worm
System: MSX1
1 SCREEN1:KEYOFF:FORW=0TO9:COLOR5,1,1:S=-10:LOCATE8,11:PRINT"'s' to start":W=0
2 M=32:D=736:IFINKEY$<>"s"THENNEXTELSECLS:F=6176:V=4096:H=6480:T=H-V:FORX=0TOD
3 VPOKEX+F,7:X=X+15*(X-30AND30AND31<XANDX<D-M):NEXT:FORZ=ATOM:S=S+10:FORC=ATOH
4 L=F+RND(1)*D:IFVPEEK(L)<>MTHENNEXTELSEFORK=ATOM: W=3AND(W+(J$="z")-(J$="x"))
5 R=R-(S>R):LOCATE1,0:VPOKEL,215: U=(2+62*(WAND1))*((W>1)+.5):Z=0:VPOKEH-V,U+M
6 PRINT"SCORE:"S,"HIGH:"R: H=H+U: O=VPEEK(H):VPOKEH,9:IFO<>MANDO<>215THENNEXTW
7 J$=INKEY$:K=0:IFO=215THENNEXTZELSEVPOKET+V,M: T=T+VPEEK(T)-M:VPOKEV*2,6:NEXT
I made a little old school game. Its been a while (like 15 years) since I wrote an MSX Basic program so I hope it is readable.
To run it press 's' to start and 'z' and 'x' to control the thing. Enjoy  |
|
dvik msx master Posts: 1312 | Posted: March 15 2005, 10:32   |
And a little one liner (although I don't really think it qualifies for one since it is quite long....) Its pretty obvious what it does maybe...
0 DEFINTA-Z:A=1:FORX=0TO0STEP0:A=A+2:B=-1:C=B:D=A:FORT=OTO0STEP0:IFD=0THENIF(C-B)=2THENPRINTA:NEXTXELSENEXTXELSEIFD>0THENC=C+2:D=D-C:NEXTELSEB=B+2:D=D+B:NEXT
|
|
dvik msx master Posts: 1312 | Posted: March 16 2005, 01:18   |
I made a more entertaining version of the prime number generator. This one is a lot slower but more interesting. It doesn't contain any branches except a goto (anyone have any ideas on how to get rid of this one. I tried run but that clears the variables?). It does however use multiplications which the other one didn't.
Since I just posted a similar entry I guess this one can be left outside IOMBCC but I wanted to show you it since it looks pretty fun. So once again, enjoy
1 A=A-2*(D=0)-(A=0):B=(D=0)-(D<>0)*B:C=(D=0)-(D<>0)*C:D=D-A*(D=0):C=C-2*(D>0):B=B-2*(D<0):D=D+C*(D>0)-B*(D<0):PRINTCHR$(-30*(D<>0OR(C-B)<>2))A:GOTO1
|
|
Grauw msx professional Posts: 1006 | Posted: March 16 2005, 18:19   |
Great entries! ^_^ I’ve enjoyed them!
|
|
dvik msx master Posts: 1312 | Posted: March 16 2005, 18:25   |
Kindof. I used that in the first prime number version but its not very obfuscated (and the goto isn't either). I was thinking if there is a way to restart the program (some kind of jump) without clearing the variables.
Btw, a bit more obscure infinite for loop is (all numbers are zero):
FOR I=0 TO 0 STEP 0: NEXT
Hey Grauw, Were did your last post go?
|
|
dvik msx master Posts: 1312 | Posted: March 16 2005, 22:33   |
Snout, I actually like the new one liner better, so if you don't mind I'd like to change the prime number entry to this one instead (I just moved the print statement to the beginning):
1 PRINTCHR$(-30*(D<>0OR(C-B)<>2))A:A=A-2*(D=0)-(A=0):B=(D=0)-(D<>0)*B:C=(D=0)-(D<>0)*C:D=D-A*(D=0):C=C-2*(D>0):B=B-2*(D<0):D=D+C*(D>0)-B*(D<0):GOTO1
|
|
snout
 msx legend Posts: 4991 | Posted: March 16 2005, 22:35   |
I'll add it as an extra entry, as I find the other one to be quite interesting as well  |
|
Grauw msx professional Posts: 1006 | Posted: March 16 2005, 23:32   |
dvik: because he already uses for i=0 to 0 step 0 in his previous version, so it was a bit stupid remark  . |
|
NYYRIKKI msx master Posts: 1510 | Posted: March 19 2005, 11:05   |
dvik: That worm game is really good looking! It's so small, hard to read and yet so well working. Congratulations! That prime number search routine is also weird!
|
|
dvik msx master Posts: 1312 | Posted: March 19 2005, 11:18   |
Thanks nyyrikki. The worm game can be done a little bit shorter but I wanted to keep the quite ugly for loops (look at how the loop variables are used and also when the next statements are called). If I manage to get it down to six lines instad of seven I'll post a new version but it may be a bit tricky
Your entries are very cool too. I like that you use a wider range of calls. It shows that you know msx basic really well.
|
|
NYYRIKKI msx master Posts: 1510 | Posted: March 20 2005, 23:24   |
Quote:
| (anyone have any ideas on how to get rid of this one. I tried run but that clears the variables?)
|
I have a little idea... Thanx to your great explanation, I also took a liberty to make some minor changes in order to obfuscate it a bit more.
1 ONERRORGOTO1:POKE-2373,0:PRINTCHR$(-30*(D<>0OR(X(1)-X(0))<>2))A:A=A-2*(D=0)-(A=0):X(0)=(D=0)-(D<>0)*X(0):X(1)=NOT(D<>0)*(X(1)+1):D=D-A*(D=0):X(-(D>0))=X(-(D>0))+2:D=D-SGN(D)*X(-(D>0)) IOMBCC ENTRY BY DVIK!
|
|
dvik msx master Posts: 1312 | Posted: March 21 2005, 07:24   |
Nice enhancment NYYRIIKI  Using an array for the two square number iterators was a good idea which made the last calculation much more intersting. |
|
dvik msx master Posts: 1312 | Posted: March 21 2005, 07:25   |
I also have an update to the snake game. I finally manage to shrink it to 6 lines instead of 7:
1 SCREEN1:KEYOFF:FORR=0TO9:COLOR5,1,1:LOCATE8,11:PRINT" s to start":M=32:S=-10
2 IFINKEY$<>"s"THEN2ELSECLS:FORD=0TO737::D=D+(D+1AND2ANDD>MANDD<704)*15:F=6176
3 VPOKED+F,7:NEXT:H=6480:T=H-D:FORC=ATOF:S=S+10:L=F+RND(1)*D:IFVPEEK(L)-MTHEN3
4 Y=Y-10*(S>Y):R=3ANDASC(INKEY$+"C")+R+1:VPOKEL,15:U=M^(RAND1)*(1-(RAND2)):C=0
5 VPOKE2^13,6:VPOKEH-D,U+M:H=H+U:O=VPEEK(H):VPOKEH,9:IFO-MANDO-15THENR=0:NEXTR
6 LOCATE1,0:PRINT"SCORE"S,"HI"Y:IFO=15THEN3ELSEVPOKET+D,M:T=T+VPEEK(T)-M:GOTO4
|
|
NYYRIKKI msx master Posts: 1510 | Posted: March 21 2005, 08:18   |
Just wondering... Does ASCII still need some BASIC listings to their magazine? We might have few suitable...
|
|
|
|
|