#define MAX_FPS 60
-static void fade_buf(SDL_Surface *screen, double amount)
+static void fade_buf(SDL_Surface *screen, int amount)
{
int i;
- unsigned char *buf = screen->pixels;
+ unsigned int *buf = screen->pixels;
+ unsigned char *b;
- for (i = 0; i < screen->pitch * screen->h; i++)
- buf[i] = (buf[i] < amount) ? 0 : buf[i] - amount;
-}
+ for (i = 0; i < screen->pitch * screen->h / sizeof(*buf); i ++) {
+ if (!buf[i])
+ continue;
+ b = (unsigned char *)&buf[i];
+ *b = *b >= amount ? (*b - amount) : *b;
+ b++;
+ *b = *b >= amount ? (*b - amount) : *b;
+ b++;
+ *b = *b >= amount ? (*b - amount) : *b;
+ }}
static void clear_buf(SDL_Surface *screen)
{