1 |
#include <windows.h> |
2 |
|
3 |
#include "../Daodan.h" |
4 |
#include "../Daodan_BSL.h" |
5 |
#include "../Daodan_Cheater.h" |
6 |
#include "../Daodan_Config.h" |
7 |
#include "../Daodan_GL.h" |
8 |
#include "../Daodan_Patch.h" |
9 |
#include "../Daodan_Persistence.h" |
10 |
#include "../Daodan_Utility.h" |
11 |
#include "../Daodan_Win32.h" |
12 |
#include "../flatline/Flatline_BSL.h" |
13 |
#include "../flatline/Flatline_Hooks.h" |
14 |
#include "../Oni.h" |
15 |
//#include "Objt.h" |
16 |
|
17 |
typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId); |
18 |
|
19 |
// Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma |
20 |
// slider in windowed mode. |
21 |
static void ONICALL DD_ONiOGU_GammaSlider_SetRange(WMtWindow* window, int min_value, int max_value) |
22 |
{ |
23 |
WMrWindow_SetEnabled(window, M3gResolutionSwitch && opt_gamma); |
24 |
WMrSlider_SetRange(window, min_value, max_value); |
25 |
} |
26 |
|
27 |
void ONICALL DD_M3rDraw_BigBitmap(M3tTextureMap_Big* inBigBitmap, const M3tPointScreen* inDestPoint, UUtUns16 inWidth, UUtUns16 inHeight, UUtUns32 inShade, UUtUns16 inAlpha) /* 0 - M3cMaxAlpha */ |
28 |
{ |
29 |
UUtUns16 x; |
30 |
UUtUns16 y; |
31 |
|
32 |
UUtUns16 index; |
33 |
UUtUns16 remaining_width; |
34 |
UUtUns16 remaining_height; |
35 |
|
36 |
M3tPointScreen dest_point; |
37 |
dest_point.z = inDestPoint->z; |
38 |
dest_point.invW = inDestPoint->invW; |
39 |
|
40 |
index = 0; |
41 |
remaining_height = inHeight; |
42 |
dest_point.y = (UUtInt16)((UUtUns16)inDestPoint->y); |
43 |
for (y = 0; y < inBigBitmap->num_y; y++) |
44 |
{ |
45 |
remaining_width = inWidth; |
46 |
dest_point.x = (UUtInt16)((UUtUns16)inDestPoint->x); |
47 |
for (x = 0; x < inBigBitmap->num_x; x++) |
48 |
{ |
49 |
UUtUns16 width; |
50 |
UUtUns16 height; |
51 |
|
52 |
width = 256 < remaining_width ? 256 : remaining_width; |
53 |
height = 256 < remaining_height ? 256 : remaining_height; |
54 |
|
55 |
M3rDraw_Bitmap(inBigBitmap->textures[index], &dest_point, width, height, inShade, inAlpha); |
56 |
|
57 |
dest_point.x += 256; |
58 |
remaining_width -= 256; |
59 |
index++; |
60 |
} |
61 |
dest_point.y += 256; |
62 |
remaining_height -= 256; |
63 |
} |
64 |
} |
65 |
|
66 |
|
67 |
void ONICALL DDrShowResumeButton(WMtWindow* window, int visibility) |
68 |
{ |
69 |
if (visibility) |
70 |
WMrWindow_SetLocation(window, 150, 350); |
71 |
WMrWindow_SetVisible(window, visibility); |
72 |
} |
73 |
|
74 |
|
75 |
/* Options always visible patch */ |
76 |
void ONICALL DDrShowOptionsButton(WMtWindow* window, int visibility) |
77 |
{ |
78 |
WMrWindow_SetVisible(window, 1); |
79 |
} |
80 |
|
81 |
void ONICALL DDrGame_Init() |
82 |
{ |
83 |
if (opt_usedaodanbsl) |
84 |
SLrDaodan_Initialize(); |
85 |
if (patch_flatline) |
86 |
SLrFlatline_Initialize(); |
87 |
} |
88 |
|
89 |
|
90 |
//this was broken |
91 |
FILE** _UUgError_WarningFile = (FILE**)0x005711B4; |
92 |
FILE* ONICALL DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message) |
93 |
{ |
94 |
FILE *v4; // eax@1 |
95 |
FILE *result; // eax@4 |
96 |
char v6[512]; // [sp+0h] [bp-100h]@1 |
97 |
FILE* UUgError_WarningFile = *_UUgError_WarningFile; |
98 |
|
99 |
if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) { |
100 |
sprintf( |
101 |
v6, |
102 |
"Error %x reported from File: %s, Line: %d (message follows) \r\n%s", |
103 |
errornum, |
104 |
(const char*)filename, |
105 |
linenumber, |
106 |
(const char*)message); |
107 |
|
108 |
if ( UUgError_WarningFile |
109 |
|| (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) ) |
110 |
{ |
111 |
oni_fprintf(UUgError_WarningFile, "%s\r\n", v6); |
112 |
oni_fflush(UUgError_WarningFile); |
113 |
} |
114 |
} |
115 |
//oni_fprintf(stdout, v6); |
116 |
//sprintf(&v6, "%s", message); |
117 |
*_UUgError_WarningFile = UUgError_WarningFile; |
118 |
result = UUgError_WarningFile; |
119 |
return result; |
120 |
} |
121 |
|
122 |
_COrTextArea_Resize Oni_COrTextArea_Resize = (_COrTextArea_Resize)0; |
123 |
int16_t ONICALL DD_COrTextArea_Resize(void* inTextArea, UUtRect* inBounds, int16_t inNumTextEntries) { |
124 |
if (inTextArea == COgCommandLine) { |
125 |
inBounds->top -= 5; |
126 |
} |
127 |
return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries); |
128 |
} |
129 |
|
130 |
int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output) |
131 |
{ |
132 |
//flags = (1 << 10); |
133 |
type = 1; |
134 |
//DDrPatch_Byte( 0x005EB83C + 3, 0xff ); |
135 |
DDrPatch_Int32((int*)(OniExe + 0x001EB83C), 0xFF000000 ); |
136 |
return M3rTextureMap_New(width, height, type, allocated, flags, name, output); |
137 |
} |
138 |
|
139 |
short DD_Patch_DebugNameShadeHack( Character* Char ) |
140 |
{ |
141 |
return TSrContext_SetShade(*(void**)(OniExe + 0x001EB844), ONrCharacter_GetHealthShade( Char->Health, Char->MaxHealth )); |
142 |
//return TSrContext_SetShade(*(void**)0x005EB844, 0xFFFFFFFF); |
143 |
} |
144 |
|
145 |
|
146 |
// Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the |
147 |
// Windows key but has the possible side effect of allowing the screensaver |
148 |
// to enable itself in-game. |
149 |
void DD_Patch_AltTab() |
150 |
{ |
151 |
// 0xC3 = ret, so makes those functions just have a "ret" instruction at their start |
152 |
DDrPatch_Byte ((char*)UUrPlatform_Initialize, 0xC3); |
153 |
DDrPatch_Byte ((char*)UUrPlatform_Terminate, 0xC3); |
154 |
} |
155 |
|
156 |
// Textures using ARGB8888 can be used |
157 |
void DD_Patch_ARGB8888() |
158 |
{ |
159 |
DDrPatch_Byte ((char*)(OniExe + 0x00135af0), 0x07); |
160 |
DDrPatch_Byte ((char*)(OniExe + 0x00135af4), 0x0B); |
161 |
} |
162 |
|
163 |
// Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting |
164 |
// instead of DirectDraw; patch ONiRunGame to use the same method to play |
165 |
// outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the |
166 |
// latter has problems on WINE). |
167 |
void DD_Patch_BinkPlay() |
168 |
{ |
169 |
// push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION. |
170 |
DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02); |
171 |
// call ONrMovie_Play_Hardware -> call ONrMovie_Play |
172 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play); |
173 |
} |
174 |
|
175 |
// Enables d_regen (unfinished) and prevents fly-in portraits from being |
176 |
// stretched when playing in widescreen resolutions. |
177 |
void DD_Patch_BSL() |
178 |
{ |
179 |
//Calculating the value of the needed offset is much more reliable when the compiler does it for you. |
180 |
|
181 |
//TODO: fix moonshadow. |
182 |
Character * Chr = 0; |
183 |
int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF; |
184 |
const unsigned char regen_patch[] = |
185 |
{0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP |
186 |
0x90, 0x90, // test al, al -> NOOP |
187 |
0x90, 0x90, // jz short loc_51BB98 -> NOOP |
188 |
0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8] |
189 |
// -> mov eax, [esi+Character.RegenHax] |
190 |
0x85, 0xC0, // test eax, eax |
191 |
0x74, 0x21 // jnz 0x21 -> jz 0x21 |
192 |
}; |
193 |
DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch); |
194 |
|
195 |
// Patches for existing BSL functions |
196 |
SLrDaodan_Patch(); |
197 |
} |
198 |
|
199 |
// Adds new cheat codes if cheattable is also enabled |
200 |
void DD_Patch_Cheater() |
201 |
{ |
202 |
DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater); |
203 |
DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590); |
204 |
#if 1 |
205 |
DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames); |
206 |
#endif |
207 |
DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); |
208 |
} |
209 |
|
210 |
// Cheats always enabled |
211 |
void DD_Patch_CheatsEnabled() |
212 |
{ |
213 |
DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame); |
214 |
} |
215 |
|
216 |
// Use Daodan's own cheattable |
217 |
void DD_Patch_CheatTable() |
218 |
{ |
219 |
DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name); |
220 |
DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on); |
221 |
} |
222 |
|
223 |
// Load chinese font DLL if available |
224 |
void DD_Patch_Chinese() |
225 |
{ |
226 |
if (GetFileAttributes("xfhsm_oni.dll") != INVALID_FILE_ATTRIBUTES) |
227 |
{ |
228 |
HMODULE dll; |
229 |
DWORD err; |
230 |
|
231 |
DDrStartupMessage("Daodan: Loading chinese DLL"); |
232 |
dll = LoadLibrary("xfhsm_oni.dll"); |
233 |
err = GetLastError(); |
234 |
if( dll ) |
235 |
{ |
236 |
void* proc = GetProcAddress( dll, "InstallHook" ); |
237 |
if(proc) |
238 |
{ |
239 |
((CHINESEPROC)proc)(GetCurrentThreadId()); |
240 |
} |
241 |
} else { |
242 |
char msg[100]; |
243 |
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL); |
244 |
DDrStartupMessage("Daodan: Loading DLL failed with error %i: %s", err, msg); |
245 |
} |
246 |
} |
247 |
} |
248 |
|
249 |
// Limit cursor to Oni's window |
250 |
void DD_Patch_ClipCursor() |
251 |
{ |
252 |
// LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. |
253 |
DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); |
254 |
|
255 |
// LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. |
256 |
DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); |
257 |
|
258 |
// LIrTermiante: replace LIrPlatform_Terminate call with our hook. |
259 |
DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); |
260 |
} |
261 |
|
262 |
// Disables weapon cooldown exploit |
263 |
void DD_Patch_CooldownTimer() |
264 |
{ |
265 |
const unsigned char cooldown_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; |
266 |
DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch); |
267 |
} |
268 |
|
269 |
// Daodan device mode enumeration function |
270 |
void DD_Patch_DaodanDisplayEnum() |
271 |
{ |
272 |
DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); |
273 |
} |
274 |
|
275 |
// Adds new BSL functions |
276 |
void DD_Patch_DaodanInit() |
277 |
{ |
278 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init); |
279 |
} |
280 |
|
281 |
// Forced DirectInput (for Windows NT) |
282 |
void DD_Patch_DirectInput() |
283 |
{ |
284 |
DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb); |
285 |
} |
286 |
|
287 |
// Disable Oni's command line parser so it doesn't interfere with ours |
288 |
void DD_Patch_DisableCmdLine() |
289 |
{ |
290 |
DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366); |
291 |
} |
292 |
|
293 |
// Enable flatline multiplayer code |
294 |
void DD_Patch_Flatline() |
295 |
{ |
296 |
DDrPatch_MakeCall((void*)(OniExe + 0x000E17F6), FLrHook_Lasers ); |
297 |
|
298 |
//Flatline related stuff |
299 |
DDrPatch_MakeCall((void*)(OniExe + 0x000FBCEA), DDrText_Hook); |
300 |
|
301 |
DDrPatch_Int32((int*)(OniExe + 0x000B24D2), (unsigned int)FLrSpawnHack); |
302 |
|
303 |
DDrPatch_NOOP((char*)(OniExe + 0x000C26CB), 6); |
304 |
|
305 |
DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen); |
306 |
DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate); |
307 |
} |
308 |
|
309 |
// Font texture cache doubled |
310 |
void DD_Patch_FontTextureCache() |
311 |
{ |
312 |
DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20); |
313 |
DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40); |
314 |
} |
315 |
|
316 |
// Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own) |
317 |
void DD_Patch_GetCmdLine() |
318 |
{ |
319 |
DDrPatch_NOOP ((char*)(OniExe + 0x000d3280), 51); |
320 |
} |
321 |
|
322 |
// Allow HD screens with resolution < 1024*768 |
323 |
void DD_Patch_HDScreens_LowRes() |
324 |
{ |
325 |
DDrPatch_MakeJump((void*)M3rDraw_BigBitmap, (void*)DD_M3rDraw_BigBitmap); |
326 |
} |
327 |
|
328 |
void DD_Patch_HighresConsole() { |
329 |
Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize); |
330 |
} |
331 |
|
332 |
// Hackish fix for Konoko not kicking guns |
333 |
// Don't use this, it breaks stairs. |
334 |
void DD_Patch_KickGuns() |
335 |
{ |
336 |
const unsigned char kickgun_patch[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0xC7, 0x05, 0x1C, 0xC9, 0x5E, 0x00, 0x70, 0xB8, 0x43, 0x00, 0xC7, 0x05, 0x20, 0xC9, 0x5E, 0x00, 0x20, 0xBE, 0x43 }; |
337 |
DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch); |
338 |
} |
339 |
|
340 |
// Disable loading the vtuneapi.dll |
341 |
void DD_Patch_KillVTune() |
342 |
{ |
343 |
DDrPatch_Byte ((char*)(OniExe + 0x00026340), 0xC3); |
344 |
} |
345 |
|
346 |
// Now supports textures up to 512x512 |
347 |
void DD_Patch_LargeTextures() |
348 |
{ |
349 |
DDrPatch_Byte ((char*)(OniExe + 0x00005251), 0x10); |
350 |
} |
351 |
|
352 |
// Non-"_Final" levels are now valid |
353 |
void DD_Patch_LevelPlugins() |
354 |
{ |
355 |
DDrPatch_Byte ((char*)(OniExe + 0x000206a8), 0x01); |
356 |
} |
357 |
|
358 |
// Weapon on ground shown with name and magazine contents |
359 |
void DD_Patch_NewWeap() |
360 |
{ |
361 |
//Makes it always say "Received weapon_name." |
362 |
//Needs check for loc_4DFC66 |
363 |
//DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2); |
364 |
|
365 |
//Adds Weapon name and ammo meter to pickup autoprompt |
366 |
DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9); |
367 |
DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5); |
368 |
DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message); |
369 |
|
370 |
//Moves location of colors |
371 |
//DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors ); |
372 |
//DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors ); |
373 |
} |
374 |
|
375 |
// Disable Multi-byte character awareness patch (multiple language support) |
376 |
void DD_Patch_NoMultiByte() |
377 |
{ |
378 |
DDrPatch_Byte ((char*)(OniExe + 0x0002d8f8), 0xeb); |
379 |
DDrPatch_Byte ((char*)(OniExe + 0x0002d9ad), 0xeb); |
380 |
DDrPatch_Byte ((char*)(OniExe + 0x0002dbe2), 0xeb); |
381 |
DDrPatch_Byte ((char*)(OniExe + 0x0002dec3), 0xeb); |
382 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e2ab), 0xeb); |
383 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e2c4), 0xeb); |
384 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e379), 0xeb); |
385 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e48c), 0xeb); |
386 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e4d0), 0xeb); |
387 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e4f4), 0xeb); |
388 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e646), 0xeb); |
389 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e695), 0xeb); |
390 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e944), 0xeb); |
391 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e95d), 0xeb); |
392 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e98e), 0xeb); |
393 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e9dc), 0xeb); |
394 |
} |
395 |
|
396 |
// Fix options not visible in main menu when a game was started |
397 |
void DD_Patch_OptionsVisible() |
398 |
{ |
399 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton); |
400 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton); |
401 |
} |
402 |
|
403 |
// Unlocks particle action disabling/enabling bits for all events. (Will be |
404 |
// controlled by a command line switch when I figure out how to do that without |
405 |
// Win32 hacks.) |
406 |
void DD_Patch_ParticleDisableBit() |
407 |
{ |
408 |
DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090); |
409 |
} |
410 |
|
411 |
// Pathfinding grid cache size x8 |
412 |
void DD_Patch_PathFinding() |
413 |
{ |
414 |
const unsigned char pathfinding[2] = {0x90 , 0xE9 }; |
415 |
DDrPatch_Byte ((char*)(OniExe + 0x0010b03b), 0x20); |
416 |
DDrPatch_Byte ((char*)(OniExe + 0x0010b04c), 0x20); |
417 |
|
418 |
//other stuff |
419 |
DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding); |
420 |
} |
421 |
|
422 |
// Projectile awareness fixed |
423 |
void DD_Patch_ProjAware() |
424 |
{ |
425 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c07c), 0x6c); |
426 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c080), 0x70); |
427 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c084), 0x74); |
428 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c110), 0x6c); |
429 |
} |
430 |
|
431 |
// Safe startup message printer |
432 |
void DD_Patch_SafePrintf() |
433 |
{ |
434 |
DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage); |
435 |
} |
436 |
|
437 |
// Show all (also enemies') lasersights |
438 |
void DD_Patch_ShowAllLasersights() |
439 |
{ |
440 |
DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 ); |
441 |
} |
442 |
|
443 |
// Experiment with allowing enemies to be thrown over railings |
444 |
void DD_Patch_Throwtest() |
445 |
{ |
446 |
const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; |
447 |
DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch); |
448 |
} |
449 |
|
450 |
// DaodanGL with windowed mode support |
451 |
void DD_Patch_UseDaodanGL() |
452 |
{ |
453 |
// LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect. |
454 |
DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6); |
455 |
DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect); |
456 |
|
457 |
// UUrWindow_GetSize: GetWindowRect -> GetClientRect. |
458 |
DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); |
459 |
DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); |
460 |
|
461 |
// LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. |
462 |
DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); |
463 |
DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos); |
464 |
|
465 |
// LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates. |
466 |
DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6); |
467 |
DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos); |
468 |
|
469 |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
470 |
DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6); |
471 |
DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos); |
472 |
|
473 |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
474 |
DDrPatch_NOOP((char*) OniExe + 0x00003349, 6); |
475 |
DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos); |
476 |
|
477 |
// Replace ONrPlatformInitialize. |
478 |
DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize); |
479 |
|
480 |
// Replace gl_platform_initialize. |
481 |
DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize); |
482 |
|
483 |
// Replace gl_platform_dispose. |
484 |
DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose); |
485 |
} |
486 |
|
487 |
// Performance patch |
488 |
void DD_Patch_UseGetTickCount() |
489 |
{ |
490 |
DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High); |
491 |
DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency); |
492 |
DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths); |
493 |
} |
494 |
|
495 |
// Adds working function for existing BSL command wp_fadetime, sets fade time to 4800 |
496 |
void DD_Patch_WpFadetime() |
497 |
{ |
498 |
// Makes wp_fadetime actually have a function |
499 |
const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 }; |
500 |
DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch); |
501 |
DDrPatch_Byte ((char*)(OniExe + 0x0011a560), 0x31); |
502 |
|
503 |
// Sets the fadetime to 4800 by default |
504 |
DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0); |
505 |
} |
506 |
|
507 |
// Disable gamma slider in options in windowed mode |
508 |
void DD_Patch_GammaSlider() |
509 |
{ |
510 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange); |
511 |
} |
512 |
|
513 |
// Fix the warning print method |
514 |
void DD_Patch_PrintWarning() |
515 |
{ |
516 |
DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning); |
517 |
} |
518 |
|
519 |
//Fix crappy ai2_shownames |
520 |
void DD_Patch_ShowNames() |
521 |
{ |
522 |
//Set distance above head to 4.0 |
523 |
DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8); |
524 |
//texture height |
525 |
DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F ); |
526 |
//texture width |
527 |
DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 ); |
528 |
|
529 |
/* |
530 |
// Crashes game. |
531 |
//Set the text color to whatever we like ;) |
532 |
DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 ); |
533 |
DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B ); |
534 |
DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE ); |
535 |
|
536 |
DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), DD_Patch_DebugNameShadeHack); |
537 |
|
538 |
//Make the background black for additive blending |
539 |
DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), DD_Patch_DebugNameTextureInit ); |
540 |
*/ |
541 |
} |
542 |
|
543 |
/* |
544 |
void DD_Patch_ShowTriggerVolumes() |
545 |
{ |
546 |
DDrPatch_Int32((int*)(OniExe + 0x000cc9bb+4), (uint32_t)DD_OBJiTriggerVolume_Draw); |
547 |
} |
548 |
|
549 |
void DD_Patch_ShowFlags() |
550 |
{ |
551 |
DDrPatch_Int32((int*)(OniExe + 0x000c4ed4+4), (uint32_t)DD_OBJiFlag_Draw); |
552 |
} |
553 |
*/ |
554 |
|
555 |
bool DD_Patch_Init() |
556 |
{ |
557 |
DDrStartupMessage("Daodan: Patching engine"); |
558 |
|
559 |
if (patch_alttab) |
560 |
DD_Patch_AltTab(); |
561 |
|
562 |
if (patch_argb8888) |
563 |
DD_Patch_ARGB8888(); |
564 |
|
565 |
if (patch_binkplay) |
566 |
DD_Patch_BinkPlay(); |
567 |
|
568 |
if (patch_bsl) |
569 |
DD_Patch_BSL(); |
570 |
|
571 |
if (patch_cheater) |
572 |
DD_Patch_Cheater(); |
573 |
|
574 |
if (patch_cheatsenabled) |
575 |
DD_Patch_CheatsEnabled(); |
576 |
|
577 |
if (patch_cheattable) |
578 |
DD_Patch_CheatTable(); |
579 |
|
580 |
if (patch_chinese) |
581 |
DD_Patch_Chinese(); |
582 |
|
583 |
if (patch_clipcursor) |
584 |
DD_Patch_ClipCursor(); |
585 |
|
586 |
if (patch_cooldowntimer) |
587 |
DD_Patch_CooldownTimer(); |
588 |
|
589 |
if (patch_daodandisplayenum) |
590 |
DD_Patch_DaodanDisplayEnum(); |
591 |
|
592 |
if (patch_directinput) |
593 |
DD_Patch_DirectInput(); |
594 |
|
595 |
if (patch_disablecmdline) |
596 |
DD_Patch_DisableCmdLine(); |
597 |
|
598 |
if (patch_fonttexturecache) |
599 |
DD_Patch_FontTextureCache(); |
600 |
|
601 |
if (patch_getcmdline) |
602 |
DD_Patch_GetCmdLine(); |
603 |
|
604 |
if (patch_hdscreens_lowres) |
605 |
DD_Patch_HDScreens_LowRes(); |
606 |
|
607 |
if (patch_highres_console) |
608 |
DD_Patch_HighresConsole(); |
609 |
|
610 |
if (patch_kickguns) |
611 |
DD_Patch_KickGuns(); |
612 |
|
613 |
//if (patch_killvtune) |
614 |
// DD_Patch_KillVTune(); |
615 |
|
616 |
if (patch_largetextures) |
617 |
DD_Patch_LargeTextures(); |
618 |
|
619 |
if (patch_levelplugins) |
620 |
DD_Patch_LevelPlugins(); |
621 |
|
622 |
if (patch_newweapon) |
623 |
DD_Patch_NewWeap(); |
624 |
|
625 |
if (patch_nomultibyte) |
626 |
DD_Patch_NoMultiByte(); |
627 |
|
628 |
if(patch_optionsvisible) |
629 |
DD_Patch_OptionsVisible(); |
630 |
|
631 |
if (patch_particledisablebit) |
632 |
DD_Patch_ParticleDisableBit(); |
633 |
|
634 |
if (patch_pathfinding) |
635 |
DD_Patch_PathFinding(); |
636 |
|
637 |
if (patch_projaware) |
638 |
DD_Patch_ProjAware(); |
639 |
|
640 |
if (patch_safeprintf) |
641 |
DD_Patch_SafePrintf(); |
642 |
|
643 |
if (patch_showalllasersights) |
644 |
DD_Patch_ShowAllLasersights(); |
645 |
|
646 |
if (patch_throwtest) |
647 |
DD_Patch_Throwtest(); |
648 |
|
649 |
if (patch_usedaodangl) |
650 |
DD_Patch_UseDaodanGL(); |
651 |
|
652 |
if (patch_usegettickcount) |
653 |
DD_Patch_UseGetTickCount(); |
654 |
|
655 |
if (patch_wpfadetime) |
656 |
DD_Patch_WpFadetime(); |
657 |
|
658 |
|
659 |
DD_Patch_DaodanInit(); |
660 |
|
661 |
DD_Patch_GammaSlider(); |
662 |
|
663 |
DD_Patch_PrintWarning(); |
664 |
|
665 |
|
666 |
DD_Patch_ShowNames(); |
667 |
/* |
668 |
DD_Patch_ShowTriggerVolumes(); |
669 |
DD_Patch_ShowFlags(); |
670 |
*/ |
671 |
if (patch_flatline) |
672 |
DD_Patch_Flatline(); |
673 |
|
674 |
return true; |
675 |
} |
676 |
|