Program Notes The following notes, keyed to comments in each program, explain the differences: Note 1 - MSCGRF.C takes advantage of the random function added as a macro. The random function generates an integer random number in the range from zero to n, where n is the largest required number. The random function depends on using an unsigned maximum integer random number, the manifest constant RAND_MAX. The Microsoft C stdlib.h header defines RAND_MAX as a signed integer. Borland C++ has a built-in random function. Note 2 - MSCGRF.C #defines the path where it can find its .FON font files. BGIGRF.C #defines the path where it can find its .BGI graphics driver files and .CHR font files. Generally, to give users of your programs with the utmost convenience, these paths would be generated as part of a software installation procedure, rather than being constants within a program. Note 3 - To use the sixteen colors common to VGA and EGA graphics, it is better to enumerate them within MSCGRF.C, instead of using a magic number constant for each color. The Borland C++ graphics.h header includes these definitions. Similarly, manifest constants for text direction, fill styles, the shape fill patterns themselves, and a viewport status struct must be added to the Microsoft graphics system. Because Microsoft C graphics does not report the current state of the viewport to your program, it is necessary to add a structured variable where this information is maintained. Note 4 - With the Microsoft C graphics system, it is useful to keep track of all available fonts and font family names so that your program has enough information available to choose the right fonts. Note 5 - See the commentary about Note 3. Note 6 - With the Microsoft C graphics system, you use the _getvideoconfig function to obtain information about the configuration of the graphics controller. With Borland C++, you call the initgraph function to detect the graphics controller and initialize the graphics system to use the right graphics driver. Then you call various BGI functions to find out the properties of the graphics adapter being used. Note 7 - Microsoft C does not have a built-in function to delay program execution for a time interval. The Borland C++ delay function is defined in the dos.h header. Note 8 - Use the _setvideomode function to reset the graphics adapter before exiting from a Microsoft C graphics program. Use the closegraph function to reset the graphics adapter before exiting from a Borland C++ BGI program. Note 9 - The respective Initialize functions with their associated variables and structures show many of the differences between Microsoft C and Borland C++ BGI graphics. Microsoft C does not have a function to calculate the aspect ratio of the graphics adapter. With Microsoft C, as part of the initialization process for a graphics program, it makes sense to initialize tables that contain the attributes of each .FON file, and the name of each font family. Note 10 - The respective ReportStatus functions with their associated variables and structures reveal other differences between Microsoft C and Borland C++ BGI graphics. Absent from the status report displayed by MSCGRF.C is data about the current text, palette, and clipping settings of the graphics system, because Microsoft C graphics does not have functions that obtain this information. Microsoft C graphics does not provide a function to control the width of a line, so there is no status here either. Microsoft C uses the term "fill mask" to mean the same thing as the Borland C++ "fill style". Note 11 - The TextDump functions display all of the characters in each of fonts available with Microsoft C and Borland C++ graphics. The Microsoft C version displays each individual bitmapped font in its point size, and each vector font at its default height. The Borland C++ version displays all of the vector fonts at different heights depending on the typeface and display adapter combination. In this function and throughout the rest of the Microsoft C program, the graphics viewport settings are managed independently of the graphics library, which has no mechanism for reporting the current state of the viewport. The Microsoft C program also manages text justification directly, because it does not have the Borland C++ settextjustify function. Note 12 - The Borland C++ bar3d function draws the outline of a rectangle and fills it with the current fill pattern. It also does not draw the rectangle transparently, instead covering over the entire area with either the fill color or a background color. As a result, data that was displayed on screen previously does not "show through" the fill pattern of the rectangle. To achieve the same effect, which is a most common one in graphics applications, Microsoft C requires that you do a series of _rectangle operations, each of which accomplishes part of the desired result. First, you need to save the previous write mode, and set the write mode that you want. This tells the _rectangle function how to combine the image of the rectangle with the existing data on screen. The _GPSET constant replaces the data on screen with the rectangle being drawn. Then, you have to draw a rectangle with a solid black interior. This step takes care of erasing the image underneath so that it does not show through the rectangle to be drawn. Next, you have to draw separately both the border and the interior with the fill pattern and color that you want. Finally, restore the previous write mode with another _setwritemode function. The _polygon function used by the Microsoft C version of PolyDemo requires painstaking treatment - 2 - similar to _rectangle when drawing and filling a polygon superimposed over other data on the screen. Note 13 - The TextDemo function shows clearly the differences in managing display fonts between Microsoft C and Borland C++. Similar to the TextDump function discussed previously, the Microsoft C TextDemo contains additional statements to justify text. The Microsoft C version of TextDemo displays one screen for every font family. For bitmapped fonts, this means that all sizes of fonts in a given family are displayed on the same screen. For each Microsoft C vector font, a single screen shows you a given font scaled to various sizes and height-to-width ratios. The Borland C++ version of TextDemo displays each vector font scaled to various sizes and height-to-width ratios. The Borland C++ 8x8 pixel default can only have a height-to-width ratio of one-to- one. Note 14 - The ColorDemo functions use comparable functions to display boxes in the current color palette in Microsoft C and Borland C++. Note 15 - The Microsoft C version of ArcDemo calculates the bounding rectangle coordinates and the endpoint coordinates from the center point, radius, starting angle, and ending angle. The Borland C++ version draws arc and connecting lines directly from the center point, and other data. Note 16 - The Microsoft C CircleDemo contains added statements to calculate the bounding rectangle of the circle that is drawn. Note 17 - Similar to the other functions, the Microsoft C PieDemo contains additional statements to calculate bounding rectangles for the pie slices that it draws and to justify text annotations. Note 18 - The comments in the previous note also apply to BarDemo, a sample two-dimensional bar graph. Note 19 - The most notable difference between the two versions of FillStyleDemo is that you must define your own fill patterns with Microsoft C, whereas you can use the built-in fill patterns of Borland C++, or define your own. Note 20 - To change the colors in the EGA/VGA palette, an RGB macro is a handy addition to the Microsoft version of PaletteDemo for mixing the right proportions of red, green and blue with the _remappalette function. Note 21 - The changetextstyle functions reflect the differences in selecting and managing fonts between Microsoft C and Borland C++. With the former, the _setfont function takes a null terminated ASCII string which describes the typeface, required height, required width, and other arguments. Depending on your parameters, _setfont chooses either a font that matches your requirements exactly, or it selects a best fit, which sometimes - 3 - produces a surprising result. The Borland C++ settextstyle function chooses a font by its index number, and sizes it to your specifications. The font indices are all identified by manifest constants defined in the Borland C++ graphics.h header file. Note 22 - Microsoft C does not have a delay function defined in its dos.h header file, so MSCGRF.C contains its own.