Notes for the Companion Disk to
"Programmer's Guide to PC Video Systems"
(c) Richard Wilton, 1994


You may freely compile and link the source code into your 
own software programs, providing that you do not redistribute 
the source code or the .OBJ files.  If you want to 
redistribute the source code or the .OBJ files, you must 
obtain written permission by contacting 

         Attn.:  Permissions
         Microsoft Press
         One Microsoft Way
         Redmond, WA  98052-6399


Contents:

         Part 1.   If You Encounter Problems
         Part 2.   Installing the Source Code
         Part 3.   Compiling, Assembling, and Linking
         Part 4.   Examples Index
         Part 5.   Contents of SOURCE Subdirectories


===< Part 1: If You Encounter Problems >====================

If you require a replacement disk, please call

         Microsoft Sales and Service
         1-800-426-9400

If you encounter a problem with any of the programs,
please write to

         Attn.:  Video Systems Editor
         Microsoft Press
         One Microsoft Way
         Redmond, WA  98052-6399


===< Part 2: Installing the Source Code >===============

There are two parallel sets of source code on this
disk: one for use with Microsoft language products
and one for Borland language products.


Microsoft-compatible source code:

The \VS2M directory on this Companion Disk contains
the compressed, Microsoft-compatible source code files
and an INSTALL.EXE utility that decompresses the files
and copies them to your hard disk.  To install the source
code, put the Companion Disk in your A: drive, change to the
A:\VS2M directory, and type

    INSTALL

The decompression program on the disk will tell you what to
do at each step of the unpacking process.


Borland-compatible source code:

The \VS2B directory on this Companion Disk contains
the compressed, Borland-compatible source code files
and an INSTALL.EXE utility that decompresses the files
and copies them to your hard disk.  To install the source
code, put the Companion Disk in your A: drive, change to the
A:\VS2B directory, and type

    INSTALL

The decompression program on the disk will tell you what to
do at each step of the unpacking process.

The installation procedure leaves the source code in a
subdirectory tree that looks like this:

    \VS2M or \VS2B
        \INCLUDE - VS2.H
                 - VS2.INC
        \OBJ     - VS2.LIB
        \SOURCE
                \CH01  - source files for Chapter 1
                \CH02  - source files for Chapter 2
                \CH03  - source files for Chapter 3
                \CH04  - source files for Chapter 4
                \CH05  - source files for Chapter 5
                \CH06  - source files for Chapter 6
                \CH07  - source files for Chapter 7
                \CH08  - source files for Chapter 8
                \CH09  - source files for Chapter 9
                \CH10  - source files for Chapter 10
                \CH11  - source files for Chapter 11
                \CH12  - source files for Chapter 12
                \CH13  - source files for Chapter 13
                \APXA  - source files for Appendix A
                \APXB  - source files for Appendix B
                \EXTRA - source files for CGA, EGA, etc.
                \TEST  - test and demo programs

The source code occupies about 1.1 MB of disk space.


===< Part 3: Compiling, Assembling, and Linking >=======

The top-level subdirectory (\VS2M or \VS2B) contains a file that
compiles, assembles, and links all the source code in
all of the subdirectories.

Before you compile, make sure that the PATH, INCLUDE, and
LIB environment variables are set appropriately for
your compiler.


Microsoft-compatible source code:

If you are using Microsoft C/C++, MASM, Microsoft LINK,
and Microsoft LIB, type

    cd \VS2M
    nmake

The source code has been successfully compiled using the
following Microsoft products:

    Microsoft C/C++ v7.00 and later
    Microsoft MASM  v6.0


Borland-compatible source code:

If you are using Borland C/C++, TASM, Borland TLINK, and
Borland TLIB, type

    cd \VS2B
    makeall

The source code has been successfully compiled using the
following Borland products:

    Borland C/C++ v4.00
    Borland TASM  v4.0

________________________________________________________

Notes on compiling the source code:

The source files are compiled and assembled in two
phases.  First, the static object library VS2.LIB is
created by assembling all functions that might be
required in order to build the executable files.
Then the source code for all the executable files is
compiled and the executables are linked with the
functions in VS2.LIB.

Some of the C-language source files compile with two
warning messages that can be safely ignored:

    - unreferenced formal parameters in function main()
    - no return value in function MulDiv()


===< Part 4: Examples Index >==============

Fig.   Function         Filename             Book Page
______________________________________________________

1-2    SetVMode         CH01\VMODE.ASM            7

   A routine that establishes a video mode via the
   ROM BIOS

1-3    GetVMode         CH01\VMODE.ASM            8

   A routine that returns the current BIOS video
   mode number

1-4                      CH01\SVM.C               9

   A program that calls SetVMode

1-5                      CH01\GVM.C               9

   A program that calls GetVMode
____________________________________________________

2-16   SetVMode256       CH02\SVM.ASM            34

   A routine that establishes nonchained VGA
   256-color graphics modes

2-29   ModeHGC           EXTRA\HGC.ASM           49

   A routine that configures a Hercules monochrome
   Graphics Card for 720-by-348 graphics mode

2-30   VNWait            CH02\VRWAIT.ASM         52

   A routine that detects the start of the vertical
   nondisplay interval
____________________________________________________

3-9    FadeDn16          CH03\FADE16.ASM         65

   A routine that produces a fade-to-black effect
   by cycling through palettes in the video DAC
____________________________________________________

4-5    PixelAddr10       CH04\PIXLADDR.ASM       90

   A routine that returns a pixel's address in
   VGA planar graphics modes

4-6    PixelAddr13       CH04\PIXLADDR.ASM       91

   A routine that returns a pixel's address in BIOS
   mode 13H

4-7    PixelAddr256      CH04\PIXLADDR.ASM       92

   A routine that returns a pixel's address in
   nonchained VGA 256-color graphics modes
____________________________________________________

5-11   GetPixel10        CH05\GETPIXEL.ASM      117

   A routine that returns a pixel's value in VGA
   planar graphics modes

5-12   GetPixel13        CH05\GETPIXEL.ASM      119

   A routine that returns a pixel's value in BIOS
   mode 13H

5-13   GetPixel256       CH05\GETPIXEL.ASM      120

   A routine that returns a pixel's value in
   nonchained VGA 256-color graphics modes

5-15   SP100b            EXTRA\VGA.ASM          122

   A routine that sets a pixel's value in VGA
   planar graphics modes using write mode 0 and the
   sequencer Map Mask register

5-16   SetPixel10        CH05\SETPIXEL.ASM      124

   A routine that sets a pixel's value in VGA planar
   graphics modes using write mode 2

5-17   SP103             EXTRA\VGA.ASM          125

   A routine that sets a pixel's value in VGA planar
   graphics modes using write mode 3

5-18   SetPixel13        CH05\SETPIXEL.ASM      127

   A routine that sets a pixel's value in BIOS mode
   13H

5-19   SetPixel256       CH05\SETPIXEL.ASM      127

   A routine that sets a pixel's value in
   nonchained VGA 256-color graphics modes

5-20   FillVBuf10        CH05\FILLVBUF.ASM      129

   A routine that fills the video buffer with a
   solid pattern in VGA planar graphics modes

5-23   FillVBuf256       CH05\FILLVBUF.ASM      131

   A routine that fills the video buffer with a
   solid pattern in nonchained VGA 256-color graphics
   modes

5-24   GetPixel06        EXTRA\CGA.ASM          132

   A routine that returns a pixel's value in CGA
   640-by-200 2-color mode

5-25   GetPixel04        EXTRA\CGA.ASM          133

   A routine that returns a pixel's value in CGA
   320-by-200 4-color mode

5-26   SetPixel06        EXTRA\CGA.ASM          134

   A routine that sets a pixel's value in CGA
   640-by-200 2-color mode

5-27   SetPixel04        EXTRA\CGA.ASM          135

   A routine that sets a pixel's value in CGA
   320-by-200 4-color mode
____________________________________________________

6-3    LineEq()          EXTRA\C_LINES.C        141

   A line-drawing program that uses the equation of
   a line

6-5    LineBres()        EXTRA\C_LINES.C        145

   A line-drawing program that uses Bresenham's
   algorithm

6-8    Line10            CH06\LINE.ASM          150

   A line-drawing routine for use with VGA planar
   graphics modes

6-9    Line13            CH06\LINE.ASM          159

   A line-drawing routine for use with BIOS mode
   13H

6-10   Line256           CH06\LINE.ASM          164

   A line-drawing routine for use with nonchained VGA
   256-color graphics modes
____________________________________________________

7-3    EllipseEq()       TEST\ELTEST.C          184

   An ellipse-drawing program that uses the
   equation of an ellipse

7-9    EllipseIncr()     TEST\ELTEST.C          191

   An ellipse-drawing program that uses the
   midpoint algorithm

7-10   Set4Pixels()      TEST\ELTEST.C          193

   A modified version of Set4Pixel() that avoids
   updating the same pixel twice

7-11   Ellipse10         CH07\ELLIPSE.ASM       194

   An ellipse-drawing routine for VGA planar graphics
   modes that uses the midpoint algorithm

7-16   CircleIncr()      TEST\CIRCTEST.C        205

   A high-level implementation of the midpoint
   algorithm for circles

7-17   Circle10          CH07\CIRCLE.ASM        206

   A circle-drawing routine for VGA planar graphics
   modes that uses the midpoint algorithm
____________________________________________________

8-3    SolidRectangle()  TEST\RECTTEST.C        216

   A rectangle-fill function that uses horizontal
   lines

8-5    PixelFill()       CH08\FILL1.C2          218

   A recursive region-fill function

8-6    LineAdjFill()     CH08\FILL1.C           219

   A recursive line-adjacency fill function

8-10   RegionFill()      CH08\FILL2.C           223

   A line-adjacency border-fill function

8-11   ScanRight         CH08\SCANPIXL.ASM      232

   An assembly language implementation of
   ScanRight() (See Figure 8-10)
____________________________________________________

9-3    BltToRAM10        CH09\BLT.ASM           242

   A video-buffer-to-system-RAM bit block transfer
   routine for VGA planar graphics modes

9-4    BltToVBuf10       CH09\BLT.ASM           250

   A system-RAM-to-video-buffer bit block transfer
   routine for VGA planar graphics modes

9-5    BltInVBuf10       CH09\BLT.ASM           260

   A video-buffer-to-video-buffer bit block transfer
   routine for VGA planar graphics modes
____________________________________________________

10-4   GlyphBlt10        CH10\GLYPHBLT.ASM      277

   A glyph block transfer routine for VGA planar
   graphics modes
____________________________________________________

11-5   ExposeCGenRAM     CH11\CGENRAM.ASM       295

   A routine that exposes character generator RAM
   by programming the sequencer and graphics
   controller registers

11-6   HideCGenRam       CH11\CGENRAM.ASM       297

   A routine that hides character generator RAM by
   restoring the sequencer and graphics controller
   registers to their default values

11-7                     CH11\CGRTEST.C         298

   A program that alters the alphanumeric character
   generator's glyph table

11-16  CSetTSR           CH11\CSETTSR.ASM       305

   A TSR that loads a character definition table
   into character generator RAM with each video
   mode change

11-18  BltToCGenRAM      CH11\CGENRAM.ASM       308

   A routine that displays a monochrome bitmap in
   an alphanumeric mode
____________________________________________________

12-1   EnableVNI         CH12\VNI.ASM           319

   Routines that enable and disable vertical
   nondisplay interrupts

12-2   ISR0A             CH12\VNI.ASM           322

   A vertical nondisplay interrupt handler

12-3                     TEST\VNITEST.C         325

   A program that counts vertical nondisplay
   interrupts

12-4   SetVBufDims       CH12\VBUF.ASM          327

   A routine that redimensions the video buffer

12-6   SetScreenOrg      CH12\VBUF.ASM          332

   A routine that resets the screen origin

12-9   SetScreenSplit    CH12\VBUF.ASM          339

   A routine that creates a split-screen effect

12-11  Test2()           TEST\ANITEST.C         343

   A function that enlarges a rectangle using XOR
   animation

12-12  Test3()           TEST\ANITEST.C         344

   A function that moves a bitmap using XOR
   animation

12-14  Test4()           TEST\ANITEST.C         346

   A function that moves an arrow using overlapping
   bitmap animation

12-15  Test5()           TEST\ANITEST.C         347

   A function that rotates the video DAC register
   contents to produce a flow of colors across the
   screen

12-18                    TEST\BOUNCE1.C         350

   A bouncing-ball animation program

12-19  EnableVNTimer     CH12\VNTIMER.ASM       356

   A routine that synchronizes system timer interrupts
   with the vertical nondisplay interval
____________________________________________________

13-3   SetPixel110       CH13\S3.ASM            370

   A routine that sets a pixel's value in VESA BIOS
   mode 110H

13-4   Line110           CH13\S3.ASM            372

   A routine that draws a line using an S3 SVGA
   accelerator

13-5   SetClip110        CH13\S3.ASM            376

   A routine that establishes a clipping rectangle
   using an S3 SVGA accelerator
____________________________________________________

A-11   EstablishPSA      APXA\SAVEAREA.ASM      392

   A routine that creates a Parameter Save Area
   to keep track of VGA palette registers

A-12   EstablishUPP      APXA\SAVEAREA.ASM      393

   A routine that creates a User Palette Profile
   to override the default 16-color VGA palette
____________________________________________________

B-1    Ellipse10X        EXTRA\E32.ASM          457

   A routine that draws an ellipse using the
   midpoint algorithm and 32-bit arithmetic


===< Part 5: Contents of SOURCE Subdirectories >==============

Directory  \CH01

GVM.C

   Returns current VGA video mode

SVM.C

   Sets video mode on all IBM-compatible video
   subsystems

VMODE.ASM

   Contains functions for retrieving and setting VGA video
   modes using the ROM BIOS and the VESA BIOS Extension
________________________________________________________

Directory  \CH02

AVMODE.C

   Sets VGA alphanumeric modes using a specified
   resolution and character height

GVMODE.C

   Sets VGA graphics modes using a specified
   pixel resolution

SVM256.ASM

   Establishes nonchained VGA 256-color graphics
   modes

VRWAIT.ASM

   Contains functions for detecting vertical retrace and
   vertical nondisplay intervals
________________________________________________________

Directory  \CH03

ALPHATXT.ASM

   Contains functions for displaying text, enabling
   blinking, and setting the border color

ATTEST.C

   Demonstrates the blinking attribute

CURSOR.ASM

   Contains functions for manipulating the cursor

FADE16.ASM

   Demonstrates fade-to-black effect by cycling through
   palettes in the video DAC

SVM.C

   Sets video mode on all IBM-compatible video
   subsystems; optionally sets border and background
   colors

________________________________________________________

Directory  \CH04

PIXLADDR.ASM

   Returns the address of a given pixel in VGA graphics
   modes

VSP.ASM

   Initializes the VIDEOSTATEPARAMS data structure

________________________________________________________

Directory  \CH05

FILLVBUF.ASM

   Contains functions for filling the video buffer in VGA
   graphics modes

GETPIXEL.ASM

   Returns the value of a given pixel in VGA graphics
   modes

SETPIXEL.ASM

   Sets the value of a given pixel in VGA graphics
   modes
________________________________________________________

Directory  \CH06

LINE.ASM

   Contains line-drawing routines for VGA graphics modes

________________________________________________________

Directory  \CH07

CIRCLE.ASM

   Draws circles in VGA graphics modes using the
   midpoint algorithm

ELLIPSE.ASM

   Draws ellipses in VGA graphics modes using the
   midpoint algorithm

________________________________________________________

Directory  \CH08

FILL1.C

   Demonstrates the "pixel-fill" and "line-adjacency-
   fill" region-fill algorithms

FILL2.C

   Demonstrates the "border-fill" region-fill algorithm

PATTERNS.C

   Contains miscellaneous region-fill test patterns

SCANPIXL.ASM

   Contains assembly language implementations of
   ScanRight() and ScanLeft() functions
________________________________________________________

Directory  \CH09

BLT.ASM

   Contains various bit block transfer (BitBlt) routines
________________________________________________________

Directory  \CH10

GLYPHBLT.ASM

   Contains bit block transfer (BitBlt) routines for
   glyphs
________________________________________________________

Directory  \CH11

*.CHR

   Various character glyph definitions (for use with
   CSETTSR.ASM and CGRTEST.C)

CGENRAM.ASM

   Contains routines for accessing and modifying character
   generator RAM in the video buffer

CSETTSR.ASM

   A TSR that displays alternate character glyph
   definitions
________________________________________________________

Directory  \CH12

VBUF.ASM

   Contains functions for manipulating video buffer
   attributes

VGADAC.ASM

   Contains functions for manipulating the video DAC

VNI.ASM

   Contains functions for enabling vertical nondisplay
   interrupts

VNIS3.ASM

   Contains functions for enabling vertical nondisplay
   interrupts (specific for S3 SVGA accelerators)

VNITIMER.ASM

   Contains functions for establishing timer interrupts
   synchronized with the vertical nondisplay interval
________________________________________________________

Directory  \CH13

S3.ASM

   Contains S3-specific drawing routines

S3TEST.C

   Tests functions in S3.ASM
________________________________________________________

Directory  \APXA

FN00.ASM
FN06.ASM
FN0C.ASM
FN0E.ASM
FN13.ASM
FN4F.ASM
M256X.ASM

   Source code for M256X.EXE, a memory-resident
   VESA BIOS Extension for nonchained VGA 256-color
   modes

SATEST.C

   Tests functions in SAVEAREA.ASM

SAVEAREA.ASM

   Contains functions for manipulating ROM BIOS save areas

VBEINFO.C

   Displays information about the VESA BIOS Extension

________________________________________________________

Directory  \APXB

E32.ASM

   Draws ellipses in planar VGA graphics modes using the
   midpoint algorithm (32-bit implementation for
   comparison with ELLIPSE.ASM)

________________________________________________________

Directory  \EXTRA

CGA.ASM

   Contains miscellaneous CGA-specific functions

EGA.ASM

   Contains miscellaneous EGA-specific functions

HGC.ASM

   Contains miscellaneous HGC-specific functions

VGA.ASM

   Contains miscellaneous VGA-specific functions
________________________________________________________

Directory  \TEST

16TEST.BMP

   A 16-color bitmap (use with TILE.EXE)

256TEST.BMP

   A 256-color bitmap (use with TILE.EXE)

A.BMP

   Letter "A" glyph (used by ALPHABLT.EXE)

AARDVARK.BMP

   Monochrome bitmap (use with ALPHABLT.EXE)

ALPHA.BMP

   Monochrome bitmap (use with ALPHABLT.EXE)

ALPHABLT.C

   Tests alphanumeric mode bit block transfer
   functions in CGENRAM.ASM

ANDBALL.BMP

   Bitmap mask (used by BOUNCE1.EXE and BOUNCE2.EXE)

ANITEST.C

   Demonstrates animation techniques

ATTEST.C

   Demonstrates alphanumeric attributes (colors,
   blinking, and intensity)

B.BMP

   Letter "B" glyph (used by ALPHABLT.EXE)

BKGDTILE.BMP

   Background tile bitmap (used by BOUNCE1.EXE
   and BOUNCE2.EXE)

BLTTEST.C

   Tests functions in BLT.ASM

BOUNCE1.C

   Bouncing-ball animation demo

BOUNCE2.C

   Bouncing-ball animation demo using timer interrupts
   synchronized with the vertical nondisplay interval

C.BMP

   Letter "C" glyph (used by ALPHABLT.EXE)

C_LINES.C

   Tests line-drawing algorithms

CGRTEST.C

   Tests functions in CGENRAM.ASM (see \CH11)

CIRCTEST.C

   Tests functions in CIRCLE.ASM

CLIPTEST.C

   Demonstrates the Sutherland-Cohen algorithm for
   clipping lines

D.BMP

   Letter "D" glyph (used by ALPHABLT.EXE)

DAC256.BMP

   Bitmap of default video DAC colors in ROM BIOS
   mode 13H (320-by-200 256-color mode)

E.BMP

   Letter "E" glyph (used by ALPHABLT.EXE)

ELTEST.C

   Tests functions in ELLIPSE.ASM

ELTIME.C

   Contains timed tests of ellipse-drawing algorithms

FADE.C

   Tests functions in FADE16.ASM

GBTEST.C

   Tests functions in GLYPHBLT.ASM

GPTEST.C

   Tests functions in GETPIXEL.ASM

HORSE.BMP

   Monochrome bitmap (use with ALPHABLT.EXE)

LATCH.C

   Looks for undocumented VGA CRTC register 22H

LINETEST.C

   Tests functions in LINE.ASM

LINETIME.C

   Timed test of line-drawing algorithms

PATEST.C

   Tests functions in PIXLADDR.ASM

PIG.BMP

   Monochrome bitmap (use with ALPHABLT.EXE)

RABBIT.BMP

   Monochrome bitmap (use with ALPHABLT.EXE)

RECTTEST.C

   Draws solid rectangles

RSEQ.ASM

   Contains functions that select pixels from a two-dimensional
   array in a pseudorandom sequence to create a "dissolve" effect
   (used in SPTEST.EXE)

SCANTEST.C

   Tests functions in SCANPIXL.ASM

SPTEST.C

   Tests functions in SETPIXEL.ASM

TILE.C

   Tests functions in BLT.ASM

VBETEST.C

   Tests M256X.EXE (memory-resident VESA BIOS Extension for
   nonchained 256-color VGA video modes

VBUFTEST.C

   Tests functions in VBUF.ASM

VNITEST.C

   Tests functions in VNI.ASM

VNTTEST.C

   Tests functions in VNITIMER.ASM

VRTEST.C

   Tests functions in VRWAIT.ASM

XORBALL.BMP

   Ball bitmap (used by BOUNCE1.EXE and BOUNCE2.EXE)

===<End of README.TXT>==============================

