home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name scattrib -- Write copies of a character on the current
- * display page with the specified display attribute.
- *
- * Synopsis iret = scattrib(fore,back,ch,cnt);
- *
- * int iret Return value is always 0
- * int fore Foreground display attribute
- * int back Background display attribute
- * char ch Character to be displayed
- * unsigned cnt Number of copies of ch to be
- * displayed.
- *
- * Description This function displays cnt copies of the character ch
- * starting at the current cursor position. The cursor is
- * not moved. The copies are displayed with attributes
- * (fore, back) on the current page (b_curpage).
- *
- * This routine will not write more characters than will
- * fit on the screen, nor will it scroll the screen.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <bscreen.h>
-
- int scattrib(fore,back,ch,cnt)
- int fore;
- int back;
- char ch;
- unsigned cnt;
- {
- int ax,bx,cx,dx,flags; /* General registers */
- int mode,cols,act_page;
- int save_row,row,col;
- int cols_left,first_chunk,chunk;
-
- if (cnt == 0) /* BIOS treats 0 as 64K */
- return(0);
- else if (cnt == 1) /* Handle the usual case this way */
- { /* to save time */
- first_chunk = cnt;
- chunk = 0;
- }
- else
- { /* The general case */
- scmode(&mode,&cols,&act_page);
- sccurpos(&row,&col);
- save_row = row;
-
- cols_left = cols - col; /* Columns remaining in this row */
-
- /* Make sure we don't write beyond the end of this page */
-
- utuplim(cnt,cols_left + ((scrows() - 1 - row) * cols));
-
- /* Divide the job into chunks: graphics mode can only write */
- /* one row at a time. */
-
- if ((mode < 3) || (mode == 7))
- { /* Text mode */
- first_chunk = cnt;
- chunk = 0;
- }
- else
- { /* Graphics mode */
- first_chunk = min(cnt,cols_left);
- chunk = cols;
- }
- }
-
- /* Write the first chunk: If text mode, this is the whole thing; */
- /* if graphics, this (at most) fills the current line. */
-
- ax = utbyword(9,ch);
- bx = utbyword(b_curpage,utnybbyt(back,fore));
- cx = first_chunk;
- cnt -= first_chunk;
- bios(16,&ax,&bx,&cx,&dx,&flags);
-
- /* Write the remainder: if text mode, do nothing; if graphics, */
- /* write each of the remaining lines on the screen. */
-
- if (chunk != 0)
- {
- for (; cnt; cnt -= cx)
- {
- sccurset(++row,0);
- ax = utbyword(9,ch);
- cx = min(cnt,chunk);
- bios(16,&ax,&bx,&cx,&dx,&flags);
- }
- sccurset(save_row,col); /* Restore the original */
- /* cursor position */
- }
-
- return(0);
- }