home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / memacs / ue311c.arc / HP110.C < prev    next >
C/C++ Source or Header  |  1990-08-16  |  4KB  |  240 lines

  1. /*
  2.  *    HP110:    Hewlett Packard 110 Screen Driver
  3.  */
  4.  
  5. #define    termdef    1            /* don't define "term" external */
  6.  
  7. #include        <stdio.h>
  8. #include    "estruct.h"
  9. #include    "eproto.h"
  10. #include        "edef.h"
  11. #include    "elang.h"
  12.  
  13. #if     HP110
  14.  
  15. #define NROW    16                      /* Screen size.                 */
  16. #define NCOL    80                      /* Edit if you want to.         */
  17. #define    NPAUSE    100            /* # times thru update to pause */
  18. #define    MARGIN    8            /* size of minimim margin and    */
  19. #define    SCRSIZ    64            /* scroll size for extended lines */
  20. #define BEL     0x07                    /* BEL character.               */
  21. #define ESC     0x1B                    /* ESC character.               */
  22.  
  23. extern PASCAL NEAR ttopen();               /* Forward references.          */
  24. extern PASCAL NEAR ttgetc();
  25. extern PASCAL NEAR ttputc();
  26. extern PASCAL NEAR ttflush();
  27. extern PASCAL NEAR ttclose();
  28. extern PASCAL NEAR h110move();
  29. extern PASCAL NEAR h110eeol();
  30. extern PASCAL NEAR h110eeop();
  31. extern PASCAL NEAR h110beep();
  32. extern PASCAL NEAR h110open();
  33. extern PASCAL NEAR h110rev();
  34. extern PASCAL NEAR h110cres();
  35. extern PASCAL NEAR h110close();
  36. extern PASCAL NEAR h110kopen();
  37. extern PASCAL NEAR h110kclose();
  38. extern PASCAL NEAR h110parm();
  39.  
  40. #if    COLOR
  41. extern PASCAL NEAR h110fcol();
  42. extern PASCAL NEAR h110bcol();
  43.  
  44. int    cfcolor = -1;        /* current forground color */
  45. int    cbcolor = -1;        /* current background color */
  46. #endif
  47.  
  48. /*
  49.  * Standard terminal interface dispatch table. Most of the fields point into
  50.  * "termio" code.
  51.  */
  52. TERM    term    = {
  53.     NROW-1,
  54.         NROW-1,
  55.         NCOL,
  56.         NCOL,
  57.     MARGIN,
  58.     SCRSIZ,
  59.     NPAUSE,
  60.         h110open,
  61.         h110close,
  62.     h110kopen,
  63.     h110kclose,
  64.         ttgetc,
  65.         ttputc,
  66.         ttflush,
  67.         h110move,
  68.         h110eeol,
  69.         h110eeop,
  70.         h110beep,
  71.     h110rev,
  72.     h110cres
  73. #if    COLOR
  74.     , h110fcol,
  75.     h110bcol
  76. #endif
  77. };
  78.  
  79. #if    COLOR
  80. PASCAL NEAR h110fcol(color)        /* set the current output color */
  81.  
  82. int color;    /* color to set */
  83.  
  84. {
  85.     if (color == cfcolor)
  86.         return;
  87.     ttputc(ESC);
  88.     ttputc('[');
  89.     h110parm(color+30);
  90.     ttputc('m');
  91.     cfcolor = color;
  92. }
  93.  
  94. PASCAL NEAR h110bcol(color)        /* set the current background color */
  95.  
  96. int color;    /* color to set */
  97.  
  98. {
  99.     if (color == cbcolor)
  100.         return;
  101.     ttputc(ESC);
  102.     ttputc('[');
  103.     h110parm(color+40);
  104.     ttputc('m');
  105.         cbcolor = color;
  106. }
  107. #endif
  108.  
  109. PASCAL NEAR h110move(row, col)
  110. {
  111.         ttputc(ESC);
  112.         ttputc('[');
  113.         h110parm(row+1);
  114.         ttputc(';');
  115.         h110parm(col+1);
  116.         ttputc('H');
  117. }
  118.  
  119. PASCAL NEAR h110eeol()
  120. {
  121.         ttputc(ESC);
  122.         ttputc('[');
  123.     ttputc('0');
  124.         ttputc('K');
  125. }
  126.  
  127. PASCAL NEAR h110eeop()
  128. {
  129. #if    COLOR
  130.     h110fcol(gfcolor);
  131.     h110bcol(gbcolor);
  132. #endif
  133.         ttputc(ESC);
  134.         ttputc('[');
  135.     ttputc('0');
  136.         ttputc('J');
  137. }
  138.  
  139. PASCAL NEAR h110rev(state)        /* change reverse video state */
  140.  
  141. int state;    /* TRUE = reverse, FALSE = normal */
  142.  
  143. {
  144. #if    COLOR
  145.     int ftmp, btmp;        /* temporaries for colors */
  146. #endif
  147.  
  148.     ttputc(ESC);
  149.     ttputc('[');
  150.     ttputc(state ? '7': '0');
  151.     ttputc('m');
  152. #if    COLOR
  153.     if (state == FALSE) {
  154.         ftmp = cfcolor;
  155.         btmp = cbcolor;
  156.         cfcolor = -1;
  157.         cbcolor = -1;
  158.         h110fcol(ftmp);
  159.         h110bcol(btmp);
  160.     }
  161. #endif
  162. }
  163.  
  164. PASCAL NEAR h110cres()    /* change screen resolution */
  165.  
  166. {
  167.     return(TRUE);
  168. }
  169.  
  170. PASCAL NEAR spal()        /* change pallette register */
  171.  
  172. {
  173.     /*   not here */
  174. }
  175.  
  176. PASCAL NEAR h110beep()
  177. {
  178.         ttputc(BEL);
  179.         ttflush();
  180. }
  181.  
  182. PASCAL NEAR h110parm(n)
  183. register int    n;
  184. {
  185.         register int q,r;
  186.  
  187.         q = n/10;
  188.         if (q != 0) {
  189.         r = q/10;
  190.         if (r != 0) {
  191.             ttputc((r%10)+'0');
  192.         }
  193.         ttputc((q%10) + '0');
  194.         }
  195.         ttputc((n%10) + '0');
  196. }
  197.  
  198. PASCAL NEAR h110open()
  199. {
  200.     strcpy(sres, "15LINE");
  201.     revexist = TRUE;
  202.         ttopen();
  203. }
  204.  
  205. PASCAL NEAR h110close()
  206.  
  207. {
  208. #if    COLOR
  209.     h110fcol(7);
  210.     h110bcol(0);
  211. #endif
  212.     ttclose();
  213. }
  214.  
  215. PASCAL NEAR h110kopen()
  216.  
  217. {
  218. }
  219.  
  220. PASCAL NEAR h110kclose()
  221.  
  222. {
  223. }
  224.  
  225. #if    FLABEL
  226. PASCAL NEAR fnclabel(f, n)        /* label a function key */
  227.  
  228. int f,n;    /* default flag, numeric argument [unused] */
  229.  
  230. {
  231.     /* on machines with no function keys...don't bother */
  232.     return(TRUE);
  233. }
  234. #endif
  235. #else
  236. h110hello()
  237. {
  238. }
  239. #endif
  240.