Changeset 995
- Timestamp:
- Apr 9, 2014, 2:10:18 AM (11 years ago)
- Location:
- Daodan/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/src/Daodan_Config.c
r994 r995 19 19 static const char* defaultSection = "options"; 20 20 21 static char invalidCurParamaters[1000] = ""; 22 static char invalidTotalParamaters[3000] = ""; 23 21 24 void DDrConfig_PrintHelp(); 22 25 … … 25 28 { "patches", "Patches", { 26 29 { "alttab", 27 "Allows user to switch applications while in Oni (Alt-Tab) and use Windows key, however it may enable the screensaver as well.",30 "Allows to Alt-Tab out of Oni and use Windows key. May enable the screensaver as well.", 28 31 C_BOOL, 29 32 {.intBoolVal = true}, 30 33 {.intBoolVal = true} }, 31 34 { "argb8888", 32 " Textures using ARGB8888 can be used.",35 "Allows using textures with ARGB8888.", 33 36 C_BOOL, 34 37 {.intBoolVal = true}, … … 39 42 {.intBoolVal = true}, 40 43 {.intBoolVal = true} }, 41 { "bsl",42 "Enables d_regen (unfinished) and prevents fly-in portraits from being stretched when playing in widescreen resolutions.",43 C_BOOL,44 {.intBoolVal = true},45 {.intBoolVal = true} },46 { "cheater",47 "Adds new cheat codes (see section below).",48 C_BOOL,49 {.intBoolVal = true},50 {.intBoolVal = true} },51 44 { "cheatsenabled", 52 45 "Enables cheats without having to beat the game first.", … … 55 48 {.intBoolVal = true} }, 56 49 { "cheattable", 57 "Replaces Oni's cheat table with table that includes new cheats (see section below).",50 "Replaces Oni's cheat table with table that includes new cheats including devmode.", 58 51 C_BOOL, 59 52 {.intBoolVal = true}, 60 53 {.intBoolVal = true} }, 61 54 { "chinese", 62 "Allow for chinese fonts to be shown .",55 "Allow for chinese fonts to be shown if the required DLL is available.", 63 56 C_BOOL, 64 57 {.intBoolVal = true}, … … 74 67 {.intBoolVal = true}, 75 68 {.intBoolVal = true} }, 69 { "d_regen", 70 "Enables script command d_regen (query/set regeneration for any character).", 71 C_BOOL, 72 {.intBoolVal = true}, 73 {.intBoolVal = true} }, 76 74 { "daodandisplayenum", 77 "Offers more display modes in the Options menu.",75 "Offers a more accurate list of available display modes in the Options menu.", 78 76 C_BOOL, 79 77 {.intBoolVal = true}, 80 78 {.intBoolVal = true} }, 81 79 { "directinput", 82 " Forces on DirectInput.",80 "Enforces the usage of DirectInput on every system. Should be off for Linux/Wine.", 83 81 C_BOOL, 84 82 {.intBoolVal = true}, 85 83 {.intBoolVal = true} }, 86 84 { "disablecmdline", 87 " Replaces existing command line parser with Daodan's in order to add new commands. Meant to be used with getcmdline.",85 "Disables Oni's existing command line parser as Daodan has its own.", 88 86 C_BOOL, 89 87 {.intBoolVal = true}, … … 94 92 {.intBoolVal = true}, 95 93 {.intBoolVal = true} }, 96 { "getcmdline",97 "Replaces existing command line parser with Daodan's in order to add new commands. Meant to be used with disablecmdline.",98 C_BOOL,99 {.intBoolVal = true},100 {.intBoolVal = true} },101 94 { "hdscreens_lowres", 102 "Allow HD screens with resolution < 1024*768.",95 "Allow HD intro/ending screens on game resolutions smaller than 1024x768.", 103 96 C_BOOL, 104 97 {.intBoolVal = true}, … … 110 103 {.intBoolVal = true} }, 111 104 { "kickguns", 112 "Unfinished, do not use.", 105 "EXPERIMENTAL! Unfinished, do not use.", 106 C_BOOL, 107 {.intBoolVal = false}, 108 {.intBoolVal = false} }, 109 { "killvtune", 110 "Prevent loading of vtuneapi.dll.", 113 111 C_BOOL, 114 112 {.intBoolVal = false}, … … 120 118 {.intBoolVal = true} }, 121 119 { "levelplugins", 122 "Allows level files to be loaded from the GDFwhich do not end in \"_Final\".",120 "Allows level files to be loaded which do not end in \"_Final\".", 123 121 C_BOOL, 124 122 {.intBoolVal = true}, 125 123 {.intBoolVal = true} }, 126 124 { "newweap", 127 " Picking upa weapon displays a message containing the weapon name and amount of ammo.",125 "Standing above a weapon displays a message containing the weapon name and amount of ammo.", 128 126 C_BOOL, 129 127 {.intBoolVal = true}, … … 139 137 {.intBoolVal = true}, 140 138 {.intBoolVal = true} }, 141 { "particledisablebit",142 "Unlocks particle action disabling/enabling bits for all events so that a particle event can occur multiple times.",143 C_BOOL,144 {.intBoolVal = false},145 {.intBoolVal = false} },146 139 { "pathfinding", 147 " Multiplies size of pathfinding grid cache by eightin order to prevent crashes in large levels.",140 "Size of pathfinding grid cache increased by eight times in order to prevent crashes in large levels.", 148 141 C_BOOL, 149 142 {.intBoolVal = true}, … … 165 158 {.intBoolVal = false} }, 166 159 { "showtriggervolumes", 167 "Allows BSL variable \"show_triggervolumes\" to work when set to 1.",160 "Allows BSL variable \"show_triggervolumes\" and Ctrl+Shift+X (in devmode) to work.", 168 161 C_BOOL, 169 162 {.intBoolVal = true}, 170 163 {.intBoolVal = true} }, 171 164 { "throwtest", 172 " Not recommended for use; experiment with allowing enemies to be thrown over railings.",165 "EXPERIMENTAL! Experiment with allowing enemies to be thrown over railings.", 173 166 C_BOOL, 174 167 {.intBoolVal = false}, 175 168 {.intBoolVal = false} }, 169 { "usedaodanbsl", 170 "Adds new BSL commands.", 171 C_BOOL, 172 {.intBoolVal = true}, 173 {.intBoolVal = true} }, 176 174 { "usedaodangl", 177 "Provides an improved windowed mode (-noswitch) ; this patch is known to break the hiding of the Windows taskbar in fullscreen mode.",175 "Provides an improved windowed mode (-noswitch).", 178 176 C_BOOL, 179 177 {.intBoolVal = true}, … … 181 179 { "usegettickcount", 182 180 "Replaces Oni's timing functions with more accurate ones.", 181 C_BOOL, 182 {.intBoolVal = true}, 183 {.intBoolVal = true} }, 184 { "widescreenportraits", 185 "Prevents fly-in portraits from being stretched when playing in widescreen resolutions.", 183 186 C_BOOL, 184 187 {.intBoolVal = true}, … … 193 196 { "options", "Options", { 194 197 { "border", 195 " If \"windowhack\" patch is active, make sure game window has border in windowed mode.",198 "Add a border if in windowed mode and \"usedaodangl\" patch is active.", 196 199 C_BOOL, 197 200 {.intBoolVal = true}, 198 201 {.intBoolVal = true} }, 199 202 { "debug", 200 " ???",203 "Not useful, probably does nothing.", 201 204 EXT_BOOL, 202 205 {.intBoolVal = false }, 203 206 {.extBoolVal = &AKgDebug_DebugMaps } }, 204 207 { "debugfiles", 205 " ???",208 "Not useful, probably does nothing.", 206 209 EXT_BOOL, 207 210 {.intBoolVal = false }, 208 211 {.extBoolVal = &BFgDebugFileEnable } }, 209 212 { "findsounds", 210 " ???",213 "Not useful, extends output of sound_list_broken_links.", 211 214 EXT_BOOL, 212 215 {.intBoolVal = false }, 213 216 {.extBoolVal = &SSgSearchOnDisk } }, 214 217 { "gamma", 215 "Enable gamma slider in fullscreen .",218 "Enable gamma slider in fullscreen, disable in windowed mode.", 216 219 C_BOOL, 217 220 {.intBoolVal = true}, … … 223 226 {.callback = DDrConfig_PrintHelp} }, 224 227 { "ignore_private_data", 225 " ? No effect ?",228 "Not useful, probably does nothing.", 226 229 EXT_BOOL, 227 230 {.intBoolVal = false }, 228 231 {.extBoolVal = &opt_ignore_private_data } }, 229 232 { "sound", 230 " ???",233 "Enable sound.", 231 234 EXT_BOOL, 232 235 {.intBoolVal = true }, 233 236 {.extBoolVal = &opt_sound } }, 234 237 { "switch", 235 " Always switch screen to resolution on Oni's Options screen, making the game fullscreen; opposite of Oni's built-in argument \"noswitch\".",238 "Switch to fullscreen instead of staying in a window.", 236 239 EXT_BOOL, 237 240 {.intBoolVal = true}, … … 242 245 {.intBoolVal = false}, 243 246 {.intBoolVal = false} }, 244 { "usedaodanbsl",245 "Adds new BSL commands (see below).",246 C_BOOL,247 {.intBoolVal = true},248 {.intBoolVal = true} },249 247 { "language", 250 248 "Localization for hardcoded strings (e.g. \"Savepoints\").", … … 480 478 STARTUPMESSAGE("Config value type unknown: %d", co->type); 481 479 } 480 } else { 481 char buf[50]; 482 sprintf_s(buf, sizeof(buf), " %s.%s\n", section, name); 483 if (strlen(buf) + strlen(invalidCurParamaters) < sizeof(invalidCurParamaters) - 1) { 484 strcpy(invalidCurParamaters + strlen(invalidCurParamaters), buf); 485 } 482 486 } 483 487 } … … 549 553 STARTUPMESSAGE("Finished parsing", 0); 550 554 551 555 if (strlen(invalidCurParamaters) > 0) 556 { 557 sprintf_s(invalidTotalParamaters, sizeof(invalidTotalParamaters), "In %s:\n%s\n", iniName, invalidCurParamaters); 558 invalidCurParamaters[0] = 0; 559 } 552 560 553 561 STARTUPMESSAGE("Parsing command line...", 0); … … 555 563 STARTUPMESSAGE("Finished parsing", 0); 556 564 565 if (strlen(invalidCurParamaters) > 0) 566 { 567 sprintf_s(invalidTotalParamaters, sizeof(invalidTotalParamaters), "%sOn command line:\n%s\n", invalidTotalParamaters, invalidCurParamaters); 568 } 569 570 if (strlen(invalidTotalParamaters) > 0) 571 { 572 char msg[3200]; 573 sprintf_s(msg, sizeof(msg), "Invalid parameters given:\n%sContinue launching Oni?", invalidTotalParamaters); 574 int res = MessageBox(NULL, msg, "Parameters invalid", MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1); 575 if (res == IDNO) { 576 exit(0); 577 } 578 } 579 557 580 // DDrConfig_Print(); 558 581 } -
Daodan/src/Daodan_Patch.c
r994 r995 42 42 { 43 43 int len = 0; 44 44 45 /* 45 DISASM MyDisasm; 46 int i = 0; 47 STARTUPMESSAGE("", 0); 48 STARTUPMESSAGE("", 0); 49 50 memset (&MyDisasm, 0, sizeof(DISASM)); 51 MyDisasm.EIP = (UIntPtr) from; 52 i = 0; 53 STARTUPMESSAGE("Orig before @ 0x%06x", from); 54 while (i<10){ 55 len = Disasm(&MyDisasm); 56 if (len != UNKNOWN_OPCODE) { 57 STARTUPMESSAGE("%s, Opcode: 0x%x, len: %d, branch: %d, to: 0x%06x", MyDisasm.CompleteInstr, MyDisasm.Instruction.Opcode, len, MyDisasm.Instruction.BranchType, MyDisasm.Instruction.AddrValue); 58 STARTUPMESSAGE(" Cat: 0x%04x, prefix count: %d", MyDisasm.Instruction.Category & 0xffff, MyDisasm.Prefix.Number ); 59 MyDisasm.EIP += (UIntPtr)len; 60 i++; 61 } 62 }; 63 STARTUPMESSAGE("", 0); 46 STARTUPMESSAGE("Orig before", 0); 47 DDrPatch_PrintDisasm(from, 10, 0); 64 48 */ 65 66 49 DISASM disasm; 67 50 memset(&disasm, 0, sizeof(DISASM)); … … 175 158 } 176 159 DDrPatch_MakeJump(from, to); 160 177 161 /* 178 memset (&MyDisasm, 0, sizeof(DISASM)); 179 MyDisasm.EIP = (UIntPtr) trampoline; 180 i = 0; 181 STARTUPMESSAGE("Trampoline @ 0x%06x", trampoline); 182 while (i<10){ 183 len = Disasm(&MyDisasm); 184 if (len != UNKNOWN_OPCODE) { 185 STARTUPMESSAGE("%s", MyDisasm.CompleteInstr); 186 MyDisasm.EIP += (UIntPtr)len; 187 i++; 188 } 189 }; 190 STARTUPMESSAGE("", 0); 191 192 memset (&MyDisasm, 0, sizeof(DISASM)); 193 MyDisasm.EIP = disasm.EIP; 194 i = 0; 195 STARTUPMESSAGE("Orig after @ 0x%06x", disasm.EIP); 196 while (i<7){ 197 len = Disasm(&MyDisasm); 198 if (len != UNKNOWN_OPCODE) { 199 STARTUPMESSAGE("%s", MyDisasm.CompleteInstr); 200 MyDisasm.EIP += (UIntPtr)len; 201 i++; 202 } 203 }; 204 STARTUPMESSAGE("", 0); 205 206 memset (&MyDisasm, 0, sizeof(DISASM)); 207 MyDisasm.EIP = (UIntPtr) from; 208 i = 0; 209 STARTUPMESSAGE("Orig start after @ 0x%06x", from); 210 while (i<3){ 211 len = Disasm(&MyDisasm); 212 if (len != UNKNOWN_OPCODE) { 213 STARTUPMESSAGE("%s", MyDisasm.CompleteInstr); 214 MyDisasm.EIP += (UIntPtr)len; 215 i++; 216 } 217 }; 218 STARTUPMESSAGE("", 0); 219 STARTUPMESSAGE("", 0); 220 STARTUPMESSAGE("", 0); 162 STARTUPMESSAGE("Trampoline", 0); 163 DDrPatch_PrintDisasm(trampoline, 10, 6); 164 165 STARTUPMESSAGE("Orig after", 0); 166 DDrPatch_PrintDisasm(disasm.EIP, 7, 0); 167 168 STARTUPMESSAGE("Orig start after", 0); 169 DDrPatch_PrintDisasm(from, 3, 6); 221 170 */ 222 223 171 return trampoline; 224 172 } -
Daodan/src/Oni/Symbols_Func.h
r992 r995 10 10 11 11 // Orig timing functions, replaced by DDrMachineTime_* if option "usegettickcount" is enabled 12 DefFunc(int64_t, UUrMachineTime_High, ONICALL, (), 0x0 4026480);13 DefFunc(double, UUrMachineTime_High_Frequency, ONICALL, (), 0x0 40264b0);14 DefFunc(int64_t, UUrMachineTime_Sixtieths, ONICALL, (), 0x0 40263e0);12 DefFunc(int64_t, UUrMachineTime_High, ONICALL, (), 0x00426480); 13 DefFunc(double, UUrMachineTime_High_Frequency, ONICALL, (), 0x004264b0); 14 DefFunc(int64_t, UUrMachineTime_Sixtieths, ONICALL, (), 0x004263e0); 15 15 16 16 // Code to initialize platform stuff (like disabling system key combination Alt+Tab) 17 DefFunc(void, UUrPlatform_Initialize, ONICALL, (), 0x0 4026010);18 DefFunc(void, UUrPlatform_Terminate, ONICALL, (), 0x0 4026310);17 DefFunc(void, UUrPlatform_Initialize, ONICALL, (), 0x00426010); 18 DefFunc(void, UUrPlatform_Terminate, ONICALL, (), 0x00426310); 19 19 20 20 // Oni's file access methods … … 39 39 // DD_GLrPlatform_Initialize/DD_GLrPlatform_Dispoose instead if daodangl is used. 40 40 DefFunc(UUtBool, gl_platform_initialize, ONICALL, (void), 0x00407da0); 41 DefFunc(void, gl_platform_dispose, ONICALL, (void), 0x 408210);41 DefFunc(void, gl_platform_dispose, ONICALL, (void), 0x00408210); 42 42 43 43 // Retrieve gamma value from settings … … 128 128 DefFunc(uint16_t, AI2iScript_Spawn, ONICALL, (sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret), 0x004B4780); 129 129 DefFunc(void, AI2rSmite, ONICALL, (Character *inCharacter, UUtBool inSpareCharacter), 0x0048BDA0); 130 //NOT USED: DefFunc(void*, OBJrObjectType_GetObject_ByNumber, ONICALL, (int inObjectType, int inIndex), );131 //NOT USED: DefFunc(int, OBJiObjectGroup_GetNumObjects, ONICALL, (void *inObjectGroup), );132 130 133 131 DefFunc(int, OBJrObjectType_EnumerateObjects, ONICALL, (int inObjectType, OBJtEnumCallback_Object inEnumCallback, int inUserData), 0x004D0080); 134 //DefFunc(void, OBJrTriggerVolume_IntersectsCharacter, ONICALL, (), 0x004cc680);135 132 136 133 DefFunc(void, OBJrDoor_Open, ONICALL, (DoorObject *inObject, Character *inCharacter), 0x004C26C0); … … 147 144 148 145 DefFunc(void, M3rGeom_Line_Light, ONICALL, (const M3tPoint3D *point1, const M3tPoint3D *point2, uint32_t shade), 0x0041f440); 149 /*150 DefFunc(void, M3rGeom_Line_Light, ONICALL, (), 0x0041f440);151 DefFunc(void, M3rMatrixStack_Push, ONICALL, (), 0x0041baa0);152 DefFunc(void, M3rMatrixStack_Get, ONICALL, (), 0x0041bb20);153 DefFunc(void, M3rMatrixStack_Pop, ONICALL, (), 0x0041bb30);154 DefFunc(void, M3rMatrixStack_Identity, ONICALL, (), 0x0041bba0);155 DefFunc(void, M3rMatrixStack_Rotate, ONICALL, (), 0x0041bbe0);156 DefFunc(void, M3rMatrixStack_UniformScale, ONICALL, (), 0x0041bc20);157 DefFunc(void, M3rMatrixStack_Translate, ONICALL, (), 0x0041bc40);158 DefFunc(void, M3rMatrixStack_Multiply, ONICALL, (), 0x0041bc70);159 DefFunc(void, M3rGeom_State_Commit, ONICALL, (), 0x0041e870);160 161 DefFunc(void, MUrPoint_Distance, ONICALL, (), 0x00433270);162 */163 146 164 147 // Make a dialog element (in)visible and change its position -
Daodan/src/Patches/BSL.c
r994 r995 13 13 #include "Character.h" 14 14 15 bool ONICALL argumentEmpty(sl_arg* arg) { 16 if ((arg->type == sl_str32) && (strlen(arg->val.value_str32) == 0)) 17 return true; 18 return false; 19 } 15 20 16 21 uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) … … 93 98 { 94 99 int index; 95 if ( numargs == 0) index = 0;100 if (argumentEmpty(&args[0])) index = 0; 96 101 else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); 97 102 else index = args[0].val.value_int32; … … 106 111 { 107 112 int index; 108 if ( numargs == 0) index = 0;113 if (argumentEmpty(&args[0])) index = 0; 109 114 else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); 110 115 else index = args[0].val.value_int32; … … 186 191 Character* Chr; 187 192 int* health; 188 if ( numargs == 0) index = 0;193 if (argumentEmpty(&args[0])) index = 0; 189 194 else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); 190 195 else index = args[0].val.value_int32; … … 207 212 int index; 208 213 Character* Chr; 209 if ( numargs == 0) index = 0;214 if (argumentEmpty(&args[0])) index = 0; 210 215 else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); 211 216 else index = args[0].val.value_int32; 212 217 Chr = ONgGameState->CharacterStorage ; 213 214 218 215 219 /* … … 311 315 { 312 316 int index; 313 if ( numargs == 0) index = 0;317 if (argumentEmpty(&args[0])) index = 0; 314 318 else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); 315 319 else index = args[0].val.value_int32; … … 336 340 337 341 int index; 338 if ( numargs == 0) index = 0;342 if (argumentEmpty(&args[0])) index = 0; 339 343 else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); 340 344 else index = args[0].val.value_int32; … … 356 360 char* name; 357 361 358 if ( numargs == 0) index = 0;362 if (argumentEmpty(&args[0])) index = 0; 359 363 else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); 360 364 else index = args[0].val.value_int32; … … 395 399 numargs++; 396 400 } 397 if( numargs == 0) return 0;401 if(argumentEmpty(&args[0])) return 0; 398 402 if(numargs > 1 ) color.R = (char)args[1].val.value_int32; 399 403 else color.R = 255; … … 693 697 { 694 698 args[1].val.value_int32 = (double)args[1].val.value_int32 / (double)(gl->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl->DisplayMode.Height)); 699 // Call orig OCiCinematic_ScriptStart 695 700 return ((sl_func)(OniExe + 0x000f3830))(callinfo, numargs, args, dontuse1, dontuse2, ret); 696 701 } … … 769 774 void SLrDaodan_Patch() 770 775 { 776 // PUSH OCiCinematic_ScriptStart -> PUSH cinematic_start_patch 771 777 DDrPatch_Int32((int*)(OniExe + 0x000f3755), (int)cinematic_start_patch); 772 778 } -
Daodan/src/Patches/Cheater.c
r994 r995 253 253 case cheat_elderrune: 254 254 { 255 ConfigOption_t* co = DDrConfig_GetOptOfType("patch.bsl", C_BOOL); 256 if (co->value.intBoolVal) 255 if (DDrConfig_GetOptOfType("patches.d_regen", C_BOOL)->value.intBoolVal) 257 256 { 258 257 int* Regeneration = &ONgGameState->PlayerCharacter->RegenHax; -
Daodan/src/Patches/Patches.c
r994 r995 85 85 void ONICALL DDrGame_Init() 86 86 { 87 ConfigOption_t* co = DDrConfig_GetOptOfType("options.usedaodanbsl", C_BOOL); 88 if (co->value.intBoolVal) 87 if (DDrConfig_GetOptOfType("patches.usedaodanbsl", C_BOOL)->value.intBoolVal) 89 88 SLrDaodan_Initialize(); 90 89 } … … 193 192 194 193 195 int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output) 196 { 197 //flags = (1 << 10); 198 type = 1; 199 //DDrPatch_Byte( 0x005EB83C + 3, 0xff ); 200 DDrPatch_Int32((int*)(OniExe + 0x001EB83C), 0xFF000000 ); 201 return M3rTextureMap_New(width, height, type, allocated, flags, name, output); 202 } 203 204 short DD_Patch_DebugNameShadeHack( Character* Char ) 205 { 206 return TSrContext_SetShade(*(void**)(OniExe + 0x001EB844), ONrCharacter_GetHealthShade( Char->Health, Char->MaxHealth )); 207 //return TSrContext_SetShade(*(void**)0x005EB844, 0xFFFFFFFF); 208 } 209 210 211 // Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the 212 // Windows key but has the possible side effect of allowing the screensaver 213 // to enable itself in-game. 214 void DD_Patch_AltTab() 215 { 216 // 0xC3 = ret, so makes those functions just have a "ret" instruction at their start 217 DDrPatch_Byte ((char*)UUrPlatform_Initialize, 0xC3); 218 DDrPatch_Byte ((char*)UUrPlatform_Terminate, 0xC3); 219 } 220 221 // Textures using ARGB8888 can be used 222 void DD_Patch_ARGB8888() 223 { 224 DDrPatch_Byte ((char*)(OniExe + 0x00135af0), 0x07); 225 DDrPatch_Byte ((char*)(OniExe + 0x00135af4), 0x0B); 226 } 227 228 // Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting 229 // instead of DirectDraw; patch ONiRunGame to use the same method to play 230 // outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the 231 // latter has problems on WINE). 232 void DD_Patch_BinkPlay() 233 { 234 // push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION. 235 DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02); 236 // call ONrMovie_Play_Hardware -> call ONrMovie_Play 237 DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play); 238 } 239 240 // Enables d_regen (unfinished) and prevents fly-in portraits from being 241 // stretched when playing in widescreen resolutions. 242 void DD_Patch_BSL() 243 { 244 //Calculating the value of the needed offset is much more reliable when the compiler does it for you. 245 246 //TODO: fix moonshadow. 194 // Enables d_regen script command. Instead of one global flag to only regenerate player each char has a flag to enable local regeneration 195 void DD_Patch_Regeneration() 196 { 197 // In: WPrInventory_Update 247 198 Character * Chr = 0; 248 199 int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF; 249 200 const unsigned char regen_patch[] = 250 201 {0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP 251 0x90, 0x90, // test al, al-> NOOP252 0x90, 0x90, 202 0x90, 0x90, // test al, al -> NOOP 203 0x90, 0x90, // jz short loc_51BB98 -> NOOP 253 204 0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8] 254 255 0x85, 0xC0, 256 0x74, 0x21 257 }; 205 // -> mov eax, [esi+Character.RegenHax] 206 0x85, 0xC0, // test eax, eax 207 0x74, 0x21 // jnz 0x21 -> jz 0x21 208 }; 258 209 DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch); 259 260 // Patches for existing BSL functions 261 SLrDaodan_Patch(); 262 } 263 264 // Adds new cheat codes if cheattable is also enabled 265 void DD_Patch_Cheater() 266 { 267 DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater); 268 DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590); 269 #if 1 270 DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames); 271 #endif 272 DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); 273 } 274 275 // Cheats always enabled 276 void DD_Patch_CheatsEnabled() 277 { 278 DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame); 279 } 280 281 // Use Daodan's own cheattable 282 void DD_Patch_CheatTable() 283 { 284 DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name); 285 DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on); 286 } 210 } 211 287 212 288 213 // Load chinese font DLL if available … … 312 237 } 313 238 314 // Limit cursor to Oni's window 315 void DD_Patch_ClipCursor() 316 { 317 // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. 318 DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); 319 320 // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. 321 DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); 322 323 // LIrTermiante: replace LIrPlatform_Terminate call with our hook. 324 DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); 325 } 326 327 // Disables weapon cooldown exploit 328 void DD_Patch_CooldownTimer() 329 { 330 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 }; 331 DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch); 332 } 333 334 // Daodan device mode enumeration function 335 void DD_Patch_DaodanDisplayEnum() 336 { 337 DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); 338 } 339 340 // Adds new BSL functions 341 void DD_Patch_DaodanInit() 342 { 343 DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init); 344 } 345 346 // Forced DirectInput (for Windows NT) 347 void DD_Patch_DirectInput() 348 { 349 DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb); 350 } 351 352 // Disable Oni's command line parser so it doesn't interfere with ours 353 void DD_Patch_DisableCmdLine() 354 { 355 // Replace start of OniParseCommandLine with XOR ax,ax; RET 356 // DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366); 357 // Replace start of OniParseCommandLine with XOR eax,eax; RET 358 DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0x00c3c033); 359 } 360 361 // Font texture cache doubled 362 void DD_Patch_FontTextureCache() 363 { 364 DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20); 365 DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40); 366 } 367 368 // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own) 369 void DD_Patch_GetCmdLine() 370 { 371 DDrPatch_NOOP ((char*)(OniExe + 0x000d3280), 51); 372 } 373 374 // Allow HD screens with resolution < 1024*768 375 void DD_Patch_HDScreens_LowRes() 376 { 377 DDrPatch_MakeJump((void*)M3rDraw_BigBitmap, (void*)DD_M3rDraw_BigBitmap); 378 } 379 380 void DD_Patch_HighresConsole() { 381 Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize); 382 } 383 384 // Hackish fix for Konoko not kicking guns 385 // Don't use this, it breaks stairs. 386 void DD_Patch_KickGuns() 387 { 388 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 }; 389 DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch); 390 } 391 392 // Disable loading the vtuneapi.dll 393 void DD_Patch_KillVTune() 394 { 395 DDrPatch_Byte ((char*)(OniExe + 0x00026340), 0xC3); 396 } 397 398 // Now supports textures up to 512x512 399 void DD_Patch_LargeTextures() 400 { 401 DDrPatch_Byte ((char*)(OniExe + 0x00005251), 0x10); 402 } 403 404 // Non-"_Final" levels are now valid 405 void DD_Patch_LevelPlugins() 406 { 407 DDrPatch_Byte ((char*)(OniExe + 0x000206a8), 0x01); 408 } 409 410 // Weapon on ground shown with name and magazine contents 411 void DD_Patch_NewWeap() 412 { 413 //Makes it always say "Received weapon_name." 414 //Needs check for loc_4DFC66 415 //DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2); 416 417 //Adds Weapon name and ammo meter to pickup autoprompt 418 DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9); 419 DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5); 420 DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message); 421 422 //Moves location of colors 423 //DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors ); 424 //DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors ); 425 } 426 427 // Disable Multi-byte character awareness patch (multiple language support) 428 void DD_Patch_NoMultiByte() 429 { 430 DDrPatch_Byte ((char*)(OniExe + 0x0002d8f8), 0xeb); 431 DDrPatch_Byte ((char*)(OniExe + 0x0002d9ad), 0xeb); 432 DDrPatch_Byte ((char*)(OniExe + 0x0002dbe2), 0xeb); 433 DDrPatch_Byte ((char*)(OniExe + 0x0002dec3), 0xeb); 434 DDrPatch_Byte ((char*)(OniExe + 0x0002e2ab), 0xeb); 435 DDrPatch_Byte ((char*)(OniExe + 0x0002e2c4), 0xeb); 436 DDrPatch_Byte ((char*)(OniExe + 0x0002e379), 0xeb); 437 DDrPatch_Byte ((char*)(OniExe + 0x0002e48c), 0xeb); 438 DDrPatch_Byte ((char*)(OniExe + 0x0002e4d0), 0xeb); 439 DDrPatch_Byte ((char*)(OniExe + 0x0002e4f4), 0xeb); 440 DDrPatch_Byte ((char*)(OniExe + 0x0002e646), 0xeb); 441 DDrPatch_Byte ((char*)(OniExe + 0x0002e695), 0xeb); 442 DDrPatch_Byte ((char*)(OniExe + 0x0002e944), 0xeb); 443 DDrPatch_Byte ((char*)(OniExe + 0x0002e95d), 0xeb); 444 DDrPatch_Byte ((char*)(OniExe + 0x0002e98e), 0xeb); 445 DDrPatch_Byte ((char*)(OniExe + 0x0002e9dc), 0xeb); 446 } 447 448 // Fix options not visible in main menu when a game was started 449 void DD_Patch_OptionsVisible() 450 { 451 DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton); 452 DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton); 453 } 454 455 // Unlocks particle action disabling/enabling bits for all events. (Will be 456 // controlled by a command line switch when I figure out how to do that without 457 // Win32 hacks.) 458 void DD_Patch_ParticleDisableBit() 459 { 460 DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090); 461 } 462 463 // Pathfinding grid cache size x8 464 void DD_Patch_PathFinding() 465 { 466 const unsigned char pathfinding[2] = {0x90 , 0xE9 }; 467 DDrPatch_Byte ((char*)(OniExe + 0x0010b03b), 0x20); 468 DDrPatch_Byte ((char*)(OniExe + 0x0010b04c), 0x20); 469 470 //other stuff 471 DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding); 472 } 473 474 // Projectile awareness fixed 475 void DD_Patch_ProjAware() 476 { 477 DDrPatch_Byte ((char*)(OniExe + 0x0009c07c), 0x6c); 478 DDrPatch_Byte ((char*)(OniExe + 0x0009c080), 0x70); 479 DDrPatch_Byte ((char*)(OniExe + 0x0009c084), 0x74); 480 DDrPatch_Byte ((char*)(OniExe + 0x0009c110), 0x6c); 481 } 482 483 // Safe startup message printer 484 void DD_Patch_SafePrintf() 485 { 486 DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage); 487 } 488 489 // Show all (also enemies') lasersights 490 void DD_Patch_ShowAllLasersights() 491 { 492 DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 ); 493 } 494 495 void DD_Patch_ShowTriggerVolumes() 496 { 497 Oni_ONrMechanics_Register = DDrPatch_MakeDetour((void*)ONrMechanics_Register, (void*)DD_ONrMechanics_Register); 498 Oni_ONrGameState_HandleUtilityInput = DDrPatch_MakeDetour((void*)ONrGameState_HandleUtilityInput, (void*)DD_ONrGameState_HandleUtilityInput); 499 } 500 501 // Experiment with allowing enemies to be thrown over railings 502 void DD_Patch_Throwtest() 503 { 504 const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; 505 DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch); 506 } 507 508 // DaodanGL with windowed mode support 509 void DD_Patch_UseDaodanGL() 510 { 511 // LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect. 512 DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6); 513 DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect); 514 515 // UUrWindow_GetSize: GetWindowRect -> GetClientRect. 516 DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); 517 DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); 518 519 // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. 520 DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); 521 DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos); 522 523 // LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates. 524 DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6); 525 DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos); 526 527 // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. 528 DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6); 529 DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos); 530 531 // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. 532 DDrPatch_NOOP((char*) OniExe + 0x00003349, 6); 533 DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos); 534 535 // Replace ONrPlatformInitialize. 536 DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize); 537 538 // Replace gl_platform_initialize. 539 DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize); 540 541 // Replace gl_platform_dispose. 542 DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose); 543 } 544 545 // Performance patch 546 void DD_Patch_UseGetTickCount() 547 { 548 DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High); 549 DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency); 550 DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths); 551 } 552 553 // Adds working function for existing BSL command wp_fadetime, sets fade time to 4800 554 void DD_Patch_WpFadetime() 555 { 556 // Makes wp_fadetime actually have a function 557 const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 }; 558 DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch); 559 DDrPatch_Byte ((char*)(OniExe + 0x0011a560), 0x31); 560 561 // Sets the fadetime to 4800 by default 562 DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0); 563 } 564 565 // Disable gamma slider in options in windowed mode 566 void DD_Patch_GammaSlider() 567 { 568 DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange); 569 } 570 571 // Fix the warning print method 572 void DD_Patch_PrintWarning() 573 { 574 DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning); 239 240 241 int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output) 242 { 243 //flags = (1 << 10); 244 type = 1; 245 //DDrPatch_Byte( 0x005EB83C + 3, 0xff ); 246 DDrPatch_Int32((int*)(OniExe + 0x001EB83C), 0xFF000000 ); 247 return M3rTextureMap_New(width, height, type, allocated, flags, name, output); 248 } 249 250 short DD_Patch_DebugNameShadeHack( Character* Char ) 251 { 252 return TSrContext_SetShade(*(void**)(OniExe + 0x001EB844), ONrCharacter_GetHealthShade( Char->Health, Char->MaxHealth )); 575 253 } 576 254 … … 599 277 } 600 278 601 /* 602 void DD_Patch_ShowTriggerVolumes() 603 { 604 DDrPatch_Int32((int*)(OniExe + 0x000cc9bb+4), (uint32_t)DD_OBJiTriggerVolume_Draw); 605 } 606 607 void DD_Patch_ShowFlags() 608 { 609 DDrPatch_Int32((int*)(OniExe + 0x000c4ed4+4), (uint32_t)DD_OBJiFlag_Draw); 610 } 611 */ 279 280 281 282 283 284 285 612 286 613 287 bool DD_Patch_Init() … … 615 289 STARTUPMESSAGE("Patching engine", 0); 616 290 291 // Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the 292 // Windows key but has the possible side effect of allowing the screensaver 293 // to enable itself in-game. 617 294 if (DDrConfig_GetOptOfType("patches.alttab", C_BOOL)->value.intBoolVal) 618 DD_Patch_AltTab(); 619 295 { 296 // 0xC3 = ret, so makes those functions just have a "ret" instruction at their start 297 DDrPatch_Byte((char*)UUrPlatform_Initialize, 0xC3); 298 DDrPatch_Byte((char*)UUrPlatform_Terminate, 0xC3); 299 } 300 301 // Textures using ARGB8888 can be used 620 302 if (DDrConfig_GetOptOfType("patches.argb8888", C_BOOL)->value.intBoolVal) 621 DD_Patch_ARGB8888(); 622 303 { 304 // Update conversion lookups in IMgConvertPixelType_List 305 DDrPatch_Byte((char*)(OniExe + 0x00135af0), 0x07); 306 DDrPatch_Byte((char*)(OniExe + 0x00135af4), 0x0B); 307 } 308 309 // Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting 310 // instead of DirectDraw; patch ONiRunGame to use the same method to play 311 // outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the 312 // latter has problems on WINE). 623 313 if (DDrConfig_GetOptOfType("patches.binkplay", C_BOOL)->value.intBoolVal) 624 DD_Patch_BinkPlay(); 625 626 if (DDrConfig_GetOptOfType("patches.bsl", C_BOOL)->value.intBoolVal) 627 DD_Patch_BSL(); 628 629 if (DDrConfig_GetOptOfType("patches.cheater", C_BOOL)->value.intBoolVal) 630 DD_Patch_Cheater(); 631 314 { 315 // push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION. 316 DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02); 317 // call ONrMovie_Play_Hardware -> call ONrMovie_Play 318 DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play); 319 } 320 321 if (DDrConfig_GetOptOfType("patches.d_regen", C_BOOL)->value.intBoolVal) 322 DD_Patch_Regeneration(); 323 324 // Cheats always enabled 632 325 if (DDrConfig_GetOptOfType("patches.cheatsenabled", C_BOOL)->value.intBoolVal) 633 DD_Patch_CheatsEnabled(); 634 326 { 327 DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame); 328 } 329 330 // Use Daodan's own cheattable 635 331 if (DDrConfig_GetOptOfType("patches.cheattable", C_BOOL)->value.intBoolVal) 636 DD_Patch_CheatTable(); 332 { 333 // In ONrGameState_HandleCheats: Replace pointers to orig cheattable 334 DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name); 335 DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on); 336 337 // ONrGameState_HandleCheats: Replace call to ONrCheater 338 DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater); 339 340 // In: ONrGameState_DoCharacterFrame 341 // -> NOP; PUSH ebp; CALL FallingFrames 342 // Replace fall height frame counter (actually in-air frame counter) increase by a 343 // conditional one (only counted when inc_fallingframes) 344 DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590); 345 DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames); 346 347 // At end of ONrUnlockLevel to init values on level loading 348 DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); 349 } 637 350 638 351 if (DDrConfig_GetOptOfType("patches.chinese", C_BOOL)->value.intBoolVal) 639 352 DD_Patch_Chinese(); 640 353 354 // Limit cursor to Oni's window 641 355 if (DDrConfig_GetOptOfType("patches.clipcursor", C_BOOL)->value.intBoolVal) 642 DD_Patch_ClipCursor(); 643 356 { 357 // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. 358 DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); 359 360 // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. 361 DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); 362 363 // LIrTerminate: replace LIrPlatform_Terminate call with our hook. 364 DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); 365 } 366 367 // Disables weapon cooldown exploit 644 368 if (DDrConfig_GetOptOfType("patches.cooldowntimer", C_BOOL)->value.intBoolVal) 645 DD_Patch_CooldownTimer(); 646 369 { 370 // In WPrRelease: NoOp 4 MOVs 371 DDrPatch_NOOP((char*)(OniExe + 0x0011a825), 22); 372 } 373 374 // Daodan device mode enumeration function 647 375 if (DDrConfig_GetOptOfType("patches.daodandisplayenum", C_BOOL)->value.intBoolVal) 648 DD_Patch_DaodanDisplayEnum(); 649 376 { 377 DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); 378 } 379 380 // Forced DirectInput (for Windows NT) 650 381 if (DDrConfig_GetOptOfType("patches.directinput", C_BOOL)->value.intBoolVal) 651 DD_Patch_DirectInput(); 652 382 { 383 // LIrPlatform_Initialize: replace conditional jump by unconditional 384 DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb); 385 } 386 387 // Disable Oni's command line parser so it doesn't interfere with ours 653 388 if (DDrConfig_GetOptOfType("patches.disablecmdline", C_BOOL)->value.intBoolVal) 654 DD_Patch_DisableCmdLine(); 655 389 { 390 // Replace start of OniParseCommandLine with XOR eax,eax; RET 391 DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0x00c3c033); 392 // NoOp first 51 byte in ONiMain, including tests and conditional exec of CLrGetCommandLine 393 DDrPatch_NOOP((char*)(OniExe + 0x000d3280), 51); 394 } 395 396 // Font texture cache doubled 656 397 if (DDrConfig_GetOptOfType("patches.fonttexturecache", C_BOOL)->value.intBoolVal) 657 DD_Patch_FontTextureCache(); 658 659 if (DDrConfig_GetOptOfType("patches.getcmdline", C_BOOL)->value.intBoolVal) 660 DD_Patch_GetCmdLine(); 661 398 { 399 // Double two values in TMrGame_Initialize 400 DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20); 401 DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40); 402 } 403 404 // Allow HD screens on resolutions < 1024*768 662 405 if (DDrConfig_GetOptOfType("patches.hdscreens_lowres", C_BOOL)->value.intBoolVal) 663 DD_Patch_HDScreens_LowRes(); 664 406 { 407 DDrPatch_MakeJump((void*)M3rDraw_BigBitmap, (void*)DD_M3rDraw_BigBitmap); 408 } 409 410 // Allow for console to show on higher resolutions 665 411 if (DDrConfig_GetOptOfType("patches.highres_console", C_BOOL)->value.intBoolVal) 666 DD_Patch_HighresConsole(); 667 412 { 413 Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize); 414 } 415 416 // Hackish fix for Konoko not kicking guns 417 // Don't use this, it breaks stairs. 668 418 if (DDrConfig_GetOptOfType("patches.kickguns", C_BOOL)->value.intBoolVal) 669 DD_Patch_KickGuns(); 670 671 //if (patch_killvtune) 672 // DD_Patch_KillVTune(); 673 419 { 420 // In ONrCharacter_EnablePhysics: Load different values to same addresses as before 421 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 }; 422 DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch); 423 } 424 425 // Disable loading the vtuneapi.dll 426 if (DDrConfig_GetOptOfType("patches.killvtune", C_BOOL)->value.intBoolVal) 427 { 428 // Instantly return from UUrLoadVtuneAPI 429 DDrPatch_Byte((char*)(OniExe + 0x00026340), 0xC3); 430 } 431 432 // Now supports textures up to 512x512 674 433 if (DDrConfig_GetOptOfType("patches.largetextures", C_BOOL)->value.intBoolVal) 675 DD_Patch_LargeTextures(); 676 434 { 435 DDrPatch_Byte((char*)(OniExe + 0x00005251), 0x10); 436 } 437 438 // Non-"_Final" levels are now valid 677 439 if (DDrConfig_GetOptOfType("patches.levelplugins", C_BOOL)->value.intBoolVal) 678 DD_Patch_LevelPlugins(); 679 440 { 441 // Patch in TMrUtility_LevelInfo_Get: 442 DDrPatch_Byte((char*)(OniExe + 0x000206a8), 0x01); 443 } 444 445 // Weapon on ground shown with name and magazine contents 680 446 if (DDrConfig_GetOptOfType("patches.newweap", C_BOOL)->value.intBoolVal) 681 DD_Patch_NewWeap(); 682 447 { 448 //Makes it always say "Received weapon_name." 449 //Needs check for loc_4DFC66 450 //DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2); 451 452 //Adds Weapon name and ammo meter to pickup autoprompt (patches to ONrGameState_ProcessHeartbeat) 453 // Do not call WPrHasAmmo and ignore conditional jump: 454 DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9); 455 // Do not load ecx with some magic value? 456 DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5); 457 // Replace call to ONiGameState_FindAutoPromptMessage 458 DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message); 459 460 //Moves location of colors 461 //DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors ); 462 //DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors ); 463 } 464 465 // Disable Multi-byte character awareness patch (multiple language support) 683 466 if (DDrConfig_GetOptOfType("patches.nomultibyte", C_BOOL)->value.intBoolVal) 684 DD_Patch_NoMultiByte(); 685 467 { 468 // TSiContext_DrawLine: Replace conditional jumps by unconditional ones 469 DDrPatch_Byte ((char*)(OniExe + 0x0002d8f8), 0xeb); 470 DDrPatch_Byte ((char*)(OniExe + 0x0002d9ad), 0xeb); 471 // TSiContext_DrawTextLine: same 472 DDrPatch_Byte ((char*)(OniExe + 0x0002dbe2), 0xeb); 473 DDrPatch_Byte ((char*)(OniExe + 0x0002dec3), 0xeb); 474 // TSrContext_FormatString: same 475 DDrPatch_Byte ((char*)(OniExe + 0x0002e2ab), 0xeb); 476 DDrPatch_Byte ((char*)(OniExe + 0x0002e2c4), 0xeb); 477 DDrPatch_Byte ((char*)(OniExe + 0x0002e379), 0xeb); 478 DDrPatch_Byte ((char*)(OniExe + 0x0002e48c), 0xeb); 479 DDrPatch_Byte ((char*)(OniExe + 0x0002e4d0), 0xeb); 480 DDrPatch_Byte ((char*)(OniExe + 0x0002e4f4), 0xeb); 481 DDrPatch_Byte ((char*)(OniExe + 0x0002e646), 0xeb); 482 DDrPatch_Byte ((char*)(OniExe + 0x0002e695), 0xeb); 483 // TSrContext_GetStringRect: same 484 DDrPatch_Byte ((char*)(OniExe + 0x0002e944), 0xeb); 485 DDrPatch_Byte ((char*)(OniExe + 0x0002e95d), 0xeb); 486 DDrPatch_Byte ((char*)(OniExe + 0x0002e98e), 0xeb); 487 DDrPatch_Byte ((char*)(OniExe + 0x0002e9dc), 0xeb); 488 } 489 490 // Fix options not visible in main menu when a game was started 686 491 if (DDrConfig_GetOptOfType("patches.optionsvisible", C_BOOL)->value.intBoolVal) 687 DD_Patch_OptionsVisible(); 688 689 if (DDrConfig_GetOptOfType("patches.particledisablebit", C_BOOL)->value.intBoolVal) 690 DD_Patch_ParticleDisableBit(); 691 492 { 493 // replace WMrWindow_SetVisible calls 494 DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton); 495 DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton); 496 } 497 498 // Pathfinding grid cache size x8 692 499 if (DDrConfig_GetOptOfType("patches.pathfinding", C_BOOL)->value.intBoolVal) 693 DD_Patch_PathFinding(); 694 500 { 501 // Replaces conditional jump (je) with unconditional jump 502 const unsigned char pathfinding[2] = {0x90 , 0xE9 }; 503 DDrPatch_Byte ((char*)(OniExe + 0x0010b03b), 0x20); 504 DDrPatch_Byte ((char*)(OniExe + 0x0010b04c), 0x20); 505 506 //other stuff 507 DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding); 508 } 509 510 // Projectile awareness fixed 695 511 if (DDrConfig_GetOptOfType("patches.projaware", C_BOOL)->value.intBoolVal) 696 DD_Patch_ProjAware(); 697 512 { 513 DDrPatch_Byte ((char*)(OniExe + 0x0009c07c), 0x6c); 514 DDrPatch_Byte ((char*)(OniExe + 0x0009c080), 0x70); 515 DDrPatch_Byte ((char*)(OniExe + 0x0009c084), 0x74); 516 DDrPatch_Byte ((char*)(OniExe + 0x0009c110), 0x6c); 517 } 518 519 // Safe startup message printer 698 520 if (DDrConfig_GetOptOfType("patches.safeprintf", C_BOOL)->value.intBoolVal) 699 DD_Patch_SafePrintf(); 700 521 { 522 DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage); 523 } 524 525 // Show all (also enemies') lasersights 701 526 if (DDrConfig_GetOptOfType("patches.showalllasersights", C_BOOL)->value.intBoolVal) 702 DD_Patch_ShowAllLasersights(); 703 527 { 528 DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 ); 529 } 530 531 // Allow bsl-var show_triggervolumes or ctrl+shift+x (devmode) to work 704 532 if (DDrConfig_GetOptOfType("patches.showtriggervolumes", C_BOOL)->value.intBoolVal) 705 DD_Patch_ShowTriggerVolumes(); 706 533 { 534 Oni_ONrMechanics_Register = DDrPatch_MakeDetour((void*)ONrMechanics_Register, (void*)DD_ONrMechanics_Register); 535 Oni_ONrGameState_HandleUtilityInput = DDrPatch_MakeDetour((void*)ONrGameState_HandleUtilityInput, (void*)DD_ONrGameState_HandleUtilityInput); 536 } 537 538 // Experiment with allowing enemies to be thrown over railings 707 539 if (DDrConfig_GetOptOfType("patches.throwtest", C_BOOL)->value.intBoolVal) 708 DD_Patch_Throwtest(); 709 540 { 541 DDrPatch_NOOP((char*)(OniExe + 0x000dc190), 10); 542 } 543 544 // DaodanGL with windowed mode support 710 545 if (DDrConfig_GetOptOfType("patches.usedaodangl", C_BOOL)->value.intBoolVal) 711 DD_Patch_UseDaodanGL(); 712 546 { 547 // LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect. 548 DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6); 549 DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect); 550 551 // UUrWindow_GetSize: GetWindowRect -> GetClientRect. 552 DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); 553 DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); 554 555 // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. 556 DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); 557 DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos); 558 559 // LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates. 560 DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6); 561 DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos); 562 563 // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. 564 DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6); 565 DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos); 566 567 // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. 568 DDrPatch_NOOP((char*) OniExe + 0x00003349, 6); 569 DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos); 570 571 // Replace ONrPlatformInitialize. 572 DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize); 573 574 // Replace gl_platform_initialize. 575 DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize); 576 577 // Replace gl_platform_dispose. 578 DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose); 579 } 580 581 // Performance patch 713 582 if (DDrConfig_GetOptOfType("patches.usegettickcount", C_BOOL)->value.intBoolVal) 714 DD_Patch_UseGetTickCount(); 715 583 { 584 DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High); 585 DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency); 586 DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths); 587 } 588 589 // Fix displaying the talking portraits in widescreen modes 590 if (DDrConfig_GetOptOfType("patches.widescreenportraits", C_BOOL)->value.intBoolVal) 591 { 592 SLrDaodan_Patch(); 593 } 594 595 // Adds working function for existing BSL command wp_fadetime, sets fade time to 4800 716 596 if (DDrConfig_GetOptOfType("patches.wpfadetime", C_BOOL)->value.intBoolVal) 717 DD_Patch_WpFadetime(); 718 719 720 DD_Patch_DaodanInit(); 721 722 DD_Patch_GammaSlider(); 723 724 DD_Patch_PrintWarning(); 597 { 598 // Makes wp_fadetime actually have a function (changes within WPrRelease) 599 // Patches end of function to instead of use a constant value for fadetime (12c0 = 4800) actually use value of wp_fadetime: 600 // orig: MOV [esi+0x46], 0x12c0 ; POP ebx ; POP esi ; ADD esp, 0x14 ; RET 601 // new: MOV bx, [0x627dc4] ; MOV [esi+0x46], bx ; POP ebx ; POP esi ; ADD esp, 0x14 ; RET 602 const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 }; 603 DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch); 604 // Fixes jump because of new length of code in patch 605 DDrPatch_Byte ((char*)(OniExe + 0x0011a560), 0x31); 606 607 // Sets the fadetime to 4800 by default (in WPrInitialize) 608 DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 4800); 609 } 610 611 // Adds new BSL functions 612 // Replaces an early unused call (OBJrLevel_Unload_Unknown_2) in ONiMain 613 DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init); 614 615 // Disable gamma slider in options in windowed mode 616 // In ONiOGU_Options_Callback: Replace WMrSlider_SetRange 617 DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange); 618 619 // Fix the warning print method 620 // Replace UUrError_Report_Internal 621 DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning); 725 622 726 623 DD_Patch_ShowNames();
Note:
See TracChangeset
for help on using the changeset viewer.