source: Daodan/src/patches/Patches.c@ 986

Last change on this file since 986 was 986, checked in by alloc, 11 years ago

Daodan: Console area fixes

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