Page 1 of 1

Font base address in z88dk crt?

Posted: Tue Aug 01, 2017 1:07 pm
by Stefan123
Are the printable characters (32 to 127) of the standard Spectrum font (located at address 0x3D00 to 0x3FFF in the Spectrum ROM) copied by the z88dk crt startup code to some RAM address with a public symbol or does the z88dk crt have a public symbol for the font base in ROM?

Posted: Wed Aug 02, 2017 12:22 am
by alvin
Stefan123 wrote:Are the printable characters (32 to 127) of the standard Spectrum font (located at address 0x3D00 to 0x3FFF in the Spectrum ROM) copied by the z88dk crt startup code to some RAM address with a public symbol or does the z88dk crt have a public symbol for the font base in ROM?
In the newlib, crt0 an crt1 (startup=0 and startup=1) are the 32 column drivers. These use the font in rom but that can be changed at compile time with a pragma:

#pragma redirect CRT_OTERM_FONT_8X8 = __font_name__

There are four 8x8 fonts in z88dk: https://github.com/z88dk/z88dk/tree/mas ... t/font_8x8

You gave to use the names with leading underscore in this pragma because the pragma is active at the assembly language level. If you use one of these fonts, the font gets added to your binary.

If you want to point the font at an absolute address use the usual pragma output:

#pragma output CRT_OTERM_FONT_8X8 = 0x6000

At runtime, fonts can be changed via ioctl:

#include <stropts.h>
old_font_address = ioctl(1, IOCTL_OTERM_FONT, new_font_address); // fd=1 corresponds to stdout, new_font_address=-1 causes no change

or via control code in the text stream for tty_z88dk terminals:
printf("\x02%c%c", new_font_address & 0xff, new_font_address/256);


crt30 (startup=30) has just been added. This one is a very simple output through rst 16, which makes the driver small. There is no input channel on this startup. The basic system has to be available if rst 16 is used, such as the system variables being present, etc. You can use it like basic so you can poke 23606/23607 for font address, use codes 144 and up for udgs, etc.