next up previous contents
Next: Objective C primitives Up: Primitive drawing functions Previous: Plot primitives   Contents

PC/DOS primitives

Early microcomputers included varying degrees of graphics presentation, mostly of fairly low resolution. Some were programmed to drive CalComp plotters, just as had been done with earlier minicomputers, such as the PDP-8. With the introduction of the IBM/PC, a standard for graphics presentation was established which was widely disseminated, beginning with the CGA video board.

At first, one of the interrupts of the INTEL 8088, interrupt 10, was dedicated to communication with the video monitor, which was arranged for two modes of operation, graphics and text. The reason for the latter was a matter of bandwidth; the use of a character generator driven by ASCII characters was much better than any other system for placing dots in the graphics bitmap. As a consequence, the ROM BIOS underlying the MS/DOS operating system contained a provision for a mixture of approximately sixteen text and graphics primitives.

Early C compilers offered as close an approximation to these sixteen primitives as was possible within the syntax of the language. Later on, more elaborate graphic functions were included within the runtime libraries, corresponding to a certain perception of users requirements, or simply of their imagined desires.

From the point of view of developing an integrated graphics environment, it turns out that the first offerings were the best; fortunately they already contained direct access to individual pixels, which was an adequate foundation upon which to build a graphics package.

The entire set of functions consisted of videobackground - set the color of the frame

-
videocmode - Set the cursor style
-
videomode - Choose between text or graphic mode
-
videopalette - Include or discard blue in the color image
-
videodot - Place a dot of given color at prescribed coordinates
-
videoputc - Place a character on the screen
-
videochar - similar to videocattr, without color coding
-
videocattr - deposit a character with prescribed color and background
-
videoscroll - Block movement of text or clearing of the screen
-
videocursor - Position the cursor (defining the location of text)
-
videopage - Select the text page to be displayed
-
videogchar - Report the character at the urrsor location
-
videogcmode - Find out the cursor mode
-
videogcols - Find out the screen width
-
videogcursor - Find out the cursor location
-
videogdot - Find out the color of the current pixel
-
videogmode - Find out the current mode
-
videogpage - Find out the current page
-
videogpen - Fetch the light pen parameters


Only the items shown in boldface were ever used to write programs such as GEOM, and of those, videodot was the essential function for creating computer graphics. The principal problem in changing over to Objective C lies in substituting printf, which is not a video function at all, but nevertheless uses one of the BIOS interrupts to put text on the screen, irrespective of whether it is in text or graphics mode. It is this detail especially, which complicates any simple substitution of video functions when changing from one operating system to another.

The following comprises the header file which has always been incorporated in TURBO C programs to make them compatible with WIZARD C programs, making the use of any TURBO C functions unnecessary. Such a substitution is feasible because both C compilers still create code for MS/DOS, in which the BIOS and screen interrupts are the same.

As for the code, one places the whole interrupt-10 package in its own .obj file. The file is relatively small, inasmuch as the functions merely transfer arguments between the stack and the registers of the CPU, conforming to differences between assembly language and C's stack protocol.

 
/*                                                                        */
/*        VIDEOH.H:        Function prototypes                            */
/*                                                                        */
/*        By :  Saturnino Julio De La Trinidad H.                         */
/*                                                                        */
/*        Departamento de Aplicacion de Microcomputadoras                 */
/*        Instituto de Ciencias de la Universidad Autonoma de Puebla      */
/*                                                                        */

#if __STDC__
#define _Cdecl
#else
#define _Cdecl        cdecl
#endif

#if     !defined(__WIZARD_DEF_)
#define __WIZARD_DEF_

 void far _Cdecl  videobackground(int color);
 void far _Cdecl  videocattr(int page, char byte, char attr, int count);
 void far _Cdecl  videochar(int page, char byte, int count);
 void far _Cdecl  videocmode(int startrow, int endrow);
 void far _Cdecl  videocursor(int page, int row, int column);
 void far _Cdecl  videodot(int pixelrow, int pixelcolumn, int color);
 void far _Cdecl  videomode(int mode);
 void far _Cdecl  videopage(int page);
 void far _Cdecl  videopalette(int colorset);
 void far _Cdecl  videoputc(char byte, int color);
 void far _Cdecl  videoscroll(int ulrow, int ulcol, int lrrow, int lrcol,
                                                       int lines, int attr);
 int  far _Cdecl  videogchar(int page);
 int  far _Cdecl  videogcmode(void);
 int  far _Cdecl  videogcols(void);
 int  far _Cdecl  videogcursor(int page);
 int  far _Cdecl  videogdot(int pixelrow, int pixelcolumn);
 int  far _Cdecl  videogmode(void);
 int  far _Cdecl  videogpage(void);

 struct pen {
        char                charrow;
        char                charcolumn;
        unsigned char        pixelrow;
        unsigned char        pixelcolumn;
        };

 int  far _Cdecl  videogpen(struct pen *penv);

 #endif


next up previous contents
Next: Objective C primitives Up: Primitive drawing functions Previous: Plot primitives   Contents
Pedro Hernandez 2004-05-13