home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / maths / plplot / plplot_2 / drivers / dg300.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-19  |  4.3 KB  |  174 lines

  1. /* $Id: dg300.c,v 1.14 1994/07/19 22:30:16 mjl Exp $
  2.  * $Log: dg300.c,v $
  3.  * Revision 1.14  1994/07/19  22:30:16  mjl
  4.  * All device drivers: enabling macro renamed to PLD_<driver>, where <driver>
  5.  * is xwin, ps, etc.  See plDevs.h for more detail.
  6.  *
  7.  * Revision 1.13  1994/03/23  06:34:20  mjl
  8.  * All drivers: cleaned up by eliminating extraneous includes (stdio.h and
  9.  * stdlib.h now included automatically by plplotP.h), extraneous clears
  10.  * of pls->fileset, pls->page, and pls->OutFile = NULL (now handled in
  11.  * driver interface or driver initialization as appropriate).  Special
  12.  * handling for malloc includes eliminated (no longer needed) and malloc
  13.  * prototypes fixed as necessary.
  14. */
  15.  
  16. /*    dg300.c
  17.  
  18.     PLPLOT dg300 device driver.
  19. */
  20. #include "plDevs.h"
  21.  
  22. #ifdef PLD_dg300
  23.  
  24. #include "plplotP.h"
  25. #include "drivers.h"
  26.  
  27. /* top level declarations */
  28.  
  29. #define  DGX    639
  30. #define  DGY    239
  31.  
  32. struct termattr {
  33.     unsigned char com[4];
  34.     unsigned char rom[4];
  35.     unsigned char ram[4];
  36.     unsigned char con[5];
  37.     unsigned char eor;
  38. } termattr;
  39.  
  40. /*----------------------------------------------------------------------*\
  41. * plD_init_dg()
  42. *
  43. * Initialize device.
  44. \*----------------------------------------------------------------------*/
  45.  
  46. void
  47. plD_init_dg(PLStream *pls)
  48. {
  49.     /* Request terminal configuration report */
  50.     printf("\n\036\107\051\n");
  51.     scanf("%s", (char *) &termattr);
  52.     while (getchar() != '\n');
  53.     if (!strncmp((char *) &termattr.ram[0], "0000", 4)) {
  54.     printf("Please wait while graphics interpreter is downloaded.\n");
  55.     /* Need to download graphics interpreter. */
  56.     system("cat  /usr/local/src/g300/g300gci110.tx");
  57.     }
  58.  
  59.     /* Clear screen, Set pen color to green, Absolute positioning */
  60.     printf("\036\107\063\060\n\036\107\155\061\n\036\107\151\060\n");
  61.     printf("\036\107\042\061\n");
  62.  
  63.     pls->termin = 1;        /* is an interactive device */
  64.     pls->icol0 = 1;
  65.     pls->color = 0;
  66.     pls->width = 1;
  67.     pls->bytecnt = 0;
  68.     pls->page = 0;
  69.  
  70.     plP_setpxl((PLFLT) (3.316 * 16), (PLFLT) (1.655 * 16));
  71.     plP_setphy(0, DGX * 16, 0, DGY * 16);
  72. }
  73.  
  74. /*----------------------------------------------------------------------*\
  75. * plD_line_dg()
  76. *
  77. * Draw a line in the current color from (x1,y1) to (x2,y2).
  78. \*----------------------------------------------------------------------*/
  79.  
  80. void
  81. plD_line_dg(PLStream *pls, short x1a, short y1a, short x2a, short y2a)
  82. {
  83.     int x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
  84.  
  85.     printf("LINE %d %d %d %d\n", x1 >> 4, y1 >> 3, x2 >> 4, y2 >> 3);
  86. }
  87.  
  88. /*----------------------------------------------------------------------*\
  89. * plD_polyline_dg()
  90. *
  91. * Draw a polyline in the current color.
  92. \*----------------------------------------------------------------------*/
  93.  
  94. void
  95. plD_polyline_dg(PLStream *pls, short *xa, short *ya, PLINT npts)
  96. {
  97.     PLINT i;
  98.  
  99.     for (i = 0; i < npts - 1; i++)
  100.     plD_line_dg(pls, xa[i], ya[i], xa[i + 1], ya[i + 1]);
  101. }
  102.  
  103. /*----------------------------------------------------------------------*\
  104. * plD_eop_dg()
  105. *
  106. * End of page.  User must hit a <CR> to continue.
  107. \*----------------------------------------------------------------------*/
  108.  
  109. void
  110. plD_eop_dg(PLStream *pls)
  111. {
  112.     /* Before clearing wait for CR */
  113.     putchar('\007');
  114.     fflush(stdout);
  115.     while (getchar() != '\n');
  116.     printf("ERASE\n");
  117. }
  118.  
  119. /*----------------------------------------------------------------------*\
  120. * plD_bop_dg()
  121. *
  122. * Set up for the next page.
  123. \*----------------------------------------------------------------------*/
  124.  
  125. void
  126. plD_bop_dg(PLStream *pls)
  127. {
  128.     pls->page++;
  129. }
  130.  
  131. /*----------------------------------------------------------------------*\
  132. * plD_tidy_dg()
  133. *
  134. * Close graphics file
  135. \*----------------------------------------------------------------------*/
  136.  
  137. void
  138. plD_tidy_dg(PLStream *pls)
  139. {
  140.     printf("\036\107\042\060\n");
  141.     fflush(stdout);
  142. }
  143.  
  144. /*----------------------------------------------------------------------*\
  145. * plD_state_dg()
  146. *
  147. * Handle change in PLStream state (color, pen width, fill attribute, etc).
  148. \*----------------------------------------------------------------------*/
  149.  
  150. void 
  151. plD_state_dg(PLStream *pls, PLINT op)
  152. {
  153. }
  154.  
  155. /*----------------------------------------------------------------------*\
  156. * plD_esc_dg()
  157. *
  158. * Escape function.
  159. \*----------------------------------------------------------------------*/
  160.  
  161. void
  162. plD_esc_dg(PLStream *pls, PLINT op, void *ptr)
  163. {
  164. }
  165.  
  166. #else
  167. int 
  168. pldummy_dg300()
  169. {
  170.     return 0;
  171. }
  172.  
  173. #endif                /* PLD_dg300 */
  174.