From: "French Luser" Newsgroups: comp.os.cpm Subject: GSX-86 Version 1.3 Date: Wed, 2 Feb 2005 13:48:22 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Lines: 715 Message-ID: <4200ccb7$0$6614$8fcfb975@news.wanadoo.fr> Organization: les newsgroups par Wanadoo NNTP-Posting-Host: 81.49.7.71 X-Trace: 1107348664 news.wanadoo.fr 6614 81.49.7.71:20096 X-Complaints-To: abuse@wanadoo.fr GSX13ART.TXT ------------ "Digital Research's GSX: Graphics Portability" by William G. Wong in "MicroSystems", July 1984, p.74 (Retyped by Emmanuel ROCHE.) (Deals with GSX-86 v1.3 for the IBM PC.) Graphics software is becoming more and more common and important in computer applications. However, in the microcomputer industry, the lack of standard computer graphics interfaces has led to applications programs that must be customized for different machines, or are available for only one machine. The reason for this situation is that the leading microcomputer operating systems (CP/M-80, CP/M-86, Concurrent CP/M, MS-DOS and PC DOS) provide standard interfaces for disk storage and simple character I/O, but have no similar interfaces for graphics peripherals. The Graphics System eXtension (GSX) from Digital Research, Inc. (DRI) provides a standard graphics interface for the operating systems mentioned above. GSX complements these operating systems and has a similar structure, as shown below. Graphics Program | V Graphics Device Operating System (GDOS) Graphics I/O System (GIOS | V Graphics device: plotter, printer, etc. It handles internally all graphics-related service calls from the application program; service calls for disk storage and character I/O are passed to the operating system for processing. Structure of GSX ---------------- GSX, like CP/M or PC DOS, has two principal components: the Graphics Device Operating System (GDOS), and the Graphics Input/Output System (GIOS). The GDOS, like CP/M's BDOS, provides a standard interface between the applications program and the operating system. There is also a standard interface between the GDOS and the GIOS. Thus, GDOS and BDOS each support a standard set of functions that can be accessed by an application program, and that does not change from machine to machine. The GIOS and BIOS consist of hardware-dependent modules that convert service requests to the GDOS and BDOS into commands that are understood by the peripheral devices. The modules that controls a specific peripheral is usually called a "device driver"; there is one device driver for each peripheral attached to the system. Thus, changing the plotter merely requires that the GIOS incorporate a device driver for the new plotter. This structure ensures that an application program will run, without modification, on any machine that supports GSX. Of course, peripheral characteristics will affect the results. For instance, a program on a machine with a high-resolution plotter, may draw green, red, and blue circles, while the same program, run on a machine that has only a low-resolution printer, will give only good approximation of the circles in black and white. GSX environment --------------- GSX is a dynamic system that is loaded before running a graphics program, and remains resident until explicitly removed from the system, when no further graphics programs are to be run. This means that the memory overhead for GSX (about 15K for the 8080 version, about 24K for the 8086 version) is not incurred unless GSX is loaded. The loading process brings the GDOS and GIOS into memory. Unlike CPM's BIOS, which always contains a driver for every character I/O device in the system, and is resident at all times, the GIOS contains only one device driver -- initially, the driver for the default graphics device. Of course, this does not mean that you are restricted to one graphics peripheral: it merely means that GSX can work with only one peripheral at a time, so only one device driver is loaded at any one time, though the application program can request GSX to abandon the current device driver and load another one instead. This is the "workstation" concept. A given workstation has one, and only one, device driver associated with it. An applications program can request the opening of a workstation, in the same way that it might request a file to be opened. Some of the peripherals supported under GSX on the IBM PC are listed in Table 1 below. You will note that these fall into four device types: displays, plotters, printers, and cameras. Table 1. GSX drivers Displays -------- Artist 2 graphics card Hercules graphics card IBM PC color adapter (color mode) IBM PC color adapter (monochrome mode) IBM 3270-PC adapter (hi-res color mode) IBM 3270-PC adapter (monochrome mode) Plantronics PC+ Colorplus adapter Plotters -------- Hewlett-Packard 7470A/7475A Houston Instruments DMP-29/4X Strobe 100/200/260 Printers -------- Anadex DP-9001A/9501A/9625A C.Itoh 8510A Centronics 351/352/353 Data South DS-180 DEC LA50 and LA100 Diablo C150 Ink Jet IBM/EPSON FX-80 graphics printers IDS Prism 80/132/480 (monochrome) Mannesmann Tally MT160 (hi-res mode) Okidata MicroLine 92A/93A/84/92/93 Phillips GP300L Printronics MVP Transtar Color Cameras ------- Polaroid Palette Table 2 shows the workstation (logical device) numbers associated with each device class. Table 2. Logical device numbers Logical device number Device class --------------------- ------------ 1-10 Display 11-20 Plotter 21-30 Printer 31-40 (reserved for Metafile) 41-50 Other devices The association of workstation (logical device) numbers to device drivers is accomplished by means of a file designated ASSIGN.SYS. Each entry in this file consists of a workstation number, the name of the file containing the associated device driver, and (where necessary) a comment preceded by a semicolon (";"). The following is an example of an ASSIGN.SYS file: 1 A:IBMBLMP2 ; IBM Color adapter, monochrome mode 2 A:IBMBLCP2 ; IBM Color adapter, color mode 11 B:IBMHP7472 ; Hewlett-Packard 7470A/7475A Plotter 21 B:DD3EPSNH ; IBM/Epson FX-80 hi-res Printer This file may be created or modified with the aid of a text editor, or by using the GSX GINSTALL program. This program is menu driven and easy to use; it shows you the current status of the ASSIGN.SYS file, and allows you to make changes via menu selection, presenting device driver descriptions instead of merely the rather cryptic filenames. When your selections are complete, GINSTALL saves the new ASSIGN.SYS file, and copies all necessary device driver files to the selected program disk. Note that ASSIGN.SYS may specify more than one workstation number of a given class (e.g., the above example specifies two display devices), but a workstation number must be assigned to one, and only one, unique device driver name. Once ASSIGN.SYS has been set up, running an application program under GSX is easy. For example, to run DR DRAW under PC DOS, you would enter: GSX DRAW A similar sequence would start any GSX-based graphics application under PC DOS (under CP/M-86, GSX.EXE is replaced by GRAPHICS.CMD). (ROCHE> On my IBM Clown, I need to insert a "MOUSE" line between GSX and DRAW8086...) GDOS program interface ---------------------- The program/GDOS interface is very similar to the program/BDOS interface. There is a single entry point that accepts a function code (indicating a GSX call) and a ref to a parameter block. The GDOS performs the function, using the specified parameters, and then returns to the calling program. A status result for the open workstation is returned in the accumulator; any other results are returned through the parameter block. Listing 1 shows typical GSX calling sequences in assembly language for 8080 and 8086 machines. Listing 1. GSX calling sequences A) in 8080 assembly language: bdos EQU 0005H ; CP/M-80 entry point gsx EQU 115 ; GSX function number ; MVI C,gsx ; C = GSX function number LXI D,param ; DE = GSX parameter block CALL bdos ; Perform GSX function B) in 8086 assembly language: cpm EQU 224 ; CP/M-86 entry point gsx EQU 473h ; GSX function number ; MOV DX,OFFSET param ; DX = offset of param block MOV DS,SEG param ; DS = segment of param block MOV CX,gsx ; CX = GSX function number INT cpm ; Perform GSX function The parameter block, of which the FWA (First Word Address) is given in the calling sequence, contains five refs, as follows: 1. FWA of control array 2. FWA of input parameter array 3. FWA of input coordinate array 4. FWA of output parameter array 5. FWA of output coordinate array In the case of 8-bit machines, these FWAs are 16-bit addresses; in the case of 16-bit machines, they are standard 32-bit segment offsets. The arrays themselves are made up of 16-bit integers, regardless of the implementation. The length of each array is dependent upon the function to be performed, and is specified in the first part of the control array, as follows: 1. GSX function number 2. Input coordinate array size 3. Output coordinate array size 4. Input parameter array size 5. Ouput parameter array size Subsequent elements in the control array are dependent upon the GSX function number, and are not always required. Note that the coordinate array sizes come before the parameter array sizes; this is done because the GDOS converts the coordinate arrays for the GIOS, and since some conversion is always done, coordinate array sizes must always be given, even if the size is zero. Table 3 contains a list of the GSX function numbers. Table 3. GSX function numbers # Description -- ----------- 1 Open workstation 2 Close workstation 3 Clear workstation 4 Update workstation 5 Escape (device-specific operation) 6 Draw polyline 7 Draw polymarkers 8 Draw text 9 Draw filled area (polygon outline) 10 Display cell array 11 Perform Generalized Drawing Primitive (GDP) (such as drawing a circle or an arc) 12 Set character height 13 Set text direction 14 Set color representation 15 Set polyline line type 16 Set polyline line width 17 Set polyline color index 18 Set polymarker type 19 Set polymarker height 20 Set polymarker color 21 Set hardware text font 22 Set color index 23 Set interior fill style 24 Set fill style index 25 Set fill color 26 Return color representation 27 Return cell array definition 28 Return locator position 29 Return value of valuator device 30 Return choice device status keys 31 Return string from specified string device 32 Set writing mode 33 Set input mode Most of the functions are used for interrogating and changing the status of the workstation, including such operations as selecting line types (solid, dotted, etc.) or finding out what font is being used. Graphics input devices can also be accessed by means of the GDOS functions; many device drivers include support for keyboards, cursor keys, mice, light pens, touch screens, and graphic tablets. Functions 6-11 are the ones that actually draw. Complex figures, such as arcs and circles, are drawn using Generalized Drawing Primitives (GDP) function #11. Table 4 lists the available GDP functions. Table 4. Generalized Drawing Primitive (GDP) subfunctions # Description ---- ----------- 1 Draw a bar 2 Draw an arc 3 Draw a pie slice (filled ard) 4 Draw a circle 5 Print graphic characters 6-7 Reserved for future use 8-10 Unused and available for special functions The main difference between the GSX polyline and polymarker and the corresponding GDP function is that the latter requires only one call per figure. Some devices support additional modes and operations, such as reverse video or hard copy output (display devices). These are accessed using the GSX Escape function (#5), instead of enumerating them as primary GSX function numbers. Table 5 lists the current Escape functions. Table 5. GSX Escape subfunctions # Descriptions ------ ------------ 1 Inquire addressable character cells (return number of rows and columns) 2 Enter graphics mode 3 Exit graphics mode 4 Move cursor up one row 5 Move cursor down one row 6 Move cursor right one column 7 Move cursor left one column 8 Move cursor to home position 9 Erase to end of screen 10 Erase to end of line 11 Move cursor to specified position 12 Output cursor addresssable text 13 Turn on reverse video for text 14 Turn off reverse video for text 15 Inquire current cursor address (return current row and column) 16 inquire tablet status 17 Make hardcopy 18 Move graphic cursor to specified position 19 Do not display graphic cursor 20-50 Reserved for future expansion 51-100 Unused and available for special functions Note that both the GDP functions and the GSX Escape subfunctions contain reserved functions numbers, as well as unused but available numbers. This means that the GSX can be upgraded by the addition of new operations, while still remaining compatible with existing software. The GSX functions can support almost any existing graphics device. A device driver should recognize any valid GSX function, even if the device does not support the function -- in which case no action should be performed. Devices with new features can be supported through the unused GDP and GSX Escape functions. The line and marker drawing functions are optimized for multiple line segments. This allows an application to generate a set of points and let the graphics device draw each item as fast as possible, without requiring the applications program to specify the individual segments. Listing 2 shows the source code for a program that draws a four-sided box, after selecting the appropriate line type, width and color. The polyline function allows a single function call to result in the drawing of all four sides, instead of having to perform four function calls, one for each line segment. ; GSXLINE.ASM ; ----------- ; ; GSX line drawing example in 8080 assembler. ; ;-------------------------------- ; bdos EQU 0005H ; CP/M-80 entry point gsx EQU 115 ; GSX function number ; ;-------------------------------- ; ORG 0100H ; Standard CP/M-80 COMmand file ; ;-------------------------------- ; Draw a box using four line segments. ; sample: lxi d,type ; Set polyline type call doit ; lxi d,width ; Set polyline width call doit ; lxi d,color ; Set polyline color call doit ; lxi d,box ; Finally, draw box ; ; Fall through to GSX call. ; ; Input: ; DE = parameter block (detailing what to do) ; C = GSX function number ; ; Output: ; A = GSX function result ; doit: mvi c,gsx ; Ask BDOS to perform jmp bdos ; a GSX function. ; ;-------------------------------- ; Polyline type parameter block. ; type DW tpyca ; Control array ref DW typipa ; Input parameter array ref DW 0 ; Input coordinate array ref DW typopa ; Output parameter array ref DW 0 ; Output coordinate array ref ; tpyca DW 15 ; Set polyline type function num DW 0 ; Input coordinate array size DW 0 ; Output coordinate array size ; typipa DW 1 ; Solid line ; typopa DS 2 ; Actual line type used ; ;-------------------------------- ; Polyline width parameter block. ; width DW widca ; Control array ref DW 0 ; Input parameter array ref DW widica ; Input coordinate array ref DW 0 ; Output parameter array ref DW widoca ; Output coordinate array ref ; widca DW 16 ; Set polyline type function num DW 1 ; Input coordinate array size DW 1 ; Output coordinate array size ; widica DW 1,0 ; Line width = 1 ; widoca DS 4 ; Actual line width used ; ;-------------------------------- ; Polyline color parameter block. ; color DW colca ; Control array ref DW colipa ; Input parameter array ref DW 0 ; Input coordinate array ref DW colopa ; Output parameter array ref DW 0 ; Output coordinate array ref ; colca DW 17 ; Set polyline function number DW 0 ; Input coordinate array size DW 0 ; Output coordinate array size ; colipa DW 1 ; Color index = 1 ; colopa DS 2 ; Actual color index used ; ;-------------------------------- ; Polyline box parameter block. ; box DW boxca ; Control array ref DW 0 ; Input parameter array ref DW boxica ; Input coordinate array ref DW 0 ; Output parameter array ref DW 0 ; Output coordinate array ref ; boxca DW 6 ; Draw polyline function number DW 5 ; Number of vertices DW 0 ; No output parameters ; boxica DW 0,0 ; Starting point DW 0,10 ; First line endpoint DW 10,10 ; Second line endpoint DW 10,0 ; Third line endpoint DW 0,0 ; Fourth line endpoint ; ;-------------------------------- ; END 0100H ; Standard CP/M-80 COMmand file The parameter blocks for setting the polyline parameters tend to be large in comparison to the box example. However, the setup is normally done only once, and the figures often consist of more than the four lines required in the example. In that case, more memory is required for the polyline endpoints. GIOS/GDOS interface ------------------- The GIOS/GDOS interface is referred to as the Virtual Device Interface (VDI); this VDI provides a consistent interface for device drivers. Each device driver receives a pointer to the same parameter block that was passed to the GDOS; the main difference is that the GIOS does not require a function code to be passed in a register, since a device driver can work only with its corresponding device. Normalized device coordinates ----------------------------- It might seem that the GDOS does nothing more than load the device drivers and pass function requests between the application and the driver. In fact, when passing information between the applications program and the GIOS, the GDOS does quite a lot of conversion, because the applications program specifies Normalized Device Coordinates (NDC), whereas the device driver expects Real Coordinates (RC). The range for normalized device coordinates never changes: it is always 0 to 32,767 for both x- and y-axes. On the other hand, the range for real coordinates may vary from device to device. For example, a typical display device has a range of 0-319 for the x-axis, and 0-199 for the y-axis. One consequence of this mapping is that a figure will always appear on the drawing surface of a device. Also, it is up to the applications program to take into account any aspect ratio that the graphic peripheral may have -- otherwise, circles may end up as ovals. This may be acceptable in some circumstances. Information about a device's real coordinate system and aspect ratio is available to an application program when a workstation is opened. Device drivers -------------- Device drivers perform the graphic operations specified by the GDOS functions. Drivers for displays, plotters, and camera devices tend to be straightforward, since hardware operations match the GDOS functions. The display and camera devices usually have sufficient memory allocated for the entire drawing surface of a CRT screen. Printer drivers, on the other hand, tend to be a bit more difficult because the hardware normally prints one line at a time, whereas GSX expects a two-dimensional drawing surface at all times. GSX printer drivers must therefore perform some special operations to accommodate GSX. A printer driver should first record all GDOS commands in an "object list", until a workstation update command is issued. The object list is kept in RAM, or on a disk file if insufficient RAM is available. The object list is then used to draw an internal copy of the graphics figures in a raster buffer that is also kept in RAM. The internal copy is then printed out, one line at a time. Unfortunately, the raster buffer can grow quite large if a printer has very high resolution. The DRI printer drivers use an additional step to keep the raster buffer to a manageable size, even though a full-size raster buffer may exceed one megabyte. The figure is logically divided into a number of strips, each of which has the full width of the printer, and is some convenient number of printer lines in depth. Thus, each strip may be considered as a window through which to view a portion of the complete figure. The display list is used to draw the figure onto each strip in turn, clipping any drawing operations at the edges of the strip. The raster buffer is then mapped onto the current strip and printed out, one line at a time. Obviously, this process requires the complete figure to be drawn several times -- the exact number depends upon the resolution of the printer and the size of the raster buffer. Low-resolution printers require only a few iterations, while high-resolution printers can require a dozen or more iterations, even with a 40 KB raster buffer. The disadvantage is that the iterations make the process slow; the advantage is that high-quality graphics can be printed even if only limited RAM is available. Software -------- Applications ------------ Programs that use graphics can be purchased from a number of vendors. Three graphic programs from DRI are: DR GRAPH, DR DRAW, and ACCESS 10. DR GRAPH provides business graphics, including pie charts and bar graphs; it can take data from many popular spreadsheet programs and convert it to graphs, or data may be entered directly from the keyboard. DR DRAW is a very flexible free-form drawing and drafting program; it even includes mouse support on the IBM PC. ACCESS 10 is a Tektronix 4010/14 graphics terminal emulator that allows a microcomputer to be connected to a graphics host computer. Other products using GSX include the SuperCalc 3 spreadsheet from Sorcim, and GraphPlan from Chang Labs. Program development ------------------- GSX is normally included with either a graphics application program or the operating system. This environment is intended for running graphics application programs, although it can be used for program development as well. For the more serious programmer, there is the "GSX-86 Programmer's Toolkit", available from DRI for $350. This package comes with information on the GINSTALL program, including customization notes, the GIOS interface, the GDOS interface, and support for compiled high-level languages. Also included are two diskettes containing device drivers for the IBM PC and more than 20 other drivers (running under PC DOS, CP/M-86, and Concurrent CP/M) for devices ranging from the popular IBM PC color adapter card to the high-resolution Polaroid Palette color camera. The high-level language support is in the form of language bindings for the 16-bit DRI compiler-based languages, including C, Pascal-MT+, PL/I, CBASIC, and Fortran-77. A demo program, with source code, is provided for each language. The language bindings allow graphics applications to be developed in a high-level language, without having to resort to assembly language interfaces. Support for large and small memory models is included. The best part of the deal is that the Toolkit comes with a licence to distribute GSX with a graphics application to IBM PC, PC-XT, and 3270-PC users, without having to pay royalties to DRI. The distribution rights cover the set of drivers supplied with the package. You can also include your own drivers for peripherals not included in the Toolkit set. Also, a "Professional Programmer Support" contract can be purchased with the Toolkit, to provide additional GSX support from DRI. The "GSX-86 Programmer's Toolkit" is not for everyone. Casual programmers can make use of GSX interfaces supplied with languages such as CBASIC without having to purchase the Toolkit. 8087 support ------------ GSX supports the Intel 8087 numeric coprocessor chip in Fortran-77 applications only. The 8087 is not usually used by device drivers, but can speed up translation of normalized to real coordinates. The amount of speed increase depends on the device used and the type of figure being drawn. Summary ------- Version 1.3 is the latest release of GSX, and is available now. Version 2 (ROCHE> Which became known as "GEM".) is in the works, and will be available soon; it will provide better throughput and more graphics functions. New complex drawing primitives, such as ellipses and elliptical arcs, are to be included. Mapping between normalized device coordinates and real coordinates will also be included, and should simplify the development of graphics applications and device drivers. Raster operations, such as contour fill, will be supported. Look for GSX running under UNIX System V, which DRI is putting on the Intel 80286, as well as on new 68000-based machines (ROCHE> The Atari 520ST family.). From a programmer's point of view, GSX has certain limitations: it allows only one workstation to be open at a time, and this prevents sophisticated programs from driving two devices (such as two displays) simultaneously. However, GSX does permit the switching of workstations; DR DRAW, for example, lets you create a figure on a display device and immediately run off a copy on a printer, plotter, or camera device. GSX offers a standard method of dealing with graphics devices. New devices can be installed, merely by running GINSTALL to include the proper driver. Device drivers are usually supplied by the hardware manufacturer, and this allows a GSX graphics application program to take advantage of new and different peripherals. Graphics applications programs can be run without modification on any machine that supports GSX. Couple this with the ability to select a wide variety of device, and you get an extremely rich and flexible graphics environment. GSX is definitely a winner. EOF