Fix endianness
authornemo
Tue, 22 Mar 2011 23:01:26 -0400
changeset 5041 3dc6ad20cbfe
parent 5040 c6cd873ac13a
child 5042 f26c5eb040af
Fix endianness
hedgewars/GSHandlers.inc
hedgewars/SDLh.pas
hedgewars/uGearsRender.pas
hedgewars/uLandGraphics.pas
--- a/hedgewars/GSHandlers.inc	Tue Mar 22 19:27:14 2011 +0300
+++ b/hedgewars/GSHandlers.inc	Tue Mar 22 23:01:26 2011 -0400
@@ -680,13 +680,13 @@
                         if (cReducedQuality and rqBlurryLand) = 0 then
                             begin
                             if gun then
-                                LandPixels[yy + py, xx + px]:= (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)
+                                LandPixels[yy + py, xx + px]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask)
                             else LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]);
                             end
                         else
                             begin
                             if gun then
-                                LandPixels[(yy + py) div 2, (xx + px) div 2]:= (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)
+                                LandPixels[(yy + py) div 2, (xx + px) div 2]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask)
                             else LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]);
                             end;
                         end
--- a/hedgewars/SDLh.pas	Tue Mar 22 19:27:14 2011 +0300
+++ b/hedgewars/SDLh.pas	Tue Mar 22 23:01:26 2011 -0400
@@ -226,11 +226,19 @@
     GMask = $0000FF00;
     BMask = $00FF0000;
     AMask = $FF000000;
+    RShift = 0;
+    GShift = 8;
+    BShift = 16;
+    AShift = 24;
 {$ELSE}
     RMask = $FF000000;
     GMask = $00FF0000;
     BMask = $0000FF00;
     AMask = $000000FF;
+    RShift = 24;
+    GShift = 16;
+    BShift = 8;
+    AShift = 0;
 {$ENDIF}
 
     {* SDL_mixer *}
--- a/hedgewars/uGearsRender.pas	Tue Mar 22 19:27:14 2011 +0300
+++ b/hedgewars/uGearsRender.pas	Tue Mar 22 23:01:26 2011 -0400
@@ -21,7 +21,7 @@
 unit uGearsRender;
 
 interface
-uses uTypes, uConsts, GLunit, uFloat;
+uses uTypes, uConsts, GLunit, uFloat, SDLh;
 
 procedure RenderGear(Gear: PGear; x, y: LongInt);
 
@@ -1041,7 +1041,10 @@
            gtFlake: if (Gear^.State and gstTmpFlag) <> 0 then
                         //DrawRotatedTextureF(SpritesData[sprSnowBall].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle)
                         begin
-                        Tint(cExplosionBorderColor shl 8 or $000000FF);
+                        Tint((cExplosionBorderColor shr RShift) and $FF, 
+                             (cExplosionBorderColor shr GShift) and $FF, 
+                             (cExplosionBorderColor shr BShift) and $FF, 
+                             (cExplosionBorderColor shr AShift) and $FF);
                         //DrawRotated(sprSnow, x, y, 0, Gear^.DirAngle);
                         // Needs a nicer white texture to tint
                         DrawTexture(x, y, SpritesData[sprVampiric].Texture, 0.1);
--- a/hedgewars/uLandGraphics.pas	Tue Mar 22 19:27:14 2011 +0300
+++ b/hedgewars/uLandGraphics.pas	Tue Mar 22 23:01:26 2011 -0400
@@ -49,15 +49,15 @@
     oRed, oBlue, oGreen, oAlpha, nRed, nBlue, nGreen, nAlpha: Byte;
 begin
     // Get colors
-    oAlpha := (OldColor shr 24) and $FF;
-    oRed   := (OldColor shr 16) and $FF;
-    oGreen := (OldColor shr 8) and $FF;
-    oBlue  := (OldColor) and $FF;
+    oAlpha := (OldColor shr AShift) and $FF;
+    oRed   := (OldColor shr RShift) and $FF;
+    oGreen := (OldColor shr GShift) and $FF;
+    oBlue  := (OldColor shr BShift) and $FF;
 
-    nAlpha := (NewColor shr 24) and $FF;
-    nRed   := (NewColor shr 16) and $FF;
-    nGreen := (NewColor shr 8) and $FF;
-    nBlue  := (NewColor) and $FF;
+    nAlpha := (NewColor shr AShift) and $FF;
+    nRed   := (NewColor shr RShift) and $FF;
+    nGreen := (NewColor shr GShift) and $FF;
+    nBlue  := (NewColor shr BShift) and $FF;
 
     // Mix colors
     nAlpha := min(255, oAlpha + nAlpha);
@@ -65,7 +65,7 @@
     nGreen := ((oGreen * oAlpha) + (nGreen * (255-oAlpha))) div 255;
     nBlue  := ((oBlue * oAlpha) + (nBlue * (255-oAlpha))) div 255;
 
-    addBgColor := (nAlpha shl 24) or (nRed shl 16) or (nGreen shl 8) or (nBlue);
+    addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift);
 end;
 
 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);