From: tomster@bigwpi.WPI.EDU (Thomas Richard Dibble)
Newsgroups: comp.graphics
Subject: Re: fading in and out a VGA picture
Date: 6 Nov 92 04:02:33 GMT
	<1992Oct30.234022.23683@organpipe.uug.arizona.edu>
	<1992Nov2.192159.25144@cognos.com>
	<1992Nov2.214701.19930@organpipe.uug.arizona.edu>
	<SFJye-Cd@lopez.marquette.MI.US>
Organization: Worcester Polytechnic Institute, Worcester, MA 01609-2280
NNTP-Posting-Host: bigwpi.wpi.edu
In-reply-to: traal@lopez.marquette.MI.US's message of Thu, 5 Nov 1992 12:05:34 EST

In article <SFJye-Cd@lopez.marquette.MI.US> traal@lopez.marquette.MI.US (Brian Phillips) writes:

   A couple of people in various articles have written, to effect:

     --To fade in/out, you need a timed loop which successively reduces/
       increases the intensity of the RGB values by 1/64th the distance
       between the starting color and zero (or the reciprocal of that if
       you are fading in).

     --There is a problem with the timing/appearance if it is linear in
       nature.  And, "if you have a parameter  0 <= t <= 1 for a scalar,
       try replacing it with t' = t ^ k, where 1 <= k <= 2."  1.5 has
       been suggested as a good value for k.

   Does someone have a simple example of these feats?  Preferrably in ASM or
   C (most likely ASM)?

     --Traal the BRAVE 


Well, sort of.  I can do the first, and I can do it in C.  Simple, really:

char(?) DAC_reg[256][3];
float   DAC_list[256][3];
float   fDAC_reg[256][3];

int counter, reg, part;

/*  Get the video registers and put them in the DAC_reg[][] array.  */
/*  If all else fails, use INT 10, AX = 1009h (from PC Interrupts)  */

for(reg = 0; reg < 256; reg++)
   {
   /*  compute all divide values for DAC_reg to DAC_list  */
   for(part = 0; part < 3; part++)
      {
      /*  '64' in the next line refers to the max # of shades of each color  */
      DAC_list[reg][part] = DAC_reg[reg][part] / 64;
      }
   }

for(counter = 0; counter < 64; counter++)
   {
   for(reg = 0; reg < 256; reg++)
      {
      for(part = 0; part < 3; part++)
         {
         fDAC_reg[reg][part] -= DAC_list[reg][part];
         DAC_reg[reg][part] = (char) fDAC_reg[reg][part];
 	 }
      }
   /*  Now set the registers with the values in DAC_reg[][]  */
   /*  Can be done with INT 10, AX = 1012h  */
   delay(whatever);
   }
}


	I *think* that that should work all right.  The INT's may be a bit
off, though ... actually, I am almost positive they are ... Try the
getpalette()/setpalette() functions in your graphics library first, 'cause
they should be faster.  Of course, I don't think the '.BGI' interface will
allow you to set more than 16 colors, so you may have to use interrupts
anyway.  I dunno.  Just a quick and inefficient hack.

BTW, I hate the use of *three* sets of DAC data.  Really, I do.  I suppose
you should at least allocate it off the heap to conserve stack space.  But
still, you have all that memory going to such a simple process ...

		---- tomster@wpi.wpi.edu




--
/* NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG*\
| "I sometimes used to try to catch her, :	FROM:   tomster@wpi.wpi.edu  |
| but never even caught her name."	 :	TO:	who(m)ever reads it  |
|	---- the cure			 :	CC:	programming language |
\vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/