Doing fades and such in 16-bit using look-ups

Started by
2 comments, last by Nazrix 23 years, 2 months ago
I'm trying to use this article on GDNet to do a fade using look-up tables. Although I understand the premise, I am not really sure about the implementation. Here's where I initialize the lookup table. The idea is that the first element is the colors and the second is 20 the increments of the fade.
    

USHORT clut[65537][21];

int clutx, cluty;

for (clutx=0; clutx<65536; clutx++)   
{
  for (cluty=0; cluty<20; cluty++)        
  {
	  clut[clutx][cluty] =(int) (clutx * (float)(cluty/20));    
  }
}
  



Here's the function that does the lookup and does the fade.

      
void ApplyFade(int pct, USHORT* fadebuffer, int pitch)
{
  int x, y;
  USHORT* temp = fadebuffer;
  int jump = pitch - 200;
  int index;

  for (y=0; y<200; y++)
  {
    for (x=0; x<200; x++, temp++) // move pointer to next pixel each time

    {
	  index=pct/5;
     *temp = clut[*temp][index];
    }

    // move pointer to beginning of next line

    temp+=jump;
  }
}
    
All that happens is it crashes back to windows when I perform the fade. Is this code anywhere near correct? Need help? Well, go FAQ yourself.
What a plight we who try to make a story-based game have...writers of conventional media have words, we have but binary numbers Edited by - Nazrix on February 17, 2001 6:41:06 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Advertisement
I didn''t look at the site, but is pitch measuring in bytes or words? That might be your problem.
Gee Brain, what we gonna do tonight?
I''m at work at the moment, getting paid to sit on my ass and do nothing, but when I get home I''ll send you some code. It''s not exactly the fastest thing in the world but it works... maybe we can figure out how to speed it up a bit.

-Ironblayde
 Aeon Software

Down with Tiberia!!
"Your superior intellect is no match for our puny weapons!"
Iron,

Great

I''ll look forward to that. A long time ago, you explained this a bit. As helpful as it was, I am still a bit shaky about it.


Need help? Well, go FAQ yourself.
What a plight we who try to make a story-based game have...writers of conventional media have words, we have but binary numbers
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi

This topic is closed to new replies.

Advertisement