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