fixed drawing envelope request to be always on top of tile cursor
[rocksndiamonds.git] / src / libgame / sdl.c
index baa53340c4502380357bc45e8540f1efe11eb782..59fe7c3df988d35d5a7269041c2c83e2c0745e30 100644 (file)
@@ -65,10 +65,21 @@ static void FinalizeScreen(int draw_target)
   // copy tile selection cursor to render target buffer, if defined (above all)
   if (gfx.draw_tile_cursor_function != NULL)
     gfx.draw_tile_cursor_function(draw_target);
+
+  // copy envelope request to render target buffer, if needed (above all)
+  if (gfx.draw_envelope_request_function != NULL)
+    gfx.draw_envelope_request_function(draw_target);
+
+  // copy global animations to render target buffer, if defined (mouse pointer)
+  if (gfx.draw_global_anim_function != NULL)
+    gfx.draw_global_anim_function(draw_target, DRAW_GLOBAL_ANIM_STAGE_3);
 }
 
 static void UpdateScreenExt(SDL_Rect *rect, boolean with_frame_delay)
 {
+  if (program.headless)
+    return;
+
   static DelayCounter update_screen_delay = { 50 };    // (milliseconds)
   SDL_Surface *screen = backbuffer->surface;
 
@@ -1451,14 +1462,14 @@ static void _PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
       case 1:
       {
        // Assuming 8-bpp
-       *((Uint8 *)surface->pixels + y*surface->pitch + x) = color;
+       *((Uint8 *)surface->pixels + y * surface->pitch + x) = color;
       }
       break;
 
       case 2:
       {
        // Probably 15-bpp or 16-bpp
-       *((Uint16 *)surface->pixels + y*surface->pitch/2 + x) = color;
+       *((Uint16 *)surface->pixels + y * surface->pitch / 2 + x) = color;
       }
       break;
 
@@ -1469,20 +1480,20 @@ static void _PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
        int shift;
 
        // Gack - slow, but endian correct
-       pix = (Uint8 *)surface->pixels + y * surface->pitch + x*3;
+       pix = (Uint8 *)surface->pixels + y * surface->pitch + x * 3;
        shift = surface->format->Rshift;
-       *(pix+shift/8) = color>>shift;
+       *(pix + shift / 8) = color>>shift;
        shift = surface->format->Gshift;
-       *(pix+shift/8) = color>>shift;
+       *(pix + shift / 8) = color>>shift;
        shift = surface->format->Bshift;
-       *(pix+shift/8) = color>>shift;
+       *(pix + shift / 8) = color>>shift;
       }
       break;
 
       case 4:
       {
        // Probably 32-bpp
-       *((Uint32 *)surface->pixels + y*surface->pitch/4 + x) = color;
+       *((Uint32 *)surface->pixels + y * surface->pitch / 4 + x) = color;
       }
       break;
     }
@@ -1498,12 +1509,12 @@ static void _PutPixelRGB(SDL_Surface *surface, Sint16 x, Sint16 y,
 
 static void _PutPixel8(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
 {
-  *((Uint8 *)surface->pixels + y*surface->pitch + x) = color;
+  *((Uint8 *)surface->pixels + y * surface->pitch + x) = color;
 }
 
 static void _PutPixel16(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
 {
-  *((Uint16 *)surface->pixels + y*surface->pitch/2 + x) = color;
+  *((Uint16 *)surface->pixels + y * surface->pitch / 2 + x) = color;
 }
 
 static void _PutPixel24(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
@@ -1512,38 +1523,38 @@ static void _PutPixel24(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
   int shift;
 
   // Gack - slow, but endian correct
-  pix = (Uint8 *)surface->pixels + y * surface->pitch + x*3;
+  pix = (Uint8 *)surface->pixels + y * surface->pitch + x * 3;
   shift = surface->format->Rshift;
-  *(pix+shift/8) = color>>shift;
+  *(pix + shift / 8) = color>>shift;
   shift = surface->format->Gshift;
-  *(pix+shift/8) = color>>shift;
+  *(pix + shift / 8) = color>>shift;
   shift = surface->format->Bshift;
-  *(pix+shift/8) = color>>shift;
+  *(pix + shift / 8) = color>>shift;
 }
 
 static void _PutPixel32(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
 {
-  *((Uint32 *)surface->pixels + y*surface->pitch/4 + x) = color;
+  *((Uint32 *)surface->pixels + y * surface->pitch / 4 + x) = color;
 }
 
-static void _PutPixelX(SDL_Surface *dest,Sint16 x,Sint16 y,Uint32 color)
+static void _PutPixelX(SDL_Surface *dest, Sint16 x, Sint16 y, Uint32 color)
 {
   switch (dest->format->BytesPerPixel)
   {
     case 1:
-      *((Uint8 *)dest->pixels + y*dest->pitch + x) = color;
+      *((Uint8 *)dest->pixels + y * dest->pitch + x) = color;
       break;
 
     case 2:
-      *((Uint16 *)dest->pixels + y*dest->pitch/2 + x) = color;
+      *((Uint16 *)dest->pixels + y * dest->pitch / 2 + x) = color;
       break;
 
     case 3:
-      _PutPixel24(dest,x,y,color);
+      _PutPixel24(dest, x, y, color);
       break;
 
     case 4:
-      *((Uint32 *)dest->pixels + y*dest->pitch/4 + x) = color;
+      *((Uint32 *)dest->pixels + y * dest->pitch / 4 + x) = color;
       break;
   }
 }
@@ -1581,19 +1592,19 @@ static Sint32 sge_CalcYPitch(SDL_Surface *dest, Sint16 y)
     switch (dest->format->BytesPerPixel)
     {
       case 1:
-       return y*dest->pitch;
+       return y * dest->pitch;
        break;
 
       case 2:
-       return y*dest->pitch/2;
+       return y * dest->pitch / 2;
        break;
 
       case 3:
-       return y*dest->pitch;
+       return y * dest->pitch;
        break;
 
       case 4:
-       return y*dest->pitch/4;
+       return y * dest->pitch / 4;
        break;
     }
   }
@@ -1629,13 +1640,13 @@ static void sge_pPutPixel(SDL_Surface *surface, Sint16 x, Sint32 ypitch,
        int shift;
 
        // Gack - slow, but endian correct
-       pix = (Uint8 *)surface->pixels + ypitch + x*3;
+       pix = (Uint8 *)surface->pixels + ypitch + x * 3;
        shift = surface->format->Rshift;
-       *(pix+shift/8) = color>>shift;
+       *(pix + shift / 8) = color>>shift;
        shift = surface->format->Gshift;
-       *(pix+shift/8) = color>>shift;
+       *(pix + shift / 8) = color>>shift;
        shift = surface->format->Bshift;
-       *(pix+shift/8) = color>>shift;
+       *(pix + shift / 8) = color>>shift;
       }
       break;