-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathhud_transp_r3.pas
187 lines (147 loc) · 4.52 KB
/
hud_transp_r3.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
unit hud_transp_r3;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
interface
function Init():boolean; stdcall;
implementation
uses BaseGameData, Misc;
type FixedMapR3 = packed record
nodes:pointer;
pool:cardinal;
limit:cardinal;
end;
var
g_map_hud_sorted_r3:FixedMapR3;
g_map_hud_distort_r3:FixedMapR3;
hud_render_phase:cardinal;
procedure hud_shader_fix_Patch_sorted(); stdcall;
asm
lea eax, g_map_hud_sorted_r3 //è âñ¸ ;) Emissive ðàáîòàþò è â îðèãèíàëå
ret
end;
procedure hud_shader_fix_Patch_distort(); stdcall;
asm
//ñíà÷àëà ïîñìîòðèì, â êàêîé áóôåð çàïèõèâàòü: â îðèãèíàëüíûé èëè â õóäîâûé.
mov eax, xrRender_R3_addr
add eax, $EB110 //ôëàã òîãî, ÷òî èäåò ðåíäåð õóäà
cmp [eax], 00
je @not_hud
lea eax, g_map_hud_distort_r3
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_r3.pool, 0
lea ecx, g_map_hud_sorted_r3.nodes
ret
@distorted:
cmp g_map_hud_distort_r3.pool, 0
lea ecx, g_map_hud_distort_r3.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_r3.pool, 0
ret
@distorted:
mov g_map_hud_distort_r3.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_R3_addr
lea eax, [ebx+$EB000]
push eax
add ebx, $24280
call ebx
mov hud_render_phase, 0
popad
mov edx, xrRender_R3_addr
mov edx, [edx+$D05F0]
ret
end;
procedure render_forward_fix_Patch(); stdcall;
asm
pushad
mov hud_render_phase, 1
mov ebx, xrRender_R3_addr
lea eax, [ebx+$EB000]
push eax
add ebx, $24280
call ebx //void r_dsgraph_structure::r_dsgraph_render_hud(), â íåé âûñòàâëåííûé âûøå ôëàã çàñòàâèò ðåíäåðèòü sorted
mov hud_render_phase, 0
popad
mov ecx, xrRender_R3_addr
mov ecx, [ecx+$D05F0]
ret
end;
function Init():boolean; stdcall;
var
jmp_addr:cardinal;
ptr:pointer;
begin
result:=false;
if xrRender_R3_addr=0 then exit;
g_map_hud_sorted_r3.nodes:=nil;
g_map_hud_sorted_r3.pool:=0;
g_map_hud_sorted_r3.limit:=0;
g_map_hud_distort_r3.nodes:=nil;
g_map_hud_distort_r3.pool:=0;
g_map_hud_distort_r3.limit:=0;
hud_render_phase:=0;
jmp_addr:=xrRender_R3_addr+$20f57;
if not WriteJump(jmp_addr, cardinal(@hud_shader_fix_Patch_sorted), 6, true) then exit;
jmp_addr:=xrRender_R3_addr+$20e9c;
if not WriteJump(jmp_addr, cardinal(@hud_shader_fix_Patch_distort), 6, true) then exit;
jmp_addr:=xrRender_R3_addr+$1FF22;
if not WriteJump(jmp_addr, cardinal(@render_forward_fix_Patch), 6, true) then exit;
jmp_addr:=xrRender_R3_addr+$783CA;
if not WriteJump(jmp_addr, cardinal(@render_distort_fix_Patch), 6, true) then exit;
jmp_addr:=xrRender_R3_addr+$24756;
if not WriteJump(jmp_addr, cardinal(@r_dsgraph_render_hud_Patch_select_pool), 13, true) then exit;
jmp_addr:=xrRender_R3_addr+$2477D;
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_R3_addr+$50d4e, @ptr, sizeof(single)) then exit;
// R_dsgraph_structure::r_dsgraph_render_hud (VIEWPORT_NEAR)
ptr:=GetNegHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R3_addr+$2437c, @ptr, sizeof(single)) then exit;
ptr:=GetHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R3_addr+$24321, @ptr, sizeof(single)) then exit;
// R_dsgraph_structure::r_dsgraph_render_hud_ui
ptr:=GetNegHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R3_addr+$248d0, @ptr, sizeof(single)) then exit;
ptr:=GetHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R3_addr+$24875, @ptr, sizeof(single)) then exit;
// R_dsgraph_structure::r_dsgraph_render_emissive (?)
ptr:=GetNegHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R3_addr+$24f02, @ptr, sizeof(single)) then exit;
ptr:=GetHudNearClipPtr();
if not WriteBufAtAdr(xrRender_R3_addr+$24ea7, @ptr, sizeof(single)) then exit;
result:=true;
end;
end.