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
/
pinball.cpp
1009 lines (960 loc) · 23.5 KB
/
pinball.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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Created by neo on 2019-08-15.
//
#include <windows.h>
#include <math.h>
#include <defs.h>
#include "pinball.h"
//----- (0101461A) --------------------------------------------------------
signed int pb_mode_change(int a1)
{
switch (a1)
{
case 1:
if (dword_1025570)
{
options_menu_set(0x191u, 0);
options_menu_set(0x67u, 0);
options_menu_check(0x194u, 1);
if (MainTable)
{
int v2 = *(DWORD*)((char*)MainTable + 230);
if (v2)
* (_BYTE*)(v2 + 5) = 1;
}
}
else
{
options_menu_set(0x67u, 1);
options_menu_set(0x191u, 1);
options_menu_check(0x194u, 0);
if (MainTable)
{
int v1 = *(DWORD*)((char*)MainTable + 230);
if (v1)
* (_BYTE*)(v1 + 5) = 0;
}
}
break;
case 2:
options_menu_set(0x191u, 0);
if (!dword_1025570)
{
options_menu_set(0x67u, 1);
options_menu_check(0x194u, 0);
}
if (MainTable && *(DWORD*)((char*)MainTable + 266))
(***(void(__thiscall * ***)(DWORD, signed int, DWORD))((char*)MainTable + 266))(
*(DWORD*)((char*)MainTable + 266),
29,
1.4);
break;
case 3:
case 4:
options_menu_set(0x191u, 0);
options_menu_set(0x67u, 0);
dword_1025574 = 5000;
break;
}
dword_1025568 = a1;
return 1;
}
// 1025568: using guessed type int dword_1025568;
// 1025570: using guessed type int dword_1025570;
// 1025574: using guessed type int dword_1025574;
//----- (01014743) --------------------------------------------------------
signed int pb_mode_countdown(int a1)
{
if (!dword_1025568 || dword_1025568 <= 0)
return 1;
if (dword_1025568 > 2)
{
if (dword_1025568 == 3)
{
dword_1025574 -= a1;
if (dword_1025574 < 0 || a1 < 0)
pb_mode_change(4);
}
else if (dword_1025568 == 4)
{
dword_1025574 -= a1;
if (dword_1025574 < 0 || a1 < 0)
pb_mode_change(1);
}
return 1;
}
return 0;
}
// 1025568: using guessed type int dword_1025568;
// 1025574: using guessed type int dword_1025574;
//----- (0101479B) --------------------------------------------------------
int pb_end_game()
{
struct TPinballTable* v0; // edx
int v1; // esi
int v2; // eax
int** v3; // ecx
int v4; // eax
int* v5; // esi
int v6; // eax
int* v7; // ecx
int v8; // edi
int* v9; // ecx
int* v10; // eax
int v11; // edx
int result; // eax
int v13; // edi
int v14; // ebx
CHAR* v15; // eax
int v16[4]; // [esp+Ch] [ebp-F8h]
int v17[4]; // [esp+1Ch] [ebp-E8h]
int v18; // [esp+2Ch] [ebp-D8h]
int v19; // [esp+30h] [ebp-D4h]
int i; // [esp+34h] [ebp-D0h]
CHAR String1; // [esp+38h] [ebp-CCh]
pb_mode_change(2);
v0 = MainTable;
v2 = 0;
v18 = *(DWORD*)((char*)MainTable + 214);
v1 = v18;
if (v18 > 0)
{
v3 = (int**)((char*)MainTable + 102);
do
{
v16[v2] = **v3;
v17[v2] = v2;
++v2;
v3 += 7;
} while (v2 < v1);
}
v4 = 0;
for (i = 0; i < v1; ++i)
{
v19 = v4;
if (v4 < v1)
{
v5 = &v16[v4];
do
{
v6 = v19;
v7 = &v16[v19];
v8 = *v7;
if (*v7 > (unsigned int) * v5)
{
*v7 = *v5;
v9 = &v17[i];
v10 = &v17[v6];
v11 = *v10;
*v5 = v8;
*v10 = *v9;
*v9 = v11;
v0 = MainTable;
}
++v19;
} while (v19 < v18);
v1 = v18;
}
v4 = i + 1;
}
result = 0;
if (!dword_1025570 && !*(DWORD*)((char*)v0 + 62))
{
i = 0;
if (v1 > 0)
{
do
{
v13 = v16[i];
v14 = high_score_get_score_position((int)byte_1025578, v16[i]);
if (v14 >= 0)
{
v15 = get_rc_string(LOWORD(v17[i]) + 26, 0);
lstrcpyA(&String1, v15);
show_and_set_high_score_dialog(byte_1025578, v13, v14, &String1);
}
result = ++i;
} while (i < v18);
}
}
return result;
}
// 1025570: using guessed type int dword_1025570;
// 101479B: using guessed type int var_F8[4];
// 101479B: using guessed type int var_E8[4];
//----- (01014908) --------------------------------------------------------
signed int pb_chk_highscore()
{
int v0; // esi
int v1; // edi
if (dword_1025570)
return 0;
v0 = *(DWORD*)((char*)MainTable + 214) - 1;
if (v0 < 0)
return 0;
v1 = 28 * v0;
while (high_score_get_score_position((int)byte_1025578, **(DWORD * *)((char*)MainTable + v1 + 102)) < 0)
{
--v0;
v1 -= 28;
if (v0 < 0)
return 0;
}
return 1;
}
// 1025570: using guessed type int dword_1025570;
//----- (01014956) --------------------------------------------------------
long double pb_collide(struct TEdgeSegment* a1, float a2, struct TBall* a3)
{
struct TBall* v3; // ebx
double v4; // st7
float v5; // eax
double v6; // st6
double v7; // st5
int v8; // eax
double v9; // st7
double v11; // st7
struct vector_type* v12; // ST0C_4
int v13; // [esp+8h] [ebp-40h]
int v14; // [esp+Ch] [ebp-3Ch]
int v15; // [esp+10h] [ebp-38h]
int v16; // [esp+14h] [ebp-34h]
int v17; // [esp+18h] [ebp-30h]
int v18; // [esp+1Ch] [ebp-2Ch]
float v19; // [esp+20h] [ebp-28h]
int v20; // [esp+24h] [ebp-24h]
float v21; // [esp+28h] [ebp-20h]
float v22; // [esp+2Ch] [ebp-1Ch]
int v23; // [esp+30h] [ebp-18h]
float v24; // [esp+34h] [ebp-14h]
float v25; // [esp+38h] [ebp-10h]
float v26; // [esp+3Ch] [ebp-Ch]
struct vector_type* v27; // [esp+40h] [ebp-8h]
float v28; // [esp+44h] [ebp-4h]
v3 = a3;
if (*((_BYTE*)a3 + 5) && !*(DWORD*)((char*)a3 + 106))
{
if (ball_speed_limit < (double) * (float*)((char*)a3 + 66))
* (float*)((char*)a3 + 66) = ball_speed_limit;
v4 = a2;
v5 = *(float*)((char*)v3 + 66);
*(float*)((char*)v3 + 74) = a2;
v6 = v4 * *(float*)((char*)v3 + 66);
v27 = (struct TBall*)((char*)v3 + 42);
v13 = *(DWORD*)((char*)v3 + 42);
*(float*)((char*)v3 + 70) = v6;
v7 = *(float*)& a1;
v14 = *(DWORD*)((char*)v3 + 46);
*(float*)((char*)v3 + 78) = *(float*)& a1;
v15 = *(DWORD*)((char*)v3 + 50);
v16 = *(DWORD*)((char*)v3 + 54);
v17 = *(DWORD*)((char*)v3 + 58);
v28 = v5;
v8 = *(DWORD*)((char*)v3 + 110);
v18 = *(DWORD*)((char*)v3 + 62);
v19 = v6;
v23 = v8;
v21 = v7;
v22 = v4;
v20 = 990057071;
v9 = TEdgeManager::FindCollisionDistance(edge_manager, (struct ray_type*) & v13, v3, &a1);
*(DWORD*)((char*)v3 + 134) = 0;
*(float*)& a3 = v9;
if (*(float*)& a3 >= 1000000000.0)
{
v11 = a2 * *(float*)((char*)v3 + 66);
v12 = v27;
*(float*)((char*)v3 + 70) = v11;
v24 = v11 * *(float*)((char*)v3 + 54);
v25 = v11 * *(float*)((char*)v3 + 58);
v26 = 0.0;
vector_add(v12, (struct vector_type*) & v24);
}
else
{
(**(void(* **)(struct TBall*, struct TBall*))a1)(v3, a3);
if (v28 > 0.000000001)
return fabs(*(float*)& a3 / v28);
}
}
return a2;
}
// 10253D0: using guessed type float ball_speed_limit;
//----- (01014A68) --------------------------------------------------------
void pb_timed_frame(float a1, float a2, int a3)
{
int v3; // eax
int v4; // edi
int v5; // ebx
int v6; // esi
bool v7; // zf
int v8; // ecx
double v9; // st7
double v10; // st7
double v11; // st7
long double v12; // st7
int v13; // esi
char v14; // [esp+18h] [ebp-2Ch]
float v15; // [esp+24h] [ebp-20h]
float v16; // [esp+28h] [ebp-1Ch]
float v17; // [esp+2Ch] [ebp-18h]
int v18; // [esp+30h] [ebp-14h]
int v19; // [esp+34h] [ebp-10h]
int v20; // [esp+38h] [ebp-Ch]
float v21; // [esp+3Ch] [ebp-8h]
float v22; // [esp+40h] [ebp-4h]
v3 = *(DWORD*)((char*)MainTable + 262);
v18 = *(DWORD*)(v3 + 4);
v4 = v18;
v5 = v3 + 8;
if (v18 > 0)
{
v19 = v18;
do
{
v6 = *(DWORD*)v5;
v7 = *(_BYTE*)(*(DWORD*)v5 + 5) == 0;
v22 = a2;
if (!v7)
{
v8 = *(DWORD*)(v6 + 106);
if (v8)
{
*(float*)(v6 + 74) = a2;
(*(void(* *)(int, char*))(*(DWORD*)v8 + 24))(v6, &v14);
}
else
{
if (*((_BYTE*)MainTable + 5))
{
v15 = 0.0;
v16 = 0.0;
v17 = 0.0;
TEdgeManager::FieldEffects(edge_manager, (struct TBall*)v6, (struct vector_type*) & v15);
v15 = v15 * a2;
v16 = v16 * a2;
*(float*)(v6 + 54) = *(float*)(v6 + 66) * *(float*)(v6 + 54);
*(float*)(v6 + 58) = *(float*)(v6 + 66) * *(float*)(v6 + 58);
vector_add((struct vector_type*)(v6 + 54), (struct vector_type*) & v15);
*(float*)(v6 + 66) = normalize_2d((float*)(v6 + 54));
if (0.0 == *(float*)(v6 + 54))
v9 = 1000000000.0;
else
v9 = 1.0 / *(float*)(v6 + 54);
*(float*)(v6 + 82) = v9;
if (0.0 == *(float*)(v6 + 58))
v10 = 1000000000.0;
else
v10 = 1.0 / *(float*)(v6 + 58);
v4 = v18;
*(float*)(v6 + 86) = v10;
}
v11 = a2;
v21 = a1;
v20 = 10;
while (v11 > 0.000001 && v20)
{
v12 = pb_collide((struct TEdgeSegment*)LODWORD(v21), v22, (struct TBall*)v6);
--v20;
v22 = v22 - v12;
v21 = v12 + v21;
v11 = v22;
}
}
}
v5 += 4;
--v19;
} while (v19);
}
if (a3)
{
v13 = *(DWORD*)((char*)MainTable + 262) + 8;
if (v4 > 0)
{
do
{
if (*(_BYTE*)(*(DWORD*)v13 + 5))
(*(void (**)(void))(**(DWORD * *)v13 + 20))();
v13 += 4;
--v4;
} while (v4);
}
}
}
//----- (01014BF9) --------------------------------------------------------
signed int pb_frame@<eax > (int a1@<ebx > , int a2)
{
double v2; // st7
char* v3; // eax
float v5; // [esp+10h] [ebp-4h]
if (a2 > 100)
a2 = 100;
v5 = (double)a2 * 0.001;
if (!pb_mode_countdown(a2))
{
time_next = time_now + v5;
pb_timed_frame(time_now, v5, 1);
time_now = time_next;
time_ticks += a2;
if (nudged_left || nudged_right || nudged_up)
{
nudge_count = v5 * 4.0 + nudge_count;
}
else
{
v2 = nudge_count - v5;
if (v2 <= 0.0)
v2 = 0.0;
nudge_count = v2;
}
timer_check();
render_update();
score_update(a1, *(int**)((char*)MainTable + 50));
if (!*(DWORD*)((char*)MainTable + 370))
{
if (nudge_count > 0.5)
{
v3 = get_rc_string(25, 0);
TTextBox::Display(InfoTextBox, a1, v3, 2.0);
}
if (nudge_count > 1.0)
TPinballTable::tilt(MainTable, a1, time_now);
}
}
return 1;
}
// 1024F84: using guessed type int time_ticks;
// 1025630: using guessed type float time_now;
// 1025634: using guessed type float time_next;
// 102563C: using guessed type int nudged_left;
// 1025640: using guessed type int nudged_right;
// 1025644: using guessed type int nudged_up;
// 102564C: using guessed type float nudge_count;
//----- (01014D3D) --------------------------------------------------------
void pb_firsttime_setup()
{
render_blit = 0;
render_update();
render_blit = 1;
}
// 1024754: using guessed type int render_blit;
//----- (01014D59) --------------------------------------------------------
struct TPinballTable* pb_tilt_no_more@<eax > (int a1@<ebx > )
{
struct TPinballTable* result; // eax
if (*(DWORD*)((char*)MainTable + 370))
TTextBox::Clear(InfoTextBox, a1);
result = MainTable;
*(DWORD*)((char*)MainTable + 370) = 0;
nudge_count = -2.0;
return result;
}
// 102564C: using guessed type float nudge_count;
//----- (01014D8E) --------------------------------------------------------
void pb_ballset(signed int a1, signed int a2)
{
int v2; // esi
v2 = *(DWORD*)(*(DWORD*)((char*)MainTable + 262) + 8);
*(float*)(v2 + 54) = (double)a1 * 30.0;
*(float*)(v2 + 58) = (double)a2 * 30.0;
*(float*)(v2 + 66) = normalize_2d((float*)(v2 + 54));
}
//----- (01014DCF) --------------------------------------------------------
void nudge(float a1, float a2)
{
struct TPinballTable* v2; // eax
int v3; // ecx
int v4; // edx
int v5; // ebx
int v6; // esi
double v7; // st7
double v8; // st7
int v9; // ST18_4
int v10; // ST14_4
int v11; // ST08_4
double v12; // st7
float v13; // [esp+20h] [ebp-10h]
float v14; // [esp+24h] [ebp-Ch]
int v15; // [esp+2Ch] [ebp-4h]
v2 = MainTable;
v3 = *(DWORD*)((char*)MainTable + 262);
v4 = *(DWORD*)(v3 + 4);
v13 = a1 * 0.5;
v5 = v3 + 8;
v14 = a2 * 0.5;
if (v4 > 0)
{
v15 = v4;
do
{
v6 = *(DWORD*)v5;
if (*(_BYTE*)(*(DWORD*)v5 + 5) && !*(DWORD*)(v6 + 106))
{
*(float*)(v6 + 54) = *(float*)(v6 + 54) * *(float*)(v6 + 66);
*(float*)(v6 + 58) = *(float*)(v6 + 58) * *(float*)(v6 + 66);
vector_add((struct vector_type*)(v6 + 54), (struct vector_type*) & v13);
*(float*)(v6 + 66) = normalize_2d((float*)(v6 + 54));
if (0.0 == *(float*)(v6 + 54))
v7 = 1000000000.0;
else
v7 = 1.0 / *(float*)(v6 + 54);
*(float*)(v6 + 82) = v7;
if (0.0 == *(float*)(v6 + 58))
v8 = 1000000000.0;
else
v8 = 1.0 / *(float*)(v6 + 58);
*(float*)(v6 + 86) = v8;
v2 = MainTable;
}
v5 += 4;
--v15;
} while (v15);
}
v9 = *(DWORD*)((char*)v2 + 246);
v10 = *(DWORD*)((char*)v2 + 242);
v11 = (signed __int64)_floor(0.5 - a2);
v12 = _floor(a1 + 0.5);
render_shift((signed __int64)v12, v11, 0, 0, v10, v9);
}
//----- (01014EEE) --------------------------------------------------------
void un_nudge_left(int a1, void* a2)
{
if (nudged_left)
nudge(2.0, -1.0);
nudged_left = 0;
}
// 102563C: using guessed type int nudged_left;
//----- (01014F20) --------------------------------------------------------
void un_nudge_right(int a1, void* a2)
{
if (nudged_right)
nudge(-2.0, -1.0);
nudged_right = 0;
}
// 1025640: using guessed type int nudged_right;
//----- (01014F52) --------------------------------------------------------
void nudge_left()
{
nudge(-2.0, 1.0);
if (nudge_timer)
timer_kill(nudge_timer);
nudge_timer = timer_set(0.40000001, 0, (int)un_nudge_left);
nudged_left = 1;
}
// 102563C: using guessed type int nudged_left;
// 1025648: using guessed type int nudge_timer;
//----- (01014FA4) --------------------------------------------------------
void nudge_right()
{
nudge(2.0, 1.0);
if (nudge_timer)
timer_kill(nudge_timer);
nudge_timer = timer_set(0.40000001, 0, (int)un_nudge_right);
nudged_right = 1;
}
// 1025640: using guessed type int nudged_right;
// 1025648: using guessed type int nudge_timer;
//----- (01014FF6) --------------------------------------------------------
void un_nudge_up(int a1, void* a2)
{
if (nudged_up)
nudge(0.0, -1.0);
nudged_up = 0;
}
// 1025644: using guessed type int nudged_up;
//----- (01015024) --------------------------------------------------------
void nudge_up()
{
nudge(0.0, 1.0);
if (nudge_timer)
timer_kill(nudge_timer);
nudge_timer = timer_set(0.40000001, 0, (int)un_nudge_up);
nudged_up = 1;
}
// 1025644: using guessed type int nudged_up;
// 1025648: using guessed type int nudge_timer;
//----- (01015072) --------------------------------------------------------
void pb_keydown(HKEY a1)
{
CHAR* v1; // eax
int v2; // eax
int v3; // edx
int v4; // esi
int v5; // ecx
TBall* v6; // eax
TBall* v7; // eax
int v8; // ecx
CHAR String1; // [esp+Ch] [ebp-E0h]
char Dest; // [esp+D4h] [ebp-18h]
if (single_step || dword_1025570)
return;
if (dword_1025568 != 1)
{
pb_mode_countdown(-1);
return;
}
pbctrl_bdoor_controller(0, (int)a1);
if (a1 == dword_1028238)
{
(**(void(* **)(signed int, DWORD))MainTable)(1000, LODWORD(time_now));
return;
}
if (a1 == dword_102823C)
{
(**(void(* **)(signed int, DWORD))MainTable)(1002, LODWORD(time_now));
}
else
{
if (a1 == dword_1028240)
{
(**(void(* **)(signed int, DWORD))MainTable)(1004, LODWORD(time_now));
return;
}
if (a1 == dword_1028244)
{
if (!*(DWORD*)((char*)MainTable + 370))
nudge_right();
return;
}
if (a1 == dword_1028248)
{
if (!*(DWORD*)((char*)MainTable + 370))
nudge_left();
return;
}
if (a1 == dword_102824C)
{
if (!*(DWORD*)((char*)MainTable + 370))
nudge_up();
return;
}
}
if (cheat_mode)
{
if (a1 == (HKEY)66)
{
v2 = *(DWORD*)((char*)MainTable + 262);
v3 = *(DWORD*)(v2 + 4);
v4 = 0;
v5 = v2 + 8;
if (v3 <= 0)
{
LABEL_36:
v7 = (TBall*)TPinballComponent::operator new(0x16Au);
if (v7)
v6 = TBall::TBall(v7, MainTable);
else
v6 = 0;
}
else
{
while (1)
{
v6 = *(TBall * *)v5;
if (!*(_BYTE*)(*(DWORD*)v5 + 5))
break;
++v4;
v5 += 4;
if (v4 >= v3)
goto LABEL_36;
}
}
v8 = *(DWORD*)((char*)v6 + 154);
*(float*)((char*)v6 + 42) = 1.0;
*((_BYTE*)v6 + 5) = 1;
*(DWORD*)((char*)v6 + 50) = v8;
*(float*)((char*)v6 + 46) = 1.0;
*(float*)((char*)v6 + 62) = 0.0;
*(float*)((char*)v6 + 58) = 0.0;
*(float*)((char*)v6 + 54) = 0.0;
}
else if (a1 == (HKEY)72)
{
v1 = get_rc_string(26, 0);
lstrcpyA(&String1, v1);
show_and_set_high_score_dialog(byte_1025578, 1000000000, 1, &String1);
}
else if (a1 == (HKEY)77)
{
_sprintf(&Dest, "%ld", memory_use_total);
MessageBoxA(hwnd_frame, &Dest, "Mem:", 0x2000u);
}
else if (a1 == (HKEY)82)
{
cheat_bump_rank(0);
}
else if (a1 == (HKEY)122)
{
gdrv_get_focus();
}
else if ((HKEY)((char*)a1 - 122) == (HKEY)1)
{
(*(void (**)(void))(*(DWORD*)MainTable + 4))();
}
}
}
// 1024F00: using guessed type int memory_use_total;
// 1024FD8: using guessed type int single_step;
// 1024FF8: using guessed type int cheat_mode;
// 1025568: using guessed type int dword_1025568;
// 1025570: using guessed type int dword_1025570;
// 1025630: using guessed type float time_now;
//----- (010152E4) --------------------------------------------------------
void pb_keyup(HKEY a1)
{
if (dword_1025568 == 1 && !single_step && !dword_1025570)
{
if (a1 == dword_1028238)
{
(**(void(* **)(signed int, DWORD))MainTable)(1001, LODWORD(time_now));
}
else if (a1 == dword_102823C)
{
(**(void(* **)(signed int, DWORD))MainTable)(1003, LODWORD(time_now));
}
else if (a1 == dword_1028240)
{
(**(void(* **)(signed int, DWORD))MainTable)(1005, LODWORD(time_now));
}
else if (a1 == dword_1028244)
{
un_nudge_right(0, 0);
}
else if (a1 == dword_1028248)
{
un_nudge_left(0, 0);
}
else if (a1 == dword_102824C)
{
un_nudge_up(0, 0);
}
}
}
// 1024FD8: using guessed type int single_step;
// 1025568: using guessed type int dword_1025568;
// 1025570: using guessed type int dword_1025570;
// 1025630: using guessed type float time_now;
//----- (010153AE) --------------------------------------------------------
int pb_replay_level(int a1)
{
float v1; // ST04_4
dword_1025570 = a1;
pb_mode_change(1);
if (phkResult)
midi_play_pb_theme(0);
v1 = (double)(signed int)dword_1028234;
return (**(int(* **)(signed int, DWORD))MainTable)(1014, LODWORD(v1));
}
// 1025570: using guessed type int dword_1025570;
//----- (010153F4) --------------------------------------------------------
INT_PTR pb_high_scores()
{
return show_high_score_dialog(byte_1025578);
}
//----- (01015404) --------------------------------------------------------
DWORD* pb_window_size(DWORD* a1, DWORD* a2)
{
DWORD* result; // eax
*a1 = 600;
result = a2;
*a2 = 416;
return result;
}
//----- (01015424) --------------------------------------------------------
int pb_init()
{
int result; // eax
int v1; // eax
signed int* v2; // ebx
DWORD* v3; // edi
DWORD* v4; // esi
char* v5; // eax
signed int v6; // ecx
double v7; // st7
double v8; // st5
int v9; // ST1C_4
int v10; // ST18_4
int v11; // ST14_4
int* v12; // esi
TPinballTable* v13; // eax
double v14; // st7
char v15; // [esp+1Ch] [ebp-294h]
float v16; // [esp+4Ch] [ebp-264h]
float v17; // [esp+50h] [ebp-260h]
CHAR String1; // [esp+54h] [ebp-25Ch]
CHAR Filename; // [esp+180h] [ebp-130h]
++memory_critical_allocation;
lstrcpyA(&String1, byte_102543C);
make_path_name(&Filename, &String1, 0x12Cu);
v17 = 0.0;
pb_record_table = (int)partman_load_records(&Filename);
get_rc_int(158, (int*)& v17);
if (v17 != 0.0)
score_load_msg_font("pbmsg_ft");
if (!pb_record_table)
return pb_record_table + 1;
v1 = partman_field_labeled(pb_record_table, "background", 5);
gdrv_display_palette(v1);
v2 = (signed int*)partman_field_labeled(pb_record_table, "table_size", 10);
v3 = (DWORD*)partman_field_labeled(pb_record_table, "background", 1);
v4 = (DWORD*)partman_field_labeled(pb_record_table, "camera_info", 11);
if (v4)
{
v5 = &v15;
LODWORD(v17) = 3;
do
{
v6 = 4;
do
{
*(DWORD*)v5 = *v4;
++v4;
v5 += 4;
--v6;
} while (v6);
--LODWORD(v17);
} while (v17 != 0.0);
v7 = *(float*)v4;
LODWORD(v17) = v2[1];
v8 = (double)SLODWORD(v17);
LODWORD(v17) = *v2;
*(float*)& v9 = v8 * 0.5;
*(float*)& v10 = 0.5 * (double)SLODWORD(v17);
*(float*)& v11 = v7;
proj_init((int)& v15, v11, v10, v9);
v12 = v4 + 1;
v16 = *(float*)v12;
v17 = *((float*)v12 + 1);
}
render_init(0, v16, v17, *v2, v2[1]);
gdrv_copy_bitmap(&vscreen, v3[3], v3[4], *(DWORD*)((char*)v3 + 29), *(DWORD*)((char*)v3 + 33), v3, 0, 0);
gdrv_destroy_bitmap((int)v3);
loader_loadfrom((WORD*)pb_record_table);
if (play_midi_music)
pb_mode_change(1);
else
pb_mode_change(3);
time_ticks = 0;
timer_init(150);
score_init();
v13 = (TPinballTable*)TPinballComponent::operator new(0x176u);
if (v13)
MainTable = TPinballTable::TPinballTable(v13);
else
MainTable = 0;
high_score_read((int)byte_1025578, (int)& pb_state);
v14 = *(float*)(*(DWORD*)(*(DWORD*)((char*)MainTable + 262) + 8) + 154);
--memory_critical_allocation;
result = 0;
ball_speed_limit = v14 * 200.0;
return result;
}
// 1024F04: using guessed type int memory_critical_allocation;
// 1024F84: using guessed type int time_ticks;
// 10253D0: using guessed type float ball_speed_limit;
// 102556C: using guessed type int play_midi_music;
//----- (0101566E) --------------------------------------------------------
int pb_uninit()
{
score_unload_msg_font();
loader_unload();
partman_unload_records((WORD*)pb_record_table);
high_score_write(byte_1025578, (int)& pb_state);
if (MainTable)
(*(void(* *)(signed int))(*(DWORD*)MainTable + 16))(1);
MainTable = 0;
gdrv_get_focus();
timer_uninit();
render_uninit();
return 0;
}
//----- (010156C1) --------------------------------------------------------
int pb_loose_focus()
{
int result; // eax
if (MainTable)
result = (**(int(* **)(signed int, DWORD))MainTable)(1010, LODWORD(time_now));
return result;
}
// 1025630: using guessed type float time_now;
//----- (010156E4) --------------------------------------------------------
void pb_pause_continue(int a1@<ebx > )
{
char* v1; // eax
char* v2; // eax
float v3; // [esp+8h] [ebp-8h]
single_step = single_step == 0;
TTextBox::Clear(InfoTextBox, a1);
TTextBox::Clear(MissTextBox, a1);
if (single_step)
{
if (MainTable)
(**(void(* **)(signed int, DWORD))MainTable)(1008, LODWORD(time_now));
v1 = get_rc_string(22, 0);
TTextBox::Display(InfoTextBox, a1, v1, -1.0);
midi_music_stop();
}
else
{
if (MainTable)
(**(void(* **)(signed int, DWORD))MainTable)(1009, 0.0);
if (!dword_1025570)
{
if (dword_1025568 == 2)
{
v3 = -1.0;
v2 = get_rc_string(24, 0);
}
else
{
v3 = 5.0;
v2 = get_rc_string(23, 0);
}
TTextBox::Display(InfoTextBox, a1, v2, v3);
}
if (phkResult && !single_step)
midi_play_pb_theme(0);
}
}
// 1024FD8: using guessed type int single_step;
// 1025568: using guessed type int dword_1025568;
// 1025570: using guessed type int dword_1025570;
// 1025630: using guessed type float time_now;
//----- (010157C3) --------------------------------------------------------
int pb_launch_ball()
{
return (***(int(* ***)(signed int, DWORD))((char*)MainTable + 222))(1017, 0.0);
}
//----- (010157E3) --------------------------------------------------------
int pb_reset_table()
{
int result; // eax
if (MainTable)
result = (**(int(* **)(signed int, DWORD))MainTable)(1024, 0.0);
return result;
}
//----- (01015802) --------------------------------------------------------
void pb_toggle_demo(int a1@<ebx > )
{
char* v1; // eax
if (dword_1025570)
{
dword_1025570 = 0;
(**(void(* **)(signed int, DWORD))MainTable)(1024, 0.0);
pb_mode_change(2);
TTextBox::Clear(MissTextBox, a1);
v1 = get_rc_string(24, 0);
TTextBox::Display(InfoTextBox, a1, v1, -1.0);
}
else
{
pb_replay_level(1);
}
}
// 1025570: using guessed type int dword_1025570;