home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 318_01 / redout.c < prev    next >
C/C++ Source or Header  |  1990-06-18  |  3KB  |  268 lines

  1. /*
  2.     RED terminal output module -- Customized for IBM PC.
  3.     Source:  redout.c
  4.     Version: September 8, 1986; January 18, 1990
  5.  
  6.     Written by
  7.     
  8.         Edward K. Ream
  9.         166 N. Prospect
  10.         Madison WI 53705
  11.         (608) 257-0802
  12.  
  13.  
  14.     PUBLIC DOMAIN SOFTWARE
  15.  
  16.     This software is in the public domain.
  17.  
  18.     See red.h for a disclaimer of warranties and other information.
  19. */
  20. #include "red.h"
  21.  
  22. #ifdef TURBOC
  23. #include <graphics.h>
  24. #include <conio.h>
  25. #endif
  26.  
  27. #define USE_ASM
  28.  
  29. #ifndef USE_ASM
  30. #ifndef TURBOC
  31. #ifndef DESMET
  32. #define PORTABLE
  33. #endif
  34. #endif
  35. #endif
  36.  
  37. /*
  38.     Initialize the globals which describe the terminal.
  39. */
  40. void
  41. outinit(void)
  42. {
  43.  
  44.     outxy(0,0);
  45.  
  46. #ifdef USE_ASM
  47.     hasdn  = FALSE;
  48.     hasup  = FALSE;
  49.     hasins = TRUE;
  50.     hasdel = TRUE;
  51.     hasint = TRUE;
  52.     hascol = TRUE;
  53.     haswrap = FALSE;
  54. #else
  55. #ifdef PORTABLE
  56.     hasdn   = FALSE;
  57.     hasup   = FALSE;
  58.     hasins  = FALSE;
  59.     hasdel  = FALSE;
  60.     hasint  = TRUE;
  61.     hascol  = TRUE;
  62.     haswrap = TRUE;
  63.     hasword = FALSE;
  64. #else
  65.     hasdn   = FALSE;
  66.     hasup   = FALSE;
  67.     hasins  = TRUE;
  68.     hasdel  = TRUE;
  69.     hasint  = TRUE;
  70.     hascol  = TRUE;
  71.     haswrap = TRUE;
  72.     hasword = FALSE;
  73.  
  74. #endif /* PORTABLE */
  75. #endif /* USE_ASM  */
  76.  
  77. #ifndef USE_ASM
  78. #ifdef DESMET
  79.     scr_setup();    /* 9/8/86 */
  80.     #ifdef PCJR
  81.         scr_mode(2);
  82.     #endif
  83. #endif
  84.  
  85. #ifdef TURBOC
  86.     /* 12/12/89 */
  87.  
  88.     directvideo = 0;    /* Use Bios Calls, not video ram. */
  89.     textmode(C80);        /* Use previous text mode.      */
  90.  
  91. #endif /* TURBOC */
  92. #endif /* USE_ASM  */
  93.  
  94. }
  95.  
  96. /*
  97.     The rest of the file is used only if the file redouta.asm 
  98.     is not used.
  99. */
  100.  
  101. #ifndef USE_ASM
  102.  
  103. /*
  104.     Output one printable character to the screen.
  105. */
  106. int
  107. outchar(char c)
  108. {
  109.     SL_DISABLE();
  110.  
  111.     outch(c);
  112.     outx++;
  113.     return c;
  114. }
  115.  
  116. /*
  117.     Erase the entire screen.
  118.     Make sure the rightmost column is erased.
  119. */
  120. void
  121. outclr(void)
  122. {
  123.     int i;
  124.  
  125.     SL_DISABLE();
  126.  
  127. #ifdef DESMET
  128.     scr_clr();
  129. #endif
  130.  
  131. #ifdef TURBOC
  132.     clrscr();
  133. #endif
  134.  
  135. #ifdef PORTABLE
  136.     for (i = 0; i < SCRNL; i++) {
  137.         outxy(0, i);
  138.         outdelln();
  139.     }
  140.     outxy(0,0);
  141. #endif
  142.  
  143. }
  144.  
  145. /*
  146.     Hardware delete line.
  147. */
  148. void
  149. outdel(void)
  150. {
  151.     SL_DISABLE();
  152.  
  153. #ifdef DESMET
  154.     scr_scrup(1,outy,0,24,79);
  155. #endif
  156.  
  157. #ifdef TURBOC
  158.     delline();
  159. #endif
  160.  
  161. }
  162.  
  163. /*
  164.     Delete the line on which the cursor rests.
  165.     Leave the cursor at the left margin.
  166. */
  167. void
  168. outdelln(void)
  169. {
  170.     SL_DISABLE();
  171.  
  172.     outxy(0,outy);
  173.     outdeol();
  174. }
  175.  
  176. /*
  177.     Delete to end of line.
  178.     Assume the last column is blank.
  179. */
  180. void
  181. outdeol(void)
  182. {
  183.     SL_DISABLE();
  184.  
  185. #ifdef DESMET
  186.     scr_clrl();
  187. #endif
  188.  
  189. #ifdef TURBOC
  190.     clreol();
  191. #endif
  192.  
  193. }
  194.  
  195. /*
  196.     Hardware insert line.
  197. */
  198. void
  199. outins(void)
  200. {
  201.     SL_DISABLE();
  202.  
  203. #ifdef DESMET
  204.     scr_scrdn(1,outy,0,24,79);    
  205. #endif
  206.  
  207. #ifdef TURBOC
  208.     insline();
  209. #endif
  210.  
  211. }
  212.  
  213. /*
  214.     Scroll screen down.
  215.     Assume the cursor is on the top line.
  216. */
  217. void
  218. outsdn(void)
  219. {
  220.     SL_DISABLE();
  221.  
  222. #ifdef PORTABLE
  223.     outxy(0,0);
  224. #endif
  225.  
  226. }
  227.  
  228. /*
  229.     Scroll the screen up.
  230.     Assume the cursor is on the bottom line.
  231. */
  232. void
  233. outsup(void)
  234. {
  235.     SL_DISABLE();
  236.  
  237. #ifdef PORTABLE
  238.     /* auto scroll */
  239.     outxy(0,SCRNL1);
  240.     syscout(10);
  241. #endif
  242.  
  243. }
  244.  
  245. /*
  246.     Position cursor to position x,y on screen.
  247.     0,0 is the top left corner.
  248. */
  249. void
  250. outxy(int x, int y)
  251. {
  252.     SL_DISABLE();
  253.  
  254.     outx = x;
  255.     outy = y;
  256.  
  257. #ifdef DESMET
  258.     scr_rowcol(y,x);
  259. #endif
  260.  
  261. #ifdef TURBOC
  262.     gotoxy(x+1, y+1);
  263. #endif
  264.  
  265. }
  266.  
  267. #endif /* USE_ASM */
  268.