aboutsummaryrefslogtreecommitdiff
path: root/convfont.c
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2015-12-29 23:10:50 -0500
committerB. Watson <yalhcru@gmail.com>2015-12-29 23:10:50 -0500
commit2300d2813a524cbfeabac794335e7abe99263df6 (patch)
treed729ca4f99634788cbb3a2101a5b5854a4bc2d06 /convfont.c
downloadtaipan-2300d2813a524cbfeabac794335e7abe99263df6.tar.gz
initial commit
Diffstat (limited to 'convfont.c')
-rw-r--r--convfont.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/convfont.c b/convfont.c
new file mode 100644
index 0000000..a2a2418
--- /dev/null
+++ b/convfont.c
@@ -0,0 +1,146 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <unistd.h>
+#include <stdio.h>
+
+/* usage:
+ # extract the 1K atari ROM font:
+ dd if=atariosb.rom of=romfont bs=256 skip=8 count=4
+
+ # extract the Apple II Taipan font:
+ dd if=taipan.dsk of=font bs=256 skip=54 count=3
+
+ # create the Atari 8-bit Taipan font:
+ cat romfont font | ./convfont > taifont.raw
+
+ # or, create the Atari 8-bit Taipan font as a binary load:
+ cat romfont font | ./convfont -x > taifont.xex
+ */
+
+/*
+ taipan font file order:
+ 0-31: `a-z{|}" block
+ 32-63: @A-Z[\]^_
+ 64-95: space !"#$%&'()*+,-./0-9:;>=<?
+
+ atari screen code order:
+ 0-31: space !"#$%&'()*+,-./0-9:;>=<?
+ 32-63: @A-Z[\]^_
+ 64-95 graphics chars
+ 96-127: `a-z and 4 graphics chars
+*/
+
+/* custom characters for ship graphics. 1st byte
+ is screencode, the other 8 are the pixel data. */
+char shipdata[][9] = {
+ {0x02 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f},
+ {0x03 , 0x18, 0x1f, 0x1f, 0x10, 0x10, 0x10, 0xff, 0xff},
+ {0x04 , 0x00, 0xf0, 0xfc, 0x3e, 0x00, 0x00, 0xfc, 0xf0},
+ {0x06 , 0x00, 0x00, 0x40, 0x70, 0x7c, 0x47, 0x40, 0x40},
+ {0x1b , 0x1f, 0x3f, 0xff, 0x3f, 0x1f, 0x3f, 0xff, 0x7f},
+ {0x1c , 0xc0, 0xf0, 0xfc, 0xf0, 0xc0, 0xf0, 0xfc, 0xf0},
+ {0x1d , 0x07, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x07, 0x0f},
+ {0x1e , 0xfe, 0xfc, 0xfe, 0xff, 0xfe, 0xf8, 0xfe, 0xff},
+ {0x20 , 0xfe, 0xf8, 0xfe, 0xff, 0xfe, 0xfe, 0xfd, 0xf9},
+ {0x3b , 0xc0, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f},
+ {0x3c , 0x00, 0x00, 0xc0, 0xff, 0x8f, 0x8e, 0x8e, 0xfe},
+ {0x3d , 0x38, 0x38, 0x38, 0x38, 0xff, 0x38, 0x38, 0x38},
+ {0x3e , 0x00, 0x00, 0x00, 0x01, 0xff, 0xe3, 0xe3, 0xe3},
+ {0x3f , 0x00, 0x00, 0x00, 0xff, 0x8e, 0x8e, 0x8e, 0xff},
+ {0x40 , 0xc3, 0xcf, 0xff, 0xff, 0x3f, 0x3e, 0x3c, 0xf8},
+ {0x46 , 0x1f, 0x0f, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03},
+ {0x47 , 0xf0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x80},
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+};
+
+/* this ends up in LORCHA.DAT */
+char shipshape[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x03, 0x04, 0x00, 0x06,
+ 0x00, 0x00, 0x1b, 0x80, 0x1c, 0x1d, 0x1e,
+ 0x00, 0x00, 0x1b, 0x80, 0x1c, 0x1d, 0x20,
+ 0x00, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
+ 0x00, 0x46, 0x80, 0x80, 0x80, 0x80, 0x47,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+void bitswap(unsigned char *b, int lim) {
+ unsigned char j, k;
+ // fprintf(stderr, "bitswap(%x, %d)\n", b, lim);
+ do {
+ k = b[lim];
+ j = 0;
+ j |= (k & 0x01 ? 0x80 : 0);
+ j |= (k & 0x02 ? 0x40 : 0);
+ j |= (k & 0x04 ? 0x20 : 0);
+ j |= (k & 0x08 ? 0x10 : 0);
+ j |= (k & 0x10 ? 0x08 : 0);
+ j |= (k & 0x20 ? 0x04 : 0);
+ j |= (k & 0x40 ? 0x02 : 0);
+ j |= (k & 0x80 ? 0x01 : 0);
+ b[lim] = j;
+ } while(--lim > 0);
+}
+
+void clear0bits(unsigned char *b, int lim) {
+ do {
+ *b++ &= 0xfe;
+ } while(--lim > 0);
+}
+
+int main(int argc, char **argv) {
+ int i, j;
+ unsigned char font[1024], xex[6];
+
+ read(0, font, 1024);
+ read(0, font + (96 * 8), 32 * 8);
+ bitswap(font + (96 * 8), 32 * 8);
+ read(0, font + (32 * 8), 32 * 8);
+ bitswap(font + (32 * 8), 32 * 8);
+ read(0, font + (0 * 8), 32 * 8);
+ bitswap(font + (0 * 8), 32 * 8);
+
+ /* this stuff is from visual inspection via bitmapdump.pl */
+ clear0bits(font + 0x1f8, 7);
+ clear0bits(font + 0x301, 7);
+ clear0bits(font + 0x308, 8);
+ clear0bits(font + 0x330, 8);
+ clear0bits(font + 0x3a0, 8);
+ clear0bits(font + 0x3d8, 8);
+ clear0bits(font + 0x3e8, 8);
+ clear0bits(font + 0x040, 16);
+ clear0bits(font + 0x1e8, 8);
+
+ /* fix the vertical bar */
+ font[0x3e0] =
+ font[0x3e1] =
+ font[0x3e2] =
+ font[0x3e3] =
+ font[0x3e4] =
+ font[0x3e5] =
+ font[0x3e6] =
+ font[0x3e7] = 0x18;
+
+ /* stick ship data where it goes */
+ for(i=0; shipdata[i][0]; i++) {
+ for(j=0; j<8; j++) {
+ font[ shipdata[i][0] * 8 + j ] = shipdata[i][j+1];
+ }
+ }
+
+ if(argc > 1) {
+ xex[0] = xex[1] = 0xff;
+ xex[2] = 0x00; xex[3] = 0xb8; /* load address $B800 */
+ xex[4] = 0xff; xex[5] = 0xbb; /* end address $bbff */
+ write(1, xex, 6);
+ }
+ write(1, font, 1024);
+
+ i = open("LORCHA.DAT", O_WRONLY | O_CREAT);
+ write(i, shipshape, sizeof(shipshape));
+ close(i);
+
+ return 0;
+}