aboutsummaryrefslogtreecommitdiffstats
path: root/psftoc.pl
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2003-03-24 16:31:19 +0000
committerH. Peter Anvin <hpa@zytor.com>2003-03-24 16:31:19 +0000
commit1128ad360b5cccb1b82de092505e5ca1c4dbed8d (patch)
tree89c7ebe649b47fa1b901872d646a2183df023c8d /psftoc.pl
downloadgrv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.tar.gz
grv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.tar.xz
grv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.zip
Port of "gršvning" to C/SDL, started 2003-03-22
Diffstat (limited to 'psftoc.pl')
-rwxr-xr-xpsftoc.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/psftoc.pl b/psftoc.pl
new file mode 100755
index 0000000..0038bdf
--- /dev/null
+++ b/psftoc.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+#
+# Convert PSF input to a C structure
+#
+
+eval { use bytes; };
+
+read(STDIN, $hdr, 4);
+
+($magic, $mode, $size) = unpack("vCC", $hdr);
+
+die "$0: Not a PSF1 file on input\n" if ( $magic != 0x0436 );
+
+print "unsigned char grv_font[256][$size] = {\n";
+
+for ( $i = 0 ; $i < 256 ; $i++ ) {
+ print " ";
+ for ( $j = 0 ; $j < $size ; $j++ ) {
+ read(STDIN, $byte, 1);
+ printf "%s0x%02x", ($j == 0 ? '{' : ','), unpack("C",$byte);
+ }
+ print "},\n";
+}
+print "};\n";