Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 251 online users. » 0 Member(s) | 249 Guest(s) Bing, Google
|
Latest Threads |
Strange Happenings
Forum: Bug Reports
Last Post: boriel
05-23-2025, 09:15 AM
» Replies: 4
» Views: 930
|
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 1,224
|
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 989
|
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 2,750
|
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 1,648
|
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 1,736
|
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 875
|
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 2,223
|
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 3,696
|
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 773
|
|
|
Printing an updated screenful in one go |
Posted by: worcestersource - 01-11-2021, 09:09 PM - Forum: Help & Support
- Replies (5)
|
 |
Hello everyone,
I'm loving the discovery of zxbc and having a great time working on the game I always wanted to make! Thanks Boriel!
I've written code that randomly generates a map (well, its floor), which is stored in an array. To keep the size in memory down, I store the rows as bits and have written a routine to make reading this back in the game code nice and simple. I can easily determine if any given coordinate is floor or not. I'm really happy with this. Bit operators are brilliant!
I'm now at the stage where I need to start putting my graphics on the screen. Using the map floor as a reference, I intend to display the walls and floor of the dungeon using 3x3 character blocks, with each successive row overprinting the bottom of the row before it. This way I should be able to display a 9 x 9 view with a pseudo 3D view and the player in the middle.
Using the floor as the starting point, what's I'm trying to work out right now is the best way to could assemble the whole view of this and print it to the screen in one go so the player doesn't see it redraw tile by tile. As the game is turn based, I don't mind if preparing and moving the updated screen isn't instant.
I've thought of two methods:
- Dynamically create a string and colour it in using control codes, to set everything up that is then printed in one go.
- Scroll the screen, a tile in whatever direction needed and then fill in the space.
I think the first would give the best results, if it's possible, and the second should be achievable with the scroll routines I've been reading about.
My questions are whether there are any other approaches I could take and if anyone kindly has any advice on manipulating and embedding control chars into strings. I've read some other posts but these don't go as far as constructing a string.
Thanks,
Steve
I'm probably going to keep throwing my thoughts into this thread (sorry - I do this on car forums when I'm fixing my old car!).
If I'm treating the string as a fake screen, could I use chr$ 22 as if it were AT? Does the string reorder itself if I do something like
LET s$ = s$ + chr$(22, y, x, 17, 1, 65)
And replace the 1 and the 65 with values from an array that stores the colour swatch and characters?
I'm then curious how the string is stored. Is it the logical concatenation of all of the statements like the above that I'll loop through 81 times or does it reorder itself if the AT equivalents were presented in a non-linear fashion?
|
|
|
Mixing variable types in a numerical calculation |
Posted by: patters - 01-05-2021, 12:50 AM - Forum: Help & Support
- Replies (18)
|
 |
My program is calculating attribute memory addresses for screen characters. In the interests of only DIMing what I need, I store the screen coordinates as UBYTE since I only need numbers from 0-32 at most.
I have spent a long time to find that the compiler doesn't perform the maths properly when these UBYTE variables are used with larger numbers in a calculation - even though I'm never asking for that UBYTE variable to be made any larger. See this example:
Code: DIM x,y AS UBYTE
DIM attrMem AS INTEGER
CLS
y=18
x=4
attrMem=22528+y*32+x
POKE attrMem,16 'red paper, black ink
The result should be a red square AT 18,4. However, it is printed in the wrong location on the screen unless I change variables x and y to type INTEGER. Why would this be, since I am not asking for y or x to be expanded beyond their existing values? Is this expected behaviour, or a bug? I haven't really programmed any languages which have needed me to be so specific about number types before, so apologies if this is a silly question.
|
|
|
Declaring the length of a string |
Posted by: patters - 01-03-2021, 01:55 AM - Forum: Help & Support
- Replies (2)
|
 |
In Sinclair BASIC you can DIM the length of a string using
DIM a$(5)
If I try something similar in Boriel BASIC
DIM a$(5) AS STRING
the compiler seems to interpret this as an array declaration.
Sometimes it's useful to declare the largest expected length of a string if you want to build it up of component pieces. e.g. In Sinclair BASIC:
Code: 10 DIM a$="hello"
20 DIM b$(8)
30 LET b$=a$
40 LET b$(4 TO 8)="p me!"
50 PRINT b$
If I try to do this in Boriel BASIC I can't declare the length, nor does it expand when needed. I seem to have to do it in two steps, one for overwriting the parts of the existing string, and a separate step to glue an addition to the end of the string.
Code: DIM a$, b$
a$="hello"
b$=a$
b$(3 TO 4)="p "
b$=b$+"me!"
PRINT b$
Is this expected? Or is there a better way of building b$ from a$ in this example in only one step?
|
|
|
PRINT bug using CHR$(22) for inline positioning (*solved*) |
Posted by: patters - 12-30-2020, 01:09 AM - Forum: Bug Reports
- Replies (13)
|
 |
It seems as if the compiler gets this wrong when the x coord is greater than 27. See example:
Code: DIM a$, b$ AS String
CLS
a$=CHR(22,17,27,65,66) 'PRINT AT 17,27;"AB" - fine
b$=CHR(22,18,28,67,68) 'PRINT AT 18,28;"CD" - wrong location (19,0)
c$=CHR(22,19,29,69,70) 'PRINT AT 19,29;"EF" - wrong location (20,0)
PRINT a$;b$;c$
PRINT AT 20,28;"GH" '- fine
PRINT AT 18,0;"--" '- fine
At x=28 there is adequate space to print the two characters "CD" before the line wrap, but strangely they end up being PRINTed AT 19,0 instead of AT 18,28. I presume it's because the compiler is forgetting that CHR$(22) and the following two special characters do not count towards the PRINTed length of the string. Will this error also occur for the other inline control codes for INK, PAPER, BRIGHT, OVER, etc.?
This error is present in the the latest stable release 1.13.2, and the betas for 1.14 (which I gather had some PRINT changes). Being able to set the coordinates and attributes inline like this is useful for manipulating pre-formed sprites.
|
|
|
Function to edit a string (*solved*) |
Posted by: patters - 12-29-2020, 05:13 PM - Forum: Bug Reports
- Replies (8)
|
 |
I'm having trouble passing a string to a Function in order to edit it. The code which works fine outside of a Function just won't modify the string inside the Function for some reason. Any idea what I'm doing wrong?
Code: DIM a$ AS String
FUNCTION editStringFN(stringToEdit$ AS String, position AS Integer, newLetter$ AS String) AS String
stringToEdit$(position)=newLetter$
RETURN stringToEdit$
END FUNCTION
CLS
a$="sample"
PRINT a$; "- original string"
'try to edit string via the function
a$=editStringFN(a$, 1, "i")
PRINT a$; "- function fails to edit"
'same edit without using the function
a$(1)="i"
PRINT a$; "- works as regular code"
|
|
|
Can't compile FSin trig function |
Posted by: patters - 12-28-2020, 01:43 AM - Forum: Help & Support
- Replies (6)
|
 |
I'm new to the compiler, using it on Mac OS. Compiling a simple test program works fine. If I paste in the code from the FSin function from the documentation it won't compile:
Code: ../sine.bas:16: error: Syntax Error. Unexpected token 'ELSE' <ELSE>
../sine.bas:17: error: Syntax Error. Unexpected token 'IF' <IF>
../sine.bas:44: error: Syntax Error. Unexpected token 'FUNCTION' <FUNCTION>
I can't understand why the compiler doesn't like this, it looks ok to me. However, I can see an IF without an END IF. This is not how this listing is expressed in the forum post where it was first published. However, adding the missing END IF doesn't appear to help with the compiler errors. What is the problem here?
|
|
|
Code Size Limit |
Posted by: yeti - 09-18-2020, 11:40 PM - Forum: ZX Basic Compiler
- Replies (1)
|
 |
Hello,
I wonder what the limit is to code size with Boriel on:
48K
128K
ZX Spectrum Next?
Can I write my program without thinking about how Boriel is paging memory in the background?
|
|
|
* Liquid War * |
Posted by: .fito. - 09-15-2020, 08:12 PM - Forum: Gallery
- Replies (1)
|
 |
Hello friends, how are you?
I present you the game made by the FitoSoft team. Made in Basic and compiled with Boriel zxb.
It is based on an old "Deep Scan" arcade machine. Your mission will be to use the miners of your destroyer to eliminate any underwater threat. You have more information and download at:
fitosoft.itch.io/liquid-war
regards
|
|
|
|