aboutsummaryrefslogtreecommitdiff
path: root/font/mkfont.pl
blob: ae52dda0c3e24f6383e79eed7b2a610ff651f14f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/perl -w

use bytes;

open $in, "</usr/share/atari800/atarixl.rom" or die $!;
open $out, ">font.dat" or die $!;

my $junk;
read($in, $junk, 0x2000); # skip to the font

read($in, $X2000, 256); # ASCII 32-63
read($in, $X2100, 256); # ASCII 64-95
read($in, $X2200, 256); # ASCII 0-31
read($in, $X2300, 256); # ASCII 96=127

# ASCII 0 is a blank glyph
substr($X2200, 0, 8) = "\x00" x 8;

# ASCII 1-26 are inverse letters instead of ATASCII control graphics.
for($i = 1; $i < 27; $i++) {
	my $old = substr($X2100, $i * 8, 8);
	my $p = 0;
	for(split "", $old) {
		my $new = ~ord($_);
		substr($X2200, $i * 8 + $p++, 1) = chr($new);
	}
}

$font = $X2200 . $X2000 . $X2100 . $X2300;

while(<DATA>) {
	chomp;
	if(/^(\d+)$/) {
		$offset = $1 * 8;
		next;
	} elsif(/^[-#]+$/) {
		s/-/0/g;
		s/#/1/g;
		my $byte = eval "0b$_";
		substr($font, $offset++, 1) = chr $byte;
	}
}

print $out $font;

close $in;
close $out;

__DATA__
96
--------
--##----
--##----
---##---
--------
--------
--------
--------

123
----###-
---##---
---##---
--##----
---##---
---##---
----###-
--------

125
-###----
---##---
---##---
----##--
---##---
---##---
-###----
--------

126
--------
-###--##
##-##-##
##--###-
--------
--------
--------
--------