test/testalpha.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/test/testalpha.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/test/testalpha.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -14,15 +14,15 @@
     1.4  
     1.5  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.6  static void
     1.7 -quit (int rc)
     1.8 +quit(int rc)
     1.9  {
    1.10 -    SDL_Quit ();
    1.11 -    exit (rc);
    1.12 +    SDL_Quit();
    1.13 +    exit(rc);
    1.14  }
    1.15  
    1.16  /* Fill the screen with a gradient */
    1.17  static void
    1.18 -FillBackground (SDL_Surface * screen)
    1.19 +FillBackground(SDL_Surface * screen)
    1.20  {
    1.21      Uint8 *buffer;
    1.22      Uint16 *buffer16;
    1.23 @@ -31,24 +31,24 @@
    1.24      int i, k;
    1.25  
    1.26      /* Set the surface pixels and refresh! */
    1.27 -    if (SDL_LockSurface (screen) < 0) {
    1.28 -        fprintf (stderr, "Couldn't lock the display surface: %s\n",
    1.29 -                 SDL_GetError ());
    1.30 -        quit (2);
    1.31 +    if (SDL_LockSurface(screen) < 0) {
    1.32 +        fprintf(stderr, "Couldn't lock the display surface: %s\n",
    1.33 +                SDL_GetError());
    1.34 +        quit(2);
    1.35      }
    1.36      buffer = (Uint8 *) screen->pixels;
    1.37      if (screen->format->BytesPerPixel != 2) {
    1.38          for (i = 0; i < screen->h; ++i) {
    1.39 -            memset (buffer, (i * 255) / screen->h,
    1.40 -                    screen->w * screen->format->BytesPerPixel);
    1.41 +            memset(buffer, (i * 255) / screen->h,
    1.42 +                   screen->w * screen->format->BytesPerPixel);
    1.43              buffer += screen->pitch;
    1.44          }
    1.45      } else {
    1.46          for (i = 0; i < screen->h; ++i) {
    1.47              gradient = ((i * 255) / screen->h);
    1.48              color =
    1.49 -                (Uint16) SDL_MapRGB (screen->format, gradient, gradient,
    1.50 -                                     gradient);
    1.51 +                (Uint16) SDL_MapRGB(screen->format, gradient, gradient,
    1.52 +                                    gradient);
    1.53              buffer16 = (Uint16 *) buffer;
    1.54              for (k = 0; k < screen->w; k++) {
    1.55                  *(buffer16 + k) = color;
    1.56 @@ -57,13 +57,13 @@
    1.57          }
    1.58      }
    1.59  
    1.60 -    SDL_UnlockSurface (screen);
    1.61 -    SDL_UpdateRect (screen, 0, 0, 0, 0);
    1.62 +    SDL_UnlockSurface(screen);
    1.63 +    SDL_UpdateRect(screen, 0, 0, 0, 0);
    1.64  }
    1.65  
    1.66  /* Create a "light" -- a yellowish surface with variable alpha */
    1.67  SDL_Surface *
    1.68 -CreateLight (int radius)
    1.69 +CreateLight(int radius)
    1.70  {
    1.71      Uint8 trans, alphamask;
    1.72      int range, addition;
    1.73 @@ -79,19 +79,19 @@
    1.74      /* Create a 16 (4/4/4/4) bpp square with a full 4-bit alpha channel */
    1.75      /* Note: this isn't any faster than a 32 bit alpha surface */
    1.76      alphamask = 0x0000000F;
    1.77 -    light = SDL_CreateRGBSurface (SDL_SWSURFACE, 2 * radius, 2 * radius, 16,
    1.78 -                                  0x0000F000, 0x00000F00, 0x000000F0,
    1.79 -                                  alphamask);
    1.80 +    light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2 * radius, 2 * radius, 16,
    1.81 +                                 0x0000F000, 0x00000F00, 0x000000F0,
    1.82 +                                 alphamask);
    1.83  #else
    1.84      Uint32 *buf;
    1.85  
    1.86      /* Create a 32 (8/8/8/8) bpp square with a full 8-bit alpha channel */
    1.87      alphamask = 0x000000FF;
    1.88 -    light = SDL_CreateRGBSurface (SDL_SWSURFACE, 2 * radius, 2 * radius, 32,
    1.89 -                                  0xFF000000, 0x00FF0000, 0x0000FF00,
    1.90 -                                  alphamask);
    1.91 +    light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2 * radius, 2 * radius, 32,
    1.92 +                                 0xFF000000, 0x00FF0000, 0x0000FF00,
    1.93 +                                 alphamask);
    1.94      if (light == NULL) {
    1.95 -        fprintf (stderr, "Couldn't create light: %s\n", SDL_GetError ());
    1.96 +        fprintf(stderr, "Couldn't create light: %s\n", SDL_GetError());
    1.97          return (NULL);
    1.98      }
    1.99  #endif
   1.100 @@ -104,7 +104,7 @@
   1.101      buf = (Uint32 *) light->pixels;
   1.102  #endif
   1.103      /* Get a tranparent pixel value - we'll add alpha later */
   1.104 -    pixel = SDL_MapRGBA (light->format, 0xFF, 0xDD, 0x88, 0);
   1.105 +    pixel = SDL_MapRGBA(light->format, 0xFF, 0xDD, 0x88, 0);
   1.106      for (y = 0; y < light->h; ++y) {
   1.107          for (x = 0; x < light->w; ++x) {
   1.108              *buf++ = pixel;
   1.109 @@ -123,7 +123,7 @@
   1.110              /* Slow distance formula (from center of light) */
   1.111              xdist = x - (light->w / 2);
   1.112              ydist = y - (light->h / 2);
   1.113 -            range = (int) sqrt (xdist * xdist + ydist * ydist);
   1.114 +            range = (int) sqrt(xdist * xdist + ydist * ydist);
   1.115  
   1.116              /* Scale distance to range of transparency (0-255) */
   1.117              if (range > radius) {
   1.118 @@ -146,7 +146,7 @@
   1.119          buf += skip;            /* Almost always 0, but just in case... */
   1.120      }
   1.121      /* Enable RLE acceleration of this alpha surface */
   1.122 -    SDL_SetAlpha (light, SDL_SRCALPHA | SDL_RLEACCEL, 0);
   1.123 +    SDL_SetAlpha(light, SDL_SRCALPHA | SDL_RLEACCEL, 0);
   1.124  
   1.125      /* We're done! */
   1.126      return (light);
   1.127 @@ -156,7 +156,7 @@
   1.128  static Uint32 flashtime = 0;
   1.129  
   1.130  void
   1.131 -FlashLight (SDL_Surface * screen, SDL_Surface * light, int x, int y)
   1.132 +FlashLight(SDL_Surface * screen, SDL_Surface * light, int x, int y)
   1.133  {
   1.134      SDL_Rect position;
   1.135      Uint32 ticks1;
   1.136 @@ -167,10 +167,10 @@
   1.137      position.y = y - (light->h / 2);
   1.138      position.w = light->w;
   1.139      position.h = light->h;
   1.140 -    ticks1 = SDL_GetTicks ();
   1.141 -    SDL_BlitSurface (light, NULL, screen, &position);
   1.142 -    ticks2 = SDL_GetTicks ();
   1.143 -    SDL_UpdateRects (screen, 1, &position);
   1.144 +    ticks1 = SDL_GetTicks();
   1.145 +    SDL_BlitSurface(light, NULL, screen, &position);
   1.146 +    ticks2 = SDL_GetTicks();
   1.147 +    SDL_UpdateRects(screen, 1, &position);
   1.148      ++flashes;
   1.149  
   1.150      /* Update time spend doing alpha blitting */
   1.151 @@ -185,48 +185,46 @@
   1.152  static int alpha_vel;
   1.153  
   1.154  int
   1.155 -LoadSprite (SDL_Surface * screen, char *file)
   1.156 +LoadSprite(SDL_Surface * screen, char *file)
   1.157  {
   1.158      SDL_Surface *converted;
   1.159  
   1.160      /* Load the sprite image */
   1.161 -    sprite = SDL_LoadBMP (file);
   1.162 +    sprite = SDL_LoadBMP(file);
   1.163      if (sprite == NULL) {
   1.164 -        fprintf (stderr, "Couldn't load %s: %s", file, SDL_GetError ());
   1.165 +        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
   1.166          return (-1);
   1.167      }
   1.168  
   1.169      /* Set transparent pixel as the pixel at (0,0) */
   1.170      if (sprite->format->palette) {
   1.171 -        SDL_SetColorKey (sprite, SDL_SRCCOLORKEY, *(Uint8 *) sprite->pixels);
   1.172 +        SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, *(Uint8 *) sprite->pixels);
   1.173      }
   1.174  
   1.175      /* Convert sprite to video format */
   1.176 -    converted = SDL_DisplayFormat (sprite);
   1.177 -    SDL_FreeSurface (sprite);
   1.178 +    converted = SDL_DisplayFormat(sprite);
   1.179 +    SDL_FreeSurface(sprite);
   1.180      if (converted == NULL) {
   1.181 -        fprintf (stderr, "Couldn't convert background: %s\n",
   1.182 -                 SDL_GetError ());
   1.183 +        fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError());
   1.184          return (-1);
   1.185      }
   1.186      sprite = converted;
   1.187  
   1.188      /* Create the background */
   1.189 -    backing = SDL_CreateRGBSurface (SDL_SWSURFACE, sprite->w, sprite->h, 8,
   1.190 -                                    0, 0, 0, 0);
   1.191 +    backing = SDL_CreateRGBSurface(SDL_SWSURFACE, sprite->w, sprite->h, 8,
   1.192 +                                   0, 0, 0, 0);
   1.193      if (backing == NULL) {
   1.194 -        fprintf (stderr, "Couldn't create background: %s\n", SDL_GetError ());
   1.195 -        SDL_FreeSurface (sprite);
   1.196 +        fprintf(stderr, "Couldn't create background: %s\n", SDL_GetError());
   1.197 +        SDL_FreeSurface(sprite);
   1.198          return (-1);
   1.199      }
   1.200  
   1.201      /* Convert background to video format */
   1.202 -    converted = SDL_DisplayFormat (backing);
   1.203 -    SDL_FreeSurface (backing);
   1.204 +    converted = SDL_DisplayFormat(backing);
   1.205 +    SDL_FreeSurface(backing);
   1.206      if (converted == NULL) {
   1.207 -        fprintf (stderr, "Couldn't convert background: %s\n",
   1.208 -                 SDL_GetError ());
   1.209 -        SDL_FreeSurface (sprite);
   1.210 +        fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError());
   1.211 +        SDL_FreeSurface(sprite);
   1.212          return (-1);
   1.213      }
   1.214      backing = converted;
   1.215 @@ -245,14 +243,14 @@
   1.216  }
   1.217  
   1.218  void
   1.219 -AttractSprite (Uint16 x, Uint16 y)
   1.220 +AttractSprite(Uint16 x, Uint16 y)
   1.221  {
   1.222      x_vel = ((int) x - position.x) / 10;
   1.223      y_vel = ((int) y - position.y) / 10;
   1.224  }
   1.225  
   1.226  void
   1.227 -MoveSprite (SDL_Surface * screen, SDL_Surface * light)
   1.228 +MoveSprite(SDL_Surface * screen, SDL_Surface * light)
   1.229  {
   1.230      SDL_Rect updates[2];
   1.231      int alpha;
   1.232 @@ -260,7 +258,7 @@
   1.233      /* Erase the sprite if it was visible */
   1.234      if (sprite_visible) {
   1.235          updates[0] = position;
   1.236 -        SDL_BlitSurface (backing, NULL, screen, &updates[0]);
   1.237 +        SDL_BlitSurface(backing, NULL, screen, &updates[0]);
   1.238      } else {
   1.239          updates[0].x = 0;
   1.240          updates[0].y = 0;
   1.241 @@ -275,8 +273,8 @@
   1.242      if (light != NULL) {
   1.243          int x, y;
   1.244  
   1.245 -        SDL_GetMouseState (&x, &y);
   1.246 -        FlashLight (screen, light, x, y);
   1.247 +        SDL_GetMouseState(&x, &y);
   1.248 +        FlashLight(screen, light, x, y);
   1.249      }
   1.250  
   1.251      /* Move the sprite, bounce at the wall */
   1.252 @@ -298,39 +296,39 @@
   1.253      } else if ((alpha + alpha_vel) > 255) {
   1.254          alpha_vel = -alpha_vel;
   1.255      }
   1.256 -    SDL_SetAlpha (sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel));
   1.257 +    SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel));
   1.258  
   1.259      /* Save the area behind the sprite */
   1.260      updates[1] = position;
   1.261 -    SDL_BlitSurface (screen, &updates[1], backing, NULL);
   1.262 +    SDL_BlitSurface(screen, &updates[1], backing, NULL);
   1.263  
   1.264      /* Blit the sprite onto the screen */
   1.265      updates[1] = position;
   1.266 -    SDL_BlitSurface (sprite, NULL, screen, &updates[1]);
   1.267 +    SDL_BlitSurface(sprite, NULL, screen, &updates[1]);
   1.268  
   1.269      /* Make it so! */
   1.270 -    SDL_UpdateRects (screen, 2, updates);
   1.271 +    SDL_UpdateRects(screen, 2, updates);
   1.272  }
   1.273  
   1.274  void
   1.275 -WarpSprite (SDL_Surface * screen, int x, int y)
   1.276 +WarpSprite(SDL_Surface * screen, int x, int y)
   1.277  {
   1.278      SDL_Rect updates[2];
   1.279  
   1.280      /* Erase, move, Draw, update */
   1.281      updates[0] = position;
   1.282 -    SDL_BlitSurface (backing, NULL, screen, &updates[0]);
   1.283 +    SDL_BlitSurface(backing, NULL, screen, &updates[0]);
   1.284      position.x = x - sprite->w / 2;     /* Center about X */
   1.285      position.y = y - sprite->h / 2;     /* Center about Y */
   1.286      updates[1] = position;
   1.287 -    SDL_BlitSurface (screen, &updates[1], backing, NULL);
   1.288 +    SDL_BlitSurface(screen, &updates[1], backing, NULL);
   1.289      updates[1] = position;
   1.290 -    SDL_BlitSurface (sprite, NULL, screen, &updates[1]);
   1.291 -    SDL_UpdateRects (screen, 2, updates);
   1.292 +    SDL_BlitSurface(sprite, NULL, screen, &updates[1]);
   1.293 +    SDL_UpdateRects(screen, 2, updates);
   1.294  }
   1.295  
   1.296  int
   1.297 -main (int argc, char *argv[])
   1.298 +main(int argc, char *argv[])
   1.299  {
   1.300      const SDL_VideoInfo *info;
   1.301      SDL_Surface *screen;
   1.302 @@ -345,8 +343,8 @@
   1.303  
   1.304  
   1.305      /* Initialize SDL */
   1.306 -    if (SDL_Init (SDL_INIT_VIDEO) < 0) {
   1.307 -        fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ());
   1.308 +    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   1.309 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   1.310          return (1);
   1.311      }
   1.312  
   1.313 @@ -359,85 +357,85 @@
   1.314      w = 640;
   1.315      h = 480;
   1.316  #endif
   1.317 -    info = SDL_GetVideoInfo ();
   1.318 +    info = SDL_GetVideoInfo();
   1.319      if (info->vfmt->BitsPerPixel > 8) {
   1.320          video_bpp = info->vfmt->BitsPerPixel;
   1.321      } else {
   1.322          video_bpp = 16;
   1.323 -        fprintf (stderr, "forced 16 bpp mode\n");
   1.324 +        fprintf(stderr, "forced 16 bpp mode\n");
   1.325      }
   1.326      videoflags = SDL_SWSURFACE;
   1.327      for (i = 1; argv[i]; ++i) {
   1.328 -        if (strcmp (argv[i], "-bpp") == 0) {
   1.329 -            video_bpp = atoi (argv[++i]);
   1.330 +        if (strcmp(argv[i], "-bpp") == 0) {
   1.331 +            video_bpp = atoi(argv[++i]);
   1.332              if (video_bpp <= 8) {
   1.333                  video_bpp = 16;
   1.334 -                fprintf (stderr, "forced 16 bpp mode\n");
   1.335 +                fprintf(stderr, "forced 16 bpp mode\n");
   1.336              }
   1.337 -        } else if (strcmp (argv[i], "-hw") == 0) {
   1.338 +        } else if (strcmp(argv[i], "-hw") == 0) {
   1.339              videoflags |= SDL_HWSURFACE;
   1.340 -        } else if (strcmp (argv[i], "-warp") == 0) {
   1.341 +        } else if (strcmp(argv[i], "-warp") == 0) {
   1.342              videoflags |= SDL_HWPALETTE;
   1.343 -        } else if (strcmp (argv[i], "-width") == 0 && argv[i + 1]) {
   1.344 -            w = atoi (argv[++i]);
   1.345 -        } else if (strcmp (argv[i], "-height") == 0 && argv[i + 1]) {
   1.346 -            h = atoi (argv[++i]);
   1.347 -        } else if (strcmp (argv[i], "-resize") == 0) {
   1.348 +        } else if (strcmp(argv[i], "-width") == 0 && argv[i + 1]) {
   1.349 +            w = atoi(argv[++i]);
   1.350 +        } else if (strcmp(argv[i], "-height") == 0 && argv[i + 1]) {
   1.351 +            h = atoi(argv[++i]);
   1.352 +        } else if (strcmp(argv[i], "-resize") == 0) {
   1.353              videoflags |= SDL_RESIZABLE;
   1.354 -        } else if (strcmp (argv[i], "-noframe") == 0) {
   1.355 +        } else if (strcmp(argv[i], "-noframe") == 0) {
   1.356              videoflags |= SDL_NOFRAME;
   1.357 -        } else if (strcmp (argv[i], "-fullscreen") == 0) {
   1.358 +        } else if (strcmp(argv[i], "-fullscreen") == 0) {
   1.359              videoflags |= SDL_FULLSCREEN;
   1.360          } else {
   1.361 -            fprintf (stderr,
   1.362 -                     "Usage: %s [-width N] [-height N] [-bpp N] [-warp] [-hw] [-fullscreen]\n",
   1.363 -                     argv[0]);
   1.364 -            quit (1);
   1.365 +            fprintf(stderr,
   1.366 +                    "Usage: %s [-width N] [-height N] [-bpp N] [-warp] [-hw] [-fullscreen]\n",
   1.367 +                    argv[0]);
   1.368 +            quit(1);
   1.369          }
   1.370      }
   1.371  
   1.372      /* Set video mode */
   1.373 -    if ((screen = SDL_SetVideoMode (w, h, video_bpp, videoflags)) == NULL) {
   1.374 -        fprintf (stderr, "Couldn't set %dx%dx%d video mode: %s\n",
   1.375 -                 w, h, video_bpp, SDL_GetError ());
   1.376 -        quit (2);
   1.377 +    if ((screen = SDL_SetVideoMode(w, h, video_bpp, videoflags)) == NULL) {
   1.378 +        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
   1.379 +                w, h, video_bpp, SDL_GetError());
   1.380 +        quit(2);
   1.381      }
   1.382 -    FillBackground (screen);
   1.383 +    FillBackground(screen);
   1.384  
   1.385      /* Create the light */
   1.386 -    light = CreateLight (82);
   1.387 +    light = CreateLight(82);
   1.388      if (light == NULL) {
   1.389 -        quit (1);
   1.390 +        quit(1);
   1.391      }
   1.392  
   1.393      /* Load the sprite */
   1.394 -    if (LoadSprite (screen, "icon.bmp") < 0) {
   1.395 -        SDL_FreeSurface (light);
   1.396 -        quit (1);
   1.397 +    if (LoadSprite(screen, "icon.bmp") < 0) {
   1.398 +        SDL_FreeSurface(light);
   1.399 +        quit(1);
   1.400      }
   1.401  
   1.402      /* Print out information about our surfaces */
   1.403 -    printf ("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel);
   1.404 +    printf("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel);
   1.405      if ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
   1.406 -        printf ("Screen is in video memory\n");
   1.407 +        printf("Screen is in video memory\n");
   1.408      } else {
   1.409 -        printf ("Screen is in system memory\n");
   1.410 +        printf("Screen is in system memory\n");
   1.411      }
   1.412      if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
   1.413 -        printf ("Screen has double-buffering enabled\n");
   1.414 +        printf("Screen has double-buffering enabled\n");
   1.415      }
   1.416      if ((sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
   1.417 -        printf ("Sprite is in video memory\n");
   1.418 +        printf("Sprite is in video memory\n");
   1.419      } else {
   1.420 -        printf ("Sprite is in system memory\n");
   1.421 +        printf("Sprite is in system memory\n");
   1.422      }
   1.423  
   1.424      /* Run a sample blit to trigger blit acceleration */
   1.425 -    MoveSprite (screen, NULL);
   1.426 +    MoveSprite(screen, NULL);
   1.427      if ((sprite->flags & SDL_HWACCEL) == SDL_HWACCEL) {
   1.428 -        printf ("Sprite blit uses hardware alpha acceleration\n");
   1.429 +        printf("Sprite blit uses hardware alpha acceleration\n");
   1.430      } else {
   1.431 -        printf ("Sprite blit dosn't uses hardware alpha acceleration\n");
   1.432 +        printf("Sprite blit dosn't uses hardware alpha acceleration\n");
   1.433      }
   1.434  
   1.435      /* Set a clipping rectangle to clip the outside edge of the screen */
   1.436 @@ -447,57 +445,57 @@
   1.437          clip.y = 32;
   1.438          clip.w = screen->w - (2 * 32);
   1.439          clip.h = screen->h - (2 * 32);
   1.440 -        SDL_SetClipRect (screen, &clip);
   1.441 +        SDL_SetClipRect(screen, &clip);
   1.442      }
   1.443  
   1.444      /* Wait for a keystroke */
   1.445 -    lastticks = SDL_GetTicks ();
   1.446 +    lastticks = SDL_GetTicks();
   1.447      done = 0;
   1.448      mouse_pressed = 0;
   1.449      while (!done) {
   1.450          /* Update the frame -- move the sprite */
   1.451          if (mouse_pressed) {
   1.452 -            MoveSprite (screen, light);
   1.453 +            MoveSprite(screen, light);
   1.454              mouse_pressed = 0;
   1.455          } else {
   1.456 -            MoveSprite (screen, NULL);
   1.457 +            MoveSprite(screen, NULL);
   1.458          }
   1.459  
   1.460          /* Slow down the loop to 30 frames/second */
   1.461 -        ticks = SDL_GetTicks ();
   1.462 +        ticks = SDL_GetTicks();
   1.463          if ((ticks - lastticks) < FRAME_TICKS) {
   1.464  #ifdef CHECK_SLEEP_GRANULARITY
   1.465 -            fprintf (stderr, "Sleeping %d ticks\n",
   1.466 -                     FRAME_TICKS - (ticks - lastticks));
   1.467 +            fprintf(stderr, "Sleeping %d ticks\n",
   1.468 +                    FRAME_TICKS - (ticks - lastticks));
   1.469  #endif
   1.470 -            SDL_Delay (FRAME_TICKS - (ticks - lastticks));
   1.471 +            SDL_Delay(FRAME_TICKS - (ticks - lastticks));
   1.472  #ifdef CHECK_SLEEP_GRANULARITY
   1.473 -            fprintf (stderr, "Slept %d ticks\n", (SDL_GetTicks () - ticks));
   1.474 +            fprintf(stderr, "Slept %d ticks\n", (SDL_GetTicks() - ticks));
   1.475  #endif
   1.476          }
   1.477          lastticks = ticks;
   1.478  
   1.479          /* Check for events */
   1.480 -        while (SDL_PollEvent (&event)) {
   1.481 +        while (SDL_PollEvent(&event)) {
   1.482              switch (event.type) {
   1.483              case SDL_VIDEORESIZE:
   1.484                  screen =
   1.485 -                    SDL_SetVideoMode (event.resize.w, event.resize.h,
   1.486 -                                      video_bpp, videoflags);
   1.487 +                    SDL_SetVideoMode(event.resize.w, event.resize.h,
   1.488 +                                     video_bpp, videoflags);
   1.489                  if (screen) {
   1.490 -                    FillBackground (screen);
   1.491 +                    FillBackground(screen);
   1.492                  }
   1.493                  break;
   1.494                  /* Attract sprite while mouse is held down */
   1.495              case SDL_MOUSEMOTION:
   1.496                  if (event.motion.state != 0) {
   1.497 -                    AttractSprite (event.motion.x, event.motion.y);
   1.498 +                    AttractSprite(event.motion.x, event.motion.y);
   1.499                      mouse_pressed = 1;
   1.500                  }
   1.501                  break;
   1.502              case SDL_MOUSEBUTTONDOWN:
   1.503                  if (event.button.button == 1) {
   1.504 -                    AttractSprite (event.button.x, event.button.y);
   1.505 +                    AttractSprite(event.button.x, event.button.y);
   1.506                      mouse_pressed = 1;
   1.507                  } else {
   1.508                      SDL_Rect area;
   1.509 @@ -506,8 +504,8 @@
   1.510                      area.y = event.button.y - 16;
   1.511                      area.w = 32;
   1.512                      area.h = 32;
   1.513 -                    SDL_FillRect (screen, &area, 0);
   1.514 -                    SDL_UpdateRects (screen, 1, &area);
   1.515 +                    SDL_FillRect(screen, &area, 0);
   1.516 +                    SDL_UpdateRects(screen, 1, &area);
   1.517                  }
   1.518                  break;
   1.519              case SDL_KEYDOWN:
   1.520 @@ -523,16 +521,16 @@
   1.521              }
   1.522          }
   1.523      }
   1.524 -    SDL_FreeSurface (light);
   1.525 -    SDL_FreeSurface (sprite);
   1.526 -    SDL_FreeSurface (backing);
   1.527 +    SDL_FreeSurface(light);
   1.528 +    SDL_FreeSurface(sprite);
   1.529 +    SDL_FreeSurface(backing);
   1.530  
   1.531      /* Print out some timing information */
   1.532      if (flashes > 0) {
   1.533 -        printf ("%d alpha blits, ~%4.4f ms per blit\n",
   1.534 -                flashes, (float) flashtime / flashes);
   1.535 +        printf("%d alpha blits, ~%4.4f ms per blit\n",
   1.536 +               flashes, (float) flashtime / flashes);
   1.537      }
   1.538  
   1.539 -    SDL_Quit ();
   1.540 +    SDL_Quit();
   1.541      return (0);
   1.542  }