home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gp35emx.zip / emxvga.trm < prev    next >
Text File  |  1995-12-06  |  3KB  |  121 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. #include <vesa.h>
  37. #include <graph.h>
  38. #undef DOWN   /* to avoid a conflict */
  39. #undef RIGHT  /* between graph.h and other terminals */
  40.  
  41. #define EMXVGA_VCHAR 8
  42. #define EMXVGA_HCHAR 8
  43. #define EMXVGA_VTIC 4
  44. #define EMXVGA_HTIC 4
  45. #define EMXVGA_XMAX 0 /* These two entries are just place holders. */
  46. #define EMXVGA_YMAX 0 /* The actual values will be filled in init. */
  47.  
  48. static int EMXVGA_vmode=G640x480x256 ; /* default mode */
  49. static int vgacolor[]={7,8,2,3,4,5,9,14,12,15,13,10,11,1,6} ;
  50. static int graphics_on=FALSE ;
  51. int startx,starty,lasty ;
  52. int EMXVGA_angle,EMXVGA_color ;
  53. char EMXVGA_chr ;
  54.  
  55. EMXVGA_init ()
  56. {
  57.   if (!g_mode(EMXVGA_vmode))
  58.     { fprintf (stderr,"Unable to initiate graphics.\n") ; return (1) ; }
  59.   term_tbl[term].xmax=g_xsize ;
  60.   term_tbl[term].ymax=g_ysize ;
  61.   lasty=g_ysize-1 ;
  62. #ifdef BORLAND
  63.   gf_loadfont ("default.chr") ;
  64. #endif
  65. }
  66.  
  67. EMXVGA_reset ()
  68. {
  69.   g_mode (GTEXT) ; graphics_on=FALSE ;
  70. }
  71.  
  72. EMXVGA_text ()
  73. {
  74.   if (graphics_on)
  75.     { VesaGetCharacter (&EMXVGA_chr) ; g_mode (GTEXT) ; graphics_on=FALSE ; }
  76. }
  77.  
  78. EMXVGA_graphics ()
  79. {
  80.   if (!graphics_on) { g_mode (EMXVGA_vmode) ; graphics_on=TRUE ; }
  81. }
  82.  
  83. EMXVGA_linetype (linetype)
  84. {
  85.   EMXVGA_color=vgacolor[(linetype%13)+2] ;
  86. }
  87.  
  88. EMXVGA_move (x,y)
  89. {
  90.   startx=x ; starty=y ;
  91. }
  92.  
  93. EMXVGA_vector (x,y)
  94. {
  95.   g_line (startx,lasty-starty,x,lasty-y,EMXVGA_color) ;
  96.   startx=x ; starty=y ;
  97. }
  98.  
  99. int EMXVGA_text_angle (ang)
  100.   int ang ;
  101. {
  102. #ifdef BORLAND
  103.   EMXVGA_angle=ang ;
  104. #else
  105.   EMXVGA_angle=ang*90 ;
  106. #endif
  107.   return (TRUE) ;
  108. }
  109.  
  110. EMXVGA_put_text (x,y,str)
  111.   unsigned int x,y ;
  112.   char *str ;
  113. {
  114. #ifdef BORLAND
  115.   gf_setdirection (EMXVGA_angle) ;
  116.   gf_drawstring (x,lasty-y,str,EMXVGA_color) ;
  117. #else
  118.   g_string (x,lasty-y-3,EMXVGA_color,EMXVGA_angle,str) ;
  119. #endif
  120. }
  121.