forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfade.cpp
140 lines (127 loc) · 3.27 KB
/
fade.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// ref: 0x1000722B
void __fastcall Fade_ApplyPaletteRange(int range1, int range2)
{
tagPALETTEENTRY *v4; // eax MAPDST
BYTE *v6; // esi
BYTE v7; // al
v4 = local_GetArtPalEntry(0);
if (range1 == range2) {
memcpy(fadepal, v4, 0x400u);
} else if (range2) {
v6 = &fadepal[0].peGreen;
do {
v7 = range2 * v4->peRed / range1;
++v4;
*(v6 - 1) = v7;
*v6 = range2 * v4[-1].peGreen / range1;
v6 += 4;
*(v6 - 3) = range2 * v4[-1].peBlue / range1;
} while ((signed int)v6 < (signed int)&fadepal[256].peGreen);
} else {
memcpy(fadepal, v4, 0x400u);
local_ClearPalette(fadepal);
}
SDrawUpdatePalette(0, 0x100u, fadepal, 1);
}
// ref: 0x100072BE
void __fastcall Fade_UpdatePaletteRange(int range)
{
tagPALETTEENTRY *v2; // eax
tagPALETTEENTRY *v3; // edi
BYTE *v4; // ecx
BYTE v5; // al
HPALETTE v6; // ebx
int v7; // [esp+10h] [ebp-4h]
v2 = local_GetArtPalEntry(0);
memcpy(fadepal, v2, 0x400u);
if (range > 0) {
v7 = range;
do {
v3 = local_GetArtPalEntry(0);
v4 = &fadepal[0].peGreen;
do {
v5 = v3->peRed / range;
++v3;
*(v4 - 1) -= v5;
*v4 -= v3[-1].peGreen / range;
v4 += 4;
*(v4 - 3) -= v3[-1].peBlue / range;
} while ((signed int)v4 < (signed int)&fadepal[256].peGreen);
SDrawUpdatePalette(0, 0x100u, fadepal, 1);
--v7;
} while (v7);
}
local_ClearPalette(fadepal);
SDrawUpdatePalette(0, 0x100u, fadepal, 1);
local_SetCursorDefault();
SDrawClearSurface(0);
v6 = (HPALETTE)GetStockObject(15);
GetPaletteEntries(v6, 0, 0xAu, fadepal);
GetPaletteEntries(v6, 0xAu, 0xAu, &fadepal[246]);
SDrawUpdatePalette(0, 0x100u, fadepal, 1);
}
// 1001043C: using guessed type int __stdcall SDrawClearSurface(_DWORD);
// ref: 0x1000739F
BOOL __cdecl Fade_CheckRange5()
{
BOOL result; // eax
result = 0;
if (sgbIsFading) {
if (sgbFadeRange <= 5)
result = 1;
}
return result;
}
// 10029C70: using guessed type int sgbIsFading;
// ref: 0x100073B4
void __cdecl Fade_Range5SetZero()
{
if (Fade_CheckRange5())
sgbIsFading = 0;
}
// 10029C70: using guessed type int sgbIsFading;
// ref: 0x100073C5
void __fastcall Fade_NoInputAndArt(HWND hWnd, BOOL bShowCurs)
{
HWND v3; // eax
v3 = GetParent(hWnd);
local_DisableKeyWaitMouse(v3);
if (bShowCurs)
local_SetCursorArt();
sgbIsFading = 0;
sgbFadeRange = 0;
}
// 10029C70: using guessed type int sgbIsFading;
// ref: 0x100073EF
void __fastcall Fade_SetInputWindow(HWND hWnd)
{
HWND v1; // eax
v1 = GetParent(hWnd);
local_DisableKeyWaitMouse(v1);
}
// ref: 0x100073FD
void __fastcall Fade_SetFadeTimer(int nTime)
{
if (!sgbIsFading) {
SDlgSetTimer(nTime, 16, 50, Fade_TimerFunctionDlg);
sgbIsFading = 1;
}
}
// 10029C70: using guessed type int sgbIsFading;
// ref: 0x10007420
void __stdcall Fade_TimerFunctionDlg(int a1, int a2, int a3, int a4)
{
if (sgbFadeRange > 5) {
SDlgKillTimer(a1, 16);
} else {
Fade_ApplyPaletteRange(5, sgbFadeRange);
++sgbFadeRange;
}
}
// ref: 0x1000744D
void __cdecl Fade_cpp_init()
{
fade_cpp_float = fade_cpp_float_value;
}
// 1001F428: using guessed type int fade_cpp_float_value;
// 10029868: using guessed type int fade_cpp_float;