rolandshacks/vs64

Autonumbering discards commands in multi-command lines

Opened this issue ยท 11 comments

Hey there,

I've got a somewhat strange behaviour with using NEXT when using Autonumbering.
(Using the current Version, 2.5.14)

For testing this out i wrote a simple snippet which should clear the screen and writes(pokes) it full with letter A, row by row.

print"{clr}"
fory=0to24:forx=0to39
poke1024+(y*40)+x,1
next:next

But the resulting code in Vice looks like this:

1 PRINT "..."
2 FORY=0TO24:FORX=0TO39
3 POKE1024+(Y*40)+X,1
4 NEXT

So it discards the second NEXT (for the Y) and therefore its prints only one Line on Screen.
If I use 3 NEXT Commands in a line then only 2 appears and so on.

Strangely enough, if i mix 2 different commands and write for example this

print"{clr}"
fory=0to24:forx=0to39
poke1024+(y*40)+x,1
next:poke53281,y
next

the NEXT disappears and only the POKE 53281 Command will remain. But, if I reverse it to

print"{clr}"
fory=0to24:forx=0to39
poke1024+(y*40)+x,1
poke53281,y:next
next

it works.

print"{clr}"
fory=0to24:forx=0to39
poke1024+(y*40)+x,1
poke53281,y:next:next

Works as well.

So, i think if a multi-command line starts with NEXT, then there's some hiccup in parsing and the rest after the first NEXT will under some cirucmstances discarded.

Michael

Hi Michael,
thanks for the report, I'll have a look as time allows.
Roland

Had a quick look - it really is a bug. Simple story: because it ends with a colon, the first "NEXT" is recognized as label "NEXT", which is then eliminated during code generation. It is a bug, BASIC keywords must never be handled as label...
This is easy to be fixed, hope you can wait a little bit until I find the time to do so.
Roland

Hi Roland,

thank you, it works now.
But interestingly enough, I got now this error:

/home/michael/pve/code/projects/retro/c64game/src/main.bas(2): error: undefined label 'delay'
ninja: build stopped: subcommand failed.
failed with exit code 1

The code I've tested

gosub delay
print "Start"
gosub drawmap
print "End"
end

delay:
print "testlabelstuff ... wait for me...."
return

drawmap:
print"{clr}"
fory=0to24
forx=0to39
poke1024+(y*40)+x,65
next:next
return

This error only occurs on delay label. Others, like synonyms for it (waitforme and so on) works just fine.

Greetings
Michael

This is because "DELAY" is a defined token in simon's BASIC. Currently, the label is checked against all keywords from the original BASIC and Simon's Basic (TSB to be precise). I probably should make this more configurable in future releases...

Oh! I've thought it could be something like that but I wasn't sure!
I know Simon's BASIC but am not very familiar with it.
Well, I'll get a list of the keywords to avoid this "error" in the future :-)

thank you for your good work ๐Ÿ‘
Michael

I quickly build a new version (hopefully didn't screw up) - but with that new v2.5.17 you can use the flag "--noext" in the project config ("args") to disable TSB / Simon's Basic tokens. DELAY should then work as expected...
https://github.com/rolandshacks/vs64/releases/latest

Hi Roland,

yes, DELAY is now accepted but now another error occurs.

Testcode:

print "Start"
gosub delay
print "middle"
gosub delay
print "end"
end
delay:
fordl=1to1000:next
return

turns into:
image

Edit: It's independent of release- or debug-mode. I've tested in both modes.

Greetings
Michael

All right Michael, I need to do proper work here - not just trying, sorry for the issues.
I'll have a more precise look and come back here once it works fine.
Roland

Hi Michael,

maybe you would like to look at v2.5.18 - I found and fixed an old bug at handling plain/standard BASIC V2 code. That bug wasn't detected because before 2.5.18, Simon's BASIC was the default feature set (making the original, most used code path not very well tested). I now changed the default setting towards BASIC V2, added a flag to enable Simon's BASIC (--tsb) and tested it with a handfull of basic programs.

Thanks again for your help - further feedback would be very appreciated!
Roland

https://github.com/rolandshacks/vs64/releases/latest

Hi Roland,

installed the new version and redefined a label to delay and it works now ๐Ÿ‘

Michael