home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / VILE327.ZIP / VILE327.TAR / vile3.27 / tipc.c < prev    next >
C/C++ Source or Header  |  1992-12-14  |  4KB  |  220 lines

  1. /*
  2.  * The routines in this file provide support for the TI-PC and other
  3.  * compatible terminals. It goes directly to the graphics RAM to do
  4.  * screen output. It compiles into nothing if not a TI-PC driver
  5.  *
  6.  * $Log: tipc.c,v $
  7.  * Revision 1.3  1991/09/10  01:19:35  pgf
  8.  * re-tabbed, and moved ESC and BEL to estruct.h
  9.  *
  10.  * Revision 1.2  1991/08/07  12:35:07  pgf
  11.  * added RCS log messages
  12.  *
  13.  * revision 1.1
  14.  * date: 1990/09/21 10:26:13;
  15.  * initial vile RCS revision
  16.  */
  17.  
  18. #define termdef 1            /* don't define "term" external */
  19.  
  20. #include    <stdio.h>
  21. #include    "estruct.h"
  22. #include    "edef.h"
  23.  
  24. #if    TIPC
  25.  
  26. #define NROW    25            /* Screen size.         */
  27. #define NCOL    80            /* Edit if you want to.     */
  28. #define MARGIN    8            /* size of minimim margin and    */
  29. #define SCRSIZ    64            /* scroll size for extended lines */
  30. #define NPAUSE    200            /* # times thru update to pause */
  31.  
  32. #define CHAR_ENABLE    0x08        /* TI attribute to show char    */
  33. #define TI_REVERSE    0x10        /* TI attribute to reverse char */
  34. #define BLACK    0+CHAR_ENABLE        /* TI attribute for Black    */
  35. #define BLUE    1+CHAR_ENABLE        /* TI attribute for Blue    */
  36. #define RED    2+CHAR_ENABLE        /* TI attribute for Red     */
  37. #define MAGENTA 3+CHAR_ENABLE        /* TI attribute for Magenta    */
  38. #define GREEN    4+CHAR_ENABLE        /* TI attribute for Green    */
  39. #define CYAN    5+CHAR_ENABLE        /* TI attribute for Cyan    */
  40. #define YELLOW    6+CHAR_ENABLE        /* TI attribute for Yellow    */
  41. #define WHITE    7+CHAR_ENABLE        /* TI attribute for White    */
  42.  
  43.  
  44. extern    int    ttopen();        /* Forward references.        */
  45. extern    int    ttgetc();
  46. extern    int    ttputc();
  47. extern    int    ttflush();
  48. extern    int    ttclose();
  49. extern    int    timove();
  50. extern    int    tieeol();
  51. extern    int    tieeop();
  52. extern    int    tibeep();
  53. extern    int    tiopen();
  54. extern    int    tirev();
  55. extern    int    ticres();
  56. extern    int    ticlose();
  57. extern    int    tiputc();
  58.  
  59. #if    COLOR
  60. extern    int    tifcol();
  61. extern    int    tibcol();
  62.  
  63. int    cfcolor = -1;        /* current forground color */
  64. int    cbcolor = -1;        /* current background color */
  65. int    ctrans[] =        /* ansi to ti color translation table */
  66.     {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
  67. #endif
  68.  
  69. /*
  70.  * Standard terminal interface dispatch table. Most of the fields point into
  71.  * "termio" code.
  72.  */
  73. TERM    term    = {
  74.     NROW-1,
  75.     NROW-1,
  76.     NCOL,
  77.     NCOL,
  78.     MARGIN,
  79.     SCRSIZ,
  80.     NPAUSE,
  81.     tiopen,
  82.     ticlose,
  83.     ttgetc,
  84.     tiputc,
  85.     ttflush,
  86.     timove,
  87.     tieeol,
  88.     tieeop,
  89.     tibeep,
  90.     tirev,
  91.     ticres
  92. #if    COLOR
  93.     , tifcol,
  94.     tibcol
  95. #endif
  96. };
  97.  
  98. extern union REGS rg;
  99.  
  100. #if    COLOR
  101. setatt( attr )
  102. int attr;
  103. {
  104.     rg.h.ah = 0x16;     /* set the forground character attribute */
  105.     rg.h.bl = attr;
  106.     int86( 0x49, &rg, &rg );
  107. }
  108.  
  109. tifcol(color)        /* set the current output color */
  110.  
  111. int color;    /* color to set */
  112.  
  113. {
  114.     cfcolor = ctrans[color];
  115.     setatt ( cfcolor );
  116. }
  117.  
  118. tibcol(color)        /* set the current background color */
  119.  
  120. int color;    /* color to set */
  121.  
  122. {
  123.     cbcolor = ctrans[color];
  124. }
  125. #endif
  126.  
  127. timove(row, col)
  128. {
  129.     rg.h.ah = 2;        /* set cursor position function code */
  130.     rg.h.dh = col;
  131.     rg.h.dl = row;
  132.     int86(0x49, &rg, &rg);
  133. }
  134.  
  135. tieeol()    /* erase to the end of the line */
  136.  
  137. {
  138.     int ccol;    /* current column cursor lives */
  139.     int crow;    /*       row    */
  140.  
  141.     /* find the current cursor position */
  142.     rg.h.ah = 3;        /* read cursor position function code */
  143.     int86(0x49, &rg, &rg);
  144.     ccol = rg.h.dh;     /* record current column */
  145.     crow = rg.h.dl;     /* and row */
  146.  
  147.     rg.h.ah = 0x09;     /* Write character at cursor position */
  148.     rg.h.al = ' ';        /* Space */
  149.     rg.h.bl = cfcolor;
  150.     rg.x.cx = NCOL-ccol;    /* Number of characters to write */
  151.     int86(0x49, &rg, &rg);
  152.  
  153. }
  154.  
  155. tiputc(ch)    /* put a character at the current position in the
  156.            current colors */
  157.  
  158. int ch;
  159.  
  160. {
  161.     rg.h.ah = 0x0E;     /* write char to screen with current attrs */
  162.     rg.h.al = ch;
  163.     int86(0x49, &rg, &rg);
  164. }
  165.  
  166. tieeop()            /* Actually a clear screen */
  167. {
  168.  
  169.     rg.h.ah = 0x13;     /* Clear Text Screen and Home Cursor */
  170.     int86(0x49, &rg, &rg);
  171. }
  172.  
  173. tirev(state)        /* change reverse video state */
  174.  
  175. int state;    /* TRUE = reverse, FALSE = normal */
  176.  
  177. {
  178.     setatt( state ? cbcolor : cfcolor  );
  179. }
  180.  
  181. ticres()    /* change screen resolution */
  182.  
  183. {
  184.     return(TRUE);
  185. }
  186.  
  187. spal()        /* change palette string */
  188.  
  189. {
  190.     /*    Does nothing here    */
  191. }
  192.  
  193. tibeep()
  194. {
  195.     bdos(6, BEL, 0);
  196. }
  197.  
  198. tiopen()
  199. {
  200.     strcpy(sres, "NORMAL");
  201.     revexist = TRUE;
  202.     ttopen();
  203. }
  204.  
  205. ticlose()
  206.  
  207. {
  208. #if    COLOR
  209.     tifcol(7);
  210.     tibcol(0);
  211. #endif
  212.     ttclose();
  213. }
  214. #else
  215. tihello()
  216. {
  217. }
  218. #endif
  219.  
  220.