Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 258
» Latest member: manuelzo75
» Forum threads: 1,074
» Forum posts: 6,434

Full Statistics

Online Users
There are currently 362 online users.
» 0 Member(s) | 360 Guest(s)
Bing, Google

Latest Threads
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 194
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 262
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,526
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 517
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 419
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 290
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,016
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,855
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 398
ZXodus][Engine
Forum: ZX Basic Compiler
Last Post: boriel
02-19-2025, 11:43 PM
» Replies: 69
» Views: 213,491

 
  SAVE and LOAD commands - help!
Posted by: RandomiserUsr - 03-08-2021, 09:04 PM - Forum: Help & Support - Replies (3)

Hi

I have been trying to use the SAVE command to save the data whilst the program is running, i.e. SAVE "GAME" DATA
which I though would save all of the variables in the program?  *Save to Virtual Cassette tape*

And then I thought "All I need to do next is " LOAD "GAME" DATA 
and it would restore the entire game's data but it just crashes after it says "Bytes: GAME" 

I am sure there is something else that needs doing but can't recall this (80's memory is not as good as it should :-)  )

thanks in advance

Print this item

  Dealing with "Out of Memory" errors
Posted by: georgeo - 03-08-2021, 01:09 PM - Forum: Help & Support - Replies (6)

Hi everyone,

I am relatively new to ZXBASIC, though think I have mostly got the hang of things and am using it to write a new game.

I am seeing intermittent Out of Memory issues (when compiling with --debug-memory), which I believe means I am running out of heap space. However, I've tried increasing the heap quite significantly (e.g., up to 8 kb) with little effect. I've also tried reducing the dependence on string arrays/ variables, in case this was the problem.

If I see an intermittent Out of Memory error mid-way through a program, long after most variables should have been defined, will it be heap-related or could it be something else?

Any suggestions for debugging my code, or properly sizing the heap, would be much appreciated.

Thanks in advance,
Georgeo.

Print this item

  String Arrays and memory
Posted by: RandomiserUsr - 02-27-2021, 10:51 PM - Forum: Help & Support - Replies (4)

Hi,

I wonder if someone could help me?

I have started writing a game but it uses a lot of String arrays.
The problem is I am compiling okay but on the screen things are missing where text should be.

I have compiled it using :-

Code:
zxbc MainEngine.bas --tzx --BASIC --autorun  --heap=6000 --optimize 2  --org=25000 --mmap=memory_map.txt
I am not sure where the issue but let me know if you need more information

Thanks
Ken

Print this item

Thumbs Up String Arrays problems "nonsense in Basic" - fixed
Posted by: RandomiserUsr - 02-27-2021, 04:12 PM - Forum: Help & Support - No Replies

Hi, I am looking at how to store a string of descriptions into an array.
Sounds straight forward enough, so should be something like


Code:
DIM A$(100,200)
LET A$(1,1)= "This description 1 : The quick brown fox jumps over the lazy dog."
LET A$(2,1)= "This description 2 : The quick brown fox jumps over the lazy dog."
LET A$(3,1)= "This description 3 : The quick brown fox jumps over the lazy dog."
LET A$(4,1)= "This description 4 : The quick brown fox jumps over the lazy dog."
[size=small][font=Tahoma, Verdana, Arial, sans-serif]PRINT A$(1,1)[/font][/size]

So it should print.

This description 1 : The quick brown fox jumps over the lazy dog.

It is being compiled with

Code:
zxbc aTest.bas --tzx --BASIC --autorun  --debug-array
But all I get when I run it in the ZX Spectrum emulator is 

C Nonsense in BASIC, 30:1

Any ideas why?
I think this is down to memory?

thanks
Ken

UPDATE: 
It seems that all I needed to do is declare A$(100,200) as A$(100) and access it via print A$(1) and that is it - nice to fix things along the new road :-)

Print this item

  FUNCTIONS again
Posted by: RandomiserUsr - 02-27-2021, 12:15 PM - Forum: Help & Support - Replies (2)

If you compile the following code 

FUNCTION A(text as STRING)

Print B("Test")

RETURN 0
END FUNCTION


FUNCTION C(text as STRING)
Print B("Test")
RETURN 0
END FUNCTION

FUNCTION B(text as STRING)
Print ("Test")
RETURN 0
END FUNCTION


you will get
inputmud.bas:137: error: 'B' is neither an array nor a function.
inputmud.bas:135: warning: [W150] Parameter 'text' is never used
inputmud.bas:144: warning: [W100] Using default implicit type 'float' for 'C'
inputmud.bas:144: error: 'B' is neither an array nor a function.
inputmud.bas:143: warning: [W150] Parameter 'text' is never used
inputmud.bas:149: warning: [W100] Using default implicit type 'float' for 'B'
inputmud.bas:148: warning: [W150] Parameter 'text' is never used


but moving function B above like below compiles okay

So I guess it's a TOP Down design where the functions in the same .BAS should be ordered

FUNCTION B(text as STRING)
Print ("Test")
RETURN 0
END FUNCTION
FUNCTION A(text as STRING)

Print B("Test")

RETURN 0
END FUNCTION


FUNCTION C(text as STRING)
Print B("Test")
RETURN 0
END FUNCTION



Great tool

Thanks
Ken

Print this item

  FYI FUNCTIONs and RETURN value
Posted by: RandomiserUsr - 02-27-2021, 12:07 PM - Forum: Help & Support - Replies (4)

I have seen a problem where if you call a function without a RETURN 0 with no return value in FUNCTION declaration e.g.

FUNCTION UFNprintText(printText$ AS STRING )

Sometimes the function will just crash the ZX Spectrum emulator

Adding a RETURN 0 makes it work.

Just thought you might know this?

Print this item

  DIM a$(100,10) possible bug?
Posted by: RandomiserUsr - 02-26-2021, 08:03 PM - Forum: Help & Support - Replies (2)

Hi, 

I have been developing a game and one of thing things I wanted to is build up a string and print it out but the issue I have is that I can't do the following code in zxbc :-


Code:
DIM a$(100,10)
LET a$(1) = "Line 1"
PRINT a$(1)

But I can do the above in a ZX Spectrum emulator.

I know the solution is to use a$(1,1) (Ignore the zero array start)

PS Brilliant compiler!! 

Thanks,
Ken

Print this item

  Value of FastPlot library
Posted by: patters - 01-28-2021, 06:39 PM - Forum: Help & Support - Replies (9)

Is the FastPlot library really going to be faster than a compiled PLOT instruction? Since you've optimised your own PRINT implementation, I would assume that PLOT and DRAW compile to pretty lean machine code do they not? I did some very basic testing comparison of filling using DRAW commands versus looping through FastPlots instead and it seemed roughly the same. Is it perhaps that some libraries are old, and now the compiler is as good with native commands in terms of performance?

Print this item

  PRINT AT 22,0
Posted by: patters - 01-27-2021, 06:57 PM - Forum: Help & Support - Replies (2)

Is it normal that the entire screen scrolls every time I print at line 22 - not even filling the line? Surely it should behave like the other lines, no? Or else it's not much of an improvement over Sinclair BASIC's PRINT #0; AT 1,0;

Print this item

  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?

Print this item