ReactOS  0.4.14-dev-854-gb9426a3
video.c
Go to the documentation of this file.
1 /*
2  * PROJECT: FreeLoader
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: UI Video helpers for special effects.
5  * COPYRIGHT: Copyright 1998-2003 Brian Palmer <brianp@sginet.com>
6  */
7 
8 #ifndef _M_ARM
9 #include <freeldr.h>
10 
11 #define RGB_MAX 64
12 #define RGB_MAX_PER_ITERATION 64
13 #define TAG_PALETTE_COLORS 'claP'
14 
16 
18 {
20 
22  {
25  }
26 
28 
30 
31  return VideoOffScreenBuffer;
32 }
33 
35 {
37 }
38 
39 
41 {
42  ULONG Color;
43 
44  for (Color = 0; Color < ColorCount; Color++)
45  {
46  MachVideoGetPaletteColor((UCHAR)Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
47  }
48 }
49 
51 {
52  ULONG Color;
53 
54  MachVideoSync();
55 
56  for (Color = 0; Color < ColorCount; Color++)
57  {
58  MachVideoSetPaletteColor((UCHAR)Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
59  }
60 }
61 
62 
64 {
65  UCHAR Color;
66 
67  MachVideoSync();
68 
69  for (Color = 0; Color < ColorCount; Color++)
70  {
72  }
73 }
74 
75 VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
76 {
77  ULONG Index;
78  UCHAR Color;
79  PPALETTE_ENTRY PaletteColors;
80 
81  PaletteColors = FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * ColorCount, TAG_PALETTE_COLORS);
82  if (!PaletteColors) return;
83 
84  for (Index = 0; Index < RGB_MAX; Index++)
85  {
86  for (Color = 0; Color < ColorCount; Color++)
87  {
88  MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
89 
90  // Increment each color so it approaches its real value
91  if (PaletteColors[Color].Red < Palette[Color].Red)
92  {
93  PaletteColors[Color].Red++;
94  }
95  if (PaletteColors[Color].Green < Palette[Color].Green)
96  {
97  PaletteColors[Color].Green++;
98  }
99  if (PaletteColors[Color].Blue < Palette[Color].Blue)
100  {
101  PaletteColors[Color].Blue++;
102  }
103 
104  // Make sure we haven't exceeded the real value
105  if (PaletteColors[Color].Red > Palette[Color].Red)
106  {
107  PaletteColors[Color].Red = Palette[Color].Red;
108  }
109  if (PaletteColors[Color].Green > Palette[Color].Green)
110  {
111  PaletteColors[Color].Green = Palette[Color].Green;
112  }
113  if (PaletteColors[Color].Blue > Palette[Color].Blue)
114  {
115  PaletteColors[Color].Blue = Palette[Color].Blue;
116  }
117  }
118 
119  // Set the colors
120  for (Color = 0; Color < ColorCount; Color++)
121  {
122  if ((Color % RGB_MAX_PER_ITERATION) == 0)
123  {
124  MachVideoSync();
125  }
126 
127  MachVideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
128  }
129  }
130 
131  FrLdrTempFree(PaletteColors, TAG_PALETTE_COLORS);
132 }
133 
135 {
136  ULONG Index;
137  UCHAR Color;
138  UCHAR Red;
139  UCHAR Green;
140  UCHAR Blue;
141 
142  for (Index = 0; Index < RGB_MAX; Index++)
143  {
144  for (Color = 0; Color < ColorCount; Color++)
145  {
146  if ((Color % RGB_MAX_PER_ITERATION) == 0)
147  {
148  MachVideoSync();
149  }
150 
152 
153  if (Red > 0)
154  {
155  Red--;
156  }
157  if (Green > 0)
158  {
159  Green--;
160  }
161  if (Blue > 0)
162  {
163  Blue--;
164  }
165 
167  }
168  }
169 }
170 
171 #endif
Definition: bl.h:202
PVOID VideoAllocateOffScreenBuffer(VOID)
Definition: video.c:17
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
Definition: video.c:63
#define MachVideoGetPaletteColor(Col, R, G, B)
Definition: machine.h:114
Definition: bl.h:199
UCHAR Blue
Definition: video.h:15
#define MachVideoSetPaletteColor(Col, R, G, B)
Definition: machine.h:112
struct Color Color
#define MachVideoGetBufferSize()
Definition: machine.h:98
VOID VideoFadeOut(ULONG ColorCount)
Definition: video.c:134
#define MachVideoSync()
Definition: machine.h:116
#define MachVideoCopyOffScreenBufferToVRAM(Buf)
Definition: machine.h:108
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
smooth NULL
Definition: ftsmooth.c:416
Definition: video.h:11
#define TAG_PALETTE_COLORS
Definition: video.c:13
static const UCHAR Index[8]
Definition: usbohci.c:18
#define BufferSize
Definition: classpnp.h:419
UCHAR Red
Definition: video.h:13
Definition: bl.h:200
unsigned char UCHAR
Definition: xmlstorage.h:181
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
#define RGB_MAX
Definition: video.c:11
VOID MmFreeMemory(PVOID MemoryPointer)
Definition: mm.c:215
unsigned int ULONG
Definition: retypes.h:1
UCHAR Green
Definition: video.h:14
#define RGB_MAX_PER_ITERATION
Definition: video.c:12
VOID VideoCopyOffScreenBufferToVRAM(VOID)
Definition: video.c:34
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:75
static PVOID VideoOffScreenBuffer
Definition: video.c:15
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:40
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:50
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186