home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume11 / gnuplot2 / part10 < prev    next >
Encoding:
Text File  |  1990-03-25  |  61.7 KB  |  2,900 lines

  1. Newsgroups: comp.sources.misc
  2. organization: Pixar -- Marin County, California
  3. subject: v11i075: Gnuplot 2.0 - 10 of 14
  4. From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 11, Issue 75
  8. Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  9. Archive-name: gnuplot2/part10
  10.  
  11. This is gnuplot.sh10
  12.  
  13. --- CUT HERE ---
  14. #! /bin/sh
  15. echo x - term/post.trm
  16. sed 's/^X//' >term/post.trm <<'*-*-END-of-term/post.trm-*-*'
  17. X/* GNUPLOT - post.trm */
  18. X/*
  19. X * Copyright (C) 1990   
  20. X *
  21. X * Permission to use, copy, and distribute this software and its
  22. X * documentation for any purpose with or without fee is hereby granted, 
  23. X * provided that the above copyright notice appear in all copies and 
  24. X * that both that copyright notice and this permission notice appear 
  25. X * in supporting documentation.
  26. X *
  27. X * Permission to modify the software is granted, but not the right to
  28. X * distribute the modified code.  Modifications are to be distributed 
  29. X * as patches to released version.
  30. X *  
  31. X * This software  is provided "as is" without express or implied warranty.
  32. X * 
  33. X * This file is included by ../term.c.
  34. X *
  35. X * This terminal driver supports:
  36. X *     postscript, psbig, epsf1, epsf2
  37. X *
  38. X * AUTHORS
  39. X *  Russell Lang
  40. X * 
  41. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  42. X * 
  43. X */
  44. X
  45. X
  46. X/* PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */
  47. X
  48. Xint pspage=0;            /* page count */
  49. Xint ps_path_count=0;     /* count of lines in path */
  50. Xint ps_ang=0;            /* text angle */
  51. Xenum JUSTIFY ps_justify=LEFT;    /* text is flush left */
  52. Xchar *ps_font;            /* name of font in use */
  53. XBOOLEAN ps_big;            /* true if big font used */
  54. X
  55. Xchar *PS_header[] = {
  56. X"/vpt2 vpt 2 mul def\n",
  57. X"/hpt2 hpt 2 mul def\n",
  58. X/* flush left show */
  59. X"/Lshow { 0 vshift rmoveto show } def\n", 
  60. X/* flush right show */
  61. X"/Rshow { dup stringwidth pop neg vshift rmoveto show } def\n", 
  62. X/* centred show */
  63. X"/Cshow { dup stringwidth pop -2 div vshift rmoveto show } def\n", 
  64. X/* Border Lines */
  65. X"/BL { stroke gnulinewidth 2 mul setlinewidth} def\n",
  66. X/* Axes Lines */
  67. X"/AL { stroke gnulinewidth 2 div setlinewidth } def\n",
  68. X/* Plot Lines */
  69. X"/PL { stroke gnulinewidth setlinewidth } def\n",
  70. X/* Line Types */
  71. X"/LTb { BL [] 0 setdash } def\n", /* border */
  72. X"/LTa { AL [1 dl 2 dl] 0 setdash } def\n", /* axes */
  73. X"/LT0 { PL [] 0 setdash } def\n",
  74. X"/LT1 { PL [4 dl 2 dl] 0 setdash } def\n",
  75. X"/LT2 { PL [2 dl 3 dl] 0 setdash } def\n",
  76. X"/LT3 { PL [1 dl 1.5 dl] 0 setdash } def\n",
  77. X"/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 setdash } def\n",
  78. X"/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 0 setdash } def\n",
  79. X"/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 setdash } def\n",
  80. X"/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0 setdash } def\n",
  81. X"/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0 setdash } def\n",
  82. X"/M {moveto} def\n",
  83. X"/L {lineto} def\n",
  84. X"/P {  LT0\n", /* Point */
  85. X"  currentlinewidth 2 div sub moveto\n",
  86. X"  0 currentlinewidth rlineto  stroke } def\n",
  87. X"/D {  LT0  2 copy  vpt add moveto\n", /* Diamond */
  88. X"  hpt neg vpt neg rlineto  hpt vpt neg rlineto\n",
  89. X"  hpt vpt rlineto  hpt neg vpt rlineto  closepath  stroke\n",
  90. X"  P  } def\n",
  91. X"/A {  LT0  vpt sub moveto  0 vpt2 rlineto\n", /* Plus (Add) */
  92. X"  currentpoint stroke moveto\n",
  93. X"  hpt neg vpt neg rmoveto  hpt2 0 rlineto stroke\n",
  94. X"  } def\n",
  95. X"/B {  LT0  2 copy  exch hpt sub exch vpt add moveto\n", /* Box */
  96. X"  0 vpt2 neg rlineto  hpt2 0 rlineto  0 vpt2 rlineto\n",
  97. X"  hpt2 neg 0 rlineto  closepath  stroke\n",
  98. X"  P  } def\n",
  99. X"/C {  LT0  exch hpt sub exch vpt add moveto\n", /* Cross */
  100. X"  hpt2 vpt2 neg rlineto  currentpoint  stroke  moveto\n",
  101. X"  hpt2 neg 0 rmoveto  hpt2 vpt2 rlineto stroke  } def\n",
  102. X"/T {  LT0  2 copy  vpt 1.12 mul add moveto\n", /* Triangle */
  103. X"  hpt neg vpt -1.62 mul rlineto\n",
  104. X"  hpt 2 mul 0 rlineto\n",
  105. X"  hpt neg vpt 1.62 mul rlineto  closepath  stroke\n",
  106. X"  P  } def\n",
  107. X"/S {  LT0  2 copy A C} def\n", /* Star */
  108. XNULL
  109. X};
  110. X
  111. X#define PS_XMAX 3600
  112. X#define PS_YMAX 2520
  113. X
  114. X#define PS_XLAST (PS_XMAX - 1)
  115. X#define PS_YLAST (PS_YMAX - 1)
  116. X
  117. X#define PS_VTIC (PS_YMAX/80)
  118. X#define PS_HTIC (PS_YMAX/80)
  119. X
  120. X
  121. X#define PS_SC (360.0/PS_XMAX)        /* scale is 1pt = 10 units */
  122. X#define    PS_LW (0.25/PS_SC)            /* linewidth = 0.25 pts */
  123. X
  124. X#define PS_VCHAR1 (int)(7.0/PS_SC)    /* 7 point characters */
  125. X#define PS_HCHAR1 (int)(0.6*7.0/PS_SC)
  126. X
  127. X#define PS_VCHAR2 (int)(11.0/PS_SC)    /* 11 point characters */
  128. X#define PS_HCHAR2 (int)(0.6*11.0/PS_SC)
  129. X
  130. X
  131. XEPSF1_init()
  132. X{
  133. X    ps_big = FALSE;
  134. X    ps_font = "Courier";
  135. X    /* the font could also be "Courier-Bold" or "Times-Roman" etc. */
  136. X}
  137. X
  138. X
  139. XEPSF2_init()
  140. X{
  141. X    ps_big = TRUE;
  142. X    ps_font = "Courier";
  143. X}
  144. X
  145. X
  146. XEPSF_graphics()
  147. X{
  148. Xint i;
  149. X    fprintf(outfile,"%%!PS-Adobe-2.0 EPSF-2.0\n");
  150. X    fprintf(outfile,"%%%%Creator: gnuplot\n");
  151. X    fprintf(outfile,"%%%%DocumentFonts: %s\n", ps_font);
  152. X    fprintf(outfile,"%%%%DocumentNeededFonts: %s\n", ps_font);
  153. X    fprintf(outfile,"%%%%BoundingBox: 0 0 %d %d\n",
  154. X        (int)(xsize*(PS_XMAX)*PS_SC+0.5), 
  155. X        (int)(ysize*(PS_YMAX)*PS_SC+0.5) );
  156. X    fprintf(outfile,"%%%%EndComments\n");
  157. X    fprintf(outfile,"40 dict begin\n");
  158. X    fprintf(outfile,"/gnulinewidth %.3f def\n",PS_LW);
  159. X    fprintf(outfile,"/vshift %d def\n", 
  160. X        ps_big ? -PS_VCHAR2/3 : -PS_VCHAR1/3);
  161. X    fprintf(outfile,"/dl {%.3f mul} def\n",1/PS_SC); /* dash length */
  162. X    fprintf(outfile,"/hpt %.1f def\n",PS_HTIC/2.0);
  163. X    fprintf(outfile,"/vpt %.1f def\n",PS_VTIC/2.0);
  164. X    for ( i=0; PS_header[i] != NULL; i++)
  165. X        fprintf(outfile,"%s",PS_header[i]);
  166. X    fprintf(outfile,"%%%%EndProlog\n");
  167. X    fprintf(outfile,"%%%%BeginSetup\n");
  168. X    fprintf(outfile,"/Gnu_save save def\n");
  169. X    fprintf(outfile,"%.3f %.3f scale\n",PS_SC,PS_SC);
  170. X    fprintf(outfile,"%%%%IncludeFont: %s\n", ps_font);
  171. X    fprintf(outfile,"/%s findfont %d ", ps_font, 
  172. X        ps_big ? PS_VCHAR2 : PS_VCHAR1 );
  173. X    fprintf(outfile,"scalefont setfont\n");
  174. X    fprintf(outfile,"newpath\n");
  175. X    ps_path_count = 0;
  176. X    fprintf(outfile,"%%%%EndSetup\n");
  177. X}
  178. X
  179. X
  180. XEPSF_text()
  181. X{
  182. X    fprintf(outfile,"stroke\nGnu_save restore\n");
  183. X    fprintf(outfile,"showpage\n");
  184. X    ps_path_count = 0;
  185. X    fprintf(outfile,"%%%%Trailer\n");
  186. X    fprintf(outfile,"end\n");
  187. X}
  188. X
  189. X
  190. XEPSF_reset()
  191. X{
  192. X}
  193. X
  194. X
  195. XPS1_init()
  196. X{
  197. X    EPSF1_init();
  198. X    PS_init();
  199. X}
  200. X
  201. X
  202. XPS2_init()
  203. X{
  204. X    EPSF2_init();
  205. X    PS_init();
  206. X}
  207. X
  208. X
  209. XPS_init()
  210. X{
  211. X    fprintf(outfile,"%%!PS-Adobe-2.0\n");
  212. X    fprintf(outfile,"%%%%Creator: gnuplot\n");
  213. X    fprintf(outfile,"%%%%DocumentFonts: %s\n", ps_font);
  214. X    fprintf(outfile,"%%%%DocumentNeededFonts: %s\n", ps_font);
  215. X    fprintf(outfile,"%%%%Pages: (atend)\n");
  216. X    fprintf(outfile,"%%%%BoundingBox: %d 50 550 %d\n",
  217. X        (int)(550.5-ysize*(PS_YMAX)*PS_SC*2), 
  218. X        (int)(50.5+xsize*(PS_XMAX)*PS_SC*2) );
  219. X    fprintf(outfile,"%%%%EndComments\n");
  220. X    fprintf(outfile,"/GnuTransform {\n");
  221. X    fprintf(outfile,"  90 rotate\n  50 -550 translate\n  2 2 scale\n");
  222. X    fprintf(outfile,"} def\n");
  223. X    fprintf(outfile,"%%%%EndProlog\n");
  224. X    pspage = 0;
  225. X}
  226. X
  227. X
  228. X
  229. XPS_graphics()
  230. X{
  231. X    fprintf(outfile,"%%%%Page: ? %d\n",++pspage);
  232. X    fprintf(outfile,"gsave\nGnuTransform\n");
  233. X    fprintf(outfile,"%%%%BeginDocument: EPSF\n");
  234. X    fprintf(outfile,"1 dict begin\n/showpage {} def\n");
  235. X    EPSF_graphics();
  236. X}
  237. X
  238. X
  239. XPS_text()
  240. X{
  241. X    EPSF_text();
  242. X    fprintf(outfile,"%%%%EndDocument\n");
  243. X    fprintf(outfile,"end\nshowpage\ngrestore\n");
  244. X}
  245. X
  246. X
  247. X
  248. XPS_reset()
  249. X{
  250. X    fprintf(outfile,"%%%%Trailer\n");
  251. X    fprintf(outfile,"%%%%Pages: %d\n",pspage);
  252. X}
  253. X
  254. X
  255. XPS_linetype(linetype)
  256. Xint linetype;
  257. X{
  258. Xchar *line = "ba012345678"; 
  259. X    fprintf(outfile,"LT%c\n", line[(linetype%9)+2]);
  260. X    ps_path_count = 0;
  261. X}
  262. X
  263. X
  264. XPS_move(x,y)
  265. Xunsigned int x,y;
  266. X{
  267. X    fprintf(outfile,"%d %d M\n", x, y);
  268. X    ps_path_count += 1;
  269. X}
  270. X
  271. X
  272. XPS_vector(x,y)
  273. Xunsigned int x,y;
  274. X{
  275. X    fprintf(outfile,"%d %d L\n", x, y);
  276. X    ps_path_count += 1;
  277. X    if (ps_path_count >= 400) {
  278. X        fprintf(outfile,"currentpoint stroke moveto\n");
  279. X        ps_path_count = 0;
  280. X    }
  281. X}
  282. X
  283. X
  284. XPS_put_text(x,y,str)
  285. Xunsigned int x, y;
  286. Xchar *str;
  287. X{
  288. Xchar ch;
  289. X    PS_move(x,y);
  290. X    if (ps_ang != 0)
  291. X        fprintf(outfile,"currentpoint gsave translate %d rotate 0 0 moveto\n"
  292. X            ,ps_ang*90);
  293. X    putc('(',outfile);
  294. X    ch = *str++;
  295. X    while(ch!='\0') {
  296. X        if ( (ch=='(') || (ch==')') || (ch=='\\') )
  297. X            putc('\\',outfile);
  298. X        putc(ch,outfile);
  299. X        ch = *str++;
  300. X    }
  301. X    switch(ps_justify) {
  302. X        case LEFT : fprintf(outfile,") Lshow\n");
  303. X            break;
  304. X        case CENTRE : fprintf(outfile,") Cshow\n");
  305. X            break;
  306. X        case RIGHT : fprintf(outfile,") Rshow\n");
  307. X            break;
  308. X    }
  309. X    if (ps_ang != 0)
  310. X        fprintf(outfile,"grestore\n");
  311. X}
  312. X
  313. Xint PS_text_angle(ang)
  314. Xint ang;
  315. X{
  316. X    ps_ang=ang;
  317. X    return TRUE;
  318. X}
  319. X
  320. Xint PS_justify_text(mode)
  321. Xenum JUSTIFY mode;
  322. X{
  323. X    ps_justify=mode;
  324. X    return TRUE;
  325. X}
  326. X
  327. X/* postscript point routines */
  328. XPS_point(x,y,number)
  329. Xint x,y;
  330. Xint number;
  331. X{
  332. Xchar *point = "PDABCTS";
  333. X    number %= POINT_TYPES;
  334. X     if (number < -1)
  335. X        number = -1;        /* negative types are all 'dot' */
  336. X    fprintf(outfile,"%d %d %c\n", x, y, point[number+1]);
  337. X    ps_path_count = 0;
  338. X}
  339. X
  340. *-*-END-of-term/post.trm-*-*
  341. echo x - term/pc.trm
  342. sed 's/^X//' >term/pc.trm <<'*-*-END-of-term/pc.trm-*-*'
  343. X/* GNUPLOT - pc.trm */
  344. X/*
  345. X * Copyright (C) 1990   
  346. X *
  347. X * Permission to use, copy, and distribute this software and its
  348. X * documentation for any purpose with or without fee is hereby granted, 
  349. X * provided that the above copyright notice appear in all copies and 
  350. X * that both that copyright notice and this permission notice appear 
  351. X * in supporting documentation.
  352. X *
  353. X * Permission to modify the software is granted, but not the right to
  354. X * distribute the modified code.  Modifications are to be distributed 
  355. X * as patches to released version.
  356. X *  
  357. X * This software  is provided "as is" without express or implied warranty.
  358. X * 
  359. X * This file is included by ../term.c.
  360. X *
  361. X * This terminal driver supports:
  362. X *  Under Microsoft C
  363. X *      cga, egabios, egalib, vgabios, hercules, corona325, att
  364. X *  Under Turboc C
  365. X *      egalib, vgalib, vgamono, mcga, cga, hercules
  366. X *
  367. X * AUTHORS
  368. X *  Colin Kelley, Thomas Williams, William Wilson, Russell Lang
  369. X * 
  370. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  371. X * 
  372. X */
  373. X
  374. X#ifdef __TURBOC__
  375. X#include <graphics.h>
  376. X#include <dos.h>
  377. X  int g_driver, g_mode, g_error;
  378. X  char far *path;
  379. X  char *pathp, path_s[128];
  380. X
  381. X/* instead of string.h */
  382. Xextern char *strrchr();
  383. X
  384. Xget_path()
  385. X{
  386. X   path=(char far *) getenv("BGI");
  387. X   if (path==NULL) {
  388. X      (void) strcpy(path_s,_argv[0]);
  389. X      pathp=strrchr(path_s,'\\');
  390. X      *pathp=0x00;
  391. X      path=path_s;
  392. X   }
  393. X}
  394. X
  395. X#endif
  396. X
  397. X
  398. Xstatic char near buf[80];    /* kludge since EGA.LIB is compiled SMALL */
  399. X
  400. Xstatic int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
  401. X
  402. Xstatic int graphics_on = FALSE;
  403. Xint startx, starty;
  404. X
  405. Xint pc_angle;
  406. X#define PC_VCHAR 11
  407. X#define PC_HCHAR 7
  408. X
  409. Xpause()                                /* press any key to continue... */
  410. X{
  411. X    while (kbhit())
  412. X        (void) getch();                /* flush the keyboard buffer */
  413. X    while (!kbhit())
  414. X        ;
  415. X}
  416. X
  417. X
  418. XPC_text()
  419. X{
  420. X    if (graphics_on) {
  421. X        graphics_on = FALSE;
  422. X        pause();
  423. X    }
  424. X#ifdef __TURBOC__
  425. X    closegraph();
  426. X#else
  427. X    Vmode(3);
  428. X#endif
  429. X}
  430. X
  431. XPC_reset()
  432. X{
  433. X#ifdef __TURBOC__
  434. X    closegraph();
  435. X#endif
  436. X}
  437. X
  438. X
  439. X#ifndef __TURBOC__
  440. X
  441. XPC_putc(x,y,c,angle,line_func)
  442. Xunsigned int x,y;
  443. Xchar c;
  444. Xint angle;
  445. XFUNC_PTR line_func;
  446. X{
  447. Xint i,j,k;
  448. Xunsigned int pixelon;
  449. X    i = (int)(c) - 32;
  450. X    for (j=0; j<9; j++) {
  451. X        for (k=0; k<5; k++) {
  452. X            pixelon = (((unsigned int)(font5x7[i][j])) >> k & 1);
  453. X            if (pixelon) {
  454. X                switch(angle) {
  455. X                    case 0 : line_func(x+k+1,y-j,x+k+1,y-j);
  456. X                            break;
  457. X                    case 1 : line_func(x-j,y-k-1,x-j,y-k-1);
  458. X                            break;
  459. X                }
  460. X            }
  461. X        }
  462. X    }
  463. X}
  464. X
  465. X
  466. Xint PC_text_angle(ang)
  467. Xint ang;
  468. X{
  469. X    pc_angle=ang;
  470. X    return TRUE;
  471. X}
  472. X
  473. X
  474. X#define CGA_XMAX 640
  475. X#define CGA_YMAX 200
  476. X
  477. X#define CGA_XLAST (CGA_XMAX - 1)
  478. X#define CGA_YLAST (CGA_YMAX - 1)
  479. X
  480. X#define CGA_VCHAR PC_VCHAR
  481. X#define CGA_HCHAR PC_HCHAR
  482. X#define CGA_VTIC 4
  483. X#define CGA_HTIC 6
  484. X
  485. Xint line_cga;
  486. X
  487. XCGA_init()
  488. X{
  489. X    PC_color(1);        /* monochrome */
  490. X}
  491. X
  492. XCGA_graphics()
  493. X{
  494. X    graphics_on = TRUE;
  495. X    Vmode(6);
  496. X}
  497. X
  498. X#define CGA_text PC_text
  499. X
  500. XCGA_linetype(linetype)
  501. X{
  502. X    if (linetype >= 5)
  503. X        linetype %= 5;
  504. X    line_cga=linetype;
  505. X    PC_mask(pattern[linetype+2]);
  506. X}
  507. X
  508. XCGA_move(x,y)
  509. X{
  510. X    startx = x;
  511. X    starty = y;
  512. X}
  513. X
  514. X
  515. XCGA_vector(x,y)
  516. X{
  517. X    PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y);
  518. X    startx = x;
  519. X    starty = y;
  520. X}
  521. X
  522. X
  523. XCGA_put_text(x,y,str)
  524. Xunsigned int x, y;
  525. Xchar *str;
  526. X{
  527. Xint i;
  528. Xint line;
  529. X    line= line_cga;     /* disable the dotted lines temporarily */
  530. X    PC_mask(pattern[0]);
  531. X    switch(pc_angle) {
  532. X        case 0 : y -= CGA_VCHAR/2;
  533. X                break;
  534. X        case 1 : x += CGA_VCHAR/2;
  535. X                break;
  536. X    }
  537. X    for (i=0;str[i];i++) {
  538. X        PC_putc(x,CGA_YLAST-y,str[i],pc_angle,PC_line);
  539. X        switch(pc_angle) {
  540. X            case 0 : x+=CGA_HCHAR ;
  541. X                    break;
  542. X            case 1 : y+=CGA_HCHAR ;
  543. X                    break;
  544. X        }
  545. X    }
  546. X    PC_mask(pattern[line]);  /* enable dotted lines */
  547. X}
  548. X
  549. X
  550. X#define CGA_text_angle PC_text_angle
  551. X
  552. X#define CGA_reset PC_reset
  553. X
  554. X
  555. X#define EGA_XMAX 640
  556. X#define EGA_YMAX 350
  557. X
  558. X#define EGA_XLAST (EGA_XMAX - 1)
  559. X#define EGA_YLAST (EGA_YMAX - 1)
  560. X
  561. X#define EGA_VCHAR PC_VCHAR
  562. X#define EGA_HCHAR PC_HCHAR
  563. X#define EGA_VTIC 4
  564. X#define EGA_HTIC 5
  565. X
  566. Xstatic int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  567. Xstatic int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  568. X
  569. Xstatic int *egacolor;
  570. X
  571. X
  572. XEGA_init()
  573. X{
  574. X    PC_mask(0xffff);
  575. X    egacolor = ega256color;        /* should be smarter */
  576. X}
  577. X
  578. XEGA_graphics()
  579. X{
  580. X    graphics_on = TRUE;
  581. X    Vmode(16);
  582. X}
  583. X
  584. X#define EGA_text PC_text
  585. X
  586. XEGA_linetype(linetype)
  587. X{
  588. X    if (linetype >= 13)
  589. X        linetype %= 13;
  590. X    PC_color(egacolor[linetype+2]);
  591. X}
  592. X
  593. XEGA_move(x,y)
  594. X{
  595. X    startx = x;
  596. X    starty = y;
  597. X}
  598. X
  599. XEGA_vector(x,y)
  600. X{
  601. X    PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y);
  602. X    startx = x;
  603. X    starty = y;
  604. X}
  605. X
  606. X
  607. XEGA_put_text(x,y,str)
  608. Xunsigned int x, y;
  609. Xchar *str;
  610. X{
  611. Xint i;
  612. X    switch(pc_angle) {
  613. X        case 0 : y -= EGA_VCHAR/2;
  614. X                break;
  615. X        case 1 : x += EGA_VCHAR/2;
  616. X                break;
  617. X    }
  618. X    for (i=0;str[i];i++) {
  619. X        PC_putc(x,EGA_YLAST-y,str[i],pc_angle,PC_line);
  620. X        switch(pc_angle) {
  621. X            case 0 : x+=EGA_HCHAR ;
  622. X                    break;
  623. X            case 1 : y+=EGA_HCHAR ;
  624. X                    break;
  625. X        }
  626. X    }
  627. X}
  628. X
  629. X
  630. X#define EGA_text_angle PC_text_angle
  631. X
  632. X#define EGA_reset PC_reset
  633. X
  634. X
  635. X
  636. X/* The following VGA routines are hacked from the above EGA routines
  637. X   They worked on two VGA cards.  
  638. X   Russell Lang, eln272v@monu1.cc.monash.oz */
  639. X#define VGA_XMAX 640
  640. X#define VGA_YMAX 480
  641. X
  642. X#define VGA_XLAST (VGA_XMAX - 1)
  643. X#define VGA_YLAST (VGA_YMAX - 1)
  644. X
  645. X#define VGA_VCHAR PC_VCHAR
  646. X#define VGA_HCHAR PC_HCHAR
  647. X#define VGA_VTIC 5
  648. X#define VGA_HTIC 5
  649. X
  650. Xstatic int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  651. X
  652. Xstatic int *vgacolor;
  653. X
  654. X
  655. XVGA_init()
  656. X{
  657. X    PC_mask(0xffff);
  658. X    vgacolor = vga256color;        /* should be smarter */
  659. X}
  660. X
  661. XVGA_graphics()
  662. X{
  663. X    graphics_on = TRUE;
  664. X    Vmode(18);
  665. X}
  666. X
  667. X#define VGA_text PC_text
  668. X
  669. XVGA_linetype(linetype)
  670. X{
  671. X    if (linetype >= 13)
  672. X        linetype %= 13;
  673. X    PC_color(vgacolor[linetype+2]);
  674. X}
  675. X
  676. XVGA_move(x,y)
  677. X{
  678. X    startx = x;
  679. X    starty = y;
  680. X}
  681. X
  682. XVGA_vector(x,y)
  683. X{
  684. X    PC_line(startx,VGA_YLAST-starty,x,VGA_YLAST-y);
  685. X    startx = x;
  686. X    starty = y;
  687. X}
  688. X
  689. X
  690. XVGA_put_text(x,y,str)
  691. Xunsigned int x, y;
  692. Xchar *str;
  693. X{
  694. Xint i;
  695. X    switch(pc_angle) {
  696. X        case 0 : y -= VGA_VCHAR/2;
  697. X                break;
  698. X        case 1 : x += VGA_VCHAR/2;
  699. X                break;
  700. X    }
  701. X    for (i=0;str[i];i++) {
  702. X        PC_putc(x,VGA_YLAST-y,str[i],pc_angle,PC_line);
  703. X        switch(pc_angle) {
  704. X            case 0 : x+=VGA_HCHAR ;
  705. X                    break;
  706. X            case 1 : y+=VGA_HCHAR ;
  707. X                    break;
  708. X        }
  709. X    }
  710. X}
  711. X
  712. X
  713. X#define VGA_text_angle PC_text_angle
  714. X
  715. X#define VGA_reset PC_reset
  716. X
  717. X
  718. X
  719. X#ifdef EGALIB
  720. X
  721. X#define EGALIB_XMAX 640
  722. X#define EGALIB_YMAX 350
  723. X
  724. X#define EGALIB_XLAST (EGA_XMAX - 1)
  725. X#define EGALIB_YLAST (EGA_YMAX - 1)
  726. X
  727. X#define EGALIB_VCHAR 14
  728. X#define EGALIB_HCHAR 8
  729. X#define EGALIB_VTIC 4
  730. X#define EGALIB_HTIC 5
  731. X
  732. X#include "mcega.h"
  733. X
  734. XEGALIB_init()
  735. X{
  736. X    GPPARMS();
  737. X    if (GDTYPE != 5) {
  738. X        term = 0;
  739. X        int_error("color EGA board not found",NO_CARET);
  740. X    }
  741. X    egacolor = (GDMEMORY < 256) ? ega64color : ega256color;
  742. X}
  743. X
  744. XEGALIB_graphics()
  745. X{
  746. X    graphics_on = TRUE;
  747. X    GPINIT();
  748. X}
  749. X
  750. XEGALIB_text()
  751. X{
  752. X    if (graphics_on) {
  753. X        graphics_on = FALSE;
  754. X        pause();
  755. X    }
  756. X    GPTERM();
  757. X}
  758. X
  759. XEGALIB_linetype(linetype)
  760. X{
  761. X    if (linetype >= 13)
  762. X        linetype %= 13;
  763. X    GPCOLOR(egacolor[linetype+2]);
  764. X}
  765. X
  766. XEGALIB_move(x,y)
  767. X{
  768. X    GPMOVE(x,GDMAXROW-y);
  769. X}
  770. X
  771. X
  772. XEGALIB_vector(x,y)
  773. X{
  774. X    GPLINE(x,GDMAXROW-y);
  775. X}
  776. X
  777. X
  778. XEGALIB_put_text(x,y,str)
  779. Xint x, y;
  780. Xchar *str;
  781. X{
  782. X    strcpy((char far *)buf,str);
  783. X    GotoXY((int)(x/EGALIB_HCHAR),
  784. X           (int)((EGALIB_YMAX-y-(EGALIB_VCHAR/2))/EGALIB_VCHAR));
  785. X    gprintf(buf);
  786. X}
  787. X
  788. X
  789. X#define EGALIB_reset PC_reset
  790. X
  791. X#endif /* EGALIB */
  792. X
  793. X
  794. X#ifdef HERCULES
  795. X
  796. X#define HERC_XMAX 720
  797. X#define HERC_YMAX 348
  798. X
  799. X#define HERC_XLAST (HERC_XMAX - 1)
  800. X#define HERC_YLAST (HERC_YMAX - 1)
  801. X
  802. X#define HERC_VCHAR PC_VCHAR
  803. X#define HERC_HCHAR PC_HCHAR
  804. X#define HERC_VTIC 4
  805. X#define HERC_HTIC 5
  806. X
  807. Xint line_herc;
  808. X
  809. XHERC_init()
  810. X{
  811. X    H_init();
  812. X}
  813. X
  814. XHERC_graphics()
  815. X{
  816. X    HVmode(1);
  817. X    graphics_on = TRUE;
  818. X}
  819. X
  820. XHERC_text()
  821. X{
  822. X    if (graphics_on) {
  823. X        graphics_on = FALSE;
  824. X        pause();
  825. X    }
  826. X    HVmode(0);
  827. X}
  828. X
  829. XHERC_linetype(linetype)
  830. X{
  831. X    if (linetype >= 5)
  832. X        linetype %= 5;
  833. X    H_mask(pattern[linetype+2]);
  834. X    line_herc = linetype;
  835. X}
  836. X
  837. XHERC_move(x,y)
  838. X{
  839. X    if (x < 0)
  840. X        startx = 0;
  841. X    else if (x > HERC_XLAST)
  842. X        startx = HERC_XLAST;
  843. X    else
  844. X        startx = x;
  845. X
  846. X    if (y < 0)
  847. X        starty = 0;
  848. X    else if (y > HERC_YLAST)
  849. X        starty = HERC_YLAST;
  850. X    else
  851. X        starty = y;
  852. X}
  853. X
  854. XHERC_vector(x,y)
  855. X{
  856. X    if (x < 0)
  857. X        x = 0;
  858. X    else if (x > HERC_XLAST)
  859. X        x = HERC_XLAST;
  860. X    if (y < 0)
  861. X        y = 0;
  862. X    else if (y > HERC_YLAST)
  863. X        y = HERC_YLAST;
  864. X
  865. X    H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y);
  866. X    startx = x;
  867. X    starty = y;
  868. X}
  869. X
  870. X
  871. XHERC_put_text(x,y,str)
  872. Xunsigned int x, y;
  873. Xchar *str;
  874. X{
  875. Xint i;
  876. Xint line;
  877. X    line= line_herc;     /* disable the dotted lines temporarily */
  878. X    H_mask(pattern[0]);
  879. X    switch(pc_angle) {
  880. X        case 0 : y -= HERC_VCHAR/2;
  881. X                break;
  882. X        case 1 : x += HERC_VCHAR/2;
  883. X                break;
  884. X    }
  885. X    for (i=0;str[i];i++) {
  886. X        PC_putc(x,HERC_YLAST-y,str[i],pc_angle,H_line);
  887. X        switch(pc_angle) {
  888. X            case 0 : x+=HERC_HCHAR ;
  889. X                    break;
  890. X            case 1 : y+=HERC_HCHAR ;
  891. X                    break;
  892. X        }
  893. X    }
  894. X    H_mask(pattern[line]);  /* enable dotted lines */
  895. X}
  896. X
  897. X
  898. X#define HERC_text_angle PC_text_angle
  899. X
  900. X#define HERC_reset PC_reset
  901. X
  902. X
  903. X#endif /* HERCULES */
  904. X
  905. X
  906. X/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
  907. X   ATT 6300 driver */ 
  908. X
  909. X
  910. X#ifdef ATT6300
  911. X
  912. X#define ATT_XMAX 640
  913. X#define ATT_YMAX 400
  914. X
  915. X#define ATT_XLAST (ATT_XMAX - 1)
  916. X#define ATT_YLAST (ATT_YMAX - 1)
  917. X
  918. X#define ATT_VCHAR PC_VCHAR
  919. X#define ATT_HCHAR PC_HCHAR
  920. X#define ATT_VTIC 4
  921. X#define ATT_HTIC 5
  922. X
  923. X#define ATT_init CGA_init
  924. X
  925. XATT_graphics()
  926. X{
  927. X    graphics_on = TRUE;
  928. X    Vmode(0x40);        /* 40H is the magic number for the AT&T driver */
  929. X}
  930. X
  931. X#define ATT_text CGA_text
  932. X
  933. X#define ATT_linetype CGA_linetype
  934. X
  935. X#define ATT_move CGA_move
  936. X
  937. XATT_vector(x,y)
  938. X{
  939. X    PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y);
  940. X    startx = x;
  941. X    starty = y;
  942. X}
  943. X
  944. X
  945. XATT_put_text(x,y,str)
  946. Xunsigned int x, y;
  947. Xchar *str;
  948. X{
  949. Xint i;
  950. Xint line;
  951. X    line= line_cga;     /* disable the dotted lines temporarily */
  952. X    PC_mask(pattern[0]);
  953. X    switch(pc_angle) {
  954. X        case 0 : y -= ATT_VCHAR/2;
  955. X                break;
  956. X        case 1 : x += ATT_VCHAR/2;
  957. X                break;
  958. X    }
  959. X    for (i=0;str[i];i++) {
  960. X        PC_putc(x,ATT_YLAST-y,str[i],pc_angle,PC_line);
  961. X        switch(pc_angle) {
  962. X            case 0 : x+=ATT_HCHAR ;
  963. X                    break;
  964. X            case 1 : y+=ATT_HCHAR ;
  965. X                    break;
  966. X        }
  967. X    }
  968. X    PC_mask(pattern[line]);  /* enable dotted lines */
  969. X}
  970. X
  971. X
  972. X#define ATT_text_angle PC_text_angle
  973. X
  974. X#define ATT_reset CGA_reset
  975. X
  976. X#endif  /* ATT6300 */
  977. X
  978. X
  979. X#ifdef CORONA
  980. X
  981. X#define COR_XMAX 640
  982. X#define COR_YMAX 325
  983. X
  984. X#define COR_XLAST (COR_XMAX - 1)
  985. X#define COR_YLAST (COR_YMAX - 1)
  986. X
  987. X#define COR_VCHAR PC_VCHAR
  988. X#define COR_HCHAR PC_HCHAR
  989. X#define COR_VTIC 4
  990. X#define COR_HTIC 5
  991. X
  992. Xint line_cor;
  993. X
  994. Xstatic int corscreen;        /* screen number, 0 - 7 */
  995. X
  996. XCOR_init()
  997. X{
  998. Xregister char *p;
  999. X    if (!(p = getenv("CORSCREEN")))
  1000. X        int_error("must run CORPLOT for Corona graphics",NO_CARET);
  1001. X    corscreen = *p - '0';
  1002. X}
  1003. X
  1004. XCOR_graphics()
  1005. X{
  1006. X    graphics_on = TRUE;
  1007. X    Vmode(3);                /* clear text screen */
  1008. X    grinit(corscreen);
  1009. X    grandtx();
  1010. X}
  1011. X
  1012. XCOR_text()
  1013. X{
  1014. X    if (graphics_on) {
  1015. X        graphics_on = FALSE;
  1016. X        pause();
  1017. X    }
  1018. X    grreset();
  1019. X    txonly();
  1020. X    Vmode(3);
  1021. X}
  1022. X
  1023. XCOR_linetype(linetype)
  1024. X{
  1025. X    if (linetype >= 5)
  1026. X        linetype %= 5;
  1027. X    line_cor = linetype;
  1028. X    Cor_mask(pattern[linetype+2]);
  1029. X}
  1030. X
  1031. XCOR_move(x,y)
  1032. X{
  1033. X    if (x < 0)
  1034. X        startx = 0;
  1035. X    else if (x > COR_XLAST)
  1036. X        startx = COR_XLAST;
  1037. X    else
  1038. X        startx = x;
  1039. X
  1040. X    if (y < 0)
  1041. X        starty = 0;
  1042. X    else if (y > COR_YLAST)
  1043. X        starty = COR_YLAST;
  1044. X    else
  1045. X        starty = y;
  1046. X}
  1047. X
  1048. XCOR_vector(x,y)
  1049. X{
  1050. X    if (x < 0)
  1051. X        x = 0;
  1052. X    else if (x > COR_XLAST)
  1053. X        x = COR_XLAST;
  1054. X    if (y < 0)
  1055. X        y = 0;
  1056. X    else if (y > COR_YLAST)
  1057. X        y = COR_YLAST;
  1058. X
  1059. X    Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
  1060. X    startx = x;
  1061. X    starty = y;
  1062. X}
  1063. X
  1064. X
  1065. XCOR_put_text(x,y,str)
  1066. Xunsigned int x, y;
  1067. Xchar *str;
  1068. X{
  1069. Xint i;
  1070. Xint line;
  1071. X    line= line_cor;     /* disable the dotted lines temporarily */
  1072. X    Cor_mask(pattern[0]);
  1073. X    switch(pc_angle) {
  1074. X        case 0 : y -= COR_VCHAR/2;
  1075. X                break;
  1076. X        case 1 : x += COR_VCHAR/2;
  1077. X                break;
  1078. X    }
  1079. X    for (i=0;str[i];i++) {
  1080. X        PC_putc(x,COR_YLAST-y,str[i],pc_angle,Cor_line);
  1081. X        switch(pc_angle) {
  1082. X            case 0 : x+=COR_HCHAR ;
  1083. X                    break;
  1084. X            case 1 : y+=COR_HCHAR ;
  1085. X                    break;
  1086. X        }
  1087. X    }
  1088. X    COR_mask(pattern[line]);  /* enable dotted lines */
  1089. X}
  1090. X
  1091. X
  1092. X#define COR_text_angle PC_text_angle
  1093. X
  1094. X#define COR_reset PC_reset
  1095. X
  1096. X#endif /* CORONA */
  1097. X
  1098. X
  1099. X#else /* ifndef __TURBOC__ */
  1100. X/* all of the Turbo C routines for the different graphics devices go here */
  1101. X
  1102. Xint PC_text_angle(ang)
  1103. Xint ang;
  1104. X{
  1105. X    pc_angle = ang;
  1106. X    switch (ang) {
  1107. X        case 0 : settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  1108. X            break;
  1109. X        case 1 : settextstyle(DEFAULT_FONT,VERT_DIR,1);
  1110. X            break;
  1111. X    }
  1112. X    return TRUE;
  1113. X}
  1114. X
  1115. Xint PC_justify_text(mode)
  1116. Xenum JUSTIFY mode;
  1117. X{
  1118. X    switch(mode) {
  1119. X        case LEFT :
  1120. X            settextjustify(LEFT_TEXT,CENTER_TEXT);
  1121. X            break;
  1122. X        case CENTRE :
  1123. X            settextjustify(CENTER_TEXT,CENTER_TEXT);
  1124. X            break;
  1125. X        case RIGHT:
  1126. X            settextjustify(RIGHT_TEXT,CENTER_TEXT);
  1127. X            break;
  1128. X    }
  1129. X    return TRUE;
  1130. X}
  1131. X
  1132. X
  1133. X#define VGA_XMAX 640
  1134. X#define VGA_YMAX 480
  1135. X
  1136. X#define VGA_XLAST (VGA_XMAX - 1)
  1137. X#define VGA_YLAST (VGA_YMAX - 1)
  1138. X
  1139. X#define VGA_VCHAR 10
  1140. X#define VGA_HCHAR 8
  1141. X#define VGA_VTIC 4
  1142. X#define VGA_HTIC 5
  1143. X
  1144. Xstatic int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  1145. X
  1146. Xstatic int *vgacolor;
  1147. X
  1148. X#define VGA_reset EGALIB_reset
  1149. X#define VGA_text EGALIB_text
  1150. X#define VGA_move EGALIB_move
  1151. X#define VGA_vector EGALIB_vector
  1152. X#define VGA_text_angle PC_text_angle
  1153. X#define VGA_justify_text PC_justify_text
  1154. X
  1155. XVGA_init()
  1156. X{
  1157. X    g_driver=VGA;
  1158. X    g_mode=2;
  1159. X        initgraph(&g_driver,&g_mode,path);
  1160. X        if(g_driver!=9){
  1161. X          term=0;
  1162. X          switch (g_driver){
  1163. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1164. X                     break;
  1165. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1166. X                     break;
  1167. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1168. X                     break;
  1169. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1170. X                             "graphics driver.");
  1171. X                     break;
  1172. X            }
  1173. X            
  1174. X/*          int_error("color VGA board not found",NO_CARET);*/
  1175. X        }
  1176. X        if(g_driver==VGA) vgacolor=vga256color;
  1177. X}
  1178. X
  1179. XVGA_graphics()
  1180. X{       g_driver=VGA;
  1181. X    g_mode=2;
  1182. X    graphics_on = TRUE;
  1183. X    initgraph(&g_driver,&g_mode,path);
  1184. X    VGA_justify_text(LEFT);
  1185. X}
  1186. X
  1187. XVGA_linetype(linetype)
  1188. X{
  1189. X    if (linetype >= 13)
  1190. X        linetype %= 13;
  1191. X    setcolor(vgacolor[linetype+2]);
  1192. X}
  1193. X
  1194. XVGA_put_text(x,y,str)
  1195. Xunsigned int x, y;
  1196. Xchar *str;
  1197. X{
  1198. X    strcpy((char far *)buf,str);
  1199. X    outtextxy(x,VGA_YLAST-y,buf);
  1200. X}
  1201. X
  1202. X
  1203. XVGAMONO_linetype(linetype)
  1204. X{
  1205. X    if (linetype >= 5)
  1206. X        linetype %= 5;
  1207. X    setlinestyle(4,pattern[linetype+2],1);
  1208. X}
  1209. X
  1210. X#define MCGA_XMAX 640
  1211. X#define MCGA_YMAX 480
  1212. X
  1213. X#define MCGA_XLAST (MCGA_XMAX - 1)
  1214. X#define MCGA_YLAST (MCGA_YMAX - 1)
  1215. X
  1216. X#define MCGA_VCHAR 10
  1217. X#define MCGA_HCHAR 8
  1218. X#define MCGA_VTIC 4
  1219. X#define MCGA_HTIC 5
  1220. X
  1221. Xstatic int *MCGAcolor;
  1222. X
  1223. X#define MCGA_reset EGALIB_reset
  1224. X#define MCGA_text EGALIB_text
  1225. X#define MCGA_move EGALIB_move
  1226. X#define MCGA_vector EGALIB_vector
  1227. X#define MCGA_text_angle PC_text_angle
  1228. X#define MCGA_justify_text PC_justify_text
  1229. X
  1230. XMCGA_init()
  1231. X{
  1232. X    g_driver=MCGA;
  1233. X    g_mode=5;
  1234. X        initgraph(&g_driver,&g_mode,path);
  1235. X        if(g_driver!=2){
  1236. X          term=0;
  1237. X          switch (g_driver){
  1238. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1239. X                     break;
  1240. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1241. X                     break;
  1242. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1243. X                     break;
  1244. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1245. X                             "graphics driver.");
  1246. X                     break;
  1247. X            }
  1248. X            
  1249. X        }
  1250. X}
  1251. X
  1252. XMCGA_graphics()
  1253. X{       g_driver=MCGA;
  1254. X    g_mode=5;
  1255. X    graphics_on = TRUE;
  1256. X    initgraph(&g_driver,&g_mode,path);
  1257. X    MCGA_justify_text(LEFT);
  1258. X}
  1259. X
  1260. X
  1261. XMCGA_put_text(x,y,str)
  1262. Xunsigned int x, y;
  1263. Xchar *str;
  1264. X{
  1265. X    strcpy((char far *)buf,str);
  1266. X    outtextxy(x,MCGA_YLAST-y,buf);
  1267. X}
  1268. X
  1269. X
  1270. XMCGA_linetype(linetype)
  1271. X{
  1272. X    if (linetype >= 5)
  1273. X        linetype %= 5;
  1274. X    setlinestyle(4,pattern[linetype+2],1);
  1275. X}
  1276. X
  1277. X
  1278. X#define EGALIB_XMAX 640
  1279. X#define EGALIB_YMAX 350
  1280. X
  1281. X#define EGALIB_XLAST (EGALIB_XMAX - 1)
  1282. X#define EGALIB_YLAST (EGALIB_YMAX - 1)
  1283. X
  1284. X#define EGALIB_VCHAR 10
  1285. X#define EGALIB_HCHAR 8
  1286. X#define EGALIB_VTIC 4
  1287. X#define EGALIB_HTIC 5
  1288. X
  1289. Xstatic int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  1290. Xstatic int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  1291. X
  1292. Xstatic int *egacolor;
  1293. X
  1294. X#define EGALIB_text_angle PC_text_angle
  1295. X#define EGALIB_justify_text PC_justify_text
  1296. X
  1297. XEGALIB_init()
  1298. X{
  1299. X    g_driver=EGA;
  1300. X    g_mode=1;
  1301. X        initgraph(&g_driver,&g_mode,path);
  1302. X        if(g_driver<3 || g_driver>4){
  1303. X          term=0;
  1304. X          switch (g_driver){
  1305. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1306. X                     break;
  1307. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1308. X                     break;
  1309. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1310. X                     break;
  1311. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1312. X                             "graphics driver.");
  1313. X                     break;
  1314. X            }
  1315. X            
  1316. X/*          int_error("color EGA board not found",NO_CARET);*/
  1317. X        }
  1318. X        if(g_driver==EGA) egacolor=ega256color;
  1319. X        if(g_driver==EGA64) egacolor=ega64color;
  1320. X}
  1321. X
  1322. XEGALIB_graphics()
  1323. X{
  1324. X    graphics_on = TRUE;
  1325. X    initgraph(&g_driver,&g_mode,path);
  1326. X    EGALIB_justify_text(LEFT);
  1327. X}
  1328. X
  1329. XEGALIB_text()
  1330. X{
  1331. X    if (graphics_on) {
  1332. X        graphics_on = FALSE;
  1333. X        pause();
  1334. X    }
  1335. X    closegraph();
  1336. X}
  1337. X
  1338. XEGALIB_linetype(linetype)
  1339. X{
  1340. X    if (linetype >= 13)
  1341. X        linetype %= 13;
  1342. X    setcolor(egacolor[linetype+2]);
  1343. X}
  1344. X
  1345. XEGALIB_move(x,y)
  1346. X{
  1347. X        moveto(x,getmaxy()-y);
  1348. X}
  1349. X
  1350. X
  1351. XEGALIB_vector(x,y)
  1352. X{
  1353. X    lineto(x,getmaxy()-y);
  1354. X}
  1355. X
  1356. X
  1357. XEGALIB_put_text(x,y,str)
  1358. Xunsigned int x, y;
  1359. Xchar *str;
  1360. X{
  1361. X    strcpy((char far *)buf,str);
  1362. X    outtextxy(x,EGALIB_YLAST-y,buf);
  1363. X}
  1364. X
  1365. X
  1366. XEGALIB_reset()
  1367. X{
  1368. X      closegraph();
  1369. X}
  1370. X
  1371. X
  1372. X#define CGA_XMAX 640
  1373. X#define CGA_YMAX 200
  1374. X
  1375. X#define CGA_XLAST (CGA_XMAX - 1)
  1376. X#define CGA_YLAST (CGA_YMAX - 1)
  1377. X
  1378. X#define CGA_VCHAR 10
  1379. X#define CGA_HCHAR 8
  1380. X#define CGA_VTIC 4
  1381. X#define CGA_HTIC 6
  1382. X
  1383. X#define CGA_text_angle PC_text_angle
  1384. X#define CGA_justify_text PC_justify_text
  1385. X#define CGA_reset PC_reset
  1386. X
  1387. XCGA_init()
  1388. X{
  1389. X    g_driver=CGA;
  1390. X    g_mode=4;
  1391. X    initgraph(&g_driver,&g_mode,path);
  1392. X          switch (g_driver){
  1393. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1394. X                     break;
  1395. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1396. X                     break;
  1397. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1398. X                     break;
  1399. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1400. X                             "graphics driver.");
  1401. X                     break;
  1402. X            }
  1403. X/*    PC_color(1);         monochrome */
  1404. X
  1405. X}
  1406. X
  1407. XCGA_graphics()
  1408. X{
  1409. X    graphics_on = TRUE;
  1410. X    g_driver=CGA;
  1411. X    g_mode=4;
  1412. X    initgraph(&g_driver,&g_mode,path);
  1413. X    CGA_justify_text(LEFT);
  1414. X    /*    Vmode(6);*/
  1415. X}
  1416. X
  1417. X#define CGA_text PC_text
  1418. X
  1419. XCGA_linetype(linetype)
  1420. X{
  1421. X    if (linetype >= 5)
  1422. X        linetype %= 5;
  1423. X    setlinestyle(4,pattern[linetype+2],1);
  1424. X}
  1425. X
  1426. XCGA_move(x,y)
  1427. X{
  1428. X    moveto(x,getmaxy()-y);
  1429. X}
  1430. X
  1431. X
  1432. XCGA_vector(x,y)
  1433. X{
  1434. X    lineto(x,getmaxy()-y);
  1435. X}
  1436. X
  1437. XCGA_put_text(x,y,str)
  1438. Xunsigned int x, y;
  1439. Xchar *str;
  1440. X{
  1441. X    strcpy((char far *)buf,str);
  1442. X    outtextxy(x,CGA_YLAST-y,buf);
  1443. X}
  1444. X
  1445. X
  1446. X
  1447. X#define HERC_XMAX 720
  1448. X#define HERC_YMAX 348
  1449. X
  1450. X#define HERC_XLAST (HERC_XMAX - 1)
  1451. X#define HERC_YLAST (HERC_YMAX - 1)
  1452. X
  1453. X#define HERC_VCHAR 10
  1454. X#define HERC_HCHAR 8
  1455. X#define HERC_VTIC 4
  1456. X#define HERC_HTIC 5
  1457. X
  1458. X#define HERC_text_angle PC_text_angle
  1459. X#define HERC_justify_text PC_justify_text
  1460. X#define HERC_reset PC_reset
  1461. X
  1462. XHERC_init()
  1463. X{
  1464. X    g_driver=HERCMONO;
  1465. X    g_mode=0;
  1466. X      initgraph(&g_driver,&g_mode,path);
  1467. X          switch (g_driver){
  1468. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  1469. X                     break;
  1470. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1471. X                     break;
  1472. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1473. X                     break;
  1474. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  1475. X                             "graphics driver.");
  1476. X                     break;
  1477. X            }
  1478. X}
  1479. X
  1480. XHERC_graphics()
  1481. X{
  1482. X    g_driver=HERCMONO;
  1483. X    g_mode=0;
  1484. X    initgraph(&g_driver,&g_mode,path);
  1485. X    HERC_justify_text(LEFT);
  1486. X    graphics_on = TRUE;
  1487. X}
  1488. X
  1489. XHERC_text()
  1490. X{
  1491. X    if (graphics_on) {
  1492. X        graphics_on = FALSE;
  1493. X        pause();
  1494. X    }
  1495. X    closegraph();
  1496. X}
  1497. X
  1498. XHERC_linetype(linetype)
  1499. X{
  1500. X    if (linetype >= 5)
  1501. X        linetype %= 5;
  1502. X    setlinestyle(4,pattern[linetype+2],1);
  1503. X}
  1504. X
  1505. XHERC_move(x,y)
  1506. X{
  1507. X    if (x < 0)
  1508. X        x = 0;
  1509. X    else if (x > HERC_XLAST)
  1510. X        x = HERC_XLAST;
  1511. X
  1512. X    if (y < 0)
  1513. X        y = 0;
  1514. X    else if (y > HERC_YLAST)
  1515. X        y = HERC_YLAST;
  1516. X    moveto(x,getmaxy()-y);
  1517. X}
  1518. X
  1519. XHERC_vector(x,y)
  1520. X{
  1521. X    if (x < 0)
  1522. X        x = 0;
  1523. X    else if (x > HERC_XLAST)
  1524. X        x = HERC_XLAST;
  1525. X    if (y < 0)
  1526. X        y = 0;
  1527. X    else if (y > HERC_YLAST)
  1528. X        y = HERC_YLAST;
  1529. X
  1530. X    lineto(x,getmaxy()-y);
  1531. X}
  1532. X
  1533. X
  1534. XHERC_put_text(x,y,str)
  1535. Xunsigned int x, y;
  1536. Xchar *str;
  1537. X{
  1538. X    strcpy((char far *)buf,str);
  1539. X    outtextxy(x,HERC_YLAST-y,buf);
  1540. X}
  1541. X
  1542. X
  1543. X#endif /* ifndef __TURBOC__ */
  1544. X
  1545. *-*-END-of-term/pc.trm-*-*
  1546. echo x - term/qms.trm
  1547. sed 's/^X//' >term/qms.trm <<'*-*-END-of-term/qms.trm-*-*'
  1548. X/* GNUPLOT - qms.trm */
  1549. X/*
  1550. X * Copyright (C) 1990   
  1551. X *
  1552. X * Permission to use, copy, and distribute this software and its
  1553. X * documentation for any purpose with or without fee is hereby granted, 
  1554. X * provided that the above copyright notice appear in all copies and 
  1555. X * that both that copyright notice and this permission notice appear 
  1556. X * in supporting documentation.
  1557. X *
  1558. X * Permission to modify the software is granted, but not the right to
  1559. X * distribute the modified code.  Modifications are to be distributed 
  1560. X * as patches to released version.
  1561. X *  
  1562. X * This software  is provided "as is" without express or implied warranty.
  1563. X * 
  1564. X * This file is included by ../term.c.
  1565. X *
  1566. X * This terminal driver supports:
  1567. X *  QMS laser printers
  1568. X *
  1569. X * AUTHORS
  1570. X *  Colin Kelley, Thomas Williams, Russell Lang
  1571. X * 
  1572. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  1573. X * 
  1574. X */
  1575. X
  1576. X#define QMS_XMAX 9000
  1577. X#define QMS_YMAX 6000
  1578. X
  1579. X#define QMS_XLAST (QMS_XMAX - 1)
  1580. X#define QMS_YLAST (QMS_YMAX - 1)
  1581. X
  1582. X#define QMS_VCHAR        120
  1583. X#define QMS_HCHAR        70
  1584. X#define QMS_VTIC        70
  1585. X#define QMS_HTIC        70
  1586. X
  1587. Xint qms_line = 0;    /* to remember current line type */
  1588. X
  1589. XQMS_init()
  1590. X{
  1591. X/* This was just ^IOL, but at Rutgers at least we need some more stuff */
  1592. X  fprintf(outfile,"^PY^-\n^IOL\n^ISYNTAX00000^F^IB11000^IJ00000^IT00000\n");
  1593. X/*                 ^ QUIC on    ^set defaults  ^ set botttom,top,left margins
  1594. X                          ^landscape         ^free format   */
  1595. X/* set defaults are: implicit decimal point, units in inches, 
  1596. X   numbers left justified, units in 1/1000 inch, do not ignore spaces */
  1597. X/* margins are in 1/1000 inch units */
  1598. X}
  1599. X
  1600. X
  1601. XQMS_graphics()
  1602. X{
  1603. X    fprintf(outfile,"^IGV\n");
  1604. X/*                     ^enter graphics vector mode */
  1605. X}
  1606. X
  1607. X
  1608. X
  1609. XQMS_text()
  1610. X{
  1611. X/* added ^-, because ^, after an ^I command doesn't actually print a page */
  1612. X/* Did anybody try this code out?  [uhh...-cdk] */
  1613. X    fprintf(outfile,"^IGE\n^-^,");
  1614. X/*                     ^exit graphics vector mode
  1615. X                           ^pass terminator
  1616. X                             ^print page  */
  1617. X}
  1618. X
  1619. X
  1620. XQMS_linetype(linetype)
  1621. Xint linetype;
  1622. X{
  1623. Xstatic int width[2+9] = {7, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7};
  1624. Xstatic int type[2+9] =  {0, 1, 0, 2, 3, 0, 2, 3, 0, 2, 3};
  1625. X/*
  1626. X * I don't know about Villanova, but on our printer, using ^V without
  1627. X * previously setting up a pattern crashes the microcode.
  1628. X * [nope, doesn't crash here. -cdk]
  1629. X * [it generates a controller error here on dotted lines. - rjl]
  1630. X */
  1631. X/* Code to define patterns added by rjl
  1632. X * According to the manual it should work - but it doesn't
  1633. X */
  1634. X    qms_line = linetype;
  1635. X    if (linetype >= 9)
  1636. X        linetype %= 9;
  1637. X    fprintf(outfile,"^PW%02d\n",width[linetype+2]); 
  1638. X/*                     ^width in dots */
  1639. X    switch (type[linetype+2]) {
  1640. X        case 1 :    /* short dash */
  1641. X            fprintf(outfile,"^PV102025^G\n^V1\n");
  1642. X/* ^PV = define pattern vector, 1 = pattern number,
  1643. X   02 = number of pen downs and ups, 025 = .025" length of ups/downs */
  1644. X            break;
  1645. X        case 2 :    /* medium dash */
  1646. X            fprintf(outfile,"^PV202050^G\n^V2\n");
  1647. X            break;
  1648. X        case 3 :    /* long dash */
  1649. X            fprintf(outfile,"^PV302100^G\n^V3\n");
  1650. X            break;
  1651. X        default:
  1652. X        case 0 :
  1653. X            fprintf(outfile,"^V0\n");
  1654. X            break;
  1655. X    }
  1656. X}
  1657. X
  1658. X
  1659. XQMS_move(x,y)
  1660. Xint x,y;
  1661. X{
  1662. X    fprintf(outfile,"^U%05d:%05d\n", 1000 + x, QMS_YLAST + 1000 - y);
  1663. X/*                     ^pen up vector*/
  1664. X}
  1665. X
  1666. X
  1667. XQMS_vector(x2,y2)
  1668. Xint x2,y2;
  1669. X{
  1670. X    fprintf(outfile,"^D%05d:%05d\n", 1000 + x2, QMS_YLAST + 1000 - y2);
  1671. X/*                     ^pen down vector*/
  1672. X}
  1673. X
  1674. X
  1675. XQMS_put_text(x,y,str)
  1676. Xunsigned int x,y;
  1677. Xchar str[];
  1678. X{
  1679. Xchar ch;
  1680. X    QMS_move(x,y + QMS_VCHAR/3);
  1681. X    fputs("^IGE\n",outfile);
  1682. X    ch = *str++;
  1683. X    while(ch!='\0') {
  1684. X        if (ch=='^')
  1685. X            putc('^',outfile);
  1686. X        putc(ch,outfile);
  1687. X        ch = *str++;
  1688. X    }
  1689. X    fputs("\n^IGV\n",outfile);
  1690. X    QMS_linetype(qms_line); /* restore line type */
  1691. X}
  1692. X
  1693. X
  1694. XQMS_reset()
  1695. X{
  1696. X    fprintf(outfile,"^PN^-\n");
  1697. X/*                     ^QUIC off*/
  1698. X}
  1699. X
  1700. *-*-END-of-term/qms.trm-*-*
  1701. echo x - term/regis.trm
  1702. sed 's/^X//' >term/regis.trm <<'*-*-END-of-term/regis.trm-*-*'
  1703. X/* GNUPLOT - regis.trm */
  1704. X/*
  1705. X * Copyright (C) 1990   
  1706. X *
  1707. X * Permission to use, copy, and distribute this software and its
  1708. X * documentation for any purpose with or without fee is hereby granted, 
  1709. X * provided that the above copyright notice appear in all copies and 
  1710. X * that both that copyright notice and this permission notice appear 
  1711. X * in supporting documentation.
  1712. X *
  1713. X * Permission to modify the software is granted, but not the right to
  1714. X * distribute the modified code.  Modifications are to be distributed 
  1715. X * as patches to released version.
  1716. X *  
  1717. X * This software  is provided "as is" without express or implied warranty.
  1718. X * 
  1719. X * This file is included by ../term.c.
  1720. X *
  1721. X * This terminal driver supports:
  1722. X *  REGIS devices
  1723. X *
  1724. X * AUTHORS
  1725. X *  Colin Kelley, Thomas Williams
  1726. X * 
  1727. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  1728. X * 
  1729. X */
  1730. X
  1731. X#define REGISXMAX 800             
  1732. X#define REGISYMAX 440
  1733. X
  1734. X#define REGISXLAST (REGISXMAX - 1)
  1735. X#define REGISYLAST (REGISYMAX - 1)
  1736. X
  1737. X#define REGISVCHAR        20      
  1738. X#define REGISHCHAR        9
  1739. X#define REGISVTIC        8
  1740. X#define REGISHTIC        6
  1741. X
  1742. Xint REGISang = 0;
  1743. X
  1744. XREGISinit()
  1745. X{
  1746. X    fprintf(outfile,"\033[r\033[24;1H");
  1747. X/*                   1     2
  1748. X    1. reset scrolling region
  1749. X    2. locate cursor on bottom line
  1750. X*/
  1751. X}
  1752. X
  1753. X
  1754. X/* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */
  1755. XREGISgraphics()
  1756. X{
  1757. X    fprintf(outfile,"\033[2J\033P1pS(C0)S(E)");
  1758. X/*                   1      2      3    4   5
  1759. X    1. clear screen
  1760. X    2. enter ReGIS graphics
  1761. X    3. turn off graphics diamond cursor
  1762. X    4. clear graphics screen
  1763. X*/
  1764. X    (void) REGIStext_angle(0); /* select text size and angle */ 
  1765. X}
  1766. X
  1767. X
  1768. XREGIStext()
  1769. X{
  1770. X    fprintf(outfile,"\033\\\033[24;1H");
  1771. X/*                       1    2
  1772. X    1. Leave ReGIS graphics mode
  1773. X     2. locate cursor on last line of screen
  1774. X*/
  1775. X}
  1776. X
  1777. X
  1778. XREGISlinetype(linetype)
  1779. Xint     linetype;
  1780. X{
  1781. X      /* This will change color in order G,R,B,G-dot,R-dot,B-dot */
  1782. Xstatic int in_map[9 + 2] = {2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1};
  1783. Xstatic int lt_map[9 + 2] = {1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6};
  1784. X
  1785. X    if (linetype >= 9)
  1786. X        linetype %= 9;
  1787. X    fprintf(outfile, "W(I%d)", in_map[linetype + 2]);
  1788. X    fprintf(outfile, "W(P%d)", lt_map[linetype + 2]);
  1789. X}
  1790. X
  1791. X
  1792. XREGISmove(x,y)
  1793. Xint x,y;
  1794. X{
  1795. X    fprintf(outfile,"P[%d,%d]",x,REGISYLAST-y,x,REGISYLAST-y);
  1796. X}
  1797. X
  1798. X
  1799. XREGISvector(x,y)
  1800. Xint x,y;
  1801. X{
  1802. X    fprintf(outfile,"v[]v[%d,%d]",x,REGISYLAST - y);
  1803. X/* the initial v[] is needed to get the first pixel plotted */
  1804. X}
  1805. X
  1806. X
  1807. X/* put_text and text_angle by rjl */
  1808. XREGISput_text(x,y,str)
  1809. Xint x, y;
  1810. Xchar *str;
  1811. X{
  1812. X    if (REGISang==1)
  1813. X        REGISmove(x-REGISVCHAR/2-1,y);
  1814. X    else
  1815. X        REGISmove(x,y+REGISVCHAR/2-1);
  1816. X    (void) putc('T',outfile); (void) putc('\'',outfile);
  1817. X    while (*str) {
  1818. X        (void) putc(*str,outfile);
  1819. X        if (*str == '\'')
  1820. X            (void) putc('\'',outfile);    /* send out another one */
  1821. X        str++;
  1822. X    }
  1823. X    (void) putc('\'',outfile);
  1824. X}
  1825. X
  1826. X
  1827. Xint REGIStext_angle(ang)
  1828. Xint ang;
  1829. X{
  1830. X    REGISang = ang;
  1831. X    if (ang == 1)
  1832. X        fputs("T(D90,S1)",outfile);
  1833. X    else
  1834. X        fputs("T(D0,S1)",outfile);
  1835. X    return TRUE;
  1836. X}
  1837. X
  1838. X
  1839. XREGISreset()
  1840. X{
  1841. X    fprintf(outfile,"\033[2J\033[24;1H");
  1842. X}
  1843. X
  1844. *-*-END-of-term/regis.trm-*-*
  1845. echo x - term/tek.trm
  1846. sed 's/^X//' >term/tek.trm <<'*-*-END-of-term/tek.trm-*-*'
  1847. X/* GNUPLOT - tek.trm */
  1848. X/*
  1849. X * Copyright (C) 1990   
  1850. X *
  1851. X * Permission to use, copy, and distribute this software and its
  1852. X * documentation for any purpose with or without fee is hereby granted, 
  1853. X * provided that the above copyright notice appear in all copies and 
  1854. X * that both that copyright notice and this permission notice appear 
  1855. X * in supporting documentation.
  1856. X *
  1857. X * Permission to modify the software is granted, but not the right to
  1858. X * distribute the modified code.  Modifications are to be distributed 
  1859. X * as patches to released version.
  1860. X *  
  1861. X * This software  is provided "as is" without express or implied warranty.
  1862. X * 
  1863. X * This file is included by ../term.c.
  1864. X *
  1865. X * This terminal driver supports:
  1866. X *  tek40xx, bitgraph, kermit_color_tek40xx, kermit_mono_tek40xx, selanar
  1867. X *
  1868. X * AUTHORS
  1869. X *   Colin Kelley, Thomas Williams, Russell Lang
  1870. X * 
  1871. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  1872. X * 
  1873. X */
  1874. X
  1875. X#ifdef TEK
  1876. X
  1877. X#define TEK40XMAX 1024
  1878. X#define TEK40YMAX 780
  1879. X
  1880. X#define TEK40XLAST (TEK40XMAX - 1)
  1881. X#define TEK40YLAST (TEK40YMAX - 1)
  1882. X
  1883. X#define TEK40VCHAR        25
  1884. X#define TEK40HCHAR        14
  1885. X#define TEK40VTIC        11
  1886. X#define TEK40HTIC        11    
  1887. X
  1888. X#define HX 0x20        /* bit pattern to OR over 5-bit data */
  1889. X#define HY 0x20
  1890. X#define LX 0x40
  1891. X#define LY 0x60
  1892. X
  1893. X#define LOWER5 31
  1894. X#define UPPER5 (31<<5)
  1895. X
  1896. X
  1897. XTEK40init()
  1898. X{
  1899. X}
  1900. X
  1901. X
  1902. XTEK40graphics()
  1903. X{
  1904. X    fprintf(outfile,"\033\014");
  1905. X/*                   1
  1906. X    1. clear screen
  1907. X*/
  1908. X    (void) fflush(outfile);
  1909. X    sleep(1);  
  1910. X    /* sleep 1 second to allow screen time to clear on real 
  1911. X       tektronix terminals */
  1912. X}
  1913. X
  1914. XTEK40text()
  1915. X{
  1916. X    TEK40move(0,12);
  1917. X    fprintf(outfile,"\037");
  1918. X/*                   1
  1919. X    1. into alphanumerics
  1920. X*/
  1921. X}
  1922. X
  1923. X
  1924. XTEK40linetype(linetype)
  1925. Xint linetype;
  1926. X{
  1927. X}
  1928. X
  1929. XTEK40move(x,y)
  1930. Xunsigned int x,y;
  1931. X{
  1932. X    (void) putc('\035', outfile);    /* into graphics */
  1933. X    TEK40vector(x,y);
  1934. X}
  1935. X
  1936. X
  1937. XTEK40vector(x,y)
  1938. Xunsigned int x,y;
  1939. X{
  1940. X    (void) putc((HY | (y & UPPER5)>>5), outfile);
  1941. X    (void) putc((LY | (y & LOWER5)), outfile);
  1942. X    (void) putc((HX | (x & UPPER5)>>5), outfile);
  1943. X    (void) putc((LX | (x & LOWER5)), outfile);
  1944. X}
  1945. X
  1946. X
  1947. XTEK40put_text(x,y,str)
  1948. Xunsigned int x,y;
  1949. Xchar str[];
  1950. X{
  1951. X    TEK40move(x,y-11);
  1952. X    fprintf(outfile,"\037%s\n",str);
  1953. X}
  1954. X
  1955. X
  1956. XTEK40reset()
  1957. X{
  1958. X}
  1959. X
  1960. X#endif /* TEK */
  1961. X
  1962. X
  1963. X
  1964. X/* thanks to dukecdu!evs (Ed Simpson) for the BBN BitGraph driver */
  1965. X
  1966. X#ifdef BITGRAPH
  1967. X
  1968. X#define BG_XMAX                 768 /* width of plot area */
  1969. X#define BG_YMAX                 768 /* height of plot area */
  1970. X#define BG_SCREEN_HEIGHT    1024 /* full screen height */
  1971. X
  1972. X#define BG_XLAST     (BG_XMAX - 1)
  1973. X#define BG_YLAST     (BG_YMAX - 1)
  1974. X
  1975. X#define BG_VCHAR    16
  1976. X#define BG_HCHAR     9
  1977. X#define BG_VTIC         8
  1978. X#define BG_HTIC         8    
  1979. X
  1980. X
  1981. X#define BG_init TEK40init
  1982. X
  1983. X#define BG_graphics TEK40graphics
  1984. X
  1985. X
  1986. X#define BG_linetype TEK40linetype
  1987. X
  1988. X#define BG_move TEK40move
  1989. X
  1990. X#define BG_vector TEK40vector
  1991. X
  1992. X
  1993. XBG_text()
  1994. X{
  1995. X    BG_move(0, BG_SCREEN_HEIGHT - 2 * BG_VCHAR);
  1996. X    fprintf(outfile,"\037");
  1997. X/*                   1
  1998. X    1. into alphanumerics
  1999. X*/
  2000. X}
  2001. X
  2002. X
  2003. XBG_put_text(x,y,str)
  2004. Xunsigned int x,y;
  2005. Xchar str[];
  2006. X{
  2007. X    BG_move(x,y-11);
  2008. X    fprintf(outfile,"\037%s\n",str);
  2009. X}
  2010. X
  2011. X
  2012. X#define BG_reset TEK40reset
  2013. X
  2014. X#endif /* BITGRAPH */
  2015. X
  2016. X
  2017. X/* Color and Monochrome specials for the MS-Kermit Tektronix Emulator
  2018. X   by Russell Lang,  eln272v@monu1.cc.monash.oz  */
  2019. X
  2020. X#ifdef KERMIT
  2021. X
  2022. X#define KTEK40HCHAR        13
  2023. X
  2024. XKTEK40graphics()
  2025. X{
  2026. X    fprintf(outfile,"\033\014");
  2027. X/*                   1
  2028. X    1. clear screen
  2029. X*/
  2030. X    /* kermit tektronix emulation doesn't need to wait */
  2031. X}
  2032. X
  2033. XKTEK40Ctext()
  2034. X{
  2035. X    TEK40text();
  2036. X    KTEK40Clinetype(0);  /* change to green */
  2037. X}
  2038. X
  2039. X/* special color linetypes for MS-DOS Kermit v2.31 tektronix emulator */
  2040. X/*    0 = normal, 1 = bright 
  2041. X    foreground color (30-37) = 30 + colors
  2042. X        where colors are   1=red, 2=green, 4=blue */
  2043. Xstatic char *kermit_color[15]= {"\033[0;37m","\033[1;30m",
  2044. X        "\033[0;32m","\033[0;36m","\033[0;31m","\033[0;35m",
  2045. X        "\033[1;34m","\033[1;33m","\033[1;31m","\033[1;37m",
  2046. X        "\033[1;35m","\033[1;32m","\033[1;36m","\033[0;34m",
  2047. X        "\033[0;33m"};
  2048. X
  2049. XKTEK40Clinetype(linetype)
  2050. Xint linetype;
  2051. X{
  2052. X    if (linetype >= 13)
  2053. X        linetype %= 13;
  2054. X    fprintf(outfile,"%s",kermit_color[linetype+2]);
  2055. X}
  2056. X
  2057. X
  2058. X/* linetypes for MS-DOS Kermit v2.30 tektronix emulator */
  2059. X/* `=solid, a=fine dots, b=short dashes, c=dash dot, 
  2060. X   d=long dash dot, e=dash dot dot */
  2061. Xstatic char *kerm_linetype = "`a`abcde" ;
  2062. X
  2063. XKTEK40Mlinetype(linetype)
  2064. Xint linetype;
  2065. X{
  2066. X    if (linetype >= 6)
  2067. X        linetype %= 6;
  2068. X    fprintf(outfile,"\033%c",kerm_linetype[linetype+2]);
  2069. X}
  2070. X
  2071. XKTEK40reset()
  2072. X{
  2073. X    fprintf(outfile,"\030\n");  /* turn off Tek emulation */
  2074. X}
  2075. X
  2076. X#endif /* KERMIT */
  2077. X
  2078. X
  2079. X/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
  2080. X   Selanar driver */
  2081. X
  2082. X#ifdef SELANAR
  2083. X
  2084. XSEL_init()
  2085. X{
  2086. X    fprintf(outfile,"\033\062");
  2087. X/*                    1
  2088. X    1. set to ansi mode
  2089. X*/
  2090. X}
  2091. X
  2092. X
  2093. XSEL_graphics()
  2094. X{
  2095. X    fprintf(outfile,"\033[H\033[J\033\061\033\014");
  2096. X/*                   1           2       3
  2097. X    1. clear ANSI screen
  2098. X    2. set to TEK mode
  2099. X    3. clear screen
  2100. X*/
  2101. X}
  2102. X
  2103. X
  2104. XSEL_text()
  2105. X{
  2106. X    TEK40move(0,12);
  2107. X    fprintf(outfile,"\033\062");
  2108. X/*                   1
  2109. X    1. into ANSI mode
  2110. X*/
  2111. X}
  2112. X
  2113. XSEL_reset()
  2114. X{
  2115. X    fprintf(outfile,"\033\061\033\012\033\062\033[H\033[J");
  2116. X/*                   1        2       3      4
  2117. X1       set tek mode
  2118. X2       clear screen
  2119. X3       set ansi mode
  2120. X4       clear screen
  2121. X*/
  2122. X}
  2123. X#endif /* SELANAR */
  2124. X
  2125. *-*-END-of-term/tek.trm-*-*
  2126. echo x - term/unixpc.trm
  2127. sed 's/^X//' >term/unixpc.trm <<'*-*-END-of-term/unixpc.trm-*-*'
  2128. X/* GNUPLOT - unixpc.trm */
  2129. X/*
  2130. X * Copyright (C) 1990   
  2131. X *
  2132. X * Permission to use, copy, and distribute this software and its
  2133. X * documentation for any purpose with or without fee is hereby granted, 
  2134. X * provided that the above copyright notice appear in all copies and 
  2135. X * that both that copyright notice and this permission notice appear 
  2136. X * in supporting documentation.
  2137. X *
  2138. X * Permission to modify the software is granted, but not the right to
  2139. X * distribute the modified code.  Modifications are to be distributed 
  2140. X * as patches to released version.
  2141. X *  
  2142. X * This software  is provided "as is" without express or implied warranty.
  2143. X * 
  2144. X * This file is included by ../term.c.
  2145. X *
  2146. X * This terminal driver supports:
  2147. X *  Unix PC's (ATT 3b1)
  2148. X *
  2149. X * AUTHORS
  2150. X *    John Campbell
  2151. X * 
  2152. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  2153. X * 
  2154. X */
  2155. X
  2156. X/*
  2157. X>From: John Campbell (...!arizona!naucse!jdc)
  2158. X
  2159. XI originally ported gnuplot to the ATT 3b1 (ATT7300) on 12/4/88, and then
  2160. Xadded the minimal code needed to bring it up to 2.0 level on 1/28/90.  The 
  2161. X3b1, as I view it, is a 720x300 bitmapped, monochrome display (often people 
  2162. Xdon't use the top 12 scan lines and thus the effective size is 720x288).  I 
  2163. Xtried to maximize the size of the graph area, by using these top 12 lines 
  2164. X(normally reserved) and set up a signal handler to restore them upon exit, 
  2165. Xabort, etc.
  2166. X
  2167. XLine styles were "fudged" (they do not know the aspect ratio).  The same
  2168. Xline style may look different depending upon the slope of the curve.  Due to
  2169. Xthis only 4 line styles were implemented.  While more line types are possible,
  2170. Xthe current styles were chosen as distinguishable.
  2171. X
  2172. XThe 3b1 has 4 "special" rows at the bottom that I could not use in graphics
  2173. Xmode.  It has been suggested that we use these lines for command prompting.
  2174. XOthers have requested that we have a graphics window and a command window.
  2175. XMy experience with gnuplot only includes relatively dumb graphics devices--
  2176. Xhence gnuplot "looks and feels" normal to me the way I implemented it.
  2177. XI welcome either of these changes from someone else, however.
  2178. X*/
  2179. X
  2180. X#include <sys/window.h>   /* Started with tam.h--too much trouble. */
  2181. X#include <sys/signal.h>
  2182. X#include <errno.h>
  2183. X
  2184. X#define uPC_HIGH_BIT    (0x8000)
  2185. X
  2186. Xtypedef unsigned short Scr_type;
  2187. Xtypedef unsigned char Scr_kluge;
  2188. X
  2189. X#define uPC_XMAX 720
  2190. X#define uPC_YMAX 300
  2191. X
  2192. X#define uPC_XSIZE       45 /* Short ints. */
  2193. X#define uPC_YSIZE uPC_YMAX
  2194. X
  2195. XScr_type uPC_display[uPC_YSIZE][uPC_XSIZE];
  2196. Xint uPC_width = 2*uPC_XSIZE;
  2197. Xint uPC_sx=0, uPC_sy=0;
  2198. Xint uPC_cur_linetype=0;
  2199. Xint uPC_angle = 0;
  2200. Xunsigned short uPC_raster_count=0;
  2201. Xstatic Scr_type lookup[] = {
  2202. X      0x0001, 0x0002, 0x0004, 0x0008,
  2203. X      0x0010, 0x0020, 0x0040, 0x0080,
  2204. X      0x0100, 0x0200, 0x0400, 0x0800,
  2205. X      0x1000, 0x2000, 0x4000, 0x8000,
  2206. X   };
  2207. X
  2208. X#define uPC_XLAST (uPC_XMAX - 1)
  2209. X#define uPC_YLAST (uPC_YMAX - 1)
  2210. X
  2211. X#define uPC_VCHAR 11
  2212. X#define uPC_HCHAR  7
  2213. X#define uPC_VTIC   8
  2214. X#define uPC_HTIC  12
  2215. X
  2216. Xextern errno, sys_nerr;
  2217. Xextern char *sys_errlist[];
  2218. X
  2219. Xstatic struct urdata uPC_ur = {(unsigned short *)uPC_display, 2*uPC_XSIZE, 0, 0,
  2220. X                           0, 0, 0, 0, uPC_XMAX, uPC_YMAX, SRCSRC, DSTOR, 0};
  2221. X
  2222. X#define IfErrOut(e1,e2,s1,s2) if (e1 e2) {\
  2223. Xfprintf(stderr, "%s:: %s %s\n", sys_errlist[errno], s1, s2);\
  2224. XuPC_fixwind(0);\
  2225. Xexit(-1);}
  2226. X
  2227. XuPC_init()
  2228. X{
  2229. X/* This routine will ioctl to change 0 size */
  2230. X   int i;
  2231. X   struct uwdata uw;
  2232. X   int uPC_fixwind();
  2233. X   short gw;
  2234. X
  2235. X/* Check that we are on the bitmapped window. */
  2236. X   if (iswind() != 0) {
  2237. X      fprintf (stderr, "Sorry--must run from the bitmapped terminal\n");
  2238. X      exit(-1);
  2239. X   }
  2240. X   for (i=1; i<=16; i++) {
  2241. X      if (i != SIGINT && i != SIGFPE)  /* Two are caught in plot.c */
  2242. X         signal (i, uPC_fixwind);
  2243. X   }
  2244. X
  2245. X/* Increase the screen size */
  2246. X   uw.uw_x = 0;
  2247. X   uw.uw_y = 0;   /* Leave room for top status line. */
  2248. X   uw.uw_width = uPC_XMAX;      /* 720 */
  2249. X   uw.uw_height = uPC_YMAX;     /* 288 normal--we clobber 12 (top row)*/
  2250. X   uw.uw_uflags = 1;         /* Creates with no border */
  2251. X
  2252. X   IfErrOut (ioctl(0, WIOCSETD, &uw), <0, "ioctl failed on", "WIOCSETD");
  2253. X}
  2254. X
  2255. X
  2256. XuPC_graphics()
  2257. X{
  2258. X/* This routine will clear the uPC_display buffer and window. */
  2259. X   register Scr_type *j;
  2260. X   register int i;
  2261. X
  2262. X   j = (Scr_type *)uPC_display;
  2263. X   i = uPC_YSIZE*uPC_XSIZE + 1;
  2264. X
  2265. X   while (--i)
  2266. X      *j++ = 0;
  2267. X/*
  2268. X   Position the cursor to the bottom of the screen so when we come back to
  2269. X   text mode we are just below the graph.
  2270. X*/
  2271. X   printf ("\033[25;1H");
  2272. X
  2273. X   uPC_ur.ur_dstop = DSTSRC;   /* replace (clear screen). */
  2274. X   IfErrOut (ioctl(0, WIOCRASTOP, &uPC_ur), <0,
  2275. X      "ioctl failed", "WIOCRASTOP");
  2276. X   uPC_ur.ur_dstop = DSTOR;   /* Or in (show text) */
  2277. X}
  2278. X
  2279. X
  2280. XuPC_text()
  2281. X{
  2282. X/* This routine will flush the display. */
  2283. X
  2284. X   IfErrOut (ioctl(0, WIOCRASTOP, &uPC_ur), <0,
  2285. X      "ioctl failed", "WIOCRASTOP");
  2286. X}
  2287. X
  2288. X
  2289. XuPC_linetype(linetype)
  2290. Xint linetype;
  2291. X{
  2292. X/* This routine records the current linetype. */
  2293. X   if (uPC_cur_linetype != linetype) {
  2294. X      uPC_raster_count = 0;
  2295. X      uPC_cur_linetype = linetype;
  2296. X   }
  2297. X}
  2298. X
  2299. X
  2300. XuPC_move(x,y)
  2301. Xunsigned int x,y;
  2302. X{
  2303. X/* This routine just records x and y in uPC_sx, uPC_sy */
  2304. X   uPC_sx = x;
  2305. X   uPC_sy = y;
  2306. X}
  2307. X
  2308. X
  2309. X/* Was just (*(a)|=(b)) */
  2310. X#define uPC_PLOT(a,b)   (uPC_cur_linetype != 0 ? uPC_plot_word (a,b) :\
  2311. X                                *(a)|=(b))
  2312. X
  2313. XuPC_plot_word(a,b)
  2314. XScr_type *a, b;
  2315. X/*
  2316. X   Weak attempt to make line styles.  The real problem is the aspect
  2317. X   ratio.  This routine is called only when a bit is to be turned on in
  2318. X   a horizontal word.  A better line style routine would know something
  2319. X   about the slope of the line around the current point (in order to
  2320. X   change weighting).
  2321. X
  2322. X   This yields 3 working linetypes plus a usable axis line type.
  2323. X*/
  2324. X{
  2325. X/* Various line types */
  2326. X   switch (uPC_cur_linetype) {
  2327. X   case -1:
  2328. X   /* Distinguish between horizontal and vertical axis. */
  2329. X      if (uPC_sx > uPC_XMAX/8 && uPC_sx < 7*uPC_XMAX/8) {
  2330. X      /* Fuzzy tolerance because we don't know exactly where the y axis is */
  2331. X         if (++uPC_raster_count % 2 == 0) *(a) |= b;
  2332. X      }
  2333. X      else {
  2334. X      /* Due to aspect ratio, take every other y pixel and every third x. */
  2335. X         *(a) |= (b & 0x9999);
  2336. X      }
  2337. X   break;
  2338. X   case 1:
  2339. X   case 5:
  2340. X   /* Make a |    |----|    |----| type of line. */
  2341. X      if ((1<<uPC_raster_count) & 0xF0F0) *(a) |= b;
  2342. X      if (++uPC_raster_count > 15) uPC_raster_count = 0;
  2343. X   break;
  2344. X   case 2:
  2345. X   case 6:
  2346. X   /* Make a |----|----|----|--- |    | type of line. */
  2347. X      if ((1<<uPC_raster_count) & 0x0EFFF) *(a) |= b;
  2348. X      if (++uPC_raster_count > 19) uPC_raster_count = 0;
  2349. X   break;
  2350. X   case 3:
  2351. X   case 7:
  2352. X   /* Make a | -  | -  | -  | -  | type of line. */
  2353. X      if ((1<<uPC_raster_count) & 0x4444) *(a) |= b;
  2354. X      if (++uPC_raster_count > 15) uPC_raster_count = 0;
  2355. X   break;
  2356. X   case 4:
  2357. X   case 8:
  2358. X   default:
  2359. X      *(a) |= b;
  2360. X   break;
  2361. X   }
  2362. X}
  2363. X
  2364. XuPC_vector(x,y)
  2365. Xunsigned int x,y;
  2366. X{
  2367. X/* This routine calls line with x,y */
  2368. X   int x1 = uPC_sx, y1=uPC_sy, x2 = x, y2 = y;
  2369. X   register int  c, e, dx, dy, width;
  2370. X   register Scr_type mask, *a;
  2371. X
  2372. X/* Record new sx, sy for next call to the vector routine. */
  2373. X   uPC_sx = x2;
  2374. X   uPC_sy = y2;
  2375. X
  2376. X   a = &uPC_display[(uPC_YSIZE - 1) - y1][x1 >> 4];
  2377. X   mask = lookup[x1 & 0x0f];
  2378. X   width = uPC_width;
  2379. X
  2380. X   if ((dx = x2 - x1) > 0) {
  2381. X      if ((dy = y2 - y1) > 0) {
  2382. X         if (dx > dy) {         /* dx > 0, dy > 0, dx > dy */
  2383. X            dy <<= 1;
  2384. X            e = dy - dx;
  2385. X            c = dx + 2;
  2386. X            dx <<= 1;
  2387. X
  2388. X            while (--c) {
  2389. X               uPC_PLOT(a, mask);
  2390. X               if (e >= 0) {
  2391. X                  (Scr_kluge *)a -= width;
  2392. X                  e -= dx;
  2393. X               }
  2394. X               if (mask & uPC_HIGH_BIT) {
  2395. X                  mask = 1;
  2396. X                  a++;
  2397. X               } else
  2398. X                  mask <<= 1;
  2399. X               e += dy;
  2400. X            }
  2401. X         } else {            /* dx > 0, dy > 0, dx <= dy */
  2402. X            dx <<= 1;
  2403. X            e = dx - dy;
  2404. X            c = dy + 2;
  2405. X            dy <<= 1;
  2406. X
  2407. X            while (--c) {
  2408. X               uPC_PLOT(a, mask);
  2409. X               if (e >= 0) {
  2410. X                  if (mask & uPC_HIGH_BIT) {
  2411. X                     mask = 1;
  2412. X                     a++;
  2413. X                  } else
  2414. X                     mask <<= 1;
  2415. X                  e -= dy;
  2416. X               }
  2417. X               (Scr_kluge *)a -= width;
  2418. X               e += dx;
  2419. X            }
  2420. X         }
  2421. X      } else {
  2422. X         dy = -dy;
  2423. X         if (dx > dy) {         /* dx > 0, dy <= 0, dx > dy */
  2424. X            dy <<= 1;
  2425. X            e = dy - dx;
  2426. X            c = dx + 2;
  2427. X            dx <<= 1;
  2428. X
  2429. X            while (--c) {
  2430. X               uPC_PLOT(a, mask);
  2431. X               if (e >= 0) {
  2432. X                  (Scr_kluge *)a += width;
  2433. X                  e -= dx;
  2434. X               }
  2435. X               if (mask & uPC_HIGH_BIT) {
  2436. X                  mask = 1;
  2437. X                  a++;
  2438. X               } else
  2439. X                  mask <<= 1;
  2440. X               e += dy;
  2441. X            }
  2442. X         } else {            /* dx > 0, dy <= 0, dx <= dy */
  2443. X            dx <<= 1;
  2444. X            e = dx - dy;
  2445. X            c = dy + 2;
  2446. X            dy <<= 1;
  2447. X
  2448. X            while (--c) {
  2449. X               uPC_PLOT(a, mask);
  2450. X               if (e >= 0) {
  2451. X                  if (mask & uPC_HIGH_BIT) {
  2452. X                     mask = 1;
  2453. X                     a++;
  2454. X                  } else
  2455. X                     mask <<= 1;
  2456. X                  e -= dy;
  2457. X               }
  2458. X               (Scr_kluge *)a += width;
  2459. X               e += dx;
  2460. X            }
  2461. X         }
  2462. X      }
  2463. X   } else {
  2464. X      dx = -dx;
  2465. X      if ((dy = y2 - y1) > 0) {
  2466. X         if (dx > dy) {         /* dx <= 0, dy > 0, dx > dy */
  2467. X            dy <<= 1;
  2468. X            e = dy - dx;
  2469. X            c = dx + 2;
  2470. X            dx <<= 1;
  2471. X
  2472. X            while (--c) {
  2473. X               uPC_PLOT(a, mask);
  2474. X               if (e >= 0) {
  2475. X                  (Scr_kluge *)a -= width;
  2476. X                  e -= dx;
  2477. X               }
  2478. X               if (mask & 1) {
  2479. X                  mask = uPC_HIGH_BIT;
  2480. X                  a--;
  2481. X               } else
  2482. X                  mask >>= 1;
  2483. X               e += dy;
  2484. X            }
  2485. X         } else {            /* dx <= 0, dy > 0, dx <= dy */
  2486. X            dx <<= 1;
  2487. X            e = dx - dy;
  2488. X            c = dy + 2;
  2489. X            dy <<= 1;
  2490. X
  2491. X            while (--c) {
  2492. X               uPC_PLOT(a, mask);
  2493. X               if (e >= 0) {
  2494. X                  if (mask & 1) {
  2495. X                     mask = uPC_HIGH_BIT;
  2496. X                     a--;
  2497. X                  } else
  2498. X                     mask >>= 1;
  2499. X                  e -= dy;
  2500. X               }
  2501. X               (Scr_kluge *)a -= width;
  2502. X               e += dx;
  2503. X            }
  2504. X         }
  2505. X      } else {
  2506. X         dy = -dy;
  2507. X         if (dx > dy) {         /* dx <= 0, dy <= 0, dx > dy */
  2508. X            dy <<= 1;
  2509. X            e = dy - dx;
  2510. X            c = dx + 2;
  2511. X            dx <<= 1;
  2512. X
  2513. X            while (--c) {
  2514. X               uPC_PLOT(a, mask);
  2515. X               if (e >= 0) {
  2516. X                  (Scr_kluge *)a += width;
  2517. X                  e -= dx;
  2518. X               }
  2519. X               if (mask & 1) {
  2520. X                  mask = uPC_HIGH_BIT;
  2521. X                  a--;
  2522. X               } else
  2523. X                  mask >>= 1;
  2524. X               e += dy;
  2525. X            }
  2526. X         } else {            /* dx <= 0, dy <= 0, dx <= dy */
  2527. X            dx <<= 1;
  2528. X            e = dx - dy;
  2529. X            c = dy + 2;
  2530. X            dy <<= 1;
  2531. X
  2532. X            while (--c) {
  2533. X               uPC_PLOT(a, mask);
  2534. X               if (e >= 0) {
  2535. X                  if (mask & 1) {
  2536. X                     mask = uPC_HIGH_BIT;
  2537. X                     a--;
  2538. X                  } else
  2539. X                     mask >>= 1;
  2540. X                  e -= dy;
  2541. X               }
  2542. X               (Scr_kluge *)a += width;
  2543. X               e += dx;
  2544. X            }
  2545. X         }
  2546. X      }
  2547. X   }
  2548. X}
  2549. X
  2550. X
  2551. X#ifdef uPC_NOT_USED
  2552. X/* Added by Russell Lang, eln272v@monu1.cc.monash.oz */
  2553. X   This placement to the nearest character cell worked, and I'm leaving
  2554. X   it here so the calculations involved won't be lost!  (jdc)
  2555. X*/
  2556. XuPC_put_text(x,y,str)
  2557. Xunsigned int x,y;
  2558. Xchar str[];
  2559. X{
  2560. X/* This routine puts the text at the cursor location nearest
  2561. X   to (x,y).  Obviously the exact postion would look better */
  2562. X
  2563. X/* Just use the ANSI escape sequence CUP (iswind said that was ok!) */
  2564. X   printf ("\033[%d;%dH%s\033[25;1H", (int)(24-(y-uPC_VCHAR/2)*25/uPC_YMAX), 
  2565. X                (int)(x*80/uPC_XMAX), str); 
  2566. X   fflush (stdout);
  2567. X}
  2568. X#endif
  2569. X
  2570. X
  2571. XuPC_put_text(x,y,str)
  2572. Xunsigned int x,y;
  2573. Xchar str[];
  2574. X{
  2575. X   if (uPC_angle == 1)
  2576. X      x += uPC_VCHAR/2;
  2577. X   else
  2578. X      y -= uPC_VCHAR/2;
  2579. X
  2580. X   switch (uPC_angle) {
  2581. X      case 0:
  2582. X         for (; *str; ++str, x += uPC_HCHAR)
  2583. X            uPC_putc (x, y, *str, uPC_angle);
  2584. X      break;
  2585. X      case 1:
  2586. X         for (; *str; ++str, y += uPC_HCHAR)
  2587. X            uPC_putc (x, y, *str, uPC_angle);
  2588. X      break;
  2589. X   }
  2590. X}
  2591. X
  2592. X
  2593. XuPC_putc (x, y, c, angle)
  2594. Xunsigned int x, y;
  2595. Xint c, angle;
  2596. X/*
  2597. X   Put a character at an x,y location in the bit map (using the font5x7
  2598. X   array.  This is mostly just copied from the epson driver.
  2599. X*/
  2600. X{
  2601. X   int i, j, k;
  2602. X   register Scr_type mask, *a;
  2603. X   char fc;
  2604. X   unsigned int pixelon;
  2605. X
  2606. X   i = c - ' ';
  2607. X   for(j=0; j < 9; j++) {
  2608. X      fc = font5x7[i][j];
  2609. X      for (k=0; k < 5; k++) {
  2610. X         pixelon = ((unsigned int)(fc))>>k & 1;
  2611. X         if (pixelon) {
  2612. X            switch (angle) {
  2613. X            case 0:
  2614. X               mask = lookup[x+k+1 & 0x0f];
  2615. X               a = &uPC_display[(uPC_YSIZE - 1) - (y+j)][(x+k+1) >> 4];
  2616. X            break;
  2617. X            case 1:
  2618. X               mask = lookup[x-j & 0x0f];
  2619. X               a = &uPC_display[(uPC_YSIZE - 1) - (y+k+1)][(x-j) >> 4];
  2620. X            break;
  2621. X            }
  2622. X            *(a) |= (mask);  /* see uPC_PLOT macro */
  2623. X         }
  2624. X      }
  2625. X   }
  2626. X}
  2627. X
  2628. X
  2629. XuPC_text_angle (ang)
  2630. Xint ang;
  2631. X{
  2632. X   uPC_angle = ang;
  2633. X   return TRUE;
  2634. X}
  2635. X
  2636. X
  2637. XuPC_reset()
  2638. X{
  2639. X/* Reset window to normal size. */
  2640. X   uPC_fixwind (0);
  2641. X}
  2642. X
  2643. X
  2644. X
  2645. XuPC_fixwind(signo)
  2646. Xint signo;
  2647. X{
  2648. X   static struct uwdata wreset = { 0, 12, 720, 288, 0x1};
  2649. X   struct utdata ut;
  2650. X
  2651. X/* Reset the window to the right size. */
  2652. X   ioctl(0, WIOCSETD, &wreset);   /* 0, not wncur here! */
  2653. X
  2654. X/* Scroll the screen once. (avoids typing over the same line) */
  2655. X   fprintf (stderr, "\n");
  2656. X
  2657. X   if (signo) {
  2658. X      if (signo == SIGILL || signo == SIGTRAP || signo == SIGPWR)
  2659. X         signal (signo, SIG_DFL);
  2660. X      kill (0,signo);  /* Redo the signal (as if we never trapped it). */
  2661. X   }
  2662. X}
  2663. *-*-END-of-term/unixpc.trm-*-*
  2664. echo x - term/unixplot.trm
  2665. sed 's/^X//' >term/unixplot.trm <<'*-*-END-of-term/unixplot.trm-*-*'
  2666. X/* GNUPLOT -- unixplot.trm */
  2667. X/*
  2668. X * Copyright (C) 1990   
  2669. X *
  2670. X * Permission to use, copy, and distribute this software and its
  2671. X * documentation for any purpose with or without fee is hereby granted, 
  2672. X * provided that the above copyright notice appear in all copies and 
  2673. X * that both that copyright notice and this permission notice appear 
  2674. X * in supporting documentation.
  2675. X *
  2676. X * Permission to modify the software is granted, but not the right to
  2677. X * distribute the modified code.  Modifications are to be distributed 
  2678. X * as patches to released version.
  2679. X *  
  2680. X * This software  is provided "as is" without express or implied warranty.
  2681. X * 
  2682. X * This file is included by ../term.c.
  2683. X *
  2684. X * This terminal driver supports:
  2685. X *  Unix plot(5) graphics language
  2686. X *
  2687. X * AUTHORS
  2688. X *  Colin Kelley, Thomas Williams, Russell Lang
  2689. X * 
  2690. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  2691. X * 
  2692. X */
  2693. X
  2694. X/*
  2695. XUnixplot library writes to stdout.  A fix was put in place by
  2696. X..!arizona!naucse!jdc to let set term and set output redirect
  2697. Xstdout.  All other terminals write to outfile.
  2698. X*/
  2699. X
  2700. X#define UP_XMAX 4096
  2701. X#define UP_YMAX 4096
  2702. X
  2703. X#define UP_XLAST (UP_XMAX - 1)
  2704. X#define UP_YLAST (UP_YMAX - 1)
  2705. X
  2706. X#define UP_VCHAR (UP_YMAX/30)    /* just a guess--no way to know this! */
  2707. X#define UP_HCHAR (UP_XMAX/60)    /* just a guess--no way to know this! */
  2708. X#define UP_VTIC (UP_YMAX/80)
  2709. X#define UP_HTIC (UP_XMAX/80)
  2710. X
  2711. XUP_init()
  2712. X{
  2713. X    openpl();
  2714. X    space(0, 0, UP_XMAX, UP_YMAX);
  2715. X}
  2716. X
  2717. X
  2718. XUP_graphics()
  2719. X{
  2720. X    erase();
  2721. X}
  2722. X
  2723. X
  2724. XUP_text()
  2725. X{
  2726. X}
  2727. X
  2728. X
  2729. XUP_linetype(linetype)
  2730. Xint linetype;
  2731. X{
  2732. Xstatic char *lt[2+5] = {"solid", "longdashed", "solid", "dotted","shortdashed",
  2733. X    "dotdashed", "longdashed"};
  2734. X
  2735. X    if (linetype >= 5)
  2736. X        linetype %= 5;
  2737. X    linemod(lt[linetype+2]);
  2738. X}
  2739. X
  2740. X
  2741. XUP_move(x,y)
  2742. Xunsigned int x,y;
  2743. X{
  2744. X    move(x,y);
  2745. X}
  2746. X
  2747. X
  2748. XUP_vector(x,y)
  2749. Xunsigned int x,y;
  2750. X{
  2751. X    cont(x,y);
  2752. X}
  2753. X
  2754. X
  2755. XUP_put_text(x,y,str)
  2756. Xunsigned int x,y;
  2757. Xchar str[];
  2758. X{
  2759. X    UP_move(x+UP_HCHAR/2,y+UP_VCHAR/5);
  2760. X    label(str);
  2761. X}
  2762. X
  2763. XUP_reset()
  2764. X{
  2765. X    closepl();
  2766. X}
  2767. X
  2768. *-*-END-of-term/unixplot.trm-*-*
  2769. echo x - term/v384.trm
  2770. sed 's/^X//' >term/v384.trm <<'*-*-END-of-term/v384.trm-*-*'
  2771. X/* GNUPLOT - v384.trm */
  2772. X/*
  2773. X * Copyright (C) 1990   
  2774. X *
  2775. X * Permission to use, copy, and distribute this software and its
  2776. X * documentation for any purpose with or without fee is hereby granted, 
  2777. X * provided that the above copyright notice appear in all copies and 
  2778. X * that both that copyright notice and this permission notice appear 
  2779. X * in supporting documentation.
  2780. X *
  2781. X * Permission to modify the software is granted, but not the right to
  2782. X * distribute the modified code.  Modifications are to be distributed 
  2783. X * as patches to released version.
  2784. X *  
  2785. X * This software  is provided "as is" without express or implied warranty.
  2786. X * 
  2787. X * This file is included by ../term.c.
  2788. X *
  2789. X * This terminal driver supports:
  2790. X *  Vectrix 384 - works with tandy color printer as well
  2791. X *
  2792. X * AUTHORS
  2793. X *   roland@moncskermit.OZ (Roland Yap) 
  2794. X * 
  2795. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  2796. X * 
  2797. X */
  2798. X
  2799. X/*
  2800. X *    Vectrix 384 driver - works with tandy color printer as well
  2801. X *  in reverse printing 8 color mode.
  2802. X *  This doesn't work on Vectrix 128 because it redefines the
  2803. X *  color table. It can be hacked to work on the 128 by changing
  2804. X *  the colours but then it will probably not print best. The color
  2805. X *  table is purposely designed so that it will print well
  2806. X *
  2807. X */
  2808. X
  2809. X#define V384_XMAX 630
  2810. X#define V384_YMAX 480
  2811. X
  2812. X#define V384_XLAST (V384_XMAX - 1)
  2813. X#define V384_YLAST (V384_YMAX - 1)
  2814. X
  2815. X#define V384_VCHAR    12
  2816. X#define V384_HCHAR    7
  2817. X#define V384_VTIC    8
  2818. X#define V384_HTIC    7
  2819. X
  2820. X
  2821. XV384_init()
  2822. X{
  2823. X    fprintf(outfile,"%c%c  G0   \n",27,18);
  2824. X    fprintf(outfile,"Q 0 8\n");
  2825. X    fprintf(outfile,"0 0 0\n");
  2826. X    fprintf(outfile,"255 0 0\n");
  2827. X    fprintf(outfile,"0 255 0\n");
  2828. X    fprintf(outfile,"0 0 255\n");
  2829. X    fprintf(outfile,"0 255 255\n");
  2830. X    fprintf(outfile,"255 0 255\n");
  2831. X    fprintf(outfile,"255 255 0\n");
  2832. X    fprintf(outfile,"255 255 255\n");
  2833. X}
  2834. X
  2835. X
  2836. XV384_graphics()
  2837. X{
  2838. X    fprintf(outfile,"%c%c E0 RE N 65535\n",27,18);
  2839. X}
  2840. X
  2841. X
  2842. XV384_text()
  2843. X{
  2844. X    fprintf(outfile,"%c%c\n",27,17);
  2845. X}
  2846. X
  2847. X
  2848. XV384_linetype(linetype)
  2849. Xint linetype;
  2850. X{
  2851. Xstatic int color[]= {
  2852. X        1 /* red */,
  2853. X        2 /* green */,
  2854. X        3 /* blue */,
  2855. X        4 /* cyan */,
  2856. X        5 /* magenta */,
  2857. X        6 /* yellow */, /* not a good color so not in use at the moment */
  2858. X        7 /* white */
  2859. X    };
  2860. X        
  2861. X    if (linetype < 0)
  2862. X        linetype=6;
  2863. X    else
  2864. X        linetype %= 5;
  2865. X    fprintf(outfile,"C %d\n",color[linetype]);
  2866. X}
  2867. X
  2868. X
  2869. XV384_move(x,y)
  2870. Xunsigned int x,y;
  2871. X{
  2872. X    fprintf(outfile,"M %d %d\n",x+20,y);
  2873. X}
  2874. X
  2875. X
  2876. XV384_vector(x,y)
  2877. Xunsigned int x,y;
  2878. X{
  2879. X    fprintf(outfile,"L %d %d\n",x+20,y);
  2880. X}
  2881. X
  2882. X
  2883. XV384_put_text (x, y, str)
  2884. Xunsigned int x, y;
  2885. Xchar str[];
  2886. X{
  2887. X    V384_move (x, y + V384_VCHAR/2);
  2888. X    fprintf (outfile, "$%s\n", str);
  2889. X}
  2890. X
  2891. X
  2892. XV384_reset()
  2893. X{
  2894. X}
  2895. X
  2896. *-*-END-of-term/v384.trm-*-*
  2897. exit
  2898.  
  2899.  
  2900.