forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfac.cpp
More file actions
391 lines (374 loc) · 8.7 KB
/
interfac.cpp
File metadata and controls
391 lines (374 loc) · 8.7 KB
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
//HEADER_GOES_HERE
#include "../types.h"
void *sgpBackCel;
float interfac_cpp_init_value;
int sgdwProgress;
int progress_id; // idb
int interfac_inf = 0x7F800000; // weak
unsigned char progress_bar_colours[3] = { 138u, 43u, 254u };
POINT32 progress_bar_screen_pos[3] = { { 53, 37 }, { 53, 421 }, { 53, 37 } };
//----- (0041B195) --------------------------------------------------------
struct interfac_cpp_init
{
interfac_cpp_init()
{
interfac_cpp_init_value = interfac_inf;
}
} _interfac_cpp_init;
// 47AE40: using guessed type int interfac_inf;
//----- (0041B1A0) --------------------------------------------------------
void __cdecl interface_msg_pump()
{
MSG Msg; // [esp+8h] [ebp-1Ch]
while ( PeekMessageA(&Msg, NULL, 0, 0, PM_REMOVE) )
{
if ( Msg.message != WM_QUIT )
{
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
}
}
}
//----- (0041B1DF) --------------------------------------------------------
bool __cdecl IncProgress()
{
interface_msg_pump();
sgdwProgress += 15;
if ( (unsigned int)sgdwProgress > 0x216 )
sgdwProgress = 534;
if ( sgpBackCel )
DrawCutscene();
return (unsigned int)sgdwProgress >= 0x216;
}
//----- (0041B218) --------------------------------------------------------
void __cdecl DrawCutscene()
{
unsigned int v0; // esi
dx_lock_mutex();
CelDecodeOnly(64, 639, sgpBackCel, 1, 640);
v0 = 0;
if ( sgdwProgress )
{
do
DrawProgress(
progress_bar_screen_pos[progress_id].x + v0++ + 64,
progress_bar_screen_pos[progress_id].y + 160,
progress_id);
while ( v0 < sgdwProgress );
}
dx_unlock_mutex();
drawpanflag = 255;
scrollrt_draw_game_screen(0);
}
// 52571C: using guessed type int drawpanflag;
//----- (0041B28D) --------------------------------------------------------
void __fastcall DrawProgress(int screen_x, int screen_y, int progress_id)
{
_BYTE *v3; // eax
signed int v4; // ecx
v3 = (unsigned char *)gpBuffer + screen_y_times_768[screen_y] + screen_x;
v4 = 22;
do
{
*v3 = progress_bar_colours[progress_id];
v3 += 768;
--v4;
}
while ( v4 );
}
//----- (0041B2B6) --------------------------------------------------------
void __fastcall ShowProgress(int uMsg)
{
LRESULT (__stdcall *saveProc)(HWND, UINT, WPARAM, LPARAM); // edi
bool v3; // cl
int v4; // eax
int v5; // edx
signed int v7; // [esp-4h] [ebp-10h]
gbSomebodyWonGameKludge = 0;
plrmsg_delay(1);
saveProc = SetWindowProc(DisableInputWndProc);
interface_msg_pump();
ClearScreenBuffer();
scrollrt_draw_game_screen(1);
InitCutscene(uMsg);
BlackPalette();
DrawCutscene();
PaletteFadeIn(8);
IncProgress();
stream_update();
IncProgress();
switch ( uMsg )
{
case WM_DIABNEXTLVL:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
v4 = ++currlevel;
goto LABEL_38;
case WM_DIABPREVLVL:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
IncProgress();
FreeGameMem();
leveltype = gnLevelTypeTbl[--currlevel];
IncProgress();
v5 = 1;
goto LABEL_33;
case WM_DIABRTNLVL:
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
setlevel = 0;
FreeGameMem();
IncProgress();
GetReturnLvlPos();
v7 = 3;
goto LABEL_32;
case WM_DIABSETLVL:
SetReturnLvlPos();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
setlevel = 1;
leveltype = setlvltype;
FreeGameMem();
IncProgress();
v7 = 2;
goto LABEL_32;
case WM_DIABWARPLVL:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
GetPortalLevel();
IncProgress();
v7 = 5;
goto LABEL_32;
case WM_DIABTOWNWARP:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
IncProgress();
v7 = 6;
goto LABEL_32;
case WM_DIABTWARPUP:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
IncProgress();
v7 = 7;
LABEL_32:
v5 = v7;
LABEL_33:
v3 = 0;
goto LABEL_40;
case WM_DIABRETOWN:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
v4 = currlevel;
LABEL_38:
leveltype = gnLevelTypeTbl[v4];
IncProgress();
v3 = 0;
goto LABEL_39;
case WM_DIABNEWGAME:
IncProgress();
FreeGameMem();
IncProgress();
pfile_remove_temp_files();
v3 = 1;
LABEL_39:
v5 = 0;
LABEL_40:
LoadGameLevel(v3, v5);
goto LABEL_41;
case WM_DIABLOADGAME:
IncProgress();
LoadGame(1);
LABEL_41:
IncProgress();
break;
default:
break;
}
PaletteFadeOut(8);
FreeInterface();
SetWindowProc(saveProc);
NetSendCmdLocParam1(1u, CMD_PLAYER_JOINLEVEL, plr[myplr].WorldX, plr[myplr].WorldY, plr[myplr].plrlevel);
plrmsg_delay(0);
ResetPal();
if ( gbSomebodyWonGameKludge && plr[myplr].plrlevel == 16 )
PrepDoEnding();
gbSomebodyWonGameKludge = 0;
}
// 5BB1ED: using guessed type char leveltype;
// 5CF31C: using guessed type char setlvltype;
// 5CF31D: using guessed type char setlevel;
// 6761B8: using guessed type char gbSomebodyWonGameKludge;
// 679660: using guessed type char gbMaxPlayers;
//----- (0041B5F5) --------------------------------------------------------
void __cdecl FreeInterface()
{
void *v0; // ecx
v0 = sgpBackCel;
sgpBackCel = 0;
mem_free_dbg(v0);
}
//----- (0041B607) --------------------------------------------------------
void __fastcall InitCutscene(int interface_mode)
{
int v1; // eax
int v2; // eax
int v3; // eax
int v4; // eax
unsigned char *v5; // eax
char *v6; // ecx
int *v7; // eax
int v8; // eax
int v9; // eax
int v10; // eax
int v11; // eax
int v12; // eax
int v13; // eax
int v14; // eax
switch ( interface_mode )
{
case WM_DIABNEXTLVL:
v1 = gnLevelTypeTbl[currlevel];
if ( !v1 )
goto LABEL_31;
v2 = v1 - 1;
if ( !v2 )
goto LABEL_10;
v3 = v2 - 1;
if ( !v3 )
goto LABEL_9;
v4 = v3 - 1;
if ( !v4 )
goto LABEL_29;
if ( v4 != 1 )
goto LABEL_10;
if ( currlevel < 0xFu )
goto LABEL_28;
v5 = LoadFileInMem("Gendata\\Cutgate.CEL", 0);
v6 = "Gendata\\Cutgate.pal";
goto LABEL_30;
case WM_DIABPREVLVL:
v7 = &gnLevelTypeTbl[currlevel];
if ( !*(v7 - 1) )
goto LABEL_31;
v8 = *v7;
if ( !v8 )
goto LABEL_31;
v9 = v8 - 1;
if ( !v9 )
goto LABEL_10;
v10 = v9 - 1;
if ( !v10 )
{
LABEL_9:
sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0);
LoadPalette("Gendata\\Cut2.pal");
progress_id = 2;
goto LABEL_33;
}
v11 = v10 - 1;
if ( !v11 )
goto LABEL_29;
if ( v11 == 1 )
goto LABEL_28;
LABEL_10:
sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0);
LoadPalette("Gendata\\Cutl1d.pal");
progress_id = 0;
goto LABEL_33;
case WM_DIABRTNLVL:
case WM_DIABSETLVL:
if ( setlvlnum == SL_BONECHAMB )
goto LABEL_21;
if ( setlvlnum != SL_VILEBETRAYER )
goto LABEL_10;
v5 = LoadFileInMem("Gendata\\Cutportr.CEL", 0);
v6 = "Gendata\\Cutportr.pal";
goto LABEL_30;
case WM_DIABWARPLVL:
v5 = LoadFileInMem("Gendata\\Cutportl.CEL", 0);
v6 = "Gendata\\Cutportl.pal";
goto LABEL_30;
case WM_DIABTOWNWARP:
case WM_DIABTWARPUP:
v12 = gnLevelTypeTbl[plr[myplr].plrlevel];
if ( !v12 )
goto LABEL_31;
v13 = v12 - 2;
if ( !v13 )
{
LABEL_21:
sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0);
LoadPalette("Gendata\\Cut2.pal");
progress_id = SL_BONECHAMB;
goto LABEL_33;
}
v14 = v13 - 1;
if ( v14 )
{
if ( v14 != 1 )
goto LABEL_33;
LABEL_28:
v5 = LoadFileInMem("Gendata\\Cut4.CEL", 0);
v6 = "Gendata\\Cut4.pal";
}
else
{
LABEL_29:
v5 = LoadFileInMem("Gendata\\Cut3.CEL", 0);
v6 = "Gendata\\Cut3.pal";
}
LABEL_30:
sgpBackCel = v5;
LoadPalette(v6);
progress_id = 1;
LABEL_33:
sgdwProgress = 0;
return;
case WM_DIABRETOWN:
LABEL_31:
v5 = LoadFileInMem("Gendata\\Cuttt.CEL", 0);
v6 = "Gendata\\Cuttt.pal";
goto LABEL_30;
case WM_DIABNEWGAME:
case WM_DIABLOADGAME:
v5 = LoadFileInMem("Gendata\\Cutstart.CEL", 0);
v6 = "Gendata\\Cutstart.pal";
goto LABEL_30;
default:
TermMsg("Unknown progress mode");
goto LABEL_33;
}
}
// 5CCB10: using guessed type char setlvlnum;