/** * Purpose: Takes text and font, outputs only those parts of the font that are used. * Text is packed, six characters per four bytes. */ #include static const char lines[][8] = { //an @ in [6] marks new paragraphs "HELLO ", "REVIS-", "ION ", " ", "TJOPP-", "EN ", "HERE ", "WITH ", "ANOTH-", "ER ", "INTRO ", "FOR ", "THE ", "ATARI ", "VCS ", "AKA ", "STELLA", " ", "SHE ", "MAY BE", "A BIT ", "OLD ", "BUT ", "SHE ", "STILL ", "HAS A ", "FEW ", "TRICKS", "UP HER", "SLEEVE", /** ************************ **/ "ATARI @", "VCS ", "TURNS ", "THIRTY", "FIVE ", "THIS ", "YEAR ", " ", "CHEERS", "TO ALL", "FELLOW", "OLDSK-", "OOLERS", " ", "THE ", "TIME ", "HAS ", "COME ", "FOR ", "THE ", "PLASMA", "BARS ", /** ************************ **/ "VCS @", "PROVI-", "DES ", "128 ", "BYTES ", "FOR ", "EVERY-", "ONE ", /** ************************ **/ "GREETS@", "------", "ARCHEE", "ATARI-", "AGE ", "DSS ", "MSB ", "NOICE ", "PANDA ", "PWP ", "SVOLLI", "TRILO-", "BIT ", "TRSI ", "JAC ", "WAMMA ", "DAVID ", "CRANE ", "------", "FUCKI-", "NGS TO", "ATARIS", "LAWYE-", "RS ", /** ************************ **/ "EXT- @", "ENSIVE", "SEVEN ", "BIT ", "PALET-", "TE ", " ", " ", "CEE ", //writing "C64" would mean extra glyphs which I can't afford "SIXTY ", "FOUR ", "PEEPS ", "BE ", "JELLY ", /** ************************ **/ "A ONE @", "DIMEN-", "SIONAL", "PLASMA", "IS OK ", "BUT ", "SHE ", "CAN DO", "BETTER", /** ************************ **/ "USING @", "A ", "FRAME ", "BUFFER", "IS ", "OPTIO-", "NAL ", /** ************************ **/ "CHANG-@", "ING ", "TYPE ", }; static const num_lines = sizeof(lines)/sizeof(*lines); int main(int argc, char **argv) { FILE *f; char font[256][8][8]; int counts[256] = {0}, codes[256], used = 0, code = 0; int x, y, x2, y2; unsigned char header[54]; int charh = 8; unsigned char bytes[num_lines][4]; int paragraphs[100] = {0}, num_paragraps = 1; f = fopen(argv[1], "rb"); fread(header, 54, 1, f); if (header[18] != 128 || header[22] != 128 || header[28] != 24) { fprintf(stderr, "BMP not 128x128, 24-bit\n"); return 1; } /* upside-down */ for (y2 = 15; y2 >= 0; y2--) { for (y = charh-1; y >= 0; y--) { for (x2 = 0; x2 < 16; x2++) { for (x = 0; x < 8; x++) { int c = getc(f) + getc(f) + getc(f); font[y2*16+x2][y][x] = c < 384; } } } } for (x = 0; x < num_lines; x++) { if (lines[x][6] == '@') paragraphs[num_paragraps++] = x; for (y = 0; y < 6; y++) if (!counts[lines[x][y]]++) used++; } paragraphs[num_paragraps++] = num_lines; if (used > 32) { fprintf(stderr, "hrmph, can't pack 6x%i unique characters into 32 bits\n", used); fprintf(stderr, "here are the symbol counts:\n"); for (x = 0; x < 256; x++) if (counts[x]) fprintf(stderr, "%c: %i\n", x, counts[x]); return 1; } printf("NUM_LINES equ %i\n", num_lines); printf("CHARH equ %i\n", charh); for (x = 0; x < num_paragraps; x++) printf("PARAGRAPH%i equ %i\n", x, paragraphs[x]); printf("\tMAC PARAGRAPHS\n"); for (x = 0; x < num_paragraps; x++) printf("\t.byte PARAGRAPH%i\n", x); printf("\tENDM\n"); /* assign codes, output font macro */ printf("\tMAC FONT\n"); for (x = 0; x < 256; x++) { if (!counts[x]) continue; printf("Glyph%i\n", code); /* upside-down as is typical for sprites */ for (y = charh-1; y >= 0; y--) printf("\t.byte %%%i%i%i%i%i%i%i%i\n", font[x][y][0], font[x][y][1], font[x][y][2], font[x][y][3], font[x][y][4], font[x][y][5], font[x][y][6], font[x][y][7]); //fprintf(stderr, "%c = %i\n", x, code); codes[x] = code++; } printf("\tENDM\n"); printf("\tMAC TEXT\n"); for (x = 0; x < num_lines; x++) { int code4, code5; bytes[x][0] = codes[lines[x][0]]; bytes[x][1] = codes[lines[x][1]]; bytes[x][2] = codes[lines[x][2]]; bytes[x][3] = codes[lines[x][3]]; code4 = codes[lines[x][4]]; code5 = codes[lines[x][5]]; bytes[x][0] |= (code4 & 7) << 5; bytes[x][1] |= (code4 & 24) << 3; bytes[x][2] |= (code5 & 7) << 5; bytes[x][3] |= (code5 & 24) << 3; /*printf("Line%i .byte $%02x, $%02x, $%02x, $%02x ;%s\n", x, bytes[0], bytes[1], bytes[2], bytes[3], lines[x]);*/ } for (y = 0; y < 4; y++) { printf("Bytes%i\n", y); for (x = 0; x < num_lines; x++) printf("\t.byte $%02x ;%s\n", bytes[x][y], lines[x]); } printf("\tENDM\n"); return 0; }