
     This directory contains all the source code  to  "poly.exe" .
     To run, type:

        poly

1. If You Use QNX:
    This same software is available free from:

            Micro Business Applications
              QNX Free-Software Board
                (415) 824-1098  
    To get it:

     $ cd 3:/        ( move to ramdisk)
     $ talk -l +f    ( dial up, connect, type ..<CR>, login to guest )
     % cd  free/games/space
     % send 0.c
     % send 1.a
     % send 2.a      ( you've got it, logoff or browse )

     To compile the three modules:
     $ cco 0
     $ asm 1.a 1.o
     $ asm 2.a 2.o
     $ linkobj 0.o 1.o 2.o c=poly


2. Converting The Code To DOS or Whatever:

        This asm.  8086 source module, poly.a, is in QNX format.  The
     manner in which you enter and leave  a  function  call  maybe  a
     little different  on your system. The asm.8086 code is about the
     same as MSDOS, but with a few changes:

         QNX:                MSDOS:

         mov cx, #100        mov cx, 100
         movw                movsw  ax
         shl                 shl    ax
       b shl                 shl    al
         rep stob            rep  stos al
         mov cx, #0fff0h     mov  cx, $fff0

     Note that QNX uses the # to indicate immediate addressing.

     QNX Directives:

         seg 1  - Start code segment
         seg 2  - Start data constants segment
         seg 3  - Start data zeroed    segment
         rmb    - Reserve n bytes
         b data - Btye Data
         w data - Word Data


2. Theory and Operation:

        The two graphic primitives which allow you to fill areas  and
     draw  lines  in  the  medium  resolution  graphics  mode for the
     standard IBM  PC  color  graphics  card.    The  two  documented
     assembly  routines,  "polyfill",  and  "gline"  are  the fastest
     possible implementations of their graphic functions.

        The program "poly" demonstrates the use of both routines, the
     program generates regular polygons of random sides,  sizes,  and
     colors.   The file poly.c containing the main program is easy to
     understand and shows you how to incorporate "polyfill".  If  you
     do  graphics with IBM PC's and you like having the source to all
     of your program fuctions, then these two graphic primitives  may
     be a  big  help.    Also,  you  may  change them for a different
     resolution graphics cards, ect, ect.

        The routine "polyfill" fills in any polygon you define and can
     even put a border of a different color around it.  The fill color
     is  two pixels meshed to give you ten possible colors rather that
     just four.

        Both  routines use Bresenham`s algorithm to define the boundry
     of the slope to within 45 degrees through the use of straight and
     diagonal directions.  The slope is then fine tuned with  straight
     and diagonal error factors, so that the line  alternates  between
     the two directions.

           D  S  D                  D                .....line
            \ | /                  /            .....
        S____\|/_____S            /        .....
             /|\                 /    .....
            / | \               /.....
           D  S  D             /__________________________S

        The  Bresenham  code  originated  from the book, "Bluebook of
     Assembly Routines" by C.L.  Morgan, The  Waite  Group.

        Before calling ether routine first set the  extended  segment
     and the clipping window. 

        es=0xb800; xmin=ymin=0; xmax=319; ymax=199;

        I hope this software is useful to those of you who have need
     of some fast graphic primitives.

     Geodesic Publications, P.O.Box 7, Willow Creek, CA. 95573

