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