home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / gnuplot.lha / gnuplot / src / term / linux.trm < prev    next >
Encoding:
Text File  |  1993-06-08  |  2.6 KB  |  159 lines

  1. /* GNUPLOT - linux.trm */
  2. /*
  3.  * Copyright (C) 1990
  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.  *  VGA 640x480x16 for PC's running the Linux Operating System 
  21.  *
  22.  * AUTHOR
  23.  *  Tommy Frandsen (frandsen@diku.dk)
  24.  *
  25.  * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  26.  *
  27.  */
  28.  
  29. #include <vga.h>
  30.  
  31. #define LINUX_XMAX 640
  32. #define LINUX_YMAX 480
  33.  
  34. #define LINUX_XLAST (LINUX_XMAX - 1)
  35. #define LINUX_YLAST (LINUX_YMAX - 1)
  36.  
  37. #define LINUX_VCHAR FNT5X9_VCHAR
  38. #define LINUX_HCHAR FNT5X9_HCHAR
  39.  
  40. #define LINUX_VTIC 5
  41. #define LINUX_HTIC 5
  42.  
  43. static int graphics_on = FALSE;
  44.  
  45. int startx, starty;
  46. int linux_angle;
  47.  
  48. static int vgacolor[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  49.  
  50.  
  51. LINUX_text()
  52. {
  53.     int c;
  54.  
  55.     if (graphics_on) {
  56.         graphics_on = FALSE;
  57.         vga_getch();
  58.     }
  59.     vga_setmode(TEXT);
  60. }
  61.  
  62.  
  63. LINUX_reset()
  64. {
  65.     vga_setmode(TEXT);
  66. }
  67.  
  68.  
  69. LINUX_putc(x,y,c,ang,line_func)
  70. unsigned int x,y;
  71. char c;
  72. int ang;
  73. FUNC_PTR line_func;
  74. {
  75. int i, j, k;
  76. unsigned int pixelon;
  77.     i = (int)(c) - 32;
  78.     for (j=0; j<FNT5X9_VBITS; j++) {
  79.         for (k=0; k<FNT5X9_HBITS; k++) {
  80.             pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
  81.             if (pixelon) {
  82.                 switch(ang) {
  83.                     case 0 : (*line_func)(x+k+1,y-j,x+k+1,y-j);
  84.                             break;
  85.                     case 1 : (*line_func)(x-j,y-k-1,x-j,y-k-1);
  86.                             break;
  87.                 }
  88.             }
  89.         }
  90.     }
  91. }
  92.  
  93.  
  94. int LINUX_text_angle(ang)
  95. int ang;
  96. {
  97.     linux_angle=ang;
  98.     return TRUE;
  99. }
  100.  
  101.  
  102. LINUX_init()
  103. {
  104. }
  105.  
  106.  
  107. LINUX_graphics()
  108. {
  109.     graphics_on = TRUE;
  110.     vga_setmode(G640x480x16);
  111. }
  112.  
  113.  
  114. LINUX_linetype(linetype)
  115. {
  116.     if (linetype >= 13)
  117.         linetype %= 13;
  118.     vga_setcolor(vgacolor[linetype+2]); 
  119. }
  120.  
  121. LINUX_move(x,y)
  122. {
  123.     startx = x;
  124.     starty = y;
  125. }
  126.  
  127.  
  128. LINUX_vector(x,y)
  129. {
  130.     vga_drawline(startx,LINUX_YLAST-starty,x,LINUX_YLAST-y); 
  131.     startx = x;
  132.     starty = y;
  133. }
  134.  
  135.  
  136. LINUX_put_text(x,y,str)
  137. unsigned int x, y;
  138. char *str;
  139. {
  140. int i;
  141.     switch(linux_angle) {
  142.         case 0 : y -= LINUX_VCHAR/2;
  143.                 break;
  144.         case 1 : x += LINUX_VCHAR/2;
  145.                 break;
  146.     }
  147.     for (i=0;str[i];i++) {
  148.         LINUX_putc(x,LINUX_YLAST-y,str[i],linux_angle,vga_drawline); 
  149.         switch(linux_angle) {
  150.             case 0 : x+=LINUX_HCHAR ;
  151.                     break;
  152.             case 1 : y+=LINUX_HCHAR ;
  153.                     break;
  154.         }
  155.     }
  156. }
  157.  
  158.  
  159.