[FREELDR] Move files where they are only used.
[reactos.git] / boot / freeldr / freeldr / ui / video.c
similarity index 56%
rename from boot/freeldr/freeldr/video/fade.c
rename to boot/freeldr/freeldr/ui/video.c
index 439718a..d44f8ee 100644 (file)
@@ -1,35 +1,72 @@
 /*
- *  FreeLoader
- *  Copyright (C) 1998-2003  Brian Palmer  <brianp@sginet.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * PROJECT:     FreeLoader
+ * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE:     UI Video helpers for special effects.
+ * COPYRIGHT:   Copyright 1998-2003 Brian Palmer <brianp@sginet.com>
  */
+
 #ifndef _M_ARM
 #include <freeldr.h>
 
-#define RGB_MAX                      64
-#define RGB_MAX_PER_ITERATION        64
-#define TAG_PALETTE_COLORS           'claP'
+#define RGB_MAX                 64
+#define RGB_MAX_PER_ITERATION   64
+#define TAG_PALETTE_COLORS      'claP'
+
+static PVOID VideoOffScreenBuffer = NULL;
+
+PVOID VideoAllocateOffScreenBuffer(VOID)
+{
+    ULONG BufferSize;
+
+    if (VideoOffScreenBuffer != NULL)
+    {
+        MmFreeMemory(VideoOffScreenBuffer);
+        VideoOffScreenBuffer = NULL;
+    }
+
+    BufferSize = MachVideoGetBufferSize();
+
+    VideoOffScreenBuffer = MmAllocateMemoryWithType(BufferSize, LoaderFirmwareTemporary);
+
+    return VideoOffScreenBuffer;
+}
+
+VOID VideoCopyOffScreenBufferToVRAM(VOID)
+{
+    MachVideoCopyOffScreenBufferToVRAM(VideoOffScreenBuffer);
+}
+
+
+VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
+{
+    ULONG Color;
+
+    for (Color = 0; Color < ColorCount; Color++)
+    {
+        MachVideoGetPaletteColor((UCHAR)Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
+    }
+}
+
+VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
+{
+    ULONG Color;
+
+    MachVideoSync();
+
+    for (Color = 0; Color < ColorCount; Color++)
+    {
+        MachVideoSetPaletteColor((UCHAR)Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
+    }
+}
+
 
 VOID VideoSetAllColorsToBlack(ULONG ColorCount)
 {
-    UCHAR        Color;
+    UCHAR Color;
 
     MachVideoSync();
 
-    for (Color=0; Color<ColorCount; Color++)
+    for (Color = 0; Color < ColorCount; Color++)
     {
         MachVideoSetPaletteColor(Color, 0, 0, 0);
     }
@@ -37,17 +74,16 @@ VOID VideoSetAllColorsToBlack(ULONG ColorCount)
 
 VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
 {
-    ULONG                Index;
-    UCHAR                Color;
-    PPALETTE_ENTRY    PaletteColors;
+    ULONG Index;
+    UCHAR Color;
+    PPALETTE_ENTRY PaletteColors;
 
     PaletteColors = FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * ColorCount, TAG_PALETTE_COLORS);
     if (!PaletteColors) return;
 
-    for (Index=0; Index<RGB_MAX; Index++)
+    for (Index = 0; Index < RGB_MAX; Index++)
     {
-
-        for (Color=0; Color<ColorCount; Color++)
+        for (Color = 0; Color < ColorCount; Color++)
         {
             MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
 
@@ -81,7 +117,7 @@ VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
         }
 
         // Set the colors
-        for (Color=0; Color<ColorCount; Color++)
+        for (Color = 0; Color < ColorCount; Color++)
         {
             if ((Color % RGB_MAX_PER_ITERATION) == 0)
             {
@@ -97,15 +133,15 @@ VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
 
 VOID VideoFadeOut(ULONG ColorCount)
 {
-    ULONG        Index;
-    UCHAR        Color;
-    UCHAR        Red;
-    UCHAR        Green;
-    UCHAR        Blue;
+    ULONG Index;
+    UCHAR Color;
+    UCHAR Red;
+    UCHAR Green;
+    UCHAR Blue;
 
-    for (Index=0; Index<RGB_MAX; Index++)
+    for (Index = 0; Index < RGB_MAX; Index++)
     {
-        for (Color=0; Color<ColorCount; Color++)
+        for (Color = 0; Color < ColorCount; Color++)
         {
             if ((Color % RGB_MAX_PER_ITERATION) == 0)
             {
@@ -131,4 +167,5 @@ VOID VideoFadeOut(ULONG ColorCount)
         }
     }
 }
+
 #endif