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 62 online users.
» 0 Member(s) | 60 Guest(s)
Applebot, 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: 679
How to open fuse as an ex...
Forum: How-To & Tutorials
Last Post: Duefectu
2026-02-09, 01:52 PM
» Replies: 3
» Views: 1,060
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

 
  INK 8 and DIM issues (*solved*)
Posted by: LTee - 2009-07-07, 03:57 PM - Forum: Bug Reports - Replies (11)

Hi - I posted these in the blog comments before I realised that this forum existed, so I've reposted them here in case they go unnoticed "out there". :-D

----

Hi Boriel, just been messing around with the compiler a little with an old BASIC game I had lying around and I’m having a little trouble with the INK and PAPER commands.

In ZX Basic you can use INK 8 and PAPER 8 when printing to specify that the character should be printed in ‘whatever colour the screen currently is’, but this doesn’t seem to be supported at the minute by the compiler.

e.g.

Code:
PRINT AT 0,0; INK 8; PAPER 8; “X”

… would be red/blue if position 0,0 was already red/blue, green/yellow if position 0,0 was already green/yellow, etc.

The code for setting ink and paper in the compiler appears to do an AND 7; on the passed parameter so it always gets printed as ‘black/black’.

Is there a way around this? I’m using the very latest dev version, btw. :-)

Thanks for all your hard work!

---

Actually, while I’m here… :-)

–array-base=1 seems to be broken in the latest dev build. If you use that parameter it is impossible to set the very first entry in the array (position 1) although subsequent positions are okay. A compiler warning is generated but the code crashes when it runs.

e.g.
Code:
10 DIM p$(2)
20 LET p$(1) = “A”
30 LET p$(2) = “B”

The compiler generates a warning for line 20 (but not line 30) when given –array-base=1. The code works okay if line 20 is removed.

Print this item

  Multiple Entry Points
Posted by: LCD - 2009-06-26, 06:00 PM - Forum: Wishlist - Replies (2)

HiSoft Basic offers this: You can define multiple entry points for the code using REM : #OPEN at every line, where a entry point is possible, then at compilation time it displays for every entry point the USR Adress.

Print this item

  Efficiency Optimizations
Posted by: britlion - 2009-05-21, 03:27 PM - Forum: Wishlist - Replies (1)

I know, I know - I'm always harping on about this.

1> Does setting array and string indexes to start at 1 - to make it like basic - make for less efficient code?
(that is using the new default for --sinclair that Boriel is presumably putting into the next version)

2> Boriel once mentioned that the default behavior for code like:

Code:
LET A=A+1
LET A=A*2

Was

Code:
ld a, 10               ;Init
   ld (_A), a            ;Load
   inc a                   ;Inc
   ld (_A), a            ; Store         <<<<< Not needed
   sla a                   ; Multiply
   ld (_A), a            ; Store

And that -O3 should remove that extra code. I actually can't tell the difference in the above with or without -O3.

What does -O3 do? My code seems to be remarkably similar. In fact, the runtime routines for almost everything are included still - most of the print system (AT, COLOR, BOLD, ITALIC) even if never used).

Is -O3 doing what it's supposed to? I find most short code seems to be just about the same size, suggesting it isn't cutting down on runtime routines at all.

Actual program used:

Code:
DIM A as byte

LET A=5
LET A=A+1
LET A=A*2

PRINT A

Actual -O3 Result:

Code:
E:\ZX\ZXBwork>zxb Test2.bas -A -O3
INFO: __PRINTI8 is not defined. No optimization is done.
INFO: PRINT_EOL is not defined. No optimization is done.

E:\ZX\ZXBwork>notepad Test2.asm

The produced code was 1134 bytes without -O3 and 1132 bytes with -O3.

The difference is the end of the program. Optimized it does
Code:
ld bc, 0
Unoptimized it closes out with
Code:
ld hl, 0
ld b, h
ld c, l

That's the only difference.
These error messages seem a little odd. Am I misusing the -O3 option, somehow? I was expecting it to cut out all the runtimes that wouldn't be needed.

Admittedly in a larger project, most of the runtimes would likely end up being used. I was a little spoiled by the tiny code that the hisoft compiler made, I think :-)

Print this item

  Color control codes
Posted by: LCD - 2009-05-21, 02:37 PM - Forum: ZX Basic Compiler - Replies (7)

Hallo boriel, you wrote, the control codes can be used like in BasIn, I tested it:

Code:
print at 0,0;"\{i7}\{p2}\{b1}Test"
works fine, but BasIn allows this too:
Code:
print at 0,0;"\{i7p2b1}Test"
which does not work. Is this a bug?

Quote:The escape sequences for control characters are as follows:
\{in}
Ink colour n, where n is in the range 0 to 7.
\{pn}
Paper colour n, where n is in the range 0 to 7.
\{bn}
Bright n, where n is 0 or 1.
\{fn}
Flash n, where n is 0 or 1.
Note: Control character escape sequences can be combined, so that for instance \{i6p1f1} is equivalent to \{i6}\{p1}\{f1} - flashing yellow ink on blue paper.

Btw: Release 1.2.1 is excellent. My latest test Program needed 8 Kb before, now it is only 4 Kb...

Print this item

  Version 1.2.1 released!
Posted by: boriel - 2009-05-20, 12:18 AM - Forum: ZX Basic Compiler - No Replies

Changes since 1.2.0

  • ! This version just fix a possible memory corruption (reported by britlion, thanks).
    But still needs more checking...
  • ! DIM f% = <value> was not allowed. Now it is.
  • Programs can now be re-runable without having to LOAD them again once returned to BASIC.
  • * Some little improvements on memory organization. Now all user-data (HEAP and VARs) are in a single contiguous block.
    This will make possible to implement SAVE "" DATA in the near future so a program can LOAD & SAVE data.

TO DO:
... Many things! Wink

Print this item

  Bug: String Slicing (*solved*)
Posted by: britlion - 2009-05-19, 08:42 PM - Forum: Bug Reports - Replies (7)

I think string slicing still has bugs in it. Not quite sure why this fails, but it produces code that runs briefly and crashes, running in Spectaculator:
(fails with or without the DIM statements, but crashes differently in each case)

Code:
DIM A$,p$ as string
DIM start,fin as integer

10 LET a$="This is a very long scrolly string that I am going to print"
20 LET start=1
30 LET fin=32
40 LET p$=a$(start TO fin)
50 LET start=start+1
60 LET fin=fin+1
70 IF fin>LEN a$ THEN LET fin=1  : END IF
80 IF start>LEN a$ THEN LET start=1 : END IF
90 PRINT AT 0,0;p$
100 IF start<fin THEN GO TO 40 : END IF
110 LET p$=a$(start TO )+a$( TO fin)
120 GO TO 50


Correcting the 1 to Zero (Since in compiled code the strings begin slicing at zero) has no effect other than change the way it crashes:

Code:
DIM A$,p$ as string
DIM start,fin as integer

10 LET a$="This is a very long scrolly string that I am going to print"
20 LET start=0
30 LET fin=31
40 LET p$=a$(start TO fin)
50 LET start=start+1
60 LET fin=fin+1
70 IF fin>LEN a$ THEN LET fin=0  : END IF
80 IF start>LEN a$ THEN LET start=0 : END IF
90 PRINT AT 0,0;p$
100 IF start<fin THEN GO TO 40 : END IF
110 LET p$=a$(start TO )+a$( TO fin)
120 GO TO 50

Print this item

  Making ZX Basic to work with Tommy Gun
Posted by: boriel - 2009-05-17, 01:47 PM - Forum: How-To & Tutorials - Replies (8)

Tommy Gun is a great Retro-develpment IDE.
As of version 0.9.39 it's author add some modifications so ZX Basic compiler will also work with this excellent IDE.

Just follow this steps:

  • Download & Install Tommy Gun (v. >= 0.9.39)
  • Download & Install ZX Basic .MSI version for Windows (see http://www.boriel.com/files/zxb)
  • On the Tommy Gun IDE Config options, go to Build Settings, and configure builder options as shown (ZX Basic already comes pre-configured):
    [Image: attachment.php?aid=298]
  • Save them, and you're done!


Only the remarked (in red) fields are necessary.

From now on, you have syntax highlighting and error line location. To go to an error line, just click on the compilation error message and the cursor will jump to the respective line automatically.

You might be interested in changing some command line options (to change output format, etc...). See command line options documentation for more info.



Attached Files
.png   Captura de pantalla de 2020-05-03 11-39-58.png (Size: 53.91 KB / Downloads: 2244)
Print this item

  Version 1.2.0 released!
Posted by: boriel - 2009-05-12, 01:06 AM - Forum: ZX Basic Compiler - No Replies

Changed from Version 1.1.9 to 1.2.0

  • ! Undeclared local variables caused a compiler error.
    They should just compile (like global ones do). Thanks, LCD.
  • ! String variables used in string slices where sometimes
    optimized (ignored). Thanks, LCD, again. Wink
  • ! ELSEIF constructions were not being compiled correctly.

TODO:
  • Bitwise instructions for AND, OR, XOR, NOT
  • CLEAR to fill memory areas
  • READ, DATA and RESTORE
  • SAVE & LOAD

Print this item

  optimised INCR & DECR variable
Posted by: LCD - 2009-05-11, 11:02 PM - Forum: Wishlist - Replies (2)

Because I also coded some stuff in AMOS on Amiga: How about optimised INCR and DECR commands for variables? This can be easyly optimised because Z80 knows INC and DEC commands, and variable=variable+1 is maybe much slower.
INCR variable incrases the value by one. This will be very handy, I think Smile.

Print this item

  STR problem (*solved*)
Posted by: LCD - 2009-05-11, 02:19 PM - Forum: Bug Reports - Replies (12)

Code:
SUB MeineRoutine(x as uinteger,y as uinteger,a$ as string)
IF a$="Test" THEN erg$="Es wurde nur getestet"
ELSE erg$=a$+str(x)+" "+str(y)
end if

PRINT erg$
END SUB

MeineRoutine(30,11,"Hallo")
Compiler claims "temp.bas:48: Error: Undefined label '_MeineRoutine_erg' Errors occured, compilation failed" (No line 48 defined)
I guess, this is a Problem with STR because this:
Code:
dim a as ubyte
a=20
print str(a)
Produces a code that crashes the Emulator

BTW: should POKE STRING adr,string$ work? I mean, if POKE UINTEGER works...

Print this item