#------------------------------------------------------------------------------#
#                             - Challenge #4 -                                 #
#                                 by JaZZ                                      #
#------------------------------------------------------------------------------#

All being well considered, the ultimate one may have been the tougher...
Reproducing as close as possible the damned graphical effect is indeed a real
challenge. I chose to code the program in C for conveniency. But before coding,
a deep analysis of the process is needed. Setting a break on Ellipse or Bitblt
after a puzzle has been achieved will get you in the heart of the routine, which
starts at 42EAFB. The effect consists of 16 successives images, each of which is
displayed by a Bitblt function at adress 429D5A. This adress is therefore a
priveleged location to study the sparkling. A random location is chosen on the
puzzle. Then there are two phases:
- ascending (images 1 to 8) where the geometric pattern grows.
- descending (im. 9 to 16) where it disappears (the 16th image beeing the
original image of the screen), using the same images in reverse order. In
addition there's a random amount of small sparks near the main figure. They last
6 images max, and can only be a pixel or a small cross. (only 2 colors for them)

The main figure is made up of
- a cross
- one to three ellipses (depending on the progress of the process), each one
having its own colour.
There are 7 sets of colors. The program chooses one at the beginning (To
retrieve them, just break on CreateSolidBrush).

The author's method.
--------------------
He uses several bitmaps (20x20).
A first one is used to save the original screen:B0
He creates two bitmaps for the figures (B1,B2), and a working one, Bw, where he
elaborates the final image that will be transfered to the screen at 429D5A. Then
the process for building one image is the following, rather complicated (i chose
a more simple way to achieve a similar result, you'll judge).
1) B0->Bw : working bmp is loaded with the "untouched" image (raster-op:SRCCPY)
2) fill B1 with white and draw the pattern in black on it.
3) fill B2 with black and draw the pattern with appropriate colors in it
4) B1->Bw (raster-op:SRCAND) the effect is to "black" the pattern in the       			
original bitmap.
5) B2->Bw (raster-op:SRCINVERT) the effect is to insert the colored pattern in
its "blacked" location in Bw.
6) Bw->Screen.

And so on along the 16 steps.

My method.
----------
I use only 2 bitmaps. With the first i save the original screen. In the second,
the working one, i draw directly.
1) copy original image in it (SRCCPY)
2) draw pattern according to the drawing process.(SRCCPY)

Drawing the correct figure...
To do this, i traced every call to Ellipse and wrote down the coordinates. then
i've hardcoded them in an array in C. Quite a laborious task indeed. For the
LineTo and MoveToEx, I've used a more clever method: I just use the min and max
of the coordinates and compute the relevant increments according to the number
of steps.
The possible sets of color are hardcoded too, one is chosen randomly at the
beginning of the process.

For the little sparks, the task is a little more comlicated, for they have a
more random behavior:
-random position "near" the ellipse.
-random date of appearance.
-random amount of these objects.
To formalize this, i defined a structure for this object:
-location
-step of appearance
-age of the object, to control its appearance: pixel or cross.

At first, i decide how many sparks there will be. For every of them,i initialize
the above structure with appropriate data. Especially, to find a good location i
use a special random generator which exclude certain intervals, as the sparks
must be "close" to the ellipse, ie. the center area and the edges shouldn't be
used.

Modifying sparkle.ini
---------------------

Feel free to modify this initialisation file, which defines the behavior of the
program. Here are the entries:

fullscreen=1/0 ;  The output will/will not take the entire screen.
blackscreen=1/0;  The background color will be black/unchanged.
howmuch=20     ;  The graphical effect will occur 20 times.
waste=23       ;  A temporisation in milliseconds.
width=300      ;  If fullscreen=0, these two parameters define the width &
height=200     ;  height of the rectangle (randomly located) where all
               ;  the figures will be drawn.

the "waste" param is quite sensible. It can affect dramatically the realism of 
the effect. This value gave a good result on my pc, for another machine i dont 
know...               
#------------------------------------------------------------------------------#              