1 /* Regis terminal window interface for Metafont, joe@rilgp.tamri.com.
2    screen_rows is 480; screen_cols is 800. */
3 
4 #define	EXTERN	extern
5 #include "../mfd.h"
6 
7 #ifdef REGISWIN		/* Whole file */
8 
9 #define ESCAPE		27
10 
11 /* set this up in one of two ways.  if defined, display is white characters
12 on a black background; undefined is the opposite */
13 #undef WRITEWHITE
14 
15 #include <mfdisplay.h>
16 
17 /*
18  *	int init_screen
19  *		Put screen in graphics mode:<ESC>Pp
20  *		Write no or both planes for the background black:S(I0)
21  *		Write both or no planes for the forground white:W(I3)
22  *		Erase screen:S(E)
23  *		Return to alpha mode: <ESC>\
24  *
25  *		Assuming that the speed limitation is a serial line to the
26  *		terminal, we want to define macros for the most common
27  *		character combinations.
28  *		Define macros for ,+0]P[ (call this "p") and
29  *		,+0]V[ (this one is called "v").
30  *		drawing a line is 4+(2 to 6) characters
31  *		We always return true.
32  */
33 
mf_regis_initscreen(void)34 int mf_regis_initscreen(void)
35 {
36 #ifdef WRITEWHITE
37 	printf("%cPpS(I0)W(I3)S(E)%c",ESCAPE,ESCAPE);
38 #else
39 	printf("%cPpS(I3)W(I0)S(E)%c",ESCAPE,ESCAPE);
40 #endif
41 	printf("%cPp@:p,+0]P[@;@:v,+0]V[@;",ESCAPE);
42 	return 1;
43 }
44 /*
45  *	procedure updatescreen;
46  *
47  */
mf_regis_updatescreen(void)48 void mf_regis_updatescreen(void)
49 {
50 }
51  /*	void blankrectangle(int left,int right,int top,int bottom);
52  *
53  *		Go to graphics mode: <ESC>Pp
54  *		Move to lower left: P[%d,%d]
55  *		Write no or both planes: W(I0)
56  *		Turn on shading: W(S1)
57  *		Vector to lower right, upper right, upper left, lower left: V's
58  *		Turn off shading: W(S0)
59  *		Write both or no planes: W(I3)
60  *		Return to alpha mode: <ESC>\
61  */
mf_regis_blankrectangle(screencol left,screencol right,screenrow top,screenrow bottom)62 void mf_regis_blankrectangle (screencol left,
63                               screencol right,
64                               screenrow top,
65                               screenrow bottom)
66 {
67 	printf(
68 #ifdef WRITEWHITE
69 	"%cPpP[%d,%d]W(I0)W(S1)V[%d,%d]V[%d,%d]V[%d,%d]V[%d,%d]W(S0)W(I3)%c\\",
70 #else
71 	"%cPpP[%d,%d]W(I3)W(S1)V[%d,%d]V[%d,%d]V[%d,%d]V[%d,%d]W(S0)W(I0)%c\\",
72 #endif
73 		ESCAPE,left,bottom,right,bottom,right,top,left,top,
74 		left,bottom,ESCAPE);
75 }
76 
77 /*
78  *	void paintrow(int row, int init_color, int* transition_vector,
79  *					int vector_size);
80  *		Paint "row" starting with color "init_color", up to next
81  *		transition specified by "transition_vector", switch colors,
82  *		and continue for "vector_size" transitions.
83  */
mf_regis_paintrow(screenrow row,pixelcolor init_color,transspec transition_vector,screencol vector_size)84 void mf_regis_paintrow (screenrow   row,
85                         pixelcolor  init_color,
86                         transspec   transition_vector,
87                         screencol   vector_size)
88 {
89 	int i;
90 	if(init_color) {
91 		init_color = 1;
92 	} else {
93 		init_color = 0;
94 	}
95 	printf("%cPpP[0,%d]P[",ESCAPE,row);
96 	for(i=0;i<vector_size;i++) {
97 		if(init_color)
98 		printf("%d@v%d@p",transition_vector[i],
99 						transition_vector[i+1]);
100 		init_color = 1-init_color;
101 	}
102 	printf("+0,+0]%c\\",ESCAPE);
103 }
104 
105 #else
106 int regis_dummy;
107 #endif	/* REGISWIN */
108