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