| 
 
 
  Audio (347) 
  Datatype (51) 
  Demo (204) 
  Development (609) 
  Document (24) 
  Driver (98) 
  Emulation (153) 
  Game (1027) 
  Graphics (510) 
  Library (119) 
  Network (236) 
  Office (67) 
  Utility (939) 
  Video (72) 
 Total files: 4456
 
 Full index file
 Recent index file
 
 
 Amigans.net
 Aminet
 IntuitionBase
 Hyperion Entertainment
 A-Eon
 Amiga Future
 
 
 
 
 
 | 
 [Back to readme page]   [Add Comment]   [Refresh page]
 
 
 | Comment by: Capehill (82.128.191.210) | At: 30 Jun 2005, 17:23 | File version: 0.1 |  | After wondering why it's so slow, I optimized the loop a bit: 
 --
 
 for ( y = 0; y < height; y++ )
 {
 // Calculate modulo outside the inner loop
 const Uint32 y_offset = y * image->pitch;
 
 // Uint32 _cos = (y + iter) % height;
 Uint32 _cos = y + iter;
 while ( _cos >= height )
 _cos -= height;
 
 // Source pixel's base address
 Uint8* src = (Uint8*)image->pixels + y_offset;
 
 for ( x = 0; x < width; x++ )
 {
 //Uint32 _sin = (x + iter) % width;
 Uint32 _sin = x + iter;
 while ( _sin >= width )
 _sin -= width;
 
 // Calculate wave effect. It depends on wave height and sin/cos
 functions
 Sint32 _x = x + ( sin_lut[ _sin ] );
 Sint32 _y = y + ( cos_lut[ _cos ] );
 
 // Check dimensions
 if ( _x < 0 )
 _x = width + _x;
 else if ( _x >= width )
 _x = _x - width;
 
 if ( _y < 0 )
 _y = height + _y;
 else if ( _y >= height )
 _y = _y - height;
 
 // Destinations pixel's base address
 Uint8* dest = (Uint8*)screen->pixels + _x * d_bpp + _y *
 screen->pitch;
 
 // Red
 *(dest + dr) = *( src + sr );
 
 // Green
 *(dest + dg) = *( src + sg );
 
 // Blue
 *(dest + db) = *( src + sb );
 
 src += s_bpp;
 
 } // x
 
 } // y
 --
 
 Also MAX_X & MAX_Y multiplications were move to main() where sin_lut and
 cos_lut are initialized.
 
 Optimizations give > 30% better performance.
 
 |  |  |  |  | 
 
 |