home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / graphics / 11552 < prev    next >
Encoding:
Internet Message Format  |  1992-11-07  |  3.6 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!hri.com!noc.near.net!bigboote.WPI.EDU!nntp!tomster
  2. From: tomster@bigwpi.WPI.EDU (Thomas Richard Dibble)
  3. Newsgroups: comp.graphics
  4. Subject: Re: fading in and out a VGA picture
  5. Message-ID: <TOMSTER.92Nov5230233@bigwpi.WPI.EDU>
  6. Date: 6 Nov 92 04:02:33 GMT
  7. References: <1992Oct30.141221.1@ualr.edu>
  8.     <1992Oct30.234022.23683@organpipe.uug.arizona.edu>
  9.     <1992Nov2.192159.25144@cognos.com>
  10.     <1992Nov2.214701.19930@organpipe.uug.arizona.edu>
  11.     <SFJye-Cd@lopez.marquette.MI.US>
  12. Organization: Worcester Polytechnic Institute, Worcester, MA 01609-2280
  13. Lines: 80
  14. NNTP-Posting-Host: bigwpi.wpi.edu
  15. In-reply-to: traal@lopez.marquette.MI.US's message of Thu, 5 Nov 1992 12:05:34 EST
  16.  
  17. In article <SFJye-Cd@lopez.marquette.MI.US> traal@lopez.marquette.MI.US (Brian Phillips) writes:
  18.  
  19.    A couple of people in various articles have written, to effect:
  20.  
  21.      --To fade in/out, you need a timed loop which successively reduces/
  22.        increases the intensity of the RGB values by 1/64th the distance
  23.        between the starting color and zero (or the reciprocal of that if
  24.        you are fading in).
  25.  
  26.      --There is a problem with the timing/appearance if it is linear in
  27.        nature.  And, "if you have a parameter  0 <= t <= 1 for a scalar,
  28.        try replacing it with t' = t ^ k, where 1 <= k <= 2."  1.5 has
  29.        been suggested as a good value for k.
  30.  
  31.    Does someone have a simple example of these feats?  Preferrably in ASM or
  32.    C (most likely ASM)?
  33.  
  34.      --Traal the BRAVE 
  35.  
  36.  
  37. Well, sort of.  I can do the first, and I can do it in C.  Simple, really:
  38.  
  39. char(?) DAC_reg[256][3];
  40. float   DAC_list[256][3];
  41. float   fDAC_reg[256][3];
  42.  
  43. int counter, reg, part;
  44.  
  45. /*  Get the video registers and put them in the DAC_reg[][] array.  */
  46. /*  If all else fails, use INT 10, AX = 1009h (from PC Interrupts)  */
  47.  
  48. for(reg = 0; reg < 256; reg++)
  49.    {
  50.    /*  compute all divide values for DAC_reg to DAC_list  */
  51.    for(part = 0; part < 3; part++)
  52.       {
  53.       /*  '64' in the next line refers to the max # of shades of each color  */
  54.       DAC_list[reg][part] = DAC_reg[reg][part] / 64;
  55.       }
  56.    }
  57.  
  58. for(counter = 0; counter < 64; counter++)
  59.    {
  60.    for(reg = 0; reg < 256; reg++)
  61.       {
  62.       for(part = 0; part < 3; part++)
  63.          {
  64.          fDAC_reg[reg][part] -= DAC_list[reg][part];
  65.          DAC_reg[reg][part] = (char) fDAC_reg[reg][part];
  66.       }
  67.       }
  68.    /*  Now set the registers with the values in DAC_reg[][]  */
  69.    /*  Can be done with INT 10, AX = 1012h  */
  70.    delay(whatever);
  71.    }
  72. }
  73.  
  74.  
  75.     I *think* that that should work all right.  The INT's may be a bit
  76. off, though ... actually, I am almost positive they are ... Try the
  77. getpalette()/setpalette() functions in your graphics library first, 'cause
  78. they should be faster.  Of course, I don't think the '.BGI' interface will
  79. allow you to set more than 16 colors, so you may have to use interrupts
  80. anyway.  I dunno.  Just a quick and inefficient hack.
  81.  
  82. BTW, I hate the use of *three* sets of DAC data.  Really, I do.  I suppose
  83. you should at least allocate it off the heap to conserve stack space.  But
  84. still, you have all that memory going to such a simple process ...
  85.  
  86.         ---- tomster@wpi.wpi.edu
  87.  
  88.  
  89.  
  90.  
  91. --
  92. /* NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG ** NEW SIG*\
  93. | "I sometimes used to try to catch her, :    FROM:   tomster@wpi.wpi.edu  |
  94. | but never even caught her name."     :    TO:    who(m)ever reads it  |
  95. |    ---- the cure             :    CC:    programming language |
  96. \vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/
  97.