            TGSDEMO -- small Windows demo by Diana Gruber

The purpose of this demo is to demonstrate bitmap scaling and
scrolling with Fastgraph for Windows. TGSDEMO is based on a program
originally written by Michael Miller, but it has been almost
completely re-written for this version. Thanks for the head start,
Michael!

TGSDEMO is written in C++ using Fastgraph for Windows. It works best
if you have WinG installed, but WinG is not required to run it. The
files in this distribution are:

  TGSDEMO.TXT  this file
  TGSDEMO.CPP  the program's C++ source code
  TGSDEM16.EXE 16-bit Windows executable
  TGSDEM32.EXE 32-bit Windows executable (Win32s or Windows 95)
  SKY.PCX      the background (clouds)
  LOGO1.PCX    "Fastgraph" logo
  LOGO2.PCX    "Ted Gruber Software" logo

The PCX files were preprocessed by using the WinPal utility to reduce
the colors of SKY.PCX from 256 to 236, with the first 10 and last 10
palette entries unused. Then the WinMatch utility was used to map the
colors in LOGO1.PCX and LOGO2.PCX to the color set in SKY.PCX. This
was done so no "on the fly" color reduction needed to be done. The
PCX files were loaded with fg_showpcx(filename,8) -- the '8' means
suppress color reduction and use the colors in the PCX file. WinPal
and WinMatch are included with Fastgraph for Windows.

The program works like this. I loaded the background PCX file into a
virtual buffer that was 1600 pixels wide. The PCX file occupies the
first 640 columns, and a mirror image of the file is created at run
time to occupy the next 640 columns. The last 320 columns duplicate
the first 320 columns, as shown below:

                     virtual buffer 1
 --------------------------------------------------------
 |                     |                     |          |
 |                     |                     | same as  |
 |   SKY.PCX           |  mirror of SKY.PCX  | columns  |
 |                     |                     | 0-319    |
 |                     |                     |          |
 --------------------------------------------------------
 0   ^                  640                  1280         1599
     x

The reason I used a mirror image was so that the clouds would be
seamless. Column 640 matches column 639, column 641 matches column
638, and so on. This gives the visual effect of continuous clouds.
To build the screen, an area measuring 320x200 is copied from the
first virtual buffer to the workspace virtual buffer, which looks
like this:

   virtual buffer 2

   -------------
   |           |
   | workspace |
   |           |
   |   area    |
   |           |
   |           |
   -------------
   0          319

An index variable, called 'x', points to the beginning of the area of
virtual buffer 1 that is copied to virtual buffer 2. This index is
incremented by 8 pixels each frame. When x reaches 1280, we are
displaying the last area of VB 1, which is identical to the first 320
columns of VB 1. The wrap-around is accomplished by simply resetting
x to 0.

If you have any comments or suggestions, please let me know!

Diana Gruber
Ted Gruber Software
P.O. Box 13408
Las Vegas, NV 89112
(702) 735-1980 voice
(702) 735-4603 fax
(702) 796-7134 bbs

ftp: ftp.accessnv.com \fg
72000.1642@compuserve.com
Fastgraph@aol.com
