stardot / MatrixBrandy

Matrix Brandy BASIC VI for Linux, Windows, MacOSX
http://brandy.matrixnetwork.co.uk/
44 stars 8 forks source link

Possible bug #90

Closed mikefairbank closed 2 years ago

mikefairbank commented 2 years ago

The following code gives me an "Address exception at line 310" error. I don't think this should happen. I think it's damaging the state of brandy somehow, because once the bug has happened, I can strip this code down to something smaller that also causes the error but then after restarting brandy the stripped down code no-longer causes the error. So it's tricky to pin down how to recreate this bug, but this block of code appears to do so consistently. Hence, to replicate the bug it's safest to restart brandy then run this code.

It also might be something to do with the parser, because putting a "THEN" into line 310 after the IF fixes the bug.

Also weird (this might be another bug), if we move lines 300 and 310 to lines 90 and 95, then the error message changes to "'=' (function return) encountered outside a function at line 95"

10MODE 13 20oversize%=4 30y_oversize%=4 40DIM streamers% 1000 50sfy1%=0:sfy2%=4:sfx1%=8:sfx2%=12:sfm%=16:sfcol%=20:sftype%=21 60DIM sfX%(y_oversize%):FOR I%=1 TOy_oversize%:sfX%(I%)=20+I%4:NEXT 80PROCstreamer(2,3,71,1,0) 90PROCincrease_streamers 100END 110 120DEF PROCstreamer(x1%,y1%,x2%,y2%,col%) LOCAL dy%,m,y,x,I% 130dy%=y1%-y2% 140m=(x2%+0.5-x1%)/dy% 150y=(y1%+oversize%-1)DIV oversize%oversize% 160x=x1%-(y-y1%)m 170x=x/oversize% 180IF m>0 x-=m/y_oversize% 190: 200!(streamers%+sfx1%)=x1%:!(streamers%+sfx2%)=x2% 210!(streamers%+sfy1%)=y1%:!(streamers%+sfy2%)=y2% 220?(streamers%+sfcol%)=col% 230!(streamers%+sfm%)=m2^16 240FOR I%=1 TOy_oversize% 250!(streamers%+sfX%(I%))=((x+m(1-I%)/y_oversize%)2^16)OR&80000000 260NEXT 270ENDPROC 280 290DEF PROCincrease_streamers LOCAL x1%,x2%,y1%,y2%,m% 300y1%=3 310IF 0<y1% ?(streamers%+27)=?(streamers%+27)AND&7F ELSE ?(streamers%+27)=?(streamers%+27)OR&80 320ENDPROC

mikefairbank commented 2 years ago

This is fixed now by a recent commit. The problem was that it was parsing line 310 incorrectly as "IF 0 < (y1%?(streamers%+27)) =?(streamers%+27)AND&7F"