File: pc.trm

package info (click to toggle)
gnuplot 3.5beta6.340-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 4,792 kB
  • ctags: 4,205
  • sloc: ansic: 41,878; asm: 539; makefile: 498; objc: 379; csh: 297; sh: 277; pascal: 194; perl: 138; lisp: 88
file content (341 lines) | stat: -rw-r--r-- 9,192 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/*
 * $Id: pc.trm,v 1.16 1997/04/10 02:34:27 drd Exp $
 *
 */

/* GNUPLOT - pc.trm */
/*
 * Copyright (C) 1990 - 1993, 1997
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the modified code.  Modifications are to be distributed
 * as patches to released version.
 *
 * This software  is provided "as is" without express or implied warranty.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Under Microsoft C
 *      cga, egabios, egalib, vgabios, hercules, corona325, att
 *  Under Turboc C
 *      cga, ega/vga, vgamono, svga, mcga, hercules, att
 *
 * AUTHORS
 *  Colin Kelley, Thomas Williams, William Wilson, Russell Lang
 *  modified by David J. Liu (liu@csb.yale.edu) for version 3.6
 *
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 *
 * Because only one compiler is used to generate gnuplot.exe
 * and the type of the single graphics board is auto-detected,
 * we can combine all these parts into one terminal type: PC
 * and let the computer take care of the rest.  -- DJL
 *
 * Since I don't have MicroSoft C, I assume it would define MSC.
 * Please correct it if you are using MS C.  Thank you.  -- DJL
 *
 */

/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

#ifndef GOT_DRIVER_H
#include "driver.h"
#endif

#ifdef TERM_REGISTER
register_term(pc)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void PC_text __PROTO((void));
TERM_PUBLIC void PC_reset __PROTO((void));
TERM_PUBLIC void PC_init __PROTO((void));
TERM_PUBLIC void PC_graphics __PROTO((void));
TERM_PUBLIC void PC_linetype __PROTO((int linetype));
TERM_PUBLIC void PC_move __PROTO((int x, int y));
TERM_PUBLIC void PC_vector __PROTO((int x, int y));
TERM_PUBLIC void PC_put_text __PROTO((int x, int y, char *str));
TERM_PUBLIC int PC_text_angle __PROTO((int ang));

#define PC_HCHAR FNT5X9_HCHAR
#define PC_VCHAR FNT5X9_VCHAR
#define PC_HTIC 5
#define PC_VTIC 4
#define PC_XMAX 100 /* These two entries are just place holders. */
#define PC_YMAX 100 /* The actual values will be found in init.  */
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

#ifdef __TURBOC__
static int huge detect_svga __PROTO((void));
#endif /* __TURBOC__ */

#include <string.h>
#include <stdlib.h>
#ifdef __TURBOC__
#include <graphics.h>
#include <conio.h>
#include <dos.h>
#endif /* __TURBOC__ */
#ifdef MSC
#include "mcega.h"
#endif /* MSC */

static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
static int vga_color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};

static int pc_driver, pc_mode;
static int graphics_on = FALSE, pc_graphics = FALSE;
static int startx, starty, pc_lastx, pc_lasty, pc_colors;
static int pc_angle, pc_text_size, pc_text_dir, pc_corscreen = -1;


#ifdef __TURBOC__
extern int far _Cdecl SVGA_driver_far[] ;
#endif /* __TURBOC__ */

static int huge detect_svga(void)
{
  return 0; /* the default mode, just a place holder */
}

void PC_setup() /* called from the beginning of main() */
{
  int i,t,x,y;
  char pc_modename[9];

/* First link all BRI dribers, then detect the display card. */
/* If environment PCTRM is set, try initiate the card/mode.  */

  strncpy(pc_modename,getenv("PCTRM"),8); /* special instruction on mode */

#ifdef __TURBOC__
/* Some of this code including BGI drivers are copyright Borland Intl. */
  registerfarbgidriver(EGAVGA_driver_far);
  registerfarbgidriver(CGA_driver_far);
  registerfarbgidriver(Herc_driver_far);
  registerfarbgidriver(ATT_driver_far);
  registerfarbgidriver(PC3270_driver_far);
  pc_driver=DETECT; detectgraph(&pc_driver,&pc_mode);
  if (graphresult())
    { fprintf(stderr,"Unable to initialize graphics.\n"); return; }
#ifdef BGI_NAME
#define LAST_BGI 10 /* the highest standard pc_driver value, see graphics.h */
#define LAST_SVGA_MODE 6 /* the last mode of the SVGA.BGI */
  if ((pc_driver==VGA)&&(pc_modename[0]=='S')) /* test SVGA if we have VGA */
    {
      installuserdriver(BGI_NAME,&detect_svga) ;
      registerfarbgidriver(SVGA_driver_far) ;
      pc_driver=DETECT ; initgraph(&pc_driver,&pc_mode,"") ;
/* The following code, which is independent of the actual SVGA.BGI used, */
/* tries to find a mode of width defined in the environment variable PCTRM */
      if (pc_driver>LAST_BGI) /* success */
        {
          sscanf(pc_modename,"S%d",&t);
          switch(t) {
            case 800  : break; /* S800  */
            case 1024 : break; /* S1024 */
            case 1280 : break; /* S1280 */
            default: t = 640;  /* 640x480 */
          }
          for (i=0;i<=LAST_SVGA_MODE;i++)
            {
              setgraphmode(i);
              if ((getmaxx()+1==t)&&(getmaxcolor()>14)) pc_mode=i;
            }
          setgraphmode(pc_mode) ;
          if (graphresult()) /* error, go back to VGA */
            { pc_driver = VGA; pc_mode = 4; }
        }
    } /* SVGA tested */
  if (pc_driver<=LAST_BGI)
#endif /* BGI_NAME */
    initgraph(&pc_driver,&pc_mode,"");
  pc_colors = getmaxcolor()+1;
  pc_lastx = getmaxx(); pc_lasty = getmaxy();
  restorecrtmode();
  clrscr();
#endif /* __TURBOC__ */
  x = pc_lastx+1 ; y = pc_lasty+1 ;
  fprintf(stderr,"\tScreen of %d x %d pixels and %d colors.\n",x,y,pc_colors);
  pc_graphics = TRUE;
}

TERM_PUBLIC void PC_init()
{
  char *pathp;

  if(!pc_graphics) {
    fprintf(stderr,"Unable to initialize graphics.\n");
    term=0; return;
  }
  pc_text_size = (pc_lasty>590)?2:1; /* Double the tic/font sizes. */
  term_tbl[term].h_char = PC_HCHAR;
  term_tbl[term].v_char = PC_VCHAR;
  term_tbl[term].h_tic  = PC_HTIC*pc_text_size;
  term_tbl[term].v_tic  = PC_VTIC*pc_text_size;
  term_tbl[term].xmax = pc_lastx+1;
  term_tbl[term].ymax = pc_lasty+1;
#ifdef __TURBOC__
  setgraphmode(pc_mode);
  settextstyle(DEFAULT_FONT,HORIZ_DIR,pc_text_size);
  term_tbl[term].h_char = textheight("X"); /* overriding the default */
  term_tbl[term].v_char = textwidth("X");  /* overriding the default */
#endif /* __TURBOC__ */
#ifdef MSC
#endif /* MSC */
}

TERM_PUBLIC void PC_graphics()
{
  graphics_on = TRUE;
#ifdef __TURBOC__
  setgraphmode(pc_mode);
#endif /* __TURBOC__ */
#ifdef MSC
  if (pc_corscreen==-1) Vmode(18); /* VGA */
  else { grinit(corscreen); grandtx(); } /* corolla */
#endif /* MSC */
}

TERM_PUBLIC void PC_linetype(linetype)
{
  if (pc_colors>14) /* 16 or more colors */
    {
      if (linetype >= 13) linetype %= 13;
#ifdef __TURBOC__
      setcolor(vga_color[linetype+2]);
#endif /* __TURBOC__ */
#ifdef MSC
#endif /* MSC */
    }
  else /* MONO */
    {
      if (linetype >= 5)  linetype %= 5;
#ifdef __TURBOC__
      setlinestyle(4,pattern[linetype+2],1);
#endif /* __TURBOC__ */
#ifdef MSC
  if (pc_corscreen!=-1) Cor_mask(pattern[linetype+2]);
#endif /* MSC */
    }
}

TERM_PUBLIC void PC_move(x,y)
  int x,y;
{
#ifdef __TURBOC__
  moveto(x,pc_lasty-y);
#endif /* __TURBOC__ */
#ifdef MSC
#endif /* MSC */
  startx = x;
  starty = y;
}

TERM_PUBLIC void PC_vector(x,y)
  int x,y;
{
#ifdef __TURBOC__
  lineto(x,pc_lasty-y);
#endif /* __TURBOC__ */
#ifdef MSC
  if (pc_corscreen!=-1) Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
#endif /* MSC */
  startx = x;
  starty = y;
}

TERM_PUBLIC void PC_reset()
{
  graphics_on = FALSE;
#ifdef __TURBOC__
  restorecrtmode();
  clrscr();
#endif /* __TURBOC__ */
#ifdef MSC
  Vmode(3);
#endif /* MSC */
}

TERM_PUBLIC void PC_text()
{
  if (graphics_on) {
    graphics_on = FALSE;
    (void)getch();
#ifdef __TURBOC__
  restorecrtmode();
  clrscr();
#endif /* __TURBOC__ */
#ifdef MSC
  if (pc_corscreen!=-1) { grreset(); txonly(); }
  Vmode(3);
#endif /* MSC */
  }
}

TERM_PUBLIC int PC_text_angle(ang)
int ang;
{
  switch(ang) {
    case 0 : pc_text_dir = HORIZ_DIR; break;
    case 1 : pc_text_dir =  VERT_DIR; break;
  }
  return TRUE;
}

TERM_PUBLIC void PC_put_text(x,y,str)
  int x, y;
  char *str;
{
#ifdef __TURBOC__
  settextstyle(DEFAULT_FONT,pc_text_dir,pc_text_size);
  outtextxy(x,pc_lasty-y-(pc_text_dir?textwidth(str):(textheight(str)/2)),str);
#endif /* __TURBOC__ */
#ifdef MSC
#endif /* MSC */
}

#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(pc_driver)
    "pc", "IBM PC/Clone running DOS",
	   PC_XMAX, PC_YMAX, PC_VCHAR, PC_HCHAR,
	   PC_VTIC, PC_HTIC, options_null, PC_init, PC_reset,
	   PC_text, null_scale, PC_graphics, PC_move, PC_vector,
	   PC_linetype, PC_put_text, PC_text_angle,
	   null_justify_text, line_and_point, do_arrow, set_font_null
TERM_TABLE_END(pc_driver)

#undef LAST_TERM
#define LAST_TERM pc_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(pc)
"1 pc",
"?set terminal pc",
"?set term pc",
"?terminal pc",
"?term pc",
"?pc",
" The `pc` terminal driver supports PCs with arbitrary graphics boards, which",
" will be automatically detected.  It should be used only if you are not using",
" the gcc or Zortec C/C++ compilers."
END_HELP(pc)
#endif