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