| 1 |
/* Tektronix terminal window interface for Metafont. */ |
| 2 |
|
| 3 |
#define EXTERN extern |
| 4 |
#include "../mfd.h" |
| 5 |
|
| 6 |
#ifdef TEKTRONIXWIN /* Whole file */ |
| 7 |
|
| 8 |
#define FORMFEED 12 |
| 9 |
#define ESCAPE 27 |
| 10 |
#define GS 29 |
| 11 |
#define US 31 |
| 12 |
#ifndef TRUE |
| 13 |
#define TRUE 1 |
| 14 |
#endif |
| 15 |
#ifndef FALSE |
| 16 |
#define FALSE 0 |
| 17 |
#endif |
| 18 |
#define WIDTH 1024 /* Screen width */ |
| 19 |
#define HEIGHT 780 /* Screen height */ |
| 20 |
#define WIDTHINBYTES (WIDTH/8) /* Only works if WIDTH % 8 == 0 */ |
| 21 |
#define SETBIT(row,col) screen_pixel[row*WIDTHINBYTES+col/8] |= 1 << 7-col%8 |
| 22 |
#define CLEARBIT(row,col) screen_pixel[row*WIDTHINBYTES+col/8] &= \ |
| 23 |
~(1 << 7-col%8) |
| 24 |
#define ISSET(row,col) (screen_pixel[row*WIDTHINBYTES+col/8] & 1 << 7-col%8) |
| 25 |
|
| 26 |
char screen_pixel[WIDTHINBYTES*HEIGHT]; |
| 27 |
char zero_array[WIDTHINBYTES]; |
| 28 |
|
| 29 |
#include <mfdisplay.h> |
| 30 |
|
| 31 |
/* |
| 32 |
* function init_screen: boolean; |
| 33 |
* |
| 34 |
* Return true if window operations legal. |
| 35 |
* We always return true. |
| 36 |
*/ |
| 37 |
|
| 38 |
int |
| 39 |
mf_tektronix_initscreen(void) |
| 40 |
{ |
| 41 |
memset(zero_array, 0, sizeof(zero_array)); |
| 42 |
return 1; |
| 43 |
} |
| 44 |
|
| 45 |
/* |
| 46 |
* procedure updatescreen; |
| 47 |
* |
| 48 |
* Print out the screen bitmap. |
| 49 |
*/ |
| 50 |
void |
| 51 |
mf_tektronix_updatescreen(void) |
| 52 |
{ |
| 53 |
int r, c, startc, makingline; |
| 54 |
|
| 55 |
printf("%c%c", ESCAPE, FORMFEED); |
| 56 |
for (r = 0; r < HEIGHT; r++) { |
| 57 |
makingline = FALSE; |
| 58 |
if (memcmp(&screen_pixel[r*WIDTHINBYTES],zero_array,WIDTHINBYTES) == 0) |
| 59 |
continue; |
| 60 |
for (c = 0; c < WIDTH; c++) { |
| 61 |
if (ISSET(r, c)) { |
| 62 |
if (!makingline) { |
| 63 |
makingline = TRUE; |
| 64 |
startc = c; |
| 65 |
} |
| 66 |
} else if (makingline) { |
| 67 |
putchar(GS); |
| 68 |
putchar(0x20|((HEIGHT-1)-r)>>5); |
| 69 |
putchar(0x60|((HEIGHT-1)-r)&0x1F); |
| 70 |
putchar(0x20|startc>>5); |
| 71 |
putchar(0x40|startc&0x1F); |
| 72 |
putchar(0x60|((HEIGHT-1)-r)&0x1F); /* Don't send high y */ |
| 73 |
putchar(0x20|c>>5); |
| 74 |
putchar(0x40|c&0x1F); |
| 75 |
makingline = FALSE; |
| 76 |
} |
| 77 |
} |
| 78 |
if (makingline) { |
| 79 |
putchar(GS); |
| 80 |
putchar(0x20|((HEIGHT-1)-r)>>5); |
| 81 |
putchar(0x60|((HEIGHT-1)-r)&0x1F); |
| 82 |
putchar(0x20|startc>>5); |
| 83 |
putchar(0x40|startc&0x1F); |
| 84 |
putchar(0x60|((HEIGHT-1)-r)&0x1F); /* Don't send high y */ |
| 85 |
putchar(0x20|c>>5); |
| 86 |
putchar(0x40|c&0x1F); |
| 87 |
} |
| 88 |
} |
| 89 |
printf("%c%c%c%c%c", GS, 0x23, 0x66, 0x20, 0x40); |
| 90 |
putchar(US); |
| 91 |
fflush(stdout); |
| 92 |
} |
| 93 |
|
| 94 |
/* |
| 95 |
* procedure blankrectangle(left, right, top, bottom: integer); |
| 96 |
* |
| 97 |
* Blanks out a port of the screen. |
| 98 |
*/ |
| 99 |
void |
| 100 |
mf_tektronix_blankrectangle (screencol left, |
| 101 |
screencol right, |
| 102 |
screenrow top, |
| 103 |
screenrow bottom) |
| 104 |
{ |
| 105 |
int r, c; |
| 106 |
|
| 107 |
if (left == 0 && right == WIDTH && top == 0 && bottom == HEIGHT) |
| 108 |
memset(screen_pixel, 0, sizeof(screen_pixel)); |
| 109 |
else |
| 110 |
for (r = top; r < bottom; r++) |
| 111 |
for (c = left; c < right; c++) |
| 112 |
CLEARBIT(r, c); |
| 113 |
} |
| 114 |
|
| 115 |
/* |
| 116 |
* procedure paintrow( |
| 117 |
* row: screenrow; |
| 118 |
* init_color: pixelcolor; |
| 119 |
* var trans_vector: transspec; |
| 120 |
* vector_size: screencol); |
| 121 |
* |
| 122 |
* Paint "row" starting with color "init_color", up to next |
| 123 |
* transition specified by "transition_vector", switch colors, |
| 124 |
* and continue for "vector_size" transitions. |
| 125 |
*/ |
| 126 |
void |
| 127 |
mf_tektronix_paintrow (screenrow row, |
| 128 |
pixelcolor init_color, |
| 129 |
transspec transition_vector, |
| 130 |
screencol vector_size) |
| 131 |
{ |
| 132 |
int k = 0; |
| 133 |
int c = transition_vector[0]; |
| 134 |
|
| 135 |
do { |
| 136 |
k++; |
| 137 |
do { |
| 138 |
if (init_color) |
| 139 |
SETBIT(row, c); |
| 140 |
else |
| 141 |
CLEARBIT(row, c); |
| 142 |
} while (++c != transition_vector[k]); |
| 143 |
init_color = !init_color; |
| 144 |
} while (k != vector_size); |
| 145 |
} |
| 146 |
|
| 147 |
#else |
| 148 |
int tek_dummy; |
| 149 |
#endif /* TEKTRONIXWIN */ |