Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 340 online users. » 0 Member(s) | 338 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: 190
|
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 259
|
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,521
|
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 513
|
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 415
|
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 287
|
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,014
|
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,852
|
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 395
|
ZXodus][Engine
Forum: ZX Basic Compiler
Last Post: boriel
02-19-2025, 11:43 PM
» Replies: 69
» Views: 213,484
|
|
|
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
|
|
|
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
|
|
|
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.
|
|
|
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
|
|
|
Understanding memory layout |
Posted by: georgeo - 03-13-2021, 11:11 AM - Forum: Help & Support
- Replies (2)
|
 |
Hi everyone,
I am seeing some strange memory problems when compiling a reasonably large program, which probably means I don't understand how the compiler organises memory.
Specifically, I have a program that is around 28kb in size, including a 1kb heap. Depending on the origin value I use, the program will either work or crash, but not as you might expect.
Initially, I set the origin of the code to 26000 (that is, "--org 26000") and this worked fine for a time. However, when my program reached a certain length (from memory, around 25kb), I started to see odd behaviour (corrupted strings and Out Of Memory errors). I tried increasing the heap size (to 2kb, 3kb, 4kb, 5kb, 6kb), though this didn't help. I then tried changing the origin to 28000 and then everything was fine again.
A little later on, with some more code added, I started to see problems again, so I again tried increasing the origin address--now to 29000 and again all is fine.
I'm confused because:
- the program isn't that big, fitting in between address 29000 and 57,353 (right now), so well clear of user-defined graphics and any Sinclair BASIC workspaces
- I would have expected that lowering the origin address would be more likely to help, if there was a lack of memory, rather than increasing it.
I checked the memory map (produced with '--mmap') and, indeed, symbols are defined for addresses between 29,000 and 57,247, so that all looks correct.
Can anyone suggest what is going on here? Thanks in advance,
|
|
|
Print42 library throws error with --explicit option |
Posted by: georgeo - 03-13-2021, 10:59 AM - Forum: Help & Support
- Replies (5)
|
 |
Hi everyone,
I'd like to use --explicit to force me to define all variables before using them, to reduce the risk of bugs. However, I see an issue because my program uses the Print42 library and it contains a definition that seems to violate the --explicit option.
Specifically, if you try to compile a program that includes Print42 library, using --explicit, you will see an error something like:
Code: C:/opt/zxbasic-1.14.0/zxbasic/src/arch/zx48k/library/print42.bas:16: error: Undeclared variable "printAt42Coords"
C:/opt/zxbasic-1.14.0/zxbasic/src/arch/zx48k/library/print42.bas:17: error: Undeclared variable "printAt42Coords"
I considered updating the library source, so that printAt42Coords is defined. However, printAt42Coords is a code label, not a normal variable. The compiler complains because the label is dereferenced with an @printAt42Coords operation to work out the address at which to store the current coordinates:
Code: SUB printat42 (y as uByte, x as uByte)
POKE @printAt42Coords,x
POKE @printAt42Coords+1,y
END SUB
...
printAt42Coords:
...
I don't know what type of variable printAt42Coords is, so can't add a 'dim' statement to define it. I tried defining it as a 'uinteger', but then the compiler complains when it tries to use as a label "error: identifier 'printAt42Coords' is a var, not a function"
Anyone know how to work around this?
Thanks in advance,
|
|
|
Understanding scope of variables |
Posted by: georgeo - 03-11-2021, 01:51 PM - Forum: Help & Support
- Replies (5)
|
 |
Hi everyone,
In ZXBASIC, is this a valid program?
Code: function myFunction( name$ as string ) as uinteger
dim length, n as ubyte
dim total as uinteger = 0
length = len(name$)
if length=0 then
return total
end if
for n = 0 to length-1
total = total + code(name$(n))
next n
return total
end function
REM Main program
dim n as ubyte
dim ans as uinteger
n = 14
ans = myFunction("Hello")
print "Answer = " + str$(ans)
print "n = " + str$(n)
stop
I have a variable labelled 'n' in both the top-level program and a function. I believe, in the function, 'n' is a different, locally defined variable, which is deleted when the function ends.
Would the same work, if I replaced the function with a subroutine (accepting I couldn't return an answer in the same way)?
I ask as I am seeing unexpected behaviour in my program (not the one above, a much longer program) and one possibility is that I'm using the same variable names for different entities in both the top-level program and subroutines.
Thanks in advance for any help
|
|
|
Dim At Issue? (1.15.0-beta4) |
Posted by: Ljg701 - 03-09-2021, 08:07 PM - Forum: Help & Support
- Replies (4)
|
 |
Hello Boriel,
The following array initiation code I don't think is initiating the array data at the correct address. In the example below, the peek returns a value of 255 rather than 1, also @test doesn't return a value of $c000 (Version 1.15.0-beta4 + NextBuild)
Code: '!ORG=24576
'!OPT=4
dim test(0 to 3) as ubyte => {1,2,3,4} at $C000
'this should return 1
print at 0,0;peek($c000)
do
loop until inkey$<>""
|
|
|
Using --debug-array with arrays passed to functions |
Posted by: georgeo - 03-09-2021, 01:11 PM - Forum: Help & Support
- Replies (4)
|
 |
Hi everyone,
I would like to use the --debug-array option to check I have not used out-of-range array indices in my program. However, it appears that I need to give the compiler more information, to use the option in a program that passes arrays as function arguments.
For example, the following simple program appears to compile/ run correctly:
Code: function pickString$( choice as ubyte, listOfStrings() as string ) as string
return listOfStrings(choice)
end function
dim myString$(3) as string
myString$(0) = "Zero"
myString$(1) = "One"
myString$(2) = "Two"
myString$(3) = "Three"
dim n as ubyte
for n=0 to 3
print pickString$(n, myString$)
next n
stop
--but the compiler generates an error if I try to compile with the --debug-array option:
Code: zxbc -t -a -B --debug-array array_bounds_ex.bas
Traceback (most recent call last):
File "c:\opt\zxbasic-1.14.0\zxbasic\zxbc.py", line 10, in <module>
sys.exit(libzxbc.main()) # Exit
File "c:\opt\zxbasic-1.14.0\zxbasic\src\libzxbc\zxbc.py", line 246, in main
func_visitor.start()
File "c:\opt\zxbasic-1.14.0\zxbasic\src\arch\zx48k\translator.py", line 1401, in start
self.visit(f)
File "c:\opt\zxbasic-1.14.0\zxbasic\src\ast\ast.py", line 35, in visit
stack.append(last.send(last_result))
File "c:\opt\zxbasic-1.14.0\zxbasic\src\arch\zx48k\translator.py", line 196, in visit_ARGLIST
upper = node.parent.entry.bounds[i].upper
File "c:\opt\zxbasic-1.14.0\zxbasic\src\symbols\boundlist.py", line 29, in __getitem__
return self.children[key]
File "c:\opt\zxbasic-1.14.0\zxbasic\src\ast\tree.py", line 40, in __getitem__
return self._children[key]
IndexError: list index out of range
I imaging the problem is that the compiler can't work out the array bounds within the function, unless I tell it. Anyone know if I can modify the source, so array-bound checking will still work?
Thanks in advance,
|
|
|
|