Questions about FZX

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

Questions about FZX

Post by Alessandro » Tue Jul 24, 2018 12:50 pm

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?
0 x

User avatar
R-Tape
Site Admin
Posts: 1672
Joined: Thu Nov 09, 2017 11:46 am

Re: Questions about FZX

Post by R-Tape » Tue Jul 24, 2018 3:41 pm

Alessandro wrote:
Tue Jul 24, 2018 12: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...
1 x

User avatar
Alessandro
Manic Miner
Posts: 233
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro » Tue Jul 24, 2018 3:47 pm

R-Tape wrote:
Tue Jul 24, 2018 3: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 3:41 pm
You might find z88dk useful for FZX too.
Unfortunately it's of no use to me because I cannot code in C.
0 x

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF » Tue Jul 24, 2018 4: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.

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 4:56 pm, edited 2 times in total.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Questions about FZX

Post by Seven.FFF » Tue Jul 24, 2018 4:12 pm

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
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
utz
Berk
Posts: 46
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Questions about FZX

Post by utz » Tue Jul 24, 2018 4:49 pm

Alessandro wrote:
Tue Jul 24, 2018 12: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.
0 x

User avatar
emook
Berk
Posts: 10
Joined: Mon Nov 13, 2017 1:04 pm
Location: Manchester, England
Contact:

Re: Questions about FZX

Post by emook » Tue Jul 24, 2018 7:59 pm

Hello

I have an example of using FZX with Boriels ZXB.

I’ll post it shortly when back on the PC.
0 x

User avatar
Alessandro
Manic Miner
Posts: 233
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro » Tue Jul 24, 2018 9:33 pm

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 7: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
0 x

User avatar
utz
Berk
Posts: 46
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Questions about FZX

Post by utz » Tue Jul 24, 2018 9:38 pm

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.
0 x

User avatar
Alessandro
Manic Miner
Posts: 233
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Questions about FZX

Post by Alessandro » Tue Jul 24, 2018 10:17 pm

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.
0 x

Post Reply