├── .gitignore ├── LICENSE ├── README.md ├── th2-patch-banner.png ├── th2patch ├── hawk2.sln └── hawk2 │ ├── Checksum.cpp │ ├── Checksum.h │ ├── GameOptions.cpp │ ├── GameOptions.h │ ├── color.cpp │ ├── color.h │ ├── cpatch.h │ ├── hawk2.cpp │ ├── hawk2.def │ ├── hawk2.h │ ├── hawk2.vcxproj │ ├── hawk2.vcxproj.filters │ ├── hawk2.vcxproj.user │ ├── hawk2_utils.cpp │ ├── hawk2_utils.h │ ├── info │ ├── THawk2_source_names.txt │ ├── classes.md │ └── hooking_tutorial.md │ ├── lib │ ├── ini │ │ ├── IniReader.cpp │ │ ├── IniReader.h │ │ ├── IniWriter.cpp │ │ ├── IniWriter.h │ │ └── readme.md │ ├── readme.md │ ├── sqlite │ │ ├── readme.md │ │ ├── sqlite3.exp │ │ └── sqlite3.h │ └── xinput │ │ ├── CXBOXController.cpp │ │ ├── CXBOXController.h │ │ └── readme.md │ ├── mydebug.cpp │ ├── mydebug.h │ ├── patch │ ├── _patch.h │ ├── hook.cpp │ └── hook.h │ ├── patchStuff.cpp │ ├── patchStuff.h │ ├── stdafx.cpp │ ├── stdafx.h │ └── thawk2 │ ├── CBruce.cpp │ ├── CBruce.h │ ├── CClass.cpp │ ├── CClass.h │ ├── CMenu.cpp │ ├── CMenu.h │ ├── CVector.cpp │ ├── Career.cpp │ ├── Career.h │ ├── Crowd.h │ ├── Flash.cpp │ ├── Flash.h │ ├── Globals.cpp │ ├── Globals.h │ ├── IO │ ├── FileIO.cpp │ ├── FileIO.h │ └── PCIO.h │ ├── Init.cpp │ ├── Init.h │ ├── LoadingScreen.h │ ├── Mem.cpp │ ├── Mem.h │ ├── Mess.cpp │ ├── Mess.h │ ├── PCInput.cpp │ ├── PCInput.h │ ├── PCMovie.cpp │ ├── PCMovie.h │ ├── PKR.cpp │ ├── PKR.h │ ├── Pad.cpp │ ├── Pad.h │ ├── Physics.cpp │ ├── Physics.h │ ├── Rail.cpp │ ├── Rail.h │ ├── Redbook.cpp │ ├── Redbook.h │ ├── Render.cpp │ ├── Render.h │ ├── Sfx.h │ ├── Shatter.cpp │ ├── Shatter.h │ ├── SkatMgr.h │ ├── SkaterProfile.h │ ├── Soundlib.h │ ├── Spool.cpp │ ├── Spool.h │ ├── Utils.cpp │ ├── Utils.h │ ├── WinMain.cpp │ ├── WinMain.h │ ├── _old.h │ ├── career │ ├── custom_goals.cpp │ └── custom_goals.h │ ├── gaps │ ├── gaps.cpp │ ├── gaps.h │ ├── thps1.cpp │ ├── thps2.cpp │ ├── thps3.cpp │ └── thps4.cpp │ ├── gte.cpp │ ├── gte.h │ ├── m3d.h │ ├── pal.cpp │ ├── pal.h │ ├── powerup.cpp │ ├── powerup.h │ ├── readme.md │ ├── thawk2.h │ └── types.h ├── th2patcheditmusic ├── readme.md ├── sql_music_import.bat ├── sql_music_list.csv └── sql_music_params.txt └── th2patchlauncher ├── th2patchlauncher.sln └── th2patchlauncher ├── ErrorMsg.cs ├── LauncherForm.Designer.cs ├── LauncherForm.cs ├── LauncherForm.resx ├── Patch ├── Helpers.cs ├── LevelPatch.cs ├── MainPatch.cs ├── Mem.cs ├── Options.cs └── Resolutions.cs ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Resources ├── th2.ico ├── th22logo.jpg └── th2_optim.ico ├── app.config ├── icon ├── optim │ ├── icon0.png │ ├── icon1.png │ ├── icon2.png │ ├── icon3.png │ ├── icon4.png │ ├── icon5.png │ └── output.ico └── source │ ├── icon0.png │ ├── icon1.png │ ├── icon2.png │ ├── icon3.png │ ├── icon4.png │ └── icon5.png ├── packages.config ├── th2patchlauncher.csproj └── th2patchlauncher.csproj.user /.gitignore: -------------------------------------------------------------------------------- 1 | packages/ 2 | [Tt]emp/ 3 | 4 | # visual studio junk 5 | .vs 6 | 7 | #unused stuff 8 | _junk 9 | 10 | #compiled stuff 11 | [Dd]ebug 12 | [Rr]elease 13 | *.pdb 14 | 15 | # not sure if needed 16 | *.sdf 17 | 18 | # archives, just in case 19 | *.zip 20 | *.rar 21 | *.7z 22 | 23 | # Prerequisites 24 | *.d 25 | 26 | # Compiled Object files 27 | *.slo 28 | *.lo 29 | *.o 30 | *.obj 31 | *.suo 32 | *.exp 33 | 34 | # Precompiled Headers 35 | *.gch 36 | *.pch 37 | 38 | # Compiled Dynamic libraries 39 | *.so 40 | *.dylib 41 | *.dll 42 | 43 | # Fortran module files 44 | *.mod 45 | *.smod 46 | 47 | # Compiled Static libraries 48 | *.lai 49 | *.la 50 | *.a 51 | *.lib 52 | 53 | # Executables 54 | *.exe 55 | *.out 56 | *.app -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cumulative Patch for Tony Hawk's Pro Skater 2 PC 2 | This cumulative patch allows you to run THPS2 at a modern widescreen resolution in 32 bits color depth without FPS limit. 3 | 4 | ## Installation 5 | [__Download latest patch release here__](https://github.com/DCxDemo/THPS2-Cumulative-Patch/releases/latest) \ 6 | For thorough patch installation instructions please refer to the [__user guide__](https://github.com/DCxDemo/THPS2-Cumulative-Patch/wiki). \ 7 | For additional support join LegacyTHPS Discord: https://discord.gg/vTWucHS 8 | 9 | ## Key features 10 | * unlocked FPS, 32 bits, any resolution up to 2048 (DirectDraw limit) 11 | * increased fog distance, field of view 12 | * XInput controllers support 13 | * additional levels support (from [LevelPack](http://www.thps-mods.com/forum/viewtopic.php?t=1041)) 14 | * additional skater styles support 15 | * unlimited custom soundtrack support, R3 skips track 16 | * restored rail balance bar 17 | * bonus: start+select on the controller quits the game instantly 18 | 19 | ![THPS2 Cumulative Patch](th2-patch-banner.png) 20 | 21 | ## Building 22 | The patch is being developed in Visual Studio 2022. \ 23 | There are 2 solutions: 24 | * ```th2patch``` - patch DLL written in C++ 25 | * ```th2patchlauncher``` - launcher app written in C# (.NET Framework 4.6.2). \ 26 | Make sure $(ProjectDir) is added to Additional include directories. \ 27 | Make sure target binary is called dinput.dll, could be hawk2.dll by default \ 28 | 29 | Make sure to install launcher dependencies (via NuGet): 30 | * ini-parser - https://github.com/rickyah/ini-parser 31 | 32 | ## Decompilation effort 33 | There is a minor decompilation effort done for this project. If you want to contribute, make sure you're familiar with Ghidra, pointers and C++ classes: 34 | * https://github.com/DCxDemo/THPS2-Cumulative-Patch/tree/main/th2patch/hawk2/info 35 | 36 | Available decomp progress is stored in a "thawk2" subfolder over here: 37 | * https://github.com/DCxDemo/THPS2-Cumulative-Patch/tree/main/th2patch/hawk2/thawk2 38 | 39 | ## Links 40 | * [LegacyTHPS Discord](https://discord.gg/vTWucHS) 41 | * [Video preview of the patch](https://www.youtube.com/watch?v=1eHHqhsgC6w) 42 | * [Original thps-mods thread](http://www.thps-mods.com/forum/viewtopic.php?t=5429) 43 | * [Installation and troubleshooting](https://github.com/DCxDemo/THPS2-Cumulative-Patch/wiki) 44 | 45 | 2016-2018, 2022-2024, DCxDemo*. -------------------------------------------------------------------------------- /th2-patch-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2-patch-banner.png -------------------------------------------------------------------------------- /th2patch/hawk2.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34202.233 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hawk2", "hawk2\hawk2.vcxproj", "{A793407F-EF50-4BDF-8B9E-AC231AA2ECD8}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{98A6A76C-3BAD-4E29-A575-2D5CC4B2A7A0}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A793407F-EF50-4BDF-8B9E-AC231AA2ECD8}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {A793407F-EF50-4BDF-8B9E-AC231AA2ECD8}.Debug|Win32.Build.0 = Debug|Win32 18 | {A793407F-EF50-4BDF-8B9E-AC231AA2ECD8}.Release|Win32.ActiveCfg = Release|Win32 19 | {A793407F-EF50-4BDF-8B9E-AC231AA2ECD8}.Release|Win32.Build.0 = Release|Win32 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | GlobalSection(ExtensibilityGlobals) = postSolution 25 | SolutionGuid = {5944664F-FA6D-4A54-BF53-4736332525A1} 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /th2patch/hawk2/Checksum.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | unsigned int checksum(char* pText) 4 | { 5 | unsigned int result; 6 | char v2; 7 | char* i; 8 | char v4; 9 | signed int v5; 10 | 11 | result = -1; 12 | 13 | v2 = *pText; 14 | 15 | for (i = pText + 1; v2; ++i) 16 | { 17 | v4 = result ^ v2; 18 | v5 = 8; 19 | 20 | do 21 | { 22 | result = (result >> 31) | 2 * result; 23 | 24 | if (v4 & 1) result ^= 0xEDB88320; 25 | 26 | v4 >>= 1; 27 | 28 | --v5; 29 | 30 | } while (v5); 31 | 32 | v2 = *i; 33 | } 34 | 35 | return result; 36 | } 37 | 38 | /* 39 | //some other checksum from demo, check for textures? 40 | unsigned int checksum2(uint param_1, uint param_2, int param_3) 41 | 42 | { 43 | uint uVar1; 44 | int iVar2; 45 | 46 | uVar1 = 0; 47 | param_1 = param_1 ^ (param_2 & 0xff) * 0xf26d; 48 | iVar2 = 0; 49 | do { 50 | uVar1 = uVar1 << 1 | uVar1 >> 0x1f; 51 | if ((param_1 & 1) != 0) { 52 | uVar1 = uVar1 ^ 0x4517215a; 53 | } 54 | iVar2 = iVar2 + 1; 55 | param_1 = param_1 >> 1; 56 | } while (iVar2 < 0x20); 57 | uVar1 = uVar1 & 0xfffffe00 | param_2 & 0xff; 58 | if (param_3 != 0) { 59 | uVar1 = uVar1 ^ 0x100; 60 | } 61 | return uVar1 ^ 0xaf350f23; 62 | } 63 | */ -------------------------------------------------------------------------------- /th2patch/hawk2/Checksum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | unsigned int checksum(char* pText); -------------------------------------------------------------------------------- /th2patch/hawk2/GameOptions.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include "lib\ini\IniReader.h" 4 | #include "lib\ini\IniWriter.h" 5 | 6 | #include "GameOptions.h" 7 | #include "patchStuff.h" 8 | 9 | GameOptions::GameOptions() 10 | { 11 | iniPath = "./th2_opt.cfg"; 12 | } 13 | 14 | void GameOptions::Load() 15 | { 16 | totalTracks = CountSongs(); 17 | 18 | CIniReader* ini = new CIniReader(iniPath); 19 | 20 | printf("Loading settings from %s\r\n", iniPath); 21 | 22 | //patch section 23 | CurrentGame = ini->ReadString("PATCH", "Game", "THPS2"); 24 | DickSwap = ini->ReadString("PATCH", "DickSwap", ""); 25 | SkipIntro = ini->ReadBool("PATCH", "SkipIntro", false); 26 | SeparateSaves = ini->ReadBool("PATCH", "SeparateSaves", true); 27 | AddSkins = ini->ReadBool("PATCH", "MoreSkins", false); 28 | 29 | FreeStats = ini->ReadBool("PATCH", "FreeStats", false); 30 | DisableVisToggle = ini->ReadBool("PATCH", "DisableVisToggle", false); 31 | DisableSky = ini->ReadBool("PATCH", "DisableSky", false); 32 | RailBalanceBar = ini->ReadBool("PATCH", "RailBalanceBar", true); 33 | FontScale = ini->ReadFloat("PATCH", "FontScale", 1.0f); 34 | 35 | //video section 36 | ShowHUD = ini->ReadBool("VIDEO", "ShowHUD", true); 37 | DrawShadow = ini->ReadBool("VIDEO", "DrawShadow", true); 38 | Force32bpp = ini->ReadBool("VIDEO", "Force32bpp", true); 39 | UnlockFPS = ini->ReadBool("VIDEO", "UnlockFps", true); 40 | DisableNewTex = ini->ReadBool("VIDEO", "DisableNewTex", false); 41 | ResX = ini->ReadInt("VIDEO", "ResX", DEFAULT_WIDTH); 42 | ResY = ini->ReadInt("VIDEO", "ResY", DEFAULT_HEIGHT); 43 | DynamicLighting = ini->ReadBool("VIDEO", "DynamicLighting", true); 44 | 45 | bool overrideFov = ini->ReadBool("VIDEO", "OverrideFov", false); 46 | FovScale = overrideFov ? ini->ReadFloat("VIDEO", "FovScale", 1.0) : 1.0; 47 | 48 | //input section 49 | XInput = ini->ReadBool("INPUT", "XInput", true); 50 | StickDeadzone = ini->ReadInt("INPUT", "StickDeadzone", DEFAULT_DEADZONE); 51 | Vibration = ini->ReadBool("INPUT", "Vibration", true); 52 | BigDrop = ini->ReadBool("INPUT", "BigDrop", true); 53 | Manuals = ini->ReadBool("Input", "Manuals", true); 54 | AutoKick = ini->ReadBool("INPUT", "AutoKick", true); 55 | FastQuit = ini->ReadBool("INPUT", "FastQuit", true); 56 | 57 | //music section 58 | PlayRandom = ini->ReadBool("MUSIC", "Random", true); 59 | Fade = ini->ReadBool("MUSIC", "Fade", true); 60 | ShowTitle = ini->ReadBool("MUSIC", "ShowTitle", true); 61 | PlayAmbience = ini->ReadBool("MUSIC", "PlayAmbience", true); 62 | SeparateTracks = ini->ReadBool("MUSIC", "SeparateTracks", true); 63 | 64 | delete ini; 65 | 66 | Save(); 67 | 68 | printf("Settings loaded.\r\n"); 69 | } 70 | 71 | void GameOptions::Save() 72 | { 73 | CIniWriter* ini = new CIniWriter(iniPath); 74 | 75 | printf("Saving settings to %s\r\n", iniPath); 76 | 77 | //patch section 78 | ini->WriteString("PATCH", "Game", &CurrentGame[0]); 79 | ini->WriteInt("PATCH", "SeparateSaves", SeparateSaves); 80 | ini->WriteInt("PATCH", "SkipIntro", SkipIntro); 81 | ini->WriteInt("PATCH", "MoreSkins", AddSkins); 82 | ini->WriteString("PATCH", "DickSwap", &DickSwap[0]); 83 | ini->WriteInt("PATCH", "FreeStats", FreeStats); 84 | ini->WriteInt("PATCH", "DisableVisToggle", DisableVisToggle); 85 | ini->WriteInt("PATCH", "DisableSky", DisableSky); 86 | 87 | //video section 88 | ini->WriteInt("VIDEO", "ShowHUD", ShowHUD); 89 | ini->WriteInt("VIDEO", "DrawShadow", DrawShadow); 90 | ini->WriteInt("VIDEO", "Force32bpp", Force32bpp); 91 | ini->WriteInt("VIDEO", "UnlockFps", UnlockFPS); 92 | ini->WriteInt("VIDEO", "DisableNewTex", DisableNewTex); 93 | ini->WriteInt("VIDEO", "ResX", ResX); 94 | ini->WriteInt("VIDEO", "ResY", ResY); 95 | ini->WriteInt("VIDEO", "DynamicLighting", DynamicLighting); 96 | 97 | //input section 98 | ini->WriteInt("INPUT", "XInput", XInput); 99 | ini->WriteInt("INPUT", "StickDeadzone", StickDeadzone); 100 | ini->WriteInt("INPUT", "Vibration", Vibration); 101 | ini->WriteInt("INPUT", "BigDrop", BigDrop); 102 | ini->WriteInt("INPUT", "Manuals", Manuals); 103 | 104 | //music section 105 | ini->WriteInt("MUSIC", "Random", PlayRandom); 106 | ini->WriteInt("MUSIC", "Fade", Fade); 107 | ini->WriteInt("MUSIC", "ShowTitle", ShowTitle); 108 | ini->WriteInt("MUSIC", "PlayAmbience", PlayAmbience); 109 | ini->WriteInt("MUSIC", "SeparateTracks", SeparateTracks); 110 | 111 | delete ini; 112 | 113 | printf("Settings saved.\r\n"); 114 | } -------------------------------------------------------------------------------- /th2patch/hawk2/GameOptions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DEFAULT_WIDTH 1280 4 | #define DEFAULT_HEIGHT 720 5 | #define DEFAULT_DEADZONE 10000 6 | 7 | using namespace std; 8 | 9 | class GameOptions 10 | { 11 | private: 12 | char* iniPath; 13 | 14 | public: 15 | //patch 16 | string CurrentGame = "THPS2"; 17 | bool SeparateSaves = true; 18 | bool SkipIntro = false; 19 | bool AddSkins = false; 20 | string DickSwap = ""; 21 | bool FreeStats = false; 22 | bool DisableVisToggle = false; 23 | bool DisableSky = false; 24 | bool RailBalanceBar = true; 25 | 26 | //video 27 | bool ShowHUD = true; 28 | bool DrawShadow = true; 29 | bool Force32bpp = true; 30 | bool UnlockFPS = true; 31 | bool DisableNewTex = false; 32 | //float FOV = 0.83f; 33 | int ResX = DEFAULT_WIDTH; 34 | int ResY = DEFAULT_HEIGHT; 35 | float FontScale = 1.0; 36 | float FovScale = 1.0; 37 | bool DynamicLighting = true; 38 | 39 | //input 40 | bool XInput = true; 41 | int StickDeadzone = DEFAULT_DEADZONE; 42 | bool Vibration = true; 43 | bool BigDrop = true; 44 | bool Manuals = true; 45 | bool AutoKick = true; 46 | bool FastQuit = true; 47 | 48 | //music 49 | bool Fade = true; 50 | bool PlayRandom = true; 51 | bool ShowTitle = true; 52 | bool PlayAmbience = true; 53 | bool SeparateTracks = true; 54 | 55 | int totalTracks = 0; 56 | 57 | GameOptions(); 58 | void Save(); 59 | void Load(); 60 | }; -------------------------------------------------------------------------------- /th2patch/hawk2/color.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "color.h" 3 | 4 | ColorRGB Color_Black() { ColorRGB c = { 0,0,0 }; return c; } 5 | ColorRGB Color_DarkGray() { ColorRGB c = { 0x40, 0x40,0x40 }; return c; } 6 | ColorRGB Color_Gray() { ColorRGB c = { 0x80,0x80,0x80 }; return c; } 7 | ColorRGB Color_LightGray() { ColorRGB c = { 0xC0,0xC0,0xC0 }; return c; } 8 | ColorRGB Color_White() { ColorRGB c = { 0xFF,0xFF,0xFF }; return c; } 9 | 10 | ColorRGB Color_Red() { ColorRGB c = { 0xFF,0,0 }; return c; } 11 | ColorRGB Color_Green() { ColorRGB c = { 0,0xFF,0 }; return c; } 12 | ColorRGB Color_Blue() { ColorRGB c = { 0,0,0xFF }; return c; } 13 | ColorRGB Color_Magenta() { ColorRGB c = { 0xFF,0,0xFF }; return c; } 14 | ColorRGB Color_Cyan() { ColorRGB c = { 0,0xFF,0xFF }; return c; } 15 | ColorRGB Color_Yellow() { ColorRGB c = { 0xFF,0xFF,0 }; return c; } -------------------------------------------------------------------------------- /th2patch/hawk2/color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define COLOR_BLACK 0x000000 4 | #define COLOR_DARKGRAY 0x808080 5 | #define COLOR_GRAY 0x808080 6 | #define COLOR_LIGHTGRAY 0xC0C0C0 7 | #define COLOR_WHITE 0xffffff 8 | 9 | #define COLOR_RED 0x0000ff 10 | #define COLOR_DARKRED 0x000080 11 | #define COLOR_GREEN 0x00ff00 12 | #define COLOR_DARKGREEN 0x008000 13 | #define COLOR_BLUE 0xff0000 14 | #define COLOR_DARKBLUE 0x800000 15 | 16 | typedef struct 17 | { 18 | unsigned char R; 19 | unsigned char G; 20 | unsigned char B; 21 | } ColorRGB; 22 | 23 | typedef struct 24 | { 25 | unsigned char R; 26 | unsigned char G; 27 | unsigned char B; 28 | unsigned char A; 29 | } ColorRGBA; 30 | 31 | typedef struct 32 | { 33 | unsigned char B; 34 | unsigned char G; 35 | unsigned char R; 36 | unsigned char A; 37 | } ColorBGRA; 38 | 39 | ColorRGB Color_Black(); 40 | ColorRGB Color_DarkGray(); 41 | ColorRGB Color_Gray(); 42 | ColorRGB Color_LightGray(); 43 | ColorRGB Color_White(); 44 | 45 | ColorRGB Color_Red(); 46 | ColorRGB Color_Green(); 47 | ColorRGB Color_Blue(); 48 | ColorRGB Color_Magenta(); 49 | ColorRGB Color_Cyan(); 50 | ColorRGB Color_Yellow(); -------------------------------------------------------------------------------- /th2patch/hawk2/cpatch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CPatch 7 | { 8 | private: 9 | inline static void Patch(void* address, void* data, int size) 10 | { 11 | unsigned long protect[2]; 12 | VirtualProtect(address, size, PAGE_EXECUTE_READWRITE, &protect[0]); 13 | memcpy(address, data, size); 14 | VirtualProtect(address, size, protect[0], &protect[1]); 15 | } 16 | public: 17 | inline static void Nop(int address, int size) 18 | { 19 | unsigned long protect[2]; 20 | VirtualProtect((void *)address, size, PAGE_EXECUTE_READWRITE, &protect[0]); 21 | memset((void *)address, 0x90, size); 22 | VirtualProtect((void *)address, size, protect[0], &protect[1]); 23 | } 24 | inline static void RedirectCall(int address, void *func) 25 | { 26 | int temp = 0xE8; 27 | Patch((void *)address, &temp, 1); 28 | temp = (int)func - ((int)address + 5); 29 | Patch((void *)((int)address + 1), &temp, 4); 30 | } 31 | inline static void RedirectJump(int address, void *func) 32 | { 33 | int temp = 0xE9; 34 | Patch((void *)address, &temp, 1); 35 | temp = (int)func - ((int)address + 5); 36 | Patch((void *)((int)address + 1), &temp, 4); 37 | } 38 | inline static void SetChar(int address, char value) 39 | { 40 | Patch((void *)address, &value, 1); 41 | } 42 | inline static void SetShort(int address, short value) 43 | { 44 | Patch((void *)address, &value, 2); 45 | } 46 | inline static void SetInt(int address, int value) 47 | { 48 | Patch((void *)address, &value, 4); 49 | } 50 | inline static void SetFloat(int address, float value) 51 | { 52 | Patch((void *)address, &value, 4); 53 | } 54 | inline static void SetDouble(int address,double value) 55 | { 56 | Patch((void *)address, &value, 8); 57 | } 58 | inline static void SetPointer(int address, void *value) 59 | { 60 | Patch((void *)address, &value, 4); 61 | } 62 | inline static int SetBytes(int address, uint8_t *data, size_t size) 63 | { 64 | Patch((void *)address, &data, size); 65 | } 66 | }; -------------------------------------------------------------------------------- /th2patch/hawk2/hawk2.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include 4 | 5 | #include "hawk2.h" 6 | #include "hawk2_utils.h" 7 | #include "patchStuff.h" 8 | #include 9 | 10 | //LPDIRECTDRAW lpDD = *((LPDIRECTDRAW*)0x29D6FF8); 11 | 12 | 13 | 14 | bool initialized = false; 15 | 16 | HINSTANCE origModule; 17 | HINSTANCE thisModule; 18 | 19 | BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) 20 | { 21 | switch (ul_reason_for_call) 22 | { 23 | case DLL_PROCESS_ATTACH: 24 | Init(hModule); 25 | break; 26 | case DLL_PROCESS_DETACH: 27 | Exit(); 28 | break; 29 | case DLL_THREAD_ATTACH: 30 | case DLL_THREAD_DETACH: 31 | break; 32 | } 33 | 34 | return TRUE; 35 | } 36 | 37 | //define hook type for DirectInputCreateA 38 | typedef HRESULT(__stdcall *__DirectInputCreateA)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); 39 | 40 | //wrapper func for directinputcreate 41 | HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter) 42 | { 43 | //load dll 44 | if (!origModule) 45 | LoadDll("dinput.dll"); 46 | 47 | //get address of DirectInputCreateA 48 | void* address = (void*)GetProcAddress(origModule, "DirectInputCreateA"); 49 | 50 | //if no address - exit 51 | if (!address) 52 | ::ExitProcess(0); 53 | 54 | //cast to function pointer 55 | __DirectInputCreateA _DirectInputCreateA = (__DirectInputCreateA)address; 56 | 57 | //return original call result 58 | return _DirectInputCreateA(hinst, dwVersion, ppDI, punkOuter); 59 | } 60 | 61 | //load dll by name 62 | void LoadDll(char* filename) 63 | { 64 | char buffer[MAX_PATH]; 65 | 66 | ::GetSystemDirectory(buffer, MAX_PATH); 67 | strcat_s(buffer, "\\"); 68 | strcat_s(buffer, filename); 69 | 70 | if (!origModule) 71 | origModule = ::LoadLibrary(buffer); 72 | 73 | if (!origModule) 74 | { 75 | _trace("Failed to load dll!\n"); 76 | ::ExitProcess(0); 77 | } 78 | } 79 | 80 | void Init(HANDLE hModule) 81 | { 82 | _trace("PROXY Init!!\n"); 83 | 84 | if (!initialized) 85 | initialized = InitPatches(); 86 | 87 | origModule = NULL; 88 | thisModule = (HINSTANCE)hModule; 89 | } 90 | 91 | void Exit() 92 | { 93 | _trace("PROXY Exit!!\n"); 94 | 95 | if (origModule) 96 | { 97 | ::FreeLibrary(origModule); 98 | origModule = NULL; 99 | } 100 | } 101 | 102 | bool InitPatches() 103 | { 104 | _trace("InitPatches!!\n"); 105 | 106 | srand(time(0)); 107 | 108 | //only allocate console in a debug build 109 | #ifdef _DEBUG 110 | if (true) 111 | { 112 | AllocConsole(); 113 | AttachConsole( GetCurrentProcessId() ); 114 | 115 | freopen("CONOUT$", "w", stdout); 116 | freopen("CONOUT$", "w", stderr); 117 | 118 | 119 | } 120 | #endif 121 | 122 | 123 | options.Load(); 124 | 125 | Patch(); 126 | LoadMessageProg(); 127 | 128 | return true; 129 | } -------------------------------------------------------------------------------- /th2patch/hawk2/hawk2.def: -------------------------------------------------------------------------------- 1 | LIBRARY "hawk2" 2 | 3 | EXPORTS 4 | DirectInputCreateA @1 -------------------------------------------------------------------------------- /th2patch/hawk2/hawk2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // exports 6 | HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); 7 | 8 | void LoadDll(char* filename); 9 | void Init(HANDLE hModule); 10 | void Exit(); 11 | bool InitPatches(); -------------------------------------------------------------------------------- /th2patch/hawk2/hawk2.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | D:\Games\THPS2\Launch-F.bat 8 | WindowsLocalDebugger 9 | D:\Games\THPS2\ 10 | 11 | 12 | D:\Games\THPS2\Launch-F.bat 13 | D:\Games\THPS2\ 14 | WindowsLocalDebugger 15 | 16 | -------------------------------------------------------------------------------- /th2patch/hawk2/hawk2_utils.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "hawk2_utils.h" 3 | #include "color.h" 4 | 5 | #include "thawk2/Mess.h" 6 | #include "thawk2/Sfx.h" 7 | #include "thawk2/Soundlib.h" 8 | 9 | void PlaySpecialSound() 10 | { 11 | SOUNDLIB_Play(0xA2, 0x500, 0); 12 | //SFX_PlayX(0xA2, 0x500); 13 | } 14 | 15 | //this should be moved to mess.h 16 | struct SMessageProgArray 17 | { 18 | SMessageProg m1; 19 | SMessageProg m2; 20 | SMessageProg m3; 21 | SMessageProg m4; 22 | SMessageProg m5; 23 | }; 24 | 25 | SMessage mess; 26 | SMessageProgArray ms; 27 | 28 | void SetupMessage(SMessageProg &message, int d, int ss, int es, ColorRGB sc, ColorRGB ec) 29 | { 30 | message.Duration = d; 31 | message.StartScale = ss; 32 | message.EndScale = es; 33 | message.StartColor = sc; 34 | message.EndColor = ec; 35 | } 36 | 37 | SMessageProgArray DefaultMessage() 38 | { 39 | return *(SMessageProgArray*)0x531CC8; 40 | } 41 | 42 | void LoadMessageProg() 43 | { 44 | ms = DefaultMessage(); 45 | 46 | SetupMessage(ms.m1, 1, 0, 0, Color_Black(), Color_Black()); 47 | SetupMessage(ms.m2, 10, 0, 150, Color_Black(), Color_White()); 48 | SetupMessage(ms.m3, 200, 150, 150, Color_White(), Color_White()); 49 | SetupMessage(ms.m4, 20, 100, 0, Color_White(), Color_Black()); 50 | SetupMessage(ms.m5, 1, 0, 0, Color_Black(), Color_Black()); 51 | } 52 | 53 | void DrawMessage(char* msgText) 54 | { 55 | Mess_Message(msgText, &ms.m1, 1, 0, -24); 56 | } -------------------------------------------------------------------------------- /th2patch/hawk2/hawk2_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void DrawMessage(char* msgText); 4 | void PlaySpecialSound(); 5 | void LoadMessageProg(); -------------------------------------------------------------------------------- /th2patch/hawk2/info/classes.md: -------------------------------------------------------------------------------- 1 | # C++ classes 101 2 | 3 | ## Disclaimer 4 | This article entirely describes a very specific case of Visual Studio compiled code, which may or may not match other patterns based on the compiler used, compilation flags, etc. To fully understand how it actually works and why it may not work in other cases, you have to somewhat go down to assembler and cpu registers level. 5 | 6 | ## Class 7 | First of all, ```class``` is an abstract concept, essentially a code pattern, thus, it is built on top of "older technology". Under the hood, class is nothing more but a structure that contains an array of pointers to all class related functions, called ```virtual table``` or vtable. 8 | 9 | ## Virtual tables 10 | https://pabloariasal.github.io/2017/06/10/understanding-virtual-tables/ 11 | 12 | ```Virtual table``` is a plain array of function pointers - ```funcptr[]```. 13 | 14 | The very first pointer of the class structure is the pointer to the vTable. 15 | 16 | Now instead of calling a class function directly by its address, under the hood it is recovered using ```pClass->vTable[functionIndex]()``` call. 17 | 18 | If you inherit a class, it simply creates anoter vtable, copies all original function pointers and adds additional funcptrs to the end of the new table. 19 | 20 | ## Recovering class structure for decompilation 21 | 22 | Hence we already know that class is simply a structure, Ghidra "auto-create structure" feature works fine for C++ classes as well. 23 | 24 | Here's an example from actual THPS2 code. For some context, originally it likely was just a plain ```TrickDatabase trickDB = new TrickDatabase();```, yet a lot of additional supporting code is added under the hood. 25 | 26 | First, game tries to allocate memory for a new generic CClass instance, the parameter here is ```SizeOf()```. Remember this number. 27 | ``` 28 | puVar9 = .__nw__6CClassFUl(0x140c); 29 | ``` 30 | 31 | Next it checks for NULL to figure out whether memory allocation was succesful or not: 32 | ``` 33 | if (puVar9 == NULL) { 34 | puVar9 = NULL; 35 | } 36 | ``` 37 | 38 | And finally, if it was succesful, it calls target class constructor. Typically it should be of __thiscall calling convention. Essentially we just declare that whatever we allocated for CClass should be treated as TrickDatabase: 39 | ``` 40 | else { 41 | puVar9 = TrickDatabase::TrickDatabase(puVar9); 42 | } 43 | ``` 44 | 45 | Now open target class constructor, edit function signature, tick "Use custom storage". This will allow to modify the first "this" param. 46 | Auto-create structure of "this", in the structure dialog, go to the bottom and type in the size of structure we got earlier in CClass constructor. 47 | 48 | We have defined proper sized struct we can pass around and rename its fields accordingly. 49 | Now you can keep working with it like with any other structure. 50 | 51 | Now you can track functions that receive instances of this class and update param types accordingly, Ghidra will automatically turn address calculations to unnamed fields. 52 | 53 | ## Confusions to avoid 54 | 55 | In this case, pointer to class instance equals to pointer to virtual table, euqals to first function in the table, which is usually a destructor. 56 | 57 | Ghidra will put in its best guess, which is destructor function. 58 | 59 | In reality you should check the context and figure out what it does exactly. 60 | 61 | If it's a constructor - it's probably assigning a vtable. 62 | 63 | If it's used as a param, it's probably a pointer to a class instance. 64 | 65 | And if it's a delete operator function, it actually calls the destructor. Easy to spot by additional params passed in. 66 | -------------------------------------------------------------------------------- /th2patch/hawk2/info/hooking_tutorial.md: -------------------------------------------------------------------------------- 1 | # C++ hooking 101 2 | This tutorial briefly covers existing binary code hooking in C++. Keep in mind, this is written with MSVC is mind (Visual Studio C++) and might not work as intended for other compilers. 3 | 4 | ## Requirements 5 | * you have to be used to Visual Studio workflow (code writing, compiling, etc) 6 | * you have to understand the concept of pointers https://en.wikipedia.org/wiki/Pointer_(computer_programming) 7 | 8 | ## Variable usage 9 | This is as simple as casting hex address to pointer type. We declare someValue of pointer to int type and save original address value as this pointer value. Then the pointer points to the original variable. 10 | 11 | ```int* someValue = (int*)0x12345678;``` 12 | 13 | From now on you can use *someValue to read/write the value along with the original code. 14 | 15 | There is also a more "plusplus-ish" approach, considered to be more verbose of the intent, but essentially it does the same thing: 16 | 17 | ```int* someValue = reinterpret_cast(0x12345678);``` 18 | 19 | ## Function hooking 20 | In short, knowing the address of the function in the executable file, we can declare a function pointer and use it like we would use a normal library function. 21 | 22 | Example: 23 | ``` 24 | typedef void(_cdecl *SOUNDLIB_Init_t)(HWND* hWnd); 25 | static const SOUNDLIB_Init_t SOUNDLIB_Init = (SOUNDLIB_Init_t)0x4ef8b0; 26 | ``` 27 | 28 | First line is used to declare the function signature: 29 | * ```typedef``` - declares the type you will use to map the pointer to. 30 | * ```void``` - denotes the return type of the function. if it returns an integer, here will be int instead. 31 | * ```_cdecl``` - denotes the calling convention used. _cdecl can be omitted in MSVC, since it's the default one for standard C style functions. classes use _thiscall, which will be described later. 32 | * `````` - just a name for the function pointer type. for convenience i go with ```_t```. 33 | * ```(params)``` - whatever goes after that is gathered through the decompiled code analysis and function usage. Most of the times it will coincide with Ghidra declarations, but sometimes it may fail. In this case we know that the result of window creation (which is of HWND type) is passed as the only param, so this is what we write. It is enough to declare param types only, but for convenience i give it a name as well. 34 | 35 | Second line is used to declare the pointer itself of previously created type: 36 | * ```static const``` - this means our pointer never changes and always points to this memory area. We can do that because we are working with the static code that never relocates. 37 | * ``` =()0x
``` - rather standard var declaration, similar to how we work with vars. we say that this address must be treated as function pointer, casted to our previously declared type. 38 | 39 | In case we are trying to hook a C++ class method, there is a slight change we need to introduce. 40 | * first of all, the calling convention of the function pointer type must be changed to _thiscall 41 | * param list always starts with a pointer to class, passed as this keyword. But since we don't have the class itself, just call the 1st param _this. rest of params are declared as usual. 42 | 43 | Now as we mapped the function we want to call, we can write a wrapper function for it that will execute the original code and do something more eventually. 44 | This is done by creating a usual C function, but its params, calling convention and return type must fully coincide with the hooked function. 45 | Inside the wrapper function you write a call to the original function like you would normally used any other function. 46 | 47 | In case of thiscall there are additonal rules: 48 | * the wrapper function must use _fastcall convention 49 | * you have to insert additional param right after _this. you can call it void* _edx. 50 | * inside the function you write your call to the original function as usual and just leave _edx unused, do not pass it. that should do the trick and allow you to hook thiscall func. 51 | 52 | But how this new function will be called then? You have to find the original function calls and redirect them to the wrapper function. 53 | Sometimes you'll want all of them, sometimes you just need a specific call, it's totally on you. 54 | You can go as low as asm and patch the address manually or you can use any existing lib that will do it for you. 55 | 56 | So how do you know it succeeded? If it didn't crash, you probably got it right. 57 | 58 | ## Additional reading on calling conventions 59 | * Wikipedia: https://en.wikipedia.org/wiki/X86_calling_conventions 60 | * Microsoft: https://docs.microsoft.com/en-us/cpp/cpp/calling-conventions?view=msvc-170 61 | * Intel: https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/c-c-calling-conventions.html 62 | -------------------------------------------------------------------------------- /th2patch/hawk2/lib/ini/IniReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "IniReader.h" 3 | #include 4 | #include 5 | 6 | CIniReader::CIniReader(char* szFileName) 7 | { 8 | memset(m_szFileName, 0x00, 255); 9 | memcpy(m_szFileName, szFileName, strlen(szFileName)); 10 | } 11 | 12 | int CIniReader::ReadInt(char* szSection, char* szKey, int iDefaultValue) 13 | { 14 | int iResult = GetPrivateProfileInt(szSection, szKey, iDefaultValue, m_szFileName); 15 | 16 | return iResult; 17 | } 18 | 19 | float CIniReader::ReadFloat(char* szSection, char* szKey, float fltDefaultValue) 20 | { 21 | char szResult[255]; 22 | char szDefault[255]; 23 | float fltResult; 24 | 25 | sprintf(szDefault, "%f",fltDefaultValue); 26 | GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); 27 | fltResult = atof(szResult); 28 | 29 | return fltResult; 30 | } 31 | 32 | bool CIniReader::ReadBool(char* szSection, char* szKey, bool bolDefaultValue) 33 | { 34 | char szResult[255]; 35 | char szDefault[255]; 36 | bool bolResult; 37 | 38 | sprintf(szDefault, "%s", bolDefaultValue? "1" : "0"); 39 | GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); 40 | bolResult = (strcmp(szResult, "1") == 0) ? true : false; 41 | 42 | return bolResult; 43 | } 44 | 45 | std::string CIniReader::ReadString(char* szSection, char* szKey, const char* szDefaultValue) 46 | { 47 | char* szResult = new char[255]; 48 | memset(szResult, 0x00, 255); 49 | GetPrivateProfileString(szSection, szKey, szDefaultValue, szResult, 255, m_szFileName); 50 | 51 | printf("INI string: %s\r\n", szResult); 52 | 53 | return std::string(szResult); 54 | } -------------------------------------------------------------------------------- /th2patch/hawk2/lib/ini/IniReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CIniReader 4 | { 5 | public: 6 | CIniReader(char* szFileName); 7 | int ReadInt(char* szSection, char* szKey, int iDefaultValue); 8 | float ReadFloat(char* szSection, char* szKey, float fltDefaultValue); 9 | bool ReadBool(char* szSection, char* szKey, bool bolDefaultValue); 10 | std::string ReadString(char* szSection, char* szKey, const char* szDefaultValue); 11 | 12 | private: 13 | char m_szFileName[255]; 14 | }; -------------------------------------------------------------------------------- /th2patch/hawk2/lib/ini/IniWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "IniWriter.h" 3 | #include 4 | #include 5 | 6 | char szValue[255]; 7 | 8 | CIniWriter::CIniWriter(char* szFileName) 9 | { 10 | memset(m_szFileName, 0x00, 255); 11 | memcpy(m_szFileName, szFileName, strlen(szFileName)); 12 | } 13 | 14 | void CIniWriter::WriteInt(char* szSection, char* szKey, int iValue) 15 | { 16 | sprintf(szValue, "%d", iValue); 17 | WritePrivateProfileString(szSection, szKey, szValue, m_szFileName); 18 | } 19 | 20 | void CIniWriter::WriteFloat(char* szSection, char* szKey, float fltValue) 21 | { 22 | sprintf(szValue, "%f", fltValue); 23 | WritePrivateProfileString(szSection, szKey, szValue, m_szFileName); 24 | } 25 | 26 | void CIniWriter::WriteBool(char* szSection, char* szKey, bool bolValue) 27 | { 28 | sprintf(szValue, "%s", bolValue ? "True" : "False"); 29 | WritePrivateProfileString(szSection, szKey, szValue, m_szFileName); 30 | } 31 | 32 | void CIniWriter::WriteString(char* szSection, char* szKey, char* szValue) 33 | { 34 | WritePrivateProfileString(szSection, szKey, szValue, m_szFileName); 35 | } -------------------------------------------------------------------------------- /th2patch/hawk2/lib/ini/IniWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CIniWriter 4 | { 5 | public: 6 | CIniWriter(char* szFileName); 7 | void WriteInt(char* szSection, char* szKey, int iValue); 8 | void WriteFloat(char* szSection, char* szKey, float fltValue); 9 | void WriteBool(char* szSection, char* szKey, bool bolValue); 10 | void WriteString(char* szSection, char* szKey, char* szValue); 11 | 12 | private: 13 | char m_szFileName[255]; 14 | }; -------------------------------------------------------------------------------- /th2patch/hawk2/lib/ini/readme.md: -------------------------------------------------------------------------------- 1 | * Author: xiaohe521 2 | * License: CPOL 3 | * Link: https://www.codeproject.com/Articles/10809/A-Small-Class-to-Read-INI-File -------------------------------------------------------------------------------- /th2patch/hawk2/lib/readme.md: -------------------------------------------------------------------------------- 1 | This folder contains third party code, either linked statically or dynamically. Each folder includes a readme file with the link to the source. 2 | 3 | Linked code: 4 | * sqlite - to store and access additional game data 5 | * ini - for configuration file reads/writes 6 | * xinput - for XInput support -------------------------------------------------------------------------------- /th2patch/hawk2/lib/sqlite/readme.md: -------------------------------------------------------------------------------- 1 | * Author: SQLite Consortium 2 | * License: public domain (https://www.sqlite.org/copyright.html) 3 | * Link: https://www.sqlite.org/download.html -------------------------------------------------------------------------------- /th2patch/hawk2/lib/sqlite/sqlite3.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patch/hawk2/lib/sqlite/sqlite3.exp -------------------------------------------------------------------------------- /th2patch/hawk2/lib/xinput/CXBOXController.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CXBOXController.h" 3 | 4 | CXBOXController::CXBOXController(int playerNumber) 5 | { 6 | // Set the Controller Number 7 | _controllerNum = playerNumber - 1; 8 | } 9 | 10 | bool CXBOXController::UpdateState() 11 | { 12 | memcpy(&_controllerStateOld, &_controllerState, sizeof(_controllerState)); 13 | //save old controllerstate 14 | 15 | // Zeroise the state 16 | ZeroMemory(&_controllerState, sizeof(XINPUT_STATE)); 17 | 18 | // Get the state 19 | DWORD Result = XInputGetState(_controllerNum, &_controllerState); 20 | 21 | if(Result == ERROR_SUCCESS) return true; 22 | return false; 23 | } 24 | 25 | XINPUT_STATE CXBOXController::GetState() 26 | { 27 | return _controllerState; 28 | } 29 | 30 | 31 | XINPUT_STATE CXBOXController::GetOldState() 32 | { 33 | return _controllerStateOld; 34 | } 35 | 36 | bool CXBOXController::IsConnected() 37 | { 38 | // Zeroise the state 39 | ZeroMemory(&_controllerState, sizeof(XINPUT_STATE)); 40 | 41 | // Get the state 42 | DWORD Result = XInputGetState(_controllerNum, &_controllerState); 43 | 44 | if(Result == ERROR_SUCCESS) return true; 45 | return false; 46 | } 47 | 48 | void CXBOXController::Vibrate(int leftVal, int rightVal, bool enabled) 49 | { 50 | if (!enabled) return; 51 | 52 | // Create a Vibraton State 53 | XINPUT_VIBRATION Vibration; 54 | 55 | // Zeroise the Vibration 56 | ZeroMemory(&Vibration, sizeof(XINPUT_VIBRATION)); 57 | 58 | // Set the Vibration Values 59 | Vibration.wLeftMotorSpeed = leftVal; 60 | Vibration.wRightMotorSpeed = rightVal; 61 | 62 | // Vibrate the controller 63 | XInputSetState(_controllerNum, &Vibration); 64 | } 65 | 66 | bool CXBOXController::Pressed(int x) { return _controllerState.Gamepad.wButtons & x; } 67 | 68 | bool CXBOXController::PressedA() { return Pressed(XINPUT_GAMEPAD_A); } 69 | bool CXBOXController::PressedB() { return Pressed(XINPUT_GAMEPAD_B); } 70 | bool CXBOXController::PressedX() { return Pressed(XINPUT_GAMEPAD_X); } 71 | bool CXBOXController::PressedY() { return Pressed(XINPUT_GAMEPAD_Y); } 72 | bool CXBOXController::PressedPOVUp() { return Pressed(XINPUT_GAMEPAD_DPAD_UP); } 73 | bool CXBOXController::PressedPOVDown() { return Pressed(XINPUT_GAMEPAD_DPAD_DOWN); } 74 | bool CXBOXController::PressedPOVLeft() { return Pressed(XINPUT_GAMEPAD_DPAD_LEFT); } 75 | bool CXBOXController::PressedPOVRight() { return Pressed(XINPUT_GAMEPAD_DPAD_RIGHT); } 76 | bool CXBOXController::PressedBack() { return Pressed(XINPUT_GAMEPAD_BACK); } 77 | bool CXBOXController::PressedStart() { return Pressed(XINPUT_GAMEPAD_START); } -------------------------------------------------------------------------------- /th2patch/hawk2/lib/xinput/CXBOXController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // No MFC 4 | #define WIN32_LEAN_AND_MEAN 5 | 6 | // We need the Windows Header and the XInput Header 7 | #include 8 | #include 9 | 10 | // Now, the XInput Library 11 | // NOTE: COMMENT THIS OUT IF YOU ARE NOT USING 12 | // A COMPILER THAT SUPPORTS THIS METHOD OF LINKING LIBRARIES 13 | #pragma comment(lib, "XInput.lib") 14 | 15 | // XBOX Controller Class Definition 16 | class CXBOXController 17 | { 18 | private: 19 | XINPUT_STATE _controllerState; 20 | XINPUT_STATE _controllerStateOld; 21 | int _controllerNum; 22 | bool Pressed(int x); 23 | 24 | public: 25 | CXBOXController(int playerNumber); 26 | bool UpdateState(); 27 | XINPUT_STATE GetState(); 28 | XINPUT_STATE GetOldState(); 29 | bool IsConnected(); 30 | void Vibrate(int leftVal = 0, int rightVal = 0, bool enable = true); 31 | 32 | bool PressedA(); 33 | bool PressedB(); 34 | bool PressedX(); 35 | bool PressedY(); 36 | bool PressedPOVUp(); 37 | bool PressedPOVDown(); 38 | bool PressedPOVLeft(); 39 | bool PressedPOVRight(); 40 | bool PressedBack(); 41 | bool PressedStart(); 42 | }; -------------------------------------------------------------------------------- /th2patch/hawk2/lib/xinput/readme.md: -------------------------------------------------------------------------------- 1 | * Author: Minalien 2 | * License: CPOL 3 | * Link: https://www.codeproject.com/Articles/26949/Xbox-360-Controller-Input-in-C-with-XInput -------------------------------------------------------------------------------- /th2patch/hawk2/mydebug.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "mydebug.h" 3 | 4 | 5 | char debugText[256]; 6 | 7 | void DebugMessage(char* text, int x, int y) 8 | { 9 | Mess_SetScale(95); 10 | Mess_SetRGB(255, 255, 32, false); 11 | Mess_SetTextJustify(eTextJustify::Left); 12 | Mess_DrawText(x, y, text, 0); 13 | } 14 | 15 | #define BUFFER_WIDTH 512 16 | #define BUFFER_HEIGHT 240 17 | 18 | void Panel_LineX(float x1, float x2, float x3, float x4, int r, int g, int b) 19 | { 20 | Panel_Line( 21 | (int)(BUFFER_WIDTH / 2 * (x1 + 1)), 22 | (int)(BUFFER_HEIGHT / 2 * (x2 + 1)), 23 | (int)(BUFFER_WIDTH / 2 * (x3 + 1)), 24 | (int)(BUFFER_HEIGHT / 2 * (x4 + 1)), 25 | (int)(r | g << 8 | b << 16) 26 | ); 27 | } 28 | 29 | 30 | 31 | 32 | void PrintDebugStuff() 33 | { 34 | if (*GamePaused) 35 | { 36 | sprintf(debugText, "THPS2 Cumulative Patch r7prev"); 37 | DebugMessage(debugText, 10, BUFFER_HEIGHT - 7); 38 | } 39 | else 40 | { 41 | if (!*InFrontEnd) 42 | { 43 | /* 44 | int* test = CBruce_GetTestValueInt( (int*)(*(int*)GSkater) , 0x0100); 45 | //*test = 64; 46 | 47 | sprintf(debugText, "test: %08X", *test); 48 | DebugMessage(debugText, 10, 10); 49 | */ 50 | 51 | //int balance = *CBruce_GetManualBalance((int*)(*(int*)GSkater)); 52 | 53 | //sprintf(debugText, "balance %i", railBal); 54 | //DebugMessage(debugText, 10, 10); 55 | 56 | 57 | CBruce* pSkater = new CBruce(GSkater); 58 | 59 | sprintf(debugText, "bruce test: %i %i %i" , 60 | pSkater->GetValue(0x12c), 61 | pSkater->GetValue(0x130), 62 | pSkater->GetValue(0x134) 63 | 64 | ); 65 | 66 | 67 | //pSkater->SetValue(0x28, 10); 68 | 69 | 70 | 71 | DebugMessage(debugText, 10, 10); 72 | 73 | delete pSkater; 74 | } 75 | 76 | 77 | 78 | //sprintf(debugText, "test: %i", *GGame); 79 | //DebugMessage(debugText, 512 / 2, 20); 80 | 81 | //Panel_LineX(-1.0, -1.0, 1.0, 1.0, 255, 0, 0); 82 | //Panel_LineX(1.0, -1.0, -1.0, 1.0, 255, 0, 0); 83 | } 84 | } 85 | 86 | 87 | void Panel_BalanceRail( 88 | int Balance, int Max, int Length, int Width, 89 | int x, int y, uint LineColor, uint MarkerColor, bool horz) 90 | { 91 | if (horz) 92 | { 93 | Length = Length * 16 / 9; 94 | Width = Width * 4 / 3; 95 | 96 | // we have to account for level flip cheat state for horizontal balance bar !!! 97 | int markerX = (Balance * Length * (*Cheat_FlipScreen ? -1 : 1)) / Max + x; 98 | 99 | Panel_Line(markerX, y, markerX, y + Width, MarkerColor); 100 | Panel_DrawBalanceBarLR(x, y, Length, Width, LineColor); 101 | Panel_DrawBalanceBarLR(x + 1, y + 1, Length, Width, LineColor >> 3 & 0x1f1f1f); 102 | } 103 | else 104 | { 105 | //marker 106 | int markerY = (Balance * Length) / Max + y; 107 | Panel_Line(x, markerY, x + Width, markerY, MarkerColor); 108 | Panel_DrawBalanceBarUD(x, y, Length, Width, LineColor); 109 | Panel_DrawBalanceBarUD(x + 1, y + 1, Length, Width, LineColor >> 3 & 0x1f1f1f); 110 | } 111 | } 112 | 113 | void Panel_DrawBalanceBarUD(int x, int y, int Length, int Width, uint color) 114 | { 115 | int topY = y + Length; 116 | int bottomY = y - Length; 117 | int rightX = x + Width; 118 | 119 | Panel_Line(x, topY, x, bottomY, color); 120 | Panel_Line(x, topY, rightX, topY, color); 121 | Panel_Line(x, y, rightX, y, color); 122 | Panel_Line(x, bottomY, rightX, bottomY, color); 123 | } 124 | 125 | 126 | void Panel_DrawBalanceBarLR(int x, int y, int Length, int Width, uint color) 127 | { 128 | int leftX = x + Length; 129 | int rightX = x - Length; 130 | int bottomY = y + Width; 131 | 132 | Panel_Line(leftX, y, rightX, y, color); 133 | Panel_Line(leftX, y, leftX, bottomY, color); 134 | Panel_Line(x, y, x, bottomY, color); 135 | Panel_Line(rightX, y, rightX, bottomY, color); 136 | } 137 | 138 | /* 139 | void Panel_BalanceRail(int Balance, int Max, int Length, int x, int y, uint LineColor, uint MarkerColor) 140 | { 141 | int iVar1; 142 | int iVar2; 143 | uint uVar3; 144 | 145 | iVar2 = (Balance * Length) / Max + y; 146 | Panel_Line(x, iVar2, x + 6, iVar2, MarkerColor); 147 | iVar2 = y + Length; 148 | Length = y - Length; 149 | uVar3 = LineColor >> 3 & 0x1f1f1f; 150 | Panel_Line(x, Length, x, iVar2, LineColor); 151 | Panel_Line(x, Length, x + 6, Length, LineColor); 152 | Panel_Line(x, y, x + 6, y, LineColor); 153 | Panel_Line(x, iVar2, x + 6, iVar2, LineColor); 154 | Length = Length + 1; 155 | iVar2 = iVar2 + 1; 156 | iVar1 = x + 1; 157 | Panel_Line(iVar1, Length, iVar1, iVar2, uVar3); 158 | x = x + 7; 159 | Panel_Line(iVar1, Length, x, Length, uVar3); 160 | Panel_Line(iVar1, y + 1, x, y + 1, uVar3); 161 | Panel_Line(iVar1, iVar2, x, iVar2, uVar3); 162 | } 163 | */ 164 | 165 | void VibrationTest(CXBOXController* Player1) 166 | { 167 | if (Player1) 168 | { 169 | 170 | Player1->Vibrate(2000, 0, true); 171 | 172 | double timer = 0; 173 | do 174 | { 175 | Sleep(16); 176 | WinYield(); 177 | timer += 16.666 * 2; 178 | //printf("timer: %f\r\n", timer / 1000); 179 | } while (timer < 16.66666 * 120 * 5); 180 | 181 | Player1->Vibrate(0, 2000, true); 182 | 183 | timer = 0; 184 | do 185 | { 186 | Sleep(16); 187 | WinYield(); 188 | timer += 16.666 * 2; 189 | //printf("timer: %f\r\n", timer / 1000); 190 | } while (timer < 16.66666 * 120 * 5); 191 | 192 | 193 | Player1->Vibrate(65535, 0, true); 194 | 195 | timer = 0; 196 | do 197 | { 198 | Sleep(16); 199 | WinYield(); 200 | timer += 16.666 * 2; 201 | //printf("timer: %f\r\n", timer / 1000); 202 | } while (timer < 16.66666 * 120 * 5); 203 | 204 | Player1->Vibrate(0, 65535, true); 205 | 206 | timer = 0; 207 | do 208 | { 209 | Sleep(16); 210 | WinYield(); 211 | timer += 16.666 * 2; 212 | //printf("timer: %f\r\n", timer / 1000); 213 | } while (timer < 16.66666 * 120 * 5); 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /th2patch/hawk2/mydebug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "lib/xinput/CXBOXController.h" 4 | #include "patchStuff.h" 5 | #include "thawk2/thawk2.h" 6 | 7 | 8 | void PrintDebugStuff(); 9 | void VibrationTest(CXBOXController* Player1); 10 | void Panel_BalanceRail(int Balance, int Max, int Length, int Width, 11 | int x, int y, uint LineColor, uint MarkerColor, bool horz); 12 | void Panel_DrawBalanceBarUD(int x, int y, int Length, int Width, uint color); 13 | void Panel_DrawBalanceBarLR(int x, int y, int Length, int Width, uint color); -------------------------------------------------------------------------------- /th2patch/hawk2/patch/_patch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // All custom patching code intended to be included in this header -------------------------------------------------------------------------------- /th2patch/hawk2/patch/hook.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "..\cpatch.h" 3 | #include "hook.h" 4 | #include "..\thawk2\thawk2.h" 5 | 6 | namespace Hook 7 | { 8 | // The idea behind this is to collect all hooks within the namespace it belongs to. 9 | // just define pHookList in the namespace and add to the array. 10 | // the sethooks is called in main patching func. 11 | 12 | Reroute* pHookLists[] = { 13 | gte::pHookList, 14 | Career::pHookList, 15 | Rail::pHookList, 16 | FileIO::pHookList, 17 | Flash::pHookList, 18 | Physics::pHookList, 19 | Redbook::pHookList 20 | //Pal::pHookList 21 | }; 22 | 23 | void SetHooks() 24 | { 25 | for (int i = 0; i < sizeof(pHookLists) / 4; i++) 26 | ProcessList(pHookLists[i]); 27 | } 28 | 29 | void ProcessList(Reroute* pList) 30 | { 31 | while (pList->pMem != NULL) 32 | { 33 | CPatch::RedirectCall(pList->pMem, pList->pFunc); 34 | 35 | printf("DECOMP DEBUG: patched %i at %i\n", (unsigned int)pList->pFunc, pList->pMem); 36 | 37 | pList++; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /th2patch/hawk2/patch/hook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Hook 4 | { 5 | typedef struct Reroute { 6 | unsigned int pMem; 7 | void* pFunc; 8 | } FuncRedirection; 9 | 10 | void ProcessList(Reroute* pList); 11 | 12 | void SetHooks(); 13 | } -------------------------------------------------------------------------------- /th2patch/hawk2/patchStuff.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GameOptions.h" 3 | #include "thawk2/Career.h" 4 | 5 | extern GameOptions options; 6 | 7 | enum class EGeneratorTheme : int { 8 | Powerplant = 0, 9 | Industrial = 1, 10 | Outdoor = 2, 11 | School = 3, 12 | First = Powerplant, 13 | Last = School 14 | }; 15 | 16 | enum class EInitCleanupType : int { 17 | Hard = 0, 18 | Soft = 1, 19 | LevelEditor = 2 20 | }; 21 | 22 | enum class EGameMode : int { 23 | None = 0, 24 | Career = 1, 25 | Practice = 2, 26 | Single = 3, 27 | Unknown4 = 4, 28 | Trick = 5, 29 | Unknown6 = 6, 30 | Horse = 7, 31 | Graffiti = 8, 32 | Tag = 9, 33 | Contest = 10, 34 | First = None, 35 | Last = Contest 36 | }; 37 | 38 | // defines basic level data like name, career unlock stuff, etc. 39 | typedef struct SLevel 40 | { 41 | char name[64]; 42 | char* subname; 43 | char* shortname; 44 | int isCompetition; //bool 45 | char* trgfile; 46 | int compScore[3]; 47 | int compAward[3]; 48 | char* renderthumb; 49 | int u2; 50 | int globeX; 51 | int globeY; 52 | char* thumb; 53 | int cashToUnlock; 54 | int medalsToUnlock; 55 | int isCompetition2; //bool 56 | int somedata[4]; 57 | int index; 58 | int somedata2[5]; 59 | int gapFirst; 60 | int gapLast; 61 | Career::SGoal Goals[10]; 62 | int killers; 63 | } SLevel; 64 | 65 | void Patch(); 66 | void PatchSkaters(); 67 | void SetHooks(); 68 | void GetSong(int num); 69 | int CountSongs(); 70 | void PCINPUT_ActuatorOn_Hook(int index, int time, int motor, int value); -------------------------------------------------------------------------------- /th2patch/hawk2/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | void __trace(const char* format, ...) 4 | { 5 | char buffer[1000]; 6 | 7 | va_list argptr; 8 | va_start(argptr, format); 9 | wvsprintf(buffer, format, argptr); 10 | va_end(argptr); 11 | 12 | OutputDebugString(buffer); 13 | } -------------------------------------------------------------------------------- /th2patch/hawk2/stdafx.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __STDAFX_H 3 | #define __STDAFX_H 4 | 5 | #define WIN32_LEAN_AND_MEAN 6 | #define DEBUG_FUNCTIONS 7 | 8 | #include 9 | #include 10 | 11 | void __trace(const char* format, ...); 12 | 13 | #ifdef DEBUG_FUNCTIONS 14 | #define _trace(...) __trace(__VA_ARGS__); 15 | #else 16 | #define _trace(...) 17 | #endif 18 | 19 | #endif // __STDAFX_H -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/CBruce.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CBruce.h" 3 | 4 | CVector* CBruce_GetPosition(void* pSkater) 5 | { 6 | return (CVector*)((int)pSkater + 0x08); 7 | } 8 | 9 | CVector* CBruce_GetVelocity(void* pSkater) 10 | { 11 | return (CVector*)((int)pSkater + 0x4C); 12 | } 13 | 14 | #define CBRUCE_TOTALSCORE 0x16C 15 | 16 | #define CBRUCE_PENDINGSCORE 0x2A8 17 | 18 | #define CBRUCE_TRICKNAME 0x29C4 19 | 20 | #define CBRUCE_RAILBALANCE 0x2EF0 21 | //0x2ef4 22 | //0x2ef8 23 | //0x2efc 24 | //0x2f00 25 | //0x2f04 26 | //0x2f08 27 | //0x2f0c 28 | //0x2f10 29 | #define CBRUCE_MANUALBALANCE 0x2F14 30 | 31 | #define CBRUCE_LASTGAPTRICK 0x3024 32 | #define CBRUCE_LASTGOALTRICK 0x3028 33 | 34 | #define CBRUCE_TERRAIN 0x30B0 35 | #define CBRUCE_PHYSICSSTATE 0x30B8 36 | 37 | 38 | 39 | //sizeof CBruce = 0x3538 40 | 41 | CBruce::CBruce(void* pBruce) 42 | { 43 | pSkater = (void*)(*((int*)pBruce)); 44 | } 45 | 46 | int CBruce::GetValue(int addr) 47 | { 48 | return *(int*)((int)pSkater + addr); 49 | } 50 | 51 | char CBruce::GetValueChar(char addr) 52 | { 53 | return *(char*)((char)pSkater + addr); 54 | } 55 | 56 | void CBruce::SetValue(int addr, int newValue) 57 | { 58 | *(int*)((int)pSkater + addr) = newValue; 59 | } 60 | 61 | 62 | int CBruce::TotalScore() 63 | { 64 | return *(int*)((int)pSkater + CBRUCE_TOTALSCORE); 65 | } 66 | 67 | int CBruce::ManualBalance() 68 | { 69 | return *(int*)((int)pSkater + CBRUCE_MANUALBALANCE); 70 | } 71 | 72 | int CBruce::RailBalance() 73 | { 74 | return *(int*)((int)pSkater + CBRUCE_RAILBALANCE); 75 | } 76 | 77 | int CBruce::PhysicsState() 78 | { 79 | return *(int*)((int)pSkater + CBRUCE_PHYSICSSTATE); 80 | } 81 | 82 | int CBruce::Terrain() 83 | { 84 | return *(int*)((int)pSkater + CBRUCE_TERRAIN); 85 | } 86 | 87 | int* CBruce_GetManualBalanceOld(void* pSkater) 88 | { 89 | return (int*)((int)pSkater + 0x2F18); 90 | } 91 | 92 | 93 | int* CBruce_GetTestValueInt(void* pSkater, int offset) 94 | { 95 | return (int*)((int)pSkater + offset); 96 | } 97 | 98 | char* CBruce::CBruce_GetTrickName() 99 | { 100 | return (char*)((int)pSkater + CBRUCE_TRICKNAME); 101 | } 102 | 103 | 104 | /* 105 | 0000 dword - ptr CBruce Vtable 106 | 0004 dword - 202? unknown 107 | 0008 Vector (3 dwords) - position 108 | 0014 dword - ?? somehow related to friction or smth, updated on grass, resets by rail 109 | 0018 dword - related to rail balance? but not bluntslide 110 | 001C dword - 0? 111 | 0020 dword - 0? 112 | 0024 dword - 00404040 some color? 113 | 0028 4 words, 3 = 1000, maybe scale? 114 | 002C ^^^ 115 | 0030 dword - 0? 116 | 117 | */ 118 | 119 | /* 120 | // maybe a bit too optimistic 121 | void CBruce::AddTrickItem(CItem* pItem) 122 | { 123 | if (pItem == NULL) 124 | printf("Adding NULL pItem to trick item list!"); 125 | 126 | int count = this->mTrickItems; 127 | 128 | if (count > 40) count = 40; 129 | 130 | for (int i = 0; i < count; i++) 131 | if (mTrickItem[i] == pItem) 132 | return; 133 | 134 | mTrickItem[i] = pItem; 135 | mTrickItems++; 136 | } 137 | */ -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/CBruce.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CVector { 4 | int X; 5 | int Y; 6 | int Z; 7 | }; 8 | 9 | typedef struct CVector CVector; 10 | 11 | struct CSVector { 12 | short X; 13 | short Y; 14 | short Z; 15 | }; 16 | 17 | typedef struct CSVector CSVector; 18 | 19 | enum class EStats : int { 20 | STATS_AIR = 0, 21 | STATS_HANGTIME = 1, 22 | STATS_OLLIE = 2, 23 | STATS_SPEED = 3, 24 | STATS_SPIN = 4, 25 | STATS_LANDING = 5, 26 | STATS_SWITCH = 6, 27 | STATS_RAILBALANCE = 7, 28 | STATS_LIPBALANCE = 8, 29 | STATS_MANUALS = 9 30 | }; 31 | 32 | 33 | class CBruce 34 | { 35 | public: 36 | CBruce::CBruce(void*); 37 | void* pSkater; 38 | int CBruce::ManualBalance(); 39 | int CBruce::RailBalance(); 40 | int CBruce::PhysicsState(); 41 | int CBruce::TotalScore(); 42 | char* CBruce::CBruce_GetTrickName(); 43 | int CBruce::GetValue(int addr); 44 | void CBruce::SetValue(int addr, int newValue); 45 | char CBruce::GetValueChar(char addr); 46 | int CBruce::Terrain(); 47 | 48 | }; 49 | 50 | CVector* CBruce_GetPosition(void* pSkater); 51 | CVector* CBruce_GetVelocity(void* pSkater); 52 | int* CBruce_GetTestValueInt(void* pSkater, int offset); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/CClass.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CClass.h" 3 | #include "mem.h" 4 | 5 | int* TotalCClassUsage = (int*)0x00567580; 6 | int* Used = (int*)0x5675d0; 7 | 8 | void* testMenu = (void*)0x0055e8a0; 9 | 10 | void* CClass::operator new(size_t size) 11 | { 12 | //calculate aligned size by 4 (mips legacy?) 13 | int sizeAligned = (size + 3) & ~3; 14 | 15 | //get pointer to allocated memory 16 | void* pAlloc = Mem_New(size, 0, 1, 0); 17 | 18 | //reset allocation 19 | memset(pAlloc, 0, sizeAligned); 20 | 21 | //increase usage var 22 | *TotalCClassUsage += 4 + sizeAligned; 23 | 24 | return pAlloc; 25 | } 26 | 27 | void CClass::operator delete(void* p) 28 | { 29 | //remember how much we used before deletion 30 | int used = *Used; 31 | 32 | //delete 33 | Mem_Delete(p); 34 | 35 | //decrease usage var 36 | *TotalCClassUsage -= used - *Used; 37 | 38 | if (*TotalCClassUsage < 0) 39 | printf("my bad\r\n"); 40 | } 41 | 42 | /* 43 | void* __fastcall CMenu__AddEntry_Hook(void* _this, void* _edx, char* pText) 44 | { 45 | return CMenu__AddEntry(_this, pText); 46 | } 47 | 48 | void* __fastcall _new_CMenu_Hook(void* _this, void* _edx, int param_2, int param_3, char param_4, short param_5, short param_6, int param_7) 49 | { 50 | return _new_CMenu(_this, param_2, param_3, param_4, param_5, param_6, param_7); 51 | } 52 | 53 | 54 | 55 | void CreateTestMenu() 56 | { 57 | printf("CreateTestMenu\n"); 58 | 59 | testMenu = _new_CClass(0x180); 60 | if (testMenu != NULL) 61 | { 62 | testMenu = _new_CMenu_Hook(testMenu, NULL, 0x100, 0, 0, 0x14f, 0x100, 0x16); 63 | } 64 | 65 | CMenu__AddEntry_Hook(testMenu, NULL, "test 1"); 66 | CMenu__AddEntry_Hook(testMenu, NULL, "test 2"); 67 | CMenu__AddEntry_Hook(testMenu, NULL, "test 3"); 68 | 69 | } 70 | 71 | */ 72 | -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/CClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern int* TotalCClassUsage; 4 | extern int* Used; 5 | extern void* testMenu; 6 | 7 | class CClass 8 | { 9 | public: 10 | void* operator new(size_t size); 11 | void operator delete(void* p); 12 | }; 13 | 14 | typedef void* (*_new_CClass_t)(int size); 15 | static const _new_CClass_t _new_CClass = (_new_CClass_t)0x00466b00; 16 | 17 | 18 | 19 | //void CreateTestMenu(); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/CMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "CMenu.h" 3 | #include "Utils.h" 4 | #include "types.h" 5 | 6 | 7 | CMenu::CMenu(SMenu* pMenu) 8 | { 9 | menu = pMenu; 10 | } 11 | 12 | int CMenu::FindEntry(char* pText) 13 | { 14 | /* 15 | if (menu->numEntries > 0) 16 | for (SMenuEntry* p = menu->entries[0]; i < menu->entries[menu->numEntries]; i++) 17 | if (Utils_CompareStrings(pText, *pEntry, 0xffffffff) != 0) 18 | return i; 19 | 20 | printf("entry not found!"); 21 | */ 22 | 23 | //so we dont confuse it with the 1st line 24 | return NS_NULL; 25 | } 26 | 27 | 28 | void CMenu::MenuReset() 29 | { 30 | //SetLine(0); 31 | } 32 | 33 | 34 | bool CMenu::ChoiceIs(char* pText) 35 | { 36 | return false; 37 | //return Utils_CompareStrings(pText, menu->entries[menu->selectedEntry].text, -1); 38 | } 39 | 40 | void CMenu::EntryOn(char* pText) 41 | { 42 | /* 43 | int index = FindEntry(_this,pText); 44 | 45 | if (index != NS_NULL) 46 | menu->entries[index].visible = true; 47 | */ 48 | } 49 | 50 | 51 | void CMenu::EntryOff(char* pText) 52 | { 53 | /* 54 | int index = FindEntry(menu, pText); 55 | 56 | if (index != NS_NULL) 57 | menu->entries[index].visible = false; 58 | */ 59 | } 60 | 61 | 62 | bool CMenu::IsEntryOn(char* pText) 63 | { 64 | /* 65 | int index = FindEntry(_this,pText); 66 | 67 | if (index != NS_NULL) 68 | menu->entries[index].visible = true; 69 | */ 70 | 71 | return false; 72 | } 73 | 74 | void CMenu::DebugPrint() 75 | { 76 | printf("Menu: items=%i x=%i y=%i\n", menu->numEntries, menu->X, menu->Y); 77 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/CMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | CMenu 5 | 6 | originally part of front.cpp 7 | Handles vertical basic menu layout 8 | */ 9 | 10 | 11 | struct SMenu { 12 | void* vTable; 13 | short justification; 14 | char selectedEntry; 15 | short unk1; 16 | char numEntries; 17 | short unk2; 18 | int X; 19 | int Y; 20 | int lineSeparation; 21 | //SMenuEntry entries[15]; 22 | }; 23 | 24 | typedef struct SMenu SMenu; 25 | 26 | 27 | class CMenu { 28 | private: 29 | SMenu* menu; //ptr to menu 30 | public: 31 | CMenu(SMenu* menuPtr); 32 | int FindEntry(char* pText); 33 | void MenuReset(); 34 | bool ChoiceIs(char* pText); 35 | void EntryOn(char* pText); 36 | void EntryOff(char* pText); 37 | bool IsEntryOn(char* pText); 38 | void DebugPrint(); 39 | }; 40 | 41 | 42 | 43 | typedef void(*CMenu__new_t)(); 44 | typedef void(*CMenu__destruct_t)(); 45 | typedef void(*CMenu__delete_t)(); 46 | typedef void(*CMenu__CentreY_t)(); 47 | typedef void(*CMenu__SetLine_t)(); 48 | typedef void(*FUN_0x0044b750_menuReset_unused_t)(); 49 | typedef void(*CMenu__FindEntry_t)(); 50 | typedef void(*CMenu__AddEntry_t)(); 51 | typedef void(*CMenu__EntryOn_t)(); 52 | typedef void(*CMenu__EntryOff_t)(); 53 | typedef void(*CMenu__IsEntryOn_t)(); 54 | typedef void(*CMenu__Disable_t)(); 55 | typedef void(*FUN_0x0044b960_isEnabled_unused_t)(); 56 | typedef void(*FUN_0x0044b980_unused_t)(); 57 | typedef void(*CMenu__ChoiceIs_t)(); 58 | typedef void(*FUN_0x0044b9c0_unused_t)(); 59 | typedef void(*CMenu__Display_t)(); 60 | typedef void(*CMenu__Update_t)(); 61 | 62 | 63 | static const CMenu__new_t CMenu__new = (CMenu__new_t)0x0044b5e0; 64 | static const CMenu__destruct_t CMenu__destruct = (CMenu__destruct_t)0x0044b690; 65 | static const CMenu__delete_t CMenu__delete = (CMenu__delete_t)0x0044b6b0; 66 | static const CMenu__CentreY_t CMenu__CentreY = (CMenu__CentreY_t)0x0044b6c0; 67 | static const CMenu__SetLine_t CMenu__SetLine = (CMenu__SetLine_t)0x0044b710; 68 | static const FUN_0x0044b750_menuReset_unused_t FUN_0x0044b750_menuReset_unused = (FUN_0x0044b750_menuReset_unused_t)0x0044b750; 69 | static const CMenu__FindEntry_t CMenu__FindEntry = (CMenu__FindEntry_t)0x0044b7a0; 70 | static const CMenu__AddEntry_t CMenu__AddEntry = (CMenu__AddEntry_t)0x0044b830; 71 | static const CMenu__EntryOn_t CMenu__EntryOn = (CMenu__EntryOn_t)0x0044b8c0; 72 | static const CMenu__EntryOff_t CMenu__EntryOff = (CMenu__EntryOff_t)0x0044b8e0; 73 | static const CMenu__IsEntryOn_t CMenu__IsEntryOn = (CMenu__IsEntryOn_t)0x0044b900; 74 | static const CMenu__Disable_t CMenu__Disable = (CMenu__Disable_t)0x0044b940; 75 | static const FUN_0x0044b960_isEnabled_unused_t FUN_0x0044b960_isEnabled_unused = (FUN_0x0044b960_isEnabled_unused_t)0x0044b960; 76 | static const FUN_0x0044b980_unused_t FUN_0x0044b980_unused = (FUN_0x0044b980_unused_t)0x0044b980; 77 | static const CMenu__ChoiceIs_t CMenu__ChoiceIs = (CMenu__ChoiceIs_t)0x0044b9a0; 78 | static const FUN_0x0044b9c0_unused_t FUN_0x0044b9c0_unused = (FUN_0x0044b9c0_unused_t)0x0044b9c0; 79 | static const CMenu__Display_t CMenu__Display = (CMenu__Display_t)0x0044ba30; 80 | static const CMenu__Update_t CMenu__Update = (CMenu__Update_t)0x0044bb60; 81 | 82 | 83 | /* 84 | typedef void* (__thiscall* CMenu__AddEntry_t)(void* _this, char* pText); 85 | typedef void* (__thiscall* _new_CMenu_t)(void* _this, int param_2, int param_3, char param_4, short param_5, short param_6, int param_7); 86 | static const CMenu__AddEntry_t CMenu__AddEntry = (CMenu__AddEntry_t)0x0044b830; 87 | static const _new_CMenu_t _new_CMenu = (_new_CMenu_t)0x0044b5e0; 88 | */ 89 | -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/CVector.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | 4 | struct SVector { 5 | int X; 6 | int Y; 7 | int Z; 8 | }; 9 | 10 | /* 11 | void __thiscall FUN_004c7f90(CVector3* v1, CVector3* v2) 12 | { 13 | v2->X = -v1->X; 14 | v2->Y = -v1->Y; 15 | v2->Z = -v1->Z; 16 | } 17 | */ -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Crowd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Crowd.h 5 | ====== 6 | - Crowd reaction logic in competition levels 7 | */ 8 | 9 | typedef void(*Crowd_Reset_t)(); //never called? 10 | typedef void(*Crowd_Init_t)(); //empty 11 | typedef void(*Crowd_Start_t)(); 12 | typedef void(*Crowd_Stop_t)(); 13 | typedef bool(*Crowd_MoveTowards_t)(int* value, int target, int step); 14 | typedef void(*Crowd_Update_t)(); 15 | typedef void(*Crowd_Cheer_t)(int score); 16 | typedef void(*Crowd_Oww_t)(int speed); 17 | typedef void(*Crowd_Ahh_t)(int score); 18 | typedef void(*Crowd_Boo_t)(int amount); 19 | 20 | static const Crowd_Reset_t Crowd_Reset = (Crowd_Reset_t)0x42f2b0; 21 | static const Crowd_Init_t Crowd_Init = (Crowd_Init_t)0x42f2c0; 22 | static const Crowd_Start_t Crowd_Start = (Crowd_Start_t)0x42f2d0; 23 | static const Crowd_Stop_t Crowd_Stop = (Crowd_Stop_t)0x42f340; 24 | //unknown, never called, maybe Crowd_Excitement? 42f390 25 | static const Crowd_MoveTowards_t Crowd_MoveTowards = (Crowd_MoveTowards_t)0x42f3b0; 26 | static const Crowd_Update_t Crowd_Update = (Crowd_Update_t)0x42f400; 27 | static const Crowd_Cheer_t Crowd_Cheer = (Crowd_Cheer_t)0x42f510; 28 | static const Crowd_Oww_t Crowd_Oww = (Crowd_Oww_t)0x42f650; 29 | static const Crowd_Ahh_t Crowd_Ahh = (Crowd_Ahh_t)0x42f6d0; 30 | static const Crowd_Boo_t Crowd_Boo = (Crowd_Boo_t)0x42f7d0; 31 | -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Flash.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "flash.h" 3 | 4 | namespace Flash { 5 | 6 | 7 | int* dR = (int*)0x0055e250; 8 | int* dG = (int*)0x0055e254; 9 | int* dB = (int*)0x0055e258; 10 | int* CurrentR = (int*)0x0055e25c; 11 | int* CurrentG = (int*)0x0055e260; 12 | int* CurrentB = (int*)0x0055e264; 13 | int* CurrentImportance = (int*)0x0055e268; 14 | int* FlashSort = (int*)0x0055e26c; 15 | int* FlashCountdown = (int*)0x0055e270; 16 | bool* Fading = (bool*)0x0055e274; 17 | int* FadeCountdown = (int*)0x0055e278; 18 | 19 | 20 | void Flash_Reset() { 21 | 22 | printf("DECOMP Flash_Reset()\n"); 23 | 24 | *FlashCountdown = 0; 25 | *FadeCountdown = 0; 26 | *Fading = false; 27 | *CurrentImportance = 0; 28 | } 29 | 30 | bool Flash_FadeFinished() { 31 | printf("DECOMP Flash_FadeFinished() = \n"); 32 | 33 | return *FadeCountdown == 0; 34 | } 35 | 36 | void Flash_Screen(char r, char g, char b, int time, int importance, int sort) { 37 | 38 | printf("DECOMP Flash_Screen()\n"); 39 | 40 | if (*CurrentImportance > importance) return; 41 | if (time == 0) return; 42 | 43 | *FlashCountdown = time; 44 | *FlashSort = sort; 45 | *CurrentImportance = importance; 46 | 47 | // assign color 48 | *CurrentR = r << 0x10; 49 | *CurrentG = g << 0x10; 50 | *CurrentB = b << 0x10; 51 | 52 | // calculate color delta 53 | *dR = *CurrentR / time; 54 | *dG = *CurrentG / time; 55 | *dB = *CurrentB / time; 56 | } 57 | 58 | 59 | 60 | void Flash_Fade(int time, int sort) { 61 | 62 | printf("DECOMP Flash_Fade()\n"); 63 | 64 | *Fading = true; 65 | 66 | *CurrentB = 0; 67 | *CurrentG = 0; 68 | *CurrentR = 0; 69 | 70 | *FadeCountdown = time; 71 | *CurrentImportance = 255; 72 | 73 | *dR = (int)(0xff0000 / time); 74 | *FlashSort = sort; 75 | } 76 | 77 | 78 | 79 | void Flash_Update() { 80 | if (!*Fading) { 81 | if (*FlashCountdown > 0) { 82 | (*FlashCountdown)--; 83 | 84 | if (*FlashCountdown == 0) { 85 | *CurrentImportance = 0; 86 | return; 87 | } 88 | 89 | *CurrentR -= *dR; 90 | *CurrentG -= *dB; 91 | *CurrentB -= *dG; 92 | } 93 | } 94 | else if (*FadeCountdown > 0) { 95 | (*FadeCountdown)--; 96 | 97 | if (*FadeCountdown == 0) { 98 | *CurrentB = 0xff0000; 99 | *CurrentG = 0xff0000; 100 | *CurrentR = 0xff0000; 101 | } else { 102 | *CurrentR += *dR; 103 | *CurrentG += *dR; 104 | *CurrentB += *dR; 105 | } 106 | } 107 | } 108 | 109 | 110 | 111 | 112 | 113 | 114 | // === hook stuff === 115 | 116 | Hook::Reroute hookList[] = { 117 | 118 | { 0x00458597, Flash_Reset }, 119 | { 0x0045867b, Flash_Reset }, 120 | { 0x0046974c, Flash_Reset }, 121 | { 0x0046a2d2, Flash_Reset }, 122 | 123 | { 0x0041a036, Flash_FadeFinished }, 124 | { 0x0041a606, Flash_FadeFinished }, 125 | { 0x00451c31, Flash_FadeFinished }, 126 | { 0x00451c5b, Flash_FadeFinished }, 127 | 128 | { 0x0040253a, Flash_Screen }, //ExecuteCommand 129 | 130 | { 0x0041a206, Flash_Fade }, 131 | { 0x0041a6e2, Flash_Fade }, 132 | { 0x0044f917, Flash_Fade }, 133 | { 0x0044fc5b, Flash_Fade }, 134 | { 0x0044ff62, Flash_Fade }, 135 | { 0x0045008a, Flash_Fade }, 136 | { 0x004511f6, Flash_Fade }, 137 | { 0x00451648, Flash_Fade }, 138 | { 0x00451755, Flash_Fade }, 139 | { 0x00451888, Flash_Fade }, 140 | { 0x00451b68, Flash_Fade }, 141 | 142 | { 0x0041a031, Flash_Update }, 143 | { 0x0041a601, Flash_Update }, 144 | { 0x00451c2c, Flash_Update }, 145 | { 0x00451c56, Flash_Update }, 146 | { 0x00469df8, Flash_Update }, 147 | 148 | //========================= 149 | { NULL, NULL } 150 | }; 151 | 152 | Hook::Reroute* pHookList = &hookList[0]; 153 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Flash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\patch\hook.h" 4 | 5 | namespace Flash { 6 | 7 | extern Hook::Reroute* pHookList; 8 | 9 | //typedef void(*Flash_Reset_t)(); 10 | //typedef bool(*Flash_FadeFinished_t)(); 11 | //typedef void(*Flash_Screen_t)(int p1, int p2, int p3, int p4, int p5, int p6); 12 | //typedef void(*Flash_Fade_t)(int time, int sort); 13 | //typedef void(*Flash_Update_t)(); 14 | typedef void(*Flash_Display_t)(); 15 | 16 | //static const Flash_Reset_t Flash_Reset = (Flash_Reset_t)0x449780; 17 | void Flash_Reset(); 18 | //static const Flash_FadeFinished_t Flash_FadeFinished = (Flash_FadeFinished_t)0x4497a0; 19 | bool Flash_FadeFinished(); 20 | //static const Flash_Screen_t Flash_Screen = (Flash_Screen_t)0x4497b0; 21 | void Flash_Screen(char r, char g, char b, int duration, int importance, int sort); 22 | //static const Flash_Fade_t Flash_Fade = (Flash_Fade_t)0x449840; 23 | void Flash_Fade(int time, int sort); 24 | //static const Flash_Update_t Flash_Update = (Flash_Update_t)0x449890; 25 | void Flash_Update(); 26 | static const Flash_Display_t Flash_Display = (Flash_Display_t)0x449950; 27 | 28 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Globals.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../patchStuff.h" 3 | 4 | 5 | char** DefaultHighScoreInitials = (char**)0x00521ec8; 6 | 7 | void* BaddyList = (void*)0x0055c31c; 8 | void* EnvironmentalObjectList = (void*)0x00567ba0; 9 | void* PowerUpList = (void*)0x00568490; 10 | void* SuspendedList = (void*)0x00567ba4; 11 | 12 | int* GStatus = (int*)0x0055e85c; 13 | bool* gotNewStatus = (bool*)0x0055e338; 14 | char** statusNames = (char**)0x00528cb0; 15 | 16 | SLevel* Levels = (SLevel*)0x538FF8; 17 | 18 | void* GSkater = (void*)0x5674b8; 19 | void* GSkater2 = (void*)0x5674bc; 20 | 21 | int* GNumberOfPlayers = (int*)0x00530d3c; 22 | 23 | int* ViewportMode = (int*)0x00567588; 24 | 25 | EGameMode* GGame = (EGameMode*)0x530d38; 26 | bool* GamePaused = (bool*)0x55e864; 27 | 28 | bool* Loading = (bool*)0x0055e230; 29 | int* LoadingTime = (int*)0x0055e8b0; 30 | int* ProcessingTime = (int*)0x0055e8b4; 31 | 32 | bool* GenerateLevel = (bool*)0x55e124; 33 | 34 | 35 | int* ScreenWidth = (int*)0x029D6FE4; 36 | int* ScreenHeight = (int*)0x029D6FE8; 37 | 38 | // in WINMAIN_SwitchResolution 39 | int* hardcodedWidth = (int*)0x4f3f30; 40 | int* hardcodedHeight = (int*)0x4f3f37; 41 | 42 | 43 | int* prevTicks = (int*)0x29d4fbc; 44 | int* Vblanks = (int*)0x56af7c; 45 | int* Xblanks = (int*)0x56af80; 46 | int* GameFrozen = (int*)0x567540; 47 | int* TTime = (int*)0x567534; 48 | 49 | int* gJoyEnabled = (int*)0x547a78; 50 | int* gAnalogsEnabled = (int*)0x6a1024; //?? 51 | 52 | int* GLevel = (int*)0x5674F8; 53 | int* InFrontEnd = (int*)0x5674e0; 54 | 55 | int* SFXLEVEL = (int*)0x528CA4; 56 | int* XALEVEL = (int*)0x528CA8; 57 | 58 | int* Redbook_XAFadeScale = (int*)0x53458C; 59 | 60 | 61 | int* Redbook_XAFading = (int*)0x5684F8; 62 | int* Redbook_XACurrentChannel = (int*)0x5684E8; 63 | int* Redbook_XACurrentGroup = (int*)0x5684EC; 64 | int* Redbook_XACurrentSector = (int*)0x5684C8; 65 | bool* Redbook_XACheckSectorOnVSync = (bool*)0x5684DC; 66 | int* Redbook_XAModeSet = (int*)0x5684DD; 67 | int* Redbook_XACompleteTimer = (int*)0x5684D8; 68 | int* Redbook_XAPaused = (int*)0x5684E0; 69 | bool* Redbook_XAValid = (bool*)0x5684e4; 70 | int* Redbook_XATryAgain = (int*)0x5684f0; 71 | int* Redbook_XASeeking = (int*)0x5684f4; 72 | 73 | int* Redbook_XAGroupStartingSector = (int*)0x5344fc; 74 | 75 | int* Redbook_XAStartSector = (int*)0x5684d4; 76 | int* Redbook_XAEndSector = (int*)0x5684c4; 77 | 78 | int* Redbook_PausedSongPos = (int*)0x55e350; 79 | 80 | int* Cheat_LevelSelect = (int*)0x567544; 81 | int* Cheat_Light = (int*)0x5674c8; 82 | int* Cheat_FlipScreen = (int*)0x005674ec; 83 | 84 | 85 | 86 | int* Trig_OffsetList = (int*)0x0056ae70; 87 | int* NumNodes = (int*)0x0056ae74; 88 | 89 | int* TotalRailNodes = (int*)0x005684bc; 90 | void* RailNodeLookup = (void*)0x005684b8; 91 | 92 | 93 | bool* AutoKickSetting = (bool*)0x00567038; 94 | bool* AutoKickState = (bool*)0x0055c88c; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Globals.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../patchStuff.h" 3 | 4 | //array of high score initials, NS devs 5 | extern char** DefaultHighScoreInitials; 6 | 7 | extern void* BaddyList; 8 | extern void* EnvironmentalObjectList; 9 | extern void* PowerUpList; 10 | extern void* SuspendedList; 11 | 12 | extern int* GStatus; 13 | extern bool* gotNewStatus; 14 | extern char** statusNames; 15 | 16 | extern SLevel* Levels; 17 | 18 | extern void* GSkater; 19 | extern void* GSkater2; 20 | 21 | extern int* GNumberOfPlayers; 22 | 23 | extern int* ViewportMode; 24 | 25 | extern EGameMode* GGame; 26 | extern bool* GamePaused; 27 | 28 | extern bool* Loading; 29 | extern int* LoadingTime; 30 | extern int* ProcessingTime; 31 | 32 | extern bool* GenerateLevel; 33 | 34 | extern int* ScreenWidth; 35 | extern int* ScreenHeight; 36 | 37 | extern int* hardcodedWidth; 38 | extern int* hardcodedHeight; 39 | 40 | extern int* prevTicks; 41 | extern int* Vblanks; 42 | extern int* Xblanks; 43 | extern int* GameFrozen; 44 | extern int* TTime; 45 | 46 | extern int* gJoyEnabled; 47 | extern int* gAnalogsEnabled; //?? 48 | 49 | extern int* GLevel; 50 | extern int* InFrontEnd; 51 | 52 | extern int* SFXLEVEL; 53 | extern int* XALEVEL; 54 | 55 | extern int* Redbook_XAFadeScale; 56 | extern int* Redbook_XAFading; 57 | 58 | extern int* Redbook_XACurrentChannel; 59 | extern int* Redbook_XACurrentGroup; 60 | extern int* Redbook_XACurrentSector; 61 | 62 | extern bool* Redbook_XACheckSectorOnVSync; 63 | extern int* Redbook_XAModeSet; 64 | extern int* Redbook_XACompleteTimer; 65 | extern int* Redbook_XAPaused; 66 | extern bool* Redbook_XAValid; 67 | extern int* Redbook_XATryAgain; 68 | extern int* Redbook_XASeeking; 69 | 70 | extern int* Redbook_XAStartSector; 71 | extern int* Redbook_XAEndSector; 72 | 73 | extern int* Redbook_PausedSongPos; 74 | 75 | extern int* Cheat_LevelSelect; 76 | extern int* Cheat_Light; 77 | extern int* Cheat_FlipScreen; 78 | 79 | 80 | extern int* Trig_OffsetList; 81 | extern int* NumNodes; 82 | 83 | extern int* TotalRailNodes; 84 | extern void* RailNodeLookup; 85 | 86 | 87 | extern bool* AutoKickSetting; 88 | extern bool* AutoKickState; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/IO/FileIO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\PKR.h" 4 | #include "..\..\patch\hook.h" 5 | 6 | namespace FileIO { 7 | 8 | extern Hook::Reroute* pHookList; 9 | 10 | typedef void (*FileIO_LoadHed_t)(); 11 | typedef void (*FileIO_UnLoadHed_t)(); 12 | typedef void (*FileIO_AddDirToFileName_t)(char* filename); 13 | typedef void (*FileIO_AddSubDirToFileName_t)(char* filename); 14 | //typedef void* (*FileIO_OpenLoad_t)(char* filename, int heap); 15 | //typedef void (*FileIO_SetSectorsPerFrame_t)(int sectorsPerFrame); 16 | typedef void (*FileIO_Init_t)(); 17 | typedef int (*FileIO_Open_t)(char* filename); 18 | typedef void (*FileIO_Load_t)(void* ptr); 19 | // typedef bool (*FileIO_Exists_t)(char* filename); 20 | typedef void (*FileIO_Continue_t)(); 21 | // typedef void (*FileIO_Sync_t)(); 22 | // typedef char* (*FileIO_GetSubDir_t)(); 23 | // typedef void (*FileIO_SetSubDir_t)(char* filename); 24 | 25 | static const FileIO_LoadHed_t FileIO_LoadHed = (FileIO_LoadHed_t)0x00448c00; 26 | static const FileIO_UnLoadHed_t FileIO_UnloadHed = (FileIO_UnLoadHed_t)0x00448c30; 27 | // unused calc checksum func here 00448c50 28 | static const FileIO_AddDirToFileName_t FileIO_AddDirToFileName = (FileIO_AddDirToFileName_t)0x00448ca0; 29 | static const FileIO_AddSubDirToFileName_t FileIO_AddSubDirToFileName = (FileIO_AddSubDirToFileName_t)0x00448cd0; 30 | //static const FileIO_OpenLoad_t FileIO_OpenLoad = (FileIO_OpenLoad_t)0x448D70; 31 | void* FileIO_OpenLoad(char* filename, int Heap); 32 | // static const FileIO_SetSectorsPerFrame_t FileIO_SetSectorsPerFrame = (FileIO_SetSectorsPerFrame_t)0x00448ee0; 33 | void FileIO_SetSectorsPerFrame(int sectorsPerFrame); 34 | static const FileIO_Init_t FileIO_Init = (FileIO_Init_t)0x00448ef0; 35 | static const FileIO_Open_t FileIO_Open = (FileIO_Open_t)0x00448fd0; 36 | static const FileIO_Load_t FileIO_Load = (FileIO_Load_t)0x004491d0; 37 | // unused close func here 00449390 38 | // static const FileIO_Exists_t FileIO_Exists = (FileIO_Exists_t)0x00449400; 39 | bool FileIO_Exists(char* filename); 40 | static const FileIO_Continue_t FileIO_Continue = (FileIO_Continue_t)0x00449450; 41 | //static const FileIO_Sync_t FileIO_Sync = (FileIO_Sync_t)0x00449600; 42 | void FileIO_Sync(); 43 | // static const FileIO_GetSubDir_t FileIO_GetSubDir = (FileIO_GetSubDir_t)0x00449690; 44 | char* FileIO_GetSubDir(); 45 | //static const FileIO_SetSubDir_t FileIO_SetSubDir = (FileIO_SetSubDir_t)0x004496a0; 46 | char* FileIO_SetSubDir(char* path); 47 | 48 | typedef void(*LoadingScreen_UpdateProgress_t)(); 49 | static const LoadingScreen_UpdateProgress_t LoadingScreen_UpdateProgress = (LoadingScreen_UpdateProgress_t)0x0045d600; 50 | 51 | //typedef bool(*tryOpenFile_t)(char* path, char* filename); 52 | //static const tryOpenFile_t tryOpenFile = (tryOpenFile_t)0x004f3900; 53 | bool Exists(char* path, char* filename); 54 | 55 | } 56 | 57 | //void* FileIO_OpenLoad_Pkr(char* filename, bool heap, Pkr2* pkr); 58 | -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/IO/PCIO.h: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | /* 4 | Functions to acces files on PC. 5 | It wraps PKR loading and fallback disk access in case PKR is missing. 6 | 7 | the logic is it has a static file queue of size 10. 8 | whenever you open a file, it finds a free slot and loads data either from PKR or disk. 9 | most functions use file index in the queue. 10 | 11 | not sure what file was called originally 12 | */ 13 | 14 | typedef void(*PCinit_t)(); 15 | typedef void(*PCstop_t)(); 16 | typedef void(*PCremove_t)(); 17 | typedef int(*PCopen_t)(char* filename, int mode); // returns file ID 18 | typedef int(*getFreeFileIndex_t)(); 19 | typedef void*(*PCcreate_t)(char* filename); 20 | typedef long(*PClseek_t)(int fileID, int offset, int origin); 21 | typedef void(*PCread_t)(); 22 | typedef void(*PCwrite_t)(); 23 | typedef void(*PCclose_t)(int file); 24 | 25 | static const PCinit_t PCinit = (PCinit_t)0x004e45c0; 26 | static const PCstop_t PCstop = (PCstop_t)0x004e46c0; 27 | static const PCremove_t PCremove = (PCremove_t)0x004e46d0; 28 | static const PCopen_t PCopen = (PCopen_t)0x004e4780; 29 | static const getFreeFileIndex_t getFreeFileIndex = (getFreeFileIndex_t)0x004e4ab0; 30 | static const PCcreate_t PCcreate = (PCcreate_t)0x004e4ad0; 31 | static const PClseek_t PClseek = (PClseek_t)0x004e4bc0; 32 | static const PCread_t PCread = (PCread_t)0x004e4ca0; 33 | static const PCwrite_t PCwrite = (PCwrite_t)0x004e4d30; 34 | static const PCclose_t PCclose = (PCclose_t)0x004e4d90; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Init.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "thawk2.h" 3 | #include "types.h" 4 | #include "Flash.h" 5 | 6 | 7 | //demo viewport, final is different 8 | struct SViewport { 9 | int xR; 10 | int yB; 11 | int xL; 12 | int yT; 13 | int Hither; 14 | int Yon; 15 | int TanHalf; 16 | }; 17 | 18 | typedef struct SViewport SViewport; 19 | 20 | 21 | uint* Camera_RandA = (uint*)0x0055c418; 22 | uint* Camera_RandB = (uint*)0x0055c41c; 23 | uint* Camera_RandSeed = (uint*)0x0055c608; 24 | 25 | #define RANDOM_SEED 0x9f6ad 26 | 27 | void Camera_InitialRand(uint seed) 28 | { 29 | *Camera_RandA = 0x12b9b0a1; 30 | *Camera_RandB = 0xaa2fb3f; 31 | *Camera_RandSeed = seed; 32 | } 33 | 34 | 35 | int* PCMemBuffer = (int*)0x0055ec78; 36 | 37 | #define RAM_SIZE 32 * 1024 * 1024 //original is 6 * 1000 * 1024 for whatever reason 38 | 39 | //SViewport, missing for now 40 | int* pCurrentViewport = (int*)0x00560698; 41 | 42 | /// 43 | /// Initialize various stuff, including memory space and game systems. 44 | /// 45 | void Init_AtStart() 46 | { 47 | printf("decomp Init_AtStart called..."); 48 | 49 | //something like this? 50 | 51 | //allocate buffer 52 | *PCMemBuffer = (int)malloc(RAM_SIZE); 53 | 54 | if (!*PCMemBuffer) throw; 55 | 56 | //clear memory 57 | memset((void*)(*PCMemBuffer), 0, RAM_SIZE); 58 | 59 | //_ResetCallback(); 60 | 61 | //init memory card stuff 62 | MMU_Init(); 63 | 64 | //set default viewport 65 | *pCurrentViewport = 0x00530da8; //&_ApocalypseViewport; 66 | 67 | //initialize mem stuff 68 | Init_ResetMemory(0x10); //heap0size? sup? 69 | 70 | //initialize pad system 71 | Pad_InitAtStart(); 72 | 73 | 74 | 75 | //_InitGeom(); 76 | //_ResetGraph(0); 77 | //_SetGraphDebug(0); 78 | 79 | //sets psyq draw callback, not needed 80 | //Db_InitAtStart(); 81 | 82 | //not required in the port 83 | //local_8 = 0; 84 | //local_6 = 0; 85 | //local_4 = 0x400; 86 | //local_2 = 0x200; 87 | //_ClearImage(&local_8, 0, 0, 0); 88 | 89 | //_VSyncCallback(MyVSync); 90 | //_SetDispMask(1); 91 | 92 | //empty func 93 | //Init_DebugStuff(); 94 | 95 | //only sets up random values 96 | Camera_InitialRand(RANDOM_SEED); 97 | 98 | //does nothing in the port 99 | //SFX_InitAtStart(); 100 | 101 | FileIO::FileIO_Init(); 102 | 103 | //empty func, must be something on psx 104 | //GameFMV_Init(); 105 | 106 | //inits m3d stuff, sets resolution 107 | M3dInit_InitAtStart(); 108 | 109 | //resets redbook globals 110 | Redbook::Redbook_XAInit(); 111 | 112 | Career_SaveCharacterStates(); 113 | 114 | Career_Init(); 115 | 116 | Front_ClearGVideoRestartData(); 117 | 118 | printf("done\n"); 119 | } 120 | 121 | 122 | #define HARD_CLEANUP 0 123 | #define SOFT_CLEANUP 1 124 | #define EDITOR_CLEANUP 2 125 | 126 | int* TitleTimeout = (int*)0x00528cac; 127 | 128 | void Init_Restart() 129 | { 130 | printf("decomp Init_Restart called\n"); 131 | 132 | Init_Cleanup(HARD_CLEANUP); 133 | 134 | Db_Reset(); 135 | 136 | Spool_Init(); 137 | 138 | *TitleTimeout = 0x14; 139 | 140 | Flash::Flash_Reset(); 141 | 142 | //unused in the port 143 | //Pack_Init(); 144 | 145 | //unused in the port 146 | //SFX_InitAtStart(); 147 | 148 | Pal_Init(0x100, 0x50); 149 | } 150 | 151 | 152 | void Init_KillAll() 153 | { 154 | /* 155 | NETGAME_DeletePlayers(); 156 | 157 | DeleteList(MechList); 158 | 159 | // do this for every list 160 | //if (MechList != 0) 161 | // printf("Leftover protected members of MechList\n"); 162 | 163 | DeleteList(CameraList); 164 | DeleteList(BaddyList); 165 | DeleteList(EnvironmentalObjectList); 166 | DeleteList(BackgroundList); 167 | DeleteList(PowerUpList); 168 | DeleteList(SuspendedList); 169 | 170 | TrickOb_DeleteAll(); 171 | Rail_DeleteAll(); 172 | Bit_DeleteAll(); 173 | */ 174 | 175 | Mess_DeleteAll(); 176 | } 177 | 178 | 179 | void TH2Main() 180 | { 181 | printf("th2 main here!\n"); 182 | 183 | //psyq call 184 | //_SetDispMask(0); 185 | 186 | //not used in the port, init relocatable modules 187 | //Reloc_Init(); 188 | 189 | Options_Init(); 190 | 191 | Init_AtStart(); 192 | 193 | Init_Restart(); //the params were passed to init_resetmemory inside, but it was removed in the port i guess - ( 0, 0x10); 194 | 195 | Db_Init(0, 0, 1, 0); 196 | 197 | //does nothing in release 198 | //Mem_SuperDebugUsage(); 199 | 200 | if (!options.SkipIntro) 201 | IntroMovies(); 202 | 203 | //show title screen 204 | LogoScreen(); 205 | 206 | //and load into the main menu 207 | FrontEnd2_Main(); 208 | 209 | /* 210 | //this is just to show "shutting down" string, removed 211 | FontManager::LoadFont(s_s2tricks.fnt_005224d0); 212 | Pause(2); 213 | */ 214 | 215 | //memory card related, calls 2 empty funcs in the port 216 | //MMU_Uninit(); 217 | 218 | Init_AtEnd(); 219 | } 220 | 221 | 222 | int* CamPtIndex = (int*)0x0055c744; 223 | 224 | void CamPt_Init() 225 | { 226 | *CamPtIndex = 0; 227 | } 228 | 229 | void Init_ForGame() 230 | { 231 | printf("decomp Init_ForGame\n"); 232 | 233 | *pCurrentViewport = 0x00530da8; //&_ApocalypseViewport; 234 | 235 | Front_Init(); 236 | 237 | Video_InitOnce(); 238 | 239 | CamPt_Init(); 240 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Init.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Init_Restart(); 4 | void Init_AtStart(); 5 | void Init_ForGame(); 6 | //void Init_KillAll(); 7 | 8 | void TH2Main(); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/LoadingScreen.h: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | typedef void (*LoadingScreen_Text_t)(char* bitmap, char* text, char param_3); 4 | typedef void (*LoadingScreen_GaugeOn_t)(int param_1, int param_2, int param_3, int param_4); 5 | typedef void (*LoadingScreen_GaugeOff_t)(); 6 | typedef void (*LoadingScreen_UpdateProgress_t)(); 7 | typedef void (*LoadingScreen_UpdateProgressForRailGeneration_t)(char param_1); 8 | typedef void (*LoadingScreen_RemoveBar_t)(); 9 | typedef void (*LoadingScreen_StartLoading_t)(int param_1); 10 | typedef void (*LoadingScreen_EndLoading_t)(); 11 | 12 | static const LoadingScreen_Text_t LoadingScreen_Text = (LoadingScreen_Text_t)0x45cf80; 13 | static const LoadingScreen_GaugeOn_t LoadingScreen_GaugeOn = (LoadingScreen_GaugeOn_t)0x45d550; 14 | static const LoadingScreen_GaugeOff_t LoadingScreen_GaugeOff = (LoadingScreen_GaugeOff_t)0x45d5f0; 15 | static const LoadingScreen_UpdateProgress_t LoadingScreen_UpdateProgress = (LoadingScreen_UpdateProgress_t)0x45d600; 16 | static const LoadingScreen_UpdateProgressForRailGeneration_t LoadingScreen_UpdateProgressForRailGeneration = (LoadingScreen_UpdateProgressForRailGeneration_t)0x45d6d0; 17 | static const LoadingScreen_RemoveBar_t LoadingScreen_RemoveBar = (LoadingScreen_RemoveBar_t)0x45d710; 18 | static const LoadingScreen_StartLoading_t LoadingScreen_StartLoading = (LoadingScreen_StartLoading_t)0x45d7a0; 19 | static const LoadingScreen_EndLoading_t LoadingScreen_EndLoading = (LoadingScreen_EndLoading_t)0x45dad0; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Mem.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Mem.h" 3 | 4 | /// 5 | /// Basically memcpy wrapper. 6 | /// Original game implements simple for loop and copies it byte by byte. 7 | /// 8 | /// Source address 9 | /// Destination address 10 | /// Buffer length 11 | void Mem_CopyBytes(void* _Dst, void* _Src, int _Size) 12 | { 13 | printf("copying from %i to %i, %i bytes... ", _Src, _Dst, _Size); 14 | 15 | if (_Size > 0) 16 | memcpy(_Dst, _Src, _Size); 17 | 18 | printf("done!\n"); 19 | } 20 | 21 | void Mem_Delete(void* pData) 22 | { 23 | printf("mem_delete! %i", pData); 24 | 25 | Mem_DeleteX( 26 | (void*) (((int*)pData)+1 ) 27 | ); 28 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Mem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SBlockHeader { 4 | size_t Size; 5 | int ParentHeap; 6 | SBlockHeader* Next; 7 | }; 8 | 9 | typedef struct SBlockHeader SBlockHeader; 10 | 11 | 12 | typedef int (*Mem_Init_t)(); 13 | typedef int* (*Mem_NewX_t)(size_t size, int Heap, int AssertOnFailure, void* Location); 14 | typedef void (*Bang_t)(int param_1, int param_2, int param_3); //psx leftover, originally draws red rectangle in the top right 15 | typedef int* (*Mem_NewTop_t)(int param_1); 16 | typedef void (*Mem_DeleteX_t)(void* p); 17 | typedef void (*Mem_ShrinkX_t)(void* param_1, int param_2); 18 | typedef int (*Mem_GetBlockSizeX_t)(int param_1); 19 | typedef int (*Mem_GetFree_t)(int param_1); 20 | typedef void (*Mem_Copy_t)(void* src, void* dst, int size); //assumed, check if matches 21 | //typedef void (*Mem_CopyBytes_t)(int src, int dst, int size); //assumed, check if matches 22 | typedef void (*Mem_Swap_t)(void* src, void* dst, int size); //assumed, check if matches 23 | typedef void (*Mem_SuperDebugUsage_t)(); //unused leftover 24 | typedef void (*Mem_NoCheck_t)(void* param_1); //unused leftover 25 | typedef void (*SuperMem_CheckForLeaks_t)(); //unused leftover 26 | typedef void* (*Mem_New_t)(size_t size, int Heap, int AssertOnFailure, void* Location); 27 | //typedef void (*Mem_Delete_t)(void* p); 28 | typedef void (*Mem_Shrink_t)(void* param_1, int param_2); 29 | typedef void (*Mem_GetBlockSize_t)(int param_1); 30 | 31 | static const Mem_Init_t Mem_Init = (Mem_Init_t)0x0046e850; 32 | static const Mem_NewX_t Mem_NewX = (Mem_NewX_t)0x0046e950; 33 | static const Bang_t Bang = (Bang_t)0x0046edb0; 34 | static const Mem_NewTop_t Mem_NewTop = (Mem_NewTop_t)0x0046edd0; 35 | static const Mem_DeleteX_t Mem_DeleteX = (Mem_DeleteX_t)0x0046ef90; 36 | static const Mem_ShrinkX_t Mem_ShrinkX = (Mem_ShrinkX_t)0x0046f070; 37 | static const Mem_GetBlockSizeX_t Mem_GetBlockSizeX = (Mem_GetBlockSizeX_t)0x0046f1e0; 38 | static const Mem_GetFree_t Mem_GetFree = (Mem_GetFree_t)0x0046f250; 39 | static const Mem_Copy_t Mem_Copy = (Mem_Copy_t)0x0046f270; 40 | //static const Mem_CopyBytes_t Mem_CopyBytes = (Mem_CopyBytes_t)0x0046f340; 41 | void Mem_CopyBytes(void* _Dst, void* _Src, int _Size); 42 | static const Mem_Swap_t Mem_Swap = (Mem_Swap_t)0x0046f370; 43 | static const Mem_SuperDebugUsage_t Mem_SuperDebugUsage = (Mem_SuperDebugUsage_t)0x0046f3f0; 44 | static const Mem_NoCheck_t Mem_NoCheck = (Mem_NoCheck_t)0x0046f400; 45 | static const SuperMem_CheckForLeaks_t SuperMem_CheckForLeaks = (SuperMem_CheckForLeaks_t)0x0046f410; 46 | static const Mem_New_t Mem_New = (Mem_New_t)0x0046f420; 47 | //static const Mem_Delete_t Mem_Delete = (Mem_Delete_t)0x0046f460; 48 | void Mem_Delete(void* p); 49 | static const Mem_Shrink_t Mem_Shrink = (Mem_Shrink_t)0x0046f470; 50 | static const Mem_GetBlockSize_t Mem_GetBlockSize = (Mem_GetBlockSize_t)0x0046f4a0; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Mess.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../color.h" 3 | 4 | /* 5 | Mess.h 6 | ====== 7 | - Mess namespace handles message queue 8 | - message queue is a doubly linked list of SMessage instances 9 | - messages are drawn on the screen using "message programs", which is a set of states (color, position, scale, etc). 10 | */ 11 | 12 | enum class eTextJustify : char { 13 | Left = 0, 14 | Center = 1, 15 | Middle = 1, 16 | Right = 2 17 | }; 18 | 19 | typedef struct SMessageProg 20 | { 21 | short Duration; 22 | char Semitrans; 23 | eTextJustify Justify; 24 | short StartScale; 25 | short EndScale; 26 | 27 | ColorRGB StartColor; 28 | ColorRGB EndColor; 29 | 30 | short StartAngle; 31 | short EndAngle; 32 | 33 | short StartX; 34 | short StartY; 35 | short EndX; 36 | short EndY; 37 | 38 | short FlashDuration; 39 | short ColorCycle; 40 | short NextOff; 41 | } SMessageProg; 42 | 43 | 44 | typedef struct SMessage { 45 | char* pText; 46 | short T; //current mess prog counter 47 | short T_total; //total message counter 48 | short xOffset; 49 | short yOffset; 50 | int recenter; 51 | SMessageProg* pProg; 52 | SMessage* pNext; 53 | SMessage* pPrevious; 54 | } SMessage; 55 | 56 | //typedef void (*Mess_SetTextJustify_t)(eTextJustify justify); 57 | //typedef void(*Mess_SetScale_t)(int scale); 58 | //typedef int(*Mess_GetScale_t)(); 59 | typedef void (*Mess_SetSort_t)(int sort); 60 | //typedef void(*Mess_SetRGB_t)(int r, int g, int b, bool semitrans); 61 | //typedef void (*Mess_DrawPanelText_t)((int x, int y, char* pMessage, int Angle); 62 | //typedef void (*Mess_DeleteMessage_t)(SMessage* pMess); 63 | //typedef void (*Mess_DeleteAll_t)(); 64 | typedef bool (*Mess_MessageExists_t)(SMessage* pMess); //never used 65 | //typedef void (*Mess_Remove_t)(SMessage* pMess); 66 | //typedef void (*Mess_Message_t)(char* text, void* messProg, int param_3, int x, int y); 67 | //typedef SMessage* (*CreateMessage_t)(); 68 | //typedef void (*Mess_Update_t)(); 69 | typedef void (*Mess_Display_t)(); 70 | typedef int (*Mess_TextWidth_t)(char* pMessage); //never used 71 | //typedef void (*Mess_DrawText_t)(int x, int y, char* pMessage, int Angle); 72 | typedef void* (*Mess_LoadFont_t)(char* filename, int param_2, int param_3); 73 | typedef void (*Mess_UnloadFont_t)(); 74 | //typedef void (*Mess_SetCurrentFont_t)(void* pFont); 75 | //typedef void (*Mess_SetCurrentFont2_t)(char* fontName); //overload 76 | 77 | //static const Mess_SetTextJustify_t Mess_SetTextJustify = (Mess_SetTextJustify_t)0x473440; 78 | void Mess_SetTextJustify(eTextJustify justify); 79 | //static const Mess_SetScale_t Mess_SetScale = (Mess_SetScale_t)0x473480; 80 | void Mess_SetScale(int scale); 81 | //static const Mess_GetScale_t Mess_GetScale = (Mess_GetScale_t)0x473490; 82 | int Mess_GetScale(); 83 | static const Mess_SetSort_t Mess_SetSort = (Mess_SetSort_t)0x4734a0; 84 | //static const Mess_SetRGB_t Mess_SetRGB = (Mess_SetRGB_t)0x473510; 85 | void Mess_SetRGB(int r, int g, int b, bool semitrans); 86 | //static const Mess_DrawPanelText_t Mess_DrawPanelText = (Mess_DrawPanelText_t)0x473540; 87 | void Mess_DrawPanelText(int x, int y, char *pMessage, int Angle); 88 | //static const Mess_DeleteMessage_t Mess_DeleteMessage = (Mess_DeleteMessage_t)0x473560; 89 | void Mess_DeleteMessage(SMessage* mess); 90 | //static const Mess_DeleteAll_t Mess_DeleteAll = (Mess_DeleteAll_t)0x4735E0; 91 | void Mess_DeleteAll(); 92 | static const Mess_MessageExists_t Mess_MessageExists = (Mess_MessageExists_t)0x473620; //never used 93 | //static const Mess_Remove_t Mess_Remove = (Mess_Remove_t)0x473650; 94 | void Mess_Remove(SMessage* pMess); 95 | //static const Mess_Message_t Mess_Message = (Mess_Message_t)0x473680; 96 | void Mess_Message(char* pText, SMessageProg* pProg, bool recenter, short xOffset, short yOffset); 97 | //static const CreateMessage_t CreateMessage = (CreateMessage_t)0x4736c0; 98 | SMessage* CreateMessage(); 99 | //static const Mess_Update_t Mess_Update = (Mess_Update_t)0x4736f0; 100 | void Mess_Update(); 101 | static const Mess_Display_t Mess_Display = (Mess_Display_t)0x473750; 102 | static const Mess_TextWidth_t Mess_TextWidth = (Mess_TextWidth_t)0x00473960; //never used 103 | //static const Mess_DrawText_t Mess_DrawText = (Mess_DrawText_t)0x473970; 104 | void Mess_DrawText(int x, int y, char* pMessage, int Angle); 105 | static const Mess_LoadFont_t Mess_LoadFont = (Mess_LoadFont_t)0x473990; 106 | static const Mess_UnloadFont_t Mess_UnoadFont = (Mess_UnloadFont_t)0x473b10; 107 | //static const Mess_SetCurrentFont_t Mess_SetCurrentFont = (Mess_SetCurrentFont_t)0x473b70; 108 | void Mess_SetCurrentFont(void* pFont); 109 | //static const Mess_SetCurrentFont2_t Mess_SetCurrentFont2 = (Mess_SetCurrentFont_t)0x473b80; 110 | void Mess_SetCurrentFont(char* fontName); 111 | 112 | void Mess_SetScale_Wrap(int scale); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/PCInput.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | int* pad1 = (int*)0x00567c58; 4 | int* pad2 = (int*)0x00567dc4; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/PCInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows.h" 4 | 5 | //PCINPUT namespace handles keyboard, mouse and joystick input via DirectInput 6 | 7 | extern int* pad1; 8 | extern int* pad2; 9 | 10 | typedef void(*PCINPUT_ResetGameControls_t)(); 11 | typedef void(*PCINPUT_SetShellMode_t)(int mode); 12 | typedef void(*PCINPUT_ForceButton_t)(short param); 13 | typedef bool(*IsDIKeyPressed_t)(int key); 14 | typedef int(*PCINPUT_GetDIKeyPressed_t)(int param); 15 | typedef int(*PCINPUT_GetAsciiCode_t)(int param); 16 | typedef void(*PCINPUT_GetKeyName_t)(); 17 | typedef int(*PCINPUT_GetJoyButtonPressed_t)(); 18 | typedef void(*PCINPUT_ClearAllTriggers_t)(); 19 | typedef void(*PCINPUT_EnableJoypad_t)(int state); 20 | typedef void(*GenPsxPadData_t)(); 21 | typedef int(*GetFakePsxPadData_t)(); 22 | typedef void(*InitDirectInput_t)(HWND hWnd, HINSTANCE hInstance); //PCINPUT_Init?? 23 | typedef void(*PCINPUT_ShutDown_t)(); 24 | typedef void(*ReadDirectInput_t)(); //PCINPUT_Update?? 25 | typedef void(*PCINPUT_DoWinKeyDown_t)(); //empty 26 | typedef void(*PCINPUT_HandleMouseMessage_t)(int message); 27 | typedef void(*PCINPUT_SetCursorPos_t)(int x, int y); 28 | typedef void(*PCINPUT_ActuatorOn_t)(int param_1, int param_2, int param_3, int param_4); 29 | typedef void(*PCINPUT_ActuatorOff_t)(int padIndex, int motorIndex); 30 | typedef void(*PCINPUT_StopVibrations_t)(); 31 | typedef void(*PCINPUT_Load_t)(); 32 | typedef void(*PCINPUT_Save_t)(); 33 | 34 | static const PCINPUT_ResetGameControls_t PCINPUT_ResetGameControls = (PCINPUT_ResetGameControls_t)0x4e1040; 35 | static const PCINPUT_SetShellMode_t PCINPUT_SetShellMode = (PCINPUT_SetShellMode_t)0x4e1140; 36 | static const PCINPUT_ForceButton_t PCINPUT_ForceButton = (PCINPUT_ForceButton_t)0x4e1350; 37 | static const IsDIKeyPressed_t IsDIKeyPressed = (IsDIKeyPressed_t)0x4e1370; 38 | static const PCINPUT_GetDIKeyPressed_t PCINPUT_GetDIKeyPressed = (PCINPUT_GetDIKeyPressed_t)0x4e1390; 39 | static const PCINPUT_GetAsciiCode_t PCINPUT_GetAsciiCode = (PCINPUT_GetAsciiCode_t)0x4e13f0; 40 | static const PCINPUT_GetKeyName_t PCINPUT_GetKeyName = (PCINPUT_GetKeyName_t)0x4e1420; 41 | static const PCINPUT_GetJoyButtonPressed_t PCINTPUT_GetJoyButtonPressed = (PCINPUT_GetJoyButtonPressed_t)0x4e1430; 42 | static const PCINPUT_ClearAllTriggers_t PCINPUT_ClearAllTriggers = (PCINPUT_ClearAllTriggers_t)0x4e1460; 43 | static const PCINPUT_EnableJoypad_t PCINPUT_EnableJoypad = (PCINPUT_EnableJoypad_t)0x4e1480; 44 | static const GenPsxPadData_t GenPsxPadData = (GenPsxPadData_t)0x4e1490; 45 | static const GetFakePsxPadData_t GetFakePsxPadData = (GetFakePsxPadData_t)0x4e1820; 46 | static const InitDirectInput_t InitDirectInput = (InitDirectInput_t)0x4e1860; 47 | static const PCINPUT_ShutDown_t PCINPUT_ShutDown = (PCINPUT_ShutDown_t)0x4e1c30; 48 | static const ReadDirectInput_t ReadDirectInput = (ReadDirectInput_t)0x4e1c60; 49 | static const PCINPUT_DoWinKeyDown_t PCINPUT_DoWinKeyDown = (PCINPUT_DoWinKeyDown_t)0x4e1db0; 50 | static const PCINPUT_HandleMouseMessage_t PCINPUT_HandleMouseMessage = (PCINPUT_HandleMouseMessage_t)0x4e1dc0; 51 | static const PCINPUT_SetCursorPos_t PCINPUT_SetCursorPos = (PCINPUT_SetCursorPos_t)0x4e1de0; 52 | static const PCINPUT_ActuatorOn_t PCINPUT_ActuatorOn = (PCINPUT_ActuatorOn_t)0x4e1e10; 53 | static const PCINPUT_ActuatorOff_t PCINPUT_ActuatorOff = (PCINPUT_ActuatorOff_t)0x4e1eb0; 54 | static const PCINPUT_StopVibrations_t PCINPUT_StopVibrations = (PCINPUT_StopVibrations_t)0x4e1ec0; 55 | static const PCINPUT_Load_t PCINPUT_Load = (PCINPUT_Load_t)0x4e1ee0; 56 | static const PCINPUT_Save_t PCINPUT_Save = (PCINPUT_Save_t)0x4e2630; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/PCMovie.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "thawk2\thawk2.h" 3 | 4 | namespace PCMovie 5 | { 6 | bool* gMusicPlaying = (bool*)0x006a3930; 7 | 8 | void PCMOVIE_XAPlay(int group, int channel) 9 | { 10 | printf("DECOMP PCMOVIE_XAPlay()\n"); 11 | 12 | int curTrack = channel + group * 8; 13 | 14 | //ambience track? 15 | if (curTrack < 15) 16 | { 17 | char buf[256]; 18 | sprintf(buf, "%s%02i%s", "ltix", curTrack, ".dat"); 19 | PCMovie::PCMOVIE_StartMusic(buf); 20 | } 21 | else 22 | { 23 | PCMovie::PCMOVIE_StartMusic(&Redbook::playingFile[0u]); 24 | } 25 | } 26 | 27 | bool PCMOVIE_XADone() 28 | { 29 | return !*gMusicPlaying; 30 | } 31 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/PCMovie.h: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "..\patch\hook.h" 3 | 4 | namespace PCMovie 5 | { 6 | extern bool* gMusicPlaying; 7 | 8 | typedef void(*SetupFullScreenMovie_t)(); 9 | typedef void(*DrawFullScreenMovie_t)(); 10 | typedef void(*InitBink_thunk_t)(); 11 | typedef void(*InitBink_t)(); 12 | typedef int(*PCMOVIE_PlayMovieFile_t)(char*); 13 | typedef int(*CreateBinkSurface_t)(); 14 | typedef int(*StartBinkMovie_t)(char*, int, int); 15 | typedef int(*NextBinkFrame_t)(); 16 | typedef void(*CloseBinkMovie_t)(); 17 | typedef void(*BinkMovieUpdate_t)(); 18 | typedef void(*PCMOVIE_Pause_t)(bool state); 19 | typedef void(*PCMOVIE_DrawWindow_t)(int); 20 | typedef char*(*PCMOVIE_GetMovieName_t)(int index); 21 | typedef void(*PCMOVIE_PlayGameFMV_t)(); 22 | typedef void(*PCMOVIE_StartFMV_t)(); 23 | typedef void(*PCMOVIE_StopFMV_t)(); 24 | typedef void(*PCMOVIE_Update_t)(); 25 | typedef void(*MusicThreadProc_t)(); 26 | typedef bool(*PCMOVIE_StartMusic_t)(char*); 27 | typedef void(*PCMOVIE_SetXAVolume_t)(int left, int right); 28 | //typedef void(*PCMOVIE_XAPlay_t)(int group, int channel); 29 | typedef void(*PCMOVIE_XAStop_t)(); 30 | //typedef bool(*PCMOVIE_XADone_t)(); 31 | 32 | static const SetupFullScreenMovie_t SetupFullScreenMovie = (SetupFullScreenMovie_t)0x004e28f0; 33 | static const DrawFullScreenMovie_t DrawFullScreenMovie = (DrawFullScreenMovie_t)0x004e2c50; 34 | static const InitBink_thunk_t InitBink_thunk = (InitBink_thunk_t)0x004e3050; 35 | static const InitBink_t InitBink = (InitBink_t)0x004e3060; 36 | static const PCMOVIE_PlayMovieFile_t PCMOVIE_PlayMovieFile = (PCMOVIE_PlayMovieFile_t)0x004e3090; 37 | static const CreateBinkSurface_t CreateBinkSurface = (CreateBinkSurface_t)0x004e31f0; 38 | static const StartBinkMovie_t StartBinkMovie = (StartBinkMovie_t)0x004e3760; 39 | static const NextBinkFrame_t NextBinkFrame = (NextBinkFrame_t)0x004e3a60; 40 | static const CloseBinkMovie_t CloseBinkMovie = (CloseBinkMovie_t)0x004e3f70; 41 | static const BinkMovieUpdate_t BinkMovieUpdate = (BinkMovieUpdate_t)0x004e4020; 42 | static const PCMOVIE_Pause_t PCMOVIE_Pause = (PCMOVIE_Pause_t)0x004e4040; 43 | static const PCMOVIE_DrawWindow_t PCMOVIE_DrawWindow = (PCMOVIE_DrawWindow_t)0x004e40d0; 44 | static const PCMOVIE_GetMovieName_t PCMOVIE_GetMovieName = (PCMOVIE_GetMovieName_t)0x004e4240; 45 | static const PCMOVIE_PlayGameFMV_t PCMOVIE_PlayGameFMV = (PCMOVIE_PlayGameFMV_t)0x004e4260; 46 | static const PCMOVIE_StartFMV_t PCMOVIE_StartFMV = (PCMOVIE_StartFMV_t)0x004e42b0; 47 | static const PCMOVIE_StopFMV_t PCMOVIE_StopFMV = (PCMOVIE_StopFMV_t)0x004e4310; 48 | static const PCMOVIE_Update_t PCMOVIE_Update = (PCMOVIE_Update_t)0x004e4390; 49 | static const MusicThreadProc_t MusicThreadProc = (MusicThreadProc_t)0x004e43a0; 50 | static const PCMOVIE_StartMusic_t PCMOVIE_StartMusic = (PCMOVIE_StartMusic_t)0x004e4430; 51 | static const PCMOVIE_SetXAVolume_t PCMOVIE_SetXAVolume = (PCMOVIE_SetXAVolume_t)0x004e44a0; 52 | //static const PCMOVIE_XAPlay_t PCMOVIE_XAPlay = (PCMOVIE_XAPlay_t)0x004e44e0; 53 | void PCMOVIE_XAPlay(int group, int channel); 54 | static const PCMOVIE_XAStop_t PCMOVIE_XAStop = (PCMOVIE_XAStop_t)0x004e4540; 55 | //static const PCMOVIE_XADone_t PCMOVIE_XADone = (PCMOVIE_XADone_t)0x004e45b0; 56 | bool PCMOVIE_XADone(); 57 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/PKR.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "PKR.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | Pkr2::~Pkr2() 9 | { 10 | free(data); 11 | } 12 | 13 | /// 14 | /// Loads PKR file to memory and initializes required pointers. 15 | /// 16 | /// 17 | /// 18 | PkrError Pkr2::Load(char* filename) 19 | { 20 | if (data) 21 | free(data); 22 | 23 | printf("trying to open\n"); 24 | 25 | FILE* file = fopen(filename, "rb"); 26 | 27 | if (file == NULL) 28 | return PkrError::FileDoesntExist; 29 | 30 | 31 | fseek(file, 0, SEEK_END); 32 | long fsize = ftell(file); 33 | fseek(file, 0, SEEK_SET); /* same as rewind(f); */ 34 | 35 | data = malloc(fsize); 36 | 37 | if (data == 0) 38 | return PkrError::ZeroFile; 39 | 40 | 41 | fread(data, fsize, 1, file); 42 | fclose(file); 43 | 44 | 45 | Header = (Pkr2Header*)data; 46 | Folders = (Pkr2Folder*)(Header + 1); 47 | Files = (Pkr2File*)(Folders + Header->numFolders); 48 | 49 | for (int i = 0; i < Header->numFiles; i++) 50 | { 51 | Files[i].pData += (int)data; 52 | } 53 | 54 | //we're all good 55 | return PkrError::Success; 56 | } 57 | 58 | /// 59 | /// Exports all files to a given directory. 60 | /// 61 | /// 62 | void Pkr2::ExportAll(char* path) 63 | { 64 | char buf[256]; 65 | char bufpath[256]; 66 | FILE* file; 67 | int curFile = 0; 68 | 69 | for (unsigned int i = 0; i < Header->numFolders; i++) 70 | { 71 | sprintf(bufpath, "%s%s", path, Folders[i].Name); 72 | _mkdir(bufpath); 73 | 74 | for (unsigned int j = 0; j < Folders[i].NumFiles; j++) 75 | { 76 | sprintf(buf, "%s%s", bufpath, Files[curFile].Name); 77 | 78 | file = fopen(buf, "wb"); 79 | fwrite((void*)Files[curFile].pData, 1, Files[curFile].Size, file); 80 | fclose(file); 81 | 82 | curFile++; 83 | 84 | printf("."); 85 | } 86 | } 87 | 88 | printf("PKR export done!\n"); 89 | } 90 | 91 | /// 92 | /// Debug print for PKR file contents 93 | /// 94 | void Pkr2::DebugPrint() 95 | { 96 | char buf[256]; 97 | 98 | printf("PKR Folders:\n"); 99 | 100 | for (int i = 0; i < Header->numFolders; i++) 101 | { 102 | sprintf(buf, "Folder: %s NumFiles: %i\n", Folders[i].Name, Folders[i].NumFiles); 103 | printf(buf); 104 | } 105 | 106 | printf("PKR Files:\n"); 107 | 108 | for (int i = 0; i < Header->numFiles; i++) 109 | { 110 | sprintf(buf, "Folder: %s Size: %i\n", Files[i].Name, Files[i].Size); 111 | printf(buf); 112 | } 113 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/PKR.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct Pkr2Header { 4 | uint32_t Magic; 5 | uint32_t unk1; 6 | uint32_t numFolders; 7 | uint32_t numFiles; 8 | } Pkr2Header; 9 | 10 | typedef struct Pkr2Folder { 11 | char Name[32]; 12 | uint32_t Offset; 13 | uint32_t NumFiles; 14 | } Pkr2Folder; 15 | 16 | typedef struct Pkr2File { 17 | char Name[32]; 18 | uint32_t CompressionType; 19 | char* pData; 20 | uint32_t Size; 21 | uint32_t CompressedSize; 22 | } Pkr2File; 23 | 24 | enum class PkrError { 25 | Success, 26 | FileDoesntExist, 27 | ZeroFile 28 | }; 29 | 30 | 31 | class Pkr2 { 32 | private: 33 | void* data; 34 | 35 | public: 36 | Pkr2Header* Header; 37 | Pkr2Folder* Folders; 38 | Pkr2File* Files; 39 | 40 | PkrError Load(char* filename); 41 | void ExportAll(char* path); 42 | void DebugPrint(); 43 | ~Pkr2(); 44 | 45 | //implement some key value conversion here for some fast search. maybe adopt checksum search? 46 | //need a table of checksum/pointer, then some scanning code. either presort and binary search or research map 47 | //checksum has to be generated from folder+path, cause thats how you look that up. 48 | //fall back to search file on the disk is required 49 | }; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Pad.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "thawk2/pad.h" 3 | 4 | #define NUM_PADS 2 5 | 6 | void Pad_ClearAll() 7 | { 8 | for (int i = 0; i < NUM_PADS; i++) 9 | Pad_ClearAllOne(i); 10 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Pad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef void (*Pad_InitAtStart_t)(); 4 | typedef void (*Pad_ClearAllOne_t)(int param_1); 5 | //typedef void (*Pad_ClearAll_t)(); 6 | typedef void (*Pad_Clear_t)(int param_1); 7 | typedef void (*Pad_ClearTriggers_t)(int param_1); 8 | //unknown name of pad func, dummied out 00486f80 9 | typedef void (*Pad_ActuatorOn_t)(int param_1, int param_2, int param_3, int param_4); 10 | typedef void (*Pad_ActuatorOff_t)(int padIndex, int motorIndex); 11 | typedef void (*Pad_Button_t)(void* pButton, int state); //SButton*p_but,int state 12 | typedef int (*Pad_Analog_t)(int param_1, int param_2, int param_3, int param_4); 13 | typedef void (*Pad_Update_t)(); 14 | typedef void (*ReadControllers_t)(); 15 | typedef void (*Pad_Restore_t)(); 16 | typedef void (*Pad_Remap_t)(); 17 | //possibly one more unrecognized func in the end 18 | 19 | static const Pad_InitAtStart_t Pad_InitAtStart = (Pad_InitAtStart_t)0x486d90; 20 | static const Pad_ClearAllOne_t Pad_ClearAllOne = (Pad_ClearAllOne_t)0x00486eb0; 21 | //static const Pad_ClearAll_t Pad_ClearAll = (Pad_ClearAll_t)0x00486f00; 22 | void Pad_ClearAll(); 23 | static const Pad_Clear_t Pad_Clear = (Pad_Clear_t)0x00486f20; 24 | static const Pad_ClearTriggers_t Pad_ClearTriggers = (Pad_ClearTriggers_t)0x00486f60; 25 | //unknown name of pad func, dummied out 00486f80 26 | static const Pad_ActuatorOn_t Pad_ActuatorOn = (Pad_ActuatorOn_t)0x00486f90; 27 | static const Pad_ActuatorOff_t Pad_ActuatorOff = (Pad_ActuatorOff_t)0x00487140; 28 | static const Pad_Button_t Pad_Button = (Pad_Button_t)0x00487220; 29 | static const Pad_Analog_t Pad_Analog = (Pad_Analog_t)0x00487280; 30 | static const Pad_Update_t Pad_Update = (Pad_Update_t)0x00487300; 31 | static const ReadControllers_t ReadControllers = (ReadControllers_t)0x004875b0; //just calls ReadDirectInput 32 | static const Pad_Restore_t Pad_Restore = (Pad_Restore_t)0x004875c0; 33 | static const Pad_Remap_t Pad_Remap = (Pad_Remap_t)0x00487760; 34 | //possibly one more unrecognized func in the end -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Physics.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "types.h" 3 | #include "thawk2\thawk2.h" 4 | #include "_old.h" 5 | 6 | namespace Physics { 7 | 8 | void** GTricks = reinterpret_cast(0x005674f4); 9 | 10 | void** GTricksKeys = reinterpret_cast(0x005652e8); 11 | void** GGrindTricksList = reinterpret_cast(0x005674a0); 12 | void** GBailsList = reinterpret_cast(0x00565250); 13 | void** GTrickTable1 = reinterpret_cast(0x005656b0); 14 | void** GTrickTable2 = reinterpret_cast(0x005656ac); 15 | void** GAllTricks = reinterpret_cast(0x005674a4); 16 | void** GMcSqueebTricks = reinterpret_cast(0x005674b0); 17 | 18 | 19 | /// 20 | /// Loads TrickDatabase file to memory if it wasn't loaded yet. 21 | /// 22 | /// 23 | unsigned int EnsureGTricksLoaded() { 24 | 25 | printf("DECOMP: EnsureGTricksLoaded()\n"); 26 | 27 | if (!*GTricks) { 28 | 29 | *GTricks = FileIO::FileIO_OpenLoad("tricks.bin", 1); 30 | 31 | short* ptrs = (short*)*GTricks; 32 | 33 | *GTricksKeys = (void*)((int)*GTricks + ptrs[0]); 34 | *GGrindTricksList = (void*)((int)*GTricks + ptrs[1]); 35 | *GBailsList = (void*)((int)*GTricks + ptrs[2]); 36 | *GTrickTable1 = (void*)((int)*GTricks + ptrs[3]); 37 | *GTrickTable2 = (void*)((int)*GTricks + ptrs[4]); 38 | *GAllTricks = (void*)((int)*GTricks + ptrs[5]); 39 | *GMcSqueebTricks = (void*)((int)*GTricks + ptrs[6]); 40 | 41 | return true; 42 | } 43 | 44 | return false; 45 | } 46 | 47 | 48 | 49 | void UnloadGTricks() { 50 | 51 | printf("DECOMP: UnloadGTricks()\n"); 52 | 53 | if (*GTricks) { 54 | Mem_Delete(*GTricks); 55 | *GTricks = NULL; 56 | *GAllTricks = NULL; 57 | } 58 | } 59 | 60 | 61 | void ExtraAnims_AddSkatersAnims() { 62 | 63 | printf("DECOMP: ExtraAnims_AddSkatersAnims()\n"); 64 | 65 | bool gTricksLoaded = EnsureGTricksLoaded(); 66 | 67 | ExtraAnims_Reset(); 68 | UpdateTrickTables(); //TrickDatabase namespace 69 | 70 | ExtraAnims_AddTrickTable(*GTrickTable1); 71 | 72 | if (*GNumberOfPlayers == 2) { 73 | ExtraAnims_AddTrickTable(*GTrickTable2); 74 | } 75 | 76 | if (gTricksLoaded) { 77 | UnloadGTricks(); 78 | } 79 | } 80 | 81 | 82 | 83 | 84 | // === hook stuff === 85 | 86 | Hook::Reroute hookList[] = { 87 | 88 | 89 | { 0x004b8782, EnsureGTricksLoaded }, 90 | { 0x004906d3, EnsureGTricksLoaded }, 91 | { 0x0046a2c3, EnsureGTricksLoaded }, 92 | { 0x00468dfb, EnsureGTricksLoaded }, 93 | 94 | 95 | { 0x004b2046, ExtraAnims_AddSkatersAnims }, 96 | 97 | //========================= 98 | { NULL, NULL } 99 | }; 100 | 101 | Hook::Reroute* pHookList = &hookList[0]; 102 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Rail.h: -------------------------------------------------------------------------------- 1 | /* 2 | Rail.h 3 | ====== 4 | - Handles rail logic. 5 | */ 6 | 7 | #pragma once 8 | #include "..\patch\hook.h" 9 | #include "types.h" 10 | 11 | namespace Rail { 12 | 13 | typedef struct Vector3i { 14 | int X; 15 | int Y; 16 | int Z; 17 | } Vector3i; 18 | 19 | typedef struct CRail { 20 | void* vTable; 21 | char active; 22 | char flags; 23 | short nodeFlags; 24 | Vector3i position; 25 | Vector3i angle; 26 | CRail* pNext; 27 | CRail* pPrev; 28 | } CRail; 29 | 30 | extern Hook::Reroute* pHookList; 31 | 32 | //move to trig 33 | 34 | typedef short* (*Trig_GetLinksPointer_t)(int nodeIndex); 35 | static const Trig_GetLinksPointer_t Trig_GetLinksPointer = (Trig_GetLinksPointer_t)0x004c57b0; 36 | 37 | 38 | 39 | typedef short(*Rail_Flags_t)(ushort nodeIndex); 40 | //typedef uint(*Rail_Type_t)(ushort nodeIndex); 41 | typedef void(*Rail_FlagsPointer_t)(); 42 | //typedef bool(*Rail_IsRailNode_t)(ushort nodeIndex); 43 | typedef uint(*Rail_GetLink_t)(ushort nodeIndex, int linkIndex); 44 | //typedef int(*Rail_NumLinks_t)(ushort nodeIndex); 45 | //typedef uint(*Rail_NextNode_t)(ushort nodeIndex); 46 | //typedef int(*Rail_PrevNode_t)(ushort nodeIndex); 47 | typedef void(*Rail_PrevNodeQuick_t)(); 48 | typedef void(*Rail_Active_t)(ushort nodeIndex, bool active); 49 | //typedef void(*Rail_KillRail_t)(ushort nodeIndex); 50 | //typedef void(*Rail_SwitchOn_t)(ushort nodeIndex); 51 | //typedef uint(*GetIndexOfNode_t)(ushort nodeIndex); 52 | //typedef void(*SetupLookup_t)(); 53 | typedef void(*Rail_CreateRails_t)(); 54 | typedef void(*Rail_Init_t)(); 55 | typedef void(*Rail_DeleteAll_t)(); 56 | typedef void(*CRail_t)(); 57 | typedef void(*CRail_destruct_t)(); 58 | typedef void(*CRail_destroy_t)(); 59 | typedef void(*Rail_Update_t)(); 60 | 61 | static const Rail_Flags_t Rail_Flags = (Rail_Flags_t)0x004a7850; 62 | //static const Rail_Type_t Rail_Type = (Rail_Type_t)0x004a78b0; 63 | static const Rail_FlagsPointer_t Rail_FlagsPointer = (Rail_FlagsPointer_t)0x004a78d0; 64 | //static const Rail_IsRailNode_t Rail_IsRailNode = (Rail_IsRailNode_t)0x004a7920; 65 | static const Rail_GetLink_t Rail_GetLink = (Rail_GetLink_t)0x004a7970; 66 | //static const Rail_NumLinks_t Rail_NumLinks = (Rail_NumLinks_t)0x004a7aa0; 67 | //static const Rail_NextNode_t Rail_NextNode = (Rail_NextNode_t)0x004a7b00; 68 | //static const Rail_PrevNode_t Rail_PrevNode = (Rail_PrevNode_t)0x004a7b70; 69 | static const Rail_PrevNodeQuick_t Rail_PrevNodeQuick = (Rail_PrevNodeQuick_t)0x004a7c10; 70 | static const Rail_Active_t Rail_Active = (Rail_Active_t)0x004a7ca0; 71 | //static const Rail_KillRail_t Rail_KillRail = (Rail_KillRail_t)0x004a7cf0; 72 | //static const Rail_SwitchOn_t Rail_SwitchOn = (Rail_SwitchOn_t)0x004a7d00; 73 | //static const GetIndexOfNode_t GetIndexOfNode = (GetIndexOfNode_t)0x004a7d10; 74 | //static const SetupLookup_t SetupLookup = (SetupLookup_t)0x004a7d90; 75 | static const Rail_CreateRails_t Rail_CreateRails = (Rail_CreateRails_t)0x004a7eb0; 76 | static const Rail_Init_t Rail_Init = (Rail_Init_t)0x004a8150; 77 | static const Rail_DeleteAll_t Rail_DeleteAll = (Rail_DeleteAll_t)0x004a8180; 78 | 79 | static const CRail_t CRail_CRail = (CRail_t)0x004a81a0; 80 | static const CRail_destruct_t CRail_destruct = (CRail_destruct_t)0x004a87f0; 81 | static const CRail_destroy_t CRail_destroy = (CRail_destroy_t)0x004a8810; 82 | static const Rail_Update_t Rail_Update = (Rail_Update_t)0x004a8850; 83 | 84 | 85 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Redbook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\patch\hook.h" 3 | 4 | namespace Redbook 5 | { 6 | typedef struct { 7 | int slot; 8 | string artist; 9 | string title; 10 | string filename; 11 | } Song; 12 | 13 | typedef struct SONG_POS 14 | { 15 | int Channel; 16 | int Group; 17 | int Sector; 18 | } SONG_POS; 19 | 20 | extern Hook::Reroute* pHookList; 21 | 22 | extern string playingName; 23 | extern string playingFile; 24 | extern Song song; 25 | 26 | 27 | 28 | //some unused func 0x4a9290 Redbook_SetXAMode? 29 | //typedef void(*Redbook_XABeginFade_t)(); 30 | //typedef void(*Redbook_XAUpdateVolume_t)(); 31 | //typedef void(*Redbook_XAInit_t)(); 32 | //some unused func 0x4a93c0 Redbook_XASeek? 33 | typedef void(*Redbook_XAPlay_t)(int group, int channel); 34 | //typedef void(*Redbook_XAStop_t)(); 35 | //typedef void(*Redbook_XANextTrack_t)(int num); //tracks to skip? 36 | //typedef void(*Redbook_XAPause_t)(bool state); 37 | //typedef void(*Redbook_XAUpdate_t)(); 38 | //typedef bool(*Redbook_XAPlayingAmbient_t)(); 39 | //typedef void(*Redbook_XARemember_t)(void* songPos); //SONG_POS struct 40 | //typedef void(*Redbook_XARestore_t)(void* songPos); //SONG_POS struct 41 | //typedef int(*Redbook_XACurrentTrack_t)(); 42 | 43 | 44 | //some unused func 0x4a9290, sets xa mode to 1 45 | //static const Redbook_XABeginFade_t Redbook_XABeginFade = (Redbook_XABeginFade_t)0x4a92a0; 46 | //static const Redbook_XAUpdateVolume_t Redbook_XAUpdateVolume = (Redbook_XAUpdateVolume_t)0x4a92c0; 47 | //static const Redbook_XAInit_t Redbook_XAInit = (Redbook_XAInit_t)0x4a9370; 48 | //some unused func 0x4a93c0, sets seek to 0 49 | //static const Redbook_XAPlay_t Redbook_XAPlay = (Redbook_XAPlay_t)0x4a93e0; 50 | //static const Redbook_XAStop_t Redbook_XAStop = (Redbook_XAStop_t)0x4a9560; 51 | //static const Redbook_XANextTrack_t Redbook_XANextTrack = (Redbook_XANextTrack_t)0x4a9590; 52 | //static const Redbook_XAPause_t Redbook_XAPause = (Redbook_XAPause_t)0x4a9700; 53 | //static const Redbook_XAUpdate_t Redbook_XAUpdate = (Redbook_XAUpdate_t)0x4a9730; 54 | //static const Redbook_XAPlayingAmbient_t Redbook_XAPlayingAmbient = (Redbook_XAPlayingAmbient_t)0x4a97b0; 55 | //static const Redbook_XARemember_t Redbook_XARemember = (Redbook_XARemember_t)0x4a97f0; 56 | //static const Redbook_XARestore_t Redbook_XARestore = (Redbook_XARestore_t)0x4a9860; 57 | //static const Redbook_XACurrentTrack_t Redbook_XACurrentTrack = (Redbook_XACurrentTrack_t)0x4a98f0; 58 | 59 | void Redbook_XABeginFade(); 60 | void Redbook_XAUpdateVolume(); 61 | void Redbook_XAInit(); 62 | void Redbook_XAPlay(); 63 | // 64 | void Redbook_XAStop(); 65 | void Redbook_XANextTrack(int num); 66 | void Redbook_XAPause(bool state); 67 | void Redbook_XAUpdate(); 68 | bool Redbook_XAPlayingAmbient(); 69 | void Redbook_XARemember(SONG_POS* pSongPos); 70 | void Redbook_XARestore(SONG_POS* pSongPos); 71 | int Redbook_XACurrentTrack(); 72 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Render.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "thawk2.h" 3 | 4 | bool* M3d_WireframeMode = (bool*)0x00560fdc; 5 | bool* M3d_WireframeLast = (bool*)0x00560fe0; 6 | unsigned int* RenderModelFlags = (unsigned int*)0x0055ed04; 7 | 8 | 9 | void RenderModel(void* pModel) 10 | { 11 | //printf("DECOMP RenderModel()\n"); 12 | 13 | D3DMODEL_RenderModel(pModel, *RenderModelFlags | (*M3d_WireframeMode ? 0x200 : 0)); 14 | *M3d_WireframeMode = *M3d_WireframeLast; 15 | } 16 | 17 | void RenderModelFast(void* pModel) 18 | { 19 | //printf("DECOMP RenderModelFast()\n"); 20 | 21 | RenderModel(pModel); 22 | } 23 | 24 | void RenderBackgroundModel(void* pModel) 25 | { 26 | //printf("DECOMP RenderBackgroundModel()\n"); 27 | 28 | D3DMODEL_RenderModel(pModel, *RenderModelFlags | (*M3d_WireframeMode ? 0x210 : 0x10)); 29 | *M3d_WireframeMode = *M3d_WireframeLast; 30 | } 31 | 32 | //void RenderModelInSuper 33 | 34 | void RenderModelInSuperFast(void* pModel, uint flags) 35 | { 36 | //printf("DECOMP RenderModelInSuperFast()\n"); 37 | 38 | D3DMODEL_RenderModel(pModel, *RenderModelFlags | flags | 1); 39 | } 40 | 41 | void RenderModelNonRotated(void* pModel) 42 | { 43 | //printf("DECOMP RenderModelNonRotated()\n"); 44 | 45 | RenderModel(pModel); 46 | } 47 | 48 | void RenderBackgroundModelNonRotated(void* pModel) 49 | { 50 | //printf("DECOMP RenderBackgroundModelNonRotated()\n"); 51 | 52 | RenderBackgroundModel(pModel); 53 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Render.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "thawk2.h" 3 | 4 | void RenderModel(void* pModel); 5 | void RenderModelFast(void* pModel); 6 | void RenderBackgroundModel(void* pModel); 7 | //void RenderModelInSuper 8 | void RenderModelInSuperFast(void* pModel, uint flags); 9 | void RenderModelNonRotated(void* pModel); 10 | void RenderBackgroundModelNonRotated(void* pModel); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Sfx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //sfx namespace is basically a wrapper for soundlib + game specific routines 4 | 5 | typedef void(*SFX_InitAtStart_t)(); 6 | typedef void(*SFX_Init_t)(char* filename); //takes vab filename as param 7 | typedef void(*SFX_SpoolInLevelSFX_t)(char* param_1); 8 | typedef void(*SFX_SpoolOutLevelSFX_t)(); 9 | typedef void(*SFX_SpoolInMIDI_t)(); //unused 10 | typedef void(*SFX_PlayX_t)(int sound_id, int volume, int param); // <-- verify params number 11 | typedef void(*SFX_PlayLR_t)(); //<-- 12 | typedef void(*SFX_PlayPos_t)(); //<-- 13 | typedef int(*SFX_GetVoicePitch_t)(int voice); 14 | typedef void(*SFX_SetVoicePitch_t)(int voice, int pitch); 15 | typedef void(*SFX_ModifyPos_t)(int ptr_sound, int pos); //assumed 2 pointers? 16 | typedef void(*SFX_ModifyVol_t)(int ptr_sound, int vol_left, int vol_right); 17 | typedef void(*SFX_LevelStart_t)(); 18 | typedef void(*SFX_Pause_t)(); 19 | typedef void(*SFX_Unpause_t)(); 20 | typedef void(*SFX_StopAll_t)(); 21 | typedef void(*SFX_Stop_t)(int ptr_sound); //is it ptr?? 22 | typedef void(*SFX_Off_t)(); 23 | typedef void(*SFX_SetReverbType_t)(char reverb_type); 24 | typedef void(*SFX_ReverbOff_t)(); 25 | typedef void(*SFX_SetReverbDepth_t)(char depth_left, char depth_right); 26 | typedef void(*SFX_MIDIFadeOut_t)(); //unused 27 | typedef void(*SFX_MIDIFadeIn_t)(); //unused 28 | typedef void(*SFX_MIDIChannelMute_t)(); //unused 29 | typedef void(*SFX_ProcessingPerFrame_t)(); //unused 30 | 31 | static const SFX_InitAtStart_t SFX_InitAtStart = (SFX_InitAtStart_t)0x4aa8c0; 32 | static const SFX_Init_t SFX_Init = (SFX_Init_t)0x4aa900; 33 | static const SFX_SpoolInLevelSFX_t SFX_SpoolInLevelSFX = (SFX_SpoolInLevelSFX_t)0x4aaa60; 34 | static const SFX_SpoolOutLevelSFX_t SFX_SpoolOutLevelSFX = (SFX_SpoolOutLevelSFX_t)0x4aae90; 35 | static const SFX_SpoolInMIDI_t SFX_SpoolInMIDI = (SFX_SpoolInMIDI_t)0x4aaec0; 36 | static const SFX_PlayX_t SFX_PlayX = (SFX_PlayX_t)0x4aaf00; 37 | static const SFX_PlayLR_t SFX_PlayLR = (SFX_PlayLR_t)0x4ab030; 38 | static const SFX_PlayPos_t SFX_PlayPos = (SFX_PlayPos_t)0x4ab0b0; 39 | static const SFX_GetVoicePitch_t SFX_GetVoicePitch = (SFX_GetVoicePitch_t)0x4ab150; 40 | static const SFX_SetVoicePitch_t SFX_SetVoicePitch = (SFX_SetVoicePitch_t)0x4ab170; 41 | static const SFX_ModifyPos_t SFX_ModifyPos = (SFX_ModifyPos_t)0x4ab190; 42 | static const SFX_ModifyVol_t SFX_ModifyVol = (SFX_ModifyVol_t)0x4ab230; 43 | static const SFX_LevelStart_t SFX_LevelStart = (SFX_LevelStart_t)0x4ab290; 44 | static const SFX_Pause_t SFX_Pause = (SFX_Pause_t)0x4ab2a0; 45 | static const SFX_Unpause_t SFX_Unpause = (SFX_Unpause_t)0x4ab2b0; 46 | static const SFX_StopAll_t SFX_StopAll = (SFX_StopAll_t)0x4ab2c0; 47 | static const SFX_Stop_t SFX_Stop = (SFX_Stop_t)0x4ab2d0; 48 | static const SFX_Off_t SFX_Off = (SFX_Off_t)0x4ab2f0; 49 | static const SFX_SetReverbType_t SFX_SetReverbType = (SFX_SetReverbType_t)0x4ab300; 50 | static const SFX_ReverbOff_t SFX_ReverbOff = (SFX_ReverbOff_t)0x4ab470; 51 | static const SFX_SetReverbDepth_t SFX_SetReverbDepth = (SFX_SetReverbDepth_t)0x4ab480; 52 | static const SFX_MIDIFadeOut_t SFX_MIDIFadeOut = (SFX_MIDIFadeOut_t)0x4ab510; 53 | static const SFX_MIDIFadeIn_t SFX_MIDIFadeIn = (SFX_MIDIFadeIn_t)0x4ab530; 54 | static const SFX_MIDIChannelMute_t SFX_MIDIChannelMute = (SFX_MIDIChannelMute_t)0x4ab540; 55 | static const SFX_ProcessingPerFrame_t SFX_ProcessingPerFrame = (SFX_ProcessingPerFrame_t)0x4ab550; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Shatter.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "thawk2/thawk2.h" 3 | #include "../lib/xinput/CXBOXController.h" 4 | 5 | #define SND_GLASS_SHATTER 0x2A 6 | #define DEFAULT_VOLUME 0x2000 7 | 8 | 9 | bool* ShatterSound = (bool*)0x5691a4; 10 | 11 | void Shatter_MaybeMakeGlassShatterSound() 12 | { 13 | if (!*ShatterSound) return; 14 | 15 | //play sound 16 | SFX_PlayX(SND_GLASS_SHATTER, DEFAULT_VOLUME, 0); 17 | 18 | //and vibrate 19 | PCINPUT_ActuatorOn_Hook(0, 8, 0, 127); 20 | PCINPUT_ActuatorOn_Hook(0, 4, 0, 200); 21 | 22 | *ShatterSound = false; 23 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Shatter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | #include "lib/xinput/CXBOXController.h" 5 | #include "thawk2/Sfx.h" 6 | #include "patchStuff.h" 7 | 8 | extern bool* ShatterSound; 9 | 10 | //int playsshatter = 0; 11 | 12 | void Shatter_MaybeMakeGlassShatterSound(); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/SkatMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //this = SkaterManager 4 | //wonder if cdecl methods are static or global 5 | 6 | typedef void(__thiscall * EditThisSkater_t)(void* _this, int param_1); 7 | typedef int(__thiscall * GetSkaterID_t)(void* _this); 8 | typedef int(__thiscall * GetCostumeID_t)(void* _this); 9 | typedef int(__thiscall * GetCustomSkaterID_t)(void* _this); 10 | typedef int(__thiscall * GetSkaterID2_t)(void* _this, int param_1); 11 | typedef int(__thiscall * GetCostumeID2_t)(void* _this, int param_1); 12 | typedef void(__thiscall * SetSkaterID_t)(void* _this, int param_1); 13 | typedef void(__thiscall * SetSkaterID2_t)(void* _this, int param_1, int param_2); 14 | typedef void(*num_costumes_t)(int param_1); 15 | typedef void(__thiscall * SetCostumeID_t)(void* _this, int param_1, int param_2, bool param_3); 16 | typedef void(__thiscall * SetCustomSkaterID_t)(void* _this, int param_1, int param_2); 17 | typedef int(__thiscall * GetPreferredCostume_t)(void* _this, int param_1); 18 | typedef void(__thiscall * PrintLoadBuffer_t)(); //empty func 19 | typedef void(__thiscall * ClearLoadBuffer_t)(void* _this); 20 | typedef void(__thiscall * ClearLoadBufferSlot_t)(void* _this); 21 | typedef void(__thiscall * SetLoadBuffer_t)(void* _this, int param_1); 22 | typedef void(__thiscall * GetSkaterName_t)(void* _this, int param_1, char* outName); //does not return, writes to outName 23 | typedef char*(__thiscall * GetPortraitName_t)(void* _this, int param_1); 24 | typedef int(__thiscall * UsesLoadBuffer_t)(void* _this, int param_1); 25 | typedef void(__thiscall * SwapLoadBuffer_t)(void* _this, int param_1); 26 | typedef void*(__thiscall * GetTrickConfig_t)(void* _this, int param_1); 27 | typedef bool(__thiscall * IsRegularStance_t)(void* _this, int param_1); 28 | typedef char*(*GetPSXName_t)(int param_1, int param_2); 29 | typedef int(*GetCustomSkaterSlotIndex_t)(int param_1); 30 | typedef void(*PlayerSelect_ClearState_t)(); 31 | typedef int(*Get_Selected_Skater_t)(int param_1); 32 | typedef void(*Set_Selected_Skater_t)(int param_1, int param_2); 33 | typedef int(*GetCustomSkaterIndex_t)(int param_1); 34 | typedef bool(*IsInitialCustomSkaterRevision_t)(int param_1); 35 | typedef char*(*FrontEnd2_GetSkaterName_t)(int param_1); 36 | 37 | static const EditThisSkater_t EditThisSkater = (EditThisSkater_t)0x4ae4a0; 38 | static const GetSkaterID_t GetSkaterID = (GetSkaterID_t)0x4ae510; 39 | static const GetCostumeID_t GetCostumeID = (GetCostumeID_t)0x4ae520; 40 | static const GetCustomSkaterID_t GetCustomSkaterID = (GetCustomSkaterID_t)0x4ae530; 41 | static const GetSkaterID2_t GetSkaterID2 = (GetSkaterID2_t)0x4ae540; 42 | static const GetCostumeID2_t GetCostumeID2 = (GetCostumeID2_t)0x4ae5b0; 43 | static const SetSkaterID_t SetSkaterID = (SetSkaterID_t)0x4ae620; 44 | static const SetSkaterID_t SetSkaterID2 = (SetSkaterID_t)0x4ae740; 45 | static const num_costumes_t num_costumes = (num_costumes_t)0x4ae860; 46 | static const SetCostumeID_t SetCostumeID = (SetCostumeID_t)0x4ae8c0; 47 | static const SetCustomSkaterID_t SetCustomSkaterID = (SetCustomSkaterID_t)0x4ae950; 48 | static const GetPreferredCostume_t GetPreferredCostume = (GetPreferredCostume_t)0x4aea10; 49 | static const PrintLoadBuffer_t PrintLoadBuffer = (PrintLoadBuffer_t)0x4aea20; 50 | static const ClearLoadBuffer_t ClearLoadBuffer = (ClearLoadBuffer_t)0x4aea30; 51 | static const ClearLoadBufferSlot_t ClearLoadBufferSlot = (ClearLoadBufferSlot_t)0x4aea60; 52 | static const SetLoadBuffer_t SetLoadBuffer = (SetLoadBuffer_t)0x4aeaa0; 53 | static const GetSkaterName_t GetSkaterName = (GetSkaterName_t)0x4aeb20; 54 | static const GetPortraitName_t GetPortraitName = (GetPortraitName_t)0x4aec40; 55 | static const UsesLoadBuffer_t UsesLoadBuffer = (UsesLoadBuffer_t)0x4aed10; 56 | static const SwapLoadBuffer_t SwapLoadBuffer = (SwapLoadBuffer_t)0x4aed80; 57 | static const GetTrickConfig_t GetTrickConfig = (GetTrickConfig_t)0x4aee50; 58 | static const IsRegularStance_t IsRegularStance = (IsRegularStance_t)0x4aef10; 59 | static const GetPSXName_t GetPSXName = (GetPSXName_t)0x4aefe0; 60 | static const GetCustomSkaterSlotIndex_t GetCustomSkaterSlotIndex = (GetCustomSkaterSlotIndex_t)0x4af0f0; 61 | static const PlayerSelect_ClearState_t PlayerSelect_ClearState = (PlayerSelect_ClearState_t)0x4af170; 62 | static const Get_Selected_Skater_t Get_Selected_Skater = (Get_Selected_Skater_t)0x4af180; 63 | static const Set_Selected_Skater_t Set_Selected_Skater = (Set_Selected_Skater_t)0x4af1b0; 64 | static const GetCustomSkaterIndex_t GetCustomSkaterIndex = (GetCustomSkaterIndex_t)0x4af260; 65 | static const IsInitialCustomSkaterRevision_t IsInitialCustomSkaterRevision = (IsInitialCustomSkaterRevision_t)0x4af2d0; 66 | static const FrontEnd2_GetSkaterName_t FrontEnd2_GetSkaterName = (FrontEnd2_GetSkaterName_t)0x4af310; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/SkaterProfile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /// 4 | /// Board struct, defines name, texture and board stats. 5 | /// Board array is stored in the skater profile. 6 | /// 7 | struct SBoardInfo 8 | { 9 | char* pBitmapName; //board graphics 10 | char* pImage; //board name 11 | 12 | int unk0; 13 | 14 | int Weight; //board stats 15 | int Speed; 16 | int Durability; 17 | 18 | int unk1; 19 | int unk2; 20 | }; 21 | 22 | typedef struct SBoardInfo SBoardInfo; 23 | 24 | 25 | /// 26 | /// Skater profile struct, describes various skater related data 27 | /// 28 | struct SkaterProfile 29 | { 30 | char* styleA_hi; //array of pointers to model PSX file names, 4 styles * hi and lo models 31 | char* styleA_lo; //pc port doesn't seem to be using low models, maybe in netplay? 32 | char* styleB_hi; 33 | char* styleB_lo; 34 | char* styleC_hi; 35 | char* styleC_lo; 36 | char* styleD_hi; 37 | char* styleD_lo; 38 | 39 | char FullName[32]; //full skater name, i.e. "Tony Hawk" 40 | char* pShortName; //short skater name, i.e. "Tony" 41 | 42 | SBoardInfo boards[8]; //board structs array 43 | char stats[10]; //skater stats, byte per stat 44 | char style; //currently selected style 45 | char stance; //switch or regular 46 | char* pFaceName; //UI face preview bitmap 47 | char** pBioLines; //list of char bio lines, ends with nullptr 48 | int unlocked; //unlocked flag 49 | int flags; //1 = female sfx, rest some unlockables 50 | int unk1; //only accessed once in LoadAllSkaters 51 | int animIndex; //animation index used in frontend 52 | int videoIndex; //video index (negative) to play at the end of the loop for this profile 53 | void* pDynamicLogos; //ptr to level dynamic logo 54 | }; 55 | 56 | typedef struct SkaterProfile SkaterProfile; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Soundlib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | //#include 5 | 6 | //pointer to directsound object 7 | //LPDIRECTSOUND* pDevice = (LPDIRECTSOUND*)0x029d4fb0; 8 | 9 | typedef void(*SOUNDLIB_Init_t)(HWND* hWnd); 10 | typedef void(*SOUNDLIB_Shutdown_t)(); 11 | typedef void(*SOUNDLIB_LoadVABList_t)(int vabIndex); 12 | typedef void(*SOUNDLIB_FreeVABList_t)(int vabIndex); 13 | typedef int(*SOUNDLIB_LoadSound_t)(int soundIndex); 14 | typedef void(*writeSoundData_t)(int* param_1, int param_2, int param_3, int param_4); 15 | typedef void(*SOUNDLIB_FreeSound_t)(int param_1); 16 | typedef int(*SOUNDLIB_Play_t)(int param_1, int param_2, int param_3); 17 | typedef void(*SOUNDLIB_Play2_t)(int param_1, int param_2, int param_3); 18 | typedef void(*SOUNDLIB_SetVolume_t)(int voice, int volLeft, int volRight); 19 | typedef void(*SOUNDLIB_SetPitch_t)(int voice, int pitch); 20 | typedef int(*SOUNDLIB_GetPitch_t)(int voice); 21 | typedef void(*SOUNDLIB_Stop_t)(int voice); 22 | typedef void(*SOUNDLIB_Pause_t)(int voice); 23 | typedef void(*SOUNDLIB_StopAll_t)(); 24 | typedef void(*SOUNDLIB_PauseAll_t)(); 25 | typedef void(*SOUNDLIB_UnPauseAll_t)(); 26 | 27 | static const SOUNDLIB_Init_t SOUNDLIB_Init = (SOUNDLIB_Init_t)0x4ef8b0; 28 | static const SOUNDLIB_Shutdown_t SOUNDLIB_Shutdown = (SOUNDLIB_Shutdown_t)0x4ef990; 29 | static const SOUNDLIB_LoadVABList_t SOUNDLIB_LoadVABList = (SOUNDLIB_LoadVABList_t)0x4efa50; 30 | static const SOUNDLIB_FreeVABList_t SOUNDLIB_FreeVABList = (SOUNDLIB_FreeVABList_t)0x4efbc0; 31 | static const SOUNDLIB_LoadSound_t SOUNDLIB_LoadSound = (SOUNDLIB_LoadSound_t)0x4efc30; 32 | static const writeSoundData_t writeSoundData = (writeSoundData_t)0x4efd60; 33 | static const SOUNDLIB_FreeSound_t SOUNDLIB_FreeSound = (SOUNDLIB_FreeSound_t)0x4efe90; 34 | static const SOUNDLIB_Play_t SOUNDLIB_Play = (SOUNDLIB_Play_t)0x4eff10; 35 | static const SOUNDLIB_Play2_t SOUNDLIB_Play2 = (SOUNDLIB_Play2_t)0x4f02f0; 36 | static const SOUNDLIB_SetVolume_t SOUNDLIB_SetVolume = (SOUNDLIB_SetVolume_t)0x4f05a0; 37 | static const SOUNDLIB_SetPitch_t SOUNDLIB_SetPitch = (SOUNDLIB_SetPitch_t)0x4f0780; 38 | static const SOUNDLIB_GetPitch_t SOUNDLIB_GetPitch = (SOUNDLIB_GetPitch_t)0x4f0810; 39 | static const SOUNDLIB_Stop_t SOUNDLIB_Stop = (SOUNDLIB_Stop_t)0x4f08b0; 40 | static const SOUNDLIB_Pause_t SOUNDLIB_Pause = (SOUNDLIB_Pause_t)0x4f0960; 41 | static const SOUNDLIB_StopAll_t SOUNDLIB_StopAll = (SOUNDLIB_StopAll_t)0x4f09c0; 42 | static const SOUNDLIB_PauseAll_t SOUNDLIB_PauseAll = (SOUNDLIB_PauseAll_t)0x4f09f0; 43 | static const SOUNDLIB_UnPauseAll_t SOUNDLIB_UnPauseAll = (SOUNDLIB_UnPauseAll_t)0x4f0a30; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Spool.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "types.h" 3 | #include "Utils.h" 4 | #include "Spool.h" 5 | #include "IO\\FileIO.h" 6 | 7 | #define PSX_SLOTS 14 8 | 9 | void* PSXRegion = (void*)0x0056a088; 10 | 11 | 12 | 13 | 14 | 15 | int Spool_FindRegion(char* pName) 16 | { 17 | char* psxSlot = (char*)PSXRegion; 18 | 19 | for (int region = 0; region < PSX_SLOTS; region++) 20 | { 21 | if (Utils_CompareStrings(pName, psxSlot, NS_NULL) != 0) 22 | return region; 23 | 24 | //just ++ for psx file slot struct 25 | psxSlot = psxSlot + 0x44; 26 | } 27 | 28 | return NS_NULL; 29 | } 30 | 31 | 32 | 33 | int Spool_FreeRegion() 34 | { 35 | char* psxSlot = (char*)PSXRegion; 36 | 37 | int freeSlot = 0; 38 | 39 | for (int region = 0; region < PSX_SLOTS; region++) 40 | { 41 | if (psxSlot == NULL) return region; 42 | 43 | //just ++ for psx file slot struct 44 | psxSlot = psxSlot + 0x44; 45 | } 46 | 47 | return NS_NULL; 48 | } 49 | 50 | 51 | /* 52 | void Spool_ClearPSX(char* pName) 53 | { 54 | int region = Spool_FindRegion(pName); 55 | 56 | if (*(int*)((int)PSXRegion + region * 0x44 + 0xa) != '\0') { 57 | Spool_ClearRegion(region, 1, 0); 58 | } 59 | } 60 | */ 61 | 62 | void Spool_LoadPSH(char* pName, int param_2, int param_3, int* param_4, int param_5) 63 | { 64 | char buf[256]; 65 | 66 | sprintf(buf, "%s.PSH", pName); 67 | void* block = FileIO::FileIO_OpenLoad(buf, 1); 68 | Spool_LoadPSHBuffer(block, pName, param_2, param_3, param_4, param_5); 69 | } 70 | 71 | /* 72 | int Spool_CountColors(uint hash) { 73 | 74 | throw "Spool_CountColors not implemented!"; 75 | 76 | void* textureEntry = Spool_FindTextureEntry(hash); 77 | 78 | if (textureEntry == NULL) { 79 | printf("Board texture not found"); 80 | return 0; 81 | } 82 | 83 | return D3DTEX_TextureCountColors(*(undefined4*)(textureEntry + 0x14)); 84 | }*/ -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Spool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //typedef int(*Spool_FreeRegion_t)(); 4 | //typedef int(*Spool_FindRegion_t)(char* pName); 5 | typedef void(*Spool_ClearRegion_t)(char* pName); 6 | //typedef void(*Spool_LoadPSH_t)(char* pName, int param_2, int param_3, int param_4, int param_5); 7 | typedef void*(*Spool_LoadPSHBuffer_t)(void* pBlock, char* pName, int param_3, int param_4, int* param_5, int param_6); 8 | 9 | 10 | //static const Spool_FreeRegion_t Spool_FreeRegion = (Spool_FreeRegion_t)0x4af490; 11 | int Spool_FreeRegion(); 12 | //static const Spool_FindRegion_t Spool_FindRegion = (Spool_FindRegion_t)0x4b0b10; 13 | int Spool_FindRegion(char* pName); 14 | static const Spool_ClearRegion_t Spool_ClearRegion = (Spool_ClearRegion_t)0x4b0bd0; 15 | static const Spool_LoadPSHBuffer_t Spool_LoadPSHBuffer = (Spool_LoadPSHBuffer_t)0x004b2220; 16 | //static const Spool_LoadPSH_t Spool_LoadPSH = (Spool_LoadPSH_t)0x4b2080; 17 | void Spool_LoadPSH(char* pName, int param_2, int param_3, int* param_4, int param_5); 18 | 19 | 20 | typedef void*(*Spool_FindTextureEntry_t)(uint hash); 21 | static const Spool_FindTextureEntry_t Spool_FindTextureEntry = (Spool_FindTextureEntry_t)0x004af910; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/Utils.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Utils.h" 3 | #include "Globals.h" 4 | 5 | 6 | bool Utils_CompareStrings(char* pSrc, char* pDst, int num) 7 | { 8 | char cSrc; 9 | char cDst; 10 | 11 | if (pSrc == NULL && pDst == NULL) return true; 12 | if (pDst == NULL) return false; 13 | 14 | do { 15 | 16 | cSrc = *pSrc; 17 | cDst = *pDst; 18 | 19 | //uppercase first 20 | if (('@' < cSrc) && (cSrc < '[')) cSrc += ' '; 21 | 22 | //uppercase second 23 | if (('@' < cDst) && (cDst < '[')) cDst += ' '; 24 | 25 | if (cSrc != cDst) return false; 26 | 27 | pSrc++; 28 | pDst++; 29 | 30 | } while ((cSrc != 0) && (num--, num != 0)); 31 | 32 | if (cSrc == cDst) return true; 33 | 34 | return false; 35 | } 36 | 37 | 38 | void Utils_GetVecFromMagDir(SVector3i* angles, int magnitude, SVector3s* velocity) 39 | { 40 | //calculate trig stuff 41 | short velSinX = Sine((ushort)velocity->X & 0xfff); 42 | short velCosX = Cosine((ushort)velocity->X & 0xfff); 43 | short velSinY = Sine((ushort)velocity->Y & 0xfff); 44 | short velCosY = Cosine((ushort)velocity->Y & 0xfff); 45 | 46 | //update angles based on velocity and magnitude 47 | angles->X = -1 * ((velCosX * magnitude) >> 12) * velSinY; 48 | angles->Y = velSinX * magnitude; 49 | angles->Z = -1 * ((velCosX * magnitude) >> 12) * velCosY; 50 | } 51 | 52 | 53 | //this func is apparently unused on PC 54 | void Utils_VblankProcessing() 55 | { 56 | printf("called Utils_VblankProcessing() !!!\n"); 57 | 58 | if (*Loading) 59 | (*LoadingTime)++; 60 | else 61 | (*ProcessingTime)++; 62 | 63 | //<...more stuff...> 64 | } 65 | 66 | 67 | /// 68 | /// Limits passed int* value within the min/max range. 69 | /// 70 | /// Pointer to int value 71 | /// Lowest range value 72 | /// Highest range value 73 | void Utils_LimitRange(int* value, int min, int max) 74 | { 75 | //particularly used for fatten 76 | printf("decomp Utils_LimitRange... v=%i min=%i max=%i\n", *value, min, max); 77 | 78 | if (*value < min) *value = min; 79 | if (*value > max) *value = max; 80 | } 81 | 82 | 83 | 84 | /// 85 | /// Calculates unit vector (basically, normalize). 86 | /// 87 | /// Target unit vector 88 | /// Source vector 89 | SVector3i* Utils_CalcUnit(SVector3i* unit, SVector3i* vec) 90 | { 91 | //calculate vector magnitude 92 | float magnitude = sqrt( 93 | pow(vec->X >> 12, 2) + 94 | pow(vec->Y >> 12, 2) + 95 | pow(vec->Z >> 12, 2) 96 | ); 97 | 98 | if (magnitude == 0.0f) { 99 | 100 | //process zero edge case 101 | unit->X = 0; 102 | unit->Y = 0; 103 | unit->Z = 0; 104 | } 105 | else 106 | { 107 | //otherwise, calculate unit 108 | unit->X = vec->X / magnitude; 109 | unit->Y = vec->Y / magnitude; 110 | unit->Z = vec->Z / magnitude; 111 | } 112 | 113 | return unit; 114 | } 115 | 116 | 117 | /// 118 | /// Calculates distance between 2 points. 119 | /// 120 | /// 121 | /// 122 | /// 123 | uint Utils_Dist(SVector3i* a, SVector3i* b) 124 | { 125 | SVector3i t = { 126 | (a->X - b->X) >> 12, 127 | (a->Y - b->Y) >> 12, 128 | (a->Z - b->Z) >> 12 129 | }; 130 | 131 | return (uint)sqrt(t.X * t.X + t.Y * t.Y + t.Z * t.Z); 132 | } 133 | 134 | 135 | /// 136 | /// Supposedly kills all objects in bounding box. 137 | /// 138 | /// BB min point 139 | /// BB max point 140 | void Utils_KillEverythingInBox(SVector3i* min, SVector3i* max) 141 | { 142 | //find this func 143 | 144 | printf("decomp Utils_KillEverythingInBox!\n"); 145 | 146 | Utils_KillObjectsInBox(min, max, BaddyList, true); 147 | Utils_KillObjectsInBox(min, max, EnvironmentalObjectList, true); 148 | Utils_KillObjectsInBox(min, max, PowerUpList, true); 149 | Utils_KillObjectsInBox(min, max, SuspendedList, false); 150 | 151 | //originally it returns sum of the above, but im not sure if its ever used 152 | } 153 | 154 | 155 | /* 156 | // requires CBody to be decompiled first 157 | int Utils_KillObjectsInBox(CVector3* min, CVector3* max, CBody* pList, char useDie) 158 | { 159 | if (pList == NULL) return 0; 160 | 161 | int numKilled = 0; 162 | CBody* pCurr = pList; 163 | CBody* pNext = NULL; 164 | 165 | do { 166 | // remember next item 167 | pNext = pCurr->nextItem; 168 | 169 | // check whether it's dead 170 | if (!pCurr->IsDead()) { 171 | 172 | int x = pCurr->pos.X; 173 | int y = pCurr->pos.Y; 174 | int z = pCurr->pos.Z; 175 | 176 | // if in bounding box between min and max 177 | if ( 178 | min->X <= x && x <= max->X && 179 | min->Y <= y && y <= max->Y && 180 | min->Z <= z && z <= max->Z 181 | ) 182 | { 183 | // if should just get dead status 184 | if (useDie) { 185 | pCurr->Die(); 186 | } else { 187 | // else remove physically 188 | delete pCurr; 189 | } 190 | 191 | // count 192 | numKilled++; 193 | } 194 | } 195 | 196 | pCurr = pNext; 197 | 198 | } while (pNext != NULL); 199 | 200 | return numKilled; 201 | } 202 | */ 203 | 204 | 205 | 206 | 207 | //this is called in front_update for level unlocked message. used to calculate text zoom 208 | int Utils_Pulse(int time, int period, int amplitude) 209 | { 210 | if ((time < period) && (time > -1)) { 211 | 212 | int iVar1 = period / 2; 213 | 214 | if (time < iVar1) return (time * amplitude) / iVar1; 215 | 216 | return ((period - time) * amplitude) / iVar1; 217 | } 218 | 219 | return 0; 220 | } 221 | 222 | 223 | 224 | 225 | 226 | 227 | #define MATH_2PI 6.2831853f 228 | #define FRAC_BITS 12 229 | 230 | uint Sine(uint deg) 231 | { 232 | return sin( ((deg & 0xFFF) / 4096.0) * MATH_2PI ) * 4096.0; 233 | } 234 | 235 | uint Cosine(uint deg) 236 | { 237 | return cos( ((deg & 0xFFF) / 4096.0) * MATH_2PI ) * 4096.0; 238 | } 239 | 240 | // the way thirteenag fixes it, makes little sense to me atm 241 | // check rotatesprite::draw function to figure it out 242 | 243 | uint ScreenScaledSine(uint deg) 244 | { 245 | return Sine(deg) / (*ScreenHeight / 480.0); 246 | } 247 | 248 | uint ScreenScaledCosine(uint deg) 249 | { 250 | return Cosine(deg) / (*ScreenHeight / 480.0); 251 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/WinMain.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "types.h" 3 | #include "Globals.h" 4 | 5 | 6 | HWND hWnd = (HWND)0x029d4fc4; 7 | 8 | tagMSG msg; 9 | 10 | uint WinYield() 11 | { 12 | printf("WinYield()\r\n"); 13 | 14 | while (true) { 15 | 16 | // maybe we processed all messages? 17 | if (!PeekMessageA(&msg, hWnd, 0, 0, 0)) return 0x75; //is this some win value? 18 | 19 | // null message? 20 | if (!GetMessageA(&msg, hWnd, 0, 0)) break; 21 | 22 | // process message: this blocks alt in the original game 23 | if (msg.message != WM_SYSKEYDOWN && 24 | msg.message != WM_SYSKEYUP) { 25 | TranslateMessage(&msg); 26 | DispatchMessageA(&msg); 27 | } 28 | } 29 | 30 | return msg.wParam; 31 | } 32 | 33 | void WINMAIN_ScreenDimensions(int* width, int* height) 34 | { 35 | *width = *ScreenWidth; 36 | *height = *ScreenHeight; 37 | } 38 | 39 | 40 | char* lpFileName = (char*)0x29d4fc8; 41 | 42 | void WINMAIN_LoadSetting(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString) 43 | { 44 | GetPrivateProfileStringA(lpAppName, lpKeyName, lpDefault, lpReturnedString, 256, lpFileName); 45 | } 46 | 47 | 48 | /* 49 | void WINMAIN_ShutDown(void) 50 | { 51 | printf("WinMain_Shutdown()\n"); 52 | 53 | NETGAME_ShutDown(); 54 | D3DTIMER_Kill(); 55 | PCINPUT_ShutDown(); 56 | PCMOVIE_StopFMV(); 57 | PCMOVIE_XAStop(); 58 | D3D_ShutDown(1); 59 | } 60 | */ 61 | 62 | 63 | 64 | /// 65 | /// not an original name, renamed for convenience 66 | /// 67 | /// 68 | /// 69 | /// 70 | /// 71 | /// 72 | LRESULT WINMAIN_WndProc(HWND hWnd, uint Msg, WPARAM wParam, LPARAM lParam) 73 | { 74 | if (Msg < 0x101) { //WM_KEYUP 75 | switch (Msg) { 76 | 77 | case WM_DESTROY: 78 | PostQuitMessage(0); 79 | return 0; 80 | 81 | case WM_MOVE: 82 | case 4: // ?? 83 | case WM_SETFOCUS: 84 | case WM_KILLFOCUS: 85 | case 9: // ?? 86 | case WM_ENABLE: 87 | case WM_SETREDRAW: 88 | case WM_SETTEXT: 89 | case WM_GETTEXT: 90 | case WM_GETTEXTLENGTH: 91 | case WM_PAINT: 92 | // go to next message 93 | break; 94 | 95 | case WM_SIZE: 96 | return 0; 97 | 98 | case WM_ACTIVATE: 99 | // remember got message or smth? 100 | // _DAT_029d6fec = (uint)((short)wParam != 0); 101 | return 0; 102 | case WM_CLOSE: 103 | // handle shutdown 104 | /* 105 | PCstop(); 106 | WINMAIN_ShutDown(); 107 | if (PCMemBuffer != 0) { 108 | operator_free(PCMemBuffer); 109 | PCMemBuffer = 0; 110 | } 111 | */ 112 | break; 113 | 114 | // any other message 115 | default: 116 | //MessageBox(NULL, "test", "test", 0); 117 | 118 | //printf("wtf %i\n", wParam); 119 | 120 | //PCINPUT_DoWinKeyDown(wParam); 121 | switch (wParam) { 122 | case VK_TAB: 123 | case VK_SHIFT: 124 | case VK_CONTROL: 125 | case VK_MENU: 126 | case VK_LWIN: 127 | case VK_RWIN: 128 | case VK_APPS: 129 | case VK_F10: 130 | // no reaction to these keys at all 131 | return 0; 132 | 133 | case VK_F9: 134 | // take a screenshot on F9. 135 | //D3D_ScreenShot(); 136 | MessageBox(NULL, "test", "test", 0); 137 | printf("screenshot!\n"); 138 | return 0; 139 | } 140 | } 141 | } 142 | // handle mouse messages 143 | else if (Msg < 0x20a) { //WM_MOUSEWHEEL 144 | if (0x200 < Msg) { //WM_MOUSEMOVE 145 | //PCINPUT_HandleMouseMessage(Msg); 146 | return 0; 147 | } 148 | // handle sys keys 149 | if (0x103 < Msg) { // WM_DEADCHAR 150 | if (Msg < 0x108) { //WM_UNICHAR 151 | //return 0; 152 | } 153 | 154 | // ignore sys command 155 | if (Msg == WM_SYSCOMMAND) { 156 | // this is probably why you cant close the window using X, lol 157 | // return 0; 158 | } 159 | } 160 | } 161 | else if (Msg == WM_HOTKEY) { 162 | // ignore user global hotkeys i guess 163 | //return 0; 164 | } 165 | 166 | return DefWindowProcA(hWnd, Msg, wParam, lParam); 167 | } 168 | 169 | 170 | 171 | void WINMAIN_PatchWndProc() 172 | { 173 | int result = SetWindowLongPtr(hWnd, GWL_WNDPROC, (LONG_PTR)WINMAIN_WndProc); 174 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/WinMain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | extern HWND hWnd; 6 | 7 | uint WinYield(); 8 | 9 | typedef void(*WinMain_t)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd); 10 | static const WinMain_t WinMainX = (WinMain_t)0x004f4ec0; 11 | 12 | //typedef void(*Thawk2Entry_t)(); 13 | //static const Thawk2Entry_t Thawk2Entry = (Thawk2Entry_t)0x004ffe6c; 14 | 15 | 16 | 17 | 18 | typedef void(*WINMAIN_Sleep_t)(); 19 | typedef void(*WINMAIN_FindFiles_t)(); 20 | typedef void(*WINMAIN_CanDoMode_t)(); 21 | typedef void(*WINMAIN_FindCD_t)(); 22 | typedef void(*tryOpenFile_t)(); 23 | typedef void(*WINMAIN_InstallSetup_t)(); 24 | typedef void(*WINMAIN_LoadOptions_t)(); 25 | typedef void(*WINMAIN_SaveOptions_t)(); 26 | //typedef void(*WINMAIN_LoadSetting_t)(); 27 | //typedef void(*WINMAIN_SaveSetting_t)(); 28 | //typedef void(*WINMAIN_ScreenDimensions_t)(); 29 | typedef void(*WINMAIN_SwitchRenderer_t)(); 30 | //typedef void(*WINMAIN_SwitchResolution_t)(); 31 | 32 | // there is more stuff down the line, mixed with directdraw initialization 33 | 34 | static const WINMAIN_Sleep_t WINMAIN_Sleep = (WINMAIN_Sleep_t)0x004f3600; 35 | static const WINMAIN_FindFiles_t WINMAIN_FindFiles = (WINMAIN_FindFiles_t)0x004f3610; 36 | static const WINMAIN_CanDoMode_t WINMAIN_CanDoMode = (WINMAIN_CanDoMode_t)0x004f3710; 37 | static const WINMAIN_FindCD_t WINMAIN_FindCD = (WINMAIN_FindCD_t)0x004f37e0; 38 | static const tryOpenFile_t tryOpenFile = (tryOpenFile_t)0x004f3900; 39 | static const WINMAIN_InstallSetup_t WINMAIN_InstallSetup = (WINMAIN_InstallSetup_t)0x004f39d0; 40 | static const WINMAIN_LoadOptions_t WINMAIN_LoadOptions = (WINMAIN_LoadOptions_t)0x004f3c40; 41 | static const WINMAIN_SaveOptions_t WINMAIN_SaveOptions = (WINMAIN_SaveOptions_t)0x004f3d10; 42 | //static const WINMAIN_LoadSetting_t WINMAIN_LoadSetting = (WINMAIN_LoadSetting_t)0x004f3d50; 43 | //static const WINMAIN_SaveSetting_t WINMAIN_SaveSetting = (WINMAIN_SaveSetting_t)0x004f3d80; 44 | //static const WINMAIN_ScreenDimensions_t WINMAIN_ScreenDimensions = (WINMAIN_ScreenDimensions_t)0x004f3db0; 45 | void WINMAIN_ScreenDimensions(int* width, int* height); 46 | static const WINMAIN_SwitchRenderer_t WINMAIN_SwitchRenderer = (WINMAIN_SwitchRenderer_t)0x004f3dd0; 47 | //static const WINMAIN_SwitchResolution_t WINMAIN_SwitchResolution = (WINMAIN_SwitchResolution_t)0x004f3f10; 48 | 49 | //typedef void(*WINMAIN_WndProc_t)(); 50 | //static const WINMAIN_WndProc_t WINMAIN_WndProc = (WINMAIN_WndProc_t)0x004f4ba0; 51 | LRESULT WINMAIN_WndProc(HWND hWnd, uint Msg, WPARAM wParam, LPARAM lParam); 52 | 53 | typedef void(*WINMAIN_ShutDown_t)(); 54 | static const WINMAIN_ShutDown_t WINMAIN_ShutDown = (WINMAIN_ShutDown_t)0x004f5750; 55 | 56 | void WINMAIN_PatchWndProc(); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/career/custom_goals.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\\thawk2.h" 3 | 4 | namespace CustomGoals 5 | { 6 | void PatchCareerGoals(void* levels); 7 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/gaps/gaps.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "gaps.h" 3 | 4 | SGapTrick catAir = { 0x80, 0, -2, 0, "AIR GAPS" }; 5 | SGapTrick catGrind = { 0x80, 0, -2, 0, "GRIND GAPS" }; 6 | SGapTrick catManual = { 0x80, 0, -2, 0, "MANUAL GAPS" }; 7 | SGapTrick catLip = { 0x80, 0, -2, 0, "LIP GAPS" }; 8 | SGapTrick catOther = { 0x80, 0, -2, 0, "OTHER GAPS" }; -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/gaps/gaps.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "thawk2/Career.h" 3 | 4 | using namespace Career; 5 | 6 | //category headlines, used to divide gaps per type in gap list 7 | extern SGapTrick catAir; 8 | extern SGapTrick catGrind; 9 | extern SGapTrick catManual; 10 | extern SGapTrick catLip; 11 | extern SGapTrick catOther; 12 | 13 | extern SGapTrick* pGapListThps1; 14 | extern SGapTrick* pGapListThps2; 15 | extern SGapTrick* pGapListThps3; 16 | extern SGapTrick* pGapListThps4; 17 | 18 | void PrintGap(SGapTrick* pGap); 19 | void CopyGaps(SGapTrick* src, SGapTrick* dst); 20 | void WipeGaps(); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/gte.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\patch\hook.h" 3 | 4 | /* 5 | GTE.H 6 | ===== 7 | Emulates PSX GTE chip math. 8 | Attempts to avoid 16 bit data loss along the way. 9 | */ 10 | 11 | namespace gte 12 | { 13 | extern Hook::Reroute* pHookList; 14 | 15 | 16 | typedef struct Vector3s { 17 | short X; 18 | short Y; 19 | short Z; 20 | } Vector3s; 21 | 22 | typedef struct Vector3i { 23 | int X; 24 | int Y; 25 | int Z; 26 | } Vector3i; 27 | 28 | 29 | typedef struct Vector3f { 30 | float X; 31 | float Y; 32 | float Z; 33 | } Vector3f; 34 | 35 | 36 | typedef struct Vector3d { 37 | double X; 38 | double Y; 39 | double Z; 40 | } Vector3d; 41 | 42 | // 20/29 ~68% 43 | 44 | typedef void(*mygte_lvtosv_t)(); 45 | typedef void(*mygte_lvtosvU_t)(); 46 | typedef void(*mygte_svtorgb_t)(); 47 | typedef void(*gte_ldlzc_t)(); 48 | //typedef void(*gte_gpf12_t)(); 49 | //typedef void(*gte_gpl0_t)(); 50 | //typedef void(*gte_gpl12_t)(); 51 | //typedef void(*gte_lcv0_t)(); 52 | //typedef void(*gte_lcir_t)(); 53 | //typedef void(*gte_lcirtr_t)(); 54 | //typedef void(*gte_llir_sf0_t)(); 55 | //typedef void(*gte_llirbk_t)(); 56 | //typedef void(*gte_llv0_t)(); 57 | typedef void(*gte_mvmva_t)(); 58 | typedef void(*gte_nclip_t)(); 59 | //typedef void(*gte_op0_t)(); 60 | //typedef void(*gte_op12_t)(); 61 | //typedef void(*gte_rt_t)(); 62 | //typedef void(*gte_rtir_t)(); 63 | //typedef void(*gte_rtirtr_t)(); 64 | //typedef void(*gte_rtir_sf0_t)(); 65 | typedef void(*gte_rtps_t)(); 66 | typedef void(*gte_rtpt_t)(); 67 | //typedef void(*gte_rtv0_t)(); 68 | //typedef void(*gte_rtv0tr_t)(); 69 | //typedef void(*gte_rtv0_sf0_t)(); 70 | //typedef void(*gte_rtv1_t)(); 71 | //typedef void(*gte_rtv2_t)(); 72 | //typedef void(*gte_sqr0_t)(); 73 | 74 | static const mygte_lvtosv_t mygte_lvtosv = (mygte_lvtosv_t)0x004df230; 75 | static const mygte_lvtosvU_t mygte_lvtosvU = (mygte_lvtosvU_t)0x004df2f0; 76 | static const mygte_svtorgb_t mygte_svtorgb = (mygte_svtorgb_t)0x004df3a0; 77 | static const gte_ldlzc_t gte_ldlzc = (gte_ldlzc_t)0x004df470; 78 | //static const gte_gpf12_t gte_gpf12 = (gte_gpf12_t)0x004df560; 79 | void gte_gpf12(); 80 | //static const gte_gpl0_t gte_gpl0 = (gte_gpl0_t)0x004df5b0; 81 | void gte_gpl0(); 82 | //static const gte_gpl12_t gte_gpl12 = (gte_gpl12_t)0x004df610; 83 | void gte_gpl12(); 84 | //static const gte_lcv0_t gte_lcv0 = (gte_lcv0_t)0x004df670; 85 | void gte_lcv0(); 86 | //static const gte_lcir_t gte_lcir = (gte_lcir_t)0x004df990; 87 | void gte_lcir(); 88 | //static const gte_lcirtr_t gte_lcirtr = (gte_lcirtr_t)0x004dfa30; 89 | void gte_lcirtr(); 90 | //static const gte_llir_sf0_t gte_llir_sf0 = (gte_llir_sf0_t)0x004dfaf0; 91 | void gte_llir_sf0(); 92 | //static const gte_llirbk_t gte_llirbk = (gte_llirbk_t)0x004dfb90; 93 | void gte_llirbk(); 94 | //static const gte_llv0_t gte_llv0 = (gte_llv0_t)0x004dfc50; 95 | void gte_llv0(); 96 | static const gte_mvmva_t gte_mvmva = (gte_mvmva_t)0x004e00b0; 97 | static const gte_nclip_t gte_nclip = (gte_nclip_t)0x004e00e0; 98 | //static const gte_op0_t gte_op0 = (gte_op0_t)0x004e0140; 99 | void gte_op0(); 100 | //static const gte_op12_t gte_op12 = (gte_op12_t)0x004e01b0; 101 | void gte_op12(); 102 | //static const gte_rt_t gte_rt = (gte_rt_t)0x004e0230; 103 | void gte_rt(); 104 | //static const gte_rtir_t gte_rtir = (gte_rtir_t)0x004e02f0; 105 | void gte_rtir(); 106 | //static const gte_rtirtr_t gte_rtirtr = (gte_rtirtr_t)0x004e0390; 107 | void gte_rtirtr(); 108 | //static const gte_rtir_sf0_t gte_rtir_sf0 = (gte_rtir_sf0_t)0x004e0450; 109 | void gte_rtir_sf0(); 110 | static const gte_rtps_t gte_rtps = (gte_rtps_t)0x004e04f0; 111 | static const gte_rtpt_t gte_rtpt = (gte_rtpt_t)0x004e06a0; 112 | //static const gte_rtv0_t gte_rtv0 = (gte_rtv0_t)0x004e0b60; 113 | void gte_rtv0(); 114 | //static const gte_rtv0tr_t gte_rtv0tr = (gte_rtv0tr_t)0x004e0c00; 115 | void gte_rtv0tr(); 116 | //static const gte_rtv0_sf0_t gte_rtv0_sf0 = (gte_rtv0_sf0_t)0x004e0cc0; 117 | void gte_rtv0_sf0(); 118 | //static const gte_rtv1_t gte_rtv1 = (gte_rtv1_t)0x004e0d60; 119 | void gte_rtv1(); 120 | //static const gte_rtv2_t gte_rtv2 = (gte_rtv2_t)0x004e0e00; 121 | void gte_rtv2(); 122 | //static const gte_sqr0_t gte_sqr0 = (gte_sqr0_t)0x004e0ea0; 123 | void gte_sqr0(); 124 | 125 | //additional macros, that are inlined on PC ports 126 | void gte_ldv0(Vector3s* v); 127 | void gte_ldv1(Vector3s* v); 128 | void gte_ldv2(Vector3s* v); 129 | void gte_ldsv(Vector3s* v); 130 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/m3d.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int* M3d_WireframeMode = (int*)0x560fdc; 4 | int* M3d_WireframeLast = (int*)0x560fe0; 5 | 6 | int* RenderModelFlags = (int*)0x55ed04; 7 | 8 | /* 9 | void RenderModel(void* model) 10 | { 11 | int flags = M3d_WireframeMode ? 0x200 : 0; 12 | 13 | D3DMODEL_RenderModel(model, *RenderModelFlags | uVar1); 14 | *M3d_WireframeMode = *M3d_WireframeLast; 15 | } 16 | */ -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/pal.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "thawk2\Mem.h" 3 | #include "thawk2\pal.h" 4 | #include "types.h" 5 | #include "..\patch\hook.h" 6 | #include "thawk2\_old.h" 7 | 8 | namespace Pal { 9 | 10 | int* TotalPaletteUsage = (int*)0x00568364; 11 | S_Pal* pPaletteList = (S_Pal*)0x00567f50; 12 | 13 | int* Pal16Max = (int*)0x00532dac; 14 | int* Pal256Max = (int*)0x00532db0; 15 | 16 | bool* Pal16Usage = (bool*)0x00568054; 17 | bool* Pal256Usage = (bool*)0x00567f54; 18 | 19 | // creates a new palette entry 20 | S_Pal* NewPaletteEntry(uint Checksum) { 21 | 22 | printf("DECOMP Pal_CreateNew(): %i\n", Checksum); 23 | 24 | // allocate new palette 25 | S_Pal* pPal = (S_Pal*)Mem_New(0x18, 0, 1, 0); 26 | 27 | // increase palette memory usage counter 28 | *TotalPaletteUsage += 0x1c; //why not 0x18? 29 | 30 | // update links 31 | pPal->pPrev = pPaletteList; 32 | pPal->pNext = NULL; 33 | 34 | // update first 35 | pPaletteList = pPal; 36 | 37 | // if list wasnt NULL, update previous first palette 38 | if (pPal->pPrev != NULL) { 39 | pPal->pPrev->pNext = pPal; 40 | } 41 | 42 | // was uploaded to VRAM 43 | pPal->InVRAM = false; 44 | 45 | // set checksum 46 | pPal->Checksum = Checksum; 47 | 48 | // usage? 49 | pPal->Usage = 0; 50 | 51 | return pPal; 52 | } 53 | 54 | // removes a palette 55 | void RemovePaletteEntry(S_Pal* pPal) 56 | { 57 | printf("DECOMP Pal_Free()\n"); 58 | 59 | if (pPal->pPrev != NULL) 60 | pPal->pPrev->pNext = pPal->pNext; 61 | 62 | if (pPal->pNext != NULL) 63 | pPal->pNext->pPrev = pPal->pPrev; 64 | 65 | if (pPal == pPaletteList) 66 | pPaletteList = pPal->pPrev; 67 | 68 | Mem_Delete(pPal); 69 | 70 | *TotalPaletteUsage -= 0x1c; 71 | } 72 | 73 | // iterates over the palette list until checksum is found. 74 | S_Pal* Pal_FindPaletteEntry(uint Checksum) { 75 | 76 | printf("DECOMP Pal_FindPaletteEntry(): %i\n", Checksum); 77 | 78 | if (pPaletteList == NULL) return NULL; 79 | 80 | S_Pal* pPal = pPaletteList; 81 | 82 | do { 83 | // got a match? 84 | if (pPal->Checksum == Checksum) 85 | return pPal; 86 | 87 | // go to the next palette 88 | pPal = pPal->pPrev; 89 | 90 | } while (pPal != NULL); 91 | 92 | return pPal; 93 | } 94 | 95 | int GetFree16Slot() 96 | { 97 | for (int i = 0; i < *Pal16Max; i++) 98 | if (Pal16Usage[i]) 99 | { 100 | Pal16Usage[i] = false; 101 | return i; 102 | } 103 | 104 | printf("Ran out of Pal16 slots!\n"); 105 | 106 | Pal16Usage[*Pal16Max - 1] = false; 107 | 108 | return *Pal16Max - 1; 109 | } 110 | 111 | int GetFree256Slot() 112 | { 113 | for (int i = 0; i < *Pal256Max; i++) 114 | if (Pal256Usage[i]) 115 | { 116 | Pal256Usage[i] = false; 117 | return i; 118 | } 119 | 120 | printf("Ran out of Pal256 slots!\n"); 121 | 122 | Pal16Usage[*Pal256Max - 1] = false; 123 | 124 | return *Pal256Max - 1; 125 | } 126 | 127 | 128 | 129 | void Pal_RemoveUnusedPalettes() 130 | { 131 | if (pPaletteList == NULL) return; 132 | 133 | S_Pal* pPal = pPaletteList; 134 | S_Pal* pPrev = pPal->pPrev; 135 | 136 | do { 137 | if (pPal->Usage == 0) { 138 | 139 | D3DTEX_FreePaletteEntry(pPal->pD3DPalette, 0); 140 | 141 | pPal->pD3DPalette = NULL; 142 | 143 | if (pPal->flags & 1) 144 | Pal16Usage[pPal->slot] = true; 145 | 146 | if (pPal->flags & 2) 147 | Pal256Usage[pPal->slot] = true; 148 | 149 | RemovePaletteEntry(pPal); 150 | } 151 | 152 | pPal = pPrev; 153 | 154 | } while (pPrev != NULL); 155 | } 156 | 157 | 158 | // === hook stuff === 159 | 160 | Hook::Reroute hookList[] = { 161 | 162 | { 0x004880dc, NewPaletteEntry }, 163 | 164 | { 0x004b0143, Pal_FindPaletteEntry }, 165 | { 0x004b01e8, Pal_FindPaletteEntry }, 166 | { 0x004b05be, Pal_FindPaletteEntry }, 167 | 168 | { 0x00487d62, RemovePaletteEntry }, 169 | 170 | { 0x00449d05, GetFree16Slot }, 171 | { 0x0048824b, GetFree16Slot }, 172 | { 0x00488034, GetFree256Slot }, 173 | { 0x004882f3, GetFree256Slot }, 174 | { 0x004ad751, GetFree256Slot }, 175 | 176 | 177 | 178 | //========================= 179 | { NULL, NULL } 180 | }; 181 | 182 | Hook::Reroute* pHookList = &hookList[0]; 183 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/pal.h: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "types.h" 3 | #include "..\patch\hook.h" 4 | 5 | namespace Pal { 6 | 7 | extern Hook::Reroute* pHookList; 8 | 9 | typedef struct S_Pal { 10 | ushort Clut; 11 | char slot; 12 | char flags; 13 | ushort Usage; 14 | bool InVRAM; 15 | char RemapIndex; 16 | uint Checksum; 17 | void* pD3DPalette; 18 | S_Pal* pPrev; 19 | S_Pal* pNext; 20 | } S_Pal; 21 | 22 | 23 | typedef void(*Pal_Init_t)(); 24 | typedef void(*Pal_Cleanup_t)(); 25 | // typedef void(*NewPaletteEntry_t)(); 26 | // typedef void(*RemovePaletteEntry_t)(); 27 | // typedef void(*Pal_FindPaletteEntry_t)(); 28 | // typedef void(*Pal_RemoveUnusedPalettes_t)(); 29 | // typedef void(*GetFree16Slot_t)(); 30 | typedef void(*Free16Slot_t)(); 31 | // typedef void(*GetFree256Slot_t)(); 32 | typedef void(*_free256slot_t)(); 33 | typedef void(*_calcPaletteUsageStats_t)(); 34 | typedef void(*Get256SlotNumber_t)(); 35 | typedef void(*Get16SlotNumber_t)(); 36 | typedef void(*_psxUploadtoVRAM_t)(); 37 | typedef void(*_psxUploadtoVRam2_t)(); 38 | typedef void(*Pal_LoadPalette_t)(); 39 | typedef void(*Pal_CopyToMemory_t)(); 40 | typedef void(*Pal_StoreFromMemory_t)(); 41 | 42 | static const Pal_Init_t Pal_Init = (Pal_Init_t)0x004879a0; 43 | static const Pal_Cleanup_t Pal_Cleanup = (Pal_Cleanup_t)0x00487c10; 44 | // static const NewPaletteEntry_t NewPaletteEntry = (NewPaletteEntry_t)0x00487c50; 45 | S_Pal* NewPaletteEntry(uint Checksum); 46 | // static const RemovePaletteEntry_t RemovePaletteEntry = (RemovePaletteEntry_t)0x00487ca0; 47 | void RemovePaletteEntry(S_Pal* pPal); 48 | // static const Pal_FindPaletteEntry_t Pal_FindPaletteEntry = (Pal_FindPaletteEntry_t)0x00487cf0; 49 | S_Pal* Pal_FindPaletteEntry(uint Checksum); 50 | // static const Pal_RemoveUnusedPalettes_t Pal_RemoveUnusedPalettes = (Pal_RemoveUnusedPalettes_t)0x00487d10; 51 | void Pal_RemoveUnusedPalettes(); 52 | // static const GetFree16Slot_t GetFree16Slot = (GetFree16Slot_t)0x00487d80; 53 | int GetFree16Slot(); 54 | static const Free16Slot_t Free16Slot = (Free16Slot_t)0x00487df0; 55 | // static const GetFree256Slot_t GetFree256Slot = (GetFree256Slot_t)0x00487e80; 56 | int GetFree256Slot(); 57 | static const _free256slot_t _free256slot = (_free256slot_t)0x00487ef0; 58 | static const _calcPaletteUsageStats_t _calcPaletteUsageStats = (_calcPaletteUsageStats_t)0x00487f80; 59 | static const Get256SlotNumber_t Get256SlotNumber = (Get256SlotNumber_t)0x00487fe0; 60 | static const Get16SlotNumber_t Get16SlotNumber = (Get16SlotNumber_t)0x00487ff0; 61 | static const _psxUploadtoVRAM_t _psxUploadtoVRAM = (_psxUploadtoVRAM_t)0x00488000; 62 | static const _psxUploadtoVRam2_t _psxUploadtoVRam2 = (_psxUploadtoVRam2_t)0x00488070; 63 | static const Pal_LoadPalette_t Pal_LoadPalette = (Pal_LoadPalette_t)0x004880d0; 64 | static const Pal_CopyToMemory_t Pal_CopyToMemory = (Pal_CopyToMemory_t)0x004883c0; 65 | static const Pal_StoreFromMemory_t Pal_StoreFromMemory = (Pal_StoreFromMemory_t)0x004883f0; 66 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/powerup.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "powerup.h" 3 | 4 | /* 5 | CPowerUp::CPowerUp(unsigned short PowerUpType, int* pos, int* vel, char Flags, unsigned short Lifetime, unsigned short Node) 6 | { 7 | throw; 8 | } 9 | */ 10 | 11 | /* 12 | CPowerUp::~CPowerUp() 13 | { 14 | throw; 15 | } 16 | */ 17 | 18 | void CPowerUp::SetGravity(int Gravity, int Friction) 19 | { 20 | //cItem_gravity = Gravity; 21 | //cItem_friction = Friction; 22 | } 23 | 24 | void CPowerUp::DontDisplay() 25 | { 26 | //cItem_flags |= 0x41; 27 | DeleteStuff(); 28 | } 29 | 30 | /* 31 | void CPowerUp::DeleteStuff() 32 | { 33 | throw; 34 | } 35 | */ 36 | 37 | void CPowerUp::Die() 38 | { 39 | // why even check? 40 | if (!IsDead()) 41 | mCBodyFlags |= CBODY_DEAD; 42 | } 43 | 44 | /* 45 | void CPowerUp::AI() 46 | { 47 | throw; 48 | } 49 | */ 50 | 51 | void CPowerUp::SetNode(unsigned short nodeIndex) 52 | { 53 | mHasNode = true; 54 | mNodeIndex = nodeIndex; 55 | } 56 | 57 | CPowerUp* PowerUp_Create(unsigned short PowerUpType, void* pos, char Flags, unsigned short Lifetime, unsigned short Node) 58 | { 59 | return NULL; 60 | //return new CPowerUp(PowerUpType, pos, emptyvel, Flags, Lifetime, Node); 61 | } -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/powerup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //CItem->CIcon3d only for arrow? 4 | // 5 | //CItem->CBody->CCamera sizeof = 0x674 6 | //CItem->CBody->CPowerUp sizeof = 0x100 7 | //CItem->CBody->CSuper sizeof = 0x168 8 | //CItem->CBody->CBackground sizeof = 0xcc 9 | 10 | #define CBODY_SUSPENDED (1 << 0) 11 | #define CBODY_HASSHADOW (1 << 3) // 0008 12 | #define CBODY_DEAD (1 << 6) // 0040 13 | 14 | /* 15 | CBODY_HITBYSMARTBOMB(1 << 8) 16 | CBODY_TIMETODIE(1<<7) 17 | CBODY_ZOMBIE(1<<6) 18 | CBODY_PROTECTED(1 << 5)) 19 | CBODY_TARGETTABLE(1 << 4) 20 | CBODY_HASSHADOW(1<<3)) 21 | CBODY_CANBESEEDED(1<<2) 22 | CBODY_RADIALSUSPENSION(1<<1) 23 | CBODY_SUSPENDED(1 << 0) 24 | */ 25 | 26 | /* inherited from Cbody: 27 | * CBackground 28 | * CCamera 29 | * CPowerup 30 | */ 31 | 32 | class CBody { 33 | public: 34 | CBody** mppOriginalList; 35 | unsigned short mCBodyFlags; 36 | 37 | virtual void DeleteStuff() = 0; 38 | virtual void Die() = 0; 39 | virtual void AI() = 0; 40 | 41 | void ShadowOn() 42 | { 43 | mCBodyFlags |= CBODY_HASSHADOW; 44 | } 45 | 46 | bool IsDead() 47 | { 48 | return (mCBodyFlags & CBODY_DEAD) > 0; 49 | } 50 | 51 | 52 | void Suspend(CBody** list) 53 | { 54 | // check if maybe flag is set already 55 | if (mCBodyFlags & 0xffffff01) 56 | printf("Suspended flag illegally set."); 57 | 58 | // null check the list we're going to remove it from 59 | if (list == NULL) 60 | printf("woops (list is null in CBody::Suspend)"); 61 | 62 | // delete stuff? 63 | //DeleteStuff(); 64 | 65 | // remember the list 66 | mppOriginalList = list; 67 | 68 | // remove from list 69 | //DeleteFrom(this, list); 70 | 71 | // attach to global list of suspended items 72 | //AttachTo(this, SuspendedList); 73 | 74 | // set suspended flag 75 | mCBodyFlags |= CBODY_SUSPENDED; 76 | } 77 | 78 | 79 | void UnSuspend() 80 | { 81 | if ((mCBodyFlags & CBODY_SUSPENDED) > 0) { 82 | //DeleteFrom(&SuspendedList); 83 | //AttachTo(pBody->mppOriginalList); 84 | 85 | mCBodyFlags &= ~CBODY_SUSPENDED; 86 | } 87 | } 88 | }; 89 | 90 | /* 91 | interface CItem? CBody? 92 | delete 93 | DeleteStuff() 94 | Die() 95 | AI() 96 | EveryFrame() 97 | DoLightingSetup() 98 | Hit() 99 | */ 100 | 101 | /* 102 | DEFAULT_ROTSPEED 100 103 | PFLAG_DROPFOREVER 1<<4 104 | PFLAG_HOPUP 1<<3 105 | PFLAG_DROPONCREATION 1<<2 106 | PFLAG_EFFECTONCREATION 1<<1 107 | PFLAG_PLAYSOUNDONCREATION 1<<0 108 | */ 109 | 110 | class CPowerUp : CBody 111 | { 112 | public: 113 | void* mpGlow; 114 | unsigned short mGlowRadiusOrg; 115 | unsigned short mGlowRadiusAmp; 116 | bool mHasNode; 117 | bool mIs3d; 118 | bool mDropping; 119 | bool mDropForever; 120 | short mHoverHeight; 121 | unsigned short mNodeIndex; 122 | int mGroundY; 123 | // svector3 124 | int mOrgPosX; 125 | int mOrgPosY; 126 | int mOrgPosZ; 127 | unsigned short mT; 128 | short mMaxWobbleAmplitude; 129 | short mWobbleAmplitude; 130 | short mWobbleSpeed; 131 | short mLifetime; 132 | // unknown 6 bytes 133 | // unknown int 134 | int mTimer; 135 | 136 | void CheckAge(); 137 | CPowerUp(); 138 | //void CPowerUp() 139 | void WhoAmI(); 140 | void SetNode(unsigned short nodeIndex); 141 | void TakeEffect(); 142 | void SetGravity(int, int); 143 | void DontDisplay(); 144 | void CreateBit(); 145 | void DeleteStuff() override; 146 | void DoPhysics(); 147 | void Die() override; 148 | void AI() override; 149 | }; 150 | 151 | //0x00568490 152 | extern CBody** PowerUpList; 153 | 154 | //CPowerUp* PowerUp_Create(unsigned short PowerUpType, int* pos, char Flags, unsigned short Lifetime, unsigned short Node); -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/readme.md: -------------------------------------------------------------------------------- 1 | # THawk2 2 | 3 | THawk2 folder contains header files with the original game function pointers found in "smaller exe". It can be called directly from any custom code. 4 | Partially rewritten code can be found in corresponding cpp files. 5 | 6 | Source file names and function names are authentic Neversoft names coming from the following publicly available sources: 7 | 8 | * PC version debug comments 9 | - Some leftover debug strings can be found in all versions of the game 10 | - PC version specifically contains a lot of garbage generated by extra ASSERTER inlined string processing code. 11 | - Whenever you see pattern like: 12 | ``` 13 | = 0xffffffff; (-1) 14 | = 267; (some int) 15 | = "somesourcefile.cpp" 16 | and then 20-30 lines later 17 | ASSERTER(message) 18 | ``` 19 | - this code was originally just a single line and can be safely removed altogether, excluding occasions when some extra meaningful logic is performed before the asserter. 20 | 21 | * Mac OS X build debug symbols 22 | - limited to function names, ghidra doesnt recognize class names 23 | - very close to the PC version minus ghidra ARM problems with switch case. 24 | - also some stuff is aggresively inlined by the compiler, often requires manual analysis. 25 | 26 | * iOS build debug symbols 27 | - function names (actual signature with param types available) + some scattered global variable names. 28 | - backend functions are rewritten to opengl and apple libs, hence drastic differences in platform specific logic 29 | - suffers from inlining as well 30 | 31 | * PSX Pro Skater Demo build debug symbols 32 | - There is a SYM file in the PROSKATE demo available. 33 | - the demo however did not implement many things yet, hence lacks many menu names, game modes, career stuff, etc. 34 | - luckily has no relocatable modules implemented yet, since all stuff is in the executable file. 35 | 36 | * PC Demo leftover source files 37 | - there are a few scattered C source files with .mik extension found in PC early demo 38 | - there is debug VS project DB containing all symbols, including structs, enums, etc. 39 | - it contains most core stuff already, but there are many differences still - incomplete enums, missing funcs, etc. 40 | -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/thawk2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // includes all required decomp headers 4 | 5 | 6 | #include "thawk2/_old.h" 7 | #include "thawk2/Career.h" 8 | #include "thawk2/career/custom_goals.h" 9 | #include "thawk2/CBruce.h" 10 | #include "thawk2/CClass.h" 11 | #include "thawk2/CMenu.h" 12 | #include "thawk2/flash.h" 13 | #include "thawk2/gaps/gaps.h" 14 | #include "thawk2/globals.h" 15 | #include "thawk2/gte.h" 16 | #include "thawk2/Init.h" 17 | #include "thawk2/IO/FileIO.h" 18 | #include "thawk2/IO/PCIO.h" 19 | #include "thawk2/Mem.h" 20 | #include "thawk2/Mess.h" 21 | #include "thawk2/Pal.h" 22 | #include "thawk2/PCInput.h" 23 | #include "thawk2/PCMovie.h" 24 | #include "thawk2/Physics.h" 25 | #include "thawk2/Rail.h" 26 | #include "thawk2/Redbook.h" 27 | #include "thawk2/Render.h" 28 | #include "thawk2/Sfx.h" 29 | #include "thawk2/Shatter.h" 30 | #include "thawk2/SkaterProfile.h" 31 | #include "thawk2/Spool.h" 32 | #include "thawk2/Utils.h" 33 | #include "thawk2/WinMain.h" 34 | 35 | -------------------------------------------------------------------------------- /th2patch/hawk2/thawk2/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define uint uint32_t 4 | #define ushort uint16_t 5 | #define NS_NULL (uint32_t)0xFFFFFFFF -------------------------------------------------------------------------------- /th2patcheditmusic/readme.md: -------------------------------------------------------------------------------- 1 | # Music editor for THPS2 patch 2 | This folder contains everything needed to edit soundtrack in music.db. 3 | Backup music.db before editing. 4 | 5 | 1. If ```sqlite3.exe``` is not present in the folder, download official ```sqlite3.exe``` command line utility from https://www.sqlite.org/ and copy to this folder. 6 | 2. Open ```sql_music_list.csv``` in notepad or any other text editor, by default it contains original THPS2PC soundtrack entries. 7 | 3. Add a few lines in following format ,,,,<file> 8 | 4. Save changes and launch ```sql_music_import.bat``` (it will execute SQL queries to import the data) 9 | 5. It should create ```music.db``` file and output the new soundtrack table contents in a cmd window. 10 | 6. Copy ```music.db``` file to ```patch``` folder. 11 | 5. Launch the game to check if it worked. 12 | 13 | Keep in mind that this procedure will completely wipe existing soundtrack entries from the database, so you must have every single entry in your CSV. 14 | Keep source CSV file along the database if you plan to edit your soundtrack regularly. Otherwise you can extract existing data using some SQLite editor like SQLiteStudio. 15 | 16 | # Audio files 17 | .DAT files found in music folder of the game are just renamed .BIK files in Bink audio format. You need to obtain a copy of RAD Game Tools/RAD Video Tools https://www.radgametools.com/bnkdown.htm , but preferably an older version. -------------------------------------------------------------------------------- /th2patcheditmusic/sql_music_import.bat: -------------------------------------------------------------------------------- 1 | sqlite3.exe music.db <sql_music_params.txt 2 | pause 3 | -------------------------------------------------------------------------------- /th2patcheditmusic/sql_music_list.csv: -------------------------------------------------------------------------------- 1 | thps2,1,Papa Roach,Blood Brothers,ltix16.dat 2 | thps2,2,Anthrax and Chuck D,Bring The Noise,ltix17.dat 3 | thps2,3,Rage Against The Machine,Guerilla Radio,ltix18.dat 4 | thps2,4,Naughty By Nature,Pin The Tail On The Donkey,ltix19.dat 5 | thps2,5,Bad Religion,You,ltix20.dat 6 | thps2,6,Powerman 5000,When Worlds Collide,ltix21.dat 7 | thps2,7,Millencolin,No Cigar,ltix22.dat 8 | thps2,8,The High and Mighty,B-Boy Document '99,ltix23.dat 9 | thps2,9,Dub Pistols,Cyclone,ltix24.dat 10 | thps2,10,Lagwagon,May 16,ltix25.dat 11 | thps2,11,Styles of Beyond,Subculture,ltix26.dat 12 | thps2,12,Consumed,Heavy Metal Winner,ltix27.dat 13 | thps2,13,Fu Manchu,Evil Eye,ltix28.dat 14 | thps2,14,Alley Life,Out With The Old,ltix29.dat 15 | thps2,15,Swingin' Utters,Five Lessons Learned,ltix30.dat -------------------------------------------------------------------------------- /th2patcheditmusic/sql_music_params.txt: -------------------------------------------------------------------------------- 1 | delete from Soundtrack; 2 | .mode csv 3 | .import sql_music_list.csv Soundtrack 4 | VACUUM; 5 | PRAGMA integrity_check; 6 | select * from SoundTrack; -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32519.379 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "th2patchlauncher", "th2patchlauncher\th2patchlauncher.csproj", "{B4D73D3D-7932-406A-9DC7-2CE490C8B1EF}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B4D73D3D-7932-406A-9DC7-2CE490C8B1EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B4D73D3D-7932-406A-9DC7-2CE490C8B1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B4D73D3D-7932-406A-9DC7-2CE490C8B1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B4D73D3D-7932-406A-9DC7-2CE490C8B1EF}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {217F9357-5767-4EE9-82EC-01604F1DFB9A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/ErrorMsg.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace th2patchlauncher 4 | { 5 | class ErrorMsg 6 | { 7 | public static string Thawk2NotFound = "Thawk2.exe not found.\r\nPlease extract patch files to your THPS2 root directory."; 8 | public static string Thawk2InUse = "Thawk2.exe is locked.\r\nIt means that it's currently running\r\n or is opened in another application."; 9 | public static string Thawk2NotSmaller = "THawk2.exe you are using is not supported.\r\nMake sure you have \"smaller\" exe installed.\r\nyou can find it at thmods.com\\mods"; 10 | } 11 | } -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Patch/Helpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace thps2patch 5 | { 6 | public class Helpers 7 | { 8 | /// <summary> 9 | /// Simply checks whether file is accessible. 10 | /// </summary> 11 | /// <param name="filename"></param> 12 | /// <returns></returns> 13 | public static bool FileLocked(string filename) 14 | { 15 | try 16 | { 17 | var file = new FileInfo(filename); 18 | var stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read); 19 | stream.Close(); 20 | 21 | return false; 22 | } 23 | catch 24 | { 25 | return true; 26 | } 27 | } 28 | 29 | //used to validate smaller THawk2.exe. Come up with something smarter but fast enough. 30 | public static bool isSmallerExe(string path) 31 | { 32 | bool result = false; 33 | 34 | using (var br = new BinaryReader(File.OpenRead(path))) 35 | { 36 | if (br.BaseStream.Length >= 0x1642EC + 4) 37 | { 38 | br.BaseStream.Position = 0x1642EC; 39 | 40 | if (br.ReadUInt32() == 0xF92BD1F7) 41 | result = true; 42 | } 43 | } 44 | 45 | return result; 46 | } 47 | 48 | /// <summary> 49 | /// A simple Math.Clamp implementation for ints. 50 | /// </summary> 51 | /// <param name="value"></param> 52 | /// <param name="min"></param> 53 | /// <param name="max"></param> 54 | /// <returns></returns> 55 | public static int MathClamp(int value, int min, int max) 56 | { 57 | if (max < min) throw new Exception("MAX is less than MIN. please fix."); 58 | 59 | if (value < min) { return min; } 60 | if (value > max) { return max; } 61 | 62 | return value; 63 | } 64 | 65 | /// <summary> 66 | /// A simple Math.Clamp implementation for floats. 67 | /// </summary> 68 | /// <param name="value"></param> 69 | /// <param name="min"></param> 70 | /// <param name="max"></param> 71 | /// <returns></returns> 72 | public static float MathClamp(float value, float min, float max) 73 | { 74 | if (max < min) throw new Exception("MAX is less than MIN. please fix."); 75 | 76 | if (value < min) { return min; } 77 | if (value > max) { return max; } 78 | 79 | return value; 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Patch/LevelPatch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Windows.Forms; 5 | 6 | namespace thps2patch 7 | { 8 | class LevelPatch 9 | { 10 | public string currentgame = "THPS2"; 11 | 12 | struct Level 13 | { 14 | public string game; 15 | public int offset; 16 | public string trig; 17 | 18 | public Level(string g, int o, string t) 19 | { 20 | game = g; 21 | offset = o; 22 | trig = t; 23 | } 24 | 25 | public void ModifyOffset(int x) 26 | { 27 | offset += x; 28 | } 29 | 30 | 31 | public void ApplyPatch(Mem m) 32 | { 33 | string fn = ""; 34 | 35 | if (trig.Contains("(file)")) 36 | { 37 | try 38 | { 39 | fn = ".\\patch\\" + trig.Replace("(file)", ""); 40 | // System.Windows.Forms.MessageBox.Show(fn); 41 | 42 | if (File.Exists(fn)) m.WriteFile(offset, fn); 43 | return; 44 | } 45 | catch 46 | { 47 | File.AppendAllText("patch.log", "Warning: file " + fn + " is missing.\r\n"); 48 | return; 49 | } 50 | } 51 | 52 | if (trig.Contains("(int32)")) 53 | { 54 | int x = 0; 55 | fn = trig.Replace("(int32)", ""); 56 | 57 | if (Int32.TryParse(fn, out x)) 58 | { 59 | m.WriteInt(offset, x); 60 | } 61 | else 62 | { 63 | File.AppendAllText("patch.log", "Can't write value " + fn + " at " + offset.ToString("X8") + " - failed to parse int32.\r\n"); 64 | } 65 | return; 66 | } 67 | 68 | 69 | if (trig.Contains("(int16)")) 70 | { 71 | short x = 0; 72 | fn = trig.Replace("(int16)", ""); 73 | 74 | if (Int16.TryParse(fn, out x)) 75 | { 76 | m.WriteShort(offset, x); 77 | } 78 | else 79 | { 80 | File.AppendAllText("patch.log", "Can't write value " + fn + " at " + offset.ToString("X8") + " - failed to parse int16.\r\n"); 81 | } 82 | return; 83 | } 84 | 85 | if (trig.Contains("(byte)")) 86 | { 87 | byte x = 0; 88 | fn = trig.Replace("(byte)", ""); 89 | 90 | if (Byte.TryParse(fn, out x)) 91 | { 92 | m.WriteByte(offset, x); 93 | } 94 | else 95 | { 96 | File.AppendAllText("patch.log", "Can't write value " + fn + " at " + offset.ToString("X8") + " - failed to parse byte.\r\n"); 97 | } 98 | return; 99 | } 100 | 101 | 102 | if (trig.Contains("(float)")) 103 | { 104 | 105 | float x = 0; 106 | fn = trig.Replace("(float)", ""); 107 | 108 | System.Globalization.NumberStyles style = System.Globalization.NumberStyles.AllowDecimalPoint; 109 | System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"); 110 | 111 | if (Single.TryParse(fn, style, culture, out x)) 112 | { 113 | m.WriteFloat(offset, x); 114 | } 115 | else 116 | { 117 | File.AppendAllText("patch.log", "Can't write value " + fn + " at " + offset.ToString("X8") + " - failed to parse float.\r\n"); 118 | } 119 | return; 120 | } 121 | 122 | m.WriteString(offset, trig); 123 | 124 | } 125 | } 126 | 127 | List<Level> levels = new List<Level>(); 128 | 129 | public void ReadLevels(string f) 130 | { 131 | 132 | if (File.Exists(f)) 133 | { 134 | string game = "[]"; 135 | 136 | string[] buf = File.ReadAllLines(f); 137 | 138 | foreach (string s in buf) 139 | { 140 | string p = TrimComment(s); 141 | 142 | switch (p) 143 | { 144 | case "": break; 145 | case "[THPS1]": game = "THPS1"; break; 146 | case "[THPS2]": game = "THPS2"; break; 147 | case "[THPS3]": game = "THPS3"; break; 148 | case "[THPS4]": game = "THPS4"; break; 149 | case "[MHPB]": game = "MHPB"; break; 150 | case "[GLOBAL]": game = "GLOBAL"; break; 151 | default: levels.Add(BakeLevel(p, game)); break; 152 | } 153 | } 154 | } 155 | else 156 | { 157 | //File.AppendAllText("patch.log", "Warning: patch file " + f + " not found. Ignore this if you don't have LevelPack."); 158 | } 159 | } 160 | 161 | //removes everything after # 162 | private string TrimComment(string s) 163 | { 164 | int x = s.IndexOf('#'); 165 | if (x < 0) x = s.Length; 166 | return s.Substring(0, x).Trim(' '); 167 | } 168 | 169 | private Level BakeLevel(string s, string game) 170 | { 171 | string[] buf = s.Split('='); 172 | 173 | int x = Convert.ToInt32(buf[0], 16); 174 | 175 | return new Level(game, x, buf[1].Replace(@"\*", "*").Replace('*', '\0')); 176 | } 177 | 178 | public LevelPatch(string f, string s) 179 | { 180 | currentgame = s; 181 | ReadLevels(f); 182 | } 183 | 184 | 185 | public void Patch(string pr) 186 | { 187 | try 188 | { 189 | Mem mem = new Mem(pr); 190 | 191 | foreach (Level l in levels) 192 | if (currentgame == l.game) 193 | l.ApplyPatch(mem); 194 | 195 | foreach (Level l in levels) 196 | if (l.game == "GLOBAL") 197 | l.ApplyPatch(mem); 198 | } 199 | catch (Exception ex) 200 | { 201 | MessageBox.Show(ex.Message); 202 | } 203 | } 204 | 205 | //huh? 206 | public void ModifyKorean() 207 | { 208 | for (int i = 0; i < levels.Count; i++) 209 | levels[i].ModifyOffset(0x3AC8); 210 | } 211 | 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Patch/MainPatch.cs: -------------------------------------------------------------------------------- 1 | namespace thps2patch 2 | { 3 | class MainPatch 4 | { 5 | Options op; 6 | 7 | public MainPatch(Options options) 8 | { 9 | op = options; 10 | } 11 | 12 | LevelPatch lp; 13 | LevelPatch up; 14 | 15 | public void Patch() 16 | { 17 | lp = new LevelPatch(".\\patch\\levelpatch.ini", op.Game); 18 | up = new LevelPatch(".\\patch\\userpatch.ini", op.Game); 19 | 20 | Mem mem = new Mem(); 21 | 22 | bool foundTH2 = false; 23 | 24 | //loop until found THawk2 process 25 | while (!foundTH2) 26 | { 27 | try 28 | { 29 | mem = new Mem("THawk2"); 30 | foundTH2 = true; 31 | } 32 | catch 33 | { 34 | foundTH2 = false; 35 | } 36 | 37 | System.Threading.Thread.Sleep(100); 38 | } 39 | 40 | lp.Patch(op.ExeName); 41 | 42 | if (op.UserPatch) 43 | up.Patch(op.ExeName); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Patch/Mem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace thps2patch 8 | { 9 | class Mem 10 | { 11 | const int PROCESS_VM_READ = 0x0010; 12 | const int PROCESS_VM_MAGIC = 0x1F0FFF; 13 | 14 | const int PROCESS_VM_WRITE = 0x0020; 15 | const int PROCESS_VM_OPERATION = 0x0008; 16 | 17 | 18 | 19 | [DllImport("kernel32.dll")] 20 | public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProccessId); 21 | 22 | [DllImport("kernel32.dll")] 23 | public static extern bool ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead); 24 | 25 | [DllImport("Kernel32.dll")] 26 | static extern bool WriteProcessMemory(int hProcess, int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesWritten); 27 | 28 | private Process process; 29 | private IntPtr processHandle; 30 | 31 | bool ready = false; 32 | 33 | public Mem() 34 | { 35 | } 36 | 37 | public Mem(string pn) 38 | { 39 | try 40 | { 41 | process = Process.GetProcessesByName(pn)[0]; 42 | ready = true; 43 | } 44 | catch 45 | { 46 | ready = false; 47 | } 48 | } 49 | 50 | 51 | public float ReadFloat(int where) 52 | { 53 | IntPtr processHandle = OpenProcess(PROCESS_VM_READ, false, process.Id); 54 | 55 | int bytesRead = 4; 56 | byte[] buffer = new byte[4]; 57 | 58 | ReadProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesRead); 59 | 60 | return BitConverter.ToSingle(buffer, 0); 61 | } 62 | 63 | public int ReadInt(int where) 64 | { 65 | IntPtr processHandle = OpenProcess(PROCESS_VM_READ, false, process.Id); 66 | 67 | int bytesRead = 4; 68 | byte[] buffer = new byte[4]; 69 | 70 | ReadProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesRead); 71 | 72 | return BitConverter.ToInt32(buffer, 0); 73 | } 74 | 75 | public uint ReadUInt32(int where) 76 | { 77 | IntPtr processHandle = OpenProcess(PROCESS_VM_READ, false, process.Id); 78 | 79 | int bytesRead = 4; 80 | byte[] buffer = new byte[4]; 81 | 82 | ReadProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesRead); 83 | 84 | return BitConverter.ToUInt32(buffer, 0); 85 | } 86 | 87 | public byte ReadByte(int where) 88 | { 89 | IntPtr processHandle = OpenProcess(PROCESS_VM_READ, false, process.Id); 90 | 91 | int bytesRead = 1; 92 | byte[] buffer = new byte[1]; 93 | 94 | ReadProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesRead); 95 | 96 | return buffer[0]; 97 | } 98 | 99 | public void WriteArray(int where, byte[] wr) 100 | { 101 | IntPtr processHandle = OpenProcess(PROCESS_VM_MAGIC, false, process.Id); 102 | 103 | int bytesWritten = wr.Length; 104 | byte[] buffer = wr; 105 | 106 | WriteProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesWritten); 107 | } 108 | 109 | public void WriteFloat(int where, float wr) 110 | { 111 | IntPtr processHandle = OpenProcess(PROCESS_VM_MAGIC, false, process.Id); 112 | 113 | int bytesWritten = 4; 114 | byte[] buffer = BitConverter.GetBytes(wr); 115 | 116 | WriteProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesWritten); 117 | } 118 | 119 | public void WriteByte(int where, byte wr) 120 | { 121 | IntPtr processHandle = OpenProcess(PROCESS_VM_MAGIC, false, process.Id); 122 | 123 | int bytesWritten = 1; 124 | byte[] buffer = new byte[1]; 125 | buffer[0] = wr; 126 | 127 | WriteProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesWritten); 128 | } 129 | 130 | public void WriteInt(int where, int wr) 131 | { 132 | IntPtr processHandle = OpenProcess(PROCESS_VM_MAGIC, false, process.Id); 133 | 134 | int bytesWritten = 4; 135 | byte[] buffer = BitConverter.GetBytes(wr); 136 | 137 | WriteProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesWritten); 138 | } 139 | 140 | public void WriteShort(int where, short wr) 141 | { 142 | IntPtr processHandle = OpenProcess(PROCESS_VM_MAGIC, false, process.Id); 143 | 144 | int bytesWritten = 2; 145 | byte[] buffer = BitConverter.GetBytes(wr); 146 | 147 | WriteProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesWritten); 148 | } 149 | 150 | public void WriteUInt32(int where, uint wr) 151 | { 152 | IntPtr processHandle = OpenProcess(PROCESS_VM_MAGIC, false, process.Id); 153 | 154 | int bytesWritten = 4; 155 | byte[] buffer = BitConverter.GetBytes(wr); 156 | 157 | WriteProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesWritten); 158 | } 159 | 160 | public string ReadString(int where, int count) 161 | { 162 | IntPtr processHandle = OpenProcess(PROCESS_VM_READ, false, process.Id); 163 | 164 | int bytesRead = count; 165 | byte[] buffer = new byte[count]; 166 | 167 | ReadProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesRead); 168 | 169 | return System.Text.Encoding.Default.GetString(buffer); 170 | } 171 | 172 | public string ReadString(int where) 173 | { 174 | List<byte> str = new List<byte>(); 175 | 176 | int offset = where; 177 | byte x; 178 | 179 | do 180 | { 181 | x = ReadByte(offset); 182 | if (x != 0x0) str.Add(x); 183 | offset++; 184 | } 185 | while (x != 0x0); 186 | 187 | return System.Text.Encoding.Default.GetString(str.ToArray()); 188 | } 189 | 190 | public void WriteString(int where, string wr) 191 | { 192 | IntPtr processHandle = OpenProcess(PROCESS_VM_MAGIC, false, process.Id); 193 | 194 | byte[] buffer = System.Text.Encoding.Default.GetBytes(wr); 195 | int bytesWritten = buffer.Length; 196 | 197 | WriteProcessMemory((int)processHandle, where, buffer, buffer.Length, ref bytesWritten); 198 | } 199 | 200 | public void WriteFile(int where, string fn) 201 | { 202 | byte[] buf = File.ReadAllBytes(fn); 203 | WriteArray(where, buf); 204 | } 205 | 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Patch/Resolutions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace thps2patch 8 | { 9 | public partial class Options 10 | { 11 | /// <summary> 12 | /// A predefined list of resolutions to use in the dropdown list. 13 | /// </summary> 14 | Dictionary<string, string> _resolutions = new Dictionary<string, string> 15 | { 16 | {"320x240", "4:3"}, 17 | {"640x480", "4:3"}, 18 | {"800x600", "4:3"}, 19 | {"1024x768", "4:3"}, 20 | {"1440x1080", "4:3" }, 21 | {"1600x1200", "4:3"}, 22 | {"2048x1536", "4:3"}, 23 | 24 | { "1280x1024", "5:4" }, 25 | { "1350x1080", "5:4" }, 26 | 27 | {"1280x720", "16:9"}, 28 | {"1366x768", "16:9" }, 29 | {"1600x900", "16:9"}, 30 | {"1920x1080", "16:9"}, 31 | {"2048x1152", "16:9"} 32 | 33 | //{"2560x1440", "16:9"} // 2048x2048 is ddraw limit 34 | }; 35 | } 36 | } -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Forms; 4 | 5 | namespace th2patchlauncher 6 | { 7 | static class Program 8 | { 9 | [STAThread] 10 | static void Main(string[] args) 11 | { 12 | //in case we're gonna parse floats 13 | var ci = (CultureInfo)CultureInfo.CurrentCulture.Clone(); 14 | ci.NumberFormat.NumberDecimalSeparator = "."; 15 | CultureInfo.CurrentCulture = ci; 16 | 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | 20 | //create invisible for our awesome -F bypass flag 21 | var launcher = new LauncherForm() { Visible = false }; 22 | Application.Run(launcher); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("th2patchlauncher")] 5 | [assembly: AssemblyDescription("THPS2 Cumulative Patch launcher")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("")] 8 | [assembly: AssemblyProduct("THPS2 Cumulative Patch launcher")] 9 | [assembly: AssemblyCopyright("dcxdemo")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | [assembly: ComVisible(false)] 13 | [assembly: Guid("6dfe35a8-9885-463f-bce3-f5cde55db571")] 14 | [assembly: AssemblyVersion("1.0.0.0")] 15 | [assembly: AssemblyFileVersion("1.0.0.0")] 16 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // <auto-generated> 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // </auto-generated> 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace th2patchlauncher.Properties { 12 | using System; 13 | 14 | 15 | /// <summary> 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// </summary> 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// <summary> 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// </summary> 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("th2patchlauncher.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// <summary> 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// </summary> 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// <summary> 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// </summary> 66 | internal static System.Drawing.Bitmap th22logo { 67 | get { 68 | object obj = ResourceManager.GetObject("th22logo", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <root> 3 | <!-- 4 | Microsoft ResX Schema 5 | 6 | Version 2.0 7 | 8 | The primary goals of this format is to allow a simple XML format 9 | that is mostly human readable. The generation and parsing of the 10 | various data types are done through the TypeConverter classes 11 | associated with the data types. 12 | 13 | Example: 14 | 15 | ... ado.net/XML headers & schema ... 16 | <resheader name="resmimetype">text/microsoft-resx</resheader> 17 | <resheader name="version">2.0</resheader> 18 | <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> 19 | <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> 20 | <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> 21 | <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> 22 | <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> 23 | <value>[base64 mime encoded serialized .NET Framework object]</value> 24 | </data> 25 | <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> 26 | <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> 27 | <comment>This is a comment</comment> 28 | </data> 29 | 30 | There are any number of "resheader" rows that contain simple 31 | name/value pairs. 32 | 33 | Each data row contains a name, and value. The row also contains a 34 | type or mimetype. Type corresponds to a .NET class that support 35 | text/value conversion through the TypeConverter architecture. 36 | Classes that don't support this are serialized and stored with the 37 | mimetype set. 38 | 39 | The mimetype is used for serialized objects, and tells the 40 | ResXResourceReader how to depersist the object. This is currently not 41 | extensible. For a given mimetype the value must be set accordingly: 42 | 43 | Note - application/x-microsoft.net.object.binary.base64 is the format 44 | that the ResXResourceWriter will generate, however the reader can 45 | read any of the formats listed below. 46 | 47 | mimetype: application/x-microsoft.net.object.binary.base64 48 | value : The object must be serialized with 49 | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter 50 | : and then encoded with base64 encoding. 51 | 52 | mimetype: application/x-microsoft.net.object.soap.base64 53 | value : The object must be serialized with 54 | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter 55 | : and then encoded with base64 encoding. 56 | 57 | mimetype: application/x-microsoft.net.object.bytearray.base64 58 | value : The object must be serialized into a byte array 59 | : using a System.ComponentModel.TypeConverter 60 | : and then encoded with base64 encoding. 61 | --> 62 | <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> 63 | <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> 64 | <xsd:element name="root" msdata:IsDataSet="true"> 65 | <xsd:complexType> 66 | <xsd:choice maxOccurs="unbounded"> 67 | <xsd:element name="metadata"> 68 | <xsd:complexType> 69 | <xsd:sequence> 70 | <xsd:element name="value" type="xsd:string" minOccurs="0" /> 71 | </xsd:sequence> 72 | <xsd:attribute name="name" use="required" type="xsd:string" /> 73 | <xsd:attribute name="type" type="xsd:string" /> 74 | <xsd:attribute name="mimetype" type="xsd:string" /> 75 | <xsd:attribute ref="xml:space" /> 76 | </xsd:complexType> 77 | </xsd:element> 78 | <xsd:element name="assembly"> 79 | <xsd:complexType> 80 | <xsd:attribute name="alias" type="xsd:string" /> 81 | <xsd:attribute name="name" type="xsd:string" /> 82 | </xsd:complexType> 83 | </xsd:element> 84 | <xsd:element name="data"> 85 | <xsd:complexType> 86 | <xsd:sequence> 87 | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> 88 | <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> 89 | </xsd:sequence> 90 | <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> 91 | <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> 92 | <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> 93 | <xsd:attribute ref="xml:space" /> 94 | </xsd:complexType> 95 | </xsd:element> 96 | <xsd:element name="resheader"> 97 | <xsd:complexType> 98 | <xsd:sequence> 99 | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> 100 | </xsd:sequence> 101 | <xsd:attribute name="name" type="xsd:string" use="required" /> 102 | </xsd:complexType> 103 | </xsd:element> 104 | </xsd:choice> 105 | </xsd:complexType> 106 | </xsd:element> 107 | </xsd:schema> 108 | <resheader name="resmimetype"> 109 | <value>text/microsoft-resx</value> 110 | </resheader> 111 | <resheader name="version"> 112 | <value>2.0</value> 113 | </resheader> 114 | <resheader name="reader"> 115 | <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 116 | </resheader> 117 | <resheader name="writer"> 118 | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 | </resheader> 120 | <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 121 | <data name="th22logo" type="System.Resources.ResXFileRef, System.Windows.Forms"> 122 | <value>..\Resources\th22logo.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 123 | </data> 124 | 125 | </root> -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // <auto-generated> 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // </auto-generated> 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace th2patchlauncher.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | <?xml version='1.0' encoding='utf-8'?> 2 | <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> 3 | <Profiles> 4 | <Profile Name="(Default)" /> 5 | </Profiles> 6 | <Settings /> 7 | </SettingsFile> 8 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Resources/th2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/Resources/th2.ico -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Resources/th22logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/Resources/th22logo.jpg -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/Resources/th2_optim.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/Resources/th2_optim.ico -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/app.config: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <configuration> 3 | <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration> 4 | -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/optim/icon0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/optim/icon0.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/optim/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/optim/icon1.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/optim/icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/optim/icon2.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/optim/icon3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/optim/icon3.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/optim/icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/optim/icon4.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/optim/icon5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/optim/icon5.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/optim/output.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/optim/output.ico -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/source/icon0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/source/icon0.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/source/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/source/icon1.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/source/icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/source/icon2.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/source/icon3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/source/icon3.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/source/icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/source/icon4.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/icon/source/icon5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DCxDemo/THPS2-Cumulative-Patch/10c5c834550d5a84905b9d3418053b28777d51f6/th2patchlauncher/th2patchlauncher/icon/source/icon5.png -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/packages.config: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <packages> 3 | <package id="ini-parser" version="2.5.2" targetFramework="net48" /> 4 | </packages> -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/th2patchlauncher.csproj: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 3 | <PropertyGroup> 4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5 | <Platform Condition=" '$(Platform)' == '' ">x86</Platform> 6 | <ProductVersion>8.0.30703</ProductVersion> 7 | <SchemaVersion>2.0</SchemaVersion> 8 | <ProjectGuid>{B4D73D3D-7932-406A-9DC7-2CE490C8B1EF}</ProjectGuid> 9 | <OutputType>WinExe</OutputType> 10 | <AppDesignerFolder>Properties</AppDesignerFolder> 11 | <RootNamespace>th2patchlauncher</RootNamespace> 12 | <AssemblyName>th2patchlauncher</AssemblyName> 13 | <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> 14 | <TargetFrameworkProfile> 15 | </TargetFrameworkProfile> 16 | <FileAlignment>512</FileAlignment> 17 | <IsWebBootstrapper>false</IsWebBootstrapper> 18 | <PublishUrl>publish\</PublishUrl> 19 | <Install>true</Install> 20 | <InstallFrom>Disk</InstallFrom> 21 | <UpdateEnabled>false</UpdateEnabled> 22 | <UpdateMode>Foreground</UpdateMode> 23 | <UpdateInterval>7</UpdateInterval> 24 | <UpdateIntervalUnits>Days</UpdateIntervalUnits> 25 | <UpdatePeriodically>false</UpdatePeriodically> 26 | <UpdateRequired>false</UpdateRequired> 27 | <MapFileExtensions>true</MapFileExtensions> 28 | <ApplicationRevision>0</ApplicationRevision> 29 | <ApplicationVersion>1.0.0.%2a</ApplicationVersion> 30 | <UseApplicationTrust>false</UseApplicationTrust> 31 | <BootstrapperEnabled>true</BootstrapperEnabled> 32 | </PropertyGroup> 33 | <PropertyGroup> 34 | <ApplicationIcon>Resources\th2_optim.ico</ApplicationIcon> 35 | </PropertyGroup> 36 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> 37 | <DebugSymbols>true</DebugSymbols> 38 | <OutputPath>bin\Debug\</OutputPath> 39 | <DefineConstants>DEBUG;TRACE</DefineConstants> 40 | <DebugType>pdbonly</DebugType> 41 | <PlatformTarget>AnyCPU</PlatformTarget> 42 | <LangVersion>7.3</LangVersion> 43 | <ErrorReport>prompt</ErrorReport> 44 | </PropertyGroup> 45 | <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> 46 | <OutputPath>bin\Release\</OutputPath> 47 | <DefineConstants>TRACE</DefineConstants> 48 | <Optimize>true</Optimize> 49 | <DebugType>pdbonly</DebugType> 50 | <PlatformTarget>AnyCPU</PlatformTarget> 51 | <LangVersion>7.3</LangVersion> 52 | <ErrorReport>prompt</ErrorReport> 53 | </PropertyGroup> 54 | <PropertyGroup> 55 | <StartupObject>th2patchlauncher.Program</StartupObject> 56 | </PropertyGroup> 57 | <ItemGroup> 58 | <Reference Include="INIFileParser, Version=2.5.2.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL"> 59 | <HintPath>..\packages\ini-parser.2.5.2\lib\net20\INIFileParser.dll</HintPath> 60 | </Reference> 61 | <Reference Include="System" /> 62 | <Reference Include="System.Data" /> 63 | <Reference Include="System.Drawing" /> 64 | <Reference Include="System.Windows.Forms" /> 65 | <Reference Include="System.Xml" /> 66 | </ItemGroup> 67 | <ItemGroup> 68 | <Compile Include="ErrorMsg.cs" /> 69 | <Compile Include="LauncherForm.cs"> 70 | <SubType>Form</SubType> 71 | </Compile> 72 | <Compile Include="LauncherForm.Designer.cs"> 73 | <DependentUpon>LauncherForm.cs</DependentUpon> 74 | </Compile> 75 | <Compile Include="Patch\Helpers.cs" /> 76 | <Compile Include="Patch\LevelPatch.cs" /> 77 | <Compile Include="Patch\MainPatch.cs" /> 78 | <Compile Include="Patch\Mem.cs" /> 79 | <Compile Include="Patch\Options.cs" /> 80 | <Compile Include="Patch\Resolutions.cs" /> 81 | <Compile Include="Program.cs" /> 82 | <Compile Include="Properties\AssemblyInfo.cs" /> 83 | <EmbeddedResource Include="LauncherForm.resx"> 84 | <DependentUpon>LauncherForm.cs</DependentUpon> 85 | <SubType>Designer</SubType> 86 | </EmbeddedResource> 87 | <EmbeddedResource Include="Properties\Resources.resx"> 88 | <Generator>ResXFileCodeGenerator</Generator> 89 | <SubType>Designer</SubType> 90 | <LastGenOutput>Resources.Designer.cs</LastGenOutput> 91 | </EmbeddedResource> 92 | <None Include="app.config" /> 93 | <None Include="packages.config" /> 94 | <None Include="Properties\Settings.settings"> 95 | <Generator>SettingsSingleFileGenerator</Generator> 96 | <LastGenOutput>Settings.Designer.cs</LastGenOutput> 97 | </None> 98 | <Compile Include="Properties\Resources.Designer.cs"> 99 | <AutoGen>True</AutoGen> 100 | <DesignTime>True</DesignTime> 101 | <DependentUpon>Resources.resx</DependentUpon> 102 | </Compile> 103 | <Compile Include="Properties\Settings.Designer.cs"> 104 | <AutoGen>True</AutoGen> 105 | <DependentUpon>Settings.settings</DependentUpon> 106 | <DesignTimeSharedInput>True</DesignTimeSharedInput> 107 | </Compile> 108 | </ItemGroup> 109 | <ItemGroup> 110 | <Content Include="Resources\th22logo.jpg" /> 111 | <Content Include="Resources\th2.ico" /> 112 | <Content Include="Resources\th2_optim.ico" /> 113 | </ItemGroup> 114 | <ItemGroup> 115 | <BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client"> 116 | <Visible>False</Visible> 117 | <ProductName>Клиентский профиль Microsoft .NET Framework 4 %28x86 и x64%29</ProductName> 118 | <Install>true</Install> 119 | </BootstrapperPackage> 120 | <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> 121 | <Visible>False</Visible> 122 | <ProductName>Клиентский профиль .NET Framework 3.5 SP1</ProductName> 123 | <Install>false</Install> 124 | </BootstrapperPackage> 125 | <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> 126 | <Visible>False</Visible> 127 | <ProductName>.NET Framework 3.5 SP1</ProductName> 128 | <Install>false</Install> 129 | </BootstrapperPackage> 130 | <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> 131 | <Visible>False</Visible> 132 | <ProductName>Установщик Windows 3.1</ProductName> 133 | <Install>true</Install> 134 | </BootstrapperPackage> 135 | </ItemGroup> 136 | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 137 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 138 | Other similar extension points exist, see Microsoft.Common.targets. 139 | <Target Name="BeforeBuild"> 140 | </Target> 141 | <Target Name="AfterBuild"> 142 | </Target> 143 | --> 144 | </Project> -------------------------------------------------------------------------------- /th2patchlauncher/th2patchlauncher/th2patchlauncher.csproj.user: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 3 | <PropertyGroup> 4 | <PublishUrlHistory>publish\</PublishUrlHistory> 5 | <InstallUrlHistory /> 6 | <SupportUrlHistory /> 7 | <UpdateUrlHistory /> 8 | <BootstrapperUrlHistory /> 9 | <ErrorReportUrlHistory /> 10 | <VerifyUploadedFiles>false</VerifyUploadedFiles> 11 | </PropertyGroup> 12 | </Project> --------------------------------------------------------------------------------