home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / GPT34SRC / TERM / FG.TRM < prev    next >
Text File  |  1993-05-25  |  5KB  |  258 lines

  1. /* GNUPLOT - fg.trm */
  2. /*
  3.  * Copyright (C) 1990, 1991, 1992
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *
  15.  * This software  is provided "as is" without express or implied warranty.
  16.  *
  17.  * This file is included by ../term.c.
  18.  *
  19.  * This terminal driver supports:
  20.  *    Under Zortech C
  21.  *      egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
  22.  *
  23.  * AUTHORS
  24.  *          Gnuplot for DOS 386/flash graphics
  25.  *                  Clifton T. Liu
  26.  *
  27.  * There is a mailing list for gnuplot users. Note, however, that the
  28.  * newsgroup 
  29.  *    comp.graphics.gnuplot 
  30.  * is identical to the mailing list (they
  31.  * both carry the same set of messages). We prefer that you read the
  32.  * messages through that newsgroup, to subscribing to the mailing list.
  33.  * (If you can read that newsgroup, and are already on the mailing list,
  34.  * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  35.  * removed from the mailing list.)
  36.  *
  37.  * The address for mailing to list members is
  38.  *       info-gnuplot@dartmouth.edu
  39.  * and for mailing administrative requests is 
  40.  *       info-gnuplot-request@dartmouth.edu
  41.  * The mailing list for bug reports is 
  42.  *       bug-gnuplot@dartmouth.edu
  43.  * The list of those interested in beta-test versions is
  44.  *       info-gnuplot-beta@dartmouth.edu
  45.  */
  46. /* The modifications to allow Gnuplot to compile with Zortech C/C++   */
  47. /* 3.1 /Flash Graphics    were made by Clifton T. Liu                   */
  48. /* (cliu@merlin.appmath.columbia.edu)         20 Feb 1993              */
  49.  
  50. #include <fg.h>
  51.  
  52. static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
  53.  
  54. static int graphics_on = FALSE;
  55. int startx, starty;
  56. /*
  57. int pc_angle;
  58. #define PC_VCHAR FNT5X9_VCHAR
  59. #define PC_HCHAR FNT5X9_HCHAR
  60. */
  61. pause()        /* press any key to continue... */
  62. {
  63.     (void) getch();
  64. }
  65.  
  66.  
  67. PC_text()
  68. {
  69.     if (graphics_on) {
  70.         graphics_on = FALSE;
  71.         pause();
  72.     }
  73.    fg_term();
  74. }
  75.  
  76. PC_reset()
  77. {
  78. }
  79.  
  80.  
  81.  
  82. /* all of the FlashGraphics C routines for the different graphics devices go here */
  83.  
  84.  
  85. #define HERC_XMAX 720
  86. #define HERC_YMAX 348
  87.  
  88. #define HERC_XLAST (HERC_XMAX - 1)
  89. #define HERC_YLAST (HERC_YMAX - 1)
  90.  
  91. #define HERC_VCHAR 10
  92. #define HERC_HCHAR 8
  93. #define HERC_VTIC 5
  94. #define HERC_HTIC 5
  95.  
  96.  
  97.  
  98. #define EGA_XMAX 640
  99. #define EGA_YMAX 350
  100.  
  101. #define EGA_XLAST (EGA_XMAX - 1)
  102. #define EGA_YLAST (EGA_YMAX - 1)
  103.  
  104. #define EGA_VCHAR 18
  105. #define EGA_HCHAR 8
  106. #define EGA_VTIC 5
  107. #define EGA_HTIC 5
  108.  
  109.  
  110. #define VGA_XMAX 640
  111. #define VGA_YMAX 480
  112.  
  113. #define VGA_XLAST (VGA_XMAX - 1)
  114. #define VGA_YLAST (VGA_YMAX - 1)
  115.  
  116. #define VGA_VCHAR 24
  117. #define VGA_HCHAR 8
  118. #define VGA_VTIC 5
  119. #define VGA_HTIC 5
  120.  
  121.  
  122. #define SVGA_XMAX 800
  123. #define SVGA_YMAX 600
  124.  
  125. #define SVGA_XLAST (SVGA_XMAX - 1)
  126. #define SVGA_YLAST (SVGA_YMAX - 1)
  127.  
  128. #define SVGA_VCHAR 24
  129. #define SVGA_HCHAR 8
  130. #define SVGA_VTIC 5
  131. #define SVGA_HTIC 5
  132.  
  133. #define SSVGA_XMAX 1024
  134. #define SSVGA_YMAX 768
  135.  
  136. #define SSVGA_XLAST (SSVGA_XMAX - 1)
  137. #define SSVGA_YLAST (SSVGA_YMAX - 1)
  138.  
  139. #define SSVGA_VCHAR 24
  140. #define SSVGA_HCHAR 8
  141. #define SSVGA_VTIC 5
  142. #define SSVGA_HTIC 5
  143.  
  144.  
  145. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  146. static int *vgacolor = vga256color;
  147. static fg_color_t vga_color;
  148. static int text_angle;
  149. static fg_line_t line_to_draw;
  150.  
  151. int VGA_text_angle(ang)
  152. int ang;
  153. {
  154.     text_angle = ang;
  155.     return TRUE;
  156. }
  157.  
  158. int VGA_justify_text(mode)
  159. enum JUSTIFY mode;
  160. {
  161.     return FALSE;
  162. }
  163.  
  164. int VGA_init()
  165. {
  166.        if (fg_init() == FG_NULL)  {
  167.            fprintf(stderr,"Graphics card not detected.\n");
  168.            exit(1);
  169.       }
  170. }
  171.  
  172. int HERC_graphics()
  173. {
  174.    fg_init_herc();
  175.    graphics_on = TRUE;
  176. }
  177.  
  178. int EGAMONO_graphics()
  179. {
  180.    fg_init_egamono();
  181.    graphics_on = TRUE;
  182. }
  183.  
  184. int EGA_graphics()
  185. {
  186.    fg_init_egaecd();
  187.    graphics_on = TRUE;
  188. }
  189.  
  190. int VGA_graphics()
  191. {
  192.    fg_init_vga12();
  193.    graphics_on = TRUE;
  194. }
  195.  
  196. int VGAMONO_graphics()
  197. {
  198.    fg_init_vga11();
  199.    graphics_on = TRUE;
  200. }
  201.  
  202. int SVGA_graphics()
  203. {
  204.    fg_init_vesa6a();
  205.    graphics_on = TRUE;
  206. }
  207.  
  208. int SSVGA_graphics()
  209. {
  210.    fg_init_vesa5();
  211.    graphics_on = TRUE;
  212. }
  213.  
  214. int VGA_linetype(linetype)
  215. {
  216.     if (linetype >= 15)
  217.         linetype %= 15;
  218.     vga_color = fg.color[vgacolor[linetype+2]];
  219. }
  220.  
  221. int VGA_put_text(x,y,str)
  222. unsigned int x, y;
  223. char *str;
  224. {
  225.    fg_puts(vga_color, FG_MODE_SET,    ~0,  text_angle, x, y, str, fg.displaybox);
  226. }
  227.  
  228. int VGA_move(x,y)
  229. {
  230.      line_to_draw[FG_X1] = x;
  231.      line_to_draw[FG_Y1] = y;
  232. }
  233.  
  234.  
  235. int VGA_vector(x,y)
  236. {
  237.      line_to_draw[FG_X2] = x;
  238.      line_to_draw[FG_Y2] = y;
  239.      fg_drawline(vga_color, FG_MODE_SET, ~0, FG_LINE_SOLID, line_to_draw);
  240.      line_to_draw[FG_X1] = x;
  241.      line_to_draw[FG_Y1] = y;
  242. }
  243.  
  244. int VGA_text()
  245. {
  246.     if (graphics_on) {
  247.         graphics_on = FALSE;
  248.         fg_flush();
  249.         pause();
  250.     }
  251.    fg_term();
  252. }
  253.  
  254. int VGA_reset()
  255. {
  256.    fg_term();
  257. }
  258.