Run gnuplot on Xenix or 286 UNIX

Dave Lewis lewis at m2-net.UUCP
Thu Jun 22 11:55:41 AEST 1989


If you have a UNIX or Xenix AT clone (286, maybe 386), and you want to be
able to run gnuplot to do graphs and function plotting to your computer
screen and printer, then these patches will help.

Prerequisites:
 1) gnuplot (from a GNU archive site)
 2) gl_plot (volume 18 of comp.sources.unix)
 3) UNIX or Xenix on an AT clone computer.  

What it is:
 Patches for "term.c" in gnuplot source code (plus trivial patches for the
 "makefile" and "plot.h" header, suitable for Microport 286 UNIX).

What it does:
 Allows gnuplot to display on the computer screen, or output to a dot matrix
 printer or Laserjet.

How to use it:
 Apply the following patches to your gnuplot source.  "term.c" and "makefile"
 will be modified.  Build gl_plot and gnuplot, linking gnuplot against the
 gl.a archive produced by gl_plot.

See Gnu docs for copyright.  My patches are in the public domain.

Dave Lewis
m-net!dtlewis!lewis

-----------------------  CUT HERE  ----------------------- 

*** makefile	Mon Jun 19 22:53:22 1989
--- makefile.new	Mon Jun 19 22:53:08 1989
***************
*** 10,12
  # -O if you trust your compiler's optimizer
! CFLAGS = -DVFORK -g #-gx -O
  

--- 10,12 -----
  # -O if you trust your compiler's optimizer
! CFLAGS = -Ml -g #-gx -O
  
***************
*** 24,25
  # -DV384        Vectrix 384 and tandy color printer
  

--- 24,26 -----
  # -DV384        Vectrix 384 and tandy color printer
+ # -GL		gl_plot library for AT clone UNIX (from comp.sources.unix)
  
***************
*** 25,27
  
! TERMFLAGS = -DPOSTSCRIPT -DREGIS -DTEK -DSELANAR -DUNIXPLOT -DHP26
  

--- 26,28 -----
  
! TERMFLAGS = -DGL -DREGIS -DTEK -DUNIXPLOT 
  
***************
*** 42,44
  # -lplot if you have -DUNIXPLOT
! LIBS = -lm -lplot
  

--- 43,45 -----
  # -lplot if you have -DUNIXPLOT
! LIBS = -lm -lgl
  
*** plot.h	Mon Jun 19 22:54:18 1989
--- plot.new	Mon Jun 19 22:54:03 1989
***************
*** 22,24
  #else /* vms */
! #define HELP  "/u/local/bin/help gnuplot"
  #endif /* vms */

--- 22,24 -----
  #else /* vms */
! #define HELP  "/usr/local/bin/gnuphelp gnuplot"
  #endif /* vms */
*** term.c	Mon Jun 19 22:51:05 1989
--- term.new	Mon Jun 19 22:51:21 1989
***************
*** 18,19
  
  char *getenv();

--- 18,23 -----
  
+ #ifdef GL
+ #include "gl.h"
+ #endif /* GL */
+ 
  char *getenv();
***************
*** 811,813
  {
! #define	SOLID	1
  #define LINE4	4

--- 815,817 -----
  {
! #define	HPSOLID	1
  #define LINE4	4
***************
*** 820,823
  
! static int map[2+9] = {	SOLID,	/* border */
! 						SOLID,	/* axes */
  						DOTS,	/* plot 0 */

--- 824,827 -----
  
! static int map[2+9] = {	HPSOLID,	/* border */
! 						HPSOLID,	/* axes */
  						DOTS,	/* plot 0 */
***************
*** 829,832
  						LINE10,	/* plot 6 */
! 						SOLID,	/* plot 7 */
! 						SOLID	/* plot 8 */ };
  

--- 833,836 -----
  						LINE10,	/* plot 6 */
! 						HPSOLID,	/* plot 7 */
! 						HPSOLID	/* plot 8 */ };
  
***************
*** 1558,1561
  {
- 	openpl();
- 	space(0, 0, UP_XMAX, UP_YMAX);
  }

--- 1562,1563 -----
  {
  }
***************
*** 1565,1566
  {
  	erase();

--- 1567,1570 -----
  {
+ 	openpl();
+ 	space(0, 0, UP_XMAX, UP_YMAX);
  	erase();
***************
*** 1571,1572
  {
  }

--- 1575,1579 -----
  {
+ 	char dummy[80];
+ 	gets(dummy);	/* Wait for carriage return	*/
+ 	closepl();
  }
***************
*** 1620,1622
  {
- 	closepl();
  }

--- 1627,1628 -----
  {
  }
***************
*** 1626,1627
  
  

--- 1632,1634 -----
  
+ #ifdef GL
  
***************
*** 1627,1628
  
  UNKNOWN_null()

--- 1634,2014 -----
  
+ /* gl_plot library (from comp.sources.unix archives) for graphics support
+  * on PC unix machines.
+  *
+  * system5 dtlewis 2 2.2-U AT
+  * Sun Dec  6 16:55:30 EST 1987
+  * Tue Mar  8 23:25:22 EST 1988
+  * Wed Jun  7 23:17:06 EDT 1989
+  *
+  * The coordinate system for the graphics routines has the origin in the
+  * upper left corner of the screen.  The X axis runs from 0 to 32767, and
+  * the Y axis runs downward from 0 to 32767. 
+  */
+ 
+ #define GL_XMAX 32767
+ #define GL_YMAX 32767
+ 
+ #define GL_VCHAR 160
+ #define GL_ibm_printer_VCHAR 100
+ #define GL_lj_printer_VCHAR 100
+ 
+ #define GL_VTIC 1500
+ #define GL_ibm_printer_VTIC 1000
+ #define GL_lj_printer_VTIC 1000
+ 
+ #define GL_herc_HCHAR 50
+ #define GL_cga_color_HCHAR 100
+ #define GL_cga_hires_HCHAR 60
+ #define GL_ega_color_HCHAR 60
+ #define GL_ibm_printer_HCHAR 50
+ #define GL_lj_printer_HCHAR 50
+ 
+ #define GL_herc_HTIC 400
+ #define GL_cga_color_HTIC 800
+ #define GL_cga_hires_HTIC 480
+ #define GL_ega_color_HTIC 480
+ #define GL_ibm_printer_HTIC 400
+ #define GL_lj_printer_HTIC 400
+ 
+ GL_init()  
+ /* Called once, when the device is first selected.  This procedure
+ should set up things that only need to be set once, like handshaking and
+ character sets etc...
+ */
+ {
+ }
+ 
+ GL_herc_graphics()  
+ /* Called just before a plot is going to be displayed.  This
+ procedure should set the device into graphics mode.  Devices which can't
+ be used as terminals (like plotters) will probably be in graphics mode always
+ and therefore won't need this.
+ */
+ /* NOTE:  There must be a command in your path called "mode" which
+ sets video mode appropriately.
+ */
+ {
+ 	g_init(HERC_P1_MODE);
+ 	g_fontctl(1.4, 1.0, 1.4, 0.0, 0.0);
+ 	g_clear();	/* Clear graphics memory	*/
+ }
+ 
+ GL_cga_color_graphics()  
+ {
+ 	g_init(CGA_COLOR_MODE);
+ 	g_fontctl(1.0, 1.0, 1.0, 0.0, 0.0);
+ 	g_clear();	/* Clear graphics memory	*/
+ }
+ 
+ GL_cga_hires_graphics()  
+ {
+ 	g_init(CGA_HI_RES_MODE);
+ 	g_fontctl(1.0, 1.0, 1.0, 0.0, 0.0);
+ 	g_clear();	/* Clear graphics memory	*/
+ }
+ 
+ GL_ega_color_graphics()  
+ {
+ 	g_init(EGA_COLOR_MODE);
+ 	g_fontctl(1.0, 1.0, 1.0, 0.0, 0.0);
+ 	g_clear();	/* Clear graphics memory	*/
+ }
+ 
+ GL_ibm_printer_graphics()
+ {
+ 	g_init(IBM_PRINTER);
+ 	g_fontctl(1.0, 1.0, 1.0, 0.0, 0.0);
+ }
+ 
+ GL_lj_printer_graphics()
+ {
+ 	g_init(LJ_PRINTER);
+ 	g_fontctl(1.0, 1.0, 1.0, 0.0, 0.0);
+ }
+ 
+ GL_text()  
+ /* Called after a plot is displayed.  This procedure should set the
+ device back into text mode if it is also a terminal, so that commands can
+ be seen as they're typed.  Again, this will probably do nothing if the
+ device can't be used as a terminal.
+ */
+ /* NOTE:  There must be a command in your path called "mode" which
+ sets video mode appropriately.
+ */
+ {
+ 	char dummy[80];
+ 	gets(dummy);	/* Wait for carriage return	*/
+ 	g_finish();
+ }
+ 
+ GL_printer_text()
+ {
+ 	g_finish();
+ }
+ 
+ GL_linetype(lt)  
+ /* Called to set the line type before text is displayed or line(s)
+ plotted.  This procedure should select a pen color or line style if the
+ device has these capabilities.  lt is an integer from -2 to 8.  An lt of
+ -2 is used for the border of the plot.  An lt of -1 is used for the X and Y
+ axes.  lt 0 through 8 are used for plots 0 through 8.
+ */
+ int lt;
+ {
+ 	long linestyle;
+ 	switch (lt)  {
+ 		case -2:	linestyle = SOLID;		break;
+ 		case -1:	linestyle = DASHED;		break;
+ 		case 0:		linestyle = SOLID;		break;
+ 		case 1:		linestyle = DASHED;		break;
+ 		case 2:		linestyle = SHORTDASHED;	break;
+ 		case 3:		linestyle = DOTDASHED;		break;
+ 		case 4:		linestyle = LONGDASHED;		break;
+ 		case 5:		linestyle = SOLID;		break;
+ 		case 6:		linestyle = DASHED;		break;
+ 		case 7:		linestyle = SHORTDASHED;	break;
+ 		case 8:		linestyle = DOTDASHED;		break;
+ 		default:	linestyle = LONGDASHED;
+ 	}
+ 	g_style(linestyle);
+ }
+ 
+ GL_move(x,y)  
+ /* Called at the start of a line.  The cursor should move to the
+ (x,y) position without drawing.
+ */
+ unsigned int x,y;
+ {
+ 	/* Note:  Y coordinate inverted to put it right side up on screen. */
+ 	n_movepen(x, 0x07FFF - y);
+ }
+ 
+ GL_vector(x,y)  
+ /* Called when a line is to be drawn.  This should display a line
+ from the last (x,y) position given by _move() or _vector() to this new (x,y)
+ position.
+ */
+ unsigned int x,y;
+ {
+ 	/* Note:  Y coordinate inverted to put it right side up on screen. */
+ 	n_draw(x, GL_YMAX - y);
+ }
+ 
+ GL_herc_hw_ulput_text(row,str)  
+ /* Called to display text in the upper-left corner of
+ the screen/page.  row is an integer from 0 through 8.  The row starts
+ at the upper-left with 0 and proceed down.  str is the string to be displayed.
+ */
+ unsigned int row;
+ char str[];
+ {
+ 	c_cursor(row + 4 , 3);
+ 	c_cellstr(str);
+ }
+ 
+ GL_hw_ulput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	c_cursor(row + 3 , 3);
+ 	c_cellstr(str);
+ }
+ 
+ GL_herc_ulput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	long save_style = g_style(SOLID);
+ 	n_movepen((int)(1.5 * GL_herc_HTIC),
+ 		(row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_cga_color_ulput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	long save_style = g_style(SOLID);
+ 	n_movepen((int)(1.5 * GL_cga_color_HTIC),
+ 		(row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_cga_hires_ulput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	long save_style = g_style(SOLID);
+ 	n_movepen((int)(1.5 * GL_cga_hires_HTIC),
+ 		(row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_ega_color_ulput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	long save_style = g_style(SOLID);
+ 	n_movepen((int)(1.5 * GL_ega_color_HTIC),
+ 		(row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_ibm_printer_ulput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	long save_style = g_style(SOLID);
+ 	n_movepen((int)(1.5 * GL_ibm_printer_HTIC),
+ 		(row + 2) * GL_ibm_printer_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_lj_printer_ulput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	long save_style = g_style(SOLID);
+ 	n_movepen((int)(1.5 * GL_lj_printer_HTIC),
+ 		(row + 2) * GL_lj_printer_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_herc_hw_lrput_text(row,str)  
+ /* Called to display text in the lower-right corner of
+ the screen/page.  This is the same as ulput_text(), except that the string
+ should be displayed right-justified in the lower right corner of the screen.
+ The row starts at the lower-right with 0 and proceeds up.
+ */
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	c_cursor(41 - row, 89 - charcount);
+ 	c_cellstr(str);
+ }
+ 
+ GL_cga_color_hw_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	c_cursor(23 - row, 39 - charcount);
+ 	c_cellstr(str);
+ }
+ 
+ GL_cga_hires_hw_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	c_cursor(23 - row, 79 - charcount);
+ 	c_cellstr(str);
+ }
+ 
+ GL_ega_color_hw_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	c_cursor(23 - row, 79 - charcount);
+ 	c_cellstr(str);
+ }
+ 
+ GL_herc_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	long save_style = g_style(SOLID);
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	n_movepen(GL_XMAX - (2 + charcount) * GL_herc_HTIC,
+ 		GL_YMAX - (row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_cga_color_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	long save_style = g_style(SOLID);
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	n_movepen(GL_XMAX - (2 + charcount) * GL_cga_color_HTIC,
+ 		GL_YMAX - (row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_cga_hires_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	long save_style = g_style(SOLID);
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	n_movepen(GL_XMAX - (2 + charcount) * GL_cga_hires_HTIC,
+ 		GL_YMAX - (row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_ega_color_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	long save_style = g_style(SOLID);
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	n_movepen(GL_XMAX - (2 + charcount) * GL_ega_color_HTIC,
+ 		GL_YMAX - (row + 2) * GL_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_ibm_printer_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	long save_style = g_style(SOLID);
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	n_movepen(GL_XMAX - (2 + charcount) * GL_ibm_printer_HTIC,
+ 		GL_YMAX - (row + 2) * GL_ibm_printer_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_lj_printer_lrput_text(row,str)  
+ unsigned int row;
+ char str[];
+ {
+ 	int charcount;	/* Count characters in str */
+ 	long save_style = g_style(SOLID);
+ 	for (charcount=0; str[charcount]!=NULL; charcount++);
+ 	n_movepen(GL_XMAX - (2 + charcount) * GL_lj_printer_HTIC,
+ 		GL_YMAX - (row + 2) * GL_lj_printer_VTIC);
+ 	n_grafstr(str);
+ 	g_style(save_style);
+ }
+ 
+ GL_reset()  
+ /* Called when Gnuplot is exited.  This procedure should reset the
+ device, possibly flushing a buffer somewhere or generating a form feed. */
+ {
+ }
+ 
+ #endif /* GL */
+ 
  UNKNOWN_null()
***************
*** 1755,1756
  		V384_ulput_text, do_point}
  #endif

--- 2141,2215 -----
  		V384_ulput_text, do_point}
+ #endif
+ 
+ #ifdef GL
+ 	,{"HERCULES (vector text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_herc_HCHAR, GL_VTIC, GL_herc_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_herc_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_herc_lrput_text,
+ 		GL_herc_ulput_text, do_point}
+ 
+ 	,{"hercules (cell text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_herc_HCHAR, GL_VTIC, GL_herc_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_herc_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_herc_hw_lrput_text,
+ 		GL_herc_hw_ulput_text, do_point}
+ 
+ 	,{"CGA_COLOR (vector text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_cga_color_HCHAR, GL_VTIC, 
+ 		GL_cga_color_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_cga_color_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_cga_color_lrput_text,
+ 		GL_cga_color_ulput_text, do_point}
+ 
+ 	,{"cga_color (cell text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_cga_color_HCHAR, GL_VTIC, 
+ 		GL_cga_color_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_cga_color_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_cga_color_hw_lrput_text,
+ 		GL_hw_ulput_text, do_point}
+ 
+ 	,{"CGA_HIRES (vector text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_cga_hires_HCHAR, GL_VTIC, 
+ 		GL_cga_hires_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_cga_hires_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_cga_hires_lrput_text,
+ 		GL_cga_hires_ulput_text, do_point}
+ 
+ 	,{"cga_hires (cell text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_cga_hires_HCHAR, GL_VTIC, 
+ 		GL_cga_hires_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_cga_hires_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_cga_hires_hw_lrput_text,
+ 		GL_hw_ulput_text, do_point}
+ 
+ 	,{"EGA_color (vector text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_ega_color_HCHAR, GL_VTIC, 
+ 		GL_ega_color_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_ega_color_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_ega_color_lrput_text,
+ 		GL_ega_color_ulput_text, do_point}
+ 
+ 	,{"ega_color (cell text)", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_ega_color_HCHAR, GL_VTIC, 
+ 		GL_ega_color_HTIC, GL_init,
+ 		GL_reset, GL_text, GL_ega_color_graphics, GL_move,
+ 		GL_vector, GL_linetype, GL_ega_color_hw_lrput_text,
+ 		GL_hw_ulput_text, do_point}
+ 
+ 	,{"IBM_printer", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_ibm_printer_HCHAR, GL_VTIC, 
+ 		GL_ibm_printer_HTIC, GL_init,
+ 		GL_reset, GL_printer_text, GL_ibm_printer_graphics, 
+ 		GL_move, GL_vector, GL_linetype, 
+ 		GL_ibm_printer_lrput_text,
+ 		GL_ibm_printer_ulput_text, do_point}
+ 
+ 	,{"laserjet_printer", GL_XMAX, GL_YMAX, GL_VCHAR,
+ 		GL_lj_printer_HCHAR, GL_VTIC, 
+ 		GL_lj_printer_HTIC, GL_init,
+ 		GL_reset, GL_printer_text, GL_lj_printer_graphics, 
+ 		GL_move, GL_vector, GL_linetype, 
+ 		GL_lj_printer_lrput_text,
+ 		GL_lj_printer_ulput_text, do_point}
+ 
  #endif


-- 
Dave Lewis
Ann Arbor, MI
...!m-net!dtlewis!lewis



More information about the Comp.unix.microport mailing list