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