Z-Machine original (?) Beyond Zork font

(Edit: I realized I had made a slight mistake in my code. Characters are supposed to be 10 pixels tall (6+4), not 12 (6+6). I’ve updated the code and sample output accordingly.)

While browsing through the Infocom source code, I came across the file vt220.mud in the Beyond Zork directory. It’s filled with what at first looks like gibberish like

	<PRINC "~QcGCA@?/F??@????;"> ; a
	<PRINC "~PPiiCC?/FCCAA@@?;"> ; b
	<PRINC "_??~ACG?/?@AF????;"> ; c

After skimming through the relevant part of the VT220 manual, I came up with this little piece of C code which I think decodes it correctly:

void print_sixels(char *row, int height) {
	int i, j;
	for (i = 0; i < height; i++) {
		for (j = 0; j < 8; j++) {
			if ((row[j] - 0x3F) & (1 << i)) {
				printf("*");
			} else {
				printf(".");
			}
		}
		printf("\n");
	}
}

void print_glyph(char *glyph) {
	print_sixels(glyph, 6);
	print_sixels(glyph + 9, 4);
}

Feeding the first of the “RUNICS” strings ("~QcGCA@?/F??@???;"), what came out was this:

*.....*.
**...*..
*.*.*...
*..*....
**......
*.*.....
*..*....
*.......
*.......
........

(Note that your C compiler may try to interpret parts of the strings as trigraphs, which is just evil.)

They’re a bit differently drawn than the ones presented in the Z-Machine specification (though this particular one is pretty close), which I think makes them at least somewhat interesting. Also, I have no idea what the “CARLSET” characters are supposed to be. But is it useful? I don’t know. Maybe to the PDP-10 / PDP-11 port of Frotz that was released recently? Otherwise, I guess it might make more sense to map the Beyond Zork runes to the appropriate Unicode runes and include some free font file that has them. (Unfortunately, I don’t think there is a match for the box-drawing characters among the Unicode ones.)

2 Likes

Seems that char.dat (in the same repository) is a binary version of the 8x8 font - I checked the first 4 characters by hand and they match.

Ah, I didn’t realize that. According to the Z-Machine specification, there were two sets of fonts which it refers to as the “Amiga and PC forms”, and includes the shapes for the Amiga form. Redrawing it to match the output from my code, this is how one of the runes compare between the three:

"Amiga"    chars.dat   vt220.mud

.**.....   ........    ***.....
.*.*....   .***....    *..**...
.*..*...   .*..*...    *....**.
.***....   .*...*..    *..**...
.*..*...   .*****..    ***.....
.*.*....   .*...*..    *..**...
.**.....   .*..*...    *....**.
........   .***....    *..**...
                       ***.....
                       ........

This is the C code I used to decode the chars.dat file, if anyone else wants to play around with it:

#include <stdio.h>

int main() {
	FILE *f;
	int c, i, n;

	n = 0;
	f = fopen("char.dat", "rb");
	while ((c = fgetc(f)) != EOF) {
		for (i = 0x80; i >= 0x01; i >>= 1) {
			if (c & i) {
				printf("*");
			} else {
				printf(".");
			}
		}
		printf("\n");

		if (++n == 8) {
			printf("\n");
			n = 0;
		}
	}

	return 0;
}
2 Likes

I converted your little program to MUDDLE. Works in ZILF, Confusion or PDP-10 ITS emulator.

Well, why? For fun, I guess…

<DEFINE PRINT-SIXELS (ROW HEIGHT)
	<REPEAT ((I 0))
		<REPEAT ((J 0))
			<COND (<G? <CHTYPE <ANDB <- <ASCII <<+ .J 1> .ROW>> 63> <LSH 1 .I>> FIX> 0> <PRINC "#">)
				  (T <PRINC ".">)>
			<SET J <+ .J 1>>
			<COND (<G=? .J 8> <RETURN>)>
		>
		<CRLF>
		<SET I <+ .I 1>>
		<COND (<G=? .I .HEIGHT> <RETURN>)>
	>
>

<DEFINE PRINT-GLYPH (GLYPH)
	<PRINT-SIXELS .GLYPH 6>
	<PRINT-SIXELS <REST .GLYPH 9> 4>
>

 <PRINT-GLYPH "~PPiiCC?/FCCAA@@?;">

Outputs:

###.....
#..##...
#....##.
#..##...
###.....
#..##...
#....##.
#..##...
###.....
........
T
1 Like

Frotz has issue #193 that is to add sixel graphics to the curses interface (although I think that it was later discussed that it might be easier to create a new frontend that does its own screen handling rather than mixing sixels with curses). That might be a good place to use these characters.

Another thing I noticed is that the vt220.mud file in the directory is using the CARLSET glyphs instead of the RUNICS for the lower case letters, see https://github.com/historicalsource/beyondzork/blob/master/vt220.mud#L169.

As I said, I have no idea what CARLSET is supposed to be. The glyphs don’t look like anything I’ve seen in Beyond Zork; in fact, I don’t recognize them at all. There is a Carl Genatossio in the game’s credits, but that may be just a coincidence.