Annotation of researchv9/jerq/src/lib/pot/btoc.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: 
        !             3: #define        CHARSIZE        /*((7*972)/368)*/ 9
        !             4: 
        !             5: #define OX     0
        !             6: #define OY     0
        !             7: 
        !             8: struct Rectangle {
        !             9:        short ox, oy;
        !            10:        short cx, cy;
        !            11: } rect;
        !            12: 
        !            13: char rasters[2][100] = { 0 };
        !            14: 
        !            15: main()
        !            16: {
        !            17:        register unsigned bit=0, byte, h, v;
        !            18:        int nrasters, rastwid, i, nw, k, j;
        !            19:        long t = time((long *)0);
        !            20: 
        !            21:        nrasters=getw(stdin);
        !            22:        rastwid =getw(stdin);
        !            23: 
        !            24:        if (rastwid & 0x8000) {
        !            25:                rastwid &= ~0x8000;
        !            26:                rect.cx = OX + rastwid;
        !            27:                rastwid = (rastwid + 15)/16;
        !            28:        } else
        !            29:                rect.cx = OX + rastwid*16;
        !            30: 
        !            31:        rect.ox = OX;
        !            32:        rect.oy = OY; rect.cy = OY + nrasters;
        !            33:        nw = (rect.cx-rect.ox+31)/32;
        !            34:        nw *= 4;
        !            35: 
        !            36:        printf("static Word bits%d[%d] = {\n", t, nrasters*nw/4);
        !            37: 
        !            38:        for(i=0, v=rect.oy; v<rect.cy; i=1-i, v++) {
        !            39:                readrast(i, rastwid, stdin);
        !            40:                k = (nw/2+3)/4*4;
        !            41:                for(j = 0; j < k; j++)
        !            42:                        printf("%s%02x%s", (j%4==0)?"0x":"", rasters[i][j]&255,
        !            43:                                (j%4==3)?", ":"");
        !            44:                printf("\n");
        !            45:                for(; j < nw; j++)
        !            46:                        printf("%s%02x%s", (j%4==0)?"0x":"", rasters[i][j]&255,
        !            47:                                (j%4==3)?", ":"");
        !            48:                printf("\n");
        !            49:        }
        !            50:        printf("};\n");
        !            51:        printf("Bitmap strike = {\n     bits%d,\n", t);
        !            52:        printf("        %d,\n", nw/4);
        !            53:        printf("        %d, %d, %d, %d,\n", rect.ox, rect.oy, rect.cx, rect.cy);
        !            54:        printf("        0,\n};\n");
        !            55:        exit(0);
        !            56: }
        !            57: 
        !            58: readrast(n,nw,in)
        !            59:        int n, nw; FILE *in;
        !            60: {
        !            61:        int count, ctype;
        !            62:        int nb = nw*2;
        !            63:        char *p1 = rasters[n];
        !            64: 
        !            65:        while (nw>0) {
        !            66:                count=getc(in); count &= 255;
        !            67:                ctype=count&128; count &= 127;
        !            68:                nw -= count; count *= 2;
        !            69: 
        !            70:                if (ctype) {
        !            71:                        fread(p1,2,1,in);
        !            72:                        for (count-=2; count>0; count--) {
        !            73:                                *(p1+2) = *p1;
        !            74:                                p1 += 1;
        !            75:                        }
        !            76:                        p1 += 2;
        !            77:                } else {
        !            78:                        fread(p1,count,1,in);
        !            79:                        p1 += count;
        !            80:                }
        !            81:        }
        !            82:        while(nb--)
        !            83:                rasters[n][nb] ^= rasters[1-n][nb];
        !            84: }
        !            85: 
        !            86: getw(stream)
        !            87: FILE *stream;
        !            88: {
        !            89:        register l, h;
        !            90:        l=getc(stream); h=getc(stream); return (h&255)<<8 | (l&255);
        !            91: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.