FZX is an excellent proportional font driver by Andrew Owen and Einar Saukas. The latest source code can be downloaded here, although the version I have added to the code for part 9 has been slightly modified.123
FZX is an indispensible font editor by Klaus Jahn. Download it from here by clicking on the image.
SetupMenu routine has a new section, as I’ve rewritten it to use a proportional font instead of the standard Spectrum font.
7 8 9 10 11 12
;menu.asm ld hl, Font.Namco ; Set FZX font ld (FZX_FONT), hl ld hl, MenuText.FZX ; Start of menu ASCII data PrintTextHL() ; Macro to print FZX proportional text with FZX
We set the font file to use 4, load
hl with the address of the new menu text, and invoke the
PrintTextHL macro. The macro looks like this:
23 24 25 26 27 28 29 30 31 32 33 34 35
;macros.asm PrintTextHL macro() PrintMenu: ld a, (hl) ; for each character of this string... cp 255 jp z, Next ; check string terminator push hl ; preserve HL call FZX_START ; print character pop hl ; recover HL inc hl jp PrintMenu Next: ; This will be whatever code follows the macro mend
We don’t really need to know much about the internals of
FZX_START, except that it prints a single ASCII character in the range 32 to 255. It uses a pixel coordinate system, so the numbers are eight times larger than the BASIC PRINT routine. It recognises the At constant, which is followed by a pair of coordinate bytes, Y first.
Here is the revised
MenuText table. You will see I have cheated slightly—because FZX doesn’t set attribute colours, I have retained the previous ROM printing code, which sets the same attributes as before, but only prints spaces. I wouldn’t normally do it like this, but I intend to change the menu again later, so let’s keep it quick and dirty for now.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
;macros.asm MenuText proc ; Named procedure to keep our print data tidy db At, 7, 13 ; These codes are the same as you would use db Paper, Black, PrBright, 1 ; with Sinclair BASIC's PRINT command db Ink, Red, " " ; Set the attributes here, with spaces, db Ink, Yellow, " " ; because FZX only prints pixels db Ink, Cyan, " " db Ink, Magenta, " " db Ink, White, " " db Ink, Green, " " db At, 21, 6 db Ink, Yellow, " " db Ink, White, " " db Ink, Yellow, " " Length equ $-MenuText ; Let Zeus do the work of calculating the length ; ($ means the current address Zeus is assembling to) FZX: db At, 56, 104 ; FXX coordinates are (Y, X) in pixels db "ZA%AXA" db At, 168, 55 db "PRESS SPACE TO START" db 255 ; Terminator byte pend
You may also notice the
% character in
ZA%AXA. I did this because
L in the Namco font was a bit narrower, and stopped the text aligning to character boundaries. I defined an unused character as a slightly wider
The Namco font is imported with a standard
16 17 18 19 20
;database.asm Font proc Namco: import_bin "..\fonts\Namco.fzx" pend
I’ve done something very similar in
25 26 27 28
; menu.asm ld hl, GameText ; Start of menu ASCII data PrintTextHL() ; Macro to print FZX proportional text with FZX
45 46 47 48 49 50 51 52 53
; database.asm GameText proc ; FXX coordinates are (Y, X) in pixels db At, 0, 0, "&UP" db At, 0, 94, "HIGH SCORE" db At, 9, 0, "0" db At, 9, 112, "20000" db 255 ; Terminator byte pend
&UP text is actually
1UP. Proportional fonts conventionally have all their digits to same width, so that columns of numbers always line up. Doing it this way makes the
1UP start on the second pixel of the line, so I made a shifted version of it in another space character.
If you recall, in part 8 we set the first character line of the game screen to bright red, and the second line to bright white, using the
ClsNirvana routine. Well, if we got everything right, our new score text will appear in the right place, with these colours.
It does! I think this looks reasonably like the font Namco used in the original arcade version of Galaga.