- PCHify freeldr and cleanup some headers (just a start).
[reactos.git] / reactos / boot / freeldr / freeldr / video / fade.c
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <freeldr.h>
21
22 #define RGB_MAX 64
23 #define RGB_MAX_PER_ITERATION 64
24
25 VOID VideoSetAllColorsToBlack(ULONG ColorCount)
26 {
27 ULONG Color;
28
29 MachVideoSync();
30
31 for (Color=0; Color<ColorCount; Color++)
32 {
33 MachVideoSetPaletteColor(Color, 0, 0, 0);
34 }
35 }
36
37 VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
38 {
39 ULONG Index;
40 ULONG Color;
41 PALETTE_ENTRY PaletteColors[ColorCount];
42
43 for (Index=0; Index<RGB_MAX; Index++)
44 {
45
46 for (Color=0; Color<ColorCount; Color++)
47 {
48 MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
49
50 // Increment each color so it approaches its real value
51 if (PaletteColors[Color].Red < Palette[Color].Red)
52 {
53 PaletteColors[Color].Red++;
54 }
55 if (PaletteColors[Color].Green < Palette[Color].Green)
56 {
57 PaletteColors[Color].Green++;
58 }
59 if (PaletteColors[Color].Blue < Palette[Color].Blue)
60 {
61 PaletteColors[Color].Blue++;
62 }
63
64 // Make sure we haven't exceeded the real value
65 if (PaletteColors[Color].Red > Palette[Color].Red)
66 {
67 PaletteColors[Color].Red = Palette[Color].Red;
68 }
69 if (PaletteColors[Color].Green > Palette[Color].Green)
70 {
71 PaletteColors[Color].Green = Palette[Color].Green;
72 }
73 if (PaletteColors[Color].Blue > Palette[Color].Blue)
74 {
75 PaletteColors[Color].Blue = Palette[Color].Blue;
76 }
77 }
78
79 // Set the colors
80 for (Color=0; Color<ColorCount; Color++)
81 {
82 if ((Color % RGB_MAX_PER_ITERATION) == 0)
83 {
84 MachVideoSync();
85 }
86
87 MachVideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
88 }
89 }
90 }
91
92 VOID VideoFadeOut(ULONG ColorCount)
93 {
94 ULONG Index;
95 ULONG Color;
96 UCHAR Red;
97 UCHAR Green;
98 UCHAR Blue;
99
100 for (Index=0; Index<RGB_MAX; Index++)
101 {
102 for (Color=0; Color<ColorCount; Color++)
103 {
104 if ((Color % RGB_MAX_PER_ITERATION) == 0)
105 {
106 MachVideoSync();
107 }
108
109 MachVideoGetPaletteColor(Color, &Red, &Green, &Blue);
110
111 if (Red > 0)
112 {
113 Red--;
114 }
115 if (Green > 0)
116 {
117 Green--;
118 }
119 if (Blue > 0)
120 {
121 Blue--;
122 }
123
124 MachVideoSetPaletteColor(Color, Red, Green, Blue);
125 }
126 }
127 }