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