ZX Basic 1.4 (beta) is out - Printable Version

+- Forum (
+-- Forum: Compilers and Computer Languages (
+--- Forum: ZX Basic Compiler (
+--- Thread: ZX Basic 1.4 (beta) is out (/showthread.php?tid=580)

Pages: 1 2 3

ZX Basic 1.4 (beta) is out - boriel - 01-29-2014

After almost a year (okay, only two month Wink ), a new version of ZX BASIC is out.
ZX BASIC 1.4 (not 2.x) is a huge step forward in terms of compiler design.
What to expect from this version? Nothing.
What? Nothing. ZX BASIC 1.4 is a huge refactor but tries to maintain 100% backward compatibility with previous releases.
Well, there are something you might expect: Bugs.
Please, if you want to help, at this moment, the best way is to recompile your old programs with this new version and report errors.
Another method is to generate --asm files with both 1.3.x and 1.4.x and compare (diff) them, to look for differences.

Okay, yes, there are things that have already improved:
  • ZX BASIC 1.4. corrects hidden bugs I've discovered on 1.3 (or which haven't happened because users don't use some BASIC features...)
    These bugs are hard to fix in the old version and will be there forever... But are already fixed in 1.4
  • ZX BASIC 1.4 already produces better code under some circumstances. Ej. @myArray(3, 4) only takes 2 asm instructions (hundreds of them before). Some POKE sentences also were not correctly optimized. They are now.
  • ZX BASIC 1.4 allows now nested scopes / functions (that is, declare a function / sub inside of another as in Pascal / C++ and some extended C compilers).
But other than that, stills the same.
The question is: OK, now I'm open to new features... and architectures (MSX, I'm looking at you). It's time to discuss then :twisted:

Download, as always, at the Download page.

Re: ZX Basic 1.4 (beta) is out - apenao - 01-29-2014

I have been compiling some old code and I have found a problem in one of the "games" I did some months ago (code can be found in the gallery forum, it's the "cicloples y Saturno game"

I try to compile with these parameters: -T -B -S 32768 -a %F.bas
and I get this warnings and error codes:
> Executing: C:\Spectrum\Mis documentos\Archivos de programa\ConTEXT\ConExec.exe -i "C:\Program Files (x86)\Boriel Tm\ZX Basic Compiler\zxb.exe" -T -B -S 32768 -a CI7E9E~1.bas

attr.bas:96: warning: FUNCTION 'attraddr' declared as FASTCALL with 2 parameters
input.bas:38: warning: Empty loop
alloc.bas:73: warning: FUNCTION 'reallocate' declared as FASTCALL with 2 parameters
Traceback (most recent call last):
  File "", line 348, in <module>
  File "", line 262, in main
  File "ply\yacc.pyc", line 263, in parse
  File "ply\yacc.pyc", line 710, in parseopt
  File "zxbparser.pyc", line 3025, in p_abs
NameError: global name 'is_unsigned' is not defined
> Execution finished.

It does compile ok with 1.3.0.s979

Strangely, the other game i did in that time "coches" compiles ok in both the previous and the new versions. They both share most of the code, but I included the "doublesizeprint" routine from the library in the game that doesn't compile. So it might be worth checking that first.

I'll upload the code in a while.

Edit: uploading code and dependent files

Re: ZX Basic 1.4 (beta) is out - apenao - 01-29-2014

I tried again with the Double Size Print routine in the library, this is the code:


doubleSizePrint(10,0,"Hello World")


SUB doubleSizePrintChar(y AS UBYTE, x AS UBYTE, thingToPrint AS UBYTE)
' Prints a single character double sized.
' Takes X and Y values as character positions, like print.
' takes an ascii code value for a character.
' By Britlion, 2012.

LD A,(IX+5)     ;' Y value
CP 22
JP NC, doubleSizePrintCharEnd

;' A=y value
AND 24             ; calculate
OR 64             ; screen
LD H,A             ; address
LD A,E             ; FOR
AND 7             ; row
OR a             ; Y

LD A,(IX+7)     ;' X Value
CP 30
JP NC, doubleSizePrintCharEnd

ADD A,E            ;' correct address for column value. (add it in)
EX DE,HL        ;' Save it in DE

LD A,(IX+9)     ;'Character

CP 164         ;' > UDG "U" ?
JP NC, doubleSizePrintCharEnd

CP 32          ;' < space+1?
JP C, doubleSizePrintCharEnd

CP 144         ;' >144?
JP NC, doubleSizePrintCharUDGAddress

LD H,0

ADD HL,HL    ;' multiply by 8.
LD BC,(23606)    ;' Chars
ADD HL,BC     ;' Hl -> Character data.
EX DE,HL    ;' DE -> character data, HL-> screen address.
JP doubleSizePrintCharRotateLoopCharStart

LD HL,(23675)    ;'UDG address
SUB 144
ADD A,A         ;multiply by 8.

JR NC, doubleSizePrintCharUDGAddressNoCarry

;' At this point HL -> Character data in UDG block.
EX DE,HL ;' DE -> character data, HL-> screen address.

LD C,2 ;' 2 character rows.
LD b,4 ;' 4 source bytes to count through per character row.

   LD A,(DE) ;' Grab a bitmap.

   LD B,4
   LD C,A ; Copy BYTE so we can put two into the big version.
      RRA  ; one bit into carry
      RR E ; one bit into result
      RR C ; same bit into carry again
      RR E ; duplicated bit into result
   DJNZ doubleSizePrintCharRotateLoop1

   LD B,4
       RR D ; Other register FOR other half of big 16 bit line.
       RR C
       RR D
   DJNZ doubleSizePrintCharRotateLoop2

   LD (HL),D    ;' Output first byte
   INC HL    ;' Move right
   LD (HL),E    ;' Second half.
   DEC HL    ;' Move left
   INC H    ;' Move down
   LD (HL),D    ;' Output second row (copy of first), first byte.
   INC HL    ;' Move right
   LD (HL),E    ; Output second row, second BYTE
   DEC HL    ; Move left
   INC H    ; Move down.
DJNZ doubleSizePrintCharRotateLoopCharRowLoopInner
; CALL __DECY+2     ;'Jump into the DRAW next_line_down routine, at a convenient point (accounting for the INC H above)
; Can't seem to call to this at the moment! Here in longhand form:

ld a, h
jr nz, doubleSizePrintCharRotateNextCharRow
ld a, l
add a, 32
ld l, a
jr c, doubleSizePrintCharRotateNextCharRow
ld a, h
ld h, a


JR NZ, doubleSizePrintCharRotateLoopCharRowLoopOuter


SUB doubleSizePrint(y AS UBYTE, x AS UBYTE, thingToPrint$ AS STRING)
'Uses doubleSizePrintChar subroutine to print a string.
'By Britlion, 2012

   FOR n=0 TO LEN thingToPrint - 1
      doubleSizePrintChar(y,x,CODE thingToPrint$(n) )
   NEXT n

It compiles ok and Works in the previous versión. In the new versión, it compiles ok (doesn't show any warning or message) but doesn't work (at least in my emulator, Specemu). It shows just one character and then freeze.

Re: ZX Basic 1.4 (beta) is out - apenao - 01-29-2014

Another "anormality" found.
In my old crap game "Steroids Sports: Diving", it compiles and Works ok with my previous versión. In the new versión, it compiles and Works just to the point I use the "Print64" routine from the library. At this moment, it starts writting a lot of garbage in the screen (in 64 columns) when it should be writting just a number (well, 3 different numbers) in a small box.

Re: ZX Basic 1.4 (beta) is out - boriel - 01-29-2014

Thanks a lot, @apenao
At this moment, all the bugs except the one in print64 (the last case) has been fixed.
Please Download and try... :roll:
I'll be fixing the last one, meanwhile...
UPDATE: I'ts fixed now. Please download 1.4.0s1754 (in the link above)

Re: ZX Basic 1.4 (beta) is out - apenao - 01-30-2014

I have checked a couple of things this morning while on work (don't tell my boss) and it seems ok now, but this night I want to make more test because I tried to compile (with the new versión) one of the demonstration programs included with ZXBC and it didn't work. I'll post later when I do the checkings.

P.S. Boriel here goes the program I told you yesterday. It's lacking a game inside but I won't give up in finishing it some day. I am very interested in the posibility of a spectranet support for ZXBC.

Re: ZX Basic 1.4 (beta) is out - apenao - 01-30-2014

I have done 3 test involving some of the programs in the example folder included with ZXBC:

Pong doesn't compile. It returns a long list of warnings.
Scroll doesn't compile (but it does not compile in 1.3 versión either)
Spfill compiles but it behaves incorrectly (doesn't fill with the expected pattern, while it behaves correctly if compiled with the 1.3 versión).

Others, like clock or freregustav are working OK.

Re: ZX Basic 1.4 (beta) is out - JBGV - 01-30-2014

Hello everyone.

Boriel, you come with good news! Big Grin

I'll try to compile any of my games tonight and tell you.

Re: ZX Basic 1.4 (beta) is out - JBGV - 01-30-2014

Well, it did not work: :roll:

The hobbit compiles but does not work well.

Abydos not compile:

.png   RETROB ERR.PNG (Size: 11.26 KB / Downloads: 16,080)

Vade Retro not compile:

.png   VADE RETRO ERR.PNG (Size: 14.74 KB / Downloads: 16,088)

Retrobsesion II not compile:

.png   ABYDOS ERR.PNG (Size: 14.51 KB / Downloads: 16,084)

Re: ZX Basic 1.4 (beta) is out - boriel - 01-31-2014

Okay, new version: ZXBASIC 1.4.0s1773.
Try this and tell me, please :roll:

Re: ZX Basic 1.4 (beta) is out - JBGV - 01-31-2014

Very nice! Big Grin

Compile and run all except Retrobsesion, that keeps on giving the same error.

It is the oldest of all, when I programmed it used this: zxb --org=28000 MAPA140e.bas -T -B -a --heap=2000

Re: ZX Basic 1.4 (beta) is out - boriel - 01-31-2014

Sorry, forgot to upload it. Try now: ZXBASIC 1.4.0s1779.

Re: ZX Basic 1.4 (beta) is out - ardentcrest - 01-31-2014

anything new added.

Re: ZX Basic 1.4 (beta) is out - JBGV - 01-31-2014

Ok, "Retrobsesion II" compiles and works perfectly Big Grin

Thanks !!

Re: ZX Basic 1.4 (beta) is out - apenao - 01-31-2014

I have re-compiled all the program I had previously tested and everything is working now.

Thanks Boriel Smile