Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 315 online users. » 0 Member(s) | 313 Guest(s) Baidu, Bing
|
Latest Threads |
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 183
|
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 257
|
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,516
|
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 512
|
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 414
|
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 286
|
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,004
|
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,844
|
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 393
|
ZXodus][Engine
Forum: ZX Basic Compiler
Last Post: boriel
02-19-2025, 11:43 PM
» Replies: 69
» Views: 213,420
|
|
|
My first Boriel BASIC program: Guess Number |
Posted by: zarsoft - 11-30-2022, 10: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
|
|
|
REPEAT UNTIL (solved) |
Posted by: zarsoft - 11-28-2022, 06: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 color bug (*solved*) |
Posted by: Darkstar - 10-03-2022, 08: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.
|
|
|
Binary into asm |
Posted by: Nando - 07-31-2022, 12: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
|
|
|
Set Number Layout to xx.00? |
Posted by: Lars_74 - 07-28-2022, 11:11 PM - 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
|
|
|
Features breaking compilation in older ZXBasic programs |
Posted by: MrKOSMOS - 06-17-2022, 06:51 AM - Forum: Core
- Replies (1)
|
 |
Hello
So I've been using ZXBasic for a while, and after struggling for a while trying to compile some code finally realised some issues. To sum it up, I tried compiling Souls Remastered, since the keyboard input wasn't working on my Timex TC2048. However, while trying to compile I kept getting IF statement errors, which I attributed to the compiler itself. However, it turned out to be due to comments placed in front of the IFs, which were being recognized as one-line commands and "resolving" the IFs, creating errors with the END IFs afterwards. This seems to date back to a previous version before the one-line IF feature was implemented. In fact, many other ZXBasic games by Retrobytes and even the BerkzMan game from the tutorials page seem to expect this feature to be absent in order to compile, so providing a solution seems like a must.
So what do I propose? Well, I see two solutions: One, adding a legacy option for the compiler, say -L. This would be the easiest, and allow compilation of unmodified older code.
Two: implementing a routine that counts all IFs and END IFs in the program flow and checks if they are the same, as well as checking for comments in front of IFs. This may be a more robust solution, letting everyone program as they want without having to check some obscure command line option.
Aside from that, there seem to be a few other bugs. There seems to be no check for writing to memory above the 64k limit, since I have written a few programs that, when loaded through the BASIC loader, give an Out Of Memory error on the Spectrum. Other than that, there seems to be a bunch of data added along the print command, which I assume is a character set. But is this really necessary when the program only uses UDGs or spaces? In that case, the whole set could be left out, saving a decent amount of space. It could even be optionally left out, and swapped for the ROM character set.
Well that would be all, please say what you think
|
|
|
The Disputed Territories of Ghotto |
Posted by: Jbizzel - 03-21-2022, 05:29 PM - Forum: Gallery
- No Replies
|
 |
I made a new game
2 pixel scrolling city bomber type game, with a story built in.
Please let me know what you think.
Credits:
zx basic,
putChar
zx0
zx paint
beepfx
beepola
DamienG fonts
get it here
|
|
|
|