home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / GPT34SRC / TERM / EPSON.TRM < prev    next >
Text File  |  1993-05-11  |  14KB  |  556 lines

  1. /*
  2.  * $Id: epson.trm%v 3.38.2.124 1993/05/04 22:53:47 woo Exp woo $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - epson.trm */
  7. /*
  8.  * Copyright (C) 1990 - 1993   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports:
  25.  *  epson_lx800, nec_cp6, starc,
  26.  *  epson_60dpi, tandy_60dpi
  27.  *  epson_180dpi
  28.  *
  29.  * AUTHORS
  30.  *  Russell Lang
  31.  *  William Wilson
  32.  *
  33.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  34.  * 
  35.  */
  36.  
  37. /* The following epson lx800 driver uses generic bit mapped graphics
  38.    routines to build up a bit map in memory. */
  39. /* by Russell Lang, rjl@monu1.cc.monash.edu.au */
  40. /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  41. /* EPSON_init changes outfile to binary mode on PC's */
  42.  
  43. #ifdef EPSONP
  44.  
  45. #define EPSONXMAX    512 
  46. #define EPSONYMAX    384
  47.  
  48. #define EPSONXLAST (EPSONXMAX - 1)
  49. #define EPSONYLAST (EPSONYMAX - 1)
  50.  
  51. #define EPSONVCHAR        FNT5X9_VCHAR      
  52. #define EPSONHCHAR        FNT5X9_HCHAR        
  53. #define EPSONVTIC        6
  54. #define EPSONHTIC        6
  55.  
  56. EPSONinit()
  57. {
  58. #ifdef REOPEN_BINARY
  59.     reopen_binary();
  60. #endif
  61. }
  62.  
  63.  
  64. EPSONgraphics()
  65. {
  66.     b_charsize(FNT5X9);
  67.     b_makebitmap((unsigned int)(EPSONXMAX*xsize),
  68.                  (unsigned int)(EPSONYMAX*ysize),1);
  69. }
  70.  
  71.  
  72. EPSONtext()
  73. {
  74.     epson_dump();
  75.     b_freebitmap();
  76. }
  77.  
  78.  
  79. #define EPSONlinetype b_setlinetype
  80. #define EPSONmove b_move
  81. #define EPSONvector b_vector
  82. #define EPSONput_text b_put_text
  83. #define EPSON_text_angle b_text_angle
  84.  
  85. EPSONreset()
  86. {
  87. #ifdef vms
  88.     fflush_binary();
  89. #endif
  90. }
  91.  
  92.  
  93. /* output file must be binary mode for epson_dump */
  94. epson_dump()
  95. {
  96.   register unsigned int x;
  97.   int j;
  98.     for (j=(b_ysize/8)-1; j>=0; j--) {
  99.         /* select plotter graphics mode (square pixels) */
  100.         fprintf(outfile,"\033J\030");    /* line feed 8/72" = 8 dots */
  101.         fprintf(outfile,"\r\033*\005");
  102.         (void) fputc((char)(b_xsize%256),outfile);
  103.         (void) fputc((char)(b_xsize/256),outfile);
  104.         for (x=0; x<b_xsize; x++) {
  105.             (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  106.         }
  107.     }
  108. #ifdef PC
  109.     fprintf(stderr,"Print using: COPY /B\n");
  110. #endif
  111. }
  112.  
  113. #endif /* EPSONP */
  114.  
  115.  
  116. /* The following NEC CP6 Pinwriter driver uses generic bit mapped graphics
  117.    routines to build up a bit map in memory. */
  118. /* by Russell Lang, rjl@monu1.cc.monash.edu.au */
  119. /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  120. /* NECinit changes outfile to binary mode for PC's */
  121.  
  122. /* Add a Monochrome NEC printer (for faster speed and line types) jdc */
  123.  
  124. #ifdef NEC
  125.  
  126. #define NECXMAX    400 
  127. #define NECYMAX    320
  128.  
  129. #define NECXLAST (NECXMAX - 1)
  130. #define NECYLAST (NECYMAX - 1)
  131.  
  132. #define NECVCHAR        FNT5X9_VCHAR      
  133. #define NECHCHAR        FNT5X9_HCHAR        
  134. #define NECVTIC        6
  135. #define NECHTIC        6
  136.  
  137. /* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
  138. static unsigned int neccolor[] = {1,8,4,2,10,12,6,14};
  139. static unsigned int necpcolor[]= {0,2,1,4};
  140.  
  141. static int NECmode;
  142.  
  143. NECoptions()
  144. {
  145.     if( END_OF_COMMAND ) {
  146.         strcpy(term_options,"monochrome");
  147.         NECmode='m';
  148.     } else
  149.     if( almost_equals(c_token,"m$onochrome") ) {
  150.         c_token++;
  151.         strcpy(term_options,"monochrome");
  152.         NECmode='m';
  153.     } else
  154.     if( almost_equals(c_token,"c$olor") ) {
  155.         c_token++;
  156.         strcpy(term_options,"color");
  157.         NECmode='c';
  158.     } else
  159.     if( almost_equals(c_token,"d$raft") ) {
  160.         c_token++;
  161.         strcpy(term_options,"draft");
  162.         NECmode='d';
  163.     } else {
  164.     /* error, but since the terminal is already set, default to mono */
  165.         strcpy(term_options,"monochrome");
  166.         NECmode='m';
  167.         int_error("modes: color, monochrome, draft",c_token);
  168.     }
  169. }
  170.  
  171. NECinit()
  172. {
  173. #ifdef REOPEN_BINARY
  174.     reopen_binary();
  175. #endif
  176. }
  177.  
  178. NECgraphics()
  179. {
  180.     b_charsize(FNT5X9);
  181.     b_makebitmap((unsigned int)(NECXMAX*xsize),
  182.              (unsigned int)(NECYMAX*ysize),(NECmode=='c' ? 4 : 1));
  183. }
  184.  
  185. NECtext()
  186. {
  187.     if( NECmode=='d' ) {
  188.         nec_draft_dump();
  189.     } else {
  190.     nec_dump();
  191.     }
  192.     b_freebitmap();
  193. }
  194.  
  195. NEClinetype(linetype)
  196. int linetype;
  197. {
  198.     if( NECmode=='c' ) {
  199.     if (linetype>=6)
  200.         linetype %= 6;
  201.     b_setvalue(neccolor[linetype+2]);
  202.     } else {
  203.         b_setlinetype(linetype);
  204.     }
  205. }
  206.  
  207. #define NECmove b_move
  208. #define NECvector b_vector
  209. #define NECput_text b_put_text
  210. #define NEC_text_angle b_text_angle
  211.  
  212.     
  213. NECreset()
  214. {
  215. #ifdef vms
  216.     fflush_binary();
  217. #endif
  218. }
  219.  
  220.  
  221. /* output file must be binary mode for nec_dump */
  222. nec_dump()
  223. {
  224. unsigned int x;
  225. unsigned int plane,offset;
  226. int j;
  227. unsigned int column8;
  228. unsigned long column24;
  229. char column3, column2, column1;
  230.     fprintf(outfile,"\033P\033l\005");  /* 10cpi, left margin 5 char */
  231.     for (j=(b_ysize/8)-1;j>=0;j--) {
  232.             fprintf(outfile,"\033J\030");  /* 24/180" line feed */
  233.             for (plane=0; plane<b_planes; plane++) {
  234.                 offset=plane*b_psize;
  235.                 if (b_planes>1) {
  236.                     /* select colour for plane */
  237.                     fprintf(outfile,"\033r");
  238.                     (void) fputc((char)necpcolor[plane],outfile);
  239.                 }
  240.                 /* select plotter graphics mode (square pixels) */
  241.                 fprintf(outfile,"\r\033*\047");
  242.                 (void) fputc((char)((b_xsize*3)%256),outfile);
  243.                 (void) fputc((char)((b_xsize*3)/256),outfile);
  244.                 for (x=0; x<b_xsize; x++) {
  245.                     column8= (unsigned int)(*((*b_p)[j+offset]+x));
  246.                     column24=0;
  247.                     if (column8&0x01) column24|=(long)0x000007;
  248.                     if (column8&0x02) column24|=(long)0x000038;
  249.                     if (column8&0x04) column24|=(long)0x0001c0;
  250.                     if (column8&0x08) column24|=(long)0x000e00;
  251.                     if (column8&0x10) column24|=(long)0x007000;
  252.                     if (column8&0x20) column24|=(long)0x038000;
  253.                     if (column8&0x40) column24|=(long)0x1c0000;
  254.                     if (column8&0x80) column24|=(long)0xe00000;
  255.                     column1 = (char) ( column24      & (long)0xff);
  256.                     column2 = (char) ((column24>>8)  & (long)0xff);
  257.                     column3 = (char) ((column24>>16) & (long)0xff);
  258.                     (void) fputc(column3,outfile);
  259.                     (void) fputc(column2,outfile);
  260.                     (void) fputc(column1,outfile);
  261.                     (void) fputc(column3,outfile);
  262.                     (void) fputc(column2,outfile);
  263.                     (void) fputc(column1,outfile);
  264.                     (void) fputc(column3,outfile);
  265.                     (void) fputc(column2,outfile);
  266.                     (void) fputc(column1,outfile);
  267.                 }
  268.             }
  269.     }
  270.     fprintf(outfile,"\r\033l");
  271.     (void) fputc('\0',outfile);                /* set left margin to 0 */
  272.     if (b_planes > 1) {
  273.         fprintf(outfile,"\033r");
  274.         (void) fputc('\0',outfile);                /* set color to black */
  275.     }
  276. #ifdef PC
  277.     fprintf(stderr,"Print using: COPY /B\n");
  278. #endif
  279. #ifdef vms
  280.     fflush_binary();
  281. #endif
  282. }
  283.  
  284. /* output file must be binary mode for nec_dump */
  285. nec_draft_dump()
  286. {
  287. unsigned int x;
  288. unsigned int plane,offset;
  289. int j;
  290.     fprintf(outfile,"\033P\033l\005\r");  /* 10cpi, left margin 5 char */
  291.     for (j=(b_ysize/8)-1;j>=0;j--) {
  292.             fprintf(outfile,"\033J\030");  /* 24/180" line feed */
  293.             for (plane=0; plane<b_planes; plane++) {
  294.                 offset=plane*b_psize;
  295.                 if (b_planes>1) {
  296.                     /* select colour for plane */
  297.                     fprintf(outfile,"\033r");
  298.                     (void) fputc((char)necpcolor[plane],outfile);
  299.                 }
  300.                 /* select plotter graphics mode (square pixels) */
  301.                 fprintf(outfile,"\r\033*");
  302.                 (void) fputc('\0',outfile);
  303.                 (void) fputc((char)(b_xsize%256),outfile);
  304.                 (void) fputc((char)(b_xsize/256),outfile);
  305.                 for (x=0; x<b_xsize; x++) {
  306.                     (void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
  307.                 }
  308.             }
  309.     }
  310.     fprintf(outfile,"\r\033l");
  311.     (void) fputc('\0',outfile);                /* set left margin to 0 */
  312.     if (b_planes > 1) {
  313.         fprintf(outfile,"\033r");
  314.         (void) fputc('\0',outfile);                /* set color to black */
  315.     }
  316. #ifdef PC
  317.     fprintf(stderr,"Print using: COPY /B\n");
  318. #endif
  319. }
  320.  
  321. #endif /* NEC */
  322.  
  323. #ifdef STARC
  324. /* The following Star color driver uses generic bit mapped graphics
  325.    routines to build up a bit map in memory. */
  326. /* Star Color changes made by William Wilson, wew@naucse.cse.nau.edu */
  327. /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  328. /* STARC_init changes outfile to binary mode on PC's */
  329.  
  330. #define STARCXMAX    512 
  331. #define STARCYMAX    384
  332.  
  333. #define STARCXLAST (STARCXMAX - 1)
  334. #define STARCYLAST (STARCYMAX - 1)
  335.  
  336. #define STARCVCHAR        FNT5X9_VCHAR      
  337. #define STARCHCHAR        FNT5X9_HCHAR        
  338. #define STARCVTIC        6
  339. #define STARCHTIC        6
  340.  
  341. /* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
  342. static unsigned int STARCcolor[] = {1,8,4,2,10,12,6,14};
  343. static unsigned int STARCpcolor[]= {0,2,1,4};
  344.  
  345. STARCinit()
  346. {
  347. #ifdef REOPEN_BINARY
  348.     reopen_binary();
  349. #endif
  350. }
  351.  
  352.  
  353. STARCgraphics()
  354. {
  355.     b_charsize(FNT5X9);
  356.     b_makebitmap((unsigned int)(STARCXMAX*xsize),
  357.                  (unsigned int)(STARCYMAX*ysize),4);
  358. }
  359.  
  360.  
  361. STARCtext()
  362. {
  363.     STARC_dump();
  364.     b_freebitmap();
  365. }
  366.  
  367. STARClinetype(linetype)
  368. int linetype;
  369. {
  370.     if (linetype>=6)
  371.         linetype %= 6;
  372.     b_setvalue(STARCcolor[linetype+2]);
  373. }
  374.  
  375.  
  376. #define STARCmove b_move
  377. #define STARCvector b_vector
  378. #define STARCput_text b_put_text
  379. #define STARC_text_angle b_text_angle
  380.  
  381. STARCreset()
  382. {
  383. #ifdef vms
  384.     fflush_binary();
  385. #endif
  386. }
  387.  
  388.  
  389. /* output file must be binary mode for STARC_dump */
  390. STARC_dump()
  391. {
  392. unsigned int x;
  393. unsigned int plane,offset;
  394. int j;
  395.     for (j=(b_ysize/8)-1;j>=0;j--) {
  396.         fprintf(outfile,"\033J\030");    /* line feed 8/72" = 8 dots */
  397.         for (plane=0; plane<b_planes; plane++) {
  398.             offset=plane*b_psize;
  399.             if (b_planes>1) {
  400.                 /* select colour for plane */
  401.                 fprintf(outfile,"\033r");
  402.                 (void) fputc((char)STARCpcolor[plane],outfile);
  403.             }
  404.             /* select plotter graphics mode (square pixels) */
  405.             fprintf(outfile,"\r\033*\005");
  406.             (void) fputc((char)(b_xsize%256),outfile);
  407.             (void) fputc((char)(b_xsize/256),outfile);
  408.             for (x=0; x<b_xsize; x++) {
  409.                 (void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
  410.             }
  411.         }
  412.     }
  413.     if (b_planes > 1) {
  414.         fprintf(outfile,"\033r");
  415.         (void) fputc('\0',outfile);                /* set color to black */
  416.     }
  417. #ifdef PC
  418.     fprintf(stderr,"Print using: COPY /B\n");
  419. #endif
  420. }
  421.  
  422. #endif /* STARC */
  423.  
  424.  
  425. #ifdef EPS180
  426.  
  427. #define EPSON180VCHAR        FNT13X25_VCHAR
  428. #define EPSON180HCHAR        FNT13X25_HCHAR
  429. #define EPSON180VTIC        18
  430. #define EPSON180HTIC        18
  431.  
  432. /* make the total dimensions 8 inches by 6 inches */
  433. #define EPS180XMAX    1260
  434. #define EPS180YMAX    1080
  435.  
  436. #define EPS180XLAST (EPS180XMAX - 1)
  437. #define EPS180YLAST (EPS180YMAX - 1)
  438.  
  439. EPS180graphics()
  440. {
  441.     b_charsize(FNT13X25);
  442.     b_makebitmap((unsigned int)(EPS180XMAX*xsize),
  443.                  (unsigned int)(EPS180YMAX*ysize),1);
  444. }
  445.  
  446.  
  447. EPS180text()
  448. {
  449.     eps180_dump();
  450.     b_freebitmap();
  451. }
  452.  
  453.  
  454.  
  455. /* output file must be binary mode for eps180_dump */
  456. eps180_dump()
  457. {
  458.   register unsigned int x;
  459.   int j;
  460.     fprintf(outfile,"\033@\033+\060\033l\005"); /* reset, set line spacing
  461.                                to 24/180", and
  462.                                move left margin */
  463.     for (j=(b_ysize/8)-1; j>=0; ) {
  464.         /* select printer graphics mode '39' */
  465.         fprintf(outfile,"\r\n\033*'");
  466.         (void) fputc((char)(b_xsize%256),outfile);
  467.         (void) fputc((char)(b_xsize/256),outfile);
  468.         for (x=0; x<b_xsize; x++) {
  469.                    (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  470.                  (void) fputc( (char)(*((*b_p)[j-1]+x)), outfile );
  471.                (void) fputc( (char)(*((*b_p)[j-2]+x)), outfile );
  472.         }
  473.     j -= 3;
  474.     }
  475.     fprintf(outfile,"\r\n\033@\r\n");     /* reset printer */
  476. #ifdef PC
  477.     fprintf(stderr,"Print using: COPY /B\n");
  478. #endif
  479. }
  480.  
  481. #endif /* EPS180 */
  482.  
  483. #ifdef EPS60
  484.  
  485. /* make the total dimensions 8 inches by 5 inches */
  486. #define EPS60XMAX    480
  487. #define EPS60YMAX    360
  488.  
  489. #define EPS60XLAST (EPS60XMAX - 1)
  490. #define EPS60YLAST (EPS60YMAX - 1)
  491.  
  492. EPS60graphics()
  493. {
  494.     b_charsize(FNT5X9);
  495.     b_makebitmap((unsigned int)(EPS60XMAX*xsize),
  496.                  (unsigned int)(EPS60YMAX*ysize),1);
  497. }
  498.  
  499.  
  500. EPS60text()
  501. {
  502.     eps60_dump();
  503.     b_freebitmap();
  504. }
  505.  
  506.  
  507.  
  508. /* output file must be binary mode for eps60_dump */
  509. eps60_dump()
  510. {
  511.   register unsigned int x;
  512.   int j;
  513.     fprintf(outfile,"\033%c\030",'3'); /* set line spacing 24/216" = 8 dots */
  514.     for (j=(b_ysize/8)-1; j>=0; j--) {
  515.         /* select printer graphics mode 'K' */
  516.         fprintf(outfile,"\r\n\033K");
  517.         (void) fputc((char)(b_xsize%256),outfile);
  518.         (void) fputc((char)(b_xsize/256),outfile);
  519.         for (x=0; x<b_xsize; x++) {
  520.             (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  521.         }
  522.     }
  523.     fprintf(outfile,"\033%c\044\r\n",'3'); /* set line spacing 36/216" = 1/6" */
  524. #ifdef PC
  525.     fprintf(stderr,"Print using: COPY /B\n");
  526. #endif
  527. }
  528.  
  529. #endif /* EPS60 */
  530.  
  531. #ifdef TANDY60
  532.  
  533. /* The only difference between TANDY60 and EPS60 is the inclusion
  534.    of codes to swap the Tandy printer into IBM mode and back
  535.    into Tandy mode.  For a Tandy already in IBM mode, use EPS60. */
  536.  
  537.  
  538. TANDY60text()
  539. {
  540. #ifdef PC
  541.     fprintf(stderr, "Inserting Tandy/IBM mode conversion codes\n");
  542. #endif
  543.     /* Switch to IBM mode, and leave 3 inches above the plot so as
  544.        to get rough vertical centring on the page.  Perform the
  545.        centring by setting 1" line feeds and issuing 3 of them. */
  546.     fprintf(outfile, "\033!\033%c%c\n\n\n", '3',216);
  547.     eps60_dump();
  548.     b_freebitmap();
  549.     /* A form feed must be sent before switching back to Tandy mode,
  550.        or else the form setting will be messed up. */
  551.     fprintf(outfile, "\f\033!");
  552. }
  553.  
  554.  
  555. #endif  /* TANDY60 */
  556.