newdevice -- Adding a New Device

In order to add a new device to CIGAL you will need to modify several files. Most of these involve minor changes.
1) MACDEP.H -- Machine dependent definitions header file
You should probably add a DEFINE statement here to identify your new
device, and perhaps comment out the DEFINE statements for devices you
don't have.
2) MTXSUB.C -- Device dependent subroutines for Matrox image processor.
This file contains most of the device dependent code. The current
version is for the Matrox MVP-AT image processor. You should use this
file as a guide for modifying the subroutines to suit your device.
I suggest copying MTXSUB.C to a new file (for example NEWSUB.C) and
changing any code delimited by "#IFDEF MTX_MVP" to suit your needs.
This file also contains some device dependent code associated with the
PC's video display systems, which you probably don't want to change, so
exercise some caution before chopping out bits that lie outside the
MTX_MVP conditional blocks.

The following is a brief description of the subroutines in MTXSUB.C:
IPINIT - initialize the image processor
IPCLOS - close the image processor (probably not needed unless you
have more than one)
MEMNUM - device variables are identified by numbers; MEMNUM converts
these variable numbers to internal device numbers and flags
GDEVVB - called by GTVARB in CVARBS.C to find out about size, type,
and dimensions of a device variable (also allocates buffer)
DEVPTR - local routine called by GDEVVB to get dimensions of variable
DEVIO - read and write to a device variable (called from CBLKIO.C)
IPMOVE - image processor graphics: move to screen position
IPDRAW - image processor graphics: draw to screen position
IPTEXT - image processor graphics: put text at screen position
IPCURS - display cursor on screen (currently draws software cursor)
IPCLER - clear image processor memory (called from DEVSUB.C)
IPERAS - local routine to erase 1 memory plane (called from IPCLER)
HARDOP - do image processor arithmetic; if hardware can do indicated
operation on given memories then do it -- if not return 0
IPALU - primitive routine for doing i.p. operations -- not really
necessary in this context
DIGTIZ - digitize an image from a video input into i.p. memory
IPWAIT - wait for next vertical refresh -- not really necessary
ROAM - pan and scroll the current display
IPZOOM - zoom, pan, and scroll the display
IPVIEW - select which memory plane(s) to view
IPANAL - if hardware can generate intensity histogram then do so;
otherwise return 0
IPCONV - if hardware can do indicated convolution then do so;
otherwise return 0
IPMAP - if hardware can do indicated lookup table mapping then do
so; otherwise return 0

3) DEVSUB.C -- Other device related subroutines. Most routines here
aren't actually device dependent anymore. The 3 to check are:
GDVPRM - get device parameters; the values of device dependent
number variables (defined in VNAMES.H and VNAMES.INI) are
returned by this routine
SDVPRM - set device parameters; if you change the value of a device
dependent number variable then this routine is called to
pass the new value to the appropriate device flag
DRWCUR - this routine is used to generate a software cursor and may
need to be modified if your device doesn't have a cursor
generator (currently called from IPCURS and elsewhere)

4) PRIMS.H, PRIMS.INI, PRIMS.C -- Device primitive routines.
You can add any or all library routines for your device as CIGAL
"primitives" by putting them into these 3 files. This is a way to
incorporate the maximum device flexibility without weighing CIGAL down
with the idiosyncrasies of individual peripherals. With CIGAL's
macro capabilities and a suitable primitive interface you can quickly
make effective use of any device.

PRIMS.INI - contains the names of the routines in a command table of
character strings. It is a good idea to add some
arbitrary prefix character to all these names to prevent
conflict with other CIGAL commands that might have similar
names.
PRIMS.H - DEFINE statements for each of the primitives.
PRIMS.C - the interface to call device dependent primitives. DOPRIM
is called by the CALL command in DOCMND.C. DOPRIM simply
passes CIGAL command line arguments to and from the
primitives, doing a minimum amount of error checking and
data massaging.

These three files are currently set up to run routines from the Matrox
software library. Use them as a model for creating your own primitives.
You can include as many routines as you like; however they can make the
program rather large, and in my experience most of them are never used.

5) CIGAL and CIGAL.LNK -- These two files control compilation and linking.

CIGAL - is set up to be read by the MAKE program builder (Microsoft version,
but I assume there are others). It is a table defining which source files
make which object and executable files. If you don't have MAKE then just use
this as a guide; basically you just compile all the C sources and then run LINK.
If you do have MAKE, then change the MTXSUB references to your NEWSUB file
(or whatever it may be called).
CIGAL.LNK - the command file for the linker program LINK. You should put your
file name in here instead of MTXSUB, and also add your device dependent library.

That should be about it. Once you have the basic device interface working then of course you may want to add other device related commands as well. See CUSTOMIZE[1] for information on adding new commands. Good luck!