forked from gunslingermod/gunslinger_wpnpatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhud_transp_r4.pas
193 lines (147 loc) · 4.63 KB
/
hud_transp_r4.pas
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
unit hud_transp_r4;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
interface
function Init():boolean; stdcall;
implementation
uses BaseGameData, Misc;
type FixedMapR4 = packed record
nodes:pointer;
pool:cardinal;
limit:cardinal;
end;
var
g_map_hud_sorted_r4:FixedMapR4;
g_map_hud_distort_r4:FixedMapR4;
hud_render_phase:cardinal;
procedure hud_shader_fix_Patch_sorted(); stdcall;
asm
lea eax, g_map_hud_sorted_r4
ret
end;
procedure hud_shader_fix_Patch_distort(); stdcall;
asm
//ñíà÷àëà ïîñìîòðèì, â êàêîé áóôåð çàïèõèâàòü: â îðèãèíàëüíûé èëè â õóäîâûé.
mov eax, xrRender_R4_addr
add eax, $F8140 //ôëàã òîãî, ÷òî èäåò ðåíäåð õóäà
cmp [eax], 00
je @not_hud
lea eax, g_map_hud_distort_r4
ret
@not_hud:
lea eax,[ebp+$1B8]
ret
end;
procedure r_dsgraph_render_hud_Patch_select_pool(); stdcall;
asm
//åñëè ñåé÷àñ ðåíäåðèì sorted èëè distort - òî âûáèðàåì íàøó ñòðóêòóðêó âûøå
//Èíà÷å - èñïîëüçóåì îðèãèíàëüíûé êîä.
cmp hud_render_phase, 0
je @original_nosorted
cmp hud_render_phase, 2
je @distorted
cmp g_map_hud_sorted_r4.pool, 0
lea ecx, g_map_hud_sorted_r4.nodes
ret
@distorted:
cmp g_map_hud_distort_r4.pool, 0
lea ecx, g_map_hud_distort_r4.nodes
ret
@original_nosorted:
cmp [ebp+$1a4], 0
lea ecx, [ebp+$1a0]
ret
end;
procedure r_dsgraph_render_hud_Patch_cleanup(); stdcall;
asm
cmp hud_render_phase, 0
je @original_nosorted
cmp hud_render_phase, 2
je @distorted
mov g_map_hud_sorted_r4.pool, 0
ret
@distorted:
mov g_map_hud_distort_r4.pool, 0
ret
@original_nosorted:
mov [ebp+$1a4], 0
ret
end;
procedure render_distort_fix_Patch(); stdcall;
asm
pushad
mov hud_render_phase, 2
mov ebx, xrRender_R4_addr
lea eax, [ebx+$f8030]
push eax
add ebx, $24E70
call ebx //void r_dsgraph_structure::r_dsgraph_render_hud(), â íåé âûñòàâëåííûé âûøå ôëàã çàñòàâèò ðåíäåðèòü sorted
mov hud_render_phase, 0
popad
//îðèãèíàëüíîå
mov [esi+$1bc], 0
ret
end;
procedure render_forward_fix_Patch(); stdcall;
asm
pushad
mov hud_render_phase, 1
mov ebx, xrRender_R4_addr
lea eax, [ebx+$f8030]
push eax
add ebx, $24E70
call ebx //void r_dsgraph_structure::r_dsgraph_render_hud(), â íåé âûñòàâëåííûé âûøå ôëàã çàñòàâèò ðåíäåðèòü sorted
mov hud_render_phase, 0
popad
mov ecx, xrRender_R4_addr
mov ecx, [ecx+$dc7e8]
ret
end;
function Init():boolean; stdcall;
var
jmp_addr:cardinal;
ptr:pointer;
begin
result:=false;
if xrRender_R4_addr=0 then exit;
g_map_hud_sorted_r4.nodes:=nil;
g_map_hud_sorted_r4.pool:=0;
g_map_hud_sorted_r4.limit:=0;
g_map_hud_distort_r4.nodes:=nil;
g_map_hud_distort_r4.pool:=0;
g_map_hud_distort_r4.limit:=0;
hud_render_phase:=0;
jmp_addr:=xrRender_R4_addr+$21737;
if not WriteJump(jmp_addr, cardinal(@hud_shader_fix_Patch_sorted), 6, true) then exit;
jmp_addr:=xrRender_R4_addr+$2167C;
if not WriteJump(jmp_addr, cardinal(@hud_shader_fix_Patch_distort), 6, true) then exit;
jmp_addr:=xrRender_R4_addr+$20012;
if not WriteJump(jmp_addr, cardinal(@render_forward_fix_Patch), 6, true) then exit;
jmp_addr:=xrRender_R4_addr+$25F7C; //âðåçêà â R_dsgraph_structure::r_dsgraph_render_distort
if not WriteJump(jmp_addr, cardinal(@render_distort_fix_Patch), 10, false) then exit;
jmp_addr:=xrRender_R4_addr+$25346;
if not WriteJump(jmp_addr, cardinal(@r_dsgraph_render_hud_Patch_select_pool), 13, true) then exit;
jmp_addr:=xrRender_R4_addr+$2536D;
if not WriteJump(jmp_addr, cardinal(@r_dsgraph_render_hud_Patch_cleanup), 10, true) then exit;
// Ôèêñ "îáðåçàíèÿ" áëèçêî ðàñïîëîæåííîãî ê ýêðàíó õóäà
// https://github.com/OGSR/OGSR-Engine/commit/3b4f01f6486446ed920116ca739b1984b8e576d4
// Â CParticleEffect::Render ìåíÿåì VIEWPORT_NEAR
ptr:=GetHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R4_addr+$52cc8, @ptr, sizeof(single)) then exit;
// R_dsgraph_structure::r_dsgraph_render_hud (VIEWPORT_NEAR)
ptr:=GetNegHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R4_addr+$24f6c, @ptr, sizeof(single)) then exit;
ptr:=GetHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R4_addr+$24f11, @ptr, sizeof(single)) then exit;
// R_dsgraph_structure::r_dsgraph_render_hud_ui
ptr:=GetNegHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R4_addr+$254ca, @ptr, sizeof(single)) then exit;
ptr:=GetHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R4_addr+$2546f, @ptr, sizeof(single)) then exit;
// R_dsgraph_structure::r_dsgraph_render_emissive (?)
ptr:=GetNegHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R4_addr+$25b02, @ptr, sizeof(single)) then exit;
ptr:=GetHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R4_addr+$25aa7, @ptr, sizeof(single)) then exit;
result:=true;
end;
end.