home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 500-599 / ff552.lzh / GNUPlot / gnuplot3.lzh / gnuplot / term / pc.trm < prev    next >
Text File  |  1991-08-04  |  25KB  |  1,423 lines

  1. /* GNUPLOT - pc.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.  *  Under Microsoft C
  21.  *      cga, egabios, egalib, vgabios, hercules, corona325, att
  22.  *  Under Turboc C
  23.  *      egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
  24.  *
  25.  * AUTHORS
  26.  *  Colin Kelley, Thomas Williams, William Wilson, Russell Lang
  27.  *
  28.  * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  29.  *
  30.  */
  31.  
  32. #ifdef __TURBOC__
  33. #include <graphics.h>
  34. #include <conio.h>
  35. #include <dos.h>
  36.   int g_driver, g_mode, g_error;
  37.   char far *path;
  38.   char *pathp, path_s[128];
  39.  
  40. /* instead of string.h */
  41. extern char *strrchr();
  42.  
  43. get_path()
  44. {
  45.    path=(char far *) getenv("BGI");
  46.    if (path==NULL) {
  47.       (void) strcpy(path_s,_argv[0]);
  48.       pathp=strrchr(path_s,'\\');
  49.       *pathp=0x00;
  50.       path=path_s;
  51.    }
  52. }
  53.  
  54. static struct text_info tinfo;       /* So we can restore starting text mode. */
  55. #endif
  56.  
  57.  
  58. static char near buf[80];    /* kludge since EGA.LIB is compiled SMALL */
  59.  
  60. static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
  61.  
  62. static int graphics_on = FALSE;
  63. int startx, starty;
  64.  
  65. int pc_angle;
  66. #define PC_VCHAR FNT5X9_VCHAR
  67. #define PC_HCHAR FNT5X9_HCHAR
  68.  
  69. pause()        /* press any key to continue... */
  70. {
  71.     (void) getch();
  72. }
  73.  
  74.  
  75. PC_text()
  76. {
  77.     if (graphics_on) {
  78.         graphics_on = FALSE;
  79.         pause();
  80.     }
  81. #ifdef __TURBOC__
  82.     restorecrtmode();
  83.         textmode(tinfo.currmode);
  84.     clrscr();
  85. #else
  86.     Vmode(3);
  87. #endif
  88. }
  89.  
  90. PC_reset()
  91. {
  92. #ifdef __TURBOC__
  93.     closegraph();
  94.         textmode(tinfo.currmode);
  95.     clrscr();
  96. #endif
  97. }
  98.  
  99.  
  100. #ifndef __TURBOC__
  101.  
  102. PC_putc(x,y,c,angle,line_func)
  103. unsigned int x,y;
  104. char c;
  105. int angle;
  106. FUNC_PTR line_func;
  107. {
  108. int i,j,k;
  109. unsigned int pixelon;
  110.     i = (int)(c) - 32;
  111.     for (j=0; j<FNT5X9_VBITS; j++) {
  112.         for (k=0; k<FNT5X9_HBITS; k++) {
  113.             pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
  114.             if (pixelon) {
  115.                 switch(angle) {
  116.                     case 0 : (*line_func)(x+k+1,y-j,x+k+1,y-j);
  117.                             break;
  118.                     case 1 : (*line_func)(x-j,y-k-1,x-j,y-k-1);
  119.                             break;
  120.                 }
  121.             }
  122.         }
  123.     }
  124. }
  125.  
  126.  
  127. int PC_text_angle(ang)
  128. int ang;
  129. {
  130.     pc_angle=ang;
  131.     return TRUE;
  132. }
  133.  
  134.  
  135. #define CGA_XMAX 640
  136. #define CGA_YMAX 200
  137.  
  138. #define CGA_XLAST (CGA_XMAX - 1)
  139. #define CGA_YLAST (CGA_YMAX - 1)
  140.  
  141. #define CGA_VCHAR PC_VCHAR
  142. #define CGA_HCHAR PC_HCHAR
  143. #define CGA_VTIC 4
  144. #define CGA_HTIC 6
  145.  
  146. int line_cga;
  147.  
  148. CGA_init()
  149. {
  150.     PC_color(1);        /* monochrome */
  151. }
  152.  
  153. CGA_graphics()
  154. {
  155.     graphics_on = TRUE;
  156.     Vmode(6);
  157. }
  158.  
  159. #define CGA_text PC_text
  160.  
  161. CGA_linetype(linetype)
  162. {
  163.     if (linetype >= 5)
  164.         linetype %= 5;
  165.     line_cga=linetype;
  166.     PC_mask(pattern[linetype+2]);
  167. }
  168.  
  169. CGA_move(x,y)
  170. {
  171.     startx = x;
  172.     starty = y;
  173. }
  174.  
  175.  
  176. CGA_vector(x,y)
  177. {
  178.     PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y);
  179.     startx = x;
  180.     starty = y;
  181. }
  182.  
  183.  
  184. CGA_put_text(x,y,str)
  185. unsigned int x, y;
  186. char *str;
  187. {
  188. int i;
  189. int line;
  190.     line= line_cga;     /* disable the dotted lines temporarily */
  191.     PC_mask(pattern[0]);
  192.     switch(pc_angle) {
  193.         case 0 : y -= CGA_VCHAR/2;
  194.                 break;
  195.         case 1 : x += CGA_VCHAR/2;
  196.                 break;
  197.     }
  198.     for (i=0;str[i];i++) {
  199.         PC_putc(x,CGA_YLAST-y,str[i],pc_angle,PC_line);
  200.         switch(pc_angle) {
  201.             case 0 : x+=CGA_HCHAR ;
  202.                     break;
  203.             case 1 : y+=CGA_HCHAR ;
  204.                     break;
  205.         }
  206.     }
  207.     PC_mask(pattern[line]);  /* enable dotted lines */
  208. }
  209.  
  210.  
  211. #define CGA_text_angle PC_text_angle
  212.  
  213. #define CGA_reset PC_reset
  214.  
  215.  
  216. #define EGA_XMAX 640
  217. #define EGA_YMAX 350
  218.  
  219. #define EGA_XLAST (EGA_XMAX - 1)
  220. #define EGA_YLAST (EGA_YMAX - 1)
  221.  
  222. #define EGA_VCHAR PC_VCHAR
  223. #define EGA_HCHAR PC_HCHAR
  224. #define EGA_VTIC 4
  225. #define EGA_HTIC 5
  226.  
  227. static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  228. static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  229.  
  230. static int *egacolor;
  231.  
  232.  
  233. EGA_init()
  234. {
  235.     PC_mask(0xffff);
  236.     egacolor = ega256color;        /* should be smarter */
  237. }
  238.  
  239. EGA_graphics()
  240. {
  241.     graphics_on = TRUE;
  242.     Vmode(16);
  243. }
  244.  
  245. #define EGA_text PC_text
  246.  
  247. EGA_linetype(linetype)
  248. {
  249.     if (linetype >= 13)
  250.         linetype %= 13;
  251.     PC_color(egacolor[linetype+2]);
  252. }
  253.  
  254. EGA_move(x,y)
  255. {
  256.     startx = x;
  257.     starty = y;
  258. }
  259.  
  260. EGA_vector(x,y)
  261. {
  262.     PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y);
  263.     startx = x;
  264.     starty = y;
  265. }
  266.  
  267.  
  268. EGA_put_text(x,y,str)
  269. unsigned int x, y;
  270. char *str;
  271. {
  272. int i;
  273.     switch(pc_angle) {
  274.         case 0 : y -= EGA_VCHAR/2;
  275.                 break;
  276.         case 1 : x += EGA_VCHAR/2;
  277.                 break;
  278.     }
  279.     for (i=0;str[i];i++) {
  280.         PC_putc(x,EGA_YLAST-y,str[i],pc_angle,PC_line);
  281.         switch(pc_angle) {
  282.             case 0 : x+=EGA_HCHAR ;
  283.                     break;
  284.             case 1 : y+=EGA_HCHAR ;
  285.                     break;
  286.         }
  287.     }
  288. }
  289.  
  290.  
  291. #define EGA_text_angle PC_text_angle
  292.  
  293. #define EGA_reset PC_reset
  294.  
  295.  
  296.  
  297. /* The following VGA routines are hacked from the above EGA routines
  298.    They worked on two VGA cards.
  299.    Russell Lang, eln272v@monu1.cc.monash.oz */
  300. #define VGA_XMAX 640
  301. #define VGA_YMAX 480
  302.  
  303. #define VGA_XLAST (VGA_XMAX - 1)
  304. #define VGA_YLAST (VGA_YMAX - 1)
  305.  
  306. #define VGA_VCHAR PC_VCHAR
  307. #define VGA_HCHAR PC_HCHAR
  308. #define VGA_VTIC 5
  309. #define VGA_HTIC 5
  310.  
  311. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  312.  
  313. static int *vgacolor;
  314.  
  315.  
  316. VGA_init()
  317. {
  318.     PC_mask(0xffff);
  319.     vgacolor = vga256color;        /* should be smarter */
  320. }
  321.  
  322. VGA_graphics()
  323. {
  324.     graphics_on = TRUE;
  325.     Vmode(18);
  326. }
  327.  
  328. #define VGA_text PC_text
  329.  
  330. VGA_linetype(linetype)
  331. {
  332.     if (linetype >= 13)
  333.         linetype %= 13;
  334.     PC_color(vgacolor[linetype+2]);
  335. }
  336.  
  337. VGA_move(x,y)
  338. {
  339.     startx = x;
  340.     starty = y;
  341. }
  342.  
  343. VGA_vector(x,y)
  344. {
  345.     PC_line(startx,VGA_YLAST-starty,x,VGA_YLAST-y);
  346.     startx = x;
  347.     starty = y;
  348. }
  349.  
  350.  
  351. VGA_put_text(x,y,str)
  352. unsigned int x, y;
  353. char *str;
  354. {
  355. int i;
  356.     switch(pc_angle) {
  357.         case 0 : y -= VGA_VCHAR/2;
  358.                 break;
  359.         case 1 : x += VGA_VCHAR/2;
  360.                 break;
  361.     }
  362.     for (i=0;str[i];i++) {
  363.         PC_putc(x,VGA_YLAST-y,str[i],pc_angle,PC_line);
  364.         switch(pc_angle) {
  365.             case 0 : x+=VGA_HCHAR ;
  366.                     break;
  367.             case 1 : y+=VGA_HCHAR ;
  368.                     break;
  369.         }
  370.     }
  371. }
  372.  
  373.  
  374. #define VGA_text_angle PC_text_angle
  375.  
  376. #define VGA_reset PC_reset
  377.  
  378.  
  379.  
  380. #ifdef EGALIB
  381.  
  382. #define EGALIB_XMAX 640
  383. #define EGALIB_YMAX 350
  384.  
  385. #define EGALIB_XLAST (EGA_XMAX - 1)
  386. #define EGALIB_YLAST (EGA_YMAX - 1)
  387.  
  388. #define EGALIB_VCHAR 14
  389. #define EGALIB_HCHAR 8
  390. #define EGALIB_VTIC 4
  391. #define EGALIB_HTIC 5
  392.  
  393. #include "mcega.h"
  394.  
  395. EGALIB_init()
  396. {
  397.     GPPARMS();
  398.     if (GDTYPE != 5) {
  399.         term = 0;
  400.         int_error("color EGA board not found",NO_CARET);
  401.     }
  402.     egacolor = (GDMEMORY < 256) ? ega64color : ega256color;
  403. }
  404.  
  405. EGALIB_graphics()
  406. {
  407.     graphics_on = TRUE;
  408.     GPINIT();
  409. }
  410.  
  411. EGALIB_text()
  412. {
  413.     if (graphics_on) {
  414.         graphics_on = FALSE;
  415.         pause();
  416.     }
  417.     GPTERM();
  418. }
  419.  
  420. EGALIB_linetype(linetype)
  421. {
  422.     if (linetype >= 13)
  423.         linetype %= 13;
  424.     GPCOLOR(egacolor[linetype+2]);
  425. }
  426.  
  427. EGALIB_move(x,y)
  428. {
  429.     GPMOVE(x,GDMAXROW-y);
  430. }
  431.  
  432.  
  433. EGALIB_vector(x,y)
  434. {
  435.     GPLINE(x,GDMAXROW-y);
  436. }
  437.  
  438.  
  439. EGALIB_put_text(x,y,str)
  440. int x, y;
  441. char *str;
  442. {
  443.     strcpy((char far *)buf,str);
  444.     GotoXY((int)(x/EGALIB_HCHAR),
  445.            (int)((EGALIB_YMAX-y-(EGALIB_VCHAR/2))/EGALIB_VCHAR));
  446.     gprintf(buf);
  447. }
  448.  
  449.  
  450. #define EGALIB_reset PC_reset
  451.  
  452. #endif /* EGALIB */
  453.  
  454.  
  455. #ifdef HERCULES
  456.  
  457. #define HERC_XMAX 720
  458. #define HERC_YMAX 348
  459.  
  460. #define HERC_XLAST (HERC_XMAX - 1)
  461. #define HERC_YLAST (HERC_YMAX - 1)
  462.  
  463. #define HERC_VCHAR PC_VCHAR
  464. #define HERC_HCHAR PC_HCHAR
  465. #define HERC_VTIC 4
  466. #define HERC_HTIC 5
  467.  
  468. int line_herc;
  469.  
  470. HERC_init()
  471. {
  472.     H_init();
  473. }
  474.  
  475. HERC_graphics()
  476. {
  477.     HVmode(1);
  478.     graphics_on = TRUE;
  479. }
  480.  
  481. HERC_text()
  482. {
  483.     if (graphics_on) {
  484.         graphics_on = FALSE;
  485.         pause();
  486.     }
  487.     HVmode(0);
  488. }
  489.  
  490. HERC_linetype(linetype)
  491. {
  492.     if (linetype >= 5)
  493.         linetype %= 5;
  494.     H_mask(pattern[linetype+2]);
  495.     line_herc = linetype;
  496. }
  497.  
  498. HERC_move(x,y)
  499. {
  500.     if (x < 0)
  501.         startx = 0;
  502.     else if (x > HERC_XLAST)
  503.         startx = HERC_XLAST;
  504.     else
  505.         startx = x;
  506.  
  507.     if (y < 0)
  508.         starty = 0;
  509.     else if (y > HERC_YLAST)
  510.         starty = HERC_YLAST;
  511.     else
  512.         starty = y;
  513. }
  514.  
  515. HERC_vector(x,y)
  516. {
  517.     if (x < 0)
  518.         x = 0;
  519.     else if (x > HERC_XLAST)
  520.         x = HERC_XLAST;
  521.     if (y < 0)
  522.         y = 0;
  523.     else if (y > HERC_YLAST)
  524.         y = HERC_YLAST;
  525.  
  526.     H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y);
  527.     startx = x;
  528.     starty = y;
  529. }
  530.  
  531.  
  532. HERC_put_text(x,y,str)
  533. unsigned int x, y;
  534. char *str;
  535. {
  536. int i;
  537. int line;
  538.     line= line_herc;     /* disable the dotted lines temporarily */
  539.     H_mask(pattern[0]);
  540.     switch(pc_angle) {
  541.         case 0 : y -= HERC_VCHAR/2;
  542.                 break;
  543.         case 1 : x += HERC_VCHAR/2;
  544.                 break;
  545.     }
  546.     for (i=0;str[i];i++) {
  547.         PC_putc(x,HERC_YLAST-y,str[i],pc_angle,H_line);
  548.         switch(pc_angle) {
  549.             case 0 : x+=HERC_HCHAR ;
  550.                     break;
  551.             case 1 : y+=HERC_HCHAR ;
  552.                     break;
  553.         }
  554.     }
  555.     H_mask(pattern[line]);  /* enable dotted lines */
  556. }
  557.  
  558.  
  559. #define HERC_text_angle PC_text_angle
  560.  
  561. #define HERC_reset PC_reset
  562.  
  563.  
  564. #endif /* HERCULES */
  565.  
  566.  
  567. /* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
  568.    ATT 6300 driver */ 
  569.  
  570.  
  571. #ifdef ATT6300
  572.  
  573. #define ATT_XMAX 640
  574. #define ATT_YMAX 400
  575.  
  576. #define ATT_XLAST (ATT_XMAX - 1)
  577. #define ATT_YLAST (ATT_YMAX - 1)
  578.  
  579. #define ATT_VCHAR PC_VCHAR
  580. #define ATT_HCHAR PC_HCHAR
  581. #define ATT_VTIC 4
  582. #define ATT_HTIC 5
  583.  
  584. #define ATT_init CGA_init
  585.  
  586. ATT_graphics()
  587. {
  588.     graphics_on = TRUE;
  589.     Vmode(0x40);        /* 40H is the magic number for the AT&T driver */
  590. }
  591.  
  592. #define ATT_text CGA_text
  593.  
  594. #define ATT_linetype CGA_linetype
  595.  
  596. #define ATT_move CGA_move
  597.  
  598. ATT_vector(x,y)
  599. {
  600.     PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y);
  601.     startx = x;
  602.     starty = y;
  603. }
  604.  
  605.  
  606. ATT_put_text(x,y,str)
  607. unsigned int x, y;
  608. char *str;
  609. {
  610. int i;
  611. int line;
  612.     line= line_cga;     /* disable the dotted lines temporarily */
  613.     PC_mask(pattern[0]);
  614.     switch(pc_angle) {
  615.         case 0 : y -= ATT_VCHAR/2;
  616.                 break;
  617.         case 1 : x += ATT_VCHAR/2;
  618.                 break;
  619.     }
  620.     for (i=0;str[i];i++) {
  621.         PC_putc(x,ATT_YLAST-y,str[i],pc_angle,PC_line);
  622.         switch(pc_angle) {
  623.             case 0 : x+=ATT_HCHAR ;
  624.                     break;
  625.             case 1 : y+=ATT_HCHAR ;
  626.                     break;
  627.         }
  628.     }
  629.     PC_mask(pattern[line]);  /* enable dotted lines */
  630. }
  631.  
  632.  
  633. #define ATT_text_angle PC_text_angle
  634.  
  635. #define ATT_reset CGA_reset
  636.  
  637. #endif  /* ATT6300 */
  638.  
  639.  
  640. #ifdef CORONA
  641.  
  642. #define COR_XMAX 640
  643. #define COR_YMAX 325
  644.  
  645. #define COR_XLAST (COR_XMAX - 1)
  646. #define COR_YLAST (COR_YMAX - 1)
  647.  
  648. #define COR_VCHAR PC_VCHAR
  649. #define COR_HCHAR PC_HCHAR
  650. #define COR_VTIC 4
  651. #define COR_HTIC 5
  652.  
  653. int line_cor;
  654.  
  655. static int corscreen;        /* screen number, 0 - 7 */
  656.  
  657. COR_init()
  658. {
  659. register char *p;
  660.     if (!(p = getenv("CORSCREEN")))
  661.         int_error("must run CORPLOT for Corona graphics",NO_CARET);
  662.     corscreen = *p - '0';
  663. }
  664.  
  665. COR_graphics()
  666. {
  667.     graphics_on = TRUE;
  668.     Vmode(3);                /* clear text screen */
  669.     grinit(corscreen);
  670.     grandtx();
  671. }
  672.  
  673. COR_text()
  674. {
  675.     if (graphics_on) {
  676.         graphics_on = FALSE;
  677.         pause();
  678.     }
  679.     grreset();
  680.     txonly();
  681.     Vmode(3);
  682. }
  683.  
  684. COR_linetype(linetype)
  685. {
  686.     if (linetype >= 5)
  687.         linetype %= 5;
  688.     line_cor = linetype;
  689.     Cor_mask(pattern[linetype+2]);
  690. }
  691.  
  692. COR_move(x,y)
  693. {
  694.     if (x < 0)
  695.         startx = 0;
  696.     else if (x > COR_XLAST)
  697.         startx = COR_XLAST;
  698.     else
  699.         startx = x;
  700.  
  701.     if (y < 0)
  702.         starty = 0;
  703.     else if (y > COR_YLAST)
  704.         starty = COR_YLAST;
  705.     else
  706.         starty = y;
  707. }
  708.  
  709. COR_vector(x,y)
  710. {
  711.     if (x < 0)
  712.         x = 0;
  713.     else if (x > COR_XLAST)
  714.         x = COR_XLAST;
  715.     if (y < 0)
  716.         y = 0;
  717.     else if (y > COR_YLAST)
  718.         y = COR_YLAST;
  719.  
  720.     Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
  721.     startx = x;
  722.     starty = y;
  723. }
  724.  
  725.  
  726. COR_put_text(x,y,str)
  727. unsigned int x, y;
  728. char *str;
  729. {
  730. int i;
  731. int line;
  732.     line= line_cor;     /* disable the dotted lines temporarily */
  733.     Cor_mask(pattern[0]);
  734.     switch(pc_angle) {
  735.         case 0 : y -= COR_VCHAR/2;
  736.                 break;
  737.         case 1 : x += COR_VCHAR/2;
  738.                 break;
  739.     }
  740.     for (i=0;str[i];i++) {
  741.         PC_putc(x,COR_YLAST-y,str[i],pc_angle,Cor_line);
  742.         switch(pc_angle) {
  743.             case 0 : x+=COR_HCHAR ;
  744.                     break;
  745.             case 1 : y+=COR_HCHAR ;
  746.                     break;
  747.         }
  748.     }
  749.     COR_mask(pattern[line]);  /* enable dotted lines */
  750. }
  751.  
  752.  
  753. #define COR_text_angle PC_text_angle
  754.  
  755. #define COR_reset PC_reset
  756.  
  757. #endif /* CORONA */
  758.  
  759.  
  760. #else /* ifndef __TURBOC__ */
  761. /* all of the Turbo C routines for the different graphics devices go here */
  762.  
  763. #define VGA_XMAX 640
  764. #define VGA_YMAX 480
  765.  
  766. #define VGA_XLAST (VGA_XMAX - 1)
  767. #define VGA_YLAST (VGA_YMAX - 1)
  768.  
  769. #define VGA_VCHAR 10
  770. #define VGA_HCHAR 8
  771. #define VGA_VTIC 4
  772. #define VGA_HTIC 5
  773.  
  774. #define SVGA_XMAX 640
  775. #define SVGA_YMAX 480
  776.  
  777. #define SVGA_VCHAR 10
  778. #define SVGA_HCHAR 8
  779. #define SVGA_VTIC 4
  780. #define SVGA_HTIC 5
  781.  
  782. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  783. static int *vgacolor;
  784.  
  785. static int svga_xmax = SVGA_XMAX,
  786.        svga_ymax = SVGA_YMAX,
  787.        svga_xlast = 639,
  788.        svga_ylast = 479;
  789.  
  790. #define VGA_reset EGALIB_reset
  791. #define VGA_text EGALIB_text
  792. #define VGA_move EGALIB_move
  793. #define VGA_vector EGALIB_vector
  794. #define VGA_text_angle PC_text_angle
  795. #define VGA_justify_text PC_justify_text
  796.  
  797. #define SVGA_reset EGALIB_reset
  798. #define SVGA_text EGALIB_text
  799. #define SVGA_move EGALIB_move
  800. #define SVGA_vector EGALIB_vector
  801. #define SVGA_text_angle PC_text_angle
  802. #define SVGA_justify_text PC_justify_text
  803. #define SVGA_linetype VGA_linetype
  804.  
  805. int PC_text_angle(ang)
  806. int ang;
  807. {
  808.     int size = svga_ymax > 600 ? 2 : 1;
  809.  
  810.     pc_angle = ang;
  811.  
  812.     switch (ang) {
  813.         case 0 : settextstyle(DEFAULT_FONT,HORIZ_DIR,size);
  814.             break;
  815.         case 1 : settextstyle(DEFAULT_FONT,VERT_DIR,size);
  816.             break;
  817.     }
  818.     return TRUE;
  819. }
  820.  
  821. int PC_justify_text(mode)
  822. enum JUSTIFY mode;
  823. {
  824.     switch(mode) {
  825.         case LEFT :
  826.             settextjustify(LEFT_TEXT,CENTER_TEXT);
  827.             break;
  828.         case CENTRE :
  829.             settextjustify(CENTER_TEXT,CENTER_TEXT);
  830.             break;
  831.         case RIGHT:
  832.             settextjustify(RIGHT_TEXT,CENTER_TEXT);
  833.             break;
  834.     }
  835.     return TRUE;
  836. }
  837.  
  838. VGA_init()
  839. {
  840.     g_driver=VGA;
  841.     g_mode=2;
  842.     gettextinfo(&tinfo);
  843.         initgraph(&g_driver,&g_mode,path);
  844.         if(g_driver!=9){
  845.           term=0;
  846.           switch (g_driver){
  847.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  848.                      break;
  849.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  850.                      break;
  851.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  852.                      break;
  853.             case -5: fprintf(stderr,"Insufficient memory to load ",
  854.                              "graphics driver.");
  855.                      break;
  856.             }
  857.  
  858. /*          int_error("color VGA board not found",NO_CARET);*/
  859.         }
  860.         if(g_driver==VGA) vgacolor=vga256color;
  861. }
  862.  
  863. VGA_graphics()
  864. {       g_driver=VGA;
  865.     g_mode=2;
  866.     graphics_on = TRUE;
  867.     gettextinfo(&tinfo);
  868.     setgraphmode(getgraphmode());
  869.     VGA_justify_text(LEFT);
  870. }
  871.  
  872. VGA_linetype(linetype)
  873. {
  874.     if (linetype >= 13)
  875.         linetype %= 13;
  876.     setcolor(vgacolor[linetype+2]);
  877. }
  878.  
  879. VGA_put_text(x,y,str)
  880. unsigned int x, y;
  881. char *str;
  882. {
  883.     strcpy((char far *)buf,str);
  884.     outtextxy(x,VGA_YLAST-y,buf);
  885. }
  886.  
  887.  
  888. VGAMONO_linetype(linetype)
  889. {
  890.     if (linetype >= 5)
  891.         linetype %= 5;
  892.     setlinestyle(4,pattern[linetype+2],1);
  893. }
  894.  
  895. static int huge detect_svga(void)
  896. {
  897.     return g_mode;
  898. }
  899.  
  900. SVGA_init()
  901. {
  902.     char *p, name[128], *SVGA = getenv( "SVGA" );
  903.  
  904.     if (SVGA == NULL)
  905.         int_error("'SVGA' driver environment variable is not set",
  906.               NO_CARET);
  907.  
  908.     strcpy(name, SVGA);
  909.     if ((p = strrchr(name, '.')) == NULL ||
  910.         sscanf(&p[1], "%d", &g_mode) != 1)
  911.         int_error("'SVGA' envvar should be of the form 'name.mode'",
  912.               NO_CARET);
  913.  
  914.     *p = 0;
  915.  
  916.     installuserdriver(name, detect_svga);
  917.     gettextinfo(&tinfo);
  918.     g_driver = 0;
  919.         initgraph(&g_driver,&g_mode,path);
  920.         if(g_driver<0){
  921.           term=0;
  922.           switch (g_driver){
  923.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  924.                      break;
  925.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  926.                      break;
  927.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  928.                      break;
  929.             case -5: fprintf(stderr,"Insufficient memory to load ",
  930.                              "graphics driver.");
  931.                      break;
  932.             }
  933.  
  934.         }
  935.     else
  936.         vgacolor=vga256color;
  937.  
  938.     /* Get the screen size: */
  939.     svga_xmax = term_tbl[term].xmax = getmaxx() + 1;
  940.         svga_ymax = term_tbl[term].ymax = getmaxy() + 1;
  941.     svga_xlast = svga_xmax-1;
  942.     svga_ylast = svga_ymax-1;
  943.  
  944.     if (svga_ymax > 600) {               /* Double the tic/font sizes. */
  945.         term_tbl[term].h_char = SVGA_HCHAR * 2;
  946.         term_tbl[term].v_char = SVGA_VCHAR * 2;
  947.         term_tbl[term].h_tic = SVGA_HTIC * 2;
  948.         term_tbl[term].v_tic = SVGA_VTIC * 2;
  949.         settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
  950.      }
  951.     else
  952.         settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  953. }
  954.  
  955. SVGA_graphics()
  956. {
  957.     graphics_on = TRUE;
  958.     gettextinfo(&tinfo);
  959.     setgraphmode(getgraphmode());
  960.     VGA_justify_text(LEFT);
  961.  
  962.         svga_ymax = getmaxy() + 1;
  963.     if (svga_ymax > 600)               /* Double the tic/font sizes. */
  964.         settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
  965.     else
  966.         settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  967. }
  968.  
  969. SVGA_put_text(x,y,str)
  970. unsigned int x, y;
  971. char *str;
  972. {
  973.     strcpy((char far *)buf,str);
  974.     outtextxy(x,svga_ylast-y,buf);
  975. }
  976.  
  977. #define MCGA_XMAX 640
  978. #define MCGA_YMAX 480
  979.  
  980. #define MCGA_XLAST (MCGA_XMAX - 1)
  981. #define MCGA_YLAST (MCGA_YMAX - 1)
  982.  
  983. #define MCGA_VCHAR 10
  984. #define MCGA_HCHAR 8
  985. #define MCGA_VTIC 4
  986. #define MCGA_HTIC 5
  987.  
  988. static int *MCGAcolor;
  989.  
  990. #define MCGA_reset EGALIB_reset
  991. #define MCGA_text EGALIB_text
  992. #define MCGA_move EGALIB_move
  993. #define MCGA_vector EGALIB_vector
  994. #define MCGA_text_angle PC_text_angle
  995. #define MCGA_justify_text PC_justify_text
  996.  
  997. MCGA_init()
  998. {
  999.     g_driver=MCGA;
  1000.     g_mode=5;
  1001.     gettextinfo(&tinfo);
  1002.         initgraph(&g_driver,&g_mode,path);
  1003.         if(g_driver!=2){
  1004.           term=0;
  1005.           switch (g_driver){
  1006.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1007.                      break;
  1008.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1009.                      break;
  1010.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1011.                      break;
  1012.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1013.                              "graphics driver.");
  1014.                      break;
  1015.             }
  1016.         }
  1017. }
  1018.  
  1019. MCGA_graphics()
  1020. {
  1021.     graphics_on = TRUE;
  1022.     gettextinfo(&tinfo);
  1023.     setgraphmode(getgraphmode());
  1024.     MCGA_justify_text(LEFT);
  1025. }
  1026.  
  1027.  
  1028. MCGA_put_text(x,y,str)
  1029. unsigned int x, y;
  1030. char *str;
  1031. {
  1032.     strcpy((char far *)buf,str);
  1033.     outtextxy(x,MCGA_YLAST-y,buf);
  1034. }
  1035.  
  1036.  
  1037. MCGA_linetype(linetype)
  1038. {
  1039.     if (linetype >= 5)
  1040.         linetype %= 5;
  1041.     setlinestyle(4,pattern[linetype+2],1);
  1042. }
  1043.  
  1044.  
  1045. #define EGALIB_XMAX 640
  1046. #define EGALIB_YMAX 350
  1047.  
  1048. #define EGALIB_XLAST (EGALIB_XMAX - 1)
  1049. #define EGALIB_YLAST (EGALIB_YMAX - 1)
  1050.  
  1051. #define EGALIB_VCHAR 10
  1052. #define EGALIB_HCHAR 8
  1053. #define EGALIB_VTIC 4
  1054. #define EGALIB_HTIC 5
  1055.  
  1056. static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  1057. static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  1058.  
  1059. static int *egacolor;
  1060.  
  1061. #define EGALIB_text_angle PC_text_angle
  1062. #define EGALIB_justify_text PC_justify_text
  1063.  
  1064. EGALIB_init()
  1065. {
  1066.     g_driver=EGA;
  1067.     g_mode=1;
  1068.     gettextinfo(&tinfo);
  1069.         initgraph(&g_driver,&g_mode,path);
  1070.         if(g_driver<3 || g_driver>4){
  1071.           term=0;
  1072.           switch (g_driver){
  1073.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1074.                      break;
  1075.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1076.                      break;
  1077.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1078.                      break;
  1079.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1080.                              "graphics driver.");
  1081.                      break;
  1082.             }
  1083.  
  1084. /*          int_error("color EGA board not found",NO_CARET);*/
  1085.         }
  1086.         if(g_driver==EGA) egacolor=ega256color;
  1087.         if(g_driver==EGA64) egacolor=ega64color;
  1088. }
  1089.  
  1090. EGALIB_graphics()
  1091. {
  1092.     graphics_on = TRUE;
  1093.     gettextinfo(&tinfo);
  1094.     setgraphmode(getgraphmode());
  1095.     EGALIB_justify_text(LEFT);
  1096. }
  1097.  
  1098. EGALIB_text()
  1099. {
  1100.     if (graphics_on) {
  1101.         graphics_on = FALSE;
  1102.         pause();
  1103.     }
  1104.     restorecrtmode();
  1105.         textmode(tinfo.currmode);
  1106.     clrscr();
  1107.     svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
  1108. }
  1109.  
  1110. EGALIB_linetype(linetype)
  1111. {
  1112.     if (linetype >= 13)
  1113.         linetype %= 13;
  1114.     setcolor(egacolor[linetype+2]);
  1115. }
  1116.  
  1117. EGALIB_move(x,y)
  1118. {
  1119.         moveto(x,getmaxy()-y);
  1120. }
  1121.  
  1122.  
  1123. EGALIB_vector(x,y)
  1124. {
  1125.     lineto(x,getmaxy()-y);
  1126. }
  1127.  
  1128.  
  1129. EGALIB_put_text(x,y,str)
  1130. unsigned int x, y;
  1131. char *str;
  1132. {
  1133.     strcpy((char far *)buf,str);
  1134.     outtextxy(x,EGALIB_YLAST-y,buf);
  1135. }
  1136.  
  1137.  
  1138. EGALIB_reset()
  1139. {
  1140.       closegraph();
  1141.         textmode(tinfo.currmode);
  1142.     clrscr();
  1143.     svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
  1144. }
  1145.  
  1146.  
  1147. #define CGA_XMAX 640
  1148. #define CGA_YMAX 200
  1149.  
  1150. #define CGA_XLAST (CGA_XMAX - 1)
  1151. #define CGA_YLAST (CGA_YMAX - 1)
  1152.  
  1153. #define CGA_VCHAR 10
  1154. #define CGA_HCHAR 8
  1155. #define CGA_VTIC 4
  1156. #define CGA_HTIC 6
  1157.  
  1158. #define CGA_text_angle PC_text_angle
  1159. #define CGA_justify_text PC_justify_text
  1160. #define CGA_reset PC_reset
  1161.  
  1162. CGA_init()
  1163. {
  1164.     g_driver=CGA;
  1165.     g_mode=4;
  1166.     gettextinfo(&tinfo);
  1167.     initgraph(&g_driver,&g_mode,path);
  1168.           switch (g_driver){
  1169.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1170.                      break;
  1171.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1172.                      break;
  1173.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1174.                      break;
  1175.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1176.                              "graphics driver.");
  1177.                      break;
  1178.             }
  1179. /*    PC_color(1);         monochrome */
  1180.  
  1181. }
  1182.  
  1183. CGA_graphics()
  1184. {
  1185.     graphics_on = TRUE;
  1186.     gettextinfo(&tinfo);
  1187.     setgraphmode(getgraphmode());
  1188.     CGA_justify_text(LEFT);
  1189.     /*    Vmode(6);*/
  1190. }
  1191.  
  1192. #define CGA_text PC_text
  1193.  
  1194. CGA_linetype(linetype)
  1195. {
  1196.     if (linetype >= 5)
  1197.         linetype %= 5;
  1198.     setlinestyle(4,pattern[linetype+2],1);
  1199. }
  1200.  
  1201. CGA_move(x,y)
  1202. {
  1203.     moveto(x,getmaxy()-y);
  1204. }
  1205.  
  1206.  
  1207. CGA_vector(x,y)
  1208. {
  1209.     lineto(x,getmaxy()-y);
  1210. }
  1211.  
  1212. CGA_put_text(x,y,str)
  1213. unsigned int x, y;
  1214. char *str;
  1215. {
  1216.     strcpy((char far *)buf,str);
  1217.     outtextxy(x,CGA_YLAST-y,buf);
  1218. }
  1219.  
  1220.  
  1221.  
  1222. #define HERC_XMAX 720
  1223. #define HERC_YMAX 348
  1224.  
  1225. #define HERC_XLAST (HERC_XMAX - 1)
  1226. #define HERC_YLAST (HERC_YMAX - 1)
  1227.  
  1228. #define HERC_VCHAR 10
  1229. #define HERC_HCHAR 8
  1230. #define HERC_VTIC 4
  1231. #define HERC_HTIC 5
  1232.  
  1233. #define HERC_text_angle PC_text_angle
  1234. #define HERC_justify_text PC_justify_text
  1235. #define HERC_reset PC_reset
  1236.  
  1237. HERC_init()
  1238. {
  1239.     g_driver=HERCMONO;
  1240.     g_mode=0;
  1241.     gettextinfo(&tinfo);
  1242.       initgraph(&g_driver,&g_mode,path);
  1243.           switch (g_driver){
  1244.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1245.                      break;
  1246.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1247.                      break;
  1248.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1249.                      break;
  1250.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1251.                              "graphics driver.");
  1252.                      break;
  1253.             }
  1254. }
  1255.  
  1256. HERC_graphics()
  1257. {
  1258.     gettextinfo(&tinfo);
  1259.     setgraphmode(getgraphmode());
  1260.     HERC_justify_text(LEFT);
  1261.     graphics_on = TRUE;
  1262. }
  1263.  
  1264. HERC_text()
  1265. {
  1266.     if (graphics_on) {
  1267.         graphics_on = FALSE;
  1268.         pause();
  1269.     }
  1270.     restorecrtmode();
  1271.         textmode(tinfo.currmode);
  1272.     clrscr();
  1273. }
  1274.  
  1275. HERC_linetype(linetype)
  1276. {
  1277.     if (linetype >= 5)
  1278.         linetype %= 5;
  1279.     setlinestyle(4,pattern[linetype+2],1);
  1280. }
  1281.  
  1282. HERC_move(x,y)
  1283. {
  1284.     if (x < 0)
  1285.         x = 0;
  1286.     else if (x > HERC_XLAST)
  1287.         x = HERC_XLAST;
  1288.  
  1289.     if (y < 0)
  1290.         y = 0;
  1291.     else if (y > HERC_YLAST)
  1292.         y = HERC_YLAST;
  1293.     moveto(x,getmaxy()-y);
  1294. }
  1295.  
  1296. HERC_vector(x,y)
  1297. {
  1298.     if (x < 0)
  1299.         x = 0;
  1300.     else if (x > HERC_XLAST)
  1301.         x = HERC_XLAST;
  1302.     if (y < 0)
  1303.         y = 0;
  1304.     else if (y > HERC_YLAST)
  1305.         y = HERC_YLAST;
  1306.  
  1307.     lineto(x,getmaxy()-y);
  1308. }
  1309.  
  1310.  
  1311. HERC_put_text(x,y,str)
  1312. unsigned int x, y;
  1313. char *str;
  1314. {
  1315.     strcpy((char far *)buf,str);
  1316.     outtextxy(x,HERC_YLAST-y,buf);
  1317. }
  1318.  
  1319.  
  1320. #ifdef ATT6300
  1321. /* this driver added by rjl@monu1.cc.monash.edu.au */
  1322.  
  1323. #define ATT_XMAX 640
  1324. #define ATT_YMAX 400
  1325.  
  1326. #define ATT_XLAST (ATT_XMAX - 1)
  1327. #define ATT_YLAST (ATT_YMAX - 1)
  1328.  
  1329. #define ATT_VCHAR PC_VCHAR
  1330. #define ATT_HCHAR PC_HCHAR
  1331. #define ATT_VTIC 4
  1332. #define ATT_HTIC 5
  1333.  
  1334. #define ATT_text_angle PC_text_angle
  1335. #define ATT_justify_text PC_justify_text
  1336. #define ATT_reset PC_reset
  1337.  
  1338. ATT_init()
  1339. {
  1340.     g_driver=ATT400;
  1341.     g_mode=5;
  1342.     gettextinfo(&tinfo);
  1343.       initgraph(&g_driver,&g_mode,path);
  1344.           switch (g_driver){
  1345.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1346.                      break;
  1347.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1348.                      break;
  1349.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1350.                      break;
  1351.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1352.                              "graphics driver.");
  1353.                      break;
  1354.             }
  1355. }
  1356.  
  1357. ATT_graphics()
  1358. {
  1359.     gettextinfo(&tinfo);
  1360.     setgraphmode(getgraphmode());
  1361.     ATT_justify_text(LEFT);
  1362.     graphics_on = TRUE;
  1363. }
  1364.  
  1365. ATT_text()
  1366. {
  1367.     if (graphics_on) {
  1368.         graphics_on = FALSE;
  1369.         pause();
  1370.     }
  1371.     restorecrtmode();
  1372.         textmode(tinfo.currmode);
  1373.     clrscr();
  1374. }
  1375.  
  1376. ATT_linetype(linetype)
  1377. {
  1378.     if (linetype >= 5)
  1379.         linetype %= 5;
  1380.     setlinestyle(4,pattern[linetype+2],1);
  1381. }
  1382.  
  1383. ATT_move(x,y)
  1384. {
  1385.     if (x < 0)
  1386.         x = 0;
  1387.     else if (x > ATT_XLAST)
  1388.         x = ATT_XLAST;
  1389.  
  1390.     if (y < 0)
  1391.         y = 0;
  1392.     else if (y > ATT_YLAST)
  1393.         y = ATT_YLAST;
  1394.     moveto(x,getmaxy()-y);
  1395. }
  1396.  
  1397. ATT_vector(x,y)
  1398. {
  1399.     if (x < 0)
  1400.         x = 0;
  1401.     else if (x > ATT_XLAST)
  1402.         x = ATT_XLAST;
  1403.     if (y < 0)
  1404.         y = 0;
  1405.     else if (y > ATT_YLAST)
  1406.         y = ATT_YLAST;
  1407.  
  1408.     lineto(x,getmaxy()-y);
  1409. }
  1410.  
  1411.  
  1412. ATT_put_text(x,y,str)
  1413. unsigned int x, y;
  1414. char *str;
  1415. {
  1416.     strcpy((char far *)buf,str);
  1417.     outtextxy(x,ATT_YLAST-y,buf);
  1418. }
  1419. #endif /* ifdef ATT6300 */
  1420.  
  1421. #endif /* ifndef __TURBOC__ */
  1422.  
  1423.