[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"
|
---|
| 15 |
|
---|
| 16 | typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId);
|
---|
| 17 |
|
---|
| 18 | // Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma
|
---|
| 19 | // slider in windowed mode.
|
---|
| 20 | static void ONICALL DD_ONiOGU_GammaSlider_SetRange(WMtWindow* window, int min_value, int max_value)
|
---|
| 21 | {
|
---|
| 22 | WMrWindow_SetEnabled(window, M3gResolutionSwitch && opt_gamma);
|
---|
| 23 | WMrSlider_SetRange(window, min_value, max_value);
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | void ONICALL DDrShowResumeButton(WMtWindow* window, int visibility)
|
---|
| 27 | {
|
---|
| 28 | if (visibility)
|
---|
| 29 | WMrWindow_SetLocation(window, 150, 350);
|
---|
| 30 | WMrWindow_SetVisible(window, visibility);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | /* Options always visible patch */
|
---|
| 35 | void ONICALL DDrShowOptionsButton(WMtWindow* window, int visibility)
|
---|
| 36 | {
|
---|
| 37 | WMrWindow_SetVisible(window, 1);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | void ONICALL DDrGame_Init()
|
---|
| 41 | {
|
---|
| 42 | if (opt_usedaodanbsl)
|
---|
| 43 | SLrDaodan_Initialize();
|
---|
[877] | 44 | if (patch_flatline)
|
---|
| 45 | SLrFlatline_Initialize();
|
---|
[839] | 46 | }
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | //this was broken
|
---|
| 50 | FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
|
---|
| 51 | FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
|
---|
| 52 | {
|
---|
| 53 |
|
---|
| 54 | FILE *v4; // eax@1
|
---|
| 55 | FILE *result; // eax@4
|
---|
| 56 | char v6[512]; // [sp+0h] [bp-100h]@1
|
---|
| 57 | FILE* UUgError_WarningFile = *_UUgError_WarningFile;
|
---|
| 58 |
|
---|
| 59 | if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) {
|
---|
| 60 | sprintf(
|
---|
| 61 | v6,
|
---|
| 62 | "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
|
---|
| 63 | errornum,
|
---|
| 64 | (const char*)filename,
|
---|
| 65 | linenumber,
|
---|
| 66 | (const char*)message);
|
---|
| 67 |
|
---|
| 68 | if ( UUgError_WarningFile
|
---|
| 69 | || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
|
---|
| 70 | {
|
---|
| 71 | oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
|
---|
| 72 | oni_fflush(UUgError_WarningFile);
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 | //oni_fprintf(stdout, v6);
|
---|
| 76 | //sprintf(&v6, "%s", message);
|
---|
| 77 | *_UUgError_WarningFile = UUgError_WarningFile;
|
---|
| 78 | result = UUgError_WarningFile;
|
---|
| 79 | return result;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[875] | 82 |
|
---|
[877] | 83 | int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output)
|
---|
[875] | 84 | {
|
---|
| 85 | //flags = (1 << 10);
|
---|
| 86 | type = 1;
|
---|
| 87 | //DDrPatch_Byte( 0x005EB83C + 3, 0xff );
|
---|
| 88 | DDrPatch_Int32((int*)(OniExe + 0x001EB83C), 0xFF000000 );
|
---|
| 89 | return M3rTextureMap_New(width, height, type, allocated, flags, name, output);
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[877] | 92 | short DD_Patch_DebugNameShadeHack( Character* Char )
|
---|
[875] | 93 | {
|
---|
| 94 | return TSrContext_SetShade(*(void**)(OniExe + 0x001EB844), ONrCharacter_GetHealthShade( Char->Health, Char->MaxHealth ));
|
---|
| 95 | //return TSrContext_SetShade(*(void**)0x005EB844, 0xFFFFFFFF);
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 |
|
---|
[839] | 99 | // Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the
|
---|
| 100 | // Windows key but has the possible side effect of allowing the screensaver
|
---|
| 101 | // to enable itself in-game.
|
---|
| 102 | void DD_Patch_AltTab()
|
---|
| 103 | {
|
---|
| 104 | // 0xC3 = ret, so makes those functions just have a "ret" instruction at their start
|
---|
| 105 | DDrPatch_Byte ((char*)UUrPlatform_Initialize, 0xC3);
|
---|
| 106 | DDrPatch_Byte ((char*)UUrPlatform_Terminate, 0xC3);
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | // Textures using ARGB8888 can be used
|
---|
| 110 | void DD_Patch_ARGB8888()
|
---|
| 111 | {
|
---|
| 112 | DDrPatch_Byte ((char*)(OniExe + 0x00135af0), 0x07);
|
---|
| 113 | DDrPatch_Byte ((char*)(OniExe + 0x00135af4), 0x0B);
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | // Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting
|
---|
| 117 | // instead of DirectDraw; patch ONiRunGame to use the same method to play
|
---|
| 118 | // outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the
|
---|
| 119 | // latter has problems on WINE).
|
---|
| 120 | void DD_Patch_BinkPlay()
|
---|
| 121 | {
|
---|
| 122 | // push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION.
|
---|
| 123 | DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02);
|
---|
| 124 | // call ONrMovie_Play_Hardware -> call ONrMovie_Play
|
---|
| 125 | DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play);
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | // Enables d_regen (unfinished) and prevents fly-in portraits from being
|
---|
| 129 | // stretched when playing in widescreen resolutions.
|
---|
| 130 | void DD_Patch_BSL()
|
---|
| 131 | {
|
---|
| 132 | //Calculating the value of the needed offset is much more reliable when the compiler does it for you.
|
---|
| 133 |
|
---|
| 134 | //TODO: fix moonshadow.
|
---|
| 135 | Character * Chr = 0;
|
---|
| 136 | int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
|
---|
| 137 | const unsigned char regen_patch[] =
|
---|
| 138 | {0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP
|
---|
| 139 | 0x90, 0x90, // test al, al -> NOOP
|
---|
| 140 | 0x90, 0x90, // jz short loc_51BB98 -> NOOP
|
---|
| 141 | 0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8]
|
---|
| 142 | // -> mov eax, [esi+Character.RegenHax]
|
---|
| 143 | 0x85, 0xC0, // test eax, eax
|
---|
| 144 | 0x74, 0x21 // jnz 0x21 -> jz 0x21
|
---|
| 145 | };
|
---|
| 146 | DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch);
|
---|
| 147 |
|
---|
| 148 | // Patches for existing BSL functions
|
---|
| 149 | SLrDaodan_Patch();
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | // Adds new cheat codes if cheattable is also enabled
|
---|
| 153 | void DD_Patch_Cheater()
|
---|
| 154 | {
|
---|
| 155 | DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater);
|
---|
| 156 | DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590);
|
---|
| 157 | #if 1
|
---|
| 158 | DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames);
|
---|
| 159 | #endif
|
---|
| 160 | DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | // Cheats always enabled
|
---|
| 164 | void DD_Patch_CheatsEnabled()
|
---|
| 165 | {
|
---|
| 166 | DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame);
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | // Use Daodan's own cheattable
|
---|
| 170 | void DD_Patch_CheatTable()
|
---|
| 171 | {
|
---|
| 172 | DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name);
|
---|
| 173 | DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | // Load chinese font DLL if available
|
---|
| 177 | void DD_Patch_Chinese()
|
---|
| 178 | {
|
---|
| 179 | if (GetFileAttributes("xfhsm_oni.dll") != INVALID_FILE_ATTRIBUTES)
|
---|
| 180 | {
|
---|
| 181 | HMODULE dll;
|
---|
| 182 | DWORD err;
|
---|
| 183 |
|
---|
| 184 | DDrStartupMessage("Daodan: Loading chinese DLL");
|
---|
| 185 | dll = LoadLibrary("xfhsm_oni.dll");
|
---|
| 186 | err = GetLastError();
|
---|
| 187 | if( dll )
|
---|
| 188 | {
|
---|
| 189 | void* proc = GetProcAddress( dll, "InstallHook" );
|
---|
| 190 | if(proc)
|
---|
| 191 | {
|
---|
| 192 | ((CHINESEPROC)proc)(GetCurrentThreadId());
|
---|
| 193 | }
|
---|
| 194 | } else {
|
---|
| 195 | char msg[100];
|
---|
| 196 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL);
|
---|
| 197 | DDrStartupMessage("Daodan: Loading DLL failed with error %i: %s", err, msg);
|
---|
| 198 | }
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | // Limit cursor to Oni's window
|
---|
| 203 | void DD_Patch_ClipCursor()
|
---|
| 204 | {
|
---|
| 205 | // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook.
|
---|
| 206 | DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set);
|
---|
| 207 |
|
---|
| 208 | // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook.
|
---|
| 209 | DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set);
|
---|
| 210 |
|
---|
| 211 | // LIrTermiante: replace LIrPlatform_Terminate call with our hook.
|
---|
| 212 | DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate);
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | // Disables weapon cooldown exploit
|
---|
| 216 | void DD_Patch_CooldownTimer()
|
---|
| 217 | {
|
---|
| 218 | 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 };
|
---|
| 219 | DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch);
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | // Daodan device mode enumeration function
|
---|
| 223 | void DD_Patch_DaodanDisplayEnum()
|
---|
| 224 | {
|
---|
| 225 | DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes);
|
---|
| 226 | }
|
---|
| 227 |
|
---|
[878] | 228 | // Adds new BSL functions
|
---|
[839] | 229 | void DD_Patch_DaodanInit()
|
---|
| 230 | {
|
---|
| 231 | DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init);
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | // Forced DirectInput (for Windows NT)
|
---|
| 235 | void DD_Patch_DirectInput()
|
---|
| 236 | {
|
---|
| 237 | DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb);
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | // Disable Oni's command line parser so it doesn't interfere with ours
|
---|
| 241 | void DD_Patch_DisableCmdLine()
|
---|
| 242 | {
|
---|
| 243 | DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366);
|
---|
| 244 | }
|
---|
| 245 |
|
---|
[877] | 246 | // Enable flatline multiplayer code
|
---|
| 247 | void DD_Patch_Flatline()
|
---|
| 248 | {
|
---|
| 249 | DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 );
|
---|
| 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 |
|
---|
| 381 | // Experiment with allowing enemies to be thrown over railings
|
---|
| 382 | void DD_Patch_Throwtest()
|
---|
| 383 | {
|
---|
| 384 | const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
|
---|
| 385 | DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch);
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | // DaodanGL with windowed mode support
|
---|
| 389 | void DD_Patch_UseDaodanGL()
|
---|
| 390 | {
|
---|
| 391 | // LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect.
|
---|
| 392 | DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6);
|
---|
| 393 | DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect);
|
---|
| 394 |
|
---|
| 395 | // UUrWindow_GetSize: GetWindowRect -> GetClientRect.
|
---|
| 396 | DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6);
|
---|
| 397 | DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect);
|
---|
| 398 |
|
---|
| 399 | // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates.
|
---|
| 400 | DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6);
|
---|
| 401 | DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos);
|
---|
| 402 |
|
---|
| 403 | // LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates.
|
---|
| 404 | DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6);
|
---|
| 405 | DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos);
|
---|
| 406 |
|
---|
| 407 | // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
|
---|
| 408 | DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6);
|
---|
| 409 | DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos);
|
---|
| 410 |
|
---|
| 411 | // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
|
---|
| 412 | DDrPatch_NOOP((char*) OniExe + 0x00003349, 6);
|
---|
| 413 | DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos);
|
---|
| 414 |
|
---|
| 415 | // Replace ONrPlatformInitialize.
|
---|
| 416 | DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize);
|
---|
| 417 |
|
---|
| 418 | // Replace gl_platform_initialize.
|
---|
| 419 | DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize);
|
---|
| 420 |
|
---|
| 421 | // Replace gl_platform_dispose.
|
---|
| 422 | DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose);
|
---|
| 423 | }
|
---|
| 424 |
|
---|
| 425 | // Performance patch
|
---|
| 426 | void DD_Patch_UseGetTickCount()
|
---|
| 427 | {
|
---|
| 428 | DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High);
|
---|
| 429 | DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency);
|
---|
| 430 | DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths);
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | // Adds working function for existing BSL command wp_fadetime, sets fade time to 4800
|
---|
| 434 | void DD_Patch_WpFadetime()
|
---|
| 435 | {
|
---|
| 436 | // Makes wp_fadetime actually have a function
|
---|
| 437 | const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
|
---|
| 438 | DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch);
|
---|
| 439 | DDrPatch_Byte ((char*)(OniExe + 0x0011a560), 0x31);
|
---|
| 440 |
|
---|
| 441 | // Sets the fadetime to 4800 by default
|
---|
| 442 | DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0);
|
---|
| 443 | }
|
---|
| 444 |
|
---|
| 445 | // Disable gamma slider in options in windowed mode
|
---|
| 446 | void DD_Patch_GammaSlider()
|
---|
| 447 | {
|
---|
| 448 | DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange);
|
---|
| 449 | }
|
---|
| 450 |
|
---|
| 451 | // Fix the warning print method
|
---|
| 452 | void DD_Patch_PrintWarning()
|
---|
| 453 | {
|
---|
| 454 | DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning);
|
---|
| 455 | }
|
---|
| 456 |
|
---|
[875] | 457 | //Fix crappy ai2_shownames
|
---|
| 458 | void DD_Patch_ShowNames()
|
---|
| 459 | {
|
---|
| 460 | //Set distance above head to 4.0
|
---|
| 461 | DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8);
|
---|
| 462 | //texture height
|
---|
| 463 | DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F );
|
---|
| 464 | //texture width
|
---|
| 465 | DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 );
|
---|
| 466 |
|
---|
| 467 | /*
|
---|
| 468 | // Crashes game.
|
---|
| 469 | //Set the text color to whatever we like ;)
|
---|
| 470 | DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 );
|
---|
| 471 | DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B );
|
---|
| 472 | DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE );
|
---|
| 473 |
|
---|
[877] | 474 | DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), DD_Patch_DebugNameShadeHack);
|
---|
[875] | 475 |
|
---|
| 476 | //Make the background black for additive blending
|
---|
[877] | 477 | DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), DD_Patch_DebugNameTextureInit );
|
---|
[875] | 478 | */
|
---|
| 479 | }
|
---|
| 480 |
|
---|
[839] | 481 | bool DD_Patch_Init()
|
---|
| 482 | {
|
---|
| 483 | DDrStartupMessage("Daodan: Patching engine");
|
---|
| 484 |
|
---|
| 485 | if (patch_alttab)
|
---|
| 486 | DD_Patch_AltTab();
|
---|
| 487 |
|
---|
| 488 | if (patch_argb8888)
|
---|
| 489 | DD_Patch_ARGB8888();
|
---|
| 490 |
|
---|
| 491 | if (patch_binkplay)
|
---|
| 492 | DD_Patch_BinkPlay();
|
---|
| 493 |
|
---|
| 494 | if (patch_bsl)
|
---|
| 495 | DD_Patch_BSL();
|
---|
| 496 |
|
---|
| 497 | if (patch_cheater)
|
---|
| 498 | DD_Patch_Cheater();
|
---|
| 499 |
|
---|
| 500 | if (patch_cheatsenabled)
|
---|
| 501 | DD_Patch_CheatsEnabled();
|
---|
| 502 |
|
---|
| 503 | if (patch_cheattable)
|
---|
| 504 | DD_Patch_CheatTable();
|
---|
| 505 |
|
---|
| 506 | if (patch_chinese)
|
---|
| 507 | DD_Patch_Chinese();
|
---|
| 508 |
|
---|
| 509 | if (patch_clipcursor)
|
---|
| 510 | DD_Patch_ClipCursor();
|
---|
| 511 |
|
---|
| 512 | if (patch_cooldowntimer)
|
---|
| 513 | DD_Patch_CooldownTimer();
|
---|
| 514 |
|
---|
| 515 | if (patch_daodandisplayenum)
|
---|
| 516 | DD_Patch_DaodanDisplayEnum();
|
---|
| 517 |
|
---|
| 518 | if (patch_directinput)
|
---|
| 519 | DD_Patch_DirectInput();
|
---|
| 520 |
|
---|
| 521 | if (patch_disablecmdline)
|
---|
| 522 | DD_Patch_DisableCmdLine();
|
---|
| 523 |
|
---|
| 524 | if (patch_fonttexturecache)
|
---|
| 525 | DD_Patch_FontTextureCache();
|
---|
| 526 |
|
---|
| 527 | if (patch_getcmdline)
|
---|
| 528 | DD_Patch_GetCmdLine();
|
---|
| 529 |
|
---|
| 530 | if (patch_kickguns)
|
---|
| 531 | DD_Patch_KickGuns();
|
---|
| 532 |
|
---|
| 533 | //if (patch_killvtune)
|
---|
| 534 | // DD_Patch_KillVTune();
|
---|
| 535 |
|
---|
| 536 | if (patch_largetextures)
|
---|
| 537 | DD_Patch_LargeTextures();
|
---|
| 538 |
|
---|
| 539 | if (patch_levelplugins)
|
---|
| 540 | DD_Patch_LevelPlugins();
|
---|
| 541 |
|
---|
| 542 | if (patch_newweapon)
|
---|
| 543 | DD_Patch_NewWeap();
|
---|
| 544 |
|
---|
[843] | 545 | if (patch_nomultibyte)
|
---|
| 546 | DD_Patch_NoMultiByte();
|
---|
| 547 |
|
---|
[839] | 548 | if(patch_optionsvisible)
|
---|
| 549 | DD_Patch_OptionsVisible();
|
---|
| 550 |
|
---|
| 551 | if (patch_particledisablebit)
|
---|
| 552 | DD_Patch_ParticleDisableBit();
|
---|
| 553 |
|
---|
| 554 | if (patch_pathfinding)
|
---|
| 555 | DD_Patch_PathFinding();
|
---|
| 556 |
|
---|
| 557 | if (patch_projaware)
|
---|
| 558 | DD_Patch_ProjAware();
|
---|
| 559 |
|
---|
| 560 | if (patch_safeprintf)
|
---|
| 561 | DD_Patch_SafePrintf();
|
---|
| 562 |
|
---|
| 563 | if (patch_throwtest)
|
---|
| 564 | DD_Patch_Throwtest();
|
---|
| 565 |
|
---|
| 566 | if (patch_usedaodangl)
|
---|
| 567 | DD_Patch_UseDaodanGL();
|
---|
| 568 |
|
---|
| 569 | if (patch_usegettickcount)
|
---|
| 570 | DD_Patch_UseGetTickCount();
|
---|
| 571 |
|
---|
| 572 | if (patch_wpfadetime)
|
---|
| 573 | DD_Patch_WpFadetime();
|
---|
| 574 |
|
---|
| 575 |
|
---|
[877] | 576 | DD_Patch_DaodanInit();
|
---|
| 577 |
|
---|
[839] | 578 | DD_Patch_GammaSlider();
|
---|
| 579 |
|
---|
| 580 | DD_Patch_PrintWarning();
|
---|
| 581 |
|
---|
[876] | 582 |
|
---|
[875] | 583 | DD_Patch_ShowNames();
|
---|
[839] | 584 |
|
---|
[877] | 585 | if (patch_flatline)
|
---|
| 586 | DD_Patch_Flatline();
|
---|
[839] | 587 |
|
---|
| 588 | return true;
|
---|
| 589 | }
|
---|
| 590 |
|
---|