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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 265
» Latest member: queensizebed
» Forum threads: 944
» Forum posts: 6,311

Full Statistics

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

Latest Threads
Tire Shredder suppliers
Forum: News
Last Post: hhent45
Today, 01:31 AM
» Replies: 0
» Views: 4
Water Faucet suppliers
Forum: News
Last Post: hhent45
Today, 01:31 AM
» Replies: 0
» Views: 0
China Solar Flood Light 1...
Forum: News
Last Post: hhent45
Today, 01:30 AM
» Replies: 0
» Views: 1
Automatic Plastic Bag Sea...
Forum: News
Last Post: hhent45
Today, 01:29 AM
» Replies: 0
» Views: 2
N95 Standard Nose Mask ma...
Forum: News
Last Post: hhent45
Today, 01:29 AM
» Replies: 0
» Views: 0
Automatic Filling And Sea...
Forum: News
Last Post: hhent45
Today, 01:28 AM
» Replies: 0
» Views: 0
cheap Reflective Elastic ...
Forum: News
Last Post: hhent45
Today, 01:28 AM
» Replies: 0
» Views: 0
Custom heat transfer prin...
Forum: News
Last Post: hhent45
Today, 01:27 AM
» Replies: 0
» Views: 1
FDA Medical KN95 Mask Non...
Forum: News
Last Post: hhent45
Today, 01:26 AM
» Replies: 0
» Views: 3
Low Cost Franchises With ...
Forum: News
Last Post: hhent45
Today, 01:25 AM
» Replies: 0
» Views: 2

 
  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:

  1. Dynamically create a string and colour it in using control codes, to set everything up that is then printed in one go.
  2. 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?

Print this item

  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.

Print this item

  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 this item

Bug 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.

Print this item

Bug 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"

Print this item

Bug PAUSE not working (*solved*)
Posted by: patters - 12-29-2020, 03:56 AM - Forum: Bug Reports - Replies (15)

In my program PAUSE doesn't seem to work. Is that normal? I would find it useful to delay execution a bit while my program prints an error on screen when the result of an INPUT isn't compliant. I can't see any mention of PAUSE in the wiki. I mean I can use a FOR loop to count to 10,000 instead, but I thought the aim of Boriel BASIC is to be a faster superset of Sinclair BASIC so it's surprising this seems to be missing.

Print this item

  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?

Print this item

  Bikers - ZX Spectrum Next
Posted by: CavernGames - 11-02-2020, 04:32 PM - Forum: Gallery - Replies (4)

Bikers - a brand new commercial game for the ZX Spectrum Next written using Boriel's ZX Basic Compiler and my own custom libraries for the ZX Spectrum Next.

https://cavern.games/bikers

  • 256 colour screen mode
  • Huge sprites
  • Tile mapped horizon graphics
  • Split tile map scrolling using copper
  • 30 fps at 60Hz
  • AY-3 music
  • 1MB or 2MB ZX Spectrum Next

[Image: bikers_screenshot3.png]

Print this item

  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?

Print this item

  * 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. 



[Image: ldWO5v.png]

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

Print this item