]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/Application/BltLibSample/BltLibSample.c
OptionRomPkg: Fix Visual Studio compiler warnings
[mirror_edk2.git] / OptionRomPkg / Application / BltLibSample / BltLibSample.c
index 24718131a48c2f3a87313a8138ed47ccc2abcc04..fd2b2ce345b3b4e9610baaa807350f568a9b2bc5 100644 (file)
@@ -43,7 +43,8 @@ Rand32 (
     if (Bits > 0) {\r
       Bits = Bits - 1;\r
     }\r
-    R32 = (R32 << Bits) | RShiftU64 (LShiftU64 (TscBits, 64 - Bits), 64 - Bits);\r
+    R32 = (UINT32)((R32 << Bits) |\r
+                   RShiftU64 (LShiftU64 (TscBits, 64 - Bits), 64 - Bits));\r
     Found = Found + Bits;\r
   } while (Found < 32);\r
 \r
@@ -101,9 +102,9 @@ TestColor1 (
 \r
   for (Y = 0; Y < Height; Y++) {\r
     for (X = 0; X < Width; X++) {\r
-      Color.Red = ((X * 0x100) / Width);\r
-      Color.Green = ((Y * 0x100) / Height);\r
-      Color.Blue = ((Y * 0x100) / Height);\r
+      Color.Red =   (UINT8) ((X * 0x100) / Width);\r
+      Color.Green = (UINT8) ((Y * 0x100) / Height);\r
+      Color.Blue =  (UINT8) ((Y * 0x100) / Height);\r
       BltLibVideoFill (&Color, X, Y, 1, 1);\r
     }\r
   }\r
@@ -115,7 +116,7 @@ Uint32SqRt (
   IN  UINT32  Uint32\r
   )\r
 {\r
-  UINT Mask;\r
+  UINT32 Mask;\r
   UINT32 SqRt;\r
   UINT32 SqRtMask;\r
   UINT32 Squared;\r
@@ -124,7 +125,7 @@ Uint32SqRt (
     return 0;\r
   }\r
 \r
-  for (SqRt = 0, Mask = 1 << (HighBitSet32 (Uint32) / 2);\r
+  for (SqRt = 0, Mask = (UINT32) (1 << (HighBitSet32 (Uint32) / 2));\r
        Mask != 0;\r
        Mask = Mask >> 1\r
       ) {\r
@@ -146,20 +147,20 @@ Uint32SqRt (
 \r
 UINT32\r
 Uint32Dist (\r
-  IN UINT32 X,\r
-  IN UINT32 Y\r
+  IN UINTN X,\r
+  IN UINTN Y\r
   )\r
 {\r
-  return Uint32SqRt ((X * X) + (Y * Y));\r
+  return Uint32SqRt ((UINT32) ((X * X) + (Y * Y)));\r
 }\r
 \r
-UINT32\r
+UINT8\r
 GetTriColor (\r
-  IN UINT32 ColorDist,\r
-  IN UINT32 TriWidth\r
+  IN UINTN ColorDist,\r
+  IN UINTN TriWidth\r
   )\r
 {\r
-  return (((TriWidth - ColorDist) * 0x100) / TriWidth);\r
+  return (UINT8) (((TriWidth - ColorDist) * 0x100) / TriWidth);\r
   //return (((TriWidth * TriWidth - ColorDist * ColorDist) * 0x100) / (TriWidth * TriWidth));\r
 }\r
 \r
@@ -174,14 +175,20 @@ TestColor (
   UINTN                          Y1, Y2;\r
   UINTN                          LineWidth, TriWidth, ScreenWidth;\r
   UINTN                          TriHeight, ScreenHeight;\r
-  UINT                         ColorDist;\r
+  UINT32                         ColorDist;\r
 \r
   BltLibGetSizes (&ScreenWidth, &ScreenHeight);\r
   *(UINT32*) (&Color) = 0;\r
   BltLibVideoFill (&Color, 0, 0, ScreenWidth, ScreenHeight);\r
 \r
-  TriWidth = DivU64x32 (MultU64x32 (11547005, ScreenHeight), 10000000);\r
-  TriHeight = DivU64x32 (MultU64x32 (8660254, ScreenWidth), 10000000);\r
+  TriWidth = (UINTN) DivU64x32 (\r
+                       MultU64x32 (11547005, (UINT32) ScreenHeight),\r
+                       10000000\r
+                       );\r
+  TriHeight = (UINTN) DivU64x32 (\r
+                        MultU64x32 (8660254, (UINT32) ScreenWidth),\r
+                        10000000\r
+                        );\r
   if (TriWidth > ScreenWidth) {\r
     DEBUG ((EFI_D_INFO, "TriWidth at %d was too big\n", TriWidth));\r
     TriWidth = ScreenWidth;\r
@@ -200,10 +207,10 @@ TestColor (
 \r
   for (Y = Y2; Y <= Y1; Y++) {\r
     LineWidth =\r
-      DivU64x32 (\r
-        MultU64x32 (11547005, (Y - Y2)),\r
-        20000000\r
-        );\r
+      (UINTN) DivU64x32 (\r
+                MultU64x32 (11547005, (UINT32) (Y - Y2)),\r
+                20000000\r
+                );\r
     for (X = X2 - LineWidth; X < (X2 + LineWidth); X++) {\r
       ColorDist = Uint32Dist(X - X1, Y1 - Y);\r
       Color.Red = GetTriColor (ColorDist, TriWidth);\r