Posts: 9
Threads: 2
Joined: Jul 2020
Reputation:
4
Hi,
I'm trying to compile a game written wholly in Sinclair BASIC and am having trouble with this line:
10 GOTO INT (RND*4)*6+1380
It works as expected when run as Basic but the compiler gives: 'Syntax Error. Unexpected token 'INT' <INT>'
If I rewrite it to:
10 LET a=INT (RND*4)*6+1380: GOTO a
this also works fine when run as Basic but the compiler gives: 'identifier 'a' is a var, not a label'
Is there another way I could write it that would compile?
Thanks.
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
GOTO <experssion> is not supported.
Line numbers are just labels.
You can, however, use ON ... GOTO. In the example above:
Code: 10 ON INT(RND * 4) GOTO 1380, 1386, 1392, 1398
ON <expression> GOTO a, b, c, d... jumps into a, b, c, d... if expression is one of 0, 1, 2, 3... respectively
Posts: 9
Threads: 2
Joined: Jul 2020
Reputation:
4
(07-14-2020, 10:19 PM)boriel Wrote: GOTO <experssion> is not supported.
Line numbers are just labels.
You can, however, use ON ... GOTO. In the example above:
Code: 10 ON INT(RND * 4) GOTO 1380, 1386, 1392, 1398
ON <expression> GOTO a, b, c, d... jumps into a, b, c, d... if expression is one of 0, 1, 2, 3... respectively
Brilliant, thank you so much for that.
I've sorted out 10 or so errors, just have a couple to go and hopefully the program will compile.
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
Beware of the "Warnings" about types.
Once the program compiles, we can discuss that. :-)
Posts: 9
Threads: 2
Joined: Jul 2020
Reputation:
4
07-18-2020, 01:25 PM
(This post was last modified: 07-18-2020, 02:16 PM by Jodo.)
I've managed to get the game to compile and it works (yay!!), but I have an issue with the UDG's. They display fine running in Basic but when compiled they aren't displayed at all at first. I currently just have a stop at end of last life and the weird thing is, if I run the code again (RANDOMIZE USR 33000) most of the UDG's appear but are heavily corrupted in some way (although the colours are correct) I've tried moving them around in memory but the same thing happens every time. This is the code (but with 21UDG's):
Code: FOR a=65367 TO 65535
READ b: POKE a,b
NEXT a
DATA 0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0
.....
I'm also using a new font (just capitals, exclamation mark and numbers, which displays correctly in the compiled code) if that would have any effect? If I print the character set out the UDG's don't show.
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
07-18-2020, 04:47 PM
(This post was last modified: 07-18-2020, 06:48 PM by boriel.)
Don't use fixed positions like 65367 in the listing above. Even for original Sinclair BASIC listings this is not recommended.
Instead use USR "a" (to start at UDG "a" position).
NOTE: "a" can be the letter "a", the letter "A" or the UDG "A".
This automatically resolves to the right position of the UDGs in memory.
In your case, you're trying to poke starting from 65367 which is one position less than UDG "a". You might be corrupting something (even in the original Sinclair BASIC program!). Do this instead:
Code: FOR a = USR "a" TO USR "u" + 7:
READ b: POKEa, b
NEXT a
...
This should work in both Sinclair BASIC and ZX Basic compiled with --sinclair.
If you don't use --sinclair, an extra step is still needed.
How are you compiling the program?
Posts: 9
Threads: 2
Joined: Jul 2020
Reputation:
4
Thanks so much boriel, with all the reading I've done I don't know how I missed that. All working now! Albeit at super speed, but that's a nice problem to have and the aim of all of this, of course!
It's 26k compiled which means I can add lots more features now, something I wasn't able to do using the Hisoft compiler because of space limitations loading the compiler and Basic listing into (40k?) of RAM! I ended up leaving the project on the shelf for a year because I didn't want to remove any code and still wanted to add more.
I'm compiling with --tzx --BASIC --sinclair --autorun --heap-size=1024 --org=30000
By the way, do you have a PayPal account, or something similar, towards a pint? I couldn't find anything on your site. Your compiler has given my very limited programming abilities a new lease of life and I'd like to say thank you and support your work and time helping me.
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
If you want to support me you can donate at Ko-fi.com (give me a coffee):
https://ko-fi.com/boriel
Any donation will be appreciated!
I'm planning to start a video series and also more things to come!
Posts: 9
Threads: 2
Joined: Jul 2020
Reputation:
4
07-19-2020, 01:50 PM
(This post was last modified: 07-19-2020, 03:47 PM by Jodo.)
(07-19-2020, 11:38 AM)boriel Wrote: If you want to support me you can donate at Ko-fi.com (give me a coffee):
https://ko-fi.com/boriel
Any donation will be appreciated!
I'm planning to start a video series and also more things to come!
Done. I hope you don't mind me saying (and please don't take this the wrong way!), but you are too shy. I would never have found that link.
Get some links up at the top of the forum and on the main website, I am sure you will find others will want to show their appreciation too!
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
07-19-2020, 03:37 PM
(This post was last modified: 07-24-2020, 09:46 AM by boriel.
Edit Reason: Fix links to documentation
)
Oh, many thanks!!
I've twitted it in the official twitter account. Hope you don't mind!!
https://twitter.com/zxbasic/status/1284873801281540096
Also if you publish the game let me know, to twit it!
EDIT:
Not sure if you're aware, but there's also an incomplete list of programs created with the compiler:
https://zxbasic.readthedocs.io/en/docs/r..._programs/
Posts: 9
Threads: 2
Joined: Jul 2020
Reputation:
4
07-19-2020, 06:35 PM
(This post was last modified: 07-24-2020, 09:46 AM by boriel.
Edit Reason: Fix links to documentation
)
(07-19-2020, 03:37 PM)boriel Wrote: Oh, many thanks!!
I've twitted it in the official twitter account. Hope you don't mind!!
https://twitter.com/zxbasic/status/1284873801281540096
You're welcome, it's worth every penny (and more!) to me. And no problem at all if it helps!
(07-19-2020, 03:37 PM)boriel Wrote: Also if you publish the game let me know, to twit it!
Thanks, hopefully in a couple of months or so I'll take you up on that.
It's nothing original at all, sadly, but I chose the genre for the first game on a whim and it's gone from there.
If I get as far as my second game in the future I am definitely planning on something more original!
(07-19-2020, 03:37 PM)boriel Wrote: EDIT:
Not sure if you're aware, but there's also an incomplete list of programs created with the compiler:
https://zxbasic.readthedocs.io/en/docs/r..._programs/
I hadn't seen that, thanks!
|