HS>If you use a table of precalculated [ * ] values it's even
faste
HS>eg.
HS>char *screen= (char *) 0xA0000;
HS>#if your using watcom - char *screen=(char *) 0x0A000;
HS>int ytable[320];
HS>void pre_calc(void)
HS>{
HS> int loop1;
HS> for (loop1=0; loop1<319; loop1++)
HS> ytable[loop1] := loop1 * 320;
HS>};
HS>void putpixel(int x, int y, unsigned char colour)
HS>{
HS> char *plot;
HS> plot = &screen[ytable[y] + x];
HS> *plot = (unsigned char)colour;
HS>};
It wasn't faster on mine (686-120, Borland C, Win95). In theory it's
faster, but not when you take into account all the dereferencing and
addressing that goes on. An imul doesn't take that long so you can't
really do much to replace it. Your method (on my computer) gives about
the same performance as a simple y*320+x, except it requires more code
and memory. It may be faster on other chips though.
Danial.
PS. Thanks for the info on DCT. I have 1 question though. You said that
it compresses it based on how fast it changes. Does this mean that it
would start with a number, then for each subsequent pixel, add a certain
number to the previous number to get the value for the pixel?
___ X SLMR 2.1a X
___
X SLMR 2.1a X
--- Maximus/2 3.00
---------------
* Origin: Hunter Connection OS/2 BBS 24hrs (049) 57-1801 (3:622/403)
|