Annotation of researchv10no/cmd/pico/framebuffers/mlib.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include <signal.h>
                      3: #include "pico.h"
                      4: 
                      5: extern struct  SRC src[MANY];
                      6: extern short   CURSCRATCH, CUROLD;
                      7: extern void    onquit();
                      8: 
                      9: #define lowbyte(A) (A)&0377
                     10: #define higbyte(A) ((A) >> 8) & 07
                     11: 
                     12: int om_fd;
                     13: char om_buf[1024];
                     14: 
                     15: char * setxy(p,x,y)
                     16:        char *p;
                     17: {
                     18:        *p++ = x&0377;
                     19:        *p++ = (x >> 8) & 07;
                     20:        *p++ = y&0377;
                     21:        *p++ = (y >> 8) & 07;
                     22:        return(p);
                     23: }
                     24: 
                     25: om_open(dev)
                     26: {      char buf[10];
                     27:        extern char metheus;
                     28: 
                     29:        sprintf(buf, "/dev/om%d", dev);
                     30:        if ((om_fd = open(buf, 2)) == -1)
                     31:        {       perror("om_open");
                     32:                metheus = 0;
                     33:                return 0;
                     34:        }
                     35:        reloadmaps();
                     36:        return 1;
                     37: }
                     38: 
                     39: om_close()
                     40: {
                     41:        close(om_fd);
                     42: }
                     43: 
                     44: om_flush(pp)
                     45:        char *pp;
                     46: {
                     47:        if ((pp-om_buf)%2) *pp++ = 0;   
                     48:        write(om_fd, om_buf, pp-om_buf);
                     49: }
                     50: 
                     51: metreset()
                     52: {      register char *pp = om_buf;
                     53: 
                     54:        *pp++ = 'O';
                     55:        *pp++ = 0377;   /* WRMASK */
                     56:        signal(SIGINT, SIG_IGN);
                     57:        metfill(0, Old->sx, Old->sy, Old->ex, Old->ey);
                     58:        om_flush(pp);
                     59: }
                     60: 
                     61: metfill(col, x1, y1, x2, y2)
                     62: {
                     63:        register char *pp = om_buf;
                     64: 
                     65:        *pp++ = 'N';
                     66:        *pp++ = col;
                     67:        *pp++ = 'R'; pp = setxy(pp, x1, y1);
                     68:        *pp++ = 'S'; pp = setxy(pp, x2, y2);
                     69:        *pp++ = 'd'; om_flush(pp);
                     70: }
                     71: 
                     72: set_color(n)
                     73: {
                     74:        register char *pp;
                     75:        pp = om_buf;
                     76:        *pp++ = 'N';
                     77:        *pp++ = n;
                     78:        om_flush(pp);
                     79: }
                     80: 
                     81: metwi(row, length, xoff, height)
                     82:        unsigned char *row;
                     83:        short length, xoff, height;
                     84: {
                     85:        unsigned char mcode[16];
                     86:        short xend;
                     87: 
                     88:        xend = xoff + length;
                     89: 
                     90:        mcode[0] = 0x4F;
                     91:        mcode[1] = 0377;        /* WRMASK */
                     92: 
                     93:        mcode[2]  = 0x52;       /* set P1 */
                     94:        mcode[3]  = lowbyte(xoff);      mcode[4]  = higbyte(xoff);
                     95: 
                     96:        mcode[5] = mcode[10] = lowbyte(height);
                     97:        mcode[6] = mcode[11] = higbyte(height);
                     98:        mcode[7]  = 0x53;       /* set P2 */
                     99:        mcode[8]  = lowbyte(xend);      mcode[9]  = higbyte(xend);
                    100: 
                    101:        mcode[12] = 0;
                    102:        mcode[13] = 'o';
                    103: 
                    104:        signal(SIGINT, SIG_IGN);
                    105:        write(om_fd, mcode, 14);
                    106:        write(om_fd, row, length);
                    107:        signal(SIGINT, onquit);
                    108: }
                    109: 
                    110: metri(b, x, y, d)
                    111:        char *b;
                    112: {
                    113:        char *bp = b;
                    114:        char *pp = om_buf;
                    115: 
                    116:        signal(SIGINT, SIG_IGN);
                    117:        *pp++ = 'R'; pp = setxy(pp, x, y);
                    118:        *pp++ = 'S'; pp = setxy(pp, x+d-1, y);
                    119:        *pp++ = 'n'; om_flush(pp);
                    120:        read(om_fd, bp, d);
                    121:        signal(SIGINT, onquit);
                    122: }

unix.superglobalmegacorp.com

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