home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / VID.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  3.8 KB  |  170 lines

  1. /*
  2.     vid.c
  3.  
  4.     % vid_ routines
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      8/10/88 jmd    Added new object stuff
  13.      8/24/88 ted    merged driver and mode in to one stub function pointer.
  14. */
  15.  
  16. #include "oakhead.h"
  17. #include "disppriv.h"
  18.  
  19. #include "viddecl.h"
  20. /* -------------------------------------------------------------------------- */
  21.  
  22. byte vid_GetMap(attr)
  23.     byte attr;
  24. {
  25.     opixval fg, bg;
  26.     byte colors;
  27.  
  28.     disp_GetAttrColors(attr, &fg, &bg);
  29.     colors = ((byte) fg) & 0x0F;
  30.     colors |= ((byte) bg) << 4;
  31.  
  32.     return(colors);
  33. }
  34. /* -------------------------------------------------------------------------- */
  35.  
  36. char vid_GetChar(row, col)
  37.     int row;
  38.     int col;
  39. {
  40.     char c;
  41.     byte attr;
  42.  
  43.     cmwin_GetStringAttr(vid_win, row, col, &c, &attr, 1);
  44.     return(c);
  45. }
  46. /* -------------------------------------------------------------------------- */
  47. #define MAXATTRBUF    90
  48.  
  49. int vid_PutAttr(row, col, attrbuf, slen)
  50.     int row;
  51.     int col;
  52.     byte *attrbuf;
  53.     int slen;
  54. /*
  55.     Puts slen attribute bytes from attrbuf into the vid_win at row, col.
  56.     Puts at most MAXATTR attrs. The display is refreshed to reflect the new
  57.     attribute bytes.
  58.     Returns the number of bytes actually used.
  59. */
  60. {
  61.     static byte abuf[MAXATTRBUF];
  62.     static char cbuf[MAXATTRBUF];
  63.     int len;
  64.  
  65.     if (slen > MAXATTRBUF) slen = MAXATTRBUF;
  66.  
  67.     len = cmwin_GetStringAttr(vid_win, row, col, cbuf, abuf, slen);
  68.  
  69.     memmove(abuf, attrbuf, len);
  70.  
  71.     cmwin_DrawStringAttr(vid_win, row, col, cbuf, abuf, len);
  72.  
  73.     return(len);
  74. }
  75. /* -------------------------------------------------------------------------- */
  76.  
  77. char *vid_GetAttr(row, col, slen)
  78.     int row;
  79.     int col;
  80.     int slen;
  81. /*
  82.     Returns a pointer to a static buffer containing slen attributes from
  83.     the vid_win at row, col. Returns MAXATTRBUF attrs at most. The buffer is
  84.     not null-terminated.
  85. */
  86. {
  87.     char cbuf[MAXATTRBUF];
  88.     static byte abuf[MAXATTRBUF];
  89.  
  90.     if (slen > MAXATTRBUF) slen = MAXATTRBUF;
  91.  
  92.     cmwin_GetStringAttr(vid_win, row, col, cbuf, abuf, slen);
  93.     return((char *) abuf);
  94. }
  95. /* -------------------------------------------------------------------------- */
  96.  
  97. void vid_ScrollWindow(toprow, leftcol, botrow, rightcol, lines, attr)
  98.     int toprow;
  99.     int leftcol;
  100.     int botrow;
  101.     int rightcol;
  102.     int lines;
  103.     byte attr;
  104. {
  105.     ocbox cbox;
  106.  
  107.     cbox.leftcol = leftcol;
  108.     cbox.rightcol = rightcol;
  109.     cbox.toprow = toprow;
  110.     cbox.botrow = botrow;
  111.  
  112.     cmwin_ScrollBoxVt(vid_win, &cbox, lines);
  113.     /* Note: attr is no longer used to clear opened part */ oak_notused(attr);
  114. }
  115. /* -------------------------------------------------------------------------- */
  116.  
  117. void vid_ClearWindow(toprow, leftcol, botrow, rightcol, attr)
  118.     int toprow;
  119.     int leftcol;
  120.     int botrow;
  121.     int rightcol;
  122.     byte attr;
  123. {
  124.     ocbox cbox;
  125.  
  126.     cbox.leftcol = leftcol;
  127.     cbox.rightcol = rightcol;
  128.     cbox.toprow = toprow;
  129.     cbox.botrow = botrow;
  130.     cmwin_ClearBox(vid_win, &cbox, (byte)attr);
  131. }
  132. /* -------------------------------------------------------------------------- */
  133.  
  134. void vid_DrawLine(linecp, row1, col1, row2, col2, attr)
  135.     char *linecp;
  136.     int row1;
  137.     int col1;
  138.     int row2;
  139.     int col2;
  140.     byte attr;
  141. {
  142.     if (row1 == row2) {
  143.         cmwin_DrawHzLine(vid_win, linecp, row1, col1, col2 - col1 + 1, attr);
  144.     }
  145.     else if (col1 == col2) {
  146.         cmwin_DrawVtLine(vid_win, linecp, row1, col1, row2 - row1 + 1, attr);
  147.     }
  148. }
  149. /* -------------------------------------------------------------------------- */
  150.  
  151. void vid_DrawBox(boxcp, row1, col1, row2, col2, attr)
  152.     char *boxcp;
  153.     int row1;
  154.     int col1;
  155.     int row2;
  156.     int col2;
  157.     byte attr;
  158. {
  159.     ocbox cbox;
  160.  
  161.     cbox.toprow  = row1;
  162.     cbox.leftcol = col1;
  163.     cbox.botrow  = row2;
  164.     cbox.rightcol= col2;
  165.  
  166.     cmwin_DrawBox(vid_win, boxcp, &cbox, attr);
  167. }
  168. /* -------------------------------------------------------------------------- */
  169.  
  170.