home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gp36emx.zip / emxvga.trm < prev    next >
Text File  |  1996-01-08  |  5KB  |  185 lines

  1. /* GNUPLOT - emxvga.trm */
  2. /*
  3.  * Copyright (C) 1994
  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.  Be sure to add term_tbl[EMXVGA].
  18.  *
  19.  * This terminal driver supports:
  20.  *   SVGA 640x480x256 on PC's running DOS or OS/2, windowed or full-screen,
  21.  *   emx run-time lib required for OS/2.
  22.  *
  23.  * AUTHOR
  24.  *   David J. Liu (liudj0@minerva.cis.yale.edu)
  25.  */
  26.  
  27. /*
  28.  * Compile with GCC (emx) with VESA and SVGAKIT maintained by
  29.  * Johannes Martin <z946785@corn.cso.niu.edu>
  30.  * with addition of g_string() by David J. Liu (liudj0@minerva.cis.yale.edu)
  31.  * ftp.uni-stuttgart.de:/pub/systems/os2/emx-0.8h/contrib/gstring.zip
  32.  * alternatively, define BORLAND to use Borland fonts (untested)
  33.  * supports Trident, Cirrus, ET4000, WD, S3 and all other VESA cards.
  34.  */
  35.  
  36. #ifndef GOT_TERM_DRIVER
  37. #include "driver.h"
  38. #endif
  39.  
  40. #ifdef TERM_REGISTER
  41. register_term(emxvga)
  42. #endif
  43.  
  44. #ifdef TERM_PROTO
  45.  
  46. #define EMXVGA_VCHAR 8
  47. #define EMXVGA_HCHAR 8
  48. #define EMXVGA_VTIC 4
  49. #define EMXVGA_HTIC 4
  50. #define EMXVGA_XMAX 0 /* These two entries are just place holders. */
  51. #define EMXVGA_YMAX 0 /* The actual values will be filled in init. */
  52.  
  53. TERM_PUBLIC void EMXVGA_init __P((void));
  54. TERM_PUBLIC void EMXVGA_reset __P((void));
  55. TERM_PUBLIC void EMXVGA_text __P((void));
  56. TERM_PUBLIC void EMXVGA_graphics __P((void));
  57. TERM_PUBLIC void EMXVGA_linetype __P((int linetype));
  58. TERM_PUBLIC void EMXVGA_move __P((unsigned int x, unsigned int y));
  59. TERM_PUBLIC void EMXVGA_vector __P((unsigned int x, unsigned int y));
  60. TERM_PUBLIC int  EMXVGA_text_angle __P((int ang));
  61. TERM_PUBLIC void EMXVGA_put_text __P((unsigned int x, unsigned int y, char *str));
  62. TERM_PUBLIC void EMXVGA_suspend __P((void));
  63. TERM_PUBLIC void EMXVGA_resume __P((void));
  64.  
  65. #endif
  66.  
  67. #ifdef TERM_BODY
  68.  
  69. #ifdef DOWN
  70. #undef DOWN
  71. #endif
  72. #ifdef RIGHT
  73. #undef RIGHT
  74. #endif
  75. #include <vesa.h>
  76. #include <graph.h>
  77. #undef DOWN   /* to avoid a conflict */
  78. #undef RIGHT  /* between graph.h and other terminals */
  79.  
  80. static int EMXVGA_vmode=G640x480x256 ; /* default mode */
  81. static int vgacolor[]={7,8,2,3,4,5,9,14,12,15,13,10,11,1,6} ;
  82. static int startx,starty,lasty,graphics_on=FALSE ;
  83. static int EMXVGA_angle,EMXVGA_color ;
  84. static char EMXVGA_chr,*EMXVGA_buf ;
  85.  
  86. TERM_PUBLIC void EMXVGA_init ()
  87. {
  88.   if (!g_mode(EMXVGA_vmode))
  89.     { fprintf (stderr,"Unable to initiate graphics.\n") ; return ; }
  90.   term->xmax=g_xsize ; term->ymax=g_ysize ; lasty=g_ysize-1 ;
  91. #ifdef BORLAND
  92.   gf_loadfont ("default.chr") ;
  93. #endif
  94. }
  95.  
  96. TERM_PUBLIC void EMXVGA_reset ()
  97. {
  98.   g_mode (GTEXT) ; graphics_on=FALSE ;
  99. }
  100.  
  101. TERM_PUBLIC void EMXVGA_text ()
  102. {
  103.   if (graphics_on)
  104.     { VesaGetCharacter (&EMXVGA_chr) ; g_mode (GTEXT) ; graphics_on=FALSE ; }
  105. }
  106.  
  107. TERM_PUBLIC void EMXVGA_graphics ()
  108. {
  109.   if (!graphics_on) { g_mode (EMXVGA_vmode) ; graphics_on=TRUE ; }
  110. }
  111.  
  112. TERM_PUBLIC void EMXVGA_linetype (linetype)
  113.   int linetype;
  114. {
  115.   EMXVGA_color=vgacolor[(linetype%13)+2] ;
  116. }
  117.  
  118. TERM_PUBLIC void EMXVGA_move (x,y)
  119.   unsigned int x,y ;
  120. {
  121.   startx=x ; starty=y ;
  122. }
  123.  
  124. TERM_PUBLIC void EMXVGA_vector (x,y)
  125.   unsigned int x,y ;
  126. {
  127.   g_line (startx,lasty-starty,x,lasty-y,EMXVGA_color) ;
  128.   startx=x ; starty=y ;
  129. }
  130.  
  131. TERM_PUBLIC int EMXVGA_text_angle (ang)
  132.   int ang ;
  133. {
  134. #ifdef BORLAND
  135.   EMXVGA_angle=ang ;
  136. #else
  137.   EMXVGA_angle=ang*90 ;
  138. #endif
  139.   return (TRUE) ;
  140. }
  141.  
  142. TERM_PUBLIC void EMXVGA_put_text (x,y,str)
  143.   unsigned int x,y ;
  144.   char *str ;
  145. {
  146. #ifdef BORLAND
  147.   gf_setdirection (EMXVGA_angle) ;
  148.   gf_drawstring (x,lasty-y,str,EMXVGA_color) ;
  149. #else
  150.   g_string (x,lasty-y-3,EMXVGA_color,EMXVGA_angle,str) ;
  151. #endif
  152. }
  153.  
  154. TERM_PUBLIC void EMXVGA_suspend ()
  155. {
  156.   EMXVGA_buf=(char *)malloc(g_memsize) ;
  157.   g_save (EMXVGA_buf) ;
  158.   g_mode (GTEXT) ;
  159. }
  160.  
  161. TERM_PUBLIC void EMXVGA_resume ()
  162. {
  163.   g_mode (EMXVGA_vmode) ;
  164.   g_restore (EMXVGA_buf) ;
  165.   free (EMXVGA_buf) ;
  166. }
  167.  
  168. #endif
  169.  
  170. #ifdef TERM_TABLE
  171. TERM_TABLE_START(emxvga_driver)
  172.   "emxvga", "PC with SuperVGA running DOS or OS/2",
  173.   EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  174.   EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
  175.   EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move, EMXVGA_vector,
  176.   EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
  177.   null_justify_text, do_point, do_arrow, set_font_null,
  178.   0, /* pointsize */
  179.   TERM_CAN_MULTIPLOT, EMXVGA_suspend, EMXVGA_resume
  180. TERM_TABLE_END(emxvga_driver)
  181.  
  182. #undef LAST_TERM
  183. #define LAST_TERM emxvga_driver
  184. #endif
  185.