Back to index

tetex-bin  3.0
tek.c
Go to the documentation of this file.
00001 /* Tektronix terminal window interface for Metafont.  */
00002 
00003 #define       EXTERN extern
00004 #include "../mfd.h"
00005 
00006 #ifdef TEKTRONIXWIN         /* Whole file */
00007 
00008 #define FORMFEED     12
00009 #define ESCAPE              27
00010 #define GS           29
00011 #define US           31
00012 #ifndef TRUE
00013 #define TRUE         1
00014 #endif
00015 #ifndef FALSE
00016 #define FALSE        0
00017 #endif
00018 #define WIDTH        1024   /* Screen width */
00019 #define HEIGHT              780    /* Screen height */
00020 #define WIDTHINBYTES (WIDTH/8)   /* Only works if WIDTH % 8 == 0 */
00021 #define SETBIT(row,col) screen_pixel[row*WIDTHINBYTES+col/8] |= 1 << 7-col%8
00022 #define CLEARBIT(row,col) screen_pixel[row*WIDTHINBYTES+col/8] &= \
00023                          ~(1 << 7-col%8)
00024 #define ISSET(row,col) (screen_pixel[row*WIDTHINBYTES+col/8] & 1 << 7-col%8)
00025 
00026 char   screen_pixel[WIDTHINBYTES*HEIGHT];
00027 char   zero_array[WIDTHINBYTES];
00028 
00029 /* 
00030  *     function init_screen: boolean;
00031  *
00032  *            Return true if window operations legal.
00033  *            We always return true.
00034  */
00035 
00036 int mf_tektronix_initscreen()
00037 {
00038     bzero(zero_array, sizeof(zero_array));
00039     return 1;
00040 }
00041 
00042 /*
00043  *     procedure updatescreen;
00044  *
00045  *            Print out the screen bitmap.
00046  */
00047 void mf_tektronix_updatescreen()
00048 {
00049     int r, c, startc, makingline;
00050 
00051     printf("%c%c", ESCAPE, FORMFEED);
00052     for (r = 0; r < HEIGHT; r++) {
00053        makingline = FALSE;
00054        if (bcmp(&screen_pixel[r*WIDTHINBYTES],zero_array,WIDTHINBYTES) == 0)
00055            continue;
00056        for (c = 0; c < WIDTH; c++) {
00057            if (ISSET(r, c)) {
00058               if (!makingline) {
00059                   makingline = TRUE;
00060                   startc = c;
00061               }
00062            } else if (makingline) {
00063               putchar(GS);
00064               putchar(0x20|((HEIGHT-1)-r)>>5);
00065               putchar(0x60|((HEIGHT-1)-r)&0x1F);
00066               putchar(0x20|startc>>5);
00067               putchar(0x40|startc&0x1F);
00068               putchar(0x60|((HEIGHT-1)-r)&0x1F); /* Don't send high y */
00069               putchar(0x20|c>>5);
00070               putchar(0x40|c&0x1F);
00071               makingline = FALSE;
00072            }
00073        }
00074        if (makingline)  {
00075            putchar(GS);
00076            putchar(0x20|((HEIGHT-1)-r)>>5);
00077            putchar(0x60|((HEIGHT-1)-r)&0x1F);
00078            putchar(0x20|startc>>5);
00079            putchar(0x40|startc&0x1F);
00080            putchar(0x60|((HEIGHT-1)-r)&0x1F); /* Don't send high y */
00081            putchar(0x20|c>>5);
00082            putchar(0x40|c&0x1F);
00083        }
00084     }
00085     printf("%c%c%c%c%c", GS, 0x23, 0x66, 0x20, 0x40);
00086     putchar(US);
00087     fflush(stdout);
00088 }
00089 
00090 /*
00091  *     procedure blankrectangle(left, right, top, bottom: integer);
00092  *
00093  *            Blanks out a port of the screen.
00094  */
00095 void mf_tektronix_blankrectangle P4C(screencol, left,
00096                                      screencol, right,
00097                                      screenrow, top,
00098                                      screenrow, bottom)
00099 {
00100     int       r, c;
00101 
00102     if (left == 0 && right == WIDTH && top == 0 && bottom == HEIGHT)
00103        bzero(screen_pixel, sizeof(screen_pixel));
00104     else 
00105        for (r = top; r < bottom; r++)
00106            for (c = left; c < right; c++)
00107               CLEARBIT(r, c);
00108 }
00109 
00110 /*
00111  *     procedure paintrow(
00112  *                   row:          screenrow;
00113  *                   init_color:   pixelcolor;
00114  *            var    trans_vector: transspec;
00115  *                   vector_size:  screencol);
00116  *
00117  *            Paint "row" starting with color "init_color", up to next
00118  *            transition specified by "transition_vector", switch colors,
00119  *            and continue for "vector_size" transitions.
00120  */
00121 void mf_tektronix_paintrow P4C(screenrow,  row,
00122                                pixelcolor, init_color,
00123                                transspec,  transition_vector,
00124                                screencol,  vector_size)
00125 {
00126     int k = 0;
00127     int c = transition_vector[0];
00128 
00129     do {
00130        k++;
00131        do {
00132            if (init_color)
00133               SETBIT(row, c);
00134            else
00135               CLEARBIT(row, c);
00136        } while (++c != transition_vector[k]);
00137        init_color = !init_color;
00138     } while (k != vector_size);
00139 }
00140 
00141 #else
00142 int tek_dummy;
00143 #endif /* TEKTRONIXWIN */