ReactOS  0.4.15-dev-5463-g138eb58
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 
24 
26 
27  return VideoOffScreenBuffer;
28 }
29 
31 {
33  return;
34 
37 }
38 
40 {
42 }
43 
44 
46 {
47  ULONG Color;
48 
49  for (Color = 0; Color < ColorCount; Color++)
50  {
51  MachVideoGetPaletteColor((UCHAR)Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
52  }
53 }
54 
56 {
57  ULONG Color;
58 
59  MachVideoSync();
60 
61  for (Color = 0; Color < ColorCount; Color++)
62  {
63  MachVideoSetPaletteColor((UCHAR)Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
64  }
65 }
66 
67 
69 {
70  UCHAR Color;
71 
72  MachVideoSync();
73 
74  for (Color = 0; Color < ColorCount; Color++)
75  {
77  }
78 }
79 
80 VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
81 {
82  ULONG Index;
83  UCHAR Color;
84  PPALETTE_ENTRY PaletteColors;
85 
86  PaletteColors = FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * ColorCount, TAG_PALETTE_COLORS);
87  if (!PaletteColors) return;
88 
89  for (Index = 0; Index < RGB_MAX; Index++)
90  {
91  for (Color = 0; Color < ColorCount; Color++)
92  {
93  MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
94 
95  // Increment each color so it approaches its real value
96  if (PaletteColors[Color].Red < Palette[Color].Red)
97  {
98  PaletteColors[Color].Red++;
99  }
100  if (PaletteColors[Color].Green < Palette[Color].Green)
101  {
102  PaletteColors[Color].Green++;
103  }
104  if (PaletteColors[Color].Blue < Palette[Color].Blue)
105  {
106  PaletteColors[Color].Blue++;
107  }
108 
109  // Make sure we haven't exceeded the real value
110  if (PaletteColors[Color].Red > Palette[Color].Red)
111  {
112  PaletteColors[Color].Red = Palette[Color].Red;
113  }
114  if (PaletteColors[Color].Green > Palette[Color].Green)
115  {
116  PaletteColors[Color].Green = Palette[Color].Green;
117  }
118  if (PaletteColors[Color].Blue > Palette[Color].Blue)
119  {
120  PaletteColors[Color].Blue = Palette[Color].Blue;
121  }
122  }
123 
124  // Set the colors
125  for (Color = 0; Color < ColorCount; Color++)
126  {
127  if ((Color % RGB_MAX_PER_ITERATION) == 0)
128  {
129  MachVideoSync();
130  }
131 
132  MachVideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
133  }
134  }
135 
136  FrLdrTempFree(PaletteColors, TAG_PALETTE_COLORS);
137 }
138 
140 {
141  ULONG Index;
142  UCHAR Color;
143  UCHAR Red;
144  UCHAR Green;
145  UCHAR Blue;
146 
147  for (Index = 0; Index < RGB_MAX; Index++)
148  {
149  for (Color = 0; Color < ColorCount; Color++)
150  {
151  if ((Color % RGB_MAX_PER_ITERATION) == 0)
152  {
153  MachVideoSync();
154  }
155 
157 
158  if (Red > 0)
159  {
160  Red--;
161  }
162  if (Green > 0)
163  {
164  Green--;
165  }
166  if (Blue > 0)
167  {
168  Blue--;
169  }
170 
172  }
173  }
174 }
175 
176 #endif
Definition: bl.h:201
PVOID VideoAllocateOffScreenBuffer(VOID)
Definition: video.c:17
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
Definition: video.c:68
#define MachVideoGetPaletteColor(Col, R, G, B)
Definition: machine.h:114
Definition: bl.h:198
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:139
#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:188
Definition: video.h:11
#define TAG_PALETTE_COLORS
Definition: video.c:13
_In_ WDFCOLLECTION _In_ ULONG Index
UCHAR Red
Definition: video.h:13
Definition: bl.h:199
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
#define NULL
Definition: types.h:112
VOID VideoFreeOffScreenBuffer(VOID)
Definition: video.c:30
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:39
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:80
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
static PVOID VideoOffScreenBuffer
Definition: video.c:15
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:45
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:55
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197