This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
score.cpp
382 lines (361 loc) · 8.14 KB
/
score.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
373
374
375
376
377
378
379
380
381
382
#include "pinball.h"
//----- (0100C335) --------------------------------------------------------
int SpecialAddScore(int a1)
{
TPinballTable *v1; // ecx
int v2; // esi
int v3; // edi
int v4; // ebx
int result; // eax
TPinballTable *v6; // ecx
v1 = dword_1025040;
v2 = *(DWORD *)((char *)dword_1025040 + 318);
*(DWORD *)((char *)dword_1025040 + 318) = 0;
v3 = *(DWORD *)((char *)v1 + 310);
*(DWORD *)((char *)v1 + 310) = 0;
v4 = *(DWORD *)((char *)v1 + 294);
*(DWORD *)((char *)v1 + 294) = 0;
result = TPinballTable::AddScore(v1, a1);
v6 = dword_1025040;
*(DWORD *)((char *)dword_1025040 + 310) = v3;
*(DWORD *)((char *)v6 + 294) = v4;
*(DWORD *)((char *)v6 + 318) = v2;
return result;
}
//----- (0100E50B) --------------------------------------------------------
int AddRankProgress(int a1)
{
signed int v1; // ebx
int v2; // edi
void (__thiscall ***v3)(DWORD, signed int, DWORD); // esi
signed int v4; // edi
int v5; // eax
int (__thiscall ***v6)(DWORD, signed int, DWORD); // esi
int v7; // edi
CHAR *v8; // ST40_4
CHAR *v9; // eax
__int64 v10; // rax
int v11; // edx
signed __int64 v12; // rt2
char Dest; // [esp+50h] [ebp-44h]
v1 = 0;
(**(void (***)(signed int, DWORD))dword_10238F0)(19, 0.0);
v2 = a1;
v3 = (void (__thiscall ***)(DWORD, signed int, DWORD))dword_1023CFC;
if ( a1 > 0 )
{
do
{
(**v3)(v3, 41, 2.0);
--v2;
}
while ( v2 );
}
v4 = ((int (__thiscall *)(DWORD, signed int, DWORD))**v3)(v3, 37, 0.0);
v5 = ((int (__thiscall *)(DWORD, signed int, DWORD))**v3)(v3, 38, 0.0);
if ( v4 == v5 )
{
v1 = 1;
(**v3)(v3, 16, 5.0);
v6 = (int (__thiscall ***)(DWORD, signed int, DWORD))dword_1023CF4;
(**(void (***)(signed int, DWORD))dword_1023CF4)(34, 0.0);
v7 = (**v6)(v6, 37, 0.0);
if ( v7 < 9 )
{
(**v6)(v6, 41, 5.0);
v8 = get_rc_string(word_10246EC[2 * v7], 1);
v9 = get_rc_string(83, 0);
_sprintf(&Dest, v9, v8);
TTextBox::Display(tTextBox, 1, &Dest, 8.0);
(*(void (**)(void))(*(DWORD *)dword_1023D1C + 20))();
}
}
else
{
v10 = 3 * v5;
v12 = v10 % 4;
LODWORD(v10) = v10 / 4;
v11 = v12;
if ( v4 >= (signed int)v10 )
(**(void (__fastcall ***)(int, int, signed int, DWORD))dword_1023CF4)(dword_1023CF4, v11, 27, -1.0);
}
return v1;
}
// 10238F0: using guessed type int dword_10238F0;
// 1023CF4: using guessed type int dword_1023CF4;
// 1023CFC: using guessed type int dword_1023CFC;
// 1023D1C: using guessed type int dword_1023D1C;
// 10246EC: using guessed type int word_10246EC[];
//----- (01013BB3) --------------------------------------------------------
DWORD *score_create(LPCSTR lpString, int a2)
{
DWORD *v2; // esi
int *v3; // eax
int v5; // cx
signed int *v6; // eax
int v7; // edx
int v8; // edx
int v9; // ebx
int *v10; // edi
int v11; // [esp+10h] [ebp+Ch]
v2 = (DWORD *)memoryallocate(0x44u);
if ( !v2 )
return 0;
*v2 = -9999;
v2[2] = a2;
v3 = (int *)partman_field_labeled(loader_table, lpString, 10);
if ( !v3 )
{
memoryfree((int)v2);
return 0;
}
v5 = *v3;
v6 = v3 + 1;
v7 = *v6;
++v6;
v2[3] = v7;
v8 = *v6;
++v6;
v2[4] = v8;
v2[5] = *v6;
v2[6] = v6[1];
v9 = v5;
v10 = v2 + 7;
v11 = 10;
do
{
*v10 = partman_field(loader_table, v9, 1);
++v10;
++v9;
--v11;
}
while ( v11 );
return v2;
}
//----- (01013C48) --------------------------------------------------------
void *score_dup(const void *a1, int a2)
{
void *result; // eax
result = (void *)memoryallocate(0x44u);
if ( result )
qmemcpy(result, a1, 0x44u);
return result;
}
//----- (01013C89) --------------------------------------------------------
DWORD *score_set(DWORD *a1, int a2)
{
DWORD *result; // eax
result = a1;
if ( a1 )
{
*a1 = a2;
a1[1] = 1;
}
return result;
}
//----- (01013CAA) --------------------------------------------------------
void *score_erase(int a1, DWORD *a2, int a3)
{
DWORD *v3; // edx
void *result; // eax
if ( a2 )
{
v3 = (DWORD *)a2[2];
if ( v3 )
result = gdrv_copy_bitmap(&vscreen, a2[5], a2[6], a2[3], a2[4], v3, a2[3], a2[4]);
else
result = (void *)gdrv_fill_bitmap(a1, &vscreen, a2[5], a2[6], a2[3], a2[4], 0);
if ( a3 )
result = gdrv_blit((int)&vscreen, a2[3], a2[4], a2[3] + xDest, a2[4] + yDest, a2[5], a2[6]);
}
return result;
}
//----- (01013D2D) --------------------------------------------------------
HDC score_update(int a1, int *a2)
{
HDC result; // eax
int v3; // ecx
int v4; // edi
unsigned int v5; // kr00_4
int v6; // eax
char *v7; // eax
int v8; // [esp-24h] [ebp-40h]
int v9; // [esp-20h] [ebp-3Ch]
DWORD *v10; // [esp-14h] [ebp-30h]
int v11; // [esp+4h] [ebp-18h]
int v12; // [esp+8h] [ebp-14h]
char DstBuf[12]; // [esp+Ch] [ebp-10h]
result = 0;
if ( a2 && a2[1] && *a2 <= 1000000000 )
{
v3 = a2[4];
v4 = a2[5] + a2[3];
a2[1] = 0;
v11 = v3;
score_erase(a1, a2, 0);
if ( *a2 >= 0 )
{
__ltoa(*a2, DstBuf, 10);
v5 = strlen(DstBuf);
v6 = v5 - 1;
v12 = v5 - 1;
if ( (signed int)(v5 - 1) >= 0 )
{
while ( 1 )
{
v7 = &DstBuf[v6];
*v7 -= 48;
v10 = (DWORD *)a2[*v7 + 7];
v4 -= v10[3];
v9 = v10[4];
v8 = v10[3];
if ( render_background_bitmap )
gdrv_copy_bitmap_w_transparency(&vscreen, v8, v9, v4, v11, v10, 0, 0);
else
gdrv_copy_bitmap(&vscreen, v8, v9, v4, v11, v10, 0, 0);
if ( --v12 < 0 )
break;
v6 = v12;
}
}
}
result = gdrv_blit((int)&vscreen, a2[3], a2[4], a2[3] + xDest, a2[4] + yDest, a2[5], a2[6]);
}
return result;
}
// 1013D2D: using guessed type char DstBuf[12];
//----- (01013E25) --------------------------------------------------------
signed int score_init()
{
return 1;
}
//----- (01013E2E) --------------------------------------------------------
void score_unload_msg_font()
{
signed int v0; // esi
if ( score_msg_fontp )
{
v0 = 8;
do
{
if ( *(DWORD *)((char *)score_msg_fontp + v0) )
{
gdrv_destroy_bitmap(*(DWORD *)((char *)score_msg_fontp + v0));
memoryfree(*(DWORD *)((char *)score_msg_fontp + v0));
}
v0 += 4;
}
while ( v0 < 520 );
score_msg_fontp = 0;
}
}
// 10253C4: using guessed type struct score_msg_font_type *score_msg_fontp;
//----- (01013E73) --------------------------------------------------------
HRSRC score_load_msg_font(LPCSTR lpName)
{
HRSRC result; // eax
HRSRC v2; // esi
signed int *v3; // ebx
int v4; // edx
signed int v5; // esi
signed int v6; // ecx
char *v7; // eax
_BYTE *v8; // esi
int v9; // eax
unsigned int v10; // eax
const void *v11; // esi
DWORD *v12; // eax
int v13; // edx
char *v14; // eax
int v15; // esi
HRSRC hResData; // [esp+0h] [ebp-20h]
unsigned int v17; // [esp+4h] [ebp-1Ch]
char *i; // [esp+8h] [ebp-18h]
int v19; // [esp+Ch] [ebp-14h]
signed int v20; // [esp+10h] [ebp-10h]
char *v21; // [esp+14h] [ebp-Ch]
int v22; // [esp+18h] [ebp-8h]
int v23; // [esp+1Ch] [ebp-4h]
LPCSTR lpNamea; // [esp+28h] [ebp+8h]
result = FindResourceA(hinst, lpName, (LPCSTR)0xA);
if ( !result )
return result;
result = (HRSRC)LoadResource(hinst, result);
v2 = result;
hResData = result;
if ( !result )
return result;
v3 = (signed int *)LockResource(result);
v22 = (int)(v3 + 67);
v4 = memoryallocate(0x208u);
score_msg_fontp = (struct score_msg_font_type *)v4;
if ( !v4 )
return (HRSRC)FreeResource(v2);
v5 = 128;
memset((void *)(v4 + 8), 0, 0x200u);
v6 = 0;
v7 = (char *)(v3 + 3);
do
{
if ( *v7 > v6 )
v6 = *v7;
++v7;
--v5;
}
while ( v5 );
v19 = memoryallocate(v6 * v3[2] + 4);
if ( !v19 )
{
memoryfree((int)score_msg_fontp);
score_msg_fontp = 0;
return (HRSRC)FreeResource(hResData);
}
v23 = 0;
*(DWORD *)score_msg_fontp = *v3;
*((DWORD *)score_msg_fontp + 1) = v3[2];
lpNamea = (LPCSTR)8;
while ( 1 )
{
v8 = (char *)v3 + v23 + 6;
if ( *v8 )
break;
LABEL_16:
lpNamea += 4;
++v23;
if ( (signed int)lpNamea >= 520 )
goto LABEL_19;
}
*(DWORD *)((char *)score_msg_fontp + (DWORD)lpNamea) = memoryallocate(0x25u);
v9 = *(DWORD *)((char *)score_msg_fontp + (DWORD)lpNamea);
if ( !v9 )
goto LABEL_19;
if ( !gdrv_create_raw_bitmap(v9, (char)*v8, v3[2], 0) )
{
v10 = v3[2] * (char)*v8;
v11 = (const void *)v22;
v22 += ++v10;
qmemcpy((void *)(v19 + 3), v11, v10);
v20 = 0;
v17 = *((char *)v3 + v23 + 6);
v21 = (char *)(v19 + 4);
v12 = *(DWORD **)((char *)score_msg_fontp + (DWORD)lpNamea);
v13 = -v12[5];
v14 = (char *)(v12[2] - v13 * (v12[4] - 1));
for ( i = v14; v20 < v3[2]; i += v13 )
{
qmemcpy(v14, v21, v17);
++v20;
v21 += v17;
v14 = &i[v13];
}
goto LABEL_16;
}
v15 = 4 * v23 + 8;
memoryfree(*(DWORD *)((char *)score_msg_fontp + v15));
*(DWORD *)((char *)score_msg_fontp + v15) = 0;
LABEL_19:
if ( v23 != 128 )
score_unload_msg_font();
return (HRSRC)FreeResource(hResData);
}
// 10253C4: using guessed type struct score_msg_font_type *score_msg_fontp;