home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name scpgcur -- Set the cursor size on current display page
- *
- * Synopsis scur = scpgcur(off,high,low,adjust);
- *
- * int scur Value of "off" parameter
- * int off Cursor off indicator (0 = on)
- * int high The cursor upper scan line
- * int low The cursor lower scan line
- * int adjust CUR_ADJUST if cursor scan lines are
- * to be adjusted to fit into limits
- * imposed by current video device;
- * CUR_NO_ADJUST if not.
- *
- * Description This function sets the size and on/off state of the
- * cursor on the current display page. (The change will
- * not appear on the screen until this page is active
- * (displayed).)
- *
- * The cursor size is determined by the upper and lower
- * scan lines, whose values can be between 0 and 13 for the
- * Monochrome Adapter, and 0 and 7 for the Color/Graphics
- * Adapter. If off is nonzero, the cursor is turned off
- * (no display); otherwise it is on.
- *
- * If no cursor size has yet been requested for the other
- * display pages on the current video adapter, the cursor
- * size requested for the current page is also recorded for
- * the other pages. However, the changes in the other
- * pages' cursors will not take effect until those other
- * pages are displayed using SCACTPG.
- *
- * Returns scur Value of "off" parameter (0 = on)
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- * Version 3.02 March 24, 1987
- * Prevented adjustment of INFO byte in cases when we're
- * not going to touch the physical cursor.
- *
- **/
-
- #include <bscreen.h>
-
- /* Cursor type for each display */
- CUR_TYPE b_curtype[MAX_DEVICES][MAX_PAGES] = {0}; /* page. */
-
- int b_curoff[MAX_DEVICES][MAX_PAGES] = {0}; /* Cursor on/off state */
- /* for each display page */
-
- int b_curknown[MAX_DEVICES] = {0}; /* Internal flag: zero means */
- /* cooresponding row of */
- /* b_curtype[][] and b_curoff[] */
- /* are not yet initialized. */
-
- int scpgcur(off,high,low,adjust)
- int off;
- int high;
- int low;
- int adjust;
- {
- int ax,bx,cx,dx,flags; /* General registers */
-
- int dev,mode,columns,act_page;
- int page;
-
- static ADS INFO_ads = {0x0087,0x0040};
- char info;
- ADS info_ads;
- int changed_info,truncate;
-
- dev = scmode(&mode,&columns,&act_page);
-
- changed_info = 0;
- if (adjust == CUR_NO_ADJUST)
- {
-
- /* In the unnatural case where there are 43 text lines and EGA */
- /* cursor compensation is enabled, disable the compensation and */
- /* restore it at exit. */
-
- if ( b_curpage == act_page
- && scrows() == 43)
- {
- utabsptr(&info,&info_ads);
- utslmove(&INFO_ads,&info_ads,1);
- if (0 == (info & 1)) /* If compensation enabled, */
- {
- info |= 1; /* disable compensation. */
- utslmove(&info_ads,&INFO_ads,1);
- changed_info = 1;
- }
- }
- }
- else
- {
-
- /* We may need to adjust the requested scan lines to fit into the */
- /* 0-7 range. This is needed if a scan line exceeds 7 and if one */
- /* of the following is true: */
- /* */
- /* 1) this is the Color/Graphics Adapter; */
- /* 2) this is 43-line mode (there are only 8 scan lines); */
- /* 3) EGA cursor compensation is being performed in a 14-scan- */
- /* line environment. */
-
- high = utlonyb(high);
- low = utlonyb(low);
- if ( dev != MONO
- || scrows() == 43)
- {
- scequip();
- if (dev == b_ega && scrows() == 25)
- { /* If EGA, truncate scan lines only if */
- /* BIOS cursor compensation is enabled */
- /* (i.e., bit 1 of INFO is off). */
- utabsptr(&info,&info_ads);
- utslmove(&INFO_ads,&info_ads,1);
- truncate = (0 == (info & 1));
- }
- else
- truncate = 1;
-
- if (truncate)
- {
- if (high > 7)
- high = (7 * high) / 13;
- if (low > 7)
- low = (7 * low) / 13;
- }
- }
- }
-
- if (!b_curknown[dev]) /* If b_curtype[dev][] is not */
- /* initialized, fill it with */
- /* requested cursor state. */
- {
- for (page = 0; page < MAX_PAGES; page++)
- {
- b_curoff [dev][page] = off;
- b_curtype[dev][page].high = high;
- b_curtype[dev][page].low = low;
- }
- b_curknown[dev] = 1; /* Now b_curtype[dev][] is */
- } /* valid. */
- else
- { /* Record new cursor type. */
- b_curoff [dev][b_curpage] = off;
- b_curtype[dev][b_curpage].high = high;
- b_curtype[dev][b_curpage].low = low;
- }
-
- if (b_curpage == act_page) /* Change physical cursor if */
- /* current page is active. */
- {
- if (off) /* Set bits 4 and 5 if turning */
- high |= 0x0030; /* cursor off. */
- ax = 0x0100;
- cx = utbyword(high,low);
- bios(16,&ax,&bx,&cx,&dx,&flags);
- }
-
- if (changed_info)
- {
- info &= ~1; /* Clear compensation bit (turn */
- /* compensation back on). */
- utslmove(&info_ads,&INFO_ads,1);
- }
-
- return(off);
- }