ReactOS 0.4.16-dev-297-gc569aee
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#include <freeldr.h>
9
10#define RGB_MAX 64
11#define RGB_MAX_PER_ITERATION 64
12#define TAG_PALETTE_COLORS 'claP'
13
15
17{
19
21
23
25
27}
28
30{
32 return;
33
36}
37
39{
41}
42
43
45{
47
48 for (Color = 0; Color < ColorCount; Color++)
49 {
50 MachVideoGetPaletteColor((UCHAR)Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
51 }
52}
53
55{
57
59
60 for (Color = 0; Color < ColorCount; Color++)
61 {
62 MachVideoSetPaletteColor((UCHAR)Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
63 }
64}
65
66
68{
70
72
73 for (Color = 0; Color < ColorCount; Color++)
74 {
76 }
77}
78
80{
83 PPALETTE_ENTRY PaletteColors;
84
85 PaletteColors = FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * ColorCount, TAG_PALETTE_COLORS);
86 if (!PaletteColors) return;
87
88 for (Index = 0; Index < RGB_MAX; Index++)
89 {
90 for (Color = 0; Color < ColorCount; Color++)
91 {
92 MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
93
94 // Increment each color so it approaches its real value
95 if (PaletteColors[Color].Red < Palette[Color].Red)
96 {
97 PaletteColors[Color].Red++;
98 }
99 if (PaletteColors[Color].Green < Palette[Color].Green)
100 {
101 PaletteColors[Color].Green++;
102 }
103 if (PaletteColors[Color].Blue < Palette[Color].Blue)
104 {
105 PaletteColors[Color].Blue++;
106 }
107
108 // Make sure we haven't exceeded the real value
109 if (PaletteColors[Color].Red > Palette[Color].Red)
110 {
111 PaletteColors[Color].Red = Palette[Color].Red;
112 }
113 if (PaletteColors[Color].Green > Palette[Color].Green)
114 {
115 PaletteColors[Color].Green = Palette[Color].Green;
116 }
117 if (PaletteColors[Color].Blue > Palette[Color].Blue)
118 {
119 PaletteColors[Color].Blue = Palette[Color].Blue;
120 }
121 }
122
123 // Set the colors
124 for (Color = 0; Color < ColorCount; Color++)
125 {
126 if ((Color % RGB_MAX_PER_ITERATION) == 0)
127 {
129 }
130
131 MachVideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
132 }
133 }
134
135 FrLdrTempFree(PaletteColors, TAG_PALETTE_COLORS);
136}
137
139{
140 ULONG Index;
141 UCHAR Color;
142 UCHAR Red;
143 UCHAR Green;
144 UCHAR Blue;
145
146 for (Index = 0; Index < RGB_MAX; Index++)
147 {
148 for (Color = 0; Color < ColorCount; Color++)
149 {
150 if ((Color % RGB_MAX_PER_ITERATION) == 0)
151 {
153 }
154
156
157 if (Red > 0)
158 {
159 Red--;
160 }
161 if (Green > 0)
162 {
163 Green--;
164 }
165 if (Blue > 0)
166 {
167 Blue--;
168 }
169
171 }
172 }
173}
174
@ Green
Definition: bl.h:199
@ Red
Definition: bl.h:201
@ Blue
Definition: bl.h:198
#define MachVideoSetPaletteColor(Col, R, G, B)
Definition: machine.h:112
#define MachVideoGetBufferSize()
Definition: machine.h:98
#define MachVideoGetPaletteColor(Col, R, G, B)
Definition: machine.h:114
#define MachVideoCopyOffScreenBufferToVRAM(Buf)
Definition: machine.h:108
#define MachVideoSync()
Definition: machine.h:116
VOID MmFreeMemory(PVOID MemoryPointer)
Definition: mm.c:215
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:79
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
Definition: video.c:67
VOID VideoFadeOut(ULONG ColorCount)
Definition: video.c:138
#define TAG_PALETTE_COLORS
Definition: video.c:12
static PVOID VideoOffScreenBuffer
Definition: video.c:14
VOID VideoFreeOffScreenBuffer(VOID)
Definition: video.c:29
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:54
#define RGB_MAX
Definition: video.c:10
PVOID VideoAllocateOffScreenBuffer(VOID)
Definition: video.c:16
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:44
VOID VideoCopyOffScreenBufferToVRAM(VOID)
Definition: video.c:38
#define RGB_MAX_PER_ITERATION
Definition: video.c:11
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
@ LoaderFirmwareTemporary
Definition: arc.h:179
Definition: video.h:12
UCHAR Blue
Definition: video.h:15
UCHAR Red
Definition: video.h:13
UCHAR Green
Definition: video.h:14
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
unsigned char UCHAR
Definition: xmlstorage.h:181