mattgodbolt / jsbeeb

Javascript BBC micro emulator
GNU General Public License v3.0
350 stars 68 forks source link

problems with Basic tokeniser (one-line TETRIS) #35

Closed murkle closed 9 years ago

murkle commented 9 years ago

It doesn't work (gives 'Bad Program') with this: http://survex.com/~olly/rheolism/dsm_rheolism/

0d=d:IFdVDUd:a=POINT(32_POS,31-VPOS<<5):RETURNELSEMODE9:GCOL-9:CLG:OFF:d=9:REPEATVDU30:REPEATGOSUBFALSE:IFPOS=28VDUPOS,15,VPOS,24;11,26:IF0ELSEIFa=0PRINT:UNTIL0ELSEUNTILVPOS=25:v=ABSRNDMOD7:i=0:VDU4895;3:REPEATm=9-INKEY6MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOURv-15:VDUrEORm:i+=m=7AND9-6_r:IF0ELSEFORn=0TO11:d=n/3OR2EORd:GOSUBFALSE:IF1<<(n+i)MOD12AND975AND&C2590EC/8^vVDU2080_ABSr;:t+=a:IF0ELSENEXT,:VDU20:UNTILt_LOGm:UNTILVPOS=3

If you make it one byte shorter by removing the 3 from the end then it can be LISTed but I think that's a symptom of another problem somewhere as it doesn't work if you split it into multiple lines across the colons

ghost commented 9 years ago

You wouldn't ordinarily be able to enter that line on the command line as-is, e.g. IFdVDUd wouldn't tokenise the VDU. Maybe what's required is something to give an error if the 255 byte limit is exceeded.

ghost commented 9 years ago

Also, just noticed: this is a BASIC V program!

murkle commented 9 years ago

MODE doesn't seem to be tokenised properly, eg try just MODE 1 gives 'Syntax Error at Line 10"

TINY should work on a BBC with small modification but I can't get it working even with a correct MODE: http://survex.com/~olly/rheolism/dsm_rheolism/history.html

murkle commented 9 years ago
50REM VDU23,TRUE;TRUE;TRUE;TRUE;TRUE
60MODE 2
65DIM p 99,z 32,e 32,f 32
70FOR A = 0 TO 31:f?A=0:NEXT:$p=""
80REPEAT:p=p+1:UNTILp MOD 6=0
90$z="ADAH(4())DAB!L"
100GCOL0,135:CLG:VDU28,5,31,14,0:PRINTSTRING$(250," ");
110GCOL0,1
120REPEAT:VDU26,29,0;1023;:b=RND(7):x=9:l=1:y=3:r=8
130p$=""
140REPEATCOLOUR0:PRINTTAB(x,y)p$:A=z!(b*2-2)
150g=INKEY0MOD9:k=y-l*(g=TRUE):j=x-(g=3)+(g=1):Q=r
160PRINTTAB(j,k);
170o=0:e!(k-4)=0:e!k=0:FORC=p+(g=2)TOp+23:Q=2-(Q>9)EORQ:IFC>=p ?C=Q*(1ANDA):VDU?C:A=A/2:IFC MOD6=3C=C+2:C?TRUE=TRUE:?C=8:e?VPOS=e?VPOS+1:o=o+POINT(POS*32,-VPOS*32):IF0ELSENEXT:?C=13:IFo=0x=j:y=k:r=Q:p$=$p
180COLOURb:PRINTTAB(x,y)p$
190REM WAIT:WAIT:WAIT:WAIT:WAIT
200UNTILk>y:f!(y-4)=f!(y-4)+e!(k-4):f!y=f!y+e!k:b=31:FORa=31TO0STEPTRUE:VDU28,5,b,14,0,30,-11*(f?a=10),26:f?b=f?a:b=b+(f?a<10):NEXT:UNTILy=3
murkle commented 9 years ago

Found the proper BBC version lower down the page :) This does work if you retokenise line 0 manually (with MODE)

0d=d:IFd VDUd:p=POINT(64*POS,1E3-VPOS*32):RETURN ELSEMODE2:GCOL0,-9:CLG
1d=9:REPEATVDU30:REPEATGOSUBFALSE:IFPOS=15VDU28,5,VPOS,14;11,26:IF0ELSEIFp=0PRINT:UNTIL0ELSEUNTILVPOS=25
2b=ABSRND MOD7:k=0:VDU31,9,3
3REPEATg=9-INKEY6MOD3
4FORl=TRUE TO1:o=l ANDSGNo
5IFo=l COLOURb-15:VDUl EORg:k=k+(g=7AND9-6*l)
6IF0ELSEFORf=0TO11:d=f/3OR2EORd:GOSUBFALSE
7IF2^((f+k)MOD12)AND975AND&C2590EC/8^b VDU2080*ABSl;:o=o+p:IF0ELSENEXT,
8VDU20:UNTILo*LOGg:UNTIL0