Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 260
» Latest member: Ra001
» Forum threads: 1,073
» Forum posts: 6,437
Full Statistics
|
Online Users |
There are currently 380 online users. » 1 Member(s) | 377 Guest(s) Bing, Google, boriel
|
Latest Threads |
Strange Happenings
Forum: Bug Reports
Last Post: boriel
05-23-2025, 09:15 AM
» Replies: 4
» Views: 1,825
|
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 2,014
|
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 1,672
|
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 4,053
|
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 2,820
|
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 2,688
|
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 1,438
|
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 3,604
|
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 4,673
|
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 1,151
|
|
|
Compiler optimization setting |
Posted by: patters - 01-27-2021, 06:35 PM - Forum: Help & Support
- Replies (2)
|
 |
Is it a good idea to use -O3? I know typically there are trade-offs - like loop unrolling can make code bigger in order to become faster. Is there much of a difference for ZX Basic between -O2 and -O3? Am I better off sticking to the default -O2 since it's more tried and tested?
Or since I'm not yet running into memory limits should I use -O3 while I can?
|
|
|
Mute compiler warnings for included libraries |
Posted by: patters - 01-26-2021, 03:24 PM - Forum: Library
- Replies (1)
|
 |
Every time I compile I get a big wall of text of warnings about unused variables and functions in libraries that are included in my program (input.bas, attr.bas and its own includes, HRPrint.bas, fastTrig.bas). Could such warnings for libraries be muted by default perhaps and make them elective for library debugging, or at least allow me to exclude them in my build script? I didn't write these pieces of code, so I'm not interested in these warnings. However if I mute all warnings then I could miss an issue with my own code. Even with warnings enabled I have missed many genuine warnings because they were drowned out by the noise (variable unused is the classic one - when a name has been mistyped or the capitalisation is wrong somewhere in the listing).
|
|
|
Screen attribute statement ignored on SUB exit (*solved*) |
Posted by: patters - 01-26-2021, 12:22 PM - Forum: Bug Reports
- Replies (5)
|
 |
If I have multiple attribute changes on a single line, the last one is ignored on exit from a SUB.
Consider this example which exposes the problem:
Code: SUB screenAttributes
PAPER 3: INK 7: BRIGHT 1
END SUB
SUB screenAttributes2
PAPER 4: BRIGHT 1: INK 2
END SUB
CLS
screenAttributes()
PRINT AT 0,0;"test"
screenAttributes2()
PRINT AT 2,0;"test2"
For the first example print, it should be bright but it isn't.
The second example print should have red ink but it doesn't.
I thought I was going mad until I found this.
If I substitute another command in this last statement position of the SUB (like a PRINT for instance) then that works. It's only attribute assignments that seem to fail. Also, if I insert another command before the END SUB, then it all works as expected. e.g. the below code works fine:
Code: SUB screenAttributes
PAPER 3: INK 7: BRIGHT 1
BEEP 0.1,60
END SUB
SUB screenAttributes2
PAPER 4: BRIGHT 1: INK 2
BEEP 0.1,60
END SUB
CLS
screenAttributes()
PRINT AT 0,0;"test"
screenAttributes2()
PRINT AT 2,0;"test2"
On further testing, the issue is not related to multiple colon-separated statements on the same line. With the following code the compiler also loses the last statement in each Sub and fails to work as expected:
Code: SUB screenAttributes
PAPER 3
INK 7
BRIGHT 1
END SUB
SUB screenAttributes2
PAPER 4
BRIGHT 1
INK 2
END SUB
CLS
screenAttributes()
PRINT AT 0,0;"test"
screenAttributes2()
PRINT AT 2,0;"test2"
|
|
|
Creating a populated array of strings |
Posted by: patters - 01-26-2021, 01:07 AM - Forum: Help & Support
- Replies (1)
|
 |
Hi Boriel,
I notice that I cannot do the following:
Code: DIM stringArray(2) AS STRING => {"apples", "oranges", "pears"}
The compiler returns "error: Initializer expression is not constant."
Digging on this forum reveals a post from 2009, in which you state this is not possible because string lengths are dynamic. Is this still the case? As you posted in that thread, it ought to be simple to just have the compiler run a bunch of individual LET assignments, but it's a bit ugly to have to type them out.
Thanks,
Patters
|
|
|
Clearing an array |
Posted by: patters - 01-19-2021, 10:47 PM - Forum: Help & Support
- Replies (6)
|
 |
What is the recommended way to reset an array's contents? Do we have to run a FOR loop from 0 TO UBOUND and clear it element by element, or is there a neater way?
I see that the following doesn't work:
|
|
|
Custom TAP loader with SCREEN$ |
Posted by: patters - 01-17-2021, 06:24 PM - Forum: Help & Support
- Replies (6)
|
 |
I have a Sinclair BASIC loader for my game which will CLEAR 32767, load a SCREEN$, LOAD ""CODE, and finally RANDOMIZE USR 32678. I have assembled the loader and the SCREEN$ into a TAP file - but how to I get zxbc.py to append its output to this TAP file? I can't seem to get it to work.
When I try:
Code: ./zxbc.py -t --append-binary ../loader+scr.tap ../arti12.bas
I get a file arti12.tap as expected but it doesn't load the machine code. If I browse the TAP file in Fuse emulator I see that zxbc.py appears to have prepended an additional self-contained TAP file into the loader TAP file, rather than appended the binary data. Am I doing this wrong, or is this a bug?
I have managed to work around the issue by producing a .bin file instead, and then Fuse's 'Import Binary Data' option and then saving the memory range back out to the mounted TAP file - but it would be much nicer to automate that with zxbc.py if possible.
Thanks
|
|
|
Documentation frequently offline |
Posted by: patters - 01-13-2021, 12:01 PM - Forum: Documentation
- No Replies
|
 |
Hi,
I have been frequently referring to the ZX Basic documentation while I have been programming. I find that at random (but multiple times a day) the search feature on the wiki returns no results for a short period which is quite frustrating. It's happened again right now. During though outages, luckily I can consult the markdown files on GitHub. However, they don't have a search function, which is useful so I do prefer the wiki.
I also notice that the boriel.com landing site frequently drops off the Internet late at night too. Can you perhaps set up some kind of host monitoring to determine just how big a problem this is, or maybe raise a support ticket with the webhost?
Thanks,
Patters
|
|
|
First RND call is ignoring RANDOMIZE, subsequent calls are fine (*solved*) |
Posted by: patters - 01-13-2021, 02:38 AM - Forum: Bug Reports
- Replies (3)
|
 |
I have noticed while testing my program that the very first random number is always the same when the compiled program is loaded into an emulator. Subsequent ones are indeed random.
That first result is normal - you might think - because RND will be invoked at the same number of ticks after power-on each time. However, I use RANDOMIZE after an INPUT (which won't always be submitted at a consistent time by the user) before the first RND in the program is requested, so this should not happen. I presume this is a bug because after the first RND, it behaves as normal. If I deliberately insert a dummy RND before the RND values I need, then my program runs with the expected randomness.
Simple test case which demonstrates the issue:
Code: #include <input.bas>
DIM i$ AS STRING
CLS
i$=INPUT(1)
RANDOMIZE
PRINT INT (RND*100) 'this number is consistent every time the emulator is launched with the tap file
PRINT INT (RND*100) 'this number will be random
When I run the tap file in Fuse on Mac OS I usually get 60 for the first random number. Very occasionally I get 61 though, so that may help for debugging. It's always those two values though. The second number will be in the range 0-99 as expected.
This issue is present in release version 1.14 and in 1.14beta9
|
|
|
|