Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bug on a bezier draw attempt
#1
i'm trying to draw a kind of custom simplified vectorial file, converted from postscript or svg, with a code like this:

Code:
1000 CA=49152:LET XT=0: LET YT=0:LET CT=0

1004 PAPER 7:BORDER 7: BRIGHT 0: INK CT: CLS: OUT 254,0

1100 REM FILE READING

1102 LET CM=PEEK(CA):LET CA=CA+1

1104 IF CM=ASC("M") THEN GOSUB 5002

1106 IF CM=ASC("L") THEN GOSUB 5102

1108 IF CM=ASC("C") THEN GOSUB 5202

1110 IF CM=ASC("F") THEN GOSUB 5302

1112 IF CM=ASC("I") THEN GOSUB 5402

1114 IF CM=ASC("Z") THEN GOSUB 5502

1116 GOTO 1102

5000 REM _M_ MOVE

5002 LET XT=PEEK(CA):LET CA=CA+1:LET YT=191-PEEK(CA):CA=CA+1:RETURN

5100 REM _L_ LINE

5102 LET X1=PEEK(CA):LET CA=CA+1:LET Y1=191-PEEK(CA):CA=CA+1

5104 INK CT: PLOT XT,YT: DRAW XT-X1,YT-Y1 :LET XT=X1:LET YT=Y1:RETURN

5200 REM _C_ BEZIER

5202 LET X1=PEEK(CA):LET CA=CA+1:LET Y1=191-PEEK(CA):LET CA=CA+1

5204 LET X2=PEEK(CA):LET CA=CA+1:LET Y2=191-PEEK(CA):LET CA=CA+1

5206 LET X3=PEEK(CA):LET CA=CA+1:LET Y3=191-PEEK(CA):LET CA=CA+1

5208 LET XA=(X3)-(3*X2)+(3*X1)-(XT):LET YA=(Y3)-(3*Y2)+(3*Y1)-(YT)

5210 LET XB=(3*X2)-(6*X1)+(3*XT):LET YB=(3*Y2)-(6*Y1)+(3*YT)

5212 LET XC=(3*X1)-(3*XT):LET YC=(3*Y1)-(3*YT)

5213 LET X=0: LET Y=0

5214 FOR T=0 TO 1 STEP 0.25

5215 LET XO=X:LET YO=Y

5216 LET X=(((((XA*T)+XB)*T)+XC)*T)+XT

5218 LET Y=(((((YA*T)+YB)*T)+YC)*T)+YT

5220 IF T=0 THEN INK CT: PLOT X,Y

5222 IF T<>0 THEN INK CT: DRAW X-XO,Y-YO

5224 NEXT T

5226 LET XT=X3:LET YT=Y3:RETURN

5300 REM _F_ FILL

5302 LET XT=PEEK(CA):LET CA=CA+1:LET YT=191-PEEK(CA):LET CA=CA+1

5304 REM PAINT (XT,YT),CT

5306 RETURN

5400 REM _I_ INK COLOUR

5402 LET CT=PEEK(CA):CA=CA+1:RETURN

5500 REM _Z_ END OF DOCUMENT

5502 GOTO 5502

but when i try to compile it:

Code:
guest@macbook_mint1 /mnt/sda4/emulation/zxspectrum/basic/BorielZxBasicCompiler $ zxb.py /mnt/sda4/emulation/zxspectrum/basic/bin2tap_py/zvfreader_
zxspectrum.bas -t -S 32768
zvfreader_zxspectrum.bas:31: Syntax Error. Unexpected token 'NEXT' <NEXT>
guest@macbook_mint1 /mnt/sda4/emulation/zxspectrum/basic/BorielZxBasicCompiler $

very weird... what could cause this?
Reply
#2
ZX Basic compiler allows multiline IFs. So every IF must be closed with END IF.
See help: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:IF">http://www.boriel.com/wiki/en/index.php/ZX_BASIC:IF</a><!-- m -->
Reply
#3
thanks! Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)