Custom Fonts and the programmers that love them.

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Custom Fonts and the programmers that love them.

Post by Nomad »

So looking through OUTLET and the rather excellent work of djnzx48

viewtopic.php?f=6&t=425&hilit=font#p5596

got my noggin' jogging - is there an easy way to load a font to use in a.) a BASIC program b.) an Assembly program.

Being a simple potato while I appreciate the work of the 64 column fonts I gotta lay it out for you fellows I don't quite get how to load the font data so you can use it in a program. I get whats happening in the program - the juicy code is the binary. My problem is this is a masterpiece in compact coding. As a starchy beginner a more basic example would be much appreciated.

I remember looking through some of the spectrum books there was one reference to using a custom font, but my memory fails me what the book was. Any link to a book or a article in the magazine would be much appreciated. If anyone is feeling generous a explanation on how to do it would be fantastic.

I can't remember the book but the sentiment of the statement I did recall 'You should use a custom font when creating a program. Don't be lazy!' :lol: Have to say I agree with the author and I have this feeling I am being a giant hack by not doing this with my programs in the past. I want to fix this.
User avatar
Alessandro
Dynamite Dan
Posts: 1908
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Custom Fonts and the programmers that love them.

Post by Alessandro »

Standard, 32-characters per line fonts, can be customized this way.

For Z80 assembly programs, just have your font in memory at an address, say FONT_ADDRESS, and then you have to make CHARS (23606) point at it:

Code: Select all

LD HL,FONT_ADDRESS-256
LD (23606),HL
In BASIC:

Code: Select all

POKE 23606,FONT_ADDRESS-256*INT (FONT_ADDRESS/256) 
POKE 23606+1,INT (FONT_ADDRESS/256)
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Custom Fonts and the programmers that love them.

Post by Nomad »

Thanks Alessandro, much appreciated.

I should have dug harder and actually googled this. :lol:

10 year old blog post:

http://szeligaski.blogspot.co.uk/2008/1 ... r-set.html

3 months ago:

https://markhardisty.wordpress.com/2018 ... ames-font/
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: Custom Fonts and the programmers that love them.

Post by Einar Saukas »

A very easy method is, load a custom font at address 64000, then POKE 23607,249

Code: Select all

10 CLEAR 63999
20 LOAD ""CODE 64000
30 POKE 23607,249
You can find lots of custom fonts in ZX-ALFA.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Custom Fonts and the programmers that love them.

Post by Nomad »

Obrigado, muito agradável.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Custom Fonts and the programmers that love them.

Post by Seven.FFF »

I'm a big fan of Einar's FZX proportional fonts. I'm even using it in Robotron where the font is almost (but not quite) fixed width.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Joefish
Rick Dangerous
Posts: 2041
Joined: Tue Nov 14, 2017 10:26 am

Re: Custom Fonts and the programmers that love them.

Post by Joefish »

In assembly, write your own print routine, then the font can be any form you want. Or you write the routine around how the font is stored.
You can load a font in memory and POKE the system variables to point to it then use ROM printing if you like things slow.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: Custom Fonts and the programmers that love them.

Post by Ast A. Moore »

Joefish wrote: Tue May 01, 2018 4:49 pm if you like things slow.
That’s putting it mildly. ;)
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
PeteProdge
Bugaboo
Posts: 3521
Joined: Mon Nov 13, 2017 9:03 am

Re: Custom Fonts and the programmers that love them.

Post by PeteProdge »

Last week I watched ChinnyVision's review of Toobin'. It's a multi-format review, so as well as covering the Spectrum, platforms such as the C64, Amiga, PC, etc, are in there.

What really surprised me is the 16-bits using the Sinclair ROM font!
https://www.youtube.com/watch?v=htk_JW-s74M

Strangely, the Spectrum version uses a custom font.
Reheated Pixels - a combination of retrogaming, comedy and factual musing, is here!
New video: Nine ZX Spectrum magazine controversies - How Crash, Your Sinclair and Sinclair User managed to offend the world!
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Custom Fonts and the programmers that love them.

Post by Nomad »

PeteProdge wrote: Tue May 01, 2018 5:41 pm What really surprised me is the 16-bits using the Sinclair ROM font!

Strangely, the Spectrum version uses a custom font.
[media]https://www.youtube.com/watch?v=3sXQoGcMN1U[/media]

That is so random... :lol:
User avatar
Kweepa
Manic Miner
Posts: 311
Joined: Sat Feb 03, 2018 6:14 pm
Location: Albuquerque, New Mexico

Re: Custom Fonts and the programmers that love them.

Post by Kweepa »

Speaking of FZX, I'm working on a crap game and I tried for several hours to get the latest Z88DK (1.99B and the nightly) to link and use FZX fonts.
I remember it was pretty easy 5 years ago, but now that they are built in to Z88DK it seems to be more complicated.
The example project has a bunch of weird parameters on the command line (-vn, -clib=new, -startup=31) but I tried those and it still refused to link.
I gave up and wrote my own (limited) routines in C.
Does anyone have a dummy's guide for FZX & the latest Z88DK? :)
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Custom Fonts and the programmers that love them.

Post by Seven.FFF »

I use it with asm, so afraid not. I know AA has put a bunch of effort into additional features, so he’d be the best person to ask, I should think.

I think it has those parameters because he’s used it to implement stdout in some of the runtimes, so you can set up scrolling windows and use printf() or whatever you C guys do.

In its assembly form it’s about as simple to use as the ROM print routines, for sure. You could probably still manually use it like that, but I can just hear AA in my head saying that wouldn’t be a good idea :D
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
bob_fossil
Manic Miner
Posts: 654
Joined: Mon Nov 13, 2017 6:09 pm

Re: Custom Fonts and the programmers that love them.

Post by bob_fossil »

Kweepa wrote: Tue May 01, 2018 6:09 pm Does anyone have a dummy's guide for FZX & the latest Z88DK? :)
This seemed to work when I was playing around with it a couple of months ago:

Code: Select all

// main.c 

#include <arch/zx.h>	// INK / PAPER #defines

#include <font/fzx.h>
#include <rect.h>

// fzx state

struct fzx_state fs;

// rectangles defining areas on screen

struct r_Rect16 screen = { 0, 256, 0, 192 };	// whole screen
char txt_intro[] = "www.spectrumcomputing.co.uk";

main()
	{
	fzx_state_init(&fs, &ff_dkud3_Notes, &screen);   // sets xor mode by default

	fs.fgnd_attr = INK_BLACK | PAPER_WHITE;
	fs.fgnd_mask = 0;

	fs.y = 32;
	fs.x = 0;

	fzx_puts(&fs, txt_intro);
		
	return 0;
	}
and then to compile:

Code: Select all

zcc +zx -vn -startup=31 -clib=new main.c -o fzx.bin -pragma-include:zpragma.inc
where zpragma.inc contains:

Code: Select all

// COMPILE TIME CRT CONFIGURATION

#pragma output CRT_ORG_CODE = 32768      // org of compile
#pragma output REGISTER_SP = 0x7500 	// typical stack location when using sp1

#pragma output CLIB_MALLOC_HEAP_SIZE = 0          // no malloc heap
#pragma output CLIB_STDIO_HEAP_SIZE = 0          // no stdio heap (no files)

#pragma output CLIB_FOPEN_MAX = -1         // no FILE* list
#pragma output CLIB_OPEN_MAX = -1         // no fd table
User avatar
Kweepa
Manic Miner
Posts: 311
Joined: Sat Feb 03, 2018 6:14 pm
Location: Albuquerque, New Mexico

Re: Custom Fonts and the programmers that love them.

Post by Kweepa »

Thanks for the pointers!
Post Reply