[MEDIA][FONTS] Add Arabic MS Sans Serif (ssee1256.fon)
[reactos.git] / 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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 #ifndef _M_ARM
20 #include <freeldr.h>
21
22 #define RGB_MAX 64
23 #define RGB_MAX_PER_ITERATION 64
24 #define TAG_PALETTE_COLORS 'claP'
25
26 VOID VideoSetAllColorsToBlack(ULONG ColorCount)
27 {
28 UCHAR Color;
29
30 MachVideoSync();
31
32 for (Color=0; Color<ColorCount; Color++)
33 {
34 MachVideoSetPaletteColor(Color, 0, 0, 0);
35 }
36 }
37
38 VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
39 {
40 ULONG Index;
41 UCHAR Color;
42 PPALETTE_ENTRY PaletteColors;
43
44 PaletteColors = FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * ColorCount, TAG_PALETTE_COLORS);
45 if (!PaletteColors) return;
46
47 for (Index=0; Index<RGB_MAX; Index++)
48 {
49
50 for (Color=0; Color<ColorCount; Color++)
51 {
52 MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
53
54 // Increment each color so it approaches its real value
55 if (PaletteColors[Color].Red < Palette[Color].Red)
56 {
57 PaletteColors[Color].Red++;
58 }
59 if (PaletteColors[Color].Green < Palette[Color].Green)
60 {
61 PaletteColors[Color].Green++;
62 }
63 if (PaletteColors[Color].Blue < Palette[Color].Blue)
64 {
65 PaletteColors[Color].Blue++;
66 }
67
68 // Make sure we haven't exceeded the real value
69 if (PaletteColors[Color].Red > Palette[Color].Red)
70 {
71 PaletteColors[Color].Red = Palette[Color].Red;
72 }
73 if (PaletteColors[Color].Green > Palette[Color].Green)
74 {
75 PaletteColors[Color].Green = Palette[Color].Green;
76 }
77 if (PaletteColors[Color].Blue > Palette[Color].Blue)
78 {
79 PaletteColors[Color].Blue = Palette[Color].Blue;
80 }
81 }
82
83 // Set the colors
84 for (Color=0; Color<ColorCount; Color++)
85 {
86 if ((Color % RGB_MAX_PER_ITERATION) == 0)
87 {
88 MachVideoSync();
89 }
90
91 MachVideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
92 }
93 }
94
95 FrLdrTempFree(PaletteColors, TAG_PALETTE_COLORS);
96 }
97
98 VOID VideoFadeOut(ULONG ColorCount)
99 {
100 ULONG Index;
101 UCHAR Color;
102 UCHAR Red;
103 UCHAR Green;
104 UCHAR Blue;
105
106 for (Index=0; Index<RGB_MAX; Index++)
107 {
108 for (Color=0; Color<ColorCount; Color++)
109 {
110 if ((Color % RGB_MAX_PER_ITERATION) == 0)
111 {
112 MachVideoSync();
113 }
114
115 MachVideoGetPaletteColor(Color, &Red, &Green, &Blue);
116
117 if (Red > 0)
118 {
119 Red--;
120 }
121 if (Green > 0)
122 {
123 Green--;
124 }
125 if (Blue > 0)
126 {
127 Blue--;
128 }
129
130 MachVideoSetPaletteColor(Color, Red, Green, Blue);
131 }
132 }
133 }
134 #endif