Questions about FZX

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Questions about FZX

Post by Alessandro »

1. How do you change the color of a text block printed with FZX? The INK command does not work.

2. Is there a way to implement FZX in ZX-Basic (i.e. "Boriel's Basic")? The compiler won't accept the PRINT#4 command (whereas the old and reliable HiSoft BASIC will).

3. Is there a way to implement the FZX driver in a pure Z80 assembly code, pointing to a string defined by DEFM?
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: Questions about FZX

Post by R-Tape »

Alessandro wrote: Tue Jul 24, 2018 1:50 pm 1. How do you change the color of a text block printed with FZX? The INK command does not work.
You'd have to write your own routine, standard FZX doesn't cater for colour as it doesn't operate within attribute boundaries.*
3. Is there a way to implement the FZX driver in a pure Z80 assembly code, pointing to a string defined by DEFM?
My Woot! engine might be exactly what you're after. You point IX at a string and CALL FZXprint and the rest was taken care of, including text wrapping. It became very specialised for the purpose though, so I will need to clean it up a bit before sharing.

You might find z88dk useful for FZX too.

Don't know about #2 sorry.

*awaits correction from Einar...
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro »

R-Tape wrote: Tue Jul 24, 2018 4:41 pm You'd have to write your own routine, standard FZX doesn't cater for colour as it doesn't operate within attribute boundaries.*
:( Bummer.
R-Tape wrote: Tue Jul 24, 2018 4:41 pm You might find z88dk useful for FZX too.
Unfortunately it's of no use to me because I cannot code in C.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF »

AA has greatly extended the capabilities of the FZX driver in z88dk, and also provited a stdout crt that uses it. But I don't code in C either. I'm pretty sure you can get z88dk to emit intermediate asm, which you could incorporate into your own framework. But that seems too fiddly for me.

For the asm version, I just mod it as I need it. I have an xor version, and supported some other control characters as well as AT.

For attributes though, I I don't usually bother rendering them inside FZX. I either set them first, in my clear screen routine, or else I use a scripting system I developed that can storyboard screens, and which printing FZX chars is only one small part of.

I don’t use the channel driver, I have the entire FZX_DRIVER section commented out. I call FZX_START directly, one byte at a time, like this:

Code: Select all


			PrintTextFont(SampleText, Fonts.MyFZXFile)          

PrintTextFont           macro(Address, Font)
                        ld hl, Font
                        ld (FZX_FONT), hl
                        ld hl, Address
PrintMenu:              ld a, (hl)                      ; for each character of this string...
                        cp 255
                        jp z, End                       ; check string terminator
                        or a
                        jp z, Skip                      ; skip padding character
                        push hl                         ; preserve HL
                        call FZX_START                  ; print character
                        pop hl                          ; recover HL
Skip:                   inc hl
                        jp PrintMenu
End:
mend

At                      equ 22

Sample Text:		db At, 10, 30, "Sample", 255
Last edited by Seven.FFF on Tue Jul 24, 2018 5:56 pm, edited 2 times in total.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF »

I also used FZX fonts (but not Einar's driver) in my Next teletext renderer, for single height, double height and sixel graphics. This works without attribute clash, by drawing on the fairly beefy layer 2 screen (48K, 1 byte per pixel, standard res).

Image
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
utz
Microbot
Posts: 113
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Questions about FZX

Post by utz »

Alessandro wrote: Tue Jul 24, 2018 1:50 pm 3. Is there a way to implement the FZX driver in a pure Z80 assembly code, pointing to a string defined by DEFM?
You can simply call FXZdriver.asm::START with a character held in the A register. The character can be 0x16 (representing an AT keyword), which can then be followed up with a horizontal and vertical pixel position. Note that the routine will clobber registers HL, DE, BC, and IX. The code in the "CREATE CHANNEL AND ATTACH STREAM" section can be safely omitted when using pure asm.
User avatar
emook
Drutt
Posts: 36
Joined: Mon Nov 13, 2017 1:04 pm
Location: Manchester, England
Contact:

Re: Questions about FZX

Post by emook »

Hello

I have an example of using FZX with Boriels ZXB.

I’ll post it shortly when back on the PC.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro »

I tried the following code:

Code: Select all

  ORG 59500

  LD HL, TEXT
STAMPA:  LD A,(HL)
  CP 255
  RET Z
  OR A
  JP Z, SKIP
  PUSH HL
  CALL START
  POP HL
SKIP:  INC HL
  JP STAMPA

TEXT: DEFB 22,0,0,"Test message",255

  ORG 60000

FONT:  INCBIN "Chloe.bin"

; -----------------------------------------------------------------------------
; FZX driver - Copyright (c) 2013 Einar Saukas
; -----------------------------------------------------------------------------

        org     65000           ; driver address

; FONT    EQU     60000           ; font address

MARGIN  EQU     0               ; left margin (in pixels)

STR_NUM EQU     4               ; stream #4

; -----------------------------------------------------------------------------
; PROPORTIONAL PRINT ROUTINE

START: [...]
Unfortunately it does not work as intended, it just prints "st message" in the middle of the screen.
emook wrote: Tue Jul 24, 2018 8:59 pm Hello

I have an example of using FZX with Boriels ZXB.

I’ll post it shortly when back on the PC.
Sounds great! :) I will wait for it, then
User avatar
utz
Microbot
Posts: 113
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Questions about FZX

Post by utz »

Don't skip the position bytes. Pass them to the driver after you've passed the AT token. The way you have it now, the first two chars of "TEST" are interpreted as the position ;)

In other words, throw out the "or a, jp z,..." and you should be fine.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro »

Tsk :x I should have minded that OR A instruction, it was a leftover from Seven's code. Thanks for pointing that out.

As for the attributes, I believe I will have to print the text in an area of the screen where there is no need for them, e.g. plain blocks of text, and leave higlighted text to a custom 32-characters-per-line font.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF »

Yes, sorry. That’ll teach me to copy my own code without reading it or checking it’s the correct version.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro »

Seven.FFF wrote: Tue Jul 24, 2018 11:43 pm Yes, sorry. That’ll teach me to copy my own code without reading it or checking it’s the correct version.
No probs at all :) you showed me the right direction after all.

Now, there is only question 2 left...
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF »

In promotional FZX fonts, I define a few alternate width spaces: -1px, +1px, +2px, etc. Then I try to adjust my words with these spaces so they fit better on the character boundaries.

In this way, you can still use attributes to highlight words, and the variable spacing is not very noticeable.

Sometimes I even change the horizontal spacing for an individual letter, if this will make the character boundaries align.

Defining a blank char (space) in FZX only ever takes three extra bytes, even if it is the largest possible size of 16px wide and 256px high. So having alternate width spaces is a nice easy cheap thing to do.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro »

Any ideas on how to implement FZX in ZX-Basic?
User avatar
oblo
Drutt
Posts: 31
Joined: Mon Dec 10, 2018 9:24 pm

Re: Questions about FZX

Post by oblo »

Alessandro wrote: Tue Jul 31, 2018 11:16 am Any ideas on how to implement FZX in ZX-Basic?
Sorry to bring up an old post and I hope you get a way to to that (at least I couldn't)
What I do to edit customized fonts is to use the Font Editor that BorIDE provides.

Image

Once you have the set of fonts you want, just click on File -> Export -> Export Byte Clipboard (or whatever other format you want) and you can paste them on your favourite text editor something like this:

Dim font (767) As uByte => { _
0, 0, 0, 0, 0, 0, 0, 0, _
24, 24, 24, 24, 24, 0, 24, 0, _
...................................
...................................
118,220, 0, 0, 0, 0, 0, 0, _
204, 51,204, 51,204, 51,204, 51 _
}
Poke uInteger 23606, (@font (0)) - 256


HTH
Cheers.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro »

Thank you for the answer, but I am not confortable with BorIDE. I prefer to edit files through Notepad++.

In the end I could not find a way to do it and left FZX fonts aside altogether.
Alcoholics Anonymous
Microbot
Posts: 194
Joined: Mon Oct 08, 2018 3:36 am

Re: Questions about FZX

Post by Alcoholics Anonymous »

Seven.FFF wrote: Tue Jul 24, 2018 5:06 pm AA has greatly extended the capabilities of the FZX driver in z88dk, and also provited a stdout crt that uses it. But I don't code in C either. I'm pretty sure you can get z88dk to emit intermediate asm, which you could incorporate into your own framework. But that seems too fiddly for me.
z88dk is not just about C; C is one component of the toolset that includes assembler, linker, macro processor, librarian, etc. It has about 1000 assembly language subroutines that are easily available in library form. To use an asm subroutine you just indicate you want to use it with an EXTERN directive and then you call it. The linker automatically pulls that asm routine out of the library and into your binary and only that asm routine plus its dependencies. It's how all commercial tools work.

The fzx implementation in z88dk is expanded quite a bit:

* colour printing with masked attributes
* pixels are mixed with the display using OR, XOR or CLEAR modes
* printing is done to a window on screen defined by a rectangle
* left margin is definable
* spaces can be expanded by a definable number of pixels

This information, along with current x/y coord, is carried in a structure (in asm this is a collection of bytes) that acts like a print context. This structure is used to remember state between calls; multiple structures can be used for independent print state.

A bunch of utility functions accompany this. Functions return size related information about the font, individual characters of a font, pixel width of strings or buffers, and word wrap functions that tell you how to split a string or buffer at spaces given available number of pixels. You can print strings or buffers left justified like usual or fully justified with space padding.

As an example of usage, the fzx putc function for the spectrum 256x192 display is located here.

To call it, you'd just do this:

Code: Select all

   EXTERN asm_fzx_putc   ;; inform the assembler & linker that this subroutine is elsewhere (it's in the library)

   ld ix,fzx_state   ;; address of structure holding fzx state
   ld c,'H'   ;; ascii code to print
   
   call asm_fzx_putc
And that's it. The linker will pull in the code shown above and its minimum set of dependencies exactly once in your project.

On top of this, fzx terminals are implemented. Terminals are text streams for display devices. In Sinclair-speak they're like channels. Channel 2 on the spectrum is for printing to the top part of the screen. Channel 3 is normally printer iirc. The io model in C is the one implemented in unix (C was created to write unix after all). stdin is the stream for typing input and stdout is the stream for printing to the standard display. The fzx terminal allows printing and text entry via keyboard with the text entry editable. There can be multiple text terminals in windows so you could create, for example, multiple fzx windows on screen with independent printing. The print stream can optionally contain control codes for things like setting colour, changing print position, whether to generate a scroll prompt and so on.

Anyway, that's the overview.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF »

Thanks for the good explanation :)
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
C.Born
Manic Miner
Posts: 202
Joined: Sat Dec 09, 2017 4:09 pm

Re: Questions about FZX

Post by C.Born »

WHY is the fzx DEMO called an EDITOR while thats al it AINT ??
https://spectrumcomputing.co.uk/entry/2 ... tEditorFZX

sorry, but i dont get it.

and i am on linux so escape routes like
a) out side zx
b) abandonware on overregistered systems
c) forgot to implement
are NO excuse

:geek:

ps i DID repair the old man, but without an editor!
cborn.nl/zxfiles/OldEnglish.fzx
and this is my work disk
cborn.nl/zxfiles/fzx002.mgt.7z
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: Questions about FZX

Post by Einar Saukas »

C.Born wrote: Thu Jan 11, 2024 7:31 pm WHY is the fzx DEMO
This is not the FZX demo.

The FZX demo is here.

C.Born wrote: Thu Jan 11, 2024 7:31 pm called an EDITOR while thats al it AINT ??
https://spectrumcomputing.co.uk/entry/2 ... tEditorFZX
It contains a conversion to FZX format of all fonts from the "Font Editor" that's included inside Proxima's Desktop. It's the reason it's called "DesktopFontEditorFZX".

This is explained under "remarks" in the link you mentioned.

C.Born wrote: Thu Jan 11, 2024 7:31 pm and i am on linux so escape routes like
a) out side zx
b) abandonware on overregistered systems
c) forgot to implement
are NO excuse
What do you mean?
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: Questions about FZX

Post by Einar Saukas »

C.Born wrote: Thu Jan 11, 2024 7:31 pm ps i DID repair the old man, but without an editor!
You can download the FZX Editor here:

https://www.alessandrogrussu.it/zx-modules.html
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: Questions about FZX

Post by Einar Saukas »

My apologies for not answering earlier questions sooner. I never noticed this thread until now...

It seems all other questions were answered already, except for this one:

Alessandro wrote: Tue Jul 24, 2018 1:50 pm 2. Is there a way to implement FZX in ZX-Basic (i.e. "Boriel's Basic")? The compiler won't accept the PRINT#4 command (whereas the old and reliable HiSoft BASIC will).
A practical example of using FZX with Boriel ZX Basic can be downloaded here:

https://spectrumcomputing.co.uk/entry/3 ... ixel_Quest
C.Born
Manic Miner
Posts: 202
Joined: Sat Dec 09, 2017 4:09 pm

Re: Questions about FZX

Post by C.Born »

thanks for the link, but that for Windows only, aka "outside zx"
i mean "no excuse for no native editor"
and i think what is called an editor is the driver with al examples.
meaning that in de ZXDATA base a wrong name is used, like you say , there AINT an editor IN THAT ZIP file ..
its not there and thats why i call it a demo, since what it does is Showing the different FZX fonts, very nice, but UNeditable, and then i feel dis-a-pointed aka pointed out into the wrong direction...
if its not a demo and not an editor, then what is it?
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: Questions about FZX

Post by Einar Saukas »

C.Born wrote: Fri Jan 12, 2024 10:10 am thanks for the link, but that for Windows only, aka "outside zx"
If you mean this editor:

https://www.alessandrogrussu.it/zx-modules.html

then it's not mine. But it should work on Linux using Wine.

C.Born wrote: Fri Jan 12, 2024 10:10 am i mean "no excuse for no native editor"
The FZX format is a binary file, that's explained in the official documentation. You can generate it by creating a simple ASM file (using any text editor in any platform), then assembling it. One of these ASM files is also provided in the official documentation as example.

Thus there's no excuse for not using FZX even without a FZX editor! :)

C.Born wrote: Fri Jan 12, 2024 10:10 am and i think what is called an editor is the driver with al examples.
The driver with all examples here is called driver. It's not called editor.

I don't understand your point...

C.Born wrote: Fri Jan 12, 2024 10:10 am meaning that in de ZXDATA base a wrong name is used
Wrong name? What do you mean?

C.Born wrote: Fri Jan 12, 2024 10:10 am like you say , there AINT an editor IN THAT ZIP file ..
No there isn't. Again what's your point?

C.Born wrote: Fri Jan 12, 2024 10:10 am its not there and thats why i call it a demo, since what it does is Showing the different FZX fonts, very nice, but UNeditable
The package called "FZXstandard.zip" contains a file called "Sinclair.fzx.asm". It's the source code of a FZX font called "Sinclair.fzx", provided as example. You can open it with any text editor. It's not uneditable.

This package also contains a text file explaining the FZX format.

C.Born wrote: Fri Jan 12, 2024 10:10 am and then i feel dis-a-pointed aka pointed out into the wrong direction...
if its not a demo and not an editor, then what is it?
Package "FZXdriver.zip" is the FZX driver source code.

Package "FZXstandard.zip" is the documentation, with a FZX font source code provided as example.

Package "FZX.tap.zip" is a tape file with a demo in Sinclair BASIC. If you want to see the source code, simply press BREAK.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF »

I think C.Born means that the name DesktopFontEditorFZX.tap implies there is an inbuilt editor, but it's just a set of fonts with a simple demo program. It's just a naming confusion. A lot of the other points are just observations like that, rather than questions or requests for help.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Post Reply