aboutsummaryrefslogtreecommitdiff
path: root/src/hex2inc.pl
blob: 047438d63414266b8cf168471ff00f8ea4b7a1eb (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
#!/usr/bin/perl -w

$|++;

while(<>) {
	chomp;
	my ($c, $data) = split /:/;
	$c = hex($c);
	next unless $c >= 32 && $c <= 127;

	my @data = ($data =~ /(..)/g);
	die "invalid data" unless @data == 6;
	my $last = pop @data;
	die "bottom row not blank: $last" if $last ne "00";

	$glyphs[$c] = \@data;
}

$idx = 0;
for(my $c = 32; $c < 128; $c += 2) {
	print " byte ";
	$bits = "";
	for(my $byte = 0; $byte < 5; ++$byte) {
		printf '$%02X', hex($glyphs[$c][$byte]) | (hex($glyphs[$c+1][$byte]) >> 4);
		print ", " unless $byte == 4;
		$bits .= sprintf "%08b\n", hex($glyphs[$c][$byte]) | (hex($glyphs[$c+1][$byte]) >> 4);
	}
	print " ; [$idx] $c," . ($c+1) . "  " . chr($c) . "," . chr($c+1) . "\n";
#	print STDERR $bits;
	$idx += 5;
}