Annotation of researchv10no/cmd/pico/munge.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <signal.h>
        !             3: #include <fb.h>
        !             4: #include "pico.h"
        !             5: 
        !             6: extern short   CURSCRATCH, CUROLD;
        !             7: extern struct  SRC src[MANY];
        !             8: extern long    program();
        !             9: extern char    usednew, usedold, frameb, metheus, faster;
        !            10: extern int     DEF_LL, DEF_NL;
        !            11: extern void    onquit();
        !            12: 
        !            13: #define RGBA   0xe
        !            14: #define RGB    0xd
        !            15: #define A      0x1
        !            16: #define R      0x2
        !            17: #define G      0x4
        !            18: #define B      0x8
        !            19: 
        !            20: struct {
        !            21:        long u;
        !            22:        long p;
        !            23:        long chld_usrt;
        !            24:        long chld_syst;
        !            25: } tim0, tim1;
        !            26: 
        !            27: int sx, sy, ex, ey, delta, offset;
        !            28: 
        !            29: munge(chann)
        !            30: {      int i;
        !            31:        float t0, t1;
        !            32: 
        !            33:        sx = Old->sx;
        !            34:        sy = Old->sy;
        !            35:        ex = Old->ex; if ((ex-sx)&1) ex++;
        !            36:        ey = Old->ey;
        !            37:        offset = sy*DEF_LL + sx;
        !            38:        delta  = DEF_LL - ex + sx;
        !            39: 
        !            40:        checkit();
        !            41:        times(&tim0);
        !            42: 
        !            43:        switch (chann) {
        !            44:        case NLOOP: noloop();  break;
        !            45:        case SLOOP: smalloop(); break;
        !            46:        case BLOOP: if (faster && (metheus || Old->nchan == 1) && usednew)
        !            47:                    {   if (frameb)
        !            48:                        {       hack();
        !            49:                                break;
        !            50:                        } else if (metheus)
        !            51:                        {       hick();
        !            52:                                break;
        !            53:                        }
        !            54:                    }
        !            55:                    bigloop();
        !            56:                    break;
        !            57:        }
        !            58:        times(&tim1);
        !            59:        t0 = (float) (tim1.u - tim0.u);
        !            60:        t1 = (float) (tim1.p - tim0.p);
        !            61: 
        !            62:        fprintf(stderr, "time: %4.2fu  + %4.2fs = %4.2f\n",
        !            63:                t0/60.0, t1/60.0, (t1+t0)/60.0);
        !            64:        if (usednew) { setscratch(Scratch, Old); RESIDENT; }
        !            65: }
        !            66: 
        !            67: hack()
        !            68: {      register x, y, i = offset;      /* r11, r10, r9 */
        !            69:        register r;
        !            70:        extern fbreg  *F;
        !            71:        register fbreg *f = F;
        !            72: 
        !            73:        f->red.csr=f->grn.csr=f->blu.csr=F_IXW;
        !            74:        for (y = sy; y < ey; y++, i += delta)
        !            75:        {       f->red.x=f->grn.x=f->blu.x=sx;
        !            76:                f->red.y=f->grn.y=f->blu.y=y;
        !            77:                for (x = sx; x < ex; x++, i++)
        !            78:                {
        !            79: asm("                  jsb     *_program       ");
        !            80: asm("  CA:             brb     CA+9            ");
        !            81:                        r=program();
        !            82:                        f->red.z=f->grn.z=f->blu.z=r&255;
        !            83:                }
        !            84:        }
        !            85: }
        !            86: 
        !            87: hick()
        !            88: {      register x, y, i = offset;      /* r11, r10, r9 */
        !            89:        unsigned char *pr, *pg, *pb;
        !            90:        int chunk;
        !            91:        extern int om_fd;
        !            92: 
        !            93:        pr = Scratch->pixred+i;
        !            94:        pg = Scratch->pixgrn+i;
        !            95:        pb = Scratch->pixblu+i;
        !            96:        chunk = ex-sx+delta;
        !            97:        signal(SIGINT, SIG_IGN);        /* don't mess up the device */
        !            98:        if (Old->nchan==1)
        !            99:        {       merect(sx, sy, ex, ey);
        !           100:                setbank(RGBA);
        !           101:                for (y = sy; y < ey; y++, i += delta, pr += chunk)
        !           102:                {       for (x = sx; x < ex; x++, i++)
        !           103:                        {
        !           104: asm("                          jsb     *_program       ");
        !           105: asm("  CD:                     brb     CD+9            ");
        !           106:                                program();
        !           107:                        }
        !           108:                        write(om_fd, pr, ex-sx);
        !           109:                }
        !           110:        }
        !           111:        else
        !           112:        for (y = sy; y < ey; y++, i += delta)
        !           113:        {       for (x = sx; x < ex; x++, i++)
        !           114:                {
        !           115: asm("                  jsb     *_program       ");
        !           116: asm("  CE:             brb     CE+9            ");
        !           117:                        program();
        !           118:                }
        !           119:                merect(sx, y, ex, y+1);
        !           120:                setbank(R); write(om_fd, pr, ex-sx); pr += chunk;
        !           121:                setbank(G); write(om_fd, pg, ex-sx); pg += chunk;
        !           122:                setbank(B); write(om_fd, pb, ex-sx); pb += chunk;
        !           123:        }
        !           124:        signal(SIGINT, onquit);
        !           125: }
        !           126: 
        !           127: bigloop()
        !           128: {      register x, y, i = offset;      /* r11, r10, r9 */
        !           129: 
        !           130:        for (y = sy; y < ey; y++, i += delta)
        !           131:        for (x = sx; x < ex; x++, i++)
        !           132:        {
        !           133: asm("          jsb     *_program       ");
        !           134: asm("  C0:     brb     C0+9            ");
        !           135:                program();
        !           136:        }
        !           137: }
        !           138: 
        !           139: smalloop()
        !           140: {      register x, y, i;       /* r11, r10, r9 */
        !           141: 
        !           142:        for (i = 0; i < 256; i++)
        !           143:        {
        !           144: asm("          jsb     *_program       ");
        !           145: asm("  C1:     brb     C1+9            ");
        !           146:                program();
        !           147:        }
        !           148: }
        !           149: 
        !           150: noloop()
        !           151: {      register x, y, i;       /* r11, r10, r9 */
        !           152: 
        !           153: asm("          jsb     *_program                       ");
        !           154: asm("  C2:     brb     C2+9                            ");     
        !           155:                program();
        !           156: }
        !           157: 

unix.superglobalmegacorp.com

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