forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoom.cpp
372 lines (336 loc) · 8.91 KB
/
doom.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
// ref: 0x10006581
void __cdecl Doom_cpp_init()
{
doom_cpp_float = doom_cpp_float_value;
}
// 1001F41C: using guessed type int doom_cpp_float_value;
// 10029854: using guessed type int doom_cpp_float;
// ref: 0x1000658C
void __fastcall Doom_ParseWndProcs(HWND hWnd, int *msgtbl, int nFont, int a4)
{
HWND msg; // eax
while (*msgtbl) {
msg = GetDlgItem(hWnd, *msgtbl);
Doom_GetSetWndText(hWnd, (int)msg, nFont, a4);
++msgtbl;
}
}
// ref: 0x100065BB
void __fastcall Doom_GetSetWndText(HWND hWnd, int msg, int nFont, int a4)
{
HWND v4; // esi
HWND v5; // edi
int v6; // eax
char String[256]; // [esp+8h] [ebp-100h]
v4 = (HWND)msg;
v5 = hWnd;
if (msg) {
Doom_AllocAndSetBMP(hWnd, msg, 1521);
Doom_GetWindowROP3(v5, v4);
artfont_SetArtFont(nFont);
Doom_PrintStrWithSpin(v4, a4);
GetWindowTextA(v4, String, 255);
if (strlen(String)) {
v6 = GetWindowLongA(v4, -21);
local_SetWndLongStr(v6, String);
SetWindowTextA(v4, &nullcharacter);
}
}
}
// ref: 0x1000663F
void __fastcall Doom_PrintStrWithSpin(HWND hWnd, BOOL a2)
{
DWORD *v3; // eax
DWORD *v4; // esi
char *v5; // ebx
int v6; // edi
size_t v7; // eax
char *i; // eax
int v9; // kr04_4
int v10; // eax
char String[256]; // [esp+8h] [ebp-10Ch]
char *v12; // [esp+108h] [ebp-Ch]
int v14; // [esp+110h] [ebp-4h]
v3 = (DWORD *)GetWindowLongA(hWnd, -21);
v4 = v3;
if (v3 && *v3) {
GetWindowTextA(hWnd, String, 255);
v5 = String;
if (!strlen(String))
v5 = (char *)(v4 + 4);
v14 = artfont_GetFontWidth(v5);
if (a2) {
v6 = v4[1] - 2 * Focus_GetSpinWidthOrZero();
v7 = strlen(v5);
if (v14 > v6) {
for (i = &v5[v7];; i = v12) {
v12 = i - 1;
*v12 = 0;
v14 = artfont_GetFontWidth(v5);
if (v14 <= v6)
break;
}
}
}
v9 = v4[1] - v14 - 1;
v10 = artfont_GetFontMaxHeight();
artfont_PrintFontStr(v5, (DWORD **)v4, v9 / 2, (v4[2] - v10) / 2);
InvalidateRect(hWnd, 0, 0);
}
}
// ref: 0x10006719
void __fastcall Doom_AllocAndSetBMP(HWND hWnd, int a2, int bmp_flags)
{
DWORD *v4; // esi
struct tagRECT Rect; // [esp+8h] [ebp-10h]
GetClientRect((HWND)a2, &Rect);
v4 = local_AllocWndLongData();
v4[1] = Rect.right;
v4[2] = Rect.bottom;
*v4 = (DWORD)SMemAlloc(Rect.right * Rect.bottom, "C:\\Src\\Diablo\\DiabloUI\\Doom.cpp", 139, 0);
SetWindowLongA((HWND)a2, -21, (LONG)v4);
SDlgSetBitmapI((HWND)a2, 0, &nullcharacter, -1, bmp_flags, (void *)*v4, 0, v4[1], v4[2], -1);
}
// ref: 0x1000678A
void __fastcall Doom_GetWindowROP3(HWND hWnd1, HWND hWnd2)
{
DWORD *v3; // ebx
LONG v4; // eax MAPDST
struct tagRECT Rect; // [esp+Ch] [ebp-14h]
v3 = (DWORD *)GetWindowLongA(hWnd1, -21);
v4 = GetWindowLongA(hWnd2, -21);
if (v3 && *v3 && v4) {
if (*(DWORD *)v4) {
GetWindowRect(hWnd2, &Rect);
ScreenToClient(hWnd1, (LPPOINT)&Rect);
ScreenToClient(hWnd1, (LPPOINT)&Rect.right);
SBltROP3(
*(void **)v4,
(void *)(Rect.left + *v3 + Rect.top * v3[1]),
*(DWORD *)(v4 + 4),
*(DWORD *)(v4 + 8),
*(DWORD *)(v4 + 4),
v3[1],
0,
0xCC0020u);
}
}
}
// ref: 0x1000680A
void __fastcall Doom_ParseWndProc2(HWND hWnd, int *msgtbl, int nFont, int a4)
{
HWND msg; // eax
while (*msgtbl) {
msg = GetDlgItem(hWnd, *msgtbl);
Doom_GetSetWndTxt2(hWnd, (int)msg, nFont, a4);
++msgtbl;
}
}
// ref: 0x10006839
void __fastcall Doom_GetSetWndTxt2(HWND hWnd, int msg, int nFont, int a4)
{
HWND v4; // esi
int v5; // eax
char String[256]; // [esp+4h] [ebp-100h]
v4 = (HWND)msg;
if (msg) {
Doom_GetWindowROP3(hWnd, (HWND)msg);
artfont_SetArtFont(nFont);
Doom_PrintStrWithSpin(v4, a4);
GetWindowTextA(v4, String, 255);
if (strlen(String)) {
v5 = GetWindowLongA(v4, -21);
local_SetWndLongStr(v5, String);
SetWindowTextA(v4, &nullcharacter);
}
}
}
// ref: 0x100068AB
void __fastcall Doom_ParseWndProc3(HWND hWnd, int *msgtbl, int nFont)
{
HWND msg; // eax
while (*msgtbl) {
msg = GetDlgItem(hWnd, *msgtbl);
Doom_GetSetWndTxt3(hWnd, (int)msg, nFont);
++msgtbl;
}
}
// ref: 0x100068D6
void __fastcall Doom_GetSetWndTxt3(HWND hWnd, int msg, int nFont)
{
HWND v3; // esi
HWND v4; // edi
int v5; // eax
int v6; // eax
char String[256]; // [esp+8h] [ebp-100h]
v3 = (HWND)msg;
v4 = hWnd;
if (msg) {
Doom_AllocAndSetBMP(hWnd, msg, 1);
Doom_GetWindowROP3(v4, v3);
artfont_SetArtFont(nFont);
v5 = GetWindowLongA(v3, -16);
Doom_PrintStrWithSpn2(v3, v5);
GetWindowTextA(v3, String, 255);
if (strlen(String)) {
v6 = GetWindowLongA(v3, -21);
local_SetWndLongStr(v6, String);
SetWindowTextA(v3, &nullcharacter);
}
}
}
// ref: 0x1000695D
void __fastcall Doom_PrintStrWithSpn2(HWND hWnd, int justify_type)
{
DWORD *v2; // eax
DWORD *v3; // esi
char *v4; // edi
int v5; // eax
char String[256]; // [esp+4h] [ebp-108h]
v2 = (DWORD *)GetWindowLongA(hWnd, -21);
v3 = v2;
if (v2 && *v2) {
GetWindowTextA(hWnd, String, 255);
v4 = String;
if (!strlen(String))
v4 = (char *)(v3 + 4);
if (justify_type & 2) {
v5 = v3[1] - artfont_GetFontWidth(v4) - 1;
} else if (justify_type & 1) {
v5 = (v3[1] - artfont_GetFontWidth(v4) - 1) / 2;
} else {
v5 = 0;
}
artfont_PrintFontStr(v4, (DWORD **)v3, v5, 0);
InvalidateRect(hWnd, 0, 0);
}
}
// ref: 0x10006A13
void __fastcall Doom_ParseWndProc4(HWND hWnd, int *msgtbl, int nFont)
{
HWND msg; // eax
while (*msgtbl) {
msg = GetDlgItem(hWnd, *msgtbl);
Doom_GetSetWndTxt4(hWnd, (int)msg, nFont);
++msgtbl;
}
}
// ref: 0x10006A3E
void __fastcall Doom_GetSetWndTxt4(HWND hWnd, int msg, int nFont)
{
HWND v3; // edi
int v4; // eax
int v5; // eax
char String[256]; // [esp+8h] [ebp-100h]
v3 = (HWND)msg;
if (msg) {
Doom_GetWindowROP3(hWnd, (HWND)msg);
artfont_SetArtFont(nFont);
v4 = GetWindowLongA(v3, -16);
Doom_PrintStrWithSpn2(v3, v4);
GetWindowTextA(v3, String, 255);
if (strlen(String)) {
v5 = GetWindowLongA(v3, -21);
local_SetWndLongStr(v5, String);
SetWindowTextA(v3, &nullcharacter);
}
}
}
// ref: 0x10006AB8
void __fastcall Doom_ParseWndProc5(HWND hWnd, int *msgtbl, int nFont)
{
HWND msg; // eax
while (*msgtbl) {
msg = GetDlgItem(hWnd, *msgtbl);
Doom_GetSetWndTxt5(hWnd, (int)msg, nFont);
++msgtbl;
}
}
// ref: 0x10006AE3
void __fastcall Doom_GetSetWndTxt5(HWND hWnd, int msg, int nFont)
{
HWND v3; // esi
v3 = (HWND)msg;
if (msg) {
Doom_AllocAndSetBMP(hWnd, msg, 1);
Doom_GetWindowROP3(hWnd, v3);
artfont_SetArtFont(nFont);
Doom_PrintTextMsg403(v3);
}
}
// ref: 0x10006B12
void __fastcall Doom_PrintTextMsg403(HWND hWnd)
{
BYTE *v2; // eax
int v3; // edi
int v4; // edi
int v5; // esi
int v6; // esi
char *i; // ebx
int v8; // eax
//char v9; // [esp+3h] [ebp-11Dh]
char String[256]; // [esp+4h] [ebp-11Ch]
struct tagRECT Rect; // [esp+104h] [ebp-1Ch]
LRESULT v12; // [esp+114h] [ebp-Ch]
BYTE *pWidthBin; // [esp+118h] [ebp-8h]
size_t v14; // [esp+11Ch] [ebp-4h]
v2 = (BYTE *)GetWindowLongA(hWnd, -21);
pWidthBin = v2;
if (v2 && *(DWORD *)v2) {
GetWindowTextA(hWnd, String, 255);
v14 = strlen(String);
v3 = Focus_GetSpinWidthOrZero();
v4 = artfont_GetFontDefWidth() + v3;
GetClientRect(hWnd, &Rect);
v5 = Focus_GetSpinWidthOrZero();
v6 = Rect.right - 2 * (artfont_GetFontDefWidth() + v5);
v12 = SendMessageA(hWnd, 0x403u, 0, 0);
if (v12 == 1)
String[v14 - 1] = 0; // *(&v9 + v14) = 0;
for (i = String; *i; ++i) {
if (artfont_GetFontWidth(i) <= v6)
break;
}
if (v12)
String[v14 - 1] = 124; // *(&v9 + v14) = 124;
v8 = artfont_GetFontMaxHeight();
artfont_PrintFontStr(i, (DWORD **)pWidthBin, v4, (*((DWORD *)pWidthBin + 2) - v8) / 2);
}
}
// ref: 0x10006C08
void __fastcall Doom_ParseWndProc6(HWND hWnd, int *msgtbl, int nFont)
{
HWND msg; // eax
while (*msgtbl) {
msg = GetDlgItem(hWnd, *msgtbl);
Doom_GetSetWndTxt6(hWnd, (int)msg, nFont);
++msgtbl;
}
}
// ref: 0x10006C33
void __fastcall Doom_GetSetWndTxt6(HWND hWnd, int msg, int nFont)
{
HWND v3; // esi
v3 = (HWND)msg;
if (msg) {
Doom_GetWindowROP3(hWnd, (HWND)msg);
artfont_SetArtFont(nFont);
Doom_PrintTextMsg403(v3);
}
}
// ref: 0x10006C53
void __fastcall Doom_DeleteFreeProcs(HWND hWnd, int *msgtbl)
{
int i; // eax
HWND v5; // eax MAPDST
void **v7; // eax
for (i = *msgtbl; *msgtbl; i = *msgtbl) {
v5 = GetDlgItem(hWnd, i);
if (v5) {
v7 = (void **)GetWindowLongA(v5, -21);
local_FreeMemPtr(v7);
SetWindowLongA(v5, -21, 0);
}
++msgtbl;
}
}