Graphics drivers for PC

Last software update: 7 February 1995.

In response to popular demand, I am herewith making available
the sources for my low-level graphics modules for the PC.
These may be freely used and modified, subject only to the
condition that they may not be sold or used in any product
which is sold. (For for-profit applications, please contact
the author.) Future versions might come with more stringent
conditions.

These modules are part of the PMOS
library; I've extracted this small subset of modules for the
benefit of those who want only the low-level graphics. (If
you already have PMOS version 2.2, don't bother fetching this
graphics package - you already have it.)

To obtain the graphics package, fetch the file graf004.zip (don't forget to set binary mode for ftp transfers).

What is included

The graphics sources come in three modules: Graphics, Screen,
and LowLevel. Graphics is the main module; the other two are
subsidiary modules to provide lower-level functions. The
source language is Modula-2.
The zip file also includes two executables:

LINEDEMO.EXE: A short demonstration which should give you a
feel for the speed of the software.

VIDCHK.EXE: A program which tells you which graphics modes the
software will support on your hardware.

Warning: LINEDEMO.EXE hooks the timer interrupt and therefore might
be incompatible with some software configurations. In addition,
both demonstration programs can crash your machine if they invoke
video modes for which your BIOS or adaptor is buggy. There is no quick
fix for this latter problem, apart from upgrading your video BIOS
to a version which has a different set of bugs.

The package does NOT include higher-level features such as screen
windows. If you want such things you'll have to fetch the entire
PMOS package.

Hardware supported

The package supports Hercules, CGA, EGA, VGA, and some
SVGA modes. If you have SVGA hardware that the software doesn't
know about, the VGA and VESA support should still work.

Limitation: although we do most things via direct access to the
hardware, mode setting is done by BIOS calls. Since the BIOS software
on video adaptors is usually buggy - it's apparently written by the same
people who have given such a bad reputation to Windows and OS/2
screen drivers - you will probably find one or more modes that don't
work. The faulty modes seem to vary from model to model and are
hard to predict. The solution is to modify the "Screen" module to
disable the modes that don't work on your hardware.

Features provided

The software allows the plotting of dots, straight lines,
characters and character strings, filling a rectangular region,
and block copy. I haven't yet got around to fancy things like stroked
character sets, polygon fill, etc., and given the amount of
work required I might never get around to these.

SVGA support includes 256-colour, 32K-colour and 64K-colour modes,
but for efficiency reasons I've left out 24-bit colour support.
Graphics accelerator support is not yet available; I'm hoping to
add it for ATI, S3, and Trident, maybe for other chips if the demand is
strong enough, but the available documentation is so poor that it's
hard to predict when and if this will be done.

Portability

By its very nature this software does a lot of low-level byte
and bit twiddling, so it uses some non-portable compiler features.
To ease the pain of porting I've put most - but not yet all
- of the non-portable operations into the LowLevel module, so if
you're porting to another compiler the first thing you should do is
write a new version of LowLevel. (This should be easy; LowLevel is
a moderately large collection of procedures, but each procedure does
something very simple.)

The software as supplied works with TopSpeed Modula-2 version 3.
By running it through the PP preprocessor (see the information on
PMOS) you can get a working version for
TopSpeed version 1.17. Porting to other dialects of Modula-2 should
be easy.

Porting to another language is possible in principle - and
certainly easier than starting the whole job from scratch - but
might result in a loss of execution speed. For the sake of
run-time efficiency, the code uses features of the Modula-2
language that might be hard to emulate in languages which are
less suited for systems programming.