Microsoft KB Archive/62814

DOS (OS/2 Real Mode) Program to Change Cursor Shape; Interrupt

PSS ID Number: Q62814 Article last modified on 06-11-1990

3.00 3.00a MS-DOS

Summary: In Microsoft COBOL versions 3.00 and 3.00a, it is possible to change the shape of the hardware text cursor by calling interrupt 10 Hex with function 01 Hex (Set cursor type). An interrupt is called from COBOL via the special subprogram X“84”. The information in this article applies to Microsoft COBOL Compiler versions 3.00 and 3.00a for MS-DOS.

More Information: Interrupt 10 Hex, function 01 Hex requires that the following registers be set: AH (upper byte of AX) = 01 Hex CH (upper byte of CX) = starting scan line for cursor CL (lower byte of CX) = ending scan line for cursor CH and CL refer to the desired starting and ending scan lines (where one line is a pixel high) of the cursor and can be manipulated to change its shape. They can be a number in the range of 0-7 for CGA, 0-13 for EGA, and 0-15 for VGA. After the call, only the specified range of scan lines that make up the cursor will be displayed. For more information on calling interrupts from COBOL 3.00 and 3.00a, see Pages 8-4 and 8-5 of the “Microsoft COBOL Compiler 3.0: Operating Guide” included with the product. For more information on interrupt 10 Hex, function 01 Hex, see Page 501 of “Advanced MS-DOS Programming, Second Edition” by Ray Duncan, Microsoft Press (1988). The following sample program (HEIGHT.CBL) allows you to increase or decrease the height of the cursor via the keyboard. Use the following to compile and link the program: cobol height; link height;

Code Example
$SET ANS85 DATA DIVISION. WORKING-STORAGE SECTION. 01 AX. *  Function 01 Hex. 05 A-H     PIC 99   COMP-X VALUE 1. 05 A-L     PIC 99   COMP-X. 01 BX         PIC 9(4) COMP-X. 01 CX. *  Initialize starting scan line to 14 (6 for CGA, 12 for EGA). 05 C-H     PIC 99   COMP-X VALUE 14. *  Initialize ending scan line to 15 (7 for CGA, 13 for EGA). 05 C-L     PIC 99   COMP-X VALUE 15. 01 DX         PIC 9(4) COMP-X. *  Interrupt 10 Hex. 01 Interrupt  PIC X         VALUE X&quot;10&quot;. *  Load registers with CALL X&quot;84&quot; parameters. 01 Flag       PIC X         VALUE X&quot;FF&quot;. *  Used to get next key from keyboard buffer. 01 AnyKey     PIC 99 COMP-X VALUE 0. *  Starting height of cursor is 2 lines. 01 Height     PIC 99        VALUE 2. PROCEDURE DIVISION. *   Clear the screen and display prompt. CALL X&quot;E4&quot;. DISPLAY &quot;l = lower cursor height&quot; AT 1325. DISPLAY &quot;r = raise cursor height&quot; AT 1425. DISPLAY &quot;q = quit&quot; AT 1525. DISPLAY &quot;Cursor height is 02&quot; AT 1125. *   Program will end if user hits 'q'. PERFORM UNTIL AnyKey = 113 *      Get next key (if any) from buffer. CALL X&quot;83&quot; USING AnyKey EVALUATE AnyKey *      When AnyKey = 'l', lower height of cursor by 1 line *      only if it is greater than the minimum 1 line high. WHEN 108 IF Height > 1 THEN COMPUTE Height = Height - 1 COMPUTE C-H   = C-H + 1 END-IF *      When AnyKey = 'r', raise height of cursor by 1 line *      only if it is less than the maximum 16 lines high. *      Maximum for CGA is 8, 14 for EGA. WHEN 114 IF Height < 16 THEN COMPUTE Height = Height + 1 COMPUTE C-H   = C-H - 1 END-IF END-EVALUATE *      Display current height of cursor and call interrupt *      to make any changes if they occurred. DISPLAY Height AT 1142 MOVE 1 TO A-H CALL X&quot;84&quot; USING Interrupt, Flag, AX, BX, CX, DX      END-PERFORM. *   Clear screen and end program. CALL X&quot;E4&quot;. STOP RUN. Copyright Microsoft Corporation 1990.