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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 273
» Latest member: mindlin
» Forum threads: 1,085
» Forum posts: 6,486

Full Statistics

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

Latest Threads
location of heap manageme...
Forum: Help & Support
Last Post: boriel
2026-03-07, 12:13 AM
» Replies: 1
» Views: 212
non-paged supervisor code...
Forum: Help & Support
Last Post: sdo303
2026-02-20, 06:38 PM
» Replies: 8
» Views: 682
How to open fuse as an ex...
Forum: How-To & Tutorials
Last Post: Duefectu
2026-02-09, 01:52 PM
» Replies: 3
» Views: 1,061
Old zxbasic game errors
Forum: Help & Support
Last Post: boriel
2025-11-09, 11:52 AM
» Replies: 7
» Views: 1,671
Error: Undefined GLOBAL l...
Forum: Help & Support
Last Post: ardentcrest
2025-11-04, 05:46 PM
» Replies: 3
» Views: 807
A Fast(er) Plot Routine f...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-30, 03:16 PM
» Replies: 2
» Views: 926
Hall of Fame - Include fo...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-28, 03:48 PM
» Replies: 0
» Views: 473
[SOLVED] Array layout bug...
Forum: Bug Reports
Last Post: Zoran
2025-10-25, 05:48 PM
» Replies: 2
» Views: 942
3DOS Commands?
Forum: Help & Support
Last Post: boriel
2025-10-06, 02:54 PM
» Replies: 3
» Views: 1,105
CLS/Fade out ASM Sub-rout...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-05, 03:39 PM
» Replies: 2
» Views: 835

 
  -1 = 255 (solved)
Posted by: zarsoft - 2023-01-19, 03:54 PM - Forum: Bug Reports - Replies (1)

Why this gives different results?
How can I force to give -1 ?

PRINT CODE("012"(1)) - CODE("012"(2)) ' gives -1
LET w$="012": PRINT CODE(w$(1))-CODE(w$(2)) ' gives 255

Print this item

  Pascalated ZX BASIC Demo
Posted by: zarsoft - 2023-01-19, 11:08 AM - Forum: Gallery - Replies (2)

To run online, click here: RUN ONLINE


Code:
' PROGRAM factorials
' Demo for the Pascalated language
' Language: Pascalated ZX BASIC (BORIEL) (compiled)
' Pascalated Sinclair BASIC (c) 1987 by ZarSoft
' Pascalated Boriel (c) 2023 by ZarSoft
' ZX BASIC compiler was created by Boriel

#include <input.bas>

'--- Pascalated Boriel ---
#define VAR       DIM
#define INTEGER   LONG
#define REAL      FLOAT
#define TYPE      AS
#define REPEAT    DO
#define UNTIL     LOOP UNTIL
#define PROCEDURE SUB
#define PROGRAM   REM

REM Variable declarations
REM VAR - Global variables
REM Uppercase are different from lowercase
VAR limit TYPE INTEGER : REM max argument to build the list

PROCEDURE Introduction
CLS
PRINT AT 13,0
PRINT "+-----------------+"
PRINT "| factorial list  |"
PRINT "+-----------------+"
PRINT " Demonstration for"
PRINT " Pascalated ZX BASIC (Boriel)"
PRINT " (c) 2023 by Zarsoft"
PRINT
PRINT
END PROCEDURE

PROCEDURE GetLimit
REPEAT
  PRINT "Max argument = ";
  limit = VAL( INPUT(9) ) : PRINT limit
  IF limit >= 12 THEN
    PRINT
    PRINT "Must be lower than 34."
    PRINT "Try again."
    PRINT
  ELSE IF limit < 0 THEN
    PRINT
    PRINT "Must be greater than 0."
    PRINT "Try again."
    PRINT
  ELSE
    PRINT
    PRINT "Valid input."
    PRINT
  END IF
UNTIL (limit >= 0) AND (limit <= 33)
END PROCEDURE

FUNCTION CalculateFactorial (argument TYPE INTEGER) TYPE REAL
VAR result TYPE REAL
LET result = 1
WHILE argument > 1
  LET result = result * argument
  LET argument = argument-1
END WHILE
RETURN result
END FUNCTION

PROCEDURE WriteFactorials
VAR w TYPE INTEGER
VAR argument TYPE INTEGER
VAR result TYPE REAL
PRINT
FOR w = limit TO 0 STEP -1
  LET argument = w
  PRINT "fact(";argument;") = ";
  result = CalculateFactorial(argument)
  PRINT result
NEXT w
END PROCEDURE

PROCEDURE MainPROCEDURE
Introduction
GetLimit
REPEAT
  WriteFactorials
  PRINT
  PRINT "Write 0 to terminate."
  GetLimit
UNTIL limit = 0
END PROCEDURE

PROGRAM factorials
MainPROCEDURE
PROGRAM END

Print this item

  First public release of ZX BASIC
Posted by: zarsoft - 2023-01-18, 05:57 PM - Forum: Documentation - Replies (1)

When was the first public release of ZX BASIC?
2010?

Print this item

  My first Boriel BASIC program: Guess Number
Posted by: zarsoft - 2022-11-30, 11:54 AM - Forum: Gallery - No Replies

To run online, click here: RUN ONLINE

Here is the source:

Code:
' PROGRAM GUESS NUMBER
' (c) 2022 by Zarsoft
' Language: ZX BASIC (BORIEL) compiled

#include <input.bas>

#define REPEAT  DO
#define UNTIL   LOOP UNTIL
#define ROUTINE SUB
#define PROGRAM REM

REM Variable declarations
REM VAR - Global variables
DIM secret AS INTEGER : REM number 1-1000
DIM guess AS INTEGER : REM user guess
LET tries = 0 : REM number of tries
LET GoodGame = 0 : REM user guessed on few tries
LET YouGuessed = 0 : REM User guessed it right

ROUTINE Introduction
CLS
PRINT AT 13,0
PRINT "+------------------+"
PRINT "| GUESS THE NUMBER |"
PRINT "+------------------+"
PRINT " (c) Zarsoft, 2022"
PRINT " ZX BASIC (Boriel)"
PRINT
PRINT
END ROUTINE

ROUTINE PickNumber
PRINT
PRINT "I am thinking of a Number"
PRINT "between 1 and 1000"
PAUSE 50
LET secret = 1+INT (RND*1000)
REM PRINT "secret= ";secret
END ROUTINE

ROUTINE GetUserGuess
PRINT "What is your guess? ";
guess = VAL( INPUT(9) )
LET tries = tries + 1
END ROUTINE

ROUTINE TestGuess
IF guess = secret
  LET YouGuessed = 1
  PRINT
  PRINT "Congratulations, human!"
  PRINT "The number was ";secret
  PRINT "On target in ";tries;" tries."
  PAUSE 50
ELSEIF guess < secret
  LET YouGuessed = 0
  PRINT
  PRINT "Try one bigger than ";guess
  PAUSE 50
ELSE
  LET YouGuessed = 0
  PRINT
  PRINT "Try one smaller than ";guess
  PAUSE 50
ENDIF
END ROUTINE

ROUTINE TestGoodGame
IF tries <= 10
  LET GoodGame = 1
ELSE
  PRINT
  PRINT "But, it took too much time."
  PRINT "Lets try again!"
  PAUSE 50
ENDIF
END ROUTINE

ROUTINE GameOver
PRINT
PRINT "GAME OVER - insert another coin"
PRINT
PRINT
PRINT
PRINT
END ROUTINE

ROUTINE Game
InitVariables
PickNumber
REPEAT
  GetUserGuess
  TestGuess
UNTIL YouGuessed
END ROUTINE

ROUTINE MainRoutine
Introduction
REPEAT
  Game
  TestGoodGame
UNTIL GoodGame
GameOver
END ROUTINE

PROGRAM GuessNumber
MainRoutine
PROGRAM END

Print this item

  REPEAT UNTIL (solved)
Posted by: zarsoft - 2022-11-28, 07:54 PM - Forum: Wishlist - Replies (3)

Hi

I'd like to use the Pascal mode because it's simpler:


Code:
REPEAT
    [<sentences>]
UNTIL <condition>




I dont like to use:

Code:
DO
    [<sentences>]
LOOP UNTIL <condition>

Print this item

  Print color bug (*solved*)
Posted by: Darkstar - 2022-10-03, 09:18 PM - Forum: Bug Reports - Replies (19)

Code:
Declare sub CenterText (ByVal Row as ubyte, ByVal Text as string)

Ink 6
Paper 1
Print at 20, 0; "\k";

Ink 7
Paper 0

'Print ; 'Put here to update colors, there is a bug in the compiler.
CenterText (21, "Hello")


Sub CenterText (ByVal Row as ubyte, ByVal Text as string)

Dim i As UInteger

i = Len(Text) / 2
i = 16 - i
Print at Row, i; Text;

End sub

Hi there Boriel.

The above code does not work correctly, both the "K" and the word "Hello" come out with blue paper and yellow ink unless you unrem the print statement. Then the "Hello" comes out with black paper and white ink.

This was not a problem before, this is a recent problem. I can use this "print" workaround for the time being but there is a bug in the complier.

Print this item

  SIN and COS functions have bug ?
Posted by: papa_robot - 2022-08-16, 10:42 PM - Forum: Help & Support - Replies (2)

Hello to the zx basic community. I'm integrating the compiler into my own spectrum bot.

I created a sample sinewave graph

Code:
FOR x = 10 TO 245 STEP 2
  PLOT x,100+SIN(2*x*PI/180)*50
NEXT x

However I see the values jump around 90 deg, see video here

https://twitter.com/ZxSpectrumBot1/statu...twCv438ECA

I cannot find any reference in the doc , it is supposed to be sinclair compatible, but in sinclair basic it works ok

https://twitter.com/ZxSpectrumBot1/statu...twCv438ECA

thanks a lot

Print this item

  Binary into asm
Posted by: Nando - 2022-07-31, 01:27 AM - Forum: Help & Support - Replies (12)

Hi everyone.

I'm trying to create a routine in assembly to copy an image from memory to the screen (a third of the screen, centered)
I know the assembly code to do this.
But, in ZX Basic, afaik, I must include the image from a bin file, and label it (I know how to do that)
So, if I need to use the address of the bin file, in Basic I would use @label (and this works)
But how to I use this label inside an asm routine?

Code:
art:
asm
incbin "final.bin"
end asm

pause 0
paper 0: ink 7: border 0: CLS

asm
ld hl,(_art)
ld de,18434
ld bc,2048
ED
LDIR
RET
end asm

It's probably some syntax issue. I need to load HL with the address of the bin file, but get "error: Undefined GLOBAL label '._art'" when compiling

Print this item

  Set Number Layout to xx.00?
Posted by: Lars_74 - 2022-07-29, 12:11 AM - Forum: Help & Support - Replies (1)

Hi,
I have been trying all evening to work on a very easy task. Well, I thought it would be easy... Nothing really worked and the only positive sideffect is that I learned a lot about ZX Basic.

I would like to set the number's layout to xx.00 Because it looks nicer.

Examples:
1.5 > 1.50
1 > 1.00
.1 > 0.10

The only thing I could come up is to work on two levels.
level a: the correct numbers the computer is working with, e.g. 12.012345
level b: the number handed over to a Sub-Routine which switches the number to a string, searches for "." and gives back a formated string to the main routine.


Thus: the Spectrum works with level a (number), the user only sees level b (string).

Is it really that difficult or is it me being just to stupid...?
Lars

Print this item

  HRPrintFast
Posted by: Nando - 2022-07-23, 08:42 PM - Forum: Help & Support - Replies (2)

Hello all.
This is my first post here.
I used to do some platform games in Sinclair Basic back in the early 90s, and am now planning on writing a new game using ZX Basic (kudos to Boriel for the fantastic work btw)
I am just begining so I might be making some silly questions, sorry in advance Wink

I am considering using HRPrintFast for sprites (in a similar way I used print back in the day, but without the 8pixel block limitation)
But the routine calls for 2 asm tables,  "Screentables.asm" and "Rotatetables.asm", which are not included (as far as I could see) in the library.
There is a link to a dropbox in the forum, but it's dead.
Can anyone help me get the asm code to make the routine work?

Thanks in advance.


Sorry, I think I just found them in another routine, on another post

Print this item