Home Intro Visibility Position Shape Blink Rate Color Back 
Hardware Level VGA and SVGA Video Programming Information Page
Manipulating the Text-mode Cursor 
Introduction
        When dealing with the cursor in most high-level languages, the cursor is defined as the place where the next text output will appear on the display. When dealing directly with the display, the cursor is simply a blinking area of a particular character cell. A program may write text directly to the display independent of the current location of the cursor. The VGA provides facilities for specifying whether a cursor is to be displayed, where the cursor is to appear, and the shape of the cursor itself. Note that this cursor is only used in the text modes of the standard VGA and is not to be confused with the graphics cursor capabilities of particular SVGA chipsets.

Enabling/Disabling the Cursor
        On the VGA there are three main ways of disabling the cursor. The most straightforward is to set the Cursor Disable field to 1. Another way is to set the Cursor Scan Line End field to a value less than that of the Cursor Scan Line Start field. On some adapters such as the IBM EGA, this will result instead in a split block cursor. The third way is to set the cursor location to a location off-screen. The first two methods are specific to VGA and compatible adapters and are not guaranteed to work on non-VGA adapters, while the third method should.

Manipulating the Cursor Position
        When dealing with the cursor in standard BIOS text modes, the cursor position is specified by row and column. The VGA hardware, due to its flexibility to display any different text modes, specifies cursor position as a 16-bit address. The upper byte of this address is specified by the Cursor Location High Register, and the lower by the Cursor Location Low Register. In addition this value is affected by the Cursor Skew field. When the hardware fetches a character from display memory it compares the address of the character fetched to that of the cursor location added to the Cursor Skew field. If they are equal and the cursor is enabled, then the character is written with the current cursor pattern superimposed. Note that the address compared to the cursor location is the address in display memory, not the address in host memory. Characters and their attributes are stored at the same address in display memory in different planes, and it is the odd/even addressing mode usually used in text modes that makes the interleaved character/attribute pairs in host memory possible. Note that it is possible to set the cursor location to an address not displayed, effectively disabling the cursor.
        The Cursor Skew field was used on the EGA to synchronize the cursor with internal timing. On the VGA this is not necessary, and setting this field to any value other than 0 may result in undesired results. For example, on one particular card, setting the cursor position to the rightmost column and setting the skew to 1 made the cursor disappear entirely. On the same card, setting the cursor position to the leftmost column and setting the skew to 1 made an additional cursor appear above and to the left of the correct cursor. At any other position, setting the skew to 1 simply moved the cursor right one position. Other than these undesired effects, there is no function that this register can provide that could not be obtained by simply increasing the cursor location.

Manipulating the Cursor Shape
       On the VGA, the text-mode cursor consists of a line or block of lines that extend horizontally across the entire scan line of a character cell. The first, topmost line is specified by the Cursor Scan Line Start field. The last, bottom most line is specified by the Cursor Scan Line End field. The scan lines in a character cell are numbered from 0 up to the value of the Maximum Scan Line field. On the VGA if the Cursor Scan Line End field is less than the Cursor Scan Line Start field, no cursor will be displayed. Some adapters, such as the IBM EGA may display a split-block cursor instead.

Cursor Blink Rate
        On the standard VGA, the blink rate is dependent on the vertical frame rate. The on/off state of the cursor changes every 16 vertical frames, which amounts to 1.875 blinks per second at 60 vertical frames per second. The cursor blink rate is thus fixed and cannot be software controlled on the standard VGA. Some SVGA chipsets provide non-standard means for changing the blink rate of the text-mode cursor.

Cursor Color
        On the standard VGA, the cursor color is obtained from the foreground color of the character that the cursor is superimposing. On the standard VGA there is no way to modify this behavior.
 

Notice: All trademarks used or referred to on this page are the property of their respective owners.
All pages are Copyright © 1997, 1998, J. D. Neal, except where noted. Permission for utilization and distribution is subject to the terms of the FreeVGA Project Copyright License.