Reading the _videoconfig Structure

At any time, you can inquire about the current video configuration by passing the _getvideoconfig function a structure of type _videoconfig. The structure contains 11 members, all of which are short integers. They are listed in Table 9.2.

Table 9.2 Members of a _videoconfig Structure

Member Description

numxpixels Number of pixels on the x axis
numypixels Number of pixels on the y axis
numtextcols Number of text columns available
numtextrows Number of text rows available
numcolors Number of color indexes
bitsperpixel Number of bits per pixel
numvideopages Number of video pages available
mode* Current video mode
adapter* Active display adapter
monitor* Active display monitor
memory Adapter video memory in kilobytes

* Possible values for the mode, adapter, and monitor items are listed in the GRAPH.H file.

The _getvideoconfig function initializes these values. Most of the values are self-explanatory. For example, if numxpixels holds 640, the current video mode contains 640 horizontal pixels, numbered 0–639.

The READVC.C example program below illustrates how to initialize and examine a _videoconfig structure:

/* READVC.C — Reads the _videoconfig structure */

#include <graph.h>

#include <stdio.h>

main()

{

struct _videoconfig vc;

_getvideoconfig( &vc );

printf( “Text Rows = %i.\n”, vc.numtextrows );

}

First, the program declares a structure vc of type _videoconfig. Next, it calls _getvideoconfig to initialize the structure. Finally, it prints a member of the structure.