Microsoft KB Archive/65748

COBOL 3.00 Examples of Using Mouse and Graphics Under MS-DOS

PSS ID Number: Q65748 Article last modified on 04-26-1991

3.00 3.00a MS-DOS

Summary: A file available in the Software/Data Library, named COBGRAMO contains sample programs that demonstrate how COBOL 3.00 and 3.00a real mode (DOS) applications can use the graphics and mouse capabilities of the PC. This file can be found in the Software/Data Library by querying on the keyword COBGRAMO, S12706, or the Q number of this article. COBGRAMO was archived using the PKWare file-compression utility. When you decompress COBGRAMO, you will get the following 26 files: READTHIS.DOC, SETMODE.CBL, BORDER.CBL, DRAWLINE.CBL, GRAPHICS.CBL, BOX.CBL, POLYGON.CBL, INPUTSTR.CBL, INPUTNUM.CBL, SETPAGE.CBL, CHKPIXEL.CBL, PRINTSTR.CBL, LOCATE.CBL, INIMOUSE.CBL, MOUSEON.CBL, MOUSEOFF.CBL, SETPIXEL.CBL, GETCURS.CBL, GETPIXEL.CBL, CHKCOLOR.CBL, SWAP.CBL, CHKPAGE.CBL, SCROLL.CBL, CLEAR.CBL, MOUSEPGE.CBL, GETMOUSE.CBL READTHIS.DOC explains how to use the above 25 COBOL .CBL source files. The above program, GRAPHICS.CBL, demonstrates how to call almost all of the subprograms in the above list of .CBL files. This information applies to Microsoft COBOL Compiler 3.00 and 3.00a for MS-DOS.

More Information: The following excerpts are paraphrased from the READTHIS.DOC file; please see the complete READTHIS.DOC file for complete details:

COBOL GRAPHICS & MOUSE TOOLBOX --

Purpose
Attached are several sample programs that can be used to write graphics and mouse applications with Microsoft COBOL Compiler versions 3.00 and 3.00a for MS-DOS. They are written to be used with an EGA or VGA video card and would need to be modified to be used with a CGA card. The sample programs (referred to as “subprograms” hereafter) are written completely in COBOL and are designed to be used as a unit, like a toolbox. That is, each subprogram can perform one specific function that would be more or less pointless without calling one or more of the other subprograms. For instance, the subprogram SetMode can be used to put the screen into a graphics mode, and the subprogram DrawLine can then be used to draw a line on the screen. Note that all of the subprograms are meant to work only under DOS (OS/2 real mode). Using most of these subprograms in an OS/2 protected mode program will generate a protection violation.

The Workings of the Toolbox Subprograms
All of the subprograms in the toolbox that implement the graphics capabilities do so through interrupt calls to functions of the ROM BIOS video driver, interrupt 10 Hex. The subprograms that implement the mouse control call functions of the Microsoft Mouse driver, interrupt 33 hex. Although the toolbox subprograms are all documented, they do not provide explicit descriptions of all the interrupt 10 hex and 33 hex functions that they call. However, a very good source of information about the functions of those interrupts (and other interrupts) is Ray Duncan’s “Advanced MS-DOS Programming” (Microsoft Press, 1988). It is recommended that you refer to this book if you want a full understanding of interrupts 10 hex and 33 hex. Interrupts are called by COBOL programs via the special subprogram X“84”. This subprogram takes six parameters: an interrupt number, a flag field, and data items (called register parameters) that represent the four main 8086 registers (AX, BX, CX, and DX).

Available Screen Modes
The screen modes that are made available by this COBOL toolbox are taken right out of Ray Duncan’s book. The page, color, and coordinate limitations of each mode, plus the actual number of the mode itself can be found in the section of the book that describes the functions of interrupt 10 hex. Following is a brief table that shows all of the modes supported by the toolbox. The maximum page, color, and coordinate values, plus the mode’s number, are supplied.

Toolbox Screen Modes +======+======+========+========+========+=======+ | No. | Mode | X Cur. | Y Cur. | Colors | Pages | +======+======+========+========+========+=======+ | 01 | T | 39 | 24 | 15 | 7 | +——+——+——–+——–+——–+——-+========+========+ | 03 | T | 79 | 24 | 15 | 7 | X Pix. | Y Pix. | +——+——+——–+——–+——–+——-+========+========+ | 13 | G | 39 | 24 | 15 | 7 | 319 | 199 | +——+——+——–+——–+——–+——-+——–+——–+ | 14 | G | 79 | 24 | 15 | 3 | 639 | 199 | +——+——+——–+——–+——–+——-+——–+——–+ | 16 | G | 79 | 24 | 15 | 1 | 639 | 349 | +——+——+——–+——–+——–+——-+——–+——–+ | 18 | G | 79 | 29 | 15 | 0 | 639 | 479 | +——+——+——–+——–+——–+——-+——–+——–+ | 19 | G | 39 | 24 | 255 | 0 | 319 | 199 | +——+——+——–+——–+——–+——-+——–+——–+

NOTE: The minimum value for all coordinates, colors, and pages is 0. Also, modes 18 and 19 are supported only by VGA video cards. [Please see the READTHIS.DOC file for more information.]

Copyright Microsoft Corporation 1991.