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. No action will be
- * taken unless 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.
- *
- * Blaise C TOOLS do not record cursor sizes and on/off
- * states for inactive display pages. That is, the cursor
- * size for the active page also applies to all inactive
- * pages.
- *
- * Returns scur Value of "off" parameter (0 = on)
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986-1989
- *
- **/
-
- #include <dos.h>
-
- #include <bscreens.h>
-
- int scpgcur(off,high,low,adjust)
- int off;
- int high;
- int low;
- int adjust;
- {
- union REGS inregs,outregs; /* General registers */
-
- int dev,mode,act_page,columns;
- unsigned int max_scan_line;
-
- /* Address of BIOS INFO byte. */
- #define INFO_LOC (uttofar(0x0040,0x0087,unsigned char))
-
- char info;
- int changed_info,truncate;
-
- dev = scmode(&mode,&columns,&act_page);
-
- if (b_curpage == act_page) /* Change physical cursor if */
- { /* current page is active. */
- scequip();
- if (dev == b_mdpa)
- max_scan_line = 13;
- else if (dev == b_cga || dev == b_pgc || b_pcmodel == IBM_JR)
- max_scan_line = 7;
- else
- {
- inregs.x.ax = 0x1130;
- inregs.h.bh = 0;
- int86(SC_BIOS_INT,&inregs,&outregs);
- max_scan_line = outregs.x.cx - 1;
- }
-
- changed_info = 0;
- if (adjust == CUR_NO_ADJUST)
- {
-
- /* In the unnatural case where there are 43 or more text lines and*/
- /* cursor compensation is enabled, disable the compensation and */
- /* restore it at exit. */
-
- if (max_scan_line > 7)
- {
- info = utpeekb(INFO_LOC);
- if (0 == (info & 1)) /* If compensation enabled, */
- {
- info |= 1; /* disable compensation. */
- utpokeb(INFO_LOC,info);
- 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 != SC_MONO
- || max_scan_line <= 7)
- {
- if ( (dev == b_ega || dev == b_vga || dev == b_mcga)
- && max_scan_line > 7)
- { /* If EGA, truncate scan lines only if */
- /* BIOS cursor compensation is enabled */
- /* (i.e., bit 1 of INFO is off). */
- info = utpeekb(INFO_LOC);
- truncate = (0 == (info & 1));
- }
- else
- truncate = 1;
-
- if (truncate)
- {
- if (high > max_scan_line)
- high = (max_scan_line * high) / 13;
- if (low > max_scan_line)
- low = (max_scan_line * low) / 13;
- }
- }
- }
-
- if (off) /* Set bits 4 and 5 if turning */
- high |= 0x0030; /* cursor off. */
- inregs.h.ah = 1;
- inregs.h.ch = (unsigned char) high;
- inregs.h.cl = (unsigned char) low;
- int86(16,&inregs,&outregs);
-
- if (changed_info)
- {
- info &= ~1; /* Clear compensation bit (turn */
- /* compensation back on). */
- utpokeb(INFO_LOC,info);
- }
- }
-
- return(off);
- }