				VGA Hardware Tricks
				Part 2.5 of 6

Introduction:

Welcome to VGA Hardware Tricks, a six-part series written by
Trixter/Hornet.  In this special insert into the series (contributed by
Trouls of TnT), we'll take one last look at crossfading; this time, with
128-color pictures.  (Next week we'll resume our original schedule.)

Description:

By now you're probably wondering where the multi-color techniques that I
wrote about last time are.  Well, Trouls of TnT (alias Alex Wenger)
wrote me right after I did my article on crossfading 16 and 256-color
pictures and pointed out somthing that I forgot to describe: Crossfading
128-color pictures.  He even went so far as to write source code and a
small article, so I'm pleased to reprint that information here.

Crossfading 128-color pictures is extremely simple.  Since the total
number of combined colors is 256, we can effectively plot both pictures
to the screen, make one picture's palette all black, and then fade that
palette from black to colors as we fade the other to black.
Simple, eh?  

Overview:

How you decide to *arrange* all those pixels, however, is a different
story.  Alex writes of two possible solutions:

1. Set the video mode to 320x400.
2. Load the first picture, the first line in the first line of the VGA,
   the second line in the 3th line and the 3th line in the 5th line and
   so on.

Like this:

 Picture1:      VGA-Ram:         Picture2:

 xxxxxx ------> xxxxxx      ____ yyyyyy
 xxxxxx ____    yyyyyy <---/ ___ yyyyyy
 xxxxxx ___ \-> xxxxxx      /  _ yyyyyy
 xxxxxx _  \    yyyyyy <---/  /
         \  \-> xxxxxx       /
          \     yyyyyy <----/
           \--> xxxxxx

3. Load the second picture in the lines that are leaved free. (But
   convert the pictures that picture1 use the colors 0-127 and the
   picture2 the colors 128-255.
4. Prepare palette for the picture1 that the colors 128-255 are all
   black, and the palette2 so that the colors 0-127 are al black.
5. Fade palette from palette1 to palette2

If you want to, you can try this pattern:

   VGA-Ram:

   xyxyxyxy
   yxyxyxyx
   xyxyxyxy
   yxyxyxyx

It's simple to program.  It's also possible to reserve a few palette
entries for a logo or something.

Code:

Code that acheives this effect is available on ftp.cdrom.com in the
directory /pub/demos/hornet/demonews/vgahard in the file vgahar25.zip.
To compile the code directly, you'll need Turbo Pascal 7.0 or later.
(The code can be compiled on eariler compilers as well, but some slight
modification might be necessary.)

Notes:

This technique has been used extensively before; most recently, in the
end credits part of Orange's X14 demo.  (They used the
pixel-interleaving to overlay text on a twisting column; it's the same
idea.)

Alex also wrote of one other thing, and while it's not a VGA hardware
effect, it's something that beginners might not have thought of:  Pixel
crossfading.  In this technique, all you have to do is make sure both
pictures have the same palette, no matter how many colors; then,
*gradually* overwrite the onscreen's picture with the other picture's
pixels.

- Change every 7 (or whatever you want) pixels until the whole picture
  is done and you have a nice crossfading effect.
- Change the pixels along lines or change hole blocks of pixels for a
  slideshow effect.

Next time:

With the addition of this special "insert" in this series, I'm pretty
sure we've exhausted crossfading.  :-)  Next week, we'll be
delving into fun stuff: How to make your standard VGA card display more
than 256 colors at once.  Have fun until then!
