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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 293
» Latest member: BillBennar
» Forum threads: 1,027
» Forum posts: 6,211

Full Statistics

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

Latest Threads
Includes in ASM
Forum: How-To & Tutorials
Last Post: bracckets
04-04-2024, 12:17 AM
» Replies: 2
» Views: 914
Intermittent errors
Forum: Help & Support
Last Post: zarsoft
03-12-2024, 12:39 PM
» Replies: 0
» Views: 465
Store array information i...
Forum: Help & Support
Last Post: rbiondi
03-10-2024, 09:42 PM
» Replies: 0
» Views: 616
ScrollLeft function scrol...
Forum: Bug Reports
Last Post: rbiondi
03-07-2024, 03:57 PM
» Replies: 2
» Views: 1,199
string.bas errors when co...
Forum: Bug Reports
Last Post: rbiondi
03-01-2024, 10:10 AM
» Replies: 2
» Views: 1,060
Using Beepola with ZX BAS...
Forum: How-To & Tutorials
Last Post: edtoo
02-29-2024, 09:47 AM
» Replies: 15
» Views: 34,637
Johnny Bravo
Forum: Gallery
Last Post: zarsoft
02-11-2024, 11:20 PM
» Replies: 0
» Views: 632
Compiling +D G+DOS progra...
Forum: ZX Basic Compiler
Last Post: boriel
01-22-2024, 08:32 AM
» Replies: 4
» Views: 9,251
VAL = ? (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:44 PM
» Replies: 8
» Views: 4,268
Wrong math (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:38 PM
» Replies: 4
» Views: 2,340

 
  LRIM/RTRIM/TRIM built in functions
Posted by: RandomiserUsr - 08-01-2021, 10:00 AM - Forum: Wishlist - Replies (3)

It would be handy to have a 

LTRIM
RTRIM
TRIM

functions built in to ZXB

I know you could right one but I wonder if there is a faster way to be compiled?

thanks

Print this item

  https://zxbasic.readthedocs.io down?
Posted by: RandomiserUsr - 06-10-2021, 08:04 PM - Forum: Documentation - Replies (3)

Hi

Not sure if this is the best place to report this but https://zxbasic.readthedocs.io/ seems to be not working?

Print this item

  GOTO inside a function question?
Posted by: RandomiserUsr - 06-05-2021, 03:14 PM - Forum: Help & Support - Replies (3)

I have two functions that have a return 0 


Code:
FUNCTION processTest(test INTEGER) as INTEGER

......processing stuff

IF X=1 THEN
   poke TestAddress, 1
   GOTO displayMsg
END IF

return 0
END FUNCTION


Does the this cause any memory leaks on the stack?
i.e. by not "returning" something is left on the stack and won't be removed?

I remember something about GOSUB/RETURN having this or am I okay to not RETURN (I am experimenting before you may say it's not "good practice  Smile    )


Thanks in advance

Print this item

  How to carve up ZX Basic into different ORG values
Posted by: RandomiserUsr - 05-15-2021, 09:29 AM - Forum: Help & Support - Replies (10)

This might be asking a tricky thing to do but :-

GOAL :  
To have main.bas compile at 24576 as main.tap
with the ability to at runtime, call on the functions in the below separate files

Functions.bas compile at last address use above +1 as functions-Bank1.bin
** ZX Basic functions only 

textdata.bas compile at  last address use above +1 as textdata-Bank3.bin
** Mixture of ZX BASIC and ASM functions and data references.

picturedata.bas  compile at last address use above +1 as picturedata-Bank6.bin
** Mixture of ZX BASIC and ASM functions and picture references but uses the 168384 address to load into.

This I am hoping would result in files being created that I can then join them together into one TAP file which can then be loaded via an emulator.
The idea is then to be able switch to the relevant bank # to call the relevant function,.

Issue:
When the main,bas is compiled the compiler insists on functions being accessible at runtime, a very logical thing, so the compile fails as the methods are not in main.bas but in the other *.BIN files.

Is there a way around this?
I was using blank labels which helps a bit but I can't really do this with the functions (I have not tried though)

thanks
:-)

Print this item

Bug Game is crashing due to out of memory (48k) (*solved*)
Posted by: RandomiserUsr - 04-25-2021, 01:34 PM - Forum: Bug Reports - Replies (10)

Hi

I am writing a text adventure game (simply for my own fun) rather than use the other systems out there e.g. PAW Infocom, DAAD, TADS,  Aventuron etc... I wanted the challenge in writing one for the ZX Spectrum . :-)

The biggest issue I had was the amount of Text that needed storing.
At first I was going to use some sort of compression but couldn't get it work so I created a tokenised dictionary that turned string arrays (Locations, Objects, Examination results etc...)  to numeric arrays thus the memory was reduced quite a bit. So I thought this would suffice but I soon ran out of memory.

I then attempted to look into the text compression again and then worked out how to do this, but due to the size of the dictionary which was needed still it crashed when there was a decompression of the location file.

I also attempted to use +3 Disk but whilst I was able to a) load a picture b) load a text it crashed subsequent attempts. (Memory clash perhaps)?

So I am here looking for some hints/tips on the options I have.
I do have another plan though where I will try to rewrite it but this time start using text compression from the start.... we will see ... but the main thing for me is

Thanks to Boriel bringing the ZXB to use and Einar Saukas for their both their support :-)

Print this item

  Crash when creating UDGs using ASM (possibly not a bug)
Posted by: worcestersource - 04-05-2021, 10:14 AM - Forum: Help & Support - Replies (3)

Hi there,

I can't for the life of me work out why I've hit this wall. I'm currently designing the graphics for my game, keeping character maps in one file and test harness in another. It crashes out with "J Invalid I/O device, 30:1".

The code in the character file, called, _graphics.bas is as follows:

Code:
graphicsroom:
ASM
DEFB 000, 254, 254, 254, 254, 254, 254, 254 ; A - roof A
DEFB 000, 000, 254, 254, 254, 254, 254, 254 ; B - roof B
DEFB 254, 254, 000, 069, 170, 069, 170, 000 ; C - top wall
DEFB 085, 168, 085, 000, 170, 069, 170, 000 ; D - bottom wall
DEFB 000, 000, 000, 000, 000, 126, 126, 126 ; E - wall cap
DEFB 060, 060, 060, 060, 060, 060, 060, 000 ; F - vert wall (shared)
DEFB 124, 124, 124, 124, 124, 124, 124, 000 ; G - vert wall (left)
DEFB 062, 062, 062, 062, 062, 062, 062, 000 ; F - vert wall (right)
DEFB 000, 000, 000, 000, 000, 000, 000, 000 ; G -
DEFB 000, 000, 000, 000, 000, 000, 000, 000 ; H -
DEFB 000, 000, 000, 000, 000, 000, 000, 000 ; I -
DEFB 238, 136, 136, 000, 238, 136, 136, 000 ; J - floor A
DEFB 254, 170, 212, 170, 212, 170, 212, 000 ; K - floor B

END ASM

And the scratch file to display them is:

Code:
#include "_graphics.bas"

POKE UINTEGER 23675, @graphicsroom

let toproof$ = chr(144) + chr(145)
let caproof$ = chr(148)
let topwall$ = chr(146) + chr(146)
let botwall$ = chr(147) + chr(147)
let sharewall$ = chr(149)
let lefwall$ = chr(150)
let rigwall$ = chr(151)
let floorA$ = chr(155) + chr(155)
let floorB$ = chr(156) + chr(156)


border 0 : paper 0 : ink 7 : bright 1 : cls

print "  " + caproof$ + toproof$ + toproof$ + toproof$ + caproof$

bright 1 : print "  " + sharewall$; : bright 0 : print topwall$ + topwall$ + topwall$; : bright 1 : print sharewall$

bright 1 : print "  " + lefwall$; : bright 0 : print botwall$ + botwall$ + botwall$; : bright 1 : print rigwall$

bright 1 : ink 7 : print "  " + sharewall$; : bright 0 : ink 1 : print floorA$ + floorA$; : INK 2 : PRINT floorB$; : bright 1 : ink 7 : print sharewall$

bright 1 : ink 7 : print "  " + lefwall$; : bright 0 : ink 1 : print floorA$ + floorA$; : INK 2: PRINT floorB$; : bright 1 : ink 7 : print rigwall$

I have determined that if the last DEFB line in the graphics file is replaced with...

Code:
DEFB 254, 170, 212, 170, 212, 170, 000, 000 ; K - floor B

i.e. substituting the last 212 with 000, there is no crash. If I replace it with 001, all of the graphics corrupt but still run. Other values either work as expected or produce crashes. Adding another line after DEFB, i.e. graphic character L, causes it to crash.

It may be me as I'm still learning zxbc. I'm using the latest downloadable version on Mac. I've tried running this with an older download from earlier this year and it also crashes.

Thanks,


Steve

Print this item

  ZX0 decompression examples
Posted by: RandomiserUsr - 03-31-2021, 08:29 AM - Forum: Help & Support - Replies (3)

Hi

I have been looking into the ZX0 library

Having created a compress file by running this "zx0 testscreen.scr"
And to us this file this is a test file I created t.bas

#include "zx0.bas"

10 dzx0Standard(@testscreen1, 16384)
20 GOTO 20

testscreen1:
    asm
        incbin "testscreen.scr.zx0"
    end asm

When compiled and run it indeed does display the image on screen.
Some questions:-

Q1.I have been able to convert some artwork (PNG) to .SCR and compress this and then load it on screen BUT (newbie alert) I am running out of memory/program crashes/resets Emulator.
So the question is, can I do this and if so HOW?
(A) load from a M: drive (emulator allowing) and/or
(B) use the 128K Mode and then use the memory banks for images and leave the '48K' for the main game?

Q2. How can I display the SCR file but only print it to the top half of the screen?
1/3 or 2/3rds is okay as well? Is there any code examples (ASM/ZXB)

Q3. Next to the text,
I want to next compress text files that contain a description of a game room.
Looking at an example I tried this (don't laugh!) :-

dzx0Standard(@Text1, 50000)

Text1:
asm
incbin "location1.txt.zx00"
end asm
Text2:
asm
incbin "location2.txt.zx00"
end asm

But this does nothing but load it to the address of 50000 but I want the routine to return a STRING containing the decompressed text?

Quote:UPDATE 4th April 2021: I have worked how to do Q3 in a standalone test.bas file but when I do this in my main program it crashes the app soon after starting it up?
I am using these params --tzx --BASIC --autorun  --heap=1000 --optimize 2  --org=25000--debug-memory  --debug-array 

Lots of questions but hopefully some kind person can help? :-)
thanks

Print this item

Bug Undefined GLOBAL label error on array (solved)
Posted by: short_jonny - 03-27-2021, 03:12 PM - Forum: Bug Reports - Replies (2)

Hi,
Recently started experimented with the compiler. It's been great so far but I've just started getting unexpected errors using arrays. Compiling the snippet below results in:
test.bas:55: error: Undefined GLOBAL label '._myArray'.  
I can't see why this is failing ?  Am I doing something stupid ?  
I've used 1.14.1 and the latest state of the repo. Is it a bug ?

DIM myArray(1 to 6) as ubyte

SUB Init(byval num as ubyte)
    DIM i as ubyte
    FOR i=1 TO num
        myArray(i) = 0
    NEXT i
END SUB

Init(6)



Jonathan

Print this item

  Potential bug in impl of LOAD "..." CODE
Posted by: georgeo - 03-15-2021, 09:21 PM - Forum: Help & Support - Replies (8)

Hi everyone (probably for the attention of Boriel),

My search for the source of instability in my game continues, though I no longer think it is to do with memory management, but a possible bug in the compiler, for the implementation of LOAD "..." CODE. I have noticed that part of my program gets corrupted after I use LOAD "..." CODE to load some UDGs at the top of memory. Digging in to the implementation of the function, I found the following code (sorry, I can't copy and paste code out of the emulator I am using):

https://1drv.ms/u/s!Atca6hVb5b8Tp5JxCEWC...g?e=qGHdEg

At the end of the snippet, a call is made to 0xE6E1, which is a wrapper to the ROM loader routine (in this case, to load a tape header). IX points to the place in memory where the header should be loaded, which -- in this case -- is inside my program code. If I understand correctly what is going on, the snippet starts with a call to MEM_FREE (0xDB56, in this case) which returns a pointer to space in the heap (perhaps where the header can be stored?). However, the IX register is loaded with 2*SP and passed to the tape loader, which I think is a mistake.

Is that a possible bug?


If this is indeed a bug, it fits with my experience. As the size of my program grows, I need to raise the origin address to avoid random crashes. For example, if I have a 30kb program with origin address at 29,000, then the stack will reside somewhere near the start of the heap, so 2*SP will be around 58,000 which will be near the end of my program. However, if I up the origin to 31,000, then 2*SP will be more like 62,000, which will be just past the end of my program. As the size of my program increases, it will eventually grow past 2*SP and then will start to get corrupted and crash randomly, when I load from tape, so I again need to raise the origin address.

It all seems to fit, but maybe I've just convinced myself,
Georgeo.

Print this item

  Memory used ?
Posted by: RandomiserUsr - 03-13-2021, 02:10 PM - Forum: Help & Support - Replies (6)

I wonder if there is a way to print the available memory your compile ZX Basic program has used whilst running it?

One more question on memory usage, which would be better in terms of reducing memory overhead?

1) IF WORD$ = "SAVE WORLD" THEN


or
2) IF WORD = 99 and WORD=98 THEN

thanks in advance
Ken

Print this item