Extended ASCII Characters

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
thweasel
Member
Posts: 15
Joined: Sun Oct 14, 2018 11:32 am

Extended ASCII Characters

Post by thweasel »

Hi I am a bit of a n00bie but,

I have been scratching about for the last few days trying to work this out. I don't seem to be having much luck with finding a good guide, or complete example to work from.

I am looking to add the extended ASCII fonts to the 80 column font set, the characters after 127 (http://www.asciitable.com/). This is for an ANSI Terminal application for BBS systems, so ANSI behaviours are required. For what I need I would be happy to swap back and forth between font sets assuming the change doesn't affect the characters on screen that have been placed. Or to put both font sets (127+127) back to back so printing character >128 magically appear when pushing character code over 128. Or using a single 255 ".FZX" character set.

Found the FZX Font Editor for drawing the fonts, which can then be saved as ".CHR" ".UDG" for less than 127 characters. Or ".FZX" or ".ASM" for a full 255 characters. Seen references to FZX font being supported, but I am looking to use classic ANSI mode, which I don't think supports FZX?

Also looked at including font/font.h which enables swapping the font set in printf(). This would do it if there was an extended font set... My attempts to hack in a line for my font into font.h, and placing a .bin file with .asm file in /libsrc/_DEVELOPMENT/Font/Font4x8, compile it to get a .o file work. BUT then I added to my print statement font_4x8_80columnx (my font), I get told off for it not being declared? If I swap the statement to any of the others, it works fine. My guess is I need to add my font to another file outside of font.h? I don't have a _zx7 or .zx7 version of the file not sure how to make one!

There seem to be several ways to do this, but everything I have found seems to only give me half the picture and not quite what I am looking for. So if anyone has an idiot proof way to handle two font sets or a one 255 font set, please help! Even if its just a pointer to the relevant section in the manual!

Thanks
Owen
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

For the ANSI engine it's possible to change the font on the ZX, see this link: https://github.com/z88dk/z88dk/wiki/Pla ... at-is-used

The format (for not packed) will be 8 bytes per character and I think in 80 column it will be the left-most bits (i.e. bits 7-5) that will be picked up.

I can't spot a limit on the characters - so anything from codes 32 -> 255 should be picked up fairly easily.

Similarly if you use the default screen driver in 64 column mode then it will handle codes > 128 (for this driver, the characters need to be mirrored in the font byte)
thweasel
Member
Posts: 15
Joined: Sun Oct 14, 2018 11:32 am

Post by thweasel »

Thanks, I seem to have stumbled through it somehow...

Using ASM to label and control the binary import at compile time. The editor seems to enforce the limit of 127 characters. I put 2 bin files in the ASM lump and that seemed to drop them somewhere back to back, so rolling past 127 prints extended characters? Then using the compile-time option to point to the ASM label for the fonts.

Some reason the alignment on the fonts is off, and it crops one side and includes the blank column when using the included fonts as subs for the font binary. If drawn in the right place they come out fine, just the best part of 255 fonts to draw!

(Main.c)
#include <conio.h>
#include <stdio.h>
#include <spectrum.h>
#include <input.h>

#asm
SECTION data_user ;

PUBLIC _fontname
_fontname:
BINARY "FONTFILE1.bin" ; // This BINARY holds the first 127 characters
BINARY "FONTFILE2.bin" ; // This BINARY holds the last 127 (128 - 255) characters, it gets parked behind the first set
#endasm

void main(void)
{
unsigned char ch;

for(int i=0;i<256;i++)
{
printf("i=%d - %c\n",i,i);
in_Wait(50);
}
}

Compiler options
zcc +zx -clib=ansi -pragma-redirect:ansifont=_fontname -pragma-define:ansifont_is_packed=0 -pragma-define:ansicolumns=80 -lndos
Post Reply