-
Notifications
You must be signed in to change notification settings - Fork 8
/
plhud.asm
1010 lines (984 loc) · 24.3 KB
/
plhud.asm
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
;; _ASM_HOOKADDR: 0058EAF1
; _ASM_HOOKADDR: 0058FBC5
; _ASM_JUMP: true
; _ASM_CORRECT_OFFSETS: true
; _ASM_COMMENTS: false
; _ASM_GCC: S:\broftware\perl\c\bin\gcc.exe
; _ASM_OBJDUMP: S:\broftware\perl\c\bin\objdump.exe
; _ASM_TARGETFILE: plhud-asm.txt
; _ASM_PREPROCONLY: false
; _ASM_LF: true
; hook on 0058EAF0 _DrawHud (0058EAF1 in asmtool)
; _DEFINE:NULL=0
; _DEFINE:__drawText=0x71A700
; _DEFINE:CText__SetBorderEffectRGBA=0x719510
; _DEFINE:CText__SetFont=0x719490
; _DEFINE:CText__SetTextAlignment=0x719610
; _DEFINE:CText__SetTextBackground=0x7195C0
; _DEFINE:CText__SetTextColour=0x719430
; _DEFINE:CText__SetTextLetterSize=0x719380
; _DEFINE:CText__SetTextOutline=0x719590
; _DEFINE:CText__SetTextUseProportionalValues=0x7195B0
; _DEFINE:dummy_7194F0=0x7194F0
; _DEFINE:CText__SetWrappingCoordinateForLeftAlignedText=0x7194D0
; _DEFINE:getPlayerCoords=0x56E010
; _DEFINE:_menutxt=_var01
; _DEFINE:_options=_var02
; _DEFINE:_menuidx=_var03
; _DEFINE:_viewdis=_var04
; _DEFINE:_sprintf=_var05
; _DEFINE:_runways=_var06
; _DEFINE:_espcolr=_var07
; _DEFINE:_lastrdr=_var08
; _DEFINE:MAXMENUIDX=3
; _DEFINE:MENUITEMS=MAXMENUIDX+1
; _DEFINE:FONT_SIZE_X=0x3f000000 ; 0.5
; _DEFINE:FONT_SIZE_Y=0x3e8ccccd ; 0.275
; _DEFINE:MENU_POS_X=0x3e800000 ; 0.25
; _DEFINE:MENU_POS_Y=0x3ee66666 ; 0.45
; !!MENUOFFSET
; _DEFINE:MENU_OFFSET_SMARTMODE_ONOFF=0xAA ; N char
; _DEFINE:MENU_OFFSET_VIEWDISTANCE=0xC3 ; _ char
; _DEFINE:MENU_OFFSET_FIRST_OPTION=0x7E ; > char
; _DEFINE:MENU_OFFSET_OPTION_LINE_LENGTH=0x1A
; _DEFINE:MENU_OFFSET_COLOR=0xD5 ; P char
; _DEFINE:MENU_OFFSET_RUNWAYCOUNT=0xED ; _ char
; _DEFINE:MENU_OFFSET_BRANDING=0xFB ; _ char
; _DEFINE:OPTION_BIT_ENABLED=0x00000001
; _DEFINE:OPTION_BIT_SMART_MODE=0x00000002
; _DEFINE:OPTION_BIT_KEY_F10=0x00000004
; _DEFINE:OPTION_BIT_KEY_RARR=0x00000008
; _DEFINE:OPTION_BIT_KEY_DARR=0x00000010
; _DEFINE:OPTION_BIT_KEY_UARR=0x00000020
; _DEFINE:OPTION_BIT_KEY_LARR=0x00000040
; _DEFINE:OPTION_BIT_ALL_KEYS=0x0000007C
; _DEFINE:OPTION_BIT_ALL_KEYS_NOT=0xFFFFFF83
; _DEFINE:OPTION_BIT_ARR_KEYS=0x00000078
; _DEFINE:OPTION_BIT_ARR_KEYS_NOT=0xFFFFFF87
; _DEFINE:OPTION_BIT_ARR_KEYS_UPDOWN=0x00000030
; _DEFINE:OPTION_BIT_SHOW_MENU=0x00000080
; _DEFINE:OPTION_BIT_SHOW_MENU_NOT=0xFFFFFF7F
; _DEFINE:OPTION_BIT_RUNONCE=0x00000100
; _DEFINE:OPTION_BIT_RUNONCE_NOT=0xFFFFFEFF
; _DEFINE:OPTION_BIT_RESULT_[REDACTED]=0x00000200
; _DEFINE:_airstrip_location=0xBA8300
entry:
test dword ptr [_options], OPTION_BIT_KEY_F10
jz no_enable_keypress
xor dword ptr [_options], OPTION_BIT_ENABLED
and dword ptr [_options], OPTION_BIT_ALL_KEYS_NOT
or dword ptr [_options], OPTION_BIT_SHOW_MENU
mov dword ptr [_lastrdr], 0
mov dword ptr [_airstrip_location], 3
call fixairstrip
no_enable_keypress:
test dword ptr [_options], OPTION_BIT_ENABLED
jz _exit
test dword ptr [_options], OPTION_BIT_RESULT_[REDACTED]
jnz _exit
main:
push edi
push ebx
push edx
push ecx
; don't push eax, is overwritten anyways
; run once
test dword ptr [_options], OPTION_BIT_RUNONCE
jz skiprunonce
and dword ptr [_options], OPTION_BIT_RUNONCE_NOT
call runonce
skiprunonce:
; handle menu keys if menu is shown
test dword ptr [_options], OPTION_BIT_SHOW_MENU
jnz menunav
menunav_ret:
call breakairstrip
; set textdraw stuff for runways
push 0 ; a2
push 0 ; a1
call CText__SetTextBackground
;add esp, 0x8
;;push 0
call dummy_7194F0
;;add esp, 0x4
;;push 0 ; 0 center 1 left 2 right
call CText__SetTextAlignment
;;add esp, 0x4
push FONT_SIZE_X ; y
push FONT_SIZE_Y ; x
call hud2screen
call CText__SetTextLetterSize ; flip x/y when alignment is center
;add esp, 0x8
push 1
call CText__SetTextUseProportionalValues
;add esp, 0x4
;;push 1
call CText__SetFont
;;add esp, 0x4
;;push 1
call CText__SetTextOutline
;;add esp, 0x4
push 0xFF000000 ; ARGB
call CText__SetBorderEffectRGBA
;add esp, 0x4
push [_espcolr] ; ARGB
call argb2abgr ; AGBR
or byte ptr [esp+0x3], 0xFF
call CText__SetTextColour
;add esp, 0x4
add esp, 0x1C
; smart mode
; >>>>>>> get checkpoint
test dword ptr [_options], OPTION_BIT_SMART_MODE
jz dont_get_checkpoint
mov ebx, 0xC7F158
smart_next_checkpoint:
cmp byte ptr [ebx+0x2], 1
je smart_got_checkpoint
add ebx, 0x38
cmp ebx, 0xC7F858
jae exit ; fix radar first?
jmp smart_next_checkpoint
smart_got_checkpoint:
push [ebx+0x10] ; checkpoint x
push [ebx+0x14] ; checkpoint y
; <<<<<<< get checkpoint
dont_get_checkpoint:
push 0 ; viewdistance^2 (int)
fild dword ptr [_viewdis]
fmul ST(0), ST(0)
fistp dword ptr [esp]
push 0x5F5E1000 ; closest distance (for radar) 1.6B (int)
push 0xFFFFFFFF ; ptr to closest runway (for radar)
sub esp, 0xC ; player coords
mov eax, esp
push 0
push eax
call getPlayerCoords
add esp, 0x8
;
mov ebx, _runways
runwayloop:
; end check
mov eax, dword ptr [ebx]
test eax, eax
jz runwayloop@end
; calculate distance (into eax), check later
push 0x40000000 ; 2.0
fld dword ptr [ebx] ; rnwy x 1
fadd dword ptr [ebx+0xC] ; rnwy x 2
fld dword ptr [esp]
fdivp
fld ST(0) ; save for later
fsub dword ptr [esp+0x4] ; player x
fmul ST(0), ST(0)
fld dword ptr [ebx+0x4] ; rnwy y 2
fadd dword ptr [ebx+0x10] ; rnwy y 2
fld dword ptr [esp]
fdivp
fld ST(0) ; save for later
fsub dword ptr [esp+0x8] ; player y
fmul ST(0), ST(0)
fxch ST(1)
fxch ST(2)
faddp
fistp dword ptr [esp]
pop eax
; smart mode check
test dword ptr [_options], OPTION_BIT_SMART_MODE
jz runwayloop@nosmart
; checkpoint to middle < length * 1.4
fld dword ptr [ebx+0xC] ; rnwy x 2
fsub dword ptr [ebx] ; rnwy x 1
fmul ST(0)
fld dword ptr [ebx+0x10] ; rnwy y 2
fsub dword ptr [ebx+0x4] ; rnwy y 1
fmul ST(0)
faddp
push 0x3fb33333 ; 1.4
fmul dword ptr [esp]
add esp, 0x4
fld ST(2) ; mx
fsub dword ptr [esp+0x1C] ; chkpnt x
fmul ST(0)
fld ST(2) ; my
fsub dword ptr [esp+0x18] ; chkpnt y
fmul ST(0)
faddp
fcomip ST, ST(1)
fstp ST(0) ; dist b
ja runwayloop@clean@next
runwayloop@nosmart:
; radar
cmp dword ptr [esp+0x10], eax
jl runwayloop@skipradar
mov dword ptr [esp+0xC], ebx
mov dword ptr [esp+0x10], eax
runwayloop@skipradar:
; real distance check
cmp eax, dword ptr [esp+0x14]
jg runwayloop@clean@next
; esp
call dorunway
runwayloop@clean@next:
fstp ST(0) ; my
fstp ST(0) ; mx
runwayloop@next:
movzx eax, byte ptr [ebx+0x18]
add ebx, eax
add ebx, 0x19
jmp runwayloop
runwayloop@end:
; radar
mov ebx, dword ptr [esp+0xC]
cmp ebx, 0xFFFFFFFF
je runwayloop@noradar
fld dword ptr [ebx+0x4] ; y1
fadd dword ptr [ebx+0x10] ; y2
fld dword ptr [ebx] ; x1
fadd dword ptr [ebx+0xC] ; x2
fld1
fadd ST(0), ST(0)
fdiv ST(2), ST(0)
fdivp
fstp dword ptr [0x8D06E0] ; mx
fstp dword ptr [0x8D06E0+0x4] ; my
push eax
sub esp, 0x8
fld dword ptr [ebx+0xC] ; x2
fsub dword ptr [ebx] ; x1
fst dword ptr [esp+0x4] ; dx
fld dword ptr [ebx+0x10] ; y2
fsub dword ptr [ebx+0x4] ; y1
fst dword ptr [esp] ; dy
; _DEFINE:CGeneral__getATanOfXY=0x53CC70
; ^ modifies eax
call CGeneral__getATanOfXY
mov dword ptr [esp], 0x43340000 ; 180.0
fmul dword ptr [esp]
fldpi
fdivp
mov dword ptr [esp], 0x42b40000 ; 90.0
fadd dword ptr [esp]
fstp dword ptr [0x8D06E0+0x8] ; ang
fmul ST(0), ST(0)
fxch
fmul ST(0), ST(0)
faddp
fsqrt
mov dword ptr [esp], 0x43960000 ; 300.0
fadd dword ptr [esp]
fstp dword ptr [0x8D06E0+0xC] ; radius
add esp, 0x8
pop eax
; force radar update if needed
cmp dword ptr [_lastrdr], ebx
je runwayloop@noradar
mov dword ptr [_airstrip_location], 1
mov dword ptr [_lastrdr], ebx
runwayloop@noradar:
; cleanup & exit
add esp, 0x18 ; 0xC player coords + 0xC viewdist + radar stuff
test dword ptr [_options], OPTION_BIT_SMART_MODE
jz exit
add esp, 0x8
exit:
; show menu if needed
test dword ptr [_options], OPTION_BIT_SHOW_MENU
jnz menushow
menushow_ret:
pop ecx
pop edx
pop ebx
pop edi
_exit:
;sub esp, 0x1A0
;jmp 0x58EAF6
; _DEFINE:_menu.EnableHudInOptions=0xBA6769
mov al, _menu.EnableHudInOptions
jmp 0x58FBC9
; modifies eax, edx
menunav:
test dword ptr [_options], OPTION_BIT_ARR_KEYS
jz menunav_ret
test dword ptr [_options], OPTION_BIT_ARR_KEYS_UPDOWN
jz menu_rl_nav
; >>> updown nav
mov dl, 0x5F ; "_"
call menu_write_mark
test dword ptr [_options], OPTION_BIT_KEY_UARR
jz menu_keys_down
sub byte ptr [_menuidx], 1
mov al, MAXMENUIDX
jmp menu_idx_boundscheck
menu_keys_down:
add byte ptr [_menuidx], 1
mov al, 0
menu_idx_boundscheck:
cmp byte ptr [_menuidx], MENUITEMS
jb menu_update_idx
mov byte ptr [_menuidx], al
menu_update_idx:
mov dl, 0x3E ; ">"
call menu_write_mark
; <<< updown nav
menu_show_clearkeys:
and dword ptr [_options], OPTION_BIT_ARR_KEYS_NOT
jmp menunav_ret
menu_rl_nav:
mov eax, [_menuidx]
imul eax, 4
add eax, __BASEADDR
mov eax, [eax+menujmptable]
add eax, __BASEADDR
jmp eax
menu_rl_continue:
xor dword ptr [_options], OPTION_BIT_SHOW_MENU
and dword ptr [_options], OPTION_BIT_ARR_KEYS_NOT
jmp menunav_ret
menu_rl_smartmode:
xor dword ptr [_options], OPTION_BIT_SMART_MODE
mov eax, _menutxt
add eax, MENU_OFFSET_SMARTMODE_ONOFF
lea edx, [eax-0x3]
test dword ptr [_options], OPTION_BIT_SMART_MODE
jz menu_rl_smartmode@off
mov word ptr [eax], 0x5F4E ; "_N"
mov byte ptr [edx], 0x67 ; "g"
jmp menu_show_clearkeys
menu_rl_smartmode@off:
mov word ptr [eax], 0x4646 ; "FF"
mov byte ptr [edx], 0x72 ; "r"
jmp menu_show_clearkeys
menu_rl_viewdistance:
; _DEFINE:VIEWDISTANCEDELTA=0x01F4FE0C ; 500/-500
; _DEFINE:VIEWDISTANCEMAX=0x7530 ; 30000
; _DEFINE:VIEWDISTANCEDEFAULT=0x5DC ; 1500
mov eax, VIEWDISTANCEDELTA
test dword ptr [_options], OPTION_BIT_KEY_RARR
jz menu_rl_viewdistance@decrease
shr eax, 16
menu_rl_viewdistance@decrease:
add word ptr [_viewdis], ax
cmp word ptr [_viewdis], VIEWDISTANCEMAX
jb menu_rl_viewdistance@updatetxt
mov word ptr [_viewdis], VIEWDISTANCEDEFAULT
menu_rl_viewdistance@updatetxt:
sub esp, 0x8
mov eax, esp
push 0x643525 ; %5d\0
mov edx, esp
push [_viewdis] ; ...
push edx ; pFormat
push eax ; pResult
call [_sprintf] ; _sprintf
add esp, 0x10
mov edx, _menutxt
pop dword ptr [edx+MENU_OFFSET_VIEWDISTANCE]
pop eax
mov byte ptr [edx+MENU_OFFSET_VIEWDISTANCE+0x4], al
jmp menu_show_clearkeys
menu_rl_color:
mov eax, 0x8
test dword ptr [_options], OPTION_BIT_KEY_LARR
jz menu_rl_color@next
neg eax
menu_rl_color@next:
push ecx
mov edx, __BASEADDR
sub edx, 0x8
menu_rl_color@loop:
add edx, 0x8
mov ecx, dword ptr [edx+espcolors]
cmp ecx, dword ptr [_espcolr]
jne menu_rl_color@loop
add edx, eax
mov ecx, dword ptr [edx+espcolors]
mov dword ptr [_espcolr], ecx
mov ecx, dword ptr [edx+espcolors+0x4]
mov edx, _menutxt
mov dword ptr [edx+MENU_OFFSET_COLOR], ecx
pop ecx
jmp menu_show_clearkeys
menushow:
; >>>>>>> menu text
push 0 ; a2
push 0 ; a1
call CText__SetTextBackground
;add esp, 0x8
;;push 0
call dummy_7194F0
;;add esp, 0x4
push FONT_SIZE_X ; y
push FONT_SIZE_Y ; x
call hud2screen
call CText__SetTextLetterSize ; flip x/y when alignment is center
;add esp, 0x8
push 1
call CText__SetTextUseProportionalValues
;add esp, 0x4
;;push 1
call CText__SetFont
;;add esp, 0x4
;;push 1 ; 0 center 1 left 2 right
call CText__SetTextAlignment
;;add esp, 0x4
;;push 1
call CText__SetTextOutline
;;add esp, 0x4
push 0xFF000000 ; ABGR
call CText__SetBorderEffectRGBA
;add esp, 0x4
push 0xFFFFFFFF; ABGR
call CText__SetTextColour
;add esp, 0x4
push 0x461c4000 ; 10000.0
call CText__SetWrappingCoordinateForLeftAlignedText
;add esp, 0x4
push _menutxt ; str
push MENU_POS_Y ; y
push MENU_POS_X ; x
call norm2screen
call __drawText
;add esp, 0xC
add esp, 0x2C
; <<<<<<< menu text
jmp menushow_ret
;menu_write_mark
menu_write_mark:
mov eax, [_menuidx]
imul eax, MENU_OFFSET_OPTION_LINE_LENGTH
add eax, _menutxt
mov byte ptr [eax+MENU_OFFSET_FIRST_OPTION], dl
ret
; ebx: ptr to runway
; eax: distance^2 (int)
; nothing interesting in stack
; rnwy middle y, x in fpu stack
dorunway:
; reserve a buffer for the airport name + distance
; _DEFINE:ESP_EXTRA_BUFFER_LENGTH=0xE ; ~n~2400000000m\0
push edx
mov dl, [ebx+0x18]
movzx edx, dl
add edx, ESP_EXTRA_BUFFER_LENGTH
sub esp, edx
; project middle first and see if it's on screen
sub esp, 0xC
fstp dword ptr [esp+0x4] ; my
fstp dword ptr [esp] ; mx
fld dword ptr [ebx+0x8] ; rnwy z1
fadd dword ptr [ebx+0x14] ; rnwy z2
push 0x40000000 ; 2.0
fdiv dword ptr [esp]
add esp, 0x4
fstp dword ptr [esp+0x8] ; mz
;project
call world2screen
cmp dword ptr [esp+0x8], 0 ; mz'
jl dorunway@notonscreen
; prepare the name and text in stack (used just before ret)
push 0
push 0x6D69257E ; mi%~
push 0x6E7E7325 ; n~s%
push eax
fild dword ptr [esp]
fsqrt
fistp dword ptr [esp] ; ... (dist)
lea eax, [ebx+0x19]
push eax ; ... (name)
lea eax, [esp+0x8]
push eax ; pFormat
lea eax, [esp+0x24]
mov dword ptr [esp+0x20], eax ; str (for __drawText; see below)
push eax ; pResult
call [_sprintf] ; _sprintf
add esp, 0x1C
; param y already in place by world2screen
; param x already in place by world2screen
;
; draw stuff
; get 4 points
; _DEFINE:CGeneral__getATanOfXY=0x53CC70
; ^ modifies eax
sub esp, 0x8
fld dword ptr [ebx+0xC] ; rnwy x2
fsub dword ptr [ebx] ; rnwy x1
fstp dword ptr [esp+0x4] ; dx
fld dword ptr [ebx+0x10] ; rnwy y2
fsub dword ptr [ebx+0x4] ; rnwy y1
fstp dword ptr [esp] ; dy
call CGeneral__getATanOfXY
fld ST(0)
fldpi
fld1
fadd ST(0)
fdivp
fsub ST(2), ST(0)
faddp
; ST(1) angle-90deg
; ST(0) angle+90deg
fsincos
fxch ST(2)
fsincos
; ST(3) cos(angle+90deg)
; ST(2) sin(angle+90deg)
; ST(1) sin(angle-90deg)
; ST(0) cos(angle-90deg)
mov dword ptr [esp], 0x41980000 ; 19.0
fld dword ptr[esp]
add esp, 0x8
fmul ST(4), ST(0)
fmul ST(3), ST(0)
fmul ST(2), ST(0)
fmulp
;
; 3
; / 4
; /
; /
; 1 /
; 2
;
; tri strip
;
; 3|\\``|4
; | \\ |
; 1|..\\|2
;
; _DEFINE:_ZBufferNear=0x00000000
; _DEFINE:_FogPlane=0x40555556 ; 3.333333492
push edx
xor edx, edx
; p1
inc edx
push 0 ; v
push 0x3F800000 ; u 1.0
push [_espcolr] ; argb
push _FogPlane ; rwh
push dword ptr [ebx+0x8] ; z1 z1
sub esp, 0x8
fld dword ptr [ebx+0x4] ; y1
fsub ST(0), ST(4) ; y1 - cos(angle+90deg)
fstp dword ptr [esp+0x4] ; y1 y1
fld dword ptr [ebx] ; x1
fsub ST(0), ST(3) ; x1 - sin(angle+90deg)
fstp dword ptr [esp] ; x1 x1
call world2screen
cmp dword ptr [esp+0x8], 1
mov dword ptr [esp+0x8], _ZBufferNear
jl dorunway@skipesp
; p2
inc edx
push 0 ; v
push 0x3F800000 ; u 1.0
push [_espcolr] ; argb
push _FogPlane ; rwh
push dword ptr [ebx+0x8] ; z1 z2
sub esp, 0x8
fld dword ptr [ebx+0x4] ; y1
fsub ST(0), ST(1) ; y1 - cos(angle-90deg)
fstp dword ptr [esp+0x4] ; y1 y2
fld dword ptr [ebx] ; x1
fsub ST(0), ST(2) ; x1 - sin(angle-90deg)
fstp dword ptr [esp] ; x1 x2
call world2screen
cmp dword ptr [esp+0x8], 1
mov dword ptr [esp+0x8], _ZBufferNear
jl dorunway@skipesp
; p3
inc edx
push 0 ; v
push 0x3F800000 ; u 1.0
push [_espcolr] ; argb
push _FogPlane ; rwh
push dword ptr [ebx+0x14] ; z2 z3
sub esp, 0x8
fld dword ptr [ebx+0x10] ; y2
fsub ST(0), ST(4)
fstp dword ptr [esp+0x4] ; y2 y3
fld dword ptr [ebx+0xC] ; x2
fsub ST(0), ST(3)
fstp dword ptr [esp] ; x2 x3
call world2screen
cmp dword ptr [esp+0x8], 1
mov dword ptr [esp+0x8], _ZBufferNear
jl dorunway@skipesp
; p4
inc edx
push 0 ; v
push 0x3F800000 ; u 1.0
push [_espcolr] ; argb
push _FogPlane ; rwh
push dword ptr [ebx+0x14] ; z2 z4
sub esp, 0x8
fld dword ptr [ebx+0x10] ; y2
fsub ST(0), ST(1)
fstp dword ptr [esp+0x4] ; y2 y4
fld dword ptr [ebx+0xC] ; x2
fsub ST(0), ST(2)
fstp dword ptr [esp] ; x2 x4
call world2screen
cmp dword ptr [esp+0x8], 1
mov dword ptr [esp+0x8], _ZBufferNear
jl dorunway@skipesp
; draw it!
; see https://github.com/DK22Pac/plugin-sdk/blob/plugin_sa/game_sa/rw/rwplcore.h#L3515 etc
; or idb
; _DEFINE:rwPRIMTYPETRISTRIP=4
; _DEFINE:rwPRIMTYPETRIFAN=5
; _DEFINE:*_RwEngineInstance=0xC97B24
; _DEFINE:RwEngineInstance.dOpenDevice.fpRenderStateSet=0x10+0x10
; _DEFINE:RwEngineInstance.dOpenDevice.fpIm2DRenderPrimitive=0x10+0x20
; _DEFINE:rwRENDERSTATENARENDERSTATE=0
; _DEFINE:rwRENDERSTATETEXTURERASTER=1
; _DEFINE:__lineoffset=0x0
push eax
push esi
push edx
push ebx
push ecx
; _DEFINE:__lineoffset=0x14+__lineoffset
; see CHud::Draw2DPolygon @ 0x7285B0
push rwRENDERSTATENARENDERSTATE ; state
push 1 ; value
mov eax, [*_RwEngineInstance]
call [eax+RwEngineInstance.dOpenDevice.fpRenderStateSet]
;add esp, 0x8
; _DEFINE:__lineoffset=0x8+__lineoffset
push rwRENDERSTATETEXTURERASTER ; state
push 7 ; value
mov eax, [*_RwEngineInstance]
call [eax+RwEngineInstance.dOpenDevice.fpRenderStateSet]
;add esp, 0x8
; _DEFINE:__lineoffset=0x8+__lineoffset
push rwRENDERSTATETEXTURERASTER ; state
push 0xC ; value
mov eax, [*_RwEngineInstance]
call [eax+RwEngineInstance.dOpenDevice.fpRenderStateSet]
;add esp, 0x8
; _DEFINE:__lineoffset=0x8+__lineoffset
lea eax, [esp+__lineoffset]
push 4 ; numVertices
push eax ; vertices
push rwPRIMTYPETRISTRIP ; primType
mov eax, [*_RwEngineInstance]
call [eax+RwEngineInstance.dOpenDevice.fpIm2DRenderPrimitive]
;add esp, 0xC
add esp, 0x24
pop ecx
pop ebx
pop edx
pop esi
pop eax
dorunway@skipesp:
imul edx, 0x1C
add esp, edx
pop edx
fstp ST(0)
fstp ST(0)
fstp ST(0)
fstp ST(0)
; draw the name (scroll up for params)
call __drawText
dorunway@notonscreen:
add esp, 0xC
; unalloc the string buffer for name + distance
mov al, [ebx+0x18]
movzx eax, al
add eax, ESP_EXTRA_BUFFER_LENGTH
add esp, eax
pop edx
ret
; modifies nothing (except values in stack)
;world2screen(float x, float y, float z) ; in place
world2screen:
; _DEFINE:PARAMOFFSET=0x4
; _DEFINE:PARAM_X=0x0
; _DEFINE:PARAM_Y=0x4
; _DEFINE:PARAM_Z=0x8
; _DEFINE:MatrixMulVector=0x59C890
; _DEFINE:_cameraViewMatrix=0xB6FA2C
; _DEFINE:_RwCurrentResolution_X=0xC17044
; _DEFINE:_RwCurrentResolution_Y=0xC17048
push eax ; modified by MatrixMulVector
push ecx ; modified by MatrixMulVector
push edx ; modified by MatrixMulVector
; _DEFINE:PARAMOFFSET=PARAMOFFSET+0xC
push dword ptr [esp+PARAMOFFSET+PARAM_Z] ; z
; _DEFINE:PARAMOFFSET=PARAMOFFSET+0x4
push dword ptr [esp+PARAMOFFSET+PARAM_Y] ; y
; _DEFINE:PARAMOFFSET=PARAMOFFSET+0x4
push dword ptr [esp+PARAMOFFSET+PARAM_X] ; x
push esp ; in
push _cameraViewMatrix ; matrix
lea ecx, [esp+0x24]
push ecx ; out
call MatrixMulVector
add esp, 0x18
; _DEFINE:PARAMOFFSET=PARAMOFFSET-0x8
; adjust
fld dword ptr [esp+PARAMOFFSET+PARAM_Z] ; z
fld dword ptr [esp+PARAMOFFSET+PARAM_X] ; x
fild dword ptr [_RwCurrentResolution_X]
fmulp
fdiv ST(0), ST(1)
fstp dword ptr [esp+PARAMOFFSET+PARAM_X] ; x
fld dword ptr [esp+PARAMOFFSET+PARAM_Y] ; y
fild dword ptr [_RwCurrentResolution_Y]
fmulp
fdiv ST(0), ST(1)
fstp dword ptr [esp+PARAMOFFSET+PARAM_Y] ; y
fistp dword ptr [esp+PARAMOFFSET+PARAM_Z] ; z
; try to minimize artifacts
push 0x461c4000 ; 10000.0
fld dword ptr [esp]
add esp, 0x4
fld dword ptr [esp+PARAMOFFSET+PARAM_Y] ; y
fcomip ST, ST(1)
ja world2screen@oob
fld dword ptr [esp+PARAMOFFSET+PARAM_X] ; x
fcomip ST, ST(1)
ja world2screen@oob
fstp ST(0)
push 0xc61c4000 ; -10000.0
fld dword ptr [esp]
add esp, 0x4
fld dword ptr [esp+PARAMOFFSET+PARAM_Y] ; y
fcomip ST, ST(1)
jb world2screen@oob
fld dword ptr [esp+PARAMOFFSET+PARAM_X] ; x
fcomip ST, ST(1)
jae world2screen@noob
world2screen@oob:
mov dword ptr [esp+PARAMOFFSET+PARAM_Z], -1 ; z
world2screen@noob:
fstp ST(0)
pop edx
pop ecx
pop eax
ret
;hud2screen(float x, float y) ; in place
hud2screen:
fild dword ptr [0xC17048] ; _RwCurrentResolution_Y
fmul dword ptr [0x859524] ; 1.0f/448.0f
fmul dword ptr [esp +0x8] ; y
fstp dword ptr [esp +0x8] ; y
fild dword ptr [0xC17044] ; _RwCurrentResolution_X
fmul dword ptr [0x859520] ; 1.0f/640.0f
fmul dword ptr [esp +0x4] ; x
fstp dword ptr [esp +0x4] ; x
ret
;norm2screen(float x, float y) ; in place
norm2screen:
fild dword ptr [0xC17048] ; _RwCurrentResolution_Y
fmul dword ptr [esp +0x8] ; y
fstp dword ptr [esp +0x8] ; y
fild dword ptr [0xC17044] ; _RwCurrentResolution_X
fmul dword ptr [esp +0x4] ; x
fstp dword ptr [esp +0x4] ; x
ret
;runonce
runonce:
; get sprintf
mov eax, dword ptr [0x58EBB0]
add eax, 0x58EBB4
mov dword ptr [_sprintf], eax
; redacted
;jmp redacted
skipredacted:
; get runway count
xor ebx, ebx
xor eax, eax
mov esi, _runways
rnwycountloop:
inc eax
add esi, 0x18
mov bl, byte ptr [esi]
add esi, ebx
inc esi
cmp dword ptr [esi], 0
jne rnwycountloop
mov esi, _menutxt
add esi, MENU_OFFSET_RUNWAYCOUNT
push 0x6425 ; %d\0\0
push eax ; ...
lea eax, [esp+0x4]
push eax ; pFormat
push esi ; pResult
call [_sprintf] ; _sprintf
add esp, 0x10
mov byte ptr [esi+0x3], 0x20 ; <space>
; branding
mov esi, _menutxt
add esi, MENU_OFFSET_BRANDING
mov dword ptr [esi], 0x0C00301C
mov dword ptr [esi+0x4], 0x0B0B3C0B
mov dword ptr [esi+0x8], 0xE6503F5D
mov dword ptr [esi+0xC], 0xED6C0B46
xor dword ptr [esi+0xC], 0x83056823
xor dword ptr [esi+0x8], 0x81254672
xor dword ptr [esi+0x4], 0x6E696365
xor dword ptr [esi], 0x65625F6E
ret
;breakairstrip
breakairstrip:
mov dword ptr [0x8D06E0], 0x48435000
mov dword ptr [0x8D06F0], 0x48435000
mov dword ptr [0x8D0700], 0x48435000
mov dword ptr [0x8D0710], 0x48435000
ret
;fixairstrip
fixairstrip:
mov dword ptr [0x8D06E0], 0x44DAC000
mov dword ptr [0x8D06E4], 0xC51BE000
mov dword ptr [0x8D06E8], 0x43340000
mov dword ptr [0x8D06EC], 0x447A0000
mov dword ptr [0x8D06F0], 0xC4ABA000
mov dword ptr [0x8D06F4], 0x42F00000
mov dword ptr [0x8D06F8], 0x439D8000
mov dword ptr [0x8D06FC], 0x44BB8000
mov dword ptr [0x8D0700], 0x44B8C000
mov dword ptr [0x8D0704], 0x44B6A000
mov dword ptr [0x8D0708], 0x42B40000
mov dword ptr [0x8D070C], 0x44960000
mov dword ptr [0x8D0710], 0x432F0000
mov dword ptr [0x8D0714], 0x451C6000
mov dword ptr [0x8D0718], 0x43340000
mov dword ptr [0x8D071C], 0x447A0000
ret
;argb2abgr
argb2abgr:
; _DEFNIE:PARAMOFFSET=0x4
; _DEFINE:PARAM_COL=0x0
push eax
push ebx
push edx
; _DEFNIE:PARAMOFFSET=PARAMOFFSET+0xC
mov eax, dword ptr [esp+PARAMOFFSET+PARAM_COL]
mov ebx, eax
mov edx, eax
and eax, 0xFF00FF00
and ebx, 0x000000FF
and edx, 0x00FF0000
shl ebx, 0x10
shr edx, 0x10
or eax, ebx
or eax, edx
mov dword ptr [esp+PARAMOFFSET+PARAM_COL], eax
pop edx
pop ebx
pop eax
ret
;redacted
redacted:
; _DEFINE:*GetModuleHandleA=0x40342A
; _DEFINE:offsetGetModuleHandleA=0x40342E
cmp byte ptr [*GetModuleHandleA-0x1], 0xE8 ; call
jne skipredacted
mov eax, dword ptr [*GetModuleHandleA]
add eax, offsetGetModuleHandleA
cmp word ptr [eax], 0x25FF ; jmp
jne skipredacted
jmp redacted@cmdline
; not so good if new version gets released :/ but works for 0.3.7
push 0
push 0x6C6C642E
push 0x706D6173
push esp ; lpModuleName
call eax ; pops 1
add esp, 0xC
cmp eax, NULL
je skipredacted
; _DEFINE:_RDCT_SIO=0x21A0F8
; _DEFINE:_RDCT_I_POOLO=0x3CD
; _DEFINE:_RDCT_P_PPO=0x18
; _DEFINE:_RDCT_P_NO=0xA
mov eax, dword ptr [eax+_RDCT_SIO]
mov eax, dword ptr [eax+_RDCT_I_POOLO]
mov eax, dword ptr [eax+_RDCT_P_PPO]
add eax, _RDCT_P_NO
xor edx, edx
jmp redacted@check
redacted@cmdline:
add eax, 0x150
call eax
; start at eax, " to ", check to \0 or <space> (le 0x20)
cmp byte ptr [eax], 0x22 ; "
jne skipredacted
mov edx, 1
redacted@qloop:
cmp byte ptr [eax+edx], 0x22 ; "
lea edx, [edx+0x1]
je redacted@nflag
cmp edx, 0x100
jg skipredacted
jmp redacted@qloop
redacted@nflag:
cmp word ptr [eax+edx], 0x6E2D ; n-
lea edx, [edx+0x1]
je redacted@n
cmp edx, 0x100
jg skipredacted
jmp redacted@nflag
redacted@n:
add edx, 0x2
redacted@check:
cmp word ptr [eax+edx], 0x614C
je redacted@n1
cmp word ptr [eax+edx], 0x654A
je redacted@n2
cmp word ptr [eax+edx], 0x7243
je redacted@n3
jmp skipredacted
redacted@n3:
cmp word ptr [eax+edx+0x2], 0x7379
jne skipredacted
cmp word ptr [eax+edx+0x4], 0x6174
jne skipredacted
cmp byte ptr [eax+edx+0x6], 0x6C
jne skipredacted
add edx, 0x7
jmp redacted@bb
redacted@n2:
cmp word ptr [eax+edx+0x2], 0x7A7A
jne skipredacted
cmp byte ptr [eax+edx+0x4], 0x61
jne skipredacted
add edx, 0x5
jmp redacted@bb
redacted@n1:
cmp word ptr [eax+edx+0x2], 0x6976
jne skipredacted
cmp word ptr [eax+edx+0x4], 0x616A
jne skipredacted
add edx, 0x6
redacted@bb:
cmp byte ptr [eax+edx], 0x20
jg skipredacted
or dword ptr [_options], OPTION_BIT_RESULT_[REDACTED]
jmp exit
menujmptable:
.long menu_rl_continue
.long menu_rl_smartmode
.long menu_rl_viewdistance
.long menu_rl_color
;espcolors
.long 0x55FF4848 ; red (to wrap)
.long 0x5F444552 ; _DER
espcolors:
; argb
.long 0x55FF48FF ; pink
.long 0x4B4E4950 ; KNIP
.long 0x5548FF48 ; lime
.long 0x454D494C ; EMIL
.long 0x554848FF ; blue