Annotation of researchv10no/cmd/view2d/term/frame.c, revision 1.1

1.1     ! root        1: #include       <CC/jerq.h>
        !             2: #include       "frame.pri"
        !             3: #include       "camera.pub"
        !             4: 
        !             5: Hcoord direct(short, short, short);
        !             6: 
        !             7: #define        Z(x,y)  data[(x)+m->nx*(y)]
        !             8: #define        SEG(x1,y1,x2,y2)        {if((Z(x1,y1)>m->floor)&&(Z(x2,y2)>m->floor))seg(x1,y1,x2,y2);}
        !             9: 
        !            10: void
        !            11: Frame.view(short vlat, short vlon, short vdist, short valat, short valon, short vpersp)
        !            12: {
        !            13:        register i;
        !            14: 
        !            15:        if((vlat != lat) || (vlon != lon) || (vdist != dist) || (valat != alat)
        !            16:                || (valon != alon) || (vpersp != persp))
        !            17:        {
        !            18:                lat = vlat;
        !            19:                lon = vlon;
        !            20:                dist = vdist;
        !            21:                alat = valat;
        !            22:                alon = valon;
        !            23:                persp = vpersp;
        !            24:                draw();
        !            25:        }
        !            26:        show();
        !            27: }
        !            28: 
        !            29: void
        !            30: Frame.draw()
        !            31: {
        !            32:        register x, y;
        !            33: 
        !            34:        transdata();
        !            35:        rectf(b, b->rect, F_CLR);
        !            36:        for(y = 0; y < m->ny; y++)
        !            37:        {
        !            38:                for(x = 0; x < m->nx; x++)
        !            39:                {
        !            40:                        if(y) SEG(x, y-1, x, y);
        !            41:                        if(x) SEG(x-1, y, x, y);
        !            42:                }
        !            43:                wait(CPU);
        !            44:        }
        !            45: }
        !            46: 
        !            47: void
        !            48: Frame.show()
        !            49: {
        !            50:        bitblt(b, b->rect, &display, m->ctr, F_STORE);
        !            51: }
        !            52: 
        !            53: void
        !            54: Frame.rd(int n)
        !            55: {
        !            56:        register short *s;
        !            57:        extern int getn();
        !            58: 
        !            59:        alon = -1;
        !            60:        gets(time);
        !            61:        s = data = (short *)alloc(n*2);
        !            62:        while(n--)
        !            63:                *s++ = getn();
        !            64:        b = balloc(m->bound);
        !            65: }
        !            66: /*
        !            67:        the data will always fall in the cube 1000*1000*1000
        !            68:        centered at the origin
        !            69: */
        !            70: 
        !            71: #define                SCALE           1000
        !            72: 
        !            73: void
        !            74: Frame.transdata()
        !            75: {
        !            76:        register x, y;
        !            77:        register Hcoord *h;
        !            78:        short *d;
        !            79:        int scaly;
        !            80:        int scale = max(m->nx, m->ny)-1;
        !            81:        Hcoord e = direct(lat, lon, dist*SCALE/100);
        !            82:        Hcoord l = direct(alat, alon, ONE*2);
        !            83:        extern long vscale;
        !            84: 
        !            85:        init3(b, 1, 1);
        !            86:        look3(e, l, Hcoord((l.x == 0) && (l.y == 0), 0, 1, 1));
        !            87:        clip3scale = (1-persp)*SCALE;
        !            88:        scaly = muldiv(SCALE/2, vscale, 32768);
        !            89:        h = (Hcoord *)m->tdata;
        !            90:        for(y = 0, d = data; y < m->ny; y++)
        !            91:                for(x = 0; x < m->nx; x++, h++)
        !            92:                {
        !            93:                        *h = Hcoord(muldiv(x, SCALE, scale)-SCALE/2,
        !            94:                                muldiv(y, SCALE, scale)-SCALE/2,
        !            95:                                muldiv(*d++, scaly, 32768), 1);
        !            96:                }
        !            97: }
        !            98: 
        !            99: void
        !           100: Frame.seg(short x1, short y1, short x2, short y2)
        !           101: {
        !           102:        register Hcoord *h = (Hcoord *)m->tdata;
        !           103: 
        !           104:        move3(h[x1+y1*m->nx]);
        !           105:        line3(h[x2+y2*m->nx]);
        !           106: }

unix.superglobalmegacorp.com

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