home *** CD-ROM | disk | FTP | other *** search
- /*
- vid.c
-
- % vid_ routines
-
- OWL 1.2
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/10/88 jmd Added new object stuff
- 8/24/88 ted merged driver and mode in to one stub function pointer.
-
- 11/29/89 jmd added casts for DG
- 3/28/90 jmd ansi-fied
- 8/30/90 ted made cbuf & abuf in vid_PutAttr automatic instead of static.
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- #include "viddecl.h"
- /* -------------------------------------------------------------------------- */
-
- byte vid_GetMap(byte attr)
- {
- opixval fg, bg;
- byte colors;
-
- disp_GetAttrColors(attr, &fg, &bg);
- colors = ((byte) fg) & 0x0F;
- colors |= ((byte) bg) << 4;
-
- return(colors);
- }
- /* -------------------------------------------------------------------------- */
-
- char vid_GetChar(int row, int col)
- {
- char c;
- byte attr;
-
- cmwin_GetStringAttr(vid_win, row, col, &c, &attr, 1);
- return(c);
- }
- /* -------------------------------------------------------------------------- */
- #define MAXATTRBUF 90
-
- int vid_PutAttr(int row, int col, byte *attrbuf, int slen)
- /*
- Puts slen attribute bytes from attrbuf into the vid_win at row, col.
- Puts at most MAXATTR attrs. The display is refreshed to reflect the new
- attribute bytes.
- Returns the number of bytes actually used.
- */
- {
- byte abuf[MAXATTRBUF];
- char cbuf[MAXATTRBUF];
- int len;
-
- if (slen > MAXATTRBUF) {
- slen = MAXATTRBUF;
- }
-
- len = cmwin_GetStringAttr(vid_win, row, col, cbuf, abuf, slen);
-
- memmove((VOID *) abuf, (VOID *) attrbuf, len);
-
- cmwin_DrawStringAttr(vid_win, row, col, cbuf, abuf, len);
-
- return(len);
- }
- /* -------------------------------------------------------------------------- */
-
- char *vid_GetAttr(int row, int col, int slen)
- /*
- Returns a pointer to a static buffer containing slen attributes from
- the vid_win at row, col. Returns MAXATTRBUF attrs at most. The buffer is
- not null-terminated.
- */
- {
- char cbuf[MAXATTRBUF];
- static byte abuf[MAXATTRBUF];
-
- if (slen > MAXATTRBUF) slen = MAXATTRBUF;
-
- cmwin_GetStringAttr(vid_win, row, col, cbuf, abuf, slen);
- return((char *) abuf);
- }
- /* -------------------------------------------------------------------------- */
-
- void vid_ScrollWindow(int toprow, int leftcol, int botrow, int rightcol, int lines, byte attr)
- {
- ocbox cbox;
-
- cbox.leftcol = leftcol;
- cbox.rightcol = rightcol;
- cbox.toprow = toprow;
- cbox.botrow = botrow;
-
- cmwin_ScrollBoxVt(vid_win, &cbox, lines);
- /* Note: attr is no longer used to clear opened part */ oak_notused(attr);
- }
- /* -------------------------------------------------------------------------- */
-
- void vid_ClearWindow(int toprow, int leftcol, int botrow, int rightcol, byte attr)
- {
- ocbox cbox;
-
- cbox.leftcol = leftcol;
- cbox.rightcol = rightcol;
- cbox.toprow = toprow;
- cbox.botrow = botrow;
- cmwin_ClearBox(vid_win, &cbox, (byte)attr);
- }
- /* -------------------------------------------------------------------------- */
-
- void vid_DrawLine(char *linecp, int row1, int col1, int row2, int col2, byte attr)
- {
- if (row1 == row2) {
- cmwin_DrawHzLine(vid_win, linecp, row1, col1, col2 - col1 + 1, attr);
- }
- else if (col1 == col2) {
- cmwin_DrawVtLine(vid_win, linecp, row1, col1, row2 - row1 + 1, attr);
- }
- }
- /* -------------------------------------------------------------------------- */
-
- void vid_DrawBox(char *boxcp, int row1, int col1, int row2, int col2, byte attr)
- {
- ocbox cbox;
-
- cbox.toprow = row1;
- cbox.leftcol = col1;
- cbox.botrow = row2;
- cbox.rightcol= col2;
-
- cmwin_DrawBox(vid_win, boxcp, &cbox, attr);
- }
- /* -------------------------------------------------------------------------- */
-