rnd-20001025-1-src
[rocksndiamonds.git] / src / sdl.c
index 3f1930136e0e4c8033766490842bb973cb45f9cf..941904e77a761836385211ee1e6781028f389c26 100644 (file)
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -35,16 +35,18 @@ inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface,
   dst_rect.h = height;
 
   SDL_BlitSurface(src_surface, &src_rect, dst_surface, &dst_rect);
-  SDL_UpdateRect(dst_surface, dst_x, dst_y, width, height);
+
+  if (dst_surface == window)
+    SDL_UpdateRect(dst_surface, dst_x, dst_y, width, height);
 }
 
 inline void SDLFillRectangle(SDL_Surface *surface, int x, int y,
                             int width, int height, unsigned int color)
 {
   SDL_Rect rect;
-  unsigned int color_r = (color >> 2) && 0xff;
-  unsigned int color_g = (color >> 1) && 0xff;
-  unsigned int color_b = (color >> 0) && 0xff;
+  unsigned int color_r = (color >> 16) && 0xff;
+  unsigned int color_g = (color >>  8) && 0xff;
+  unsigned int color_b = (color >>  0) && 0xff;
 
   rect.x = x;
   rect.y = y;
@@ -53,15 +55,16 @@ inline void SDLFillRectangle(SDL_Surface *surface, int x, int y,
 
   SDL_FillRect(surface, &rect,
                SDL_MapRGB(surface->format, color_r, color_g, color_b));
+  SDL_UpdateRect(surface, x, y, width, height);
 }
 
 inline void SDLDrawSimpleLine(SDL_Surface *surface, int from_x, int from_y,
                              int to_x, int to_y, unsigned int color)
 {
   SDL_Rect rect;
-  unsigned int color_r = (color >> 2) && 0xff;
-  unsigned int color_g = (color >> 1) && 0xff;
-  unsigned int color_b = (color >> 0) && 0xff;
+  unsigned int color_r = (color >> 16) & 0xff;
+  unsigned int color_g = (color >>  8) & 0xff;
+  unsigned int color_b = (color >>  0) & 0xff;
 
   if (from_x > to_x)
     swap_numbers(&from_x, &to_x);