/* cview -- Yijun Ding, 04-16-1992 */ /*int BOX = 178; /* ibm */ int BOX = '#'; /* other */ #include #define syserr(str) {perror(str);exit(0);} #include #include #define SEEK_END 2 char *fname = "song16.fon"; FILE *fi, *ff; /* input, font */ int col, row; /* global */ int left=6, top=1; /* skips */ int misssec; /* missing sections */ char buffer[16][800]; /* 8 inches maximum */ int maxcol=70; int maxrow=9999; char efont[1024]={ /* English 8x8 fonts */ 0, 0, 0, 0, 0, 0, 0, 0,126,129,165,129,189,153,129,126, 126,255,219,255,195,231,255,126,108,254,254,254,124, 56, 16, 0, 16, 56,124,254,124, 56, 16, 0, 56,124, 56,254,254,124, 56,124, 16, 16, 56,124,254,124, 56,124, 0, 0, 24, 60, 60, 24, 0, 0, 255,255,231,195,195,231,255,255, 0, 60,102, 66, 66,102, 60, 0, 255,195,153,189,189,153,195,255, 15, 7, 15,125,204,204,204,120, 60,102,102,102, 60, 24,126, 24, 63, 51, 63, 48, 48,112,240,224, 127, 99,127, 99, 99,103,230,192,153, 90, 60,231,231, 60, 90,153, 128,224,248,254,248,224,128, 0, 2, 14, 62,254, 62, 14, 2, 0, 24, 60,126, 24, 24,126, 60, 24,102,102,102,102,102, 0,102, 0, 127,219,219,123, 27, 27, 27, 0, 62, 99, 56,108,108, 56,204,120, 0, 0, 0, 0,126,126,126, 0, 24, 60,126, 24,126, 60, 24,255, 24, 60,126, 24, 24, 24, 24, 0, 24, 24, 24, 24,126, 60, 24, 0, 0, 24, 12,254, 12, 24, 0, 0, 0, 48, 96,254, 96, 48, 0, 0, 0, 0,192,192,192,254, 0, 0, 0, 36,102,255,102, 36, 0, 0, 0, 24, 60,126,255,255, 0, 0, 0,255,255,126, 60, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48,120,120, 48, 48, 0, 48, 0, 108,108,108, 0, 0, 0, 0, 0,108,108,254,108,254,108,108, 0, 48,124,192,120, 12,248, 48, 0, 0,198,204, 24, 48,102,198, 0, 56,108, 56,118,220,204,118, 0, 96, 96,192, 0, 0, 0, 0, 0, 24, 48, 96, 96, 96, 48, 24, 0, 96, 48, 24, 24, 24, 48, 96, 0, 0,102, 60,255, 60,102, 0, 0, 0, 48, 48,252, 48, 48, 0, 0, 0, 0, 0, 0, 0, 48, 48, 96, 0, 0, 0,252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 0, 6, 12, 24, 48, 96,192,128, 0, 124,198,206,222,246,230,124, 0, 48,112, 48, 48, 48, 48,252, 0, 120,204, 12, 56, 96,204,252, 0,120,204, 12, 56, 12,204,120, 0, 28, 60,108,204,254, 12, 30, 0,252,192,248, 12, 12,204,120, 0, 56, 96,192,248,204,204,120, 0,252,204, 12, 24, 48, 48, 48, 0, 120,204,204,120,204,204,120, 0,120,204,204,124, 12, 24,112, 0, 0, 48, 48, 0, 0, 48, 48, 0, 0, 48, 48, 0, 0, 48, 48, 96, 24, 48, 96,192, 96, 48, 24, 0, 0, 0,252, 0, 0,252, 0, 0, 96, 48, 24, 12, 24, 48, 96, 0,120,204, 12, 24, 48, 0, 48, 0, 124,198,222,222,222,192,120, 0, 48,120,204,204,252,204,204, 0, 252,102,102,124,102,102,252, 0, 60,102,192,192,192,102, 60, 0, 248,108,102,102,102,108,248, 0,254, 98,104,120,104, 98,254, 0, 254, 98,104,120,104, 96,240, 0, 60,102,192,192,206,102, 62, 0, 204,204,204,252,204,204,204, 0,120, 48, 48, 48, 48, 48,120, 0, 30, 12, 12, 12,204,204,120, 0,230,102,108,120,108,102,230, 0, 240, 96, 96, 96, 98,102,254, 0,198,238,254,254,214,198,198, 0, 198,230,246,222,206,198,198, 0, 56,108,198,198,198,108, 56, 0, 252,102,102,124, 96, 96,240, 0,120,204,204,204,220,120, 28, 0, 252,102,102,124,108,102,230, 0,120,204,224,112, 28,204,120, 0, 252,180, 48, 48, 48, 48,120, 0,204,204,204,204,204,204,252, 0, 204,204,204,204,204,120, 48, 0,198,198,198,214,254,238,198, 0, 198,198,108, 56, 56,108,198, 0,204,204,204,120, 48, 48,120, 0, 254,198,140, 24, 50,102,254, 0,120, 96, 96, 96, 96, 96,120, 0, 192, 96, 48, 24, 12, 6, 2, 0,120, 24, 24, 24, 24, 24,120, 0, 16, 56,108,198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 48, 48, 24, 0, 0, 0, 0, 0, 0, 0,120, 12,124,204,118, 0, 224, 96, 96,124,102,102,220, 0, 0, 0,120,204,192,204,120, 0, 28, 12, 12,124,204,204,118, 0, 0, 0,120,204,252,192,120, 0, 56,108, 96,240, 96, 96,240, 0, 0, 0,118,204,204,124, 12,248, 224, 96,108,118,102,102,230, 0, 48, 0,112, 48, 48, 48,120, 0, 12, 0, 12, 12, 12,204,204,120,224, 96,102,108,120,108,230, 0, 112, 48, 48, 48, 48, 48,120, 0, 0, 0,204,254,254,214,198, 0, 0, 0,248,204,204,204,204, 0, 0, 0,120,204,204,204,120, 0, 0, 0,220,102,102,124, 96,240, 0, 0,118,204,204,124, 12, 30, 0, 0,220,118,102, 96,240, 0, 0, 0,124,192,120, 12,248, 0, 16, 48,124, 48, 48, 52, 24, 0, 0, 0,204,204,204,204,118, 0, 0, 0,204,204,204,120, 48, 0, 0, 0,198,214,254,254,108, 0, 0, 0,198,108, 56,108,198, 0, 0, 0,204,204,204,124, 12,248, 0, 0,252,152, 48,100,252, 0, 28, 48, 48,224, 48, 48, 28, 0, 24, 24, 24, 0, 24, 24, 24, 0,224, 48, 48, 28, 48, 48,224, 0, 118,220, 0, 0, 0, 0, 0, 0, 0, 16, 56,108,198,198,254, 0}; void buffer_out() { int i, j; for(i=0; i<16; i++) { /* tackle line wrap by omit the first! */ for(j=1; j 0) putchar('\n'); } col = 0; } void fill_english(k) int k; { int i, j; char ch; k *= 8; for(i=0; i<8; i++) for(j=0; j<8; j++) buffer[i][col+j] = ' '; for(; i<16; i++) { ch = efont[k++]; for(j=0; j<8; j++) { buffer[i][col+j] = ch<0? BOX: ' '; ch <<= 1; } } col += 8; } int decode(ch1, ch2) int ch1; int ch2; { int index; index = (ch1-161)*94 + (ch2-161); if(index > 94*(15-misssec)) index -= 94*misssec; return index; } void fill_chinese(k) int k; { int i, j; char ch, cc[16][2]; /* int not portable */ fseek(ff, (long)k*32l, 0); fread(cc, 1, 32, ff); for(i=0; i<16; i++) { ch = cc[i][0]; for(j=0; j<8; j++) { buffer[i][col+j] = ch<0? BOX: ' '; ch <<= 1; } ch = cc[i][1]; for(j=8; j<16; j++) { buffer[i][col+j] = ch<0? BOX: ' '; ch <<= 1; } } col += 16; } void main(argc, argv) int argc; char **argv; { int lo, hi; if(argc == 1) { puts("Print GB coded file to SCREEN by Yijun Ding\n"); printf("\n%s [-options] file\n\n", argv[0]); printf("-ffile\t: font file (default = %s).\n", fname); printf("-c#\t: columns per line (%d).", maxcol); printf("-bX\t: box character (%c).\n", BOX); return; } while(**++argv == '-') switch(*++*argv) { case 'c': maxcol = atoi(++*argv); break; case 'n': maxrow = atoi(++*argv); break; case 'f': fname = ++*argv; break; case 'b': BOX = *++*argv; break; } if(maxcol == 0 || maxrow == 0) syserr("maxcol/maxrow"); if((fi=fopen(argv[0],"r")) == 0) syserr(argv[0]); if((ff=fopen(fname, "rb")) == 0) syserr(fname); fseek(ff, 0l, SEEK_END); misssec = 87 - ftell(ff)/32/94; while((lo = fgetc(fi)) != EOF) { if(lo == '\n') { buffer_out(); continue; } if(lo < 161) { fill_english(lo); } else { hi = fgetc(fi); fill_chinese(decode(lo, hi)); } if(col >= maxcol) { buffer_out(); } } if(col ) buffer_out(); printf("\n"); }