├── .editorconfig ├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── 01-crash-report.yml │ ├── 02-bug-report.yml │ ├── 03-feature-request.yml │ └── config.yml ├── .gitignore ├── .gitmodules ├── BuildScript.ini ├── CHANGES.md ├── README.md ├── SADXModLoader.sln ├── SADXModLoader ├── AutoMipmap.cpp ├── AutoMipmap.h ├── BasicWeights.cpp ├── BasicWeights.h ├── ChunkSpecularFix.cpp ├── ChunkSpecularFix.h ├── CrashDump.cpp ├── CrashDump.h ├── CrashGuard.cpp ├── CrashGuard.h ├── DDS.h ├── DLLData.cpp ├── DLLData.h ├── DisableRoundedCorners.cpp ├── DisableRoundedCorners.h ├── DreamPad.cpp ├── DreamPad.h ├── EXEData.cpp ├── EXEData.h ├── Events.cpp ├── Events.h ├── ExtendedSaveSupport.cpp ├── ExtendedSaveSupport.h ├── FileMap.cpp ├── FileMap.hpp ├── FileReplacement.cpp ├── FileReplacement.h ├── FixFOV.cpp ├── FixFOV.h ├── Gbix.cpp ├── Gbix.h ├── HelperFunctions.cpp ├── InterpolationFixes.cpp ├── InterpolationFixes.h ├── KeyboardMouse.cpp ├── KeyboardMouse.h ├── MaterialColorFixes.cpp ├── MaterialColorFixes.h ├── MediaFns.cpp ├── MediaFns.hpp ├── MinorGamePatches.cpp ├── MinorGamePatches.h ├── NodeLimit.cpp ├── NodeLimit.h ├── SADXModLoader.rc ├── SADXModLoader.vcxproj ├── SADXModLoader.vcxproj.filters ├── SDL.h ├── SDL2.cpp ├── SkyChaseFixes.cpp ├── SkyChaseFixes.h ├── TextureReplacement.cpp ├── TextureReplacement.h ├── VoiceDuration.h ├── XInputFix.cpp ├── XInputFix.h ├── backend.cpp ├── backend.h ├── bgscale.cpp ├── bgscale.h ├── config.cpp ├── config.h ├── cpp.hint ├── direct3d.cpp ├── direct3d.h ├── dllmain.cpp ├── dpi.cpp ├── dpi.h ├── git.h ├── gvm.cpp ├── gvm.h ├── hudscale.cpp ├── hudscale.h ├── include │ ├── AudioFile.h │ ├── FunctionHook.h │ ├── MemAccess.h │ ├── SADXEnums.h │ ├── SADXEnumsNew.h │ ├── SADXFunctions.h │ ├── SADXFunctionsNew.h │ ├── SADXModInfo.h │ ├── SADXModLoader.h │ ├── SADXModelsNew.h │ ├── SADXMotionsNew.h │ ├── SADXStructs.h │ ├── SADXStructsNew.h │ ├── SADXVariables.h │ ├── SADXVariablesNew.h │ ├── ScaleInfo.h │ ├── UsercallFunctionHandler.h │ ├── WeightInfo.h │ ├── d3d8types.h │ ├── ninja.h │ └── njdef.h ├── input.cpp ├── input.h ├── json.hpp ├── jvList.cpp ├── jvList.h ├── minmax.h ├── polybuff.cpp ├── polybuff.h ├── prs.cpp ├── prs.h ├── pvmx.cpp ├── pvmx.h ├── resource.h ├── rumble.cpp ├── rumble.h ├── sound.cpp ├── sound.h ├── stdafx.cpp ├── stdafx.h ├── targetver.h ├── testspawn.cpp ├── testspawn.h ├── typedefs.h ├── uiscale.cpp ├── uiscale.h ├── util.h ├── version.h ├── video.cpp ├── video.h ├── window.cpp └── window.h ├── appveyor.yml ├── data ├── Border_Default.png ├── Codes.lst └── Patches.json ├── doc ├── CodeList.xsd └── codes.md ├── extlib ├── ModLoaders │ └── SADXModLoader.dll ├── SDL2 │ ├── cmake │ │ ├── sdl2-config-version.cmake │ │ └── sdl2-config.cmake │ ├── include │ │ ├── SDL.h │ │ ├── SDL_assert.h │ │ ├── SDL_atomic.h │ │ ├── SDL_audio.h │ │ ├── SDL_bits.h │ │ ├── SDL_blendmode.h │ │ ├── SDL_clipboard.h │ │ ├── SDL_config.h │ │ ├── SDL_config.h.cmake │ │ ├── SDL_config.h.in │ │ ├── SDL_config_android.h │ │ ├── SDL_config_emscripten.h │ │ ├── SDL_config_iphoneos.h │ │ ├── SDL_config_macosx.h │ │ ├── SDL_config_minimal.h │ │ ├── SDL_config_ngage.h │ │ ├── SDL_config_os2.h │ │ ├── SDL_config_pandora.h │ │ ├── SDL_config_windows.h │ │ ├── SDL_config_wingdk.h │ │ ├── SDL_config_winrt.h │ │ ├── SDL_config_xbox.h │ │ ├── SDL_copying.h │ │ ├── SDL_cpuinfo.h │ │ ├── SDL_egl.h │ │ ├── SDL_endian.h │ │ ├── SDL_error.h │ │ ├── SDL_events.h │ │ ├── SDL_filesystem.h │ │ ├── SDL_gamecontroller.h │ │ ├── SDL_gesture.h │ │ ├── SDL_guid.h │ │ ├── SDL_haptic.h │ │ ├── SDL_hidapi.h │ │ ├── SDL_hints.h │ │ ├── SDL_joystick.h │ │ ├── SDL_keyboard.h │ │ ├── SDL_keycode.h │ │ ├── SDL_loadso.h │ │ ├── SDL_locale.h │ │ ├── SDL_log.h │ │ ├── SDL_main.h │ │ ├── SDL_messagebox.h │ │ ├── SDL_metal.h │ │ ├── SDL_misc.h │ │ ├── SDL_mouse.h │ │ ├── SDL_mutex.h │ │ ├── SDL_name.h │ │ ├── SDL_opengl.h │ │ ├── SDL_opengl_glext.h │ │ ├── SDL_opengles.h │ │ ├── SDL_opengles2.h │ │ ├── SDL_opengles2_gl2.h │ │ ├── SDL_opengles2_gl2ext.h │ │ ├── SDL_opengles2_gl2platform.h │ │ ├── SDL_opengles2_khrplatform.h │ │ ├── SDL_pixels.h │ │ ├── SDL_platform.h │ │ ├── SDL_power.h │ │ ├── SDL_quit.h │ │ ├── SDL_rect.h │ │ ├── SDL_render.h │ │ ├── SDL_revision.h │ │ ├── SDL_revision.h.cmake │ │ ├── SDL_rwops.h │ │ ├── SDL_scancode.h │ │ ├── SDL_sensor.h │ │ ├── SDL_shape.h │ │ ├── SDL_stdinc.h │ │ ├── SDL_surface.h │ │ ├── SDL_system.h │ │ ├── SDL_syswm.h │ │ ├── SDL_test.h │ │ ├── SDL_test_assert.h │ │ ├── SDL_test_common.h │ │ ├── SDL_test_compare.h │ │ ├── SDL_test_crc32.h │ │ ├── SDL_test_font.h │ │ ├── SDL_test_fuzzer.h │ │ ├── SDL_test_harness.h │ │ ├── SDL_test_images.h │ │ ├── SDL_test_log.h │ │ ├── SDL_test_md5.h │ │ ├── SDL_test_memory.h │ │ ├── SDL_test_random.h │ │ ├── SDL_thread.h │ │ ├── SDL_timer.h │ │ ├── SDL_touch.h │ │ ├── SDL_types.h │ │ ├── SDL_version.h │ │ ├── SDL_video.h │ │ ├── SDL_vulkan.h │ │ ├── begin_code.h │ │ └── close_code.h │ └── lib │ │ └── x86 │ │ ├── SDL2.dll │ │ ├── SDL2.lib │ │ ├── SDL2main.lib │ │ └── SDL2test.lib ├── bass │ ├── COPYING_BASS_VGMSTREAM │ ├── COPYING_VGMSTREAM │ ├── avcodec-vgmstream-59.dll │ ├── avformat-vgmstream-59.dll │ ├── avutil-vgmstream-57.dll │ ├── bass.dll │ ├── bass.h │ ├── bass.lib │ ├── bass_vgmstream.dll │ ├── bass_vgmstream.h │ ├── bass_vgmstream.lib │ ├── libmpg123-0.dll │ ├── libvorbis.dll │ └── swresample-vgmstream-4.dll ├── d3d8to11 │ ├── LICENSE.md │ ├── composite.hlsl │ ├── config.ini │ ├── d3d8to11.dll │ ├── d3d8to11.hlsl │ ├── include.hlsli │ └── shader.hlsl └── d3d8to9 │ ├── LICENSE.md │ └── d3d8.dll ├── git_version.sh ├── libmodutils ├── AnimationFile.cpp ├── AnimationFile.h ├── ArchiveX.cpp ├── ArchiveX.h ├── GameObject.cpp ├── GameObject.h ├── GoalRing.cpp ├── GoalRingModels.cpp ├── LandTableInfo.cpp ├── LandTableInfo.h ├── ModelInfo.cpp ├── ModelInfo.h ├── Trampoline.cpp ├── Trampoline.h ├── libmodutils.vcxproj ├── libmodutils.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h └── sadx_programming.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | [*.{cs,c,h,cpp,hpp}] 3 | indent_style=tab -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | git_version.sh text eol=lf 2 | 3 | # Auto detect text files and perform LF normalization 4 | * text=auto 5 | 6 | # Custom for Visual Studio 7 | *.cs diff=csharp 8 | 9 | # Standard to msysgit 10 | *.doc diff=astextplain 11 | *.DOC diff=astextplain 12 | *.docx diff=astextplain 13 | *.DOCX diff=astextplain 14 | *.dot diff=astextplain 15 | *.DOT diff=astextplain 16 | *.pdf diff=astextplain 17 | *.PDF diff=astextplain 18 | *.rtf diff=astextplain 19 | *.RTF diff=astextplain 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/01-crash-report.yml: -------------------------------------------------------------------------------- 1 | name: Crash Report 2 | description: Report crashes with the SADX Mod Loader. 3 | title: "[Crash Report]: " 4 | labels: ["bug", "game crash"] 5 | body: 6 | - type: checkboxes 7 | id: checks 8 | attributes: 9 | label: Required Checks 10 | options: 11 | - label: I have ensured my Mod Loader is updated to the latest version before reporting this crash. 12 | required: true 13 | - label: I have ensured that I meet the [system requirements](https://github.com/X-Hax/sadx-mod-loader?tab=readme-ov-file#system-requirements) before submitting a report. 14 | required: true 15 | - label: I have followed the troubleshooting guides [from the SADX Modding Wiki](https://github.com/X-Hax/SADXModdingGuide/wiki/SADX-Troubleshooting-Guide) and the [SA Mod Manager wiki](https://github.com/X-Hax/SA-Mod-Manager/wiki/Troubleshooting-Guide) and they did not resolve my issue. 16 | required: true 17 | - type: textarea 18 | id: report 19 | attributes: 20 | label: Please provide information on the crash you have experienced below. 21 | description: Please include any and all steps taken before and during gameplay regarding the crash. 22 | validations: 23 | required: true 24 | - type: textarea 25 | id: info 26 | attributes: 27 | label: Crash Info 28 | description: Please provide your crash dump information below. You can drag and drop files to the text box to be uploaded. If you do not have crash dump information, please enable the feature in the SA Mod Manager and reproduce the crash. If no crash dump is created with them enabled, please include a list of mods and codes you have active in the texbox instead. 29 | validations: 30 | required: true 31 | - type: dropdown 32 | id: os 33 | attributes: 34 | label: Please select your operating system 35 | options: 36 | - Windows 37 | - Linux 38 | - MacOS 39 | validations: 40 | required: true 41 | - type: input 42 | id: osinfo 43 | attributes: 44 | label: OS Information 45 | description: Please provide the version of your OS. If you're using Linux or MacOS, please provide what Windows emulation layer it is that you're using. 46 | placeholder: e.g. Ubuntu 24.04.2, Wine 10.0 -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/02-bug-report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Report a bug with the SADX Mod Loader. 3 | title: "[Bug Report]: " 4 | labels: ["bug"] 5 | body: 6 | - type: checkboxes 7 | id: checks 8 | attributes: 9 | label: Required Checks 10 | options: 11 | - label: I have checked through existing issues and my bug has not been reported. 12 | required: true 13 | - label: I have ensured my Mod Loader is updated to the latest version before reporting this bug. 14 | required: true 15 | - label: I have ensured that I meet the [system requirements](https://github.com/X-Hax/sadx-mod-loader?tab=readme-ov-file#system-requirements) before reporting a bug. 16 | required: true 17 | - label: I have followed the troubleshooting guides [from the SADX Modding Wiki](https://github.com/X-Hax/SADXModdingGuide/wiki/SADX-Troubleshooting-Guide) and the [SA Mod Manager wiki](https://github.com/X-Hax/SA-Mod-Manager/wiki/Troubleshooting-Guide) and they did not resolve my issue. 18 | required: true 19 | - type: textarea 20 | id: report 21 | attributes: 22 | label: Please provide information on the bug you're experiencing below. 23 | description: Please include any and all steps taken to reach the bug you are experiencing. For mod developers, if confirmed to be an issue with the mod loader, please include the steps you used for creating your mod. 24 | validations: 25 | required: true 26 | - type: dropdown 27 | id: os 28 | attributes: 29 | label: Please select your operating system 30 | options: 31 | - Windows 32 | - Linux 33 | - MacOS 34 | validations: 35 | required: true 36 | - type: input 37 | id: osinfo 38 | attributes: 39 | label: OS Information 40 | description: Please provide the version of your OS. If you're using Linux or MacOS, please provide what translation layer you're using. 41 | placeholder: e.g. Ubuntu 24.04.2, Wine 10.0 -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/03-feature-request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Request a feature for the SADX Mod Loader 3 | title: "[Feature Request]: " 4 | labels: ["enhancement"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Feature Requests include new API capabilities, new codes, or new patches. 10 | - type: textarea 11 | id: request 12 | attributes: 13 | label: Please provide information regarding your request 14 | description: Please include what the purpose is of this request and why you believe it should be part of the Mod Loader. If this is a new API feature, please include how you believe it should function as well. 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: info 19 | attributes: 20 | label: Additional Information 21 | description: If there is anything additional would you like to provide, such as additional screenshots or files, please include them here. 22 | validations: 23 | required: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: SA Mod Manager 4 | url: https://github.com/X-Hax/SA-Mod-Manager 5 | about: Issues with the Mod Manager for SADX and SA2 should be reported here. 6 | - name: SA2 Mod Loader 7 | url: https://github.com/X-Hax/sa2-mod-loader 8 | about: Issues with the SA2 Mod Loader should be reported here. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # Roslyn cache directories 20 | *.ide/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | #NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | 30 | # Build Results of an ATL Project 31 | [Dd]ebugPS/ 32 | [Rr]eleasePS/ 33 | dlldata.c 34 | 35 | *_i.c 36 | *_p.c 37 | *_i.h 38 | *.ilk 39 | *.meta 40 | *.obj 41 | *.pch 42 | *.pdb 43 | *.pgc 44 | *.pgd 45 | *.rsp 46 | *.sbr 47 | *.tlb 48 | *.tli 49 | *.tlh 50 | *.tmp 51 | *.tmp_proj 52 | *.log 53 | *.vspscc 54 | *.vssscc 55 | .builds 56 | *.pidb 57 | *.svclog 58 | *.scc 59 | 60 | # Chutzpah Test files 61 | _Chutzpah* 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | _NCrunch_* 98 | .*crunch*.local.xml 99 | 100 | # MightyMoose 101 | *.mm.* 102 | AutoTest.Net/ 103 | 104 | # Web workbench (sass) 105 | .sass-cache/ 106 | 107 | # Installshield output folder 108 | [Ee]xpress/ 109 | 110 | # DocProject is a documentation generator add-in 111 | DocProject/buildhelp/ 112 | DocProject/Help/*.HxT 113 | DocProject/Help/*.HxC 114 | DocProject/Help/*.hhc 115 | DocProject/Help/*.hhk 116 | DocProject/Help/*.hhp 117 | DocProject/Help/Html2 118 | DocProject/Help/html 119 | 120 | # Click-Once directory 121 | publish/ 122 | 123 | # Publish Web Output 124 | *.[Pp]ublish.xml 125 | *.azurePubxml 126 | ## TODO: Comment the next line if you want to checkin your 127 | ## web deploy settings but do note that will include unencrypted 128 | ## passwords 129 | #*.pubxml 130 | 131 | # NuGet Packages Directory 132 | packages/* 133 | ## TODO: If the tool you use requires repositories.config 134 | ## uncomment the next line 135 | #!packages/repositories.config 136 | 137 | # Enable "build/" folder in the NuGet Packages folder since 138 | # NuGet packages use it for MSBuild targets. 139 | # This line needs to be after the ignore of the build folder 140 | # (and the packages folder if the line above has been uncommented) 141 | !packages/build/ 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | # LightSwitch generated files 187 | GeneratedArtifacts/ 188 | _Pvt_Extensions/ 189 | ModelManifest.xml 190 | 191 | SADXModLoader/git_version.h 192 | *.opendb 193 | /SADXModLoader.VC.db 194 | *.db 195 | *.db-shm 196 | *.db-wal 197 | *.ide 198 | /.vs 199 | *.svg 200 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "mod-loader-common"] 2 | path = mod-loader-common 3 | url = https://github.com/sonicretro/mod-loader-common.git 4 | -------------------------------------------------------------------------------- /BuildScript.ini: -------------------------------------------------------------------------------- 1 | programming=SADXModLoader\\include 2 | programming\\AnimationFile.cpp=libmodutils\\AnimationFile.cpp 3 | programming\\AnimationFile.h=libmodutils\\AnimationFile.h 4 | programming\\ArchiveX.cpp=libmodutils\\ArchiveX.cpp 5 | programming\\ArchiveX.h=libmodutils\\ArchiveX.h 6 | programming\\GameObject.cpp=libmodutils\\GameObject.cpp 7 | programming\\GameObject.h=libmodutils\\GameObject.h 8 | programming\\GoalRing.cpp=libmodutils\\GoalRing.cpp 9 | programming\\GoalRingModels.cpp=libmodutils\\GoalRingModels.cpp 10 | programming\\LandTableInfo.cpp=libmodutils\\LandTableInfo.cpp 11 | programming\\LandTableInfo.h=libmodutils\\LandTableInfo.h 12 | programming\\ModelInfo.cpp=libmodutils\\ModelInfo.cpp 13 | programming\\ModelInfo.h=libmodutils\\ModelInfo.h 14 | programming\\Trampoline.cpp=libmodutils\\Trampoline.cpp 15 | programming\\Trampoline.h=libmodutils\\Trampoline.h 16 | programming\\IniFile.cpp=mod-loader-common\\ModLoaderCommon\\IniFile.cpp 17 | programming\\IniFile.hpp=mod-loader-common\\ModLoaderCommon\\IniFile.hpp 18 | programming\\TextConv.cpp=mod-loader-common\\ModLoaderCommon\\TextConv.cpp 19 | programming\\TextConv.hpp=mod-loader-common\\ModLoaderCommon\\TextConv.hpp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sonic Adventure DX PC Mod Loader 2 | 3 | If you need any help, check the [SADX Modding wiki.](https://github.com/X-Hax/SADXModdingGuide/wiki/SADX-Troubleshooting-Guide). 4 | 5 | ## System Requirements 6 | 7 | To use SADX Mod Loader, you must have: 8 | * Sonic Adventure DX PC, 2004 version (US release) 9 | * Windows 7 or later 10 | * [Visual C++ 2022 runtime (x86)](https://aka.ms/vs/17/release/vc_redist.x86.exe) 11 | 12 | To manage mods and edit settings, you also need the following: 13 | * [SA Mod Manager](https://github.com/X-Hax/SA-Mod-Manager) 14 | * .NET 8.0 Desktop runtime 15 | 16 | ## License 17 | 18 | DISCLAIMER: 19 | Any and all content presented in this repository is presented for 20 | informational and educational purposes only. Commercial usage is 21 | expressly prohibited. X-Hax claims no ownership of any code 22 | in these repositories. You assume any and all responsibility for 23 | using this content responsibly. X-Hax claims no responsibility 24 | or warranty. 25 | 26 | ## Trademarks 27 | 28 | SEGA, Sonic, Sonic the Hedgehog, and Sonic Adventure DX are either 29 | trademarks or registered trademarks of SEGA of America, Inc. 30 | -------------------------------------------------------------------------------- /SADXModLoader.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33213.308 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmodutils", "libmodutils\libmodutils.vcxproj", "{90CF4AD9-6603-458F-8E3F-E99C0818E43D}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModLoaderCommon", "mod-loader-common\ModLoaderCommon\ModLoaderCommon.vcxproj", "{EC0293F5-4BCF-46B2-8133-18CAEA141C5B}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SADXModLoader", "SADXModLoader\SADXModLoader.vcxproj", "{B537B54A-67A7-4CD8-9679-457E498E592F}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | {EC0293F5-4BCF-46B2-8133-18CAEA141C5B} = {EC0293F5-4BCF-46B2-8133-18CAEA141C5B} 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|x86 = Debug|x86 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {90CF4AD9-6603-458F-8E3F-E99C0818E43D}.Debug|x86.ActiveCfg = Debug|Win32 22 | {90CF4AD9-6603-458F-8E3F-E99C0818E43D}.Debug|x86.Build.0 = Debug|Win32 23 | {90CF4AD9-6603-458F-8E3F-E99C0818E43D}.Release|x86.ActiveCfg = Release|Win32 24 | {90CF4AD9-6603-458F-8E3F-E99C0818E43D}.Release|x86.Build.0 = Release|Win32 25 | {EC0293F5-4BCF-46B2-8133-18CAEA141C5B}.Debug|x86.ActiveCfg = Debug|Win32 26 | {EC0293F5-4BCF-46B2-8133-18CAEA141C5B}.Debug|x86.Build.0 = Debug|Win32 27 | {EC0293F5-4BCF-46B2-8133-18CAEA141C5B}.Release|x86.ActiveCfg = Release|Win32 28 | {EC0293F5-4BCF-46B2-8133-18CAEA141C5B}.Release|x86.Build.0 = Release|Win32 29 | {B537B54A-67A7-4CD8-9679-457E498E592F}.Debug|x86.ActiveCfg = Debug|Win32 30 | {B537B54A-67A7-4CD8-9679-457E498E592F}.Debug|x86.Build.0 = Debug|Win32 31 | {B537B54A-67A7-4CD8-9679-457E498E592F}.Release|x86.ActiveCfg = Release|Win32 32 | {B537B54A-67A7-4CD8-9679-457E498E592F}.Release|x86.Build.0 = Release|Win32 33 | EndGlobalSection 34 | GlobalSection(SolutionProperties) = preSolution 35 | HideSolutionNode = FALSE 36 | EndGlobalSection 37 | GlobalSection(ExtensibilityGlobals) = postSolution 38 | SolutionGuid = {463403A3-8B1A-4984-AE81-55B84168C953} 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /SADXModLoader/AutoMipmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mipmap 6 | { 7 | void enable_auto_mipmaps(); 8 | bool is_blacklisted_pvm(const char* name); 9 | bool is_blacklisted_pvr(const char* name); 10 | bool is_blacklisted_gbix(Uint32 gbix); 11 | void blacklist_gbix(Uint32 gbix); 12 | void skip_mipmap(bool value); 13 | bool auto_mipmaps_enabled(); 14 | 15 | class MipGuard 16 | { 17 | bool current = false; 18 | bool last = false; 19 | 20 | public: 21 | explicit MipGuard(bool skip); 22 | ~MipGuard(); 23 | 24 | bool is_blacklisted() const 25 | { 26 | return current; 27 | } 28 | }; 29 | } -------------------------------------------------------------------------------- /SADXModLoader/BasicWeights.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "BasicWeights.h" 3 | #include "IniFile.hpp" 4 | 5 | using std::vector; 6 | 7 | void InitWeights(WeightInfo* weights, NJS_OBJECT* object) 8 | { 9 | for (int ni = 0; ni < weights->nodeCount; ++ni) 10 | { 11 | auto& node = weights->nodes[ni]; 12 | if (node.vertices_orig) 13 | delete[] node.vertices_orig; 14 | if (node.normals_orig) 15 | delete[] node.normals_orig; 16 | node.nodeIndex = GetNodeIndex(object, node.node); 17 | for (int wi = 0; wi < node.weightCount; ++wi) 18 | { 19 | auto& weight = node.weights[wi]; 20 | for (int vi = 0; vi < weight.vertexCount; ++vi) 21 | { 22 | auto& vert = weight.vertices[vi]; 23 | vert.nodeIndex = GetNodeIndex(object, vert.node); 24 | } 25 | } 26 | auto model = node.node->basicdxmodel; 27 | node.vertices_orig = new NJS_VECTOR[model->nbPoint]; 28 | memcpy(node.vertices_orig, model->points, model->nbPoint * sizeof(NJS_VECTOR)); 29 | node.normals_orig = new NJS_VECTOR[model->nbPoint]; 30 | memcpy(node.normals_orig, model->normals, model->nbPoint * sizeof(NJS_VECTOR)); 31 | } 32 | } 33 | 34 | void ApplyWeights(WeightInfo* weights, NJS_ACTION* action, float frame) 35 | { 36 | CalcMMMatrix( 37 | nj_unit_matrix_, 38 | action, 39 | frame, 40 | action->object->countnodes(), 41 | 0); 42 | NJS_MATRIX basemat, matrix; 43 | NJS_VECTOR tmpvert, tmpnorm, vd; 44 | for (int ni = 0; ni < weights->nodeCount; ++ni) 45 | { 46 | auto& node = weights->nodes[ni]; 47 | if (node.nodeIndex == -1) 48 | { 49 | node.nodeIndex = GetNodeIndex(action->object, node.node); 50 | if (node.nodeIndex == -1) 51 | continue; 52 | } 53 | NJS_MODEL_SADX* model = node.node->basicdxmodel; 54 | memcpy(model->points, node.vertices_orig, model->nbPoint * sizeof(NJS_VECTOR)); 55 | memcpy(model->normals, node.normals_orig, model->nbPoint * sizeof(NJS_VECTOR)); 56 | SetInstancedMatrix(node.nodeIndex, basemat); 57 | njInvertMatrix(basemat); 58 | for (int wi = 0; wi < node.weightCount; ++wi) 59 | { 60 | auto& weight = node.weights[wi]; 61 | tmpvert = {}; 62 | tmpnorm = {}; 63 | for (int vi = 0; vi < weight.vertexCount; ++vi) 64 | { 65 | auto& vert = weight.vertices[vi]; 66 | if (vert.nodeIndex == -1) 67 | { 68 | vert.nodeIndex = GetNodeIndex(action->object, vert.node); 69 | if (vert.nodeIndex == -1) 70 | continue; 71 | } 72 | SetInstancedMatrix(vert.nodeIndex, matrix); 73 | NJS_MODEL_SADX* vm = vert.node->basicdxmodel; 74 | njCalcPoint(matrix, &vm->points[vert.vertex], &vd); 75 | tmpvert.x += vd.x * vert.weight; 76 | tmpvert.y += vd.y * vert.weight; 77 | tmpvert.z += vd.z * vert.weight; 78 | njCalcVector(matrix, &vm->normals[vert.vertex], &vd); 79 | tmpnorm.x += vd.x * vert.weight; 80 | tmpnorm.y += vd.y * vert.weight; 81 | tmpnorm.z += vd.z * vert.weight; 82 | } 83 | njCalcPoint(basemat, &tmpvert, &model->points[weight.index]); 84 | njCalcVector(basemat, &tmpnorm, &model->normals[weight.index]); 85 | } 86 | } 87 | } 88 | 89 | void DeInitWeights(WeightInfo* weights, NJS_OBJECT* object) 90 | { 91 | for (int ni = 0; ni < weights->nodeCount; ++ni) 92 | { 93 | auto& node = weights->nodes[ni]; 94 | auto model = node.node->basicdxmodel; 95 | if (node.vertices_orig && node.normals_orig) 96 | { 97 | memcpy(model->points, node.vertices_orig, model->nbPoint * sizeof(NJS_VECTOR)); 98 | memcpy(model->normals, node.normals_orig, model->nbPoint * sizeof(NJS_VECTOR)); 99 | delete[] node.vertices_orig; 100 | delete[] node.normals_orig; 101 | } 102 | node.vertices_orig = nullptr; 103 | node.normals_orig = nullptr; 104 | } 105 | } -------------------------------------------------------------------------------- /SADXModLoader/BasicWeights.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ninja.h" 3 | 4 | void InitWeights(WeightInfo* weights, NJS_OBJECT* object); 5 | 6 | void ApplyWeights(WeightInfo* weights, NJS_ACTION* action, float frame); 7 | 8 | void DeInitWeights(WeightInfo* weights, NJS_OBJECT* object); -------------------------------------------------------------------------------- /SADXModLoader/ChunkSpecularFix.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SADXModLoader.h" 3 | #include "direct3d.h" 4 | #include "ChunkSpecularFix.h" 5 | 6 | void sub_78E3D0(unsigned int ambient, unsigned int diffuse, unsigned int specular, float exponent) 7 | { 8 | D3DMATERIAL8 v3; // [esp+8h] [ebp-44h] 9 | NJS_COLOR ambientColor; 10 | ambientColor.color = ambient; 11 | NJS_COLOR diffuseColor; 12 | diffuseColor.color = diffuse; 13 | NJS_COLOR specularColor; 14 | specularColor.color = specular; 15 | 16 | //v3.Diffuse.r = (double)(*(unsigned int *)&diffuse >> 24); 17 | v3.Diffuse.a = static_cast(diffuseColor.argb.a); 18 | v3.Diffuse.r = static_cast(diffuseColor.argb.r); 19 | v3.Diffuse.g = static_cast(diffuseColor.argb.g); 20 | v3.Diffuse.b = static_cast(diffuseColor.argb.b); 21 | 22 | v3.Ambient.a = static_cast(ambientColor.argb.a); 23 | v3.Ambient.r = static_cast(ambientColor.argb.r); 24 | v3.Ambient.g = static_cast(ambientColor.argb.g); 25 | v3.Ambient.b = static_cast(ambientColor.argb.b); 26 | 27 | v3.Specular.a = static_cast(specularColor.argb.a); 28 | v3.Specular.r = static_cast(specularColor.argb.r); 29 | v3.Specular.g = static_cast(specularColor.argb.g); 30 | v3.Specular.b = static_cast(specularColor.argb.b); 31 | 32 | // divide by 255 33 | v3.Ambient.a = v3.Ambient.a / 255.0f; 34 | v3.Ambient.r = v3.Ambient.r / 255.0f; 35 | v3.Ambient.g = v3.Ambient.g / 255.0f; 36 | v3.Ambient.b = v3.Ambient.b / 255.0f; 37 | 38 | v3.Diffuse.a = v3.Diffuse.a / 255.0f; 39 | v3.Diffuse.r = v3.Diffuse.r / 255.0f; 40 | v3.Diffuse.g = v3.Diffuse.g / 255.0f; 41 | v3.Diffuse.b = v3.Diffuse.b / 255.0f; 42 | 43 | v3.Specular.a = v3.Specular.a / 255.0f; 44 | v3.Specular.r = v3.Specular.r / 255.0f; 45 | v3.Specular.g = v3.Specular.g / 255.0f; 46 | v3.Specular.b = v3.Specular.b / 255.0f; 47 | 48 | v3.Power = exponent; 49 | 50 | v3.Emissive.a = 0.0f; 51 | v3.Emissive.r = 0.0f; 52 | v3.Emissive.g = 0.0f; 53 | v3.Emissive.b = 0.0f; 54 | 55 | if (_nj_control_3d_flag_ & NJD_CONTROL_3D_CONSTANT_MATERIAL) 56 | { 57 | v3.Diffuse.a = _nj_constant_material_.a; 58 | v3.Diffuse.r = _nj_constant_material_.r; 59 | v3.Diffuse.g = _nj_constant_material_.g; 60 | v3.Diffuse.b = _nj_constant_material_.b; 61 | } 62 | 63 | Direct3D_Device->SetMaterial(&v3); 64 | *(int*)0x389D8F4 = (int)diffuseColor.color; 65 | } 66 | 67 | void __cdecl sub_7913D0(int* a1) //Diffuse 68 | { 69 | sub_78E3D0(0xFFFFFFFF, *a1, 0, 0.0f); 70 | } 71 | 72 | void __cdecl sub_7913F0(unsigned int* a1) //Ambient 73 | { 74 | sub_78E3D0(*a1, 0xFFFFFFFF, 0, 0.0f); 75 | } 76 | 77 | void __cdecl sub_791410(int* a1) //DiffuseAmbient 78 | { 79 | sub_78E3D0(a1[1], *a1, 0, 0); 80 | } 81 | 82 | void __cdecl sub_791430(int* a1) //Specular 83 | { 84 | auto shrt = reinterpret_cast(a1); 85 | sub_78E3D0(0xFFFFFFFF, 0xFFFFFFFF, *a1, static_cast(shrt[1] >> 8)); 86 | } 87 | 88 | void __cdecl sub_791450(int* a1) //DiffuseSpecular 89 | { 90 | auto shrt = reinterpret_cast(&a1[1]); 91 | sub_78E3D0(0xFFFFFFFF, *a1, a1[1], static_cast(shrt[1] >> 8)); 92 | } 93 | 94 | void __cdecl sub_791470(int* a1) //AmbientSpecular 95 | { 96 | auto shrt = reinterpret_cast(&a1[1]); 97 | sub_78E3D0(*a1, 0xFFFFFFFF, a1[1], static_cast(shrt[1] >> 8)); 98 | } 99 | 100 | void __cdecl sub_791490(int* a1) //DiffuseAmbientSpecular 101 | { 102 | auto shrt = reinterpret_cast(&a1[2]); 103 | sub_78E3D0(a1[1], *a1, a1[2], static_cast(shrt[1] >> 8)); 104 | } 105 | 106 | void ChunkSpecularFix_Init() 107 | { 108 | WriteJump((void*)0x7913D0, sub_7913D0); 109 | WriteJump((void*)0x7913F0, sub_7913F0); 110 | WriteJump((void*)0x791410, sub_791410); 111 | WriteJump((void*)0x791430, sub_791430); 112 | WriteJump((void*)0x791450, sub_791450); 113 | WriteJump((void*)0x791470, sub_791470); 114 | WriteJump((void*)0x791490, sub_791490); 115 | } 116 | -------------------------------------------------------------------------------- /SADXModLoader/ChunkSpecularFix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ChunkSpecularFix_Init(); 4 | -------------------------------------------------------------------------------- /SADXModLoader/CrashDump.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void initCrashDump(); 4 | -------------------------------------------------------------------------------- /SADXModLoader/CrashGuard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void CrashGuard_Init(); 4 | void InitDefaultTexture(); 5 | extern NJS_TEXMEMLIST checker_memlist; -------------------------------------------------------------------------------- /SADXModLoader/DDS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //-------------------------------------------------------------------------------------- 3 | // DDS file structure definitions 4 | // 5 | // See DDS.h in the 'Texconv' sample and the 'DirectXTex' library 6 | //-------------------------------------------------------------------------------------- 7 | 8 | #include 9 | 10 | #pragma pack(push,1) 11 | 12 | const uint32_t DDS_MAGIC = 0x20534444; // "DDS " 13 | 14 | struct DDS_PIXELFORMAT 15 | { 16 | uint32_t size; 17 | uint32_t flags; 18 | uint32_t fourCC; 19 | uint32_t RGBBitCount; 20 | uint32_t RBitMask; 21 | uint32_t GBitMask; 22 | uint32_t BBitMask; 23 | uint32_t ABitMask; 24 | }; 25 | 26 | #define DDS_FOURCC 0x00000004 // DDPF_FOURCC 27 | #define DDS_RGB 0x00000040 // DDPF_RGB 28 | #define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE 29 | #define DDS_ALPHA 0x00000002 // DDPF_ALPHA 30 | 31 | #define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH 32 | 33 | #define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT 34 | #define DDS_WIDTH 0x00000004 // DDSD_WIDTH 35 | 36 | #define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX 37 | #define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX 38 | #define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY 39 | #define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY 40 | #define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ 41 | #define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ 42 | 43 | #define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\ 44 | DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\ 45 | DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ ) 46 | 47 | #define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP 48 | 49 | enum DDS_MISC_FLAGS2 50 | { 51 | DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L, 52 | }; 53 | 54 | struct DDS_HEADER 55 | { 56 | uint32_t size; 57 | uint32_t flags; 58 | uint32_t height; 59 | uint32_t width; 60 | uint32_t pitchOrLinearSize; 61 | uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags 62 | uint32_t mipMapCount; 63 | uint32_t reserved1[11]; 64 | DDS_PIXELFORMAT ddspf; 65 | uint32_t caps; 66 | uint32_t caps2; 67 | uint32_t caps3; 68 | uint32_t caps4; 69 | uint32_t reserved2; 70 | }; 71 | 72 | /* 73 | struct DDS_HEADER_DXT10 74 | { 75 | DXGI_FORMAT dxgiFormat; 76 | uint32_t resourceDimension; 77 | uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG 78 | uint32_t arraySize; 79 | uint32_t miscFlags2; 80 | }; 81 | */ 82 | 83 | #pragma pack(pop) 84 | 85 | -------------------------------------------------------------------------------- /SADXModLoader/DLLData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void ProcessDLLData(const wchar_t* filename, const std::wstring& mod_dir); 5 | 6 | void SetDLLHandle(const wchar_t* name, HMODULE handle); 7 | -------------------------------------------------------------------------------- /SADXModLoader/DisableRoundedCorners.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include "dwmapi.h" 4 | 5 | typedef enum { 6 | DWMWCP_DEFAULT = 0, 7 | DWMWCP_DONOTROUND = 1, 8 | DWMWCP_ROUND = 2, 9 | DWMWCP_ROUNDSMALL = 3 10 | } DWM_WINDOW_CORNER_PREFERENCE; 11 | 12 | HRESULT DwmSetWindowAttributeWrapper(HWND handle, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) 13 | { 14 | typedef HRESULT(WINAPI* DwmSetWindowAttributePtr)(HWND, DWORD, LPCVOID, DWORD); 15 | DwmSetWindowAttributePtr DwmSetWindowAttribute_Original; 16 | HMODULE dwmapiModule = GetModuleHandle(L"dwmapi.dll"); 17 | if (!dwmapiModule) 18 | return 0; 19 | DwmSetWindowAttribute_Original = (DwmSetWindowAttributePtr)GetProcAddress(dwmapiModule, "DwmSetWindowAttribute"); 20 | if (!DwmSetWindowAttribute_Original) 21 | return 0; 22 | return DwmSetWindowAttribute_Original(handle, dwAttribute, pvAttribute, cbAttribute); 23 | } 24 | 25 | static DWM_WINDOW_CORNER_PREFERENCE pref = DWMWCP_DONOTROUND; 26 | 27 | void DisableRoundedCorners(HWND handle) 28 | { 29 | HRESULT result = DwmSetWindowAttributeWrapper(handle, 33, &pref, sizeof(DWM_WINDOW_CORNER_PREFERENCE)); 30 | if (result != 0) 31 | PrintDebug("Disabling rounded corners: HRESULT %X\n", result); 32 | } -------------------------------------------------------------------------------- /SADXModLoader/DisableRoundedCorners.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "dwmapi.h" 3 | 4 | void DisableRoundedCorners(HWND handle); -------------------------------------------------------------------------------- /SADXModLoader/EXEData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void ProcessEXEData(const wchar_t* filename, const std::wstring& mod_dir); 5 | 6 | extern UINT CodepageJapanese; 7 | extern UINT CodepageEnglish; 8 | extern UINT CodepageFrench; 9 | extern UINT CodepageGerman; 10 | extern UINT CodepageSpanish; -------------------------------------------------------------------------------- /SADXModLoader/Events.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Trampoline.h" 3 | #include "Events.h" 4 | #include "input.h" 5 | #include "jvList.h" 6 | 7 | std::vector modInitEndEvents; 8 | std::vector modFrameEvents; 9 | std::vector modInputEvents; 10 | std::vector modControlEvents; 11 | std::vector modExitEvents; 12 | std::vector modCustomTextureLoadEvents; 13 | std::vector modRenderDeviceLost; 14 | std::vector modRenderDeviceReset; 15 | std::vector onRenderSceneEnd; 16 | std::vector onRenderSceneStart; 17 | std::vector modInitGameLoopEvents; 18 | 19 | Trampoline exitDetour(0x0064672F, 0x00646736, OnExit); 20 | 21 | /** 22 | * Registers an event to the specified event list. 23 | * @param eventList The event list to add to. 24 | * @param module The module for the mod DLL. 25 | * @param name The name of the exported function from the module (i.e OnFrame) 26 | */ 27 | void RegisterEvent(std::vector& eventList, HMODULE module, const char* name) 28 | { 29 | const auto modEvent = reinterpret_cast(GetProcAddress(module, name)); 30 | 31 | if (modEvent != nullptr) 32 | { 33 | eventList.push_back(modEvent); 34 | } 35 | } 36 | 37 | DataPointer(short, word_3B2C464, 0x3B2C464); 38 | 39 | void OnInput() 40 | { 41 | SDL2_OnInput(); 42 | RaiseEvents(modInputEvents); 43 | } 44 | 45 | void __declspec(naked) OnInput_MidJump() 46 | { 47 | __asm 48 | { 49 | inc word_3B2C464 50 | pop esi 51 | jmp OnInput 52 | } 53 | } 54 | 55 | void OnControl() 56 | { 57 | RaiseEvents(modControlEvents); 58 | } 59 | 60 | void __cdecl OnExit(UINT uExitCode, int a1, int a2) 61 | { 62 | RaiseEvents(modExitEvents); 63 | SDL2_OnExit(); 64 | FreeJVListIndices(); 65 | NonStaticFunctionPointer(void, original, (UINT, int, int), exitDetour.Target()); 66 | original(uExitCode, a1, a2); 67 | } 68 | -------------------------------------------------------------------------------- /SADXModLoader/Events.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SADXModLoader.h" 4 | #include 5 | 6 | using TextureLoadEvent = void(__cdecl *)(NJS_TEXMEMLIST*, const char*, Uint32); 7 | 8 | extern std::vector modInitEndEvents; 9 | extern std::vector modFrameEvents; 10 | extern std::vector modInputEvents; 11 | extern std::vector modControlEvents; 12 | extern std::vector modExitEvents; 13 | extern std::vector modCustomTextureLoadEvents; 14 | extern std::vector modRenderDeviceLost; 15 | extern std::vector modRenderDeviceReset; 16 | extern std::vector onRenderSceneEnd; 17 | extern std::vector onRenderSceneStart; 18 | extern std::vector modInitGameLoopEvents; 19 | 20 | /** 21 | * Calls all registered events in the specified event list. 22 | * @param eventList The list of events to trigger. 23 | */ 24 | inline void RaiseEvents(const std::vector& eventList) 25 | { 26 | for (auto &i : eventList) 27 | i(); 28 | } 29 | 30 | /** 31 | * Registers an event to the specified event list. 32 | * @param eventList The event list to add to. 33 | * @param module The module for the mod DLL. 34 | * @param name The name of the exported function from the module (i.e OnFrame) 35 | */ 36 | void RegisterEvent(std::vector& eventList, HMODULE module, const char* name); 37 | 38 | void __cdecl OnInput(); 39 | void __cdecl OnInput_MidJump(); 40 | void __cdecl OnControl(); 41 | void __cdecl OnExit(UINT uExitCode, int a1, int a2); 42 | -------------------------------------------------------------------------------- /SADXModLoader/ExtendedSaveSupport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ExtendedSaveSupport_Init(); 4 | 5 | extern const char* mainsavepath; 6 | extern const char* chaosavepath; -------------------------------------------------------------------------------- /SADXModLoader/FileMap.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * SADX Mod Loader 3 | * File remapper. 4 | */ 5 | 6 | #ifndef FILEMAP_HPP 7 | #define FILEMAP_HPP 8 | 9 | #include 10 | #include 11 | 12 | class FileMap 13 | { 14 | public: 15 | FileMap() = default; 16 | ~FileMap() = default; 17 | 18 | // Disable the copy and assign constructors. 19 | FileMap(const FileMap&) = delete; 20 | FileMap& operator=(const FileMap&) = delete; 21 | 22 | /** 23 | * Normalize a filename for the file replacement map. 24 | * @param filename Filename. 25 | * @return Normalized filename. 26 | */ 27 | static std::string normalizePath(const std::string& filename); 28 | 29 | /** 30 | * Normalize a filename for the file replacement map. 31 | * @param filename Filename. 32 | * @return Normalized filename. 33 | */ 34 | static std::string normalizePath(const char* filename); 35 | 36 | /** 37 | * Ignore a file. 38 | * @param ignoreFile File to ignore. 39 | * @param modIdx Index of the current mod. 40 | */ 41 | void addIgnoreFile(const std::string& ignoreFile, int modIdx); 42 | 43 | /** 44 | * Add a file replacement. 45 | * @param origFile Original filename. 46 | * @param modFile Mod filename. 47 | * @param force Do not check if the destination file is being replaced. 48 | */ 49 | void addReplaceFile(const std::string& origFile, const std::string& modFile, bool force = false); 50 | 51 | /** 52 | * Remove a file replacement. 53 | * @param file Filename. 54 | */ 55 | void FileMap::unreplaceFile(const std::string& file); 56 | 57 | /** 58 | * Swap two files. 59 | * @param fileA First filename. 60 | * @param fileB Second filename. 61 | */ 62 | void swapFiles(const std::string& fileA, const std::string& fileB); 63 | 64 | /** 65 | * Recursively scan a directory and add all files to the replacement map. 66 | * Destination is always relative to system/. 67 | * @param srcPath Path to scan. 68 | * @param modIdx Index of the current mod. 69 | */ 70 | void scanFolder(const std::string& srcPath, int modIdx); 71 | 72 | /** 73 | * Scans a sound folder for non-WMA files. 74 | * @param srcPath Path to scan. 75 | */ 76 | void scanSoundFolder(const std::string& srcPath); 77 | 78 | /** 79 | * Scans a texture pack folder for 80 | * @param srcPath The path to the "textures" folder to scan. 81 | * @param modIndex Index of the current mod. 82 | */ 83 | void scanTextureFolder(const std::string& srcPath, int modIndex); 84 | 85 | void FileMap::EditVoiceDuration(std::string modFile, bool isJp); 86 | 87 | protected: 88 | /** 89 | * Recursively scan a directory and add all files to the replacement map. 90 | * Destination is always relative to system/. 91 | * (Internal recursive function) 92 | * @param srcPath Path to scan. 93 | * @param srcLen Length of original srcPath. (used for recursion) 94 | * @param modIdx Index of the current mod. 95 | */ 96 | void scanFolder_int(const std::string& srcPath, int srcLen, int modIdx); 97 | 98 | /** 99 | * Set a replacement file in the map. 100 | * Filenames must already be normalized! 101 | * (Internal function; handles memory allocation) 102 | * @param origFile Original file. 103 | * @param destFile Mod filename. 104 | * @param modIdx Index of the current mod. 105 | */ 106 | void setReplaceFile(const std::string& origFile, const std::string& destFile, int modIdx); 107 | 108 | public: 109 | /** 110 | * Get a filename from the file replacement map. 111 | * @param lpFileName Filename. 112 | * @return Replaced filename, or original filename if not replaced by a mod. 113 | */ 114 | const char* replaceFile(const char* lpFileName) const; 115 | 116 | /** 117 | * Get the index of the mod that replaced a given file. 118 | * @param lpFileName Filename. 119 | * @return Index of the mod that replaced a file, or 0 if no mod replaced it. 120 | */ 121 | int getModIndex(const char* lpFileName) const; 122 | 123 | /** 124 | * Clear the file replacement map. 125 | */ 126 | void clear(); 127 | 128 | protected: 129 | 130 | struct Entry 131 | { 132 | std::string fileName; 133 | int modIndex; 134 | }; 135 | 136 | /** 137 | * File replacement map. 138 | * - Key: Original filename. 139 | * - Value: New filename. 140 | */ 141 | std::unordered_map m_fileMap; 142 | }; 143 | 144 | #endif /* FILEMAP_HPP */ 145 | -------------------------------------------------------------------------------- /SADXModLoader/FileReplacement.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "FileReplacement.h" 3 | 4 | // File replacement map. 5 | // NOTE: Do NOT mark this as static. 6 | // MediaFns.cpp needs to access the FileMap. 7 | FileMap sadx_fileMap; 8 | 9 | /** 10 | * CreateFileA() wrapper using _ReplaceFile(). 11 | * @param lpFileName 12 | * @param dwDesiredAccess 13 | * @param dwShareMode 14 | * @param lpSecurityAttributes 15 | * @param dwCreationDisposition 16 | * @param dwFlagsAndAttributes 17 | * @param hTemplateFile 18 | * @return 19 | */ 20 | HANDLE WINAPI MyCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) 21 | { 22 | return CreateFileA(sadx_fileMap.replaceFile(lpFileName), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); 23 | } 24 | 25 | /** 26 | * C wrapper to call sadx_fileMap.replaceFile() from asm. 27 | * @param lpFileName Filename. 28 | * @return Replaced filename, or original filename if not replaced by a mod. 29 | */ 30 | const char *_ReplaceFile(const char *lpFileName) 31 | { 32 | return sadx_fileMap.replaceFile(lpFileName); 33 | } 34 | -------------------------------------------------------------------------------- /SADXModLoader/FileReplacement.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | #include "FileMap.hpp" 6 | 7 | extern FileMap sadx_fileMap; 8 | 9 | HANDLE __stdcall MyCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); 10 | const char* _ReplaceFile(const char* lpFileName); 11 | -------------------------------------------------------------------------------- /SADXModLoader/FixFOV.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fov 4 | { 5 | void check_aspect_ratio(); 6 | void initialize(); 7 | 8 | /** 9 | * \brief Gets the current unmodified horizontal field of view provided by the game code. 10 | */ 11 | Angle get_fov(); 12 | } 13 | -------------------------------------------------------------------------------- /SADXModLoader/Gbix.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | NJS_TEXMEMLIST* __cdecl GetCachedTexture_r(int gbix) 4 | { 5 | NJS_TEXMEMLIST* result = nullptr; 6 | NJS_TEXMEMLIST* t = GlobalTextures_p; 7 | int i = 0; 8 | 9 | if (GlobalTextureCount) 10 | { 11 | while (t->count) 12 | { 13 | ++i; 14 | ++t; 15 | if (i >= GlobalTextureCount) 16 | { 17 | return result; 18 | } 19 | } 20 | result = t; 21 | } 22 | 23 | return result; 24 | } 25 | 26 | //removed for now as it can trigger some random crash when loading too many PVM. 27 | void Init_NOGbixHack() 28 | { 29 | //WriteJump((void*)0x77F5B0, GetCachedTexture_r); 30 | } -------------------------------------------------------------------------------- /SADXModLoader/Gbix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Init_NOGbixHack(); -------------------------------------------------------------------------------- /SADXModLoader/InterpolationFixes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace interpolation 4 | { 5 | extern bool enabled; 6 | void init(); 7 | void push(); 8 | void pop(); 9 | } -------------------------------------------------------------------------------- /SADXModLoader/KeyboardMouse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct KeyboardMapping 7 | { 8 | Sint16 Analog1_Up[3]; 9 | Sint16 Analog1_Down[3]; 10 | Sint16 Analog1_Left[3]; 11 | Sint16 Analog1_Right[3]; 12 | Sint16 Analog2_Up[3]; 13 | Sint16 Analog2_Down[3]; 14 | Sint16 Analog2_Left[3]; 15 | Sint16 Analog2_Right[3]; 16 | Sint16 LT[3]; 17 | Sint16 RT[3]; 18 | Sint16 DPad_Up[3]; 19 | Sint16 DPad_Down[3]; 20 | Sint16 DPad_Left[3]; 21 | Sint16 DPad_Right[3]; 22 | Sint16 Button_A[3]; 23 | Sint16 Button_B[3]; 24 | Sint16 Button_X[3]; 25 | Sint16 Button_Y[3]; 26 | Sint16 Button_Start[3]; 27 | Sint16 Button_LeftShoulder[3]; 28 | Sint16 Button_RightShoulder[3]; 29 | Sint16 Button_Back[3]; 30 | Sint16 Button_LeftStick[3]; 31 | Sint16 Button_RightStick[3]; 32 | }; 33 | 34 | struct KeyboardKey 35 | { 36 | char held; 37 | char old; 38 | char pressed; 39 | }; 40 | 41 | struct KeyboardStick : NJS_POINT2I 42 | { 43 | Uint32 directions; 44 | static constexpr auto amount = 8192; 45 | 46 | void update(); 47 | }; 48 | 49 | class KeyboardMouse 50 | { 51 | public: 52 | static const ControllerData& dreamcast_data() 53 | { 54 | return pad; 55 | } 56 | static float normalized_l() 57 | { 58 | return normalized_l_; 59 | } 60 | static float normalized_r() 61 | { 62 | return normalized_r_; 63 | } 64 | 65 | static void poll(); 66 | static void update_keyboard_buttons(Uint32 key, bool down); 67 | static void update_cursor(Sint32 xrel, Sint32 yrel); 68 | static void update_wheel(WPARAM wParam); 69 | static void reset_cursor(); 70 | static void set_player(ushort keyboard_player_current); 71 | static void update_mouse_buttons(Uint32 button, bool down); 72 | static LRESULT read_window_message(HWND handle, UINT Msg, WPARAM wParam, LPARAM lParam); 73 | static void hook_wnd_proc(); 74 | static void clear_sadx_keys(); 75 | static void update_sadx_key(Uint32 key, bool down); 76 | 77 | private: 78 | static ControllerData pad; 79 | static float normalized_l_, normalized_r_; 80 | static bool mouse_active; 81 | static bool wheel_active; 82 | static bool left_button; 83 | static bool right_button; 84 | static bool half_press; 85 | static bool e_held; 86 | static NJS_POINT2I cursor; 87 | static KeyboardStick sticks[2]; 88 | static Sint16 mouse_x; 89 | static Sint16 mouse_y; 90 | static Sint16 wheel_delta; 91 | static WNDPROC lpPrevWndFunc; 92 | }; 93 | 94 | extern KeyboardInput SADXKeyboard; -------------------------------------------------------------------------------- /SADXModLoader/MinorGamePatches.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | //fix a crash on Chaos 2 if you restart after defeating him. (Knuckles only) 4 | 5 | static FunctionHook SetLocalPathCamera_t((intptr_t)0x469300); 6 | 7 | void __cdecl SetLocalPathCamera_r(pathtag* path, Sint8 mode, int timer) 8 | { 9 | if (!camera_twp) 10 | { 11 | return; 12 | } 13 | 14 | return SetLocalPathCamera_t.Original(path, mode, timer); 15 | } 16 | 17 | //fix wrong music on Chaos 2 if you restart after defeating him 18 | void LoadDelayedSoundBGM_r(int index) 19 | { 20 | if (!IsIngame()) 21 | return; 22 | 23 | Load_DelayedSound_BGM(index); 24 | } 25 | 26 | void MinorGamePatches_Init() 27 | { 28 | WriteData<1>((char*)0x006ED184, 0x03u); // Fix effect_cons (Big intro, Knuckles outro) texture ID going out of range 29 | SetLocalPathCamera_t.Hook(SetLocalPathCamera_r); 30 | WriteCall((void*)0x415631, LoadDelayedSoundBGM_r); 31 | } -------------------------------------------------------------------------------- /SADXModLoader/MinorGamePatches.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void MinorGamePatches_Init(); -------------------------------------------------------------------------------- /SADXModLoader/NodeLimit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void IncreaseNodeLimit(); -------------------------------------------------------------------------------- /SADXModLoader/SADXModLoader.rc: -------------------------------------------------------------------------------- 1 | /** 2 | * SADX Mod Loader 3 | * Win32 resource script. 4 | */ 5 | 6 | #include "windows.h" 7 | #include "resource.h" 8 | 9 | /** Accelerator table. **/ 10 | 11 | IDR_ACCEL_WRAPPER_WINDOW ACCELERATORS 12 | BEGIN 13 | VK_RETURN, ID_FULLSCREEN, VIRTKEY, ALT 14 | END 15 | 16 | /** Application version. **/ 17 | 18 | // git version 19 | #include "git.h" 20 | 21 | // program version 22 | #include "version.h" 23 | 24 | #ifdef MODLOADER_GIT_VERSION 25 | #ifdef MODLOADER_GIT_DESCRIBE 26 | #define Win32_RC_FileVersion VERSION_STRING "\r\n" MODLOADER_GIT_VERSION "\r\n" MODLOADER_GIT_DESCRIBE 27 | #else /* !MODLOADER_GIT_DESCRIBE */ 28 | #define Win32_RC_FileVersion VERSION_STRING "\r\n" MODLOADER_GIT_VERSION 29 | #endif /* MODLOADER_GIT_DESCRIBE */ 30 | #else /* !MODLOADER_GIT_VERSION */ 31 | #define Win32_RC_FileVersion VERSION_STRING 32 | #endif /* MODLOADER_GIT_VERSION */ 33 | 34 | VS_VERSION_INFO VERSIONINFO 35 | FILEVERSION VERSION_WIN32 36 | PRODUCTVERSION VERSION_WIN32 37 | FILEFLAGSMASK 0x3fL 38 | #ifdef VERSION_PRERELEASE 39 | #ifdef _DEBUG 40 | FILEFLAGS VS_FF_PRERELEASE | VS_FF_DEBUG 41 | #else 42 | FILEFLAGS VS_FF_PRERELEASE 43 | #endif 44 | #else /* !VERSION_PRERELEASE */ 45 | #ifdef _DEBUG 46 | FILEFLAGS VS_FF_DEBUG 47 | #else 48 | FILEFLAGS 0 49 | #endif 50 | #endif /* VERSION_PRERELEASE */ 51 | FILEOS VOS_NT_WINDOWS32 52 | FILETYPE VFT_DLL 53 | FILESUBTYPE VFT2_UNKNOWN 54 | BEGIN 55 | BLOCK "StringFileInfo" 56 | BEGIN 57 | BLOCK "040904b0" 58 | BEGIN 59 | //VALUE "Comments", "" 60 | //VALUE "CompanyName", "" 61 | VALUE "FileDescription", "SADX Mod Loader" 62 | VALUE "FileVersion", Win32_RC_FileVersion 63 | VALUE "InternalName", "SADX Mod Loader" 64 | //VALUE "LegalCopyright", "" 65 | //VALUE "LegalTrademarks", "" 66 | //VALUE "OriginalFilename", "" 67 | //VALUE "PrivateBuild", "" 68 | VALUE "ProductName", "SADX Mod Loader" 69 | VALUE "ProductVersion", Win32_RC_FileVersion 70 | //VALUE "SpecialBuild", "" 71 | END 72 | END 73 | BLOCK "VarFileInfo" 74 | BEGIN 75 | VALUE "Translation", 0x409, 1200 76 | END 77 | END 78 | -------------------------------------------------------------------------------- /SADXModLoader/SDL.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma once 4 | 5 | // HACK: Prevents compatibility issues with ninja.h 6 | #define _TYPEDEF_Uint32 7 | #define _TYPEDEF_Sint32 8 | 9 | #include 10 | 11 | -------------------------------------------------------------------------------- /SADXModLoader/SkyChaseFixes.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include "SkyChaseFixes.h" 4 | 5 | static float HorizontalResolution_float = 640.0f; 6 | static float VerticalResolution_float = 480.0f; 7 | static float VerticalResolutionHalf_float = 240.0f; 8 | 9 | static const float float_one = 1.0f; 10 | static float target_collision_size = 1.0f; 11 | static float target_speed_multiplier = 2.0f; 12 | 13 | static const double SkyRotationMultiplier = -0.5; 14 | 15 | template 16 | T clamp(T value, T low, T high) 17 | { 18 | if (value < low) 19 | { 20 | return low; 21 | } 22 | 23 | if (value > high) 24 | { 25 | return high; 26 | } 27 | 28 | return value; 29 | } 30 | 31 | static void __cdecl TornadoTarget_MoveTargetWithinBounds_r(task* tp) 32 | { 33 | auto pos = &tp->twp->pos; 34 | 35 | const float m = min(VerticalStretch, HorizontalStretch); 36 | const float move_speed = m * 0.000308093f; 37 | 38 | // 640x480 - 160x160 margin 39 | const float w = 480.0f * m; 40 | const float h = 320.0f * m; 41 | 42 | const float left = (HorizontalResolution_float - w) / 2.0f; 43 | const float top = (VerticalResolution_float - h) / 2.0f; 44 | const float right = left + w; 45 | const float bottom = top + h; 46 | 47 | const float x = (static_cast(static_cast(Controllers[0].LeftStickX) << 8) * move_speed) + pos->x; 48 | const float y = (static_cast(static_cast(Controllers[0].LeftStickY) << 8) * move_speed) + pos->y; 49 | 50 | pos->x = clamp(x, left, right); 51 | pos->y = clamp(y, top, bottom); 52 | } 53 | 54 | static void __declspec(naked) TornadoTarget_MoveTargetWithinBounds_asm() 55 | { 56 | __asm 57 | { 58 | push eax 59 | call TornadoTarget_MoveTargetWithinBounds_r 60 | pop eax 61 | retn 62 | } 63 | } 64 | 65 | static void __cdecl TornadoTarget_CalculateCenterPoint_r(task* tp) 66 | { 67 | auto pos = &tp->twp->pos; 68 | auto parent_pos = &tp->ptp->twp->pos; 69 | 70 | pos->x = parent_pos->x - _nj_screen_.cx; 71 | pos->y = parent_pos->y - _nj_screen_.cy; 72 | pos->z = 1000.0f * min(VerticalStretch, HorizontalStretch); 73 | 74 | njPushMatrix(nullptr); 75 | njInvertMatrix(nullptr); 76 | njCalcPoint(nullptr, pos, pos); 77 | njPopMatrixEx(); 78 | } 79 | 80 | static void __cdecl TornadoFixTargetSpriteScale(NJS_SPRITE* sp, Int n, Float pri, NJD_SPRITE attr) 81 | { 82 | if (!IsGamePaused()) 83 | { 84 | sp->sy = sp->sy * min(VerticalStretch, HorizontalStretch); 85 | njDrawSprite2D_ForcePriority(sp, n, pri, attr); 86 | } 87 | } 88 | 89 | void SkyChaseFix_UpdateBounds() 90 | { 91 | // Resolution related fixes 92 | HorizontalResolution_float = static_cast(HorizontalResolution); 93 | VerticalResolution_float = static_cast(VerticalResolution); 94 | VerticalResolutionHalf_float = VerticalResolution_float / 2.0f; 95 | 96 | auto m = min(VerticalStretch, HorizontalStretch); 97 | 98 | // Sky Chase reticle and multiplier fixes 99 | target_speed_multiplier = m; 100 | target_collision_size = 1024.0f * m; 101 | 102 | WriteData(reinterpret_cast(0x00628951), m); // Reticle scale X 103 | WriteData(reinterpret_cast(0x0062895B), m); // Reticle scale Y 104 | } 105 | 106 | void SkyChaseFix_Init() 107 | { 108 | SkyChaseFix_UpdateBounds(); 109 | 110 | WriteJump(reinterpret_cast(0x00628970), TornadoTarget_MoveTargetWithinBounds_asm); 111 | 112 | WriteData(reinterpret_cast(0x00627F4D), &float_one); // Tornado Speed (always 1) 113 | WriteData(reinterpret_cast(0x00627F60), &float_one); // Horizontal limit 114 | WriteData(reinterpret_cast(0x00627F72), &float_one); // Vertical limit 115 | 116 | WriteJump(reinterpret_cast(0x628D50), TornadoTarget_CalculateCenterPoint_r); // Calculate center for bullets 117 | 118 | // Hodai fixes 119 | WriteData(reinterpret_cast(0x0043854D), &HorizontalResolution_float); 120 | WriteData(reinterpret_cast(0x00438571), &VerticalResolutionHalf_float); 121 | WriteData(reinterpret_cast(0x0043857F), &VerticalResolutionHalf_float); 122 | 123 | WriteData(reinterpret_cast(0x628AF7), &target_collision_size); // Target size 124 | WriteData(reinterpret_cast(0x00629472), &target_speed_multiplier); // Target speed 125 | 126 | // Visual stuff 127 | WriteData(reinterpret_cast(0x00627D14), &SkyRotationMultiplier); 128 | WriteCall(reinterpret_cast(0x00628E4D), TornadoFixTargetSpriteScale); 129 | } -------------------------------------------------------------------------------- /SADXModLoader/SkyChaseFixes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void SkyChaseFix_UpdateBounds(); 4 | void SkyChaseFix_Init(); -------------------------------------------------------------------------------- /SADXModLoader/TextureReplacement.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct TexPackEntry 6 | { 7 | uint32_t global_index; 8 | std::string name; 9 | uint32_t width, height; 10 | }; 11 | 12 | void ScanTextureReplaceFolder(const std::string& srcPath, int modIndex); 13 | void ReplaceTexture(const char* pvm_name, const char* tex_name, const char* file_path, uint32_t gbix, uint32_t width, uint32_t height); 14 | void MipmapBlacklistGBIX(Uint32 index); 15 | 16 | namespace texpack 17 | { 18 | /** 19 | * \brief Parses custom texture index. 20 | * \param path A valid path to a texture pack directory containing index.txt 21 | * \param out A vector to populate. 22 | * \return \c true on success. 23 | */ 24 | bool parse_index(const std::string& path, std::vector& out); 25 | 26 | /** 27 | * \brief Initializes function hooks for texture replacement. 28 | */ 29 | void init(); 30 | } 31 | -------------------------------------------------------------------------------- /SADXModLoader/VoiceDuration.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void RegisterEnglishVoiceDuration(const uint16_t voiceID, const uint16_t duration); 4 | void RegisterJapaneseVoiceDuration(const uint16_t voiceID, const uint16_t duration); 5 | 6 | int GetSoundLength(std::string filename); 7 | std::string base_name(std::string const& path); 8 | bool isInteger(const std::string& s); -------------------------------------------------------------------------------- /SADXModLoader/XInputFix.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | Uint32 ProcessButtons(Uint32 orig) 4 | { 5 | Uint32 result = 0; 6 | if (orig & 0x04) 7 | result |= Buttons_A; 8 | if (orig & 0x02) 9 | result |= Buttons_B; 10 | if (orig & 0x20) 11 | result |= Buttons_X; 12 | if (orig & 0x400) 13 | result |= Buttons_Y; 14 | if (orig & 0x200) 15 | result |= Buttons_L; 16 | if (orig & 0x10) 17 | result |= Buttons_R; 18 | if (orig & 0x10000) 19 | result |= Buttons_Start; 20 | if (orig & 0x20000) 21 | result |= Buttons_Z; 22 | if (orig & 0x8) 23 | result |= Buttons_C; 24 | return result; 25 | } 26 | 27 | static Trampoline* GetControllerData_t; 28 | static ControllerData* GetControllerData_r(int a1) 29 | { 30 | Sint16 newx = 0; 31 | Uint16 deadzone = 24; // To prevent 1st person camera from getting stuck at near-center values of the stick 32 | 33 | ControllerData* orig = TARGET_DYNAMIC(GetControllerData)(a1); 34 | 35 | Uint16 rawx = (Uint16)orig->RightStickX; // X360 controller reports 0 to 65535 for this axis in DInput mode 36 | Sint16 newy = orig->RightStickY; // X360 controller reports -128 to 128 for this axis in DInput mode 37 | Uint32 rawbtn_held = orig->HeldButtons; 38 | Uint32 rawbtn_notheld = orig->NotHeldButtons; 39 | Uint32 rawbtn_pressed = orig->PressedButtons; 40 | // Convert 0~65535 to -128~128 for the X axis 41 | if (rawx != 0) 42 | { 43 | if (rawx < 32768) 44 | { 45 | newx = int(-128.0f + (float)rawx / 256.0f); 46 | } 47 | else 48 | { 49 | newx = int((float)(rawx - 32768) / 256.0f); 50 | } 51 | 52 | } 53 | 54 | // Apply deadzones 55 | if (abs(newx) < deadzone) 56 | newx = 0; 57 | if (abs(newy) < deadzone) 58 | newy = 0; 59 | 60 | orig->RightStickX = newx; 61 | orig->RightStickY = newy; 62 | 63 | /* 64 | if (a1 == 0) 65 | { 66 | PrintDebug("X2: %d / %d\n", rawx, orig->RightStickX); 67 | PrintDebug("Y2: %d / %d\n", newy, orig->RightStickY); 68 | PrintDebug("Buttons: %X\n", orig->HeldButtons); 69 | } 70 | */ 71 | 72 | // Process buttons 73 | orig->HeldButtons = ProcessButtons(rawbtn_held); 74 | orig->PressedButtons = ProcessButtons(rawbtn_pressed); 75 | orig->NotHeldButtons = ProcessButtons(rawbtn_notheld); 76 | 77 | return orig; 78 | } 79 | 80 | void XInputFix_Init() 81 | { 82 | GetControllerData_t = new Trampoline(0x0077F120, 0x0077F129, GetControllerData_r); 83 | } -------------------------------------------------------------------------------- /SADXModLoader/XInputFix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void XInputFix_Init(); -------------------------------------------------------------------------------- /SADXModLoader/backend.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "d3d8types.h" 3 | #include "util.h" 4 | 5 | enum RenderBackend: int 6 | { 7 | DirectX8 = 0, 8 | DirectX9 = 1, 9 | DirectX11 = 2 10 | }; 11 | 12 | static std::string BackendName; // Title of the backend, e.g. "d3d8to9" 13 | static std::wstring WrapperDllFilename; // Filename of the backend DLL, e.g. "d3d8to11.dll" 14 | static std::wstring WrapperCheckFilename; // Filename of DLL to check if the backend is already loaded, e.g. "d3d9.dll" or "d3d11.dll" 15 | static std::wstring WrapperDllFolderLocation; // Full path to the backend folder, e.g. "C:\SADX\SAManager\extlib\d3d8m" 16 | static std::wstring WrapperDllFullPath; // Full path to the backend DLL file e.g. "C:\SADX\SAManager\extlib\d3d8m\d3d8m.dll" 17 | 18 | IDirect3D8* __stdcall CreateDirect3D8Hook(UINT SDKVersion) 19 | { 20 | HMODULE handle = GetModuleHandle(WrapperDllFilename.c_str()); 21 | if (!handle) 22 | return 0; 23 | typedef IDirect3D8* (WINAPI* Direct3DCreate8Ptr)(UINT); 24 | Direct3DCreate8Ptr Direct3DCreate8Original = (Direct3DCreate8Ptr)GetProcAddress(handle, "Direct3DCreate8"); 25 | if (!Direct3DCreate8Original) 26 | return 0; 27 | IDirect3D8* result = Direct3DCreate8Original(SDKVersion); 28 | if (!result) 29 | { 30 | PrintDebug("%s backend: Error creating Direct3D object - IDirect3D8 pointer is null \n", BackendName.c_str()); 31 | MessageBox(nullptr, L"Error creating Direct3D object: IDirect3D8 pointer is null.", L"Direct3D Object Error", MB_OK | MB_ICONERROR); 32 | OnExit(0, 0, 0); 33 | ExitProcess(0); 34 | } 35 | return result; 36 | } 37 | 38 | void __cdecl InitRenderBackend(int mode) 39 | { 40 | bool loadWrapper = false; 41 | switch ((RenderBackend)mode) 42 | { 43 | case DirectX8: 44 | default: 45 | break; 46 | case DirectX9: 47 | loadWrapper = true; 48 | BackendName = "D3D8to9"; 49 | WrapperDllFilename = L"d3d8m.dll"; 50 | WrapperCheckFilename = L"d3d9.dll"; 51 | WrapperDllFolderLocation = loaderSettings.ExtLibPath + L"D3D8M"; 52 | WrapperDllFullPath = loaderSettings.ExtLibPath + L"D3D8M\\d3d8m.dll"; 53 | break; 54 | case DirectX11: 55 | loadWrapper = true; 56 | BackendName = "D3D8to11"; 57 | WrapperDllFilename = L"d3d8to11.dll"; 58 | WrapperCheckFilename = L"d3d11.dll"; 59 | WrapperDllFolderLocation = loaderSettings.ExtLibPath + L"D3D8to11"; 60 | WrapperDllFullPath = loaderSettings.ExtLibPath + L"D3D8to11\\d3d8to11.dll"; 61 | // Set environment variables 62 | SetEnvironmentVariable(L"D3D8TO11_CONFIG_DIR", WrapperDllFolderLocation.c_str()); 63 | SetEnvironmentVariable(L"D3D8TO11_SHADER_SOURCE_DIR", WrapperDllFolderLocation.c_str()); 64 | break; 65 | } 66 | if (loadWrapper) 67 | { 68 | if (GetModuleHandle(WrapperCheckFilename.c_str()) != nullptr) 69 | { 70 | PrintDebug("%s: Skipping initialization because the DLL is already loaded\n", BackendName.c_str()); 71 | return; 72 | } 73 | // Attempt to load the DLL 74 | HMODULE handle = LoadLibraryEx(WrapperDllFullPath.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); 75 | 76 | if (handle) 77 | PrintDebug("%s: Backend DLL loaded successfully\n", BackendName.c_str()); 78 | else 79 | { 80 | int err = GetLastError(); 81 | PrintDebug("%s: Error loading backend DLL %X (%d)\n", BackendName.c_str(), err, err); 82 | MessageBox(nullptr, L"Error loading rendering backend.\n\n" 83 | L"Make sure the Mod Loader is installed properly.", 84 | L"Backend Load Error", MB_OK | MB_ICONERROR); 85 | return; 86 | } 87 | // Hook Direct3DCreate8 88 | WriteJump((void*)0x007C235E, CreateDirect3D8Hook); 89 | } 90 | } -------------------------------------------------------------------------------- /SADXModLoader/backend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void __cdecl InitRenderBackend(int mode); -------------------------------------------------------------------------------- /SADXModLoader/bgscale.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace bgscale 4 | { 5 | void initialize(); 6 | } 7 | -------------------------------------------------------------------------------- /SADXModLoader/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void LoadModLoaderSettings(LoaderSettings* loaderSettings, std::wstring gamePath); 4 | unsigned int GetModCount(); 5 | std::string GetModName(int index); 6 | bool IsGamePatchEnabled(const char* patchName); 7 | void ListGamePatches(); -------------------------------------------------------------------------------- /SADXModLoader/cpp.hint: -------------------------------------------------------------------------------- 1 | // Data pointer and array declarations. 2 | #define DataPointer(type, name, address) \ 3 | static type &name = *(type *)address 4 | #define DataArray(type, name, address, len) \ 5 | static DataArray_t name 6 | 7 | // Function pointer declarations. 8 | #define FunctionPointer(RETURN_TYPE, NAME, ARGS, ADDRESS) \ 9 | static RETURN_TYPE (__cdecl *const NAME)ARGS = (RETURN_TYPE (__cdecl *)ARGS)ADDRESS 10 | #define StdcallFunctionPointer(RETURN_TYPE, NAME, ARGS, ADDRESS) \ 11 | static RETURN_TYPE (__stdcall *const NAME)ARGS = (RETURN_TYPE (__stdcall *)ARGS)ADDRESS 12 | #define FastcallFunctionPointer(RETURN_TYPE, NAME, ARGS, ADDRESS) \ 13 | static RETURN_TYPE (__fastcall *const NAME)ARGS = (RETURN_TYPE (__fastcall *)ARGS)ADDRESS 14 | #define ThiscallFunctionPointer(RETURN_TYPE, NAME, ARGS, ADDRESS) \ 15 | static RETURN_TYPE (__thiscall *const NAME)ARGS = (RETURN_TYPE (__thiscall *)ARGS)ADDRESS 16 | #define VoidFunc(NAME, ADDRESS) FunctionPointer(void,NAME,(void),ADDRESS) 17 | 18 | // Non-static FunctionPointer. 19 | // If declaring a FunctionPointer within a function, use this one instead. 20 | // Otherwise, the program will crash on Windows XP. 21 | #define NonStaticFunctionPointer(RETURN_TYPE, NAME, ARGS, ADDRESS) \ 22 | RETURN_TYPE (__cdecl *const NAME)ARGS = (RETURN_TYPE (__cdecl *)ARGS)ADDRESS 23 | 24 | #define ObjectFunc(NAME, ADDRESS) FunctionPointer(void,NAME,(ObjectMaster *obj),ADDRESS) -------------------------------------------------------------------------------- /SADXModLoader/direct3d.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "MemAccess.h" 7 | #include "SADXStructs.h" 8 | 9 | #if defined(_MSC_VER) && _MSC_VER >= 1900 10 | // MSVC 2015 inlines printf() and scanf() functions. 11 | // As a result, MSVCRT no longer has definitions for them, resulting 12 | // in a linker error because d3dx8.lib depends on sprintf(). 13 | // Link in legacy_stdio_definitions.lib to fix this. 14 | // Reference: https://msdn.microsoft.com/en-us/library/Bb531344.aspx 15 | #pragma comment(lib, "legacy_stdio_definitions.lib") 16 | #endif 17 | 18 | struct MeshSetBuffer 19 | { 20 | NJS_MESHSET_SADX* Meshset; 21 | void* field_4; 22 | int FVF; 23 | IDirect3DVertexBuffer8* VertexBuffer; 24 | int Size; 25 | IDirect3DIndexBuffer8* IndexBuffer; 26 | D3DPRIMITIVETYPE PrimitiveType; 27 | int MinIndex; 28 | int NumVertecies; 29 | int StartIndex; 30 | int PrimitiveCount; 31 | }; 32 | 33 | #pragma pack(push, 1) 34 | struct __declspec(align(2)) PolyBuff_RenderArgs 35 | { 36 | Uint32 StartVertex; 37 | Uint32 PrimitiveCount; 38 | Uint32 CullMode; 39 | Uint32 d; 40 | }; 41 | #pragma pack(pop) 42 | 43 | #pragma pack(push, 1) 44 | struct PolyBuff 45 | { 46 | IDirect3DVertexBuffer8* pStreamData; 47 | Uint32 TotalSize; 48 | Uint32 CurrentSize; 49 | Uint32 Stride; 50 | Uint32 FVF; 51 | PolyBuff_RenderArgs* RenderArgs; 52 | Uint32 LockCount; 53 | const char* name; 54 | int i; 55 | }; 56 | #pragma pack(pop) 57 | 58 | DataPointer(IDirect3DDevice8*, Direct3D_Device, 0x03D128B0); 59 | DataPointer(IDirect3D8*, Direct3D_Object, 0x03D11F60); 60 | 61 | FastcallFunctionPointer(void, PolyBuff_Init, (PolyBuff *polyBuff, int count, int size, Uint32 FVF, const char *name), 0x794540); 62 | FastcallFunctionPointer(void, PolyBuff_Free, (PolyBuff *_this), 0x7945C0); 63 | FastcallFunctionPointer(void, PolyBuff_SetCurrent, (PolyBuff *_this), 0x794600); 64 | FastcallFunctionPointer(BYTE*, PolyBuff_LockTriangleStrip, (PolyBuff *__this, int primitives, int cullmode), 0x794630); 65 | FastcallFunctionPointer(BYTE*, PolyBuff_LockTriangleList, (PolyBuff *__this, unsigned int primitives, int cullmode), 0x7946C0); 66 | FastcallFunctionPointer(int, PolyBuff_Unlock, (PolyBuff *_this), 0x794750); 67 | FastcallFunctionPointer(void, PolyBuff_DrawTriangleStrip, (PolyBuff *_this), 0x794760); 68 | FastcallFunctionPointer(void, PolyBuff_DrawTriangleList, (PolyBuff *_this), 0x7947B0); 69 | FastcallFunctionPointer(void, PolyBuff_Discard, (PolyBuff *_this), 0x794800); 70 | 71 | // BYTE* __usercall@(MeshSetBuffer* mesh@, int count) 72 | static const void* const MeshSetBuffer_CreateVertexBufferPtr = reinterpret_cast(0x7853D0); 73 | 74 | static inline BYTE* MeshSetBuffer_CreateVertexBuffer(MeshSetBuffer* mesh, int count) 75 | { 76 | BYTE* result; 77 | __asm 78 | { 79 | push [count] 80 | mov edi, [mesh] 81 | call MeshSetBuffer_CreateVertexBufferPtr 82 | add esp, 4 83 | mov result, eax 84 | } 85 | return result; 86 | } 87 | 88 | namespace direct3d 89 | { 90 | void init(); 91 | void set_vsync(bool value); 92 | void set_aa(int value); 93 | void set_af(int value); 94 | void reset_device(); 95 | void change_resolution(uint32_t width, uint32_t height); 96 | void change_resolution(uint32_t width, uint32_t height, bool windowed); 97 | bool is_windowed(); 98 | } 99 | -------------------------------------------------------------------------------- /SADXModLoader/dpi.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | BOOL SetProcessDPIAwareWrapper() { 5 | typedef BOOL(WINAPI* SetProcessDPIAwarePtr)(VOID); 6 | SetProcessDPIAwarePtr set_process_dpi_aware_func = 7 | reinterpret_cast( 8 | GetProcAddress(GetModuleHandleA("user32.dll"), 9 | "SetProcessDPIAware")); 10 | return set_process_dpi_aware_func && 11 | set_process_dpi_aware_func(); 12 | } 13 | 14 | void DPIFix_Init() 15 | { 16 | SetProcessDPIAwareWrapper(); 17 | } -------------------------------------------------------------------------------- /SADXModLoader/dpi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void DPIFix_Init(); -------------------------------------------------------------------------------- /SADXModLoader/git.h: -------------------------------------------------------------------------------- 1 | /** 2 | * SADX Mod Loader 3 | * Git version macros. 4 | */ 5 | 6 | #ifndef SADXMODLOADER_GIT_H 7 | #define SADXMODLOADER_GIT_H 8 | 9 | // git_version.h is generated by git_version.sh 10 | #include "git_version.h" 11 | 12 | // MODLOADER_GIT_VERSION: Macro for the git revision, if available. 13 | #ifdef GIT_REPO 14 | #ifdef GIT_BRANCH 15 | #define MODLOADER_GIT_TMP_BRANCH GIT_BRANCH 16 | #ifdef GIT_SHAID 17 | #define MODLOADER_GIT_TMP_SHAID "/" GIT_SHAID 18 | #else /* !GIT_SHAID */ 19 | #define MODLOADER_GIT_TMP_SHAID 20 | #endif /* GIT_SHAID */ 21 | #else /* !GIT_BRANCH */ 22 | #define MODLOADER_GIT_TMP_BRANCH 23 | #ifdef GIT_SHAID 24 | #define MODLOADER_GIT_TMP_SHAID GIT_SHAID 25 | #else /* !GIT_SHAID */ 26 | #define MODLOADER_GIT_TMP_SHAID 27 | #endif /* GIT_SHAID */ 28 | #endif /* GIT_BRANCH */ 29 | 30 | #ifdef GIT_DIRTY 31 | #define MODLOADER_GIT_TMP_DIRTY "+" 32 | #else /* !GIT_DIRTY */ 33 | #define MODLOADER_GIT_TMP_DIRTY 34 | #endif /* GIT_DIRTY */ 35 | 36 | #define MODLOADER_GIT_VERSION "git: " MODLOADER_GIT_TMP_BRANCH MODLOADER_GIT_TMP_SHAID MODLOADER_GIT_TMP_DIRTY 37 | #ifdef GIT_DESCRIBE 38 | #define MODLOADER_GIT_DESCRIBE GIT_DESCRIBE MODLOADER_GIT_TMP_DIRTY 39 | #endif 40 | #else /* !GIT_REPO */ 41 | #ifdef MODLOADER_GIT_VERSION 42 | #undef MODLOADER_GIT_VERSION 43 | #endif /* MODLOADER_GIT_VERSION */ 44 | #ifdef MODLOADER_GIT_DESCRIBE 45 | #undef MODLOADER_GIT_DESCRIBE 46 | #endif /* MODLOADER_GIT_DESCRIBE */ 47 | #endif /* GIT_REPO */ 48 | 49 | #endif /* __MODLOADER_GIT_H__ */ 50 | -------------------------------------------------------------------------------- /SADXModLoader/gvm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void __cdecl GVR_Init(); 4 | 5 | // GVR data formats 6 | #define GJD_TEXFMT_ARGB_I4 (0x00) 7 | #define GJD_TEXFMT_ARGB_I8 (0x01) 8 | #define GJD_TEXFMT_ARGB_IA4 (0x02) 9 | #define GJD_TEXFMT_ARGB_IA8 (0x03) 10 | #define GJD_TEXFMT_RGB_565 (0x04) 11 | #define GJD_TEXFMT_ARGB_5A3 (0x05) 12 | #define GJD_TEXFMT_ARGB_8888 (0x06) 13 | #define GJD_TEXFMT_PALETTIZE4 (0x08) 14 | #define GJD_TEXFMT_PALETTIZE8 (0x09) 15 | #define GJD_TEXFMT_DXT1 (0x0E) 16 | 17 | // GVR pixel formats 18 | #define GJD_PIXELFORMAT_PAL_4BPP (0x28000000) // Same as NJD_PIXELFORMAT_PALETTIZED_4BPP for compatibility with stApplyPalette 19 | #define GJD_PIXELFORMAT_PAL_8BPP (0x30000000) // Same as NJD_PIXELFORMAT_PALETTIZED_8BPP 20 | #define GJD_PIXELFORMAT_OTHER (0x10000000) // Same as NJD_PIXELFORMAT_ARGB4444 for compatibility with "draw texture" functions 21 | #define GJD_PIXELFORMAT_DXT1 (0xFF000000) // Whatever 22 | 23 | // GVM flags 24 | #define GVMH_NAMES (0x1) 25 | #define GVMH_FORMATS (0x2) 26 | #define GVMH_DIMENSIONS (0x4) 27 | #define GVMH_GBIX (0x8) 28 | 29 | // GVR surface flags 30 | #define GJD_SURFACEFLAGS_MIPMAPED (0x80000000) 31 | #define GJD_SURFACEFLAGS_VQ (0x40000000) 32 | #define GJD_SURFACEFLAGS_NOTWIDDLED (0x04000000) 33 | #define GJD_SURFACEFLAGS_TWIDDLED (0x00000000) 34 | #define GJD_SURFACEFLAGS_STRIDE (0x02000000) 35 | #define GJD_SURFACEFLAGS_PALETTIZED (0x00008000) 36 | 37 | // GVR data flags 38 | #define GVR_FLAG_MIPMAP (0x1) 39 | #define GVR_FLAG_PALETTE (0x2) 40 | #define GVR_FLAG_PALETTE_INT (0x8) -------------------------------------------------------------------------------- /SADXModLoader/hudscale.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma once 4 | 5 | namespace hudscale 6 | { 7 | void update(); 8 | void initialize(); 9 | } 10 | -------------------------------------------------------------------------------- /SADXModLoader/include/SADXModLoader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * SADX Mod Loader. 3 | * Common header file for SADXModLoader mods. 4 | */ 5 | 6 | #ifndef SADXMODLOADER_H 7 | #define SADXMODLOADER_H 8 | 9 | #if !defined(_M_IX86) && !defined(__i386__) 10 | #error Mods must be built targeting 32-bit x86, change your settings. 11 | #endif 12 | 13 | #include "ninja.h" 14 | 15 | // HACK: Fixes conflict with Windows API PlaySound. 16 | #ifdef PlaySound 17 | #undef PlaySound 18 | #endif 19 | 20 | // Split-out header files. 21 | #include "MemAccess.h" 22 | #include "SADXModInfo.h" 23 | #include "SADXEnums.h" 24 | #include "SADXStructs.h" 25 | #include "SADXVariables.h" 26 | #include "SADXFunctions.h" 27 | #include "SADXEnumsNew.h" 28 | #include "SADXStructsNew.h" 29 | #include "SADXVariablesNew.h" 30 | #include "SADXFunctionsNew.h" 31 | 32 | static inline void ResizeTextureList(NJS_TEXLIST *texlist, Uint32 count) 33 | { 34 | texlist->textures = new NJS_TEXNAME[count] {}; 35 | texlist->nbTexture = count; 36 | } 37 | 38 | static inline void ResizeTextureList(NJS_TEXLIST *texlist, NJS_TEXNAME *textures, Uint32 count) 39 | { 40 | texlist->textures = textures; 41 | texlist->nbTexture = count; 42 | } 43 | 44 | template 45 | static inline void ResizeTextureList(NJS_TEXLIST *texlist, NJS_TEXNAME(&textures)[N]) 46 | { 47 | ResizeTextureList(texlist, textures, N); 48 | } 49 | 50 | #endif /* SADXMODLOADER_H */ 51 | -------------------------------------------------------------------------------- /SADXModLoader/include/ScaleInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace uiscale 4 | { 5 | /** 6 | * \brief Alignment of the canvas used for scaled UI elements. 7 | */ 8 | enum Align : Uint8 9 | { 10 | /** 11 | * \brief Use default alignment behavior (top left). 12 | */ 13 | Align_Default = 0, 14 | 15 | /** 16 | * \brief Align the canvas to the left side of the screen. 17 | */ 18 | Align_Left = 1 << 1, 19 | 20 | /** 21 | * \brief Align the canvas to the right side of the screen. 22 | */ 23 | Align_Right = 1 << 2, 24 | 25 | /** 26 | * \brief Align the canvas to the center of the screen horizontally. 27 | */ 28 | Align_Center_Horizontal = Align_Left | Align_Right, 29 | 30 | /** 31 | * \brief Automatically align the canvas to a horizontal third of the 32 | * screen based on the horizontal placement of the UI element. 33 | */ 34 | Align_Automatic_Horizontal = 1 << 3, 35 | 36 | /** 37 | * \brief Align the canvas to the top of the screen. 38 | */ 39 | Align_Top = 1 << 4, 40 | 41 | /** 42 | * \brief Align the canvas to the bottom of the screen. 43 | */ 44 | Align_Bottom = 1 << 5, 45 | 46 | /** 47 | * \brief Align the canvas to the center of the screen vertically. 48 | */ 49 | Align_Center_Vertical = Align_Top | Align_Bottom, 50 | 51 | /** 52 | * \brief Automatically align the canvas to a vertical third of the 53 | * screen based on the vertical placement of the UI element. 54 | */ 55 | Align_Automatic_Vertical = 1 << 6, 56 | 57 | /** 58 | * \brief Align the canvas to the center of the screen horizontally 59 | * and vertically. 60 | */ 61 | Align_Center = Align_Center_Horizontal | Align_Center_Vertical, 62 | 63 | /** 64 | * \brief Automatically align the canvas to horizontal and vertical thirds 65 | * of the screen based on the placement of the UI element. 66 | */ 67 | Align_Automatic = Align_Automatic_Horizontal | Align_Automatic_Vertical 68 | }; 69 | 70 | // The order of the values in this enum are important for ensuring 71 | // compatibility with the Mod Loader's configuration file. Do not 72 | // change these values without also updating the mod manager! 73 | enum FillMode : Uint8 74 | { 75 | /** 76 | * \brief Stretch the canvas to match the screen size. 77 | */ 78 | FillMode_Stretch = 0, 79 | 80 | /** 81 | * \brief Scale the canvas to the screen maintaining aspect ratio, 82 | * displaying letter or pillar boxes where necessary. 83 | */ 84 | FillMode_Fit = 1, 85 | 86 | /** 87 | * \brief Scale the canvas maintaining aspect ratio, and crops to 88 | * fill all edges of the screen to eliminate letter or pillar boxing. 89 | */ 90 | FillMode_Fill = 2 91 | }; 92 | } -------------------------------------------------------------------------------- /SADXModLoader/include/WeightInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ninja.h" 3 | 4 | struct WeightVertex 5 | { 6 | NJS_OBJECT* node; 7 | int nodeIndex; 8 | int vertex; 9 | float weight; 10 | }; 11 | 12 | struct WeightVertexList 13 | { 14 | int index; 15 | WeightVertex* vertices; 16 | int vertexCount; 17 | }; 18 | 19 | struct WeightNode 20 | { 21 | NJS_OBJECT* node; 22 | int nodeIndex; 23 | WeightVertexList* weights; 24 | int weightCount; 25 | NJS_VECTOR* vertices_orig; 26 | NJS_VECTOR* normals_orig; 27 | }; 28 | 29 | struct WeightInfo 30 | { 31 | WeightNode* nodes; 32 | int nodeCount; 33 | }; 34 | -------------------------------------------------------------------------------- /SADXModLoader/input.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DreamPad.h" 3 | #include 4 | 5 | namespace input 6 | { 7 | void poll_controllers(); 8 | void WriteAnalogs_hook(); 9 | void InitRawControllers_hook(); 10 | void __cdecl EnableController_r(Uint8 index); 11 | void __cdecl DisableController_r(Uint8 index); 12 | 13 | extern ControllerData raw_input[GAMEPAD_COUNT]; 14 | extern bool legacy_mode; // To be deleted 15 | extern bool controller_enabled[GAMEPAD_COUNT]; 16 | extern bool debug; 17 | extern bool disable_mouse; 18 | extern bool e_held; 19 | extern bool demo; 20 | extern KeyboardMapping keys; 21 | 22 | extern ushort keyboard_player_current; // Only in non-legacy mode 23 | } 24 | 25 | extern IniFile* config; // Only in non-legacy mode 26 | extern bool enabledSmoothCam; // Only in non-legacy mode 27 | 28 | void SDL2_Init(); 29 | void SDL2_OnExit(); 30 | void SDL2_OnInput(); -------------------------------------------------------------------------------- /SADXModLoader/jvList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IniFile.hpp" 4 | 5 | void FreeJVListIndices(); 6 | void SetNewWelds(uint8_t character, IniFile* file); 7 | -------------------------------------------------------------------------------- /SADXModLoader/minmax.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Force std::min/max instead for type consistency 4 | #include 5 | 6 | using std::min; 7 | using std::max; 8 | 9 | template 10 | constexpr T clamp(T value, T low, T high) 11 | { 12 | return min(max(low, value), high); 13 | } 14 | -------------------------------------------------------------------------------- /SADXModLoader/polybuff.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace polybuff 4 | { 5 | // These three variables are the parameters used to initialize the polybuff subsystem. 6 | // Used to re-initialize when the device resets (window resize etc). 7 | extern int alignment_probably; 8 | extern int count; 9 | extern void* ptr; 10 | 11 | void init(); 12 | void rewrite_init(); 13 | } 14 | -------------------------------------------------------------------------------- /SADXModLoader/prs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * https://github.com/essen/prsutil 3 | * 4 | * Archive of the original code from fuzziqer. No license was provided 5 | * with the released files, although fuzziqer stated using the source 6 | * freely was fine as long as he's credited for the compression and 7 | * decompression code. 8 | * 9 | * http://fuzziqer.10.forumer.com/viewtopic.php?t=110 10 | * 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | 19 | struct PRS_COMPRESSOR 20 | { 21 | uint8_t bitpos; 22 | //uint8_t controlbyte; 23 | uint8_t* controlbyteptr; 24 | uint8_t* srcptr_orig; 25 | uint8_t* dstptr_orig; 26 | uint8_t* srcptr; 27 | uint8_t* dstptr; 28 | }; 29 | 30 | void prs_put_control_bit(PRS_COMPRESSOR* pc, uint8_t bit); 31 | 32 | void prs_put_control_bit_nosave(PRS_COMPRESSOR* pc, uint8_t bit); 33 | 34 | void prs_put_control_save(PRS_COMPRESSOR* pc); 35 | 36 | void prs_put_static_data(PRS_COMPRESSOR* pc, uint8_t data); 37 | 38 | uint8_t prs_get_static_data(PRS_COMPRESSOR* pc); 39 | 40 | //////////////////////////////////////////////////////////////////////////////// 41 | 42 | void prs_init(PRS_COMPRESSOR* pc, void* src, void* dst); 43 | 44 | void prs_finish(PRS_COMPRESSOR* pc); 45 | 46 | void prs_rawbyte(PRS_COMPRESSOR* pc); 47 | 48 | void prs_shortcopy(PRS_COMPRESSOR* pc, int offset, uint8_t size); 49 | 50 | void prs_longcopy(PRS_COMPRESSOR* pc, int offset, uint8_t size); 51 | 52 | void prs_copy(PRS_COMPRESSOR* pc, int offset, uint8_t size); 53 | 54 | //////////////////////////////////////////////////////////////////////////////// 55 | 56 | uint32_t prs_compress(void* source, void* dest, uint32_t size); 57 | 58 | //////////////////////////////////////////////////////////////////////////////// 59 | 60 | uint32_t prs_decompress(void* source, void* dest); // 800F7CB0 through 800F7DE4 in mem 61 | 62 | uint32_t prs_decompress_size(void* source); 63 | -------------------------------------------------------------------------------- /SADXModLoader/pvmx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "pvmx.h" 10 | 11 | #pragma region convenience 12 | 13 | template 14 | auto& write_t(std::ofstream& file, const T& data) 15 | { 16 | return file.write(reinterpret_cast(&data), sizeof(T)); 17 | } 18 | 19 | template 20 | auto& read_t(std::ifstream& file, T& data) 21 | { 22 | return file.read(reinterpret_cast(&data), sizeof(T)); 23 | } 24 | 25 | void read_cstr(std::ifstream& file, std::string& out) 26 | { 27 | std::stringstream buffer; 28 | 29 | while (true) 30 | { 31 | auto c = '\0'; 32 | read_t(file, c); 33 | 34 | if (c == '\0') 35 | { 36 | break; 37 | } 38 | 39 | buffer.put(c); 40 | } 41 | 42 | out = buffer.str(); 43 | } 44 | 45 | #pragma endregion 46 | 47 | namespace pvmx 48 | { 49 | bool check_header(std::ifstream& file) 50 | { 51 | if (!file.is_open()) 52 | { 53 | return false; 54 | } 55 | 56 | int fourcc; 57 | read_t(file, fourcc); 58 | 59 | if (fourcc != PVMX_FOURCC) 60 | { 61 | return false; 62 | } 63 | 64 | uint8_t version; 65 | read_t(file, version); 66 | 67 | return version == PVMX_VERSION; 68 | } 69 | 70 | bool is_pvmx(std::ifstream& file) 71 | { 72 | if (!file.is_open()) 73 | { 74 | return false; 75 | } 76 | 77 | const auto pos = file.tellg(); 78 | const auto result = check_header(file); 79 | file.seekg(pos); 80 | 81 | return result; 82 | } 83 | 84 | bool is_pvmx(const char* path) 85 | { 86 | std::ifstream file(path, std::ios::binary | std::ios::in); 87 | return check_header(file); 88 | } 89 | 90 | bool is_pvmx(const std::string& path) 91 | { 92 | return is_pvmx(path.c_str()); 93 | } 94 | 95 | bool read_index(std::ifstream& file, std::vector& out) 96 | { 97 | const auto pos = file.tellg(); 98 | 99 | if (!check_header(file)) 100 | { 101 | file.seekg(pos); 102 | return false; 103 | } 104 | 105 | uint8_t type = 0; 106 | 107 | for (read_t(file, type); type != dictionary_field::none; read_t(file, type)) 108 | { 109 | DictionaryEntry entry = {}; 110 | 111 | while (type != dictionary_field::none) 112 | { 113 | switch (type) 114 | { 115 | case dictionary_field::none: 116 | break; 117 | 118 | case dictionary_field::global_index: 119 | read_t(file, entry.global_index); 120 | break; 121 | 122 | case dictionary_field::name: 123 | read_cstr(file, entry.name); 124 | break; 125 | 126 | case dictionary_field::dimensions: 127 | read_t(file, entry.width); 128 | read_t(file, entry.height); 129 | break; 130 | 131 | // Unknown field type. 132 | default: 133 | return false; 134 | } 135 | 136 | read_t(file, type); 137 | } 138 | 139 | read_t(file, entry.offset); 140 | read_t(file, entry.size); 141 | 142 | out.push_back(entry); 143 | } 144 | 145 | return true; 146 | } 147 | 148 | bool get_entry(std::ifstream& file, const DictionaryEntry& entry, std::vector& out) 149 | { 150 | if (!file.is_open()) 151 | { 152 | return false; 153 | } 154 | 155 | out.resize(static_cast(entry.size)); 156 | 157 | const auto pos = static_cast(file.tellg()); 158 | file.read(reinterpret_cast(out.data()), out.size()); 159 | 160 | const auto delta = static_cast(file.tellg()) - pos; 161 | 162 | if (delta != entry.size) 163 | { 164 | out.clear(); 165 | return false; 166 | } 167 | 168 | return true; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /SADXModLoader/pvmx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "TextureReplacement.h" 7 | 8 | constexpr uint32_t PVMX_FOURCC = 'XMVP'; 9 | constexpr uint8_t PVMX_VERSION = 1; 10 | 11 | namespace pvmx 12 | { 13 | struct DictionaryEntry : TexPackEntry 14 | { 15 | uint64_t offset; 16 | uint64_t size; 17 | }; 18 | 19 | namespace dictionary_field 20 | { 21 | enum _ : uint8_t 22 | { 23 | none, 24 | /** 25 | * \brief 32-bit integer global index 26 | */ 27 | global_index, 28 | /** 29 | * \brief Null-terminated file name 30 | */ 31 | name, 32 | /** 33 | * \brief Two 32-bit integers defining width and height 34 | */ 35 | dimensions, 36 | }; 37 | 38 | static_assert(sizeof(none) == sizeof(uint8_t), "dictionary_field size mismatch"); 39 | } 40 | 41 | /** 42 | * \brief Checks the header of the provided file and restores the stream position. 43 | * \param file An open stream of the file to check. 44 | * \return \c true if the file is a PVMX archive. 45 | */ 46 | bool is_pvmx(std::ifstream& file); 47 | 48 | /** 49 | * \brief Checks the header of the provided file and restores the stream position. 50 | * \param path A valid path to the file to be checked. 51 | * \return \c true if the file is a PVMX archive. 52 | */ 53 | bool is_pvmx(const char* path); 54 | 55 | /** 56 | * \brief Checks the header of the provided file and restores the stream position. 57 | * \param path A valid path to the file to be checked. 58 | * \return \c true if the file is a PVMX archive. 59 | */ 60 | bool is_pvmx(const std::string& path); 61 | 62 | /** 63 | * \brief Same as \a is_pvmx, but does not restore the stream position. 64 | * \param file An open stream of the file to check. 65 | * \return \c true if the file is a PVMX archive. 66 | */ 67 | bool check_header(std::ifstream& file); 68 | 69 | /** 70 | * \brief Reads the texture pack index from the given PVMX archive. 71 | * \param file The file to read from. 72 | * \param out A vector to be populated with the texture pack index. 73 | * \return \c true on success. 74 | */ 75 | bool read_index(std::ifstream& file, std::vector& out); 76 | 77 | /** 78 | * \brief Reads a texture entry into the provided buffer. 79 | * \param file The file to read from. 80 | * \param entry The entry whose data is to be read. 81 | * \param out The buffer to store the data. 82 | * \return \c true on success. 83 | */ 84 | bool get_entry(std::ifstream& file, const DictionaryEntry& entry, std::vector& out); 85 | } 86 | -------------------------------------------------------------------------------- /SADXModLoader/resource.h: -------------------------------------------------------------------------------- 1 | /** 2 | * SADX Mod Loader 3 | * Win32 resource script. 4 | */ 5 | 6 | #ifndef SADXMODLOADER_RESOURCE_H 7 | #define SADXMODLOADER_RESOURCE_H 8 | 9 | // Accelerator table for the wrapper window. 10 | #define IDR_ACCEL_WRAPPER_WINDOW 101 11 | #define ID_FULLSCREEN 40001 12 | 13 | #endif /* SADXMODLOADER_RESOURCE_H */ 14 | -------------------------------------------------------------------------------- /SADXModLoader/rumble.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "DreamPad.h" 4 | 5 | namespace rumble 6 | { 7 | //FunctionPointer(Sint32, pdVibMxStart, (Uint32 port, const PDS_VIBPARAM *a2), 0x00785280); 8 | FunctionPointer(Sint32, pdVibMxStop, (Uint32 port), 0x00785330); 9 | 10 | Sint32 __cdecl pdVibMxStop_r(Uint32 port); 11 | void __cdecl Rumble_Load_hook(Uint32 port, Uint32 time, Motor motor); 12 | void __cdecl RumbleA_r(Uint32 port, Uint32 time); 13 | void __cdecl RumbleB_r(Uint32 port, Uint32 time, int a3, int a4); 14 | void default_rumble(); 15 | } -------------------------------------------------------------------------------- /SADXModLoader/sound.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Sound_Init(int sevolume); 4 | -------------------------------------------------------------------------------- /SADXModLoader/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SADXModLoader.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /SADXModLoader/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | 12 | // Windows Header Files: 13 | #include 14 | 15 | // C 16 | #include 17 | 18 | // C (C++ namespace) 19 | #include 20 | #include 21 | 22 | // C++ 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "direct3d.h" 37 | #include "ninja.h" 38 | #include "SADXModLoader.h" 39 | #include "Events.h" 40 | #include "FileReplacement.h" 41 | #include "Trampoline.h" 42 | #include "FileSystem.h" 43 | #include "pvmx.h" 44 | #include "prs.h" 45 | #include "polybuff.h" 46 | #include "uiscale.h" 47 | #include "hudscale.h" 48 | #include "bgscale.h" 49 | #include "FunctionHook.h" 50 | 51 | #if defined(_MSC_VER) && _MSC_VER < 1900 52 | #define snprintf _snprintf 53 | #endif 54 | -------------------------------------------------------------------------------- /SADXModLoader/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #define _WIN32_WINNT _WIN32_WINNT_WINXP 9 | #define WINVER _WIN32_WINNT_WINXP -------------------------------------------------------------------------------- /SADXModLoader/testspawn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ProcessTestSpawn(const HelperFunctions& helperFunctions); 4 | void ApplyTestSpawn(); -------------------------------------------------------------------------------- /SADXModLoader/typedefs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // Shorthand for unsigned standard types (unsigned x -> ux) 6 | 7 | using uchar = unsigned char; 8 | using ushort = unsigned short; 9 | using uint = unsigned int; 10 | using ulong = unsigned long; 11 | 12 | // Integer by bit count (char -> int8) 13 | 14 | using int8 = int8_t; 15 | using int16 = int16_t; 16 | using int32 = int32_t; 17 | using int64 = int64_t; 18 | using uint8 = uint8_t; 19 | using uint16 = uint16_t; 20 | using uint32 = uint32_t; 21 | using uint64 = uint64_t; -------------------------------------------------------------------------------- /SADXModLoader/uiscale.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ScaleInfo.h" 5 | #include "../include/ninja.h" 6 | 7 | namespace uiscale 8 | { 9 | extern FillMode bg_fill; 10 | extern FillMode fmv_fill; 11 | 12 | /** 13 | * \brief The minimum of the horizontal and vertical scale factors. 14 | */ 15 | extern float scale_min; 16 | 17 | /** 18 | * \brief The maximum of the horizontal and vertical scale factors. 19 | */ 20 | extern float scale_max; 21 | 22 | /** 23 | * \brief Horizontal UI scale factor relative to 640x480. 24 | */ 25 | extern float scale_h; 26 | 27 | /** 28 | * \brief Vertical UI scale factor relative to 640x480. 29 | */ 30 | extern float scale_v; 31 | 32 | void update_parameters(); 33 | void initialize_common(); 34 | void initialize(); 35 | void setup_background_scale(); 36 | void setup_fmv_scale(); 37 | bool is_top_background(); 38 | bool is_scale_enabled(); 39 | void scale_texmemlist(NJS_TEXTURE_VTX* list, Int count); 40 | 41 | /** 42 | * \brief Push a UI scale element onto the scale stack. 43 | * \param align Combination of \sa Align bits to align the next drawn UI elements. 44 | * \param is_background If \c true, treat the drawn elements as backgrounds. 45 | * \param h The horizontal reference scale to use for UI rendering. When in doubt, leave as \c 1.0f 46 | * \param v The vertical reference scale to use for UI rendering. When in doubt, leave as \c 1.0f 47 | */ 48 | void scale_push(Uint8 align, bool is_background, float h = 1.0f, float v = 1.0f); 49 | 50 | /** 51 | * \brief Disable UI scaling for the next drawn UI element. 52 | * Must have matching call to scale_enable() 53 | */ 54 | void scale_disable(); 55 | 56 | /** 57 | * \brief Enable UI scaling for the next drawn UI element. 58 | */ 59 | void scale_enable(); 60 | 61 | /** 62 | * \brief Pop a UI scale element off of the top of the scale stack. 63 | */ 64 | void scale_pop(); 65 | 66 | /** 67 | * \brief Get the current uniform scale factor for UI elements. 68 | */ 69 | float get_scale(); 70 | 71 | /** 72 | * \brief Check that the stack has been emptied at the end of a frame. 73 | */ 74 | void check_stack_balance(); 75 | 76 | /** 77 | * \brief Calls a function with UI scaling enabled. 78 | * \tparam T Function type. 79 | * \tparam Args Optional arguments for the function. 80 | * \param align Alignment mode. 81 | * \param is_background Enables background scaling mode. 82 | * \param pfn The function to call. 83 | * \param args Optional arguments for the function. 84 | */ 85 | template 86 | auto scale_function(Uint8 align, bool is_background, T* const pfn, Args ... args) 87 | { 88 | constexpr bool return_void = std::is_void>::value; 89 | 90 | if (is_background && bg_fill == FillMode_Stretch) 91 | { 92 | scale_disable(); 93 | 94 | if constexpr (return_void) 95 | { 96 | pfn(args...); 97 | scale_enable(); 98 | return; 99 | } 100 | else 101 | { 102 | typename std::invoke_result::type result = pfn(args...); 103 | scale_enable(); 104 | return result; 105 | } 106 | } 107 | 108 | scale_push(align, is_background); 109 | 110 | if constexpr (return_void) 111 | { 112 | pfn(args...); 113 | scale_pop(); 114 | } 115 | else 116 | { 117 | typename std::invoke_result::type result = pfn(args...); 118 | scale_pop(); 119 | return result; 120 | } 121 | } 122 | 123 | /** 124 | * \brief Calls a trampoline function with UI scaling enabled. 125 | * \tparam T Function type. 126 | * \tparam Args Optional arguments for the function. 127 | * \param align Alignment mode. 128 | * \param is_background Enables background scaling mode. 129 | * \param t Trampoline 130 | * \param args Optional arguments for the function. 131 | */ 132 | template 133 | auto scale_trampoline(Uint8 align, bool is_background, const T&, const Trampoline* t, Args ... args) 134 | { 135 | T* const pfn = reinterpret_cast(t->Target()); 136 | return scale_function(align, is_background, pfn, args...); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /SADXModLoader/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern LoaderSettings loaderSettings; 4 | extern std::wstring currentProfilePath; 5 | bool IsGamePatchEnabled(const char* patchName); -------------------------------------------------------------------------------- /SADXModLoader/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Current version. 4 | // Make sure this is updated before every release! 5 | #define VERSION_MAJOR 3 6 | #define VERSION_MINOR 7 7 | #define VERSION_BUILD 0 8 | #define VERSION_REVISION 0 9 | //#define VERSION_PRERELEASE 1 10 | 11 | #define STRINGIFY(x) #x 12 | #define TOSTRING(x) STRINGIFY(x) 13 | 14 | #define makeverstr(major,minor) STRINGIFY(major) "." STRINGIFY(minor) 15 | 16 | #define VERSION_STRING makeverstr(VERSION_MAJOR, VERSION_MINOR) 17 | #define VERSION_WIN32 VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD,VERSION_REVISION 18 | -------------------------------------------------------------------------------- /SADXModLoader/video.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | Bool PauseVideo(); 4 | Bool ResumeVideo(); 5 | void Video_Init(const LoaderSettings& settings, const std::wstring& borderpath); -------------------------------------------------------------------------------- /SADXModLoader/window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern HINSTANCE g_hinstDll; 4 | extern wstring iconPathName; 5 | 6 | void PatchWindow(const LoaderSettings& settings); 7 | void SetBorderImage(std::wstring path); -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | pull_requests: 3 | do_not_increment_build_number: true 4 | branches: 5 | only: 6 | - master 7 | skip_tags: true 8 | image: Visual Studio 2019 9 | configuration: Release 10 | platform: x86 11 | init: 12 | - cmd: >- 13 | choco install wget --version 1.20 14 | 15 | cd \ 16 | 17 | wget -np --no-parent -nH --cut-dirs 4 -nc "https://dcmods.unreliable.network/owncloud/data/PiKeyAr/files/Various/dx81sdk.7z" 18 | 19 | 7z x dx81sdk.7z -o"C:\Program Files (x86)\DirectX 8.1 SDK" 20 | 21 | cd C:\projects\sadx-mod-loader 22 | before_build: 23 | - cmd: git submodule update --init --recursive 24 | build: 25 | project: SADXModLoader.sln 26 | verbosity: minimal 27 | after_build: 28 | - cmd: >- 29 | mkdir C:\sadxmm 30 | 31 | mkdir C:\sadxmm\extlib 32 | 33 | mkdir C:\sadxmm\extlib\BASS 34 | 35 | mkdir C:\sadxmm\extlib\D3D8M 36 | 37 | mkdir C:\sadxmm\extlib\d3d8to11 38 | 39 | mkdir C:\sadxmm\extlib\SDL2 40 | 41 | copy C:\projects\sadx-mod-loader\bin\SADXModLoader.dll C:\sadxmm\SADXModLoader.dll 42 | 43 | copy C:\projects\sadx-mod-loader\data\*.* C:\sadxmm\ 44 | 45 | copy C:\projects\sadx-mod-loader\extlib\bass\*.dll C:\sadxmm\extlib\BASS\ 46 | 47 | copy C:\projects\sadx-mod-loader\extlib\d3d8to9\d3d8.dll C:\sadxmm\extlib\D3D8M\d3d8m.dll 48 | 49 | copy C:\projects\sadx-mod-loader\extlib\d3d8to11\*.* C:\sadxmm\extlib\d3d8to11\*.* 50 | 51 | copy C:\projects\sadx-mod-loader\extlib\SDL2\lib\x86\*.dll C:\sadxmm\extlib\SDL2\ 52 | 53 | echo | set /p dummyName="%APPVEYOR_BUILD_VERSION%" > "C:\sadxmm\sadxmlver.txt" 54 | 55 | 7z a C:\projects\sadx-mod-loader\bin\SADXModLoader.7z C:\sadxmm\* 56 | artifacts: 57 | - path: bin\SADXModLoader.7z 58 | 59 | - path: bin\SADXModLoader.pdb 60 | 61 | before_deploy: 62 | - ps: |- 63 | if (!$env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED) { 64 | $env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED = "$env:APPVEYOR_REPO_COMMIT_MESSAGE" 65 | } 66 | 67 | deploy: 68 | - provider: GitHub 69 | description: $(APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED) 70 | auth_token: 71 | secure: 3U0hYOvkeEJsoN2b4U/c9RTDxjcj9txunvCbWfkg5qvOSB1qOnh4fnIE9EK5yAXi2m8RJMO4Zr/UqiVMB9CDPulfPRcJSJ83rsmh1EXBipUs4K/RQmQHaDG6UiiNQ1Xg 72 | artifact: bin/SADXModLoader.7z,bin/SADXModLoader.pdb 73 | on: 74 | branch: master -------------------------------------------------------------------------------- /data/Border_Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/data/Border_Default.png -------------------------------------------------------------------------------- /extlib/ModLoaders/SADXModLoader.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/ModLoaders/SADXModLoader.dll -------------------------------------------------------------------------------- /extlib/SDL2/cmake/sdl2-config-version.cmake: -------------------------------------------------------------------------------- 1 | # based on the files generated by CMake's write_basic_package_version_file 2 | 3 | # SDL2 CMake version configuration file: 4 | # This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-VC 5 | 6 | if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL_version.h") 7 | message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the root of SDL2-devel-2.x.y-VC") 8 | return() 9 | endif() 10 | 11 | file(READ "${CMAKE_CURRENT_LIST_DIR}/../include/SDL_version.h" _sdl_version_h) 12 | string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}") 13 | set(_sdl_major "${CMAKE_MATCH_1}") 14 | string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}") 15 | set(_sdl_minor "${CMAKE_MATCH_1}") 16 | string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}") 17 | set(_sdl_patch "${CMAKE_MATCH_1}") 18 | if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re) 19 | set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}") 20 | else() 21 | message(AUTHOR_WARNING "Could not extract version from SDL_version.h.") 22 | return() 23 | endif() 24 | 25 | if(PACKAGE_FIND_VERSION_RANGE) 26 | # Package version must be in the requested version range 27 | if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) 28 | OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) 29 | OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) 30 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 31 | else() 32 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 33 | endif() 34 | else() 35 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 36 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 37 | else() 38 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 39 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 40 | set(PACKAGE_VERSION_EXACT TRUE) 41 | endif() 42 | endif() 43 | endif() 44 | 45 | # if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail. 46 | if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") 47 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 48 | endif() 49 | 50 | # check that the installed version has the same 32/64bit-ness as the one which is currently searching: 51 | if(NOT (CMAKE_SIZEOF_VOID_P STREQUAL "8" OR CMAKE_SIZEOF_VOID_P STREQUAL "4")) 52 | set(PACKAGE_VERSION "${PACKAGE_VERSION} (32+64bit)") 53 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 54 | endif() 55 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * # CategoryBits 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef SDL_bits_h_ 29 | #define SDL_bits_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return the index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | #if defined(__WATCOMC__) && defined(__386__) 51 | extern __inline int _SDL_bsr_watcom(Uint32); 52 | #pragma aux _SDL_bsr_watcom = \ 53 | "bsr eax, eax" \ 54 | parm [eax] nomemory \ 55 | value [eax] \ 56 | modify exact [eax] nomemory; 57 | #endif 58 | 59 | /** 60 | * Use this function to get the index of the most significant (set) bit in a 61 | * 62 | * \param x the number to find the MSB of. 63 | * \returns the index of the most significant bit of x, or -1 if x is 0. 64 | */ 65 | SDL_FORCE_INLINE int 66 | SDL_MostSignificantBitIndex32(Uint32 x) 67 | { 68 | #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 69 | /* Count Leading Zeroes builtin in GCC. 70 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 71 | */ 72 | if (x == 0) { 73 | return -1; 74 | } 75 | return 31 - __builtin_clz(x); 76 | #elif defined(__WATCOMC__) && defined(__386__) 77 | if (x == 0) { 78 | return -1; 79 | } 80 | return _SDL_bsr_watcom(x); 81 | #elif defined(_MSC_VER) 82 | unsigned long index; 83 | if (_BitScanReverse(&index, x)) { 84 | return index; 85 | } 86 | return -1; 87 | #else 88 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 89 | * , released in the public domain. 90 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 91 | */ 92 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 93 | const int S[] = {1, 2, 4, 8, 16}; 94 | 95 | int msbIndex = 0; 96 | int i; 97 | 98 | if (x == 0) { 99 | return -1; 100 | } 101 | 102 | for (i = 4; i >= 0; i--) 103 | { 104 | if (x & b[i]) 105 | { 106 | x >>= S[i]; 107 | msbIndex |= S[i]; 108 | } 109 | } 110 | 111 | return msbIndex; 112 | #endif 113 | } 114 | 115 | SDL_FORCE_INLINE SDL_bool 116 | SDL_HasExactlyOneBitSet32(Uint32 x) 117 | { 118 | if (x && !(x & (x - 1))) { 119 | return SDL_TRUE; 120 | } 121 | return SDL_FALSE; 122 | } 123 | 124 | /* Ends C function definitions when using C++ */ 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | #include "close_code.h" 129 | 130 | #endif /* SDL_bits_h_ */ 131 | 132 | /* vi: set ts=4 sw=4 expandtab: */ 133 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_h_ 23 | #define SDL_config_h_ 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* WIKI CATEGORY: - */ 28 | 29 | /* Add any platform that doesn't build using the configure system. */ 30 | #if defined(__WIN32__) 31 | #include "SDL_config_windows.h" 32 | #elif defined(__WINRT__) 33 | #include "SDL_config_winrt.h" 34 | #elif defined(__WINGDK__) 35 | #include "SDL_config_wingdk.h" 36 | #elif defined(__XBOXONE__) || defined(__XBOXSERIES__) 37 | #include "SDL_config_xbox.h" 38 | #elif defined(__MACOSX__) 39 | #include "SDL_config_macosx.h" 40 | #elif defined(__IPHONEOS__) 41 | #include "SDL_config_iphoneos.h" 42 | #elif defined(__ANDROID__) 43 | #include "SDL_config_android.h" 44 | #elif defined(__OS2__) 45 | #include "SDL_config_os2.h" 46 | #elif defined(__EMSCRIPTEN__) 47 | #include "SDL_config_emscripten.h" 48 | #elif defined(__NGAGE__) 49 | #include "SDL_config_ngage.h" 50 | #else 51 | /* This is a minimal configuration just to get SDL running on new platforms. */ 52 | #include "SDL_config_minimal.h" 53 | #endif /* platform config */ 54 | 55 | #ifdef USING_GENERATED_CONFIG_H 56 | #error Wrong SDL_config.h, check your include path? 57 | #endif 58 | 59 | #endif /* SDL_config_h_ */ 60 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_config_minimal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_minimal_h_ 23 | #define SDL_config_minimal_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | /** 29 | * \file SDL_config_minimal.h 30 | * 31 | * This is the minimal configuration that can be used to build SDL. 32 | */ 33 | 34 | #define HAVE_STDARG_H 1 35 | #define HAVE_STDDEF_H 1 36 | 37 | #if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_) 38 | /* Most everything except Visual Studio 2008 and earlier has stdint.h now */ 39 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 40 | typedef signed __int8 int8_t; 41 | typedef unsigned __int8 uint8_t; 42 | typedef signed __int16 int16_t; 43 | typedef unsigned __int16 uint16_t; 44 | typedef signed __int32 int32_t; 45 | typedef unsigned __int32 uint32_t; 46 | typedef signed __int64 int64_t; 47 | typedef unsigned __int64 uint64_t; 48 | #ifndef _UINTPTR_T_DEFINED 49 | #ifdef _WIN64 50 | typedef unsigned __int64 uintptr_t; 51 | #else 52 | typedef unsigned int uintptr_t; 53 | #endif 54 | #define _UINTPTR_T_DEFINED 55 | #endif 56 | #else 57 | #define HAVE_STDINT_H 1 58 | #endif /* Visual Studio 2008 */ 59 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 60 | 61 | #ifdef __GNUC__ 62 | #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 63 | #endif 64 | 65 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 66 | #define SDL_AUDIO_DRIVER_DUMMY 1 67 | 68 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 69 | #define SDL_JOYSTICK_DISABLED 1 70 | 71 | /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ 72 | #define SDL_HAPTIC_DISABLED 1 73 | 74 | /* Enable the stub HIDAPI */ 75 | #define SDL_HIDAPI_DISABLED 1 76 | 77 | /* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ 78 | #define SDL_SENSOR_DISABLED 1 79 | 80 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 81 | #define SDL_LOADSO_DISABLED 1 82 | 83 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 84 | #define SDL_THREADS_DISABLED 1 85 | 86 | /* Enable the stub timer support (src/timer/dummy/\*.c) */ 87 | #define SDL_TIMERS_DISABLED 1 88 | 89 | /* Enable the dummy video driver (src/video/dummy/\*.c) */ 90 | #define SDL_VIDEO_DRIVER_DUMMY 1 91 | 92 | /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ 93 | #define SDL_FILESYSTEM_DUMMY 1 94 | 95 | #endif /* SDL_config_minimal_h_ */ 96 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_config_ngage.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_ngage_h_ 23 | #define SDL_config_ngage_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | typedef signed char int8_t; 29 | typedef unsigned char uint8_t; 30 | typedef signed short int16_t; 31 | typedef unsigned short uint16_t; 32 | typedef signed int int32_t; 33 | typedef unsigned int uint32_t; 34 | typedef signed long long int64_t; 35 | typedef unsigned long long uint64_t; 36 | typedef unsigned long uintptr_t; 37 | 38 | #define HAVE_STDARG_H 1 39 | #define HAVE_STDDEF_H 1 40 | #define HAVE_STDIO_H 1 41 | #define HAVE_STDLIB_H 1 42 | #define HAVE_MATH_H 1 43 | #define HAVE_CEIL 1 44 | #define HAVE_COPYSIGN 1 45 | #define HAVE_COS 1 46 | #define HAVE_EXP 1 47 | #define HAVE_FABS 1 48 | #define HAVE_FLOOR 1 49 | #define HAVE_LOG 1 50 | #define HAVE_LOG10 1 51 | #define HAVE_SCALBN 1 52 | #define HAVE_SIN 1 53 | #define HAVE_SQRT 1 54 | #define HAVE_TAN 1 55 | #define HAVE_MALLOC 1 56 | #define SDL_MAIN_NEEDED 1 57 | #define LACKS_SYS_MMAN_H 1 58 | 59 | /* Enable the N-Gage thread support (src/thread/ngage/\*.c) */ 60 | #define SDL_THREAD_NGAGE 1 61 | 62 | /* Enable the N-Gage timer support (src/timer/ngage/\*.c) */ 63 | #define SDL_TIMER_NGAGE 1 64 | 65 | /* Enable the N-Gage video driver (src/video/ngage/\*.c) */ 66 | #define SDL_VIDEO_DRIVER_NGAGE 1 67 | 68 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 69 | #define SDL_AUDIO_DRIVER_DUMMY 1 70 | 71 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 72 | #define SDL_JOYSTICK_DISABLED 1 73 | 74 | /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ 75 | #define SDL_HAPTIC_DISABLED 1 76 | 77 | /* Enable the stub HIDAPI */ 78 | #define SDL_HIDAPI_DISABLED 1 79 | 80 | /* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ 81 | #define SDL_SENSOR_DISABLED 1 82 | 83 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 84 | #define SDL_LOADSO_DISABLED 1 85 | 86 | /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ 87 | #define SDL_FILESYSTEM_DUMMY 1 88 | 89 | #endif /* SDL_config_ngage_h_ */ 90 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_config_pandora.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_pandora_h_ 23 | #define SDL_config_pandora_h_ 24 | #define SDL_config_h_ 25 | 26 | /* This is a set of defines to configure the SDL features */ 27 | 28 | /* General platform specific identifiers */ 29 | #include "SDL_platform.h" 30 | 31 | #ifdef __LP64__ 32 | #define SIZEOF_VOIDP 8 33 | #else 34 | #define SIZEOF_VOIDP 4 35 | #endif 36 | 37 | #define SDL_BYTEORDER 1234 38 | 39 | #define STDC_HEADERS 1 40 | #define HAVE_ALLOCA_H 1 41 | #define HAVE_CTYPE_H 1 42 | #define HAVE_ICONV_H 1 43 | #define HAVE_INTTYPES_H 1 44 | #define HAVE_LIMITS_H 1 45 | #define HAVE_MALLOC_H 1 46 | #define HAVE_MATH_H 1 47 | #define HAVE_MEMORY_H 1 48 | #define HAVE_SIGNAL_H 1 49 | #define HAVE_STDARG_H 1 50 | #define HAVE_STDINT_H 1 51 | #define HAVE_STDIO_H 1 52 | #define HAVE_STDLIB_H 1 53 | #define HAVE_STRINGS_H 1 54 | #define HAVE_STRING_H 1 55 | #define HAVE_SYS_TYPES_H 1 56 | 57 | #define HAVE_DLOPEN 1 58 | #define HAVE_MALLOC 1 59 | #define HAVE_CALLOC 1 60 | #define HAVE_REALLOC 1 61 | #define HAVE_FREE 1 62 | #define HAVE_ALLOCA 1 63 | #define HAVE_GETENV 1 64 | #define HAVE_SETENV 1 65 | #define HAVE_PUTENV 1 66 | #define HAVE_UNSETENV 1 67 | #define HAVE_QSORT 1 68 | #define HAVE_BSEARCH 1 69 | #define HAVE_ABS 1 70 | #define HAVE_BCOPY 1 71 | #define HAVE_MEMSET 1 72 | #define HAVE_MEMCPY 1 73 | #define HAVE_MEMMOVE 1 74 | #define HAVE_STRLEN 1 75 | #define HAVE_STRCHR 1 76 | #define HAVE_STRRCHR 1 77 | #define HAVE_STRSTR 1 78 | #define HAVE_STRTOL 1 79 | #define HAVE_STRTOUL 1 80 | #define HAVE_STRTOLL 1 81 | #define HAVE_STRTOULL 1 82 | #define HAVE_ATOI 1 83 | #define HAVE_ATOF 1 84 | #define HAVE_STRCMP 1 85 | #define HAVE_STRNCMP 1 86 | #define HAVE_STRCASECMP 1 87 | #define HAVE_STRNCASECMP 1 88 | #define HAVE_VSSCANF 1 89 | #define HAVE_VSNPRINTF 1 90 | #define HAVE_M_PI 1 91 | #define HAVE_CEIL 1 92 | #define HAVE_COPYSIGN 1 93 | #define HAVE_COS 1 94 | #define HAVE_COSF 1 95 | #define HAVE_EXP 1 96 | #define HAVE_FABS 1 97 | #define HAVE_FLOOR 1 98 | #define HAVE_LOG 1 99 | #define HAVE_LOG10 1 100 | #define HAVE_LROUND 1 101 | #define HAVE_LROUNDF 1 102 | #define HAVE_ROUND 1 103 | #define HAVE_ROUNDF 1 104 | #define HAVE_SCALBN 1 105 | #define HAVE_SIN 1 106 | #define HAVE_SINF 1 107 | #define HAVE_SQRT 1 108 | #define HAVE_SQRTF 1 109 | #define HAVE_TAN 1 110 | #define HAVE_TANF 1 111 | #define HAVE_TRUNC 1 112 | #define HAVE_TRUNCF 1 113 | #define HAVE_SIGACTION 1 114 | #define HAVE_SETJMP 1 115 | #define HAVE_NANOSLEEP 1 116 | 117 | #define SDL_AUDIO_DRIVER_DUMMY 1 118 | #define SDL_AUDIO_DRIVER_OSS 1 119 | 120 | #define SDL_INPUT_LINUXEV 1 121 | #define SDL_JOYSTICK_LINUX 1 122 | #define SDL_JOYSTICK_VIRTUAL 1 123 | #define SDL_HAPTIC_LINUX 1 124 | 125 | #define SDL_SENSOR_DUMMY 1 126 | 127 | #define SDL_LOADSO_DLOPEN 1 128 | 129 | #define SDL_THREAD_PTHREAD 1 130 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 131 | 132 | #define SDL_TIMER_UNIX 1 133 | #define SDL_FILESYSTEM_UNIX 1 134 | 135 | #define SDL_VIDEO_DRIVER_DUMMY 1 136 | #define SDL_VIDEO_DRIVER_X11 1 137 | #define SDL_VIDEO_DRIVER_PANDORA 1 138 | #define SDL_VIDEO_RENDER_OGL_ES 1 139 | #define SDL_VIDEO_OPENGL_ES 1 140 | 141 | #endif /* SDL_config_pandora_h_ */ 142 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * # CategoryGesture 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef SDL_gesture_h_ 29 | #define SDL_gesture_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * Begin recording a gesture on a specified touch device or all touch devices. 50 | * 51 | * If the parameter `touchId` is -1 (i.e., all devices), this function will 52 | * always return 1, regardless of whether there actually are any devices. 53 | * 54 | * \param touchId the touch device id, or -1 for all touch devices. 55 | * \returns 1 on success or 0 if the specified device could not be found. 56 | * 57 | * \since This function is available since SDL 2.0.0. 58 | * 59 | * \sa SDL_GetTouchDevice 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 62 | 63 | 64 | /** 65 | * Save all currently loaded Dollar Gesture templates. 66 | * 67 | * \param dst a SDL_RWops to save to. 68 | * \returns the number of saved templates on success or 0 on failure; call 69 | * SDL_GetError() for more information. 70 | * 71 | * \since This function is available since SDL 2.0.0. 72 | * 73 | * \sa SDL_LoadDollarTemplates 74 | * \sa SDL_SaveDollarTemplate 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 77 | 78 | /** 79 | * Save a currently loaded Dollar Gesture template. 80 | * 81 | * \param gestureId a gesture id. 82 | * \param dst a SDL_RWops to save to. 83 | * \returns 1 on success or 0 on failure; call SDL_GetError() for more 84 | * information. 85 | * 86 | * \since This function is available since SDL 2.0.0. 87 | * 88 | * \sa SDL_LoadDollarTemplates 89 | * \sa SDL_SaveAllDollarTemplates 90 | */ 91 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 92 | 93 | 94 | /** 95 | * Load Dollar Gesture templates from a file. 96 | * 97 | * \param touchId a touch id. 98 | * \param src a SDL_RWops to load from. 99 | * \returns the number of loaded templates on success or a negative error code 100 | * (or 0) on failure; call SDL_GetError() for more information. 101 | * 102 | * \since This function is available since SDL 2.0.0. 103 | * 104 | * \sa SDL_SaveAllDollarTemplates 105 | * \sa SDL_SaveDollarTemplate 106 | */ 107 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 108 | 109 | /* Ends C function definitions when using C++ */ 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | #include "close_code.h" 114 | 115 | #endif /* SDL_gesture_h_ */ 116 | 117 | /* vi: set ts=4 sw=4 expandtab: */ 118 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_guid.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* WIKI CATEGORY: GUID */ 23 | 24 | /** 25 | * # CategoryGUID 26 | * 27 | * A GUID is a 128-bit value that represents something that is uniquely 28 | * identifiable by this value: "globally unique." 29 | */ 30 | 31 | #ifndef SDL_guid_h_ 32 | #define SDL_guid_h_ 33 | 34 | #include "SDL_stdinc.h" 35 | #include "SDL_error.h" 36 | 37 | #include "begin_code.h" 38 | /* Set up for C function definitions, even when using C++ */ 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** 44 | * An SDL_GUID is a 128-bit identifier. 45 | * 46 | * This is an acronym for "Globally Unique ID." 47 | * 48 | * While a GUID can be used to assign a unique value to almost anything, in 49 | * SDL these are largely used to identify input devices across runs of SDL 50 | * programs on the same platform.If the device is detached and then 51 | * re-attached to a different port, or if the base system is rebooted, the 52 | * device should still report the same GUID. 53 | * 54 | * GUIDs are as precise as possible but are not guaranteed to distinguish 55 | * physically distinct but equivalent devices. For example, two game 56 | * controllers from the same vendor with the same product ID and revision may 57 | * have the same GUID. 58 | * 59 | * GUIDs may be platform-dependent (i.e., the same device may report different 60 | * GUIDs on different operating systems). 61 | */ 62 | typedef struct SDL_GUID { 63 | Uint8 data[16]; 64 | } SDL_GUID; 65 | 66 | /* Function prototypes */ 67 | 68 | /** 69 | * Get an ASCII string representation for a given SDL_GUID. 70 | * 71 | * You should supply at least 33 bytes for pszGUID. 72 | * 73 | * \param guid the SDL_GUID you wish to convert to string. 74 | * \param pszGUID buffer in which to write the ASCII string. 75 | * \param cbGUID the size of pszGUID. 76 | * 77 | * \since This function is available since SDL 2.24.0. 78 | * 79 | * \sa SDL_GUIDFromString 80 | */ 81 | extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID); 82 | 83 | /** 84 | * Convert a GUID string into a SDL_GUID structure. 85 | * 86 | * Performs no error checking. If this function is given a string containing 87 | * an invalid GUID, the function will silently succeed, but the GUID generated 88 | * will not be useful. 89 | * 90 | * \param pchGUID string containing an ASCII representation of a GUID. 91 | * \returns a SDL_GUID structure. 92 | * 93 | * \since This function is available since SDL 2.24.0. 94 | * 95 | * \sa SDL_GUIDToString 96 | */ 97 | extern DECLSPEC SDL_GUID SDLCALL SDL_GUIDFromString(const char *pchGUID); 98 | 99 | /* Ends C function definitions when using C++ */ 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | #include "close_code.h" 104 | 105 | #endif /* SDL_guid_h_ */ 106 | 107 | /* vi: set ts=4 sw=4 expandtab: */ 108 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* WIKI CATEGORY: LoadSO */ 23 | 24 | /** 25 | * # CategoryLoadSO 26 | * 27 | * System-dependent library loading routines. 28 | * 29 | * Some things to keep in mind: 30 | * 31 | * - These functions only work on C function names. Other languages may have 32 | * name mangling and intrinsic language support that varies from compiler to 33 | * compiler. 34 | * - Make sure you declare your function pointers with the same calling 35 | * convention as the actual library function. Your code will crash 36 | * mysteriously if you do not do this. 37 | * - Avoid namespace collisions. If you load a symbol from the library, it is 38 | * not defined whether or not it goes into the global symbol namespace for 39 | * the application. If it does and it conflicts with symbols in your code or 40 | * other shared libraries, you will not get the results you expect. :) 41 | */ 42 | 43 | #ifndef SDL_loadso_h_ 44 | #define SDL_loadso_h_ 45 | 46 | #include "SDL_stdinc.h" 47 | #include "SDL_error.h" 48 | 49 | #include "begin_code.h" 50 | /* Set up for C function definitions, even when using C++ */ 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | * Dynamically load a shared object. 57 | * 58 | * \param sofile a system-dependent name of the object file. 59 | * \returns an opaque pointer to the object handle or NULL if there was an 60 | * error; call SDL_GetError() for more information. 61 | * 62 | * \since This function is available since SDL 2.0.0. 63 | * 64 | * \sa SDL_LoadFunction 65 | * \sa SDL_UnloadObject 66 | */ 67 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); 68 | 69 | /** 70 | * Look up the address of the named function in a shared object. 71 | * 72 | * This function pointer is no longer valid after calling SDL_UnloadObject(). 73 | * 74 | * This function can only look up C function names. Other languages may have 75 | * name mangling and intrinsic language support that varies from compiler to 76 | * compiler. 77 | * 78 | * Make sure you declare your function pointers with the same calling 79 | * convention as the actual library function. Your code will crash 80 | * mysteriously if you do not do this. 81 | * 82 | * If the requested function doesn't exist, NULL is returned. 83 | * 84 | * \param handle a valid shared object handle returned by SDL_LoadObject(). 85 | * \param name the name of the function to look up. 86 | * \returns a pointer to the function or NULL if there was an error; call 87 | * SDL_GetError() for more information. 88 | * 89 | * \since This function is available since SDL 2.0.0. 90 | * 91 | * \sa SDL_LoadObject 92 | * \sa SDL_UnloadObject 93 | */ 94 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, 95 | const char *name); 96 | 97 | /** 98 | * Unload a shared object from memory. 99 | * 100 | * \param handle a valid shared object handle returned by SDL_LoadObject(). 101 | * 102 | * \since This function is available since SDL 2.0.0. 103 | * 104 | * \sa SDL_LoadFunction 105 | * \sa SDL_LoadObject 106 | */ 107 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 108 | 109 | /* Ends C function definitions when using C++ */ 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | #include "close_code.h" 114 | 115 | #endif /* SDL_loadso_h_ */ 116 | 117 | /* vi: set ts=4 sw=4 expandtab: */ 118 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_locale.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * # CategoryLocale 24 | * 25 | * Include file for SDL locale services 26 | */ 27 | 28 | #ifndef _SDL_locale_h 29 | #define _SDL_locale_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | /* *INDENT-OFF* */ 38 | extern "C" { 39 | /* *INDENT-ON* */ 40 | #endif 41 | 42 | 43 | typedef struct SDL_Locale 44 | { 45 | const char *language; /**< A language name, like "en" for English. */ 46 | const char *country; /**< A country, like "US" for America. Can be NULL. */ 47 | } SDL_Locale; 48 | 49 | /** 50 | * Report the user's preferred locale. 51 | * 52 | * This returns an array of SDL_Locale structs, the final item zeroed out. 53 | * When the caller is done with this array, it should call SDL_free() on the 54 | * returned value; all the memory involved is allocated in a single block, so 55 | * a single SDL_free() will suffice. 56 | * 57 | * Returned language strings are in the format xx, where 'xx' is an ISO-639 58 | * language specifier (such as "en" for English, "de" for German, etc). 59 | * Country strings are in the format YY, where "YY" is an ISO-3166 country 60 | * code (such as "US" for the United States, "CA" for Canada, etc). Country 61 | * might be NULL if there's no specific guidance on them (so you might get { 62 | * "en", "US" } for American English, but { "en", NULL } means "English 63 | * language, generically"). Language strings are never NULL, except to 64 | * terminate the array. 65 | * 66 | * Please note that not all of these strings are 2 characters; some are three 67 | * or more. 68 | * 69 | * The returned list of locales are in the order of the user's preference. For 70 | * example, a German citizen that is fluent in US English and knows enough 71 | * Japanese to navigate around Tokyo might have a list like: { "de", "en_US", 72 | * "jp", NULL }. Someone from England might prefer British English (where 73 | * "color" is spelled "colour", etc), but will settle for anything like it: { 74 | * "en_GB", "en", NULL }. 75 | * 76 | * This function returns NULL on error, including when the platform does not 77 | * supply this information at all. 78 | * 79 | * This might be a "slow" call that has to query the operating system. It's 80 | * best to ask for this once and save the results. However, this list can 81 | * change, usually because the user has changed a system preference outside of 82 | * your program; SDL will send an SDL_LOCALECHANGED event in this case, if 83 | * possible, and you can call this function again to get an updated copy of 84 | * preferred locales. 85 | * 86 | * \return array of locales, terminated with a locale with a NULL language 87 | * field. Will return NULL on error. 88 | * 89 | * \since This function is available since SDL 2.0.14. 90 | */ 91 | extern DECLSPEC SDL_Locale * SDLCALL SDL_GetPreferredLocales(void); 92 | 93 | /* Ends C function definitions when using C++ */ 94 | #ifdef __cplusplus 95 | /* *INDENT-OFF* */ 96 | } 97 | /* *INDENT-ON* */ 98 | #endif 99 | #include "close_code.h" 100 | 101 | #endif /* _SDL_locale_h */ 102 | 103 | /* vi: set ts=4 sw=4 expandtab: */ 104 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_metal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * # CategoryMetal 24 | * 25 | * Header file for functions to creating Metal layers and views on SDL 26 | * windows. 27 | */ 28 | 29 | #ifndef SDL_metal_h_ 30 | #define SDL_metal_h_ 31 | 32 | #include "SDL_video.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). 42 | * 43 | * This can be cast directly to an NSView or UIView. 44 | */ 45 | typedef void *SDL_MetalView; 46 | 47 | /** 48 | * \name Metal support functions 49 | */ 50 | /* @{ */ 51 | 52 | /** 53 | * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified 54 | * window. 55 | * 56 | * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on 57 | * its own. It is up to user code to do that. 58 | * 59 | * The returned handle can be casted directly to a NSView or UIView. To access 60 | * the backing CAMetalLayer, call SDL_Metal_GetLayer(). 61 | * 62 | * \since This function is available since SDL 2.0.12. 63 | * 64 | * \sa SDL_Metal_DestroyView 65 | * \sa SDL_Metal_GetLayer 66 | */ 67 | extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window); 68 | 69 | /** 70 | * Destroy an existing SDL_MetalView object. 71 | * 72 | * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was 73 | * called after SDL_CreateWindow. 74 | * 75 | * \since This function is available since SDL 2.0.12. 76 | * 77 | * \sa SDL_Metal_CreateView 78 | */ 79 | extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); 80 | 81 | /** 82 | * Get a pointer to the backing CAMetalLayer for the given view. 83 | * 84 | * \since This function is available since SDL 2.0.14. 85 | * 86 | * \sa SDL_Metal_CreateView 87 | */ 88 | extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view); 89 | 90 | /** 91 | * Get the size of a window's underlying drawable in pixels (for use with 92 | * setting viewport, scissor & etc). 93 | * 94 | * \param window SDL_Window from which the drawable size should be queried. 95 | * \param w Pointer to variable for storing the width in pixels, may be NULL. 96 | * \param h Pointer to variable for storing the height in pixels, may be NULL. 97 | * 98 | * \since This function is available since SDL 2.0.14. 99 | * 100 | * \sa SDL_GetWindowSize 101 | * \sa SDL_CreateWindow 102 | */ 103 | extern DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize(SDL_Window* window, int *w, 104 | int *h); 105 | 106 | /* @} *//* Metal support functions */ 107 | 108 | /* Ends C function definitions when using C++ */ 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | #include "close_code.h" 113 | 114 | #endif /* SDL_metal_h_ */ 115 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * # CategoryMisc 24 | * 25 | * Include file for SDL API functions that don't fit elsewhere. 26 | */ 27 | 28 | #ifndef SDL_misc_h_ 29 | #define SDL_misc_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * Open a URL/URI in the browser or other appropriate external application. 42 | * 43 | * Open a URL in a separate, system-provided application. How this works will 44 | * vary wildly depending on the platform. This will likely launch what makes 45 | * sense to handle a specific URL's protocol (a web browser for `http://`, 46 | * etc), but it might also be able to launch file managers for directories and 47 | * other things. 48 | * 49 | * What happens when you open a URL varies wildly as well: your game window 50 | * may lose focus (and may or may not lose focus if your game was fullscreen 51 | * or grabbing input at the time). On mobile devices, your app will likely 52 | * move to the background or your process might be paused. Any given platform 53 | * may or may not handle a given URL. 54 | * 55 | * If this is unimplemented (or simply unavailable) for a platform, this will 56 | * fail with an error. A successful result does not mean the URL loaded, just 57 | * that we launched _something_ to handle it (or at least believe we did). 58 | * 59 | * All this to say: this function can be useful, but you should definitely 60 | * test it on every platform you target. 61 | * 62 | * \param url A valid URL/URI to open. Use `file:///full/path/to/file` for 63 | * local files, if supported. 64 | * \returns 0 on success, or -1 on error; call SDL_GetError() for more 65 | * information. 66 | * 67 | * \since This function is available since SDL 2.0.14. 68 | */ 69 | extern DECLSPEC int SDLCALL SDL_OpenURL(const char *url); 70 | 71 | /* Ends C function definitions when using C++ */ 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | #include "close_code.h" 76 | 77 | #endif /* SDL_misc_h_ */ 78 | 79 | /* vi: set ts=4 sw=4 expandtab: */ 80 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDLname_h_ 23 | #define SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 24 | */ 25 | 26 | #include "SDL_config.h" 27 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 24 | */ 25 | 26 | #include "SDL_config.h" 27 | 28 | #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) 29 | 30 | #ifdef __IPHONEOS__ 31 | #include 32 | #include 33 | #else 34 | #include 35 | #include 36 | #include 37 | #endif 38 | 39 | #else /* _MSC_VER */ 40 | 41 | /* OpenGL ES2 headers for Visual Studio */ 42 | #include "SDL_opengles2_khrplatform.h" 43 | #include "SDL_opengles2_gl2platform.h" 44 | #include "SDL_opengles2_gl2.h" 45 | #include "SDL_opengles2_gl2ext.h" 46 | 47 | #endif /* _MSC_VER */ 48 | 49 | #ifndef APIENTRY 50 | #define APIENTRY GL_APIENTRY 51 | #endif 52 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* 5 | ** Copyright 2017-2020 The Khronos Group Inc. 6 | ** SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 10 | * 11 | * Adopters may modify khrplatform.h and this file to suit their platform. 12 | * Please contribute modifications back to Khronos as pull requests on the 13 | * public github repository: 14 | * https://github.com/KhronosGroup/OpenGL-Registry 15 | */ 16 | 17 | /*#include */ 18 | 19 | #ifndef GL_APICALL 20 | #define GL_APICALL KHRONOS_APICALL 21 | #endif 22 | 23 | #ifndef GL_APIENTRY 24 | #define GL_APIENTRY KHRONOS_APIENTRY 25 | #endif 26 | 27 | #endif /* __gl2platform_h_ */ 28 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_power_h_ 23 | #define SDL_power_h_ 24 | 25 | /** 26 | * # CategoryPower 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * The basic state for the system's power supply. 41 | */ 42 | typedef enum SDL_PowerState 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | /** 52 | * Get the current power supply details. 53 | * 54 | * You should never take a battery status as absolute truth. Batteries 55 | * (especially failing batteries) are delicate hardware, and the values 56 | * reported here are best estimates based on what that hardware reports. It's 57 | * not uncommon for older batteries to lose stored power much faster than it 58 | * reports, or completely drain when reporting it has 20 percent left, etc. 59 | * 60 | * Battery status can change at any time; if you are concerned with power 61 | * state, you should call this function frequently, and perhaps ignore changes 62 | * until they seem to be stable for a few seconds. 63 | * 64 | * It's possible a platform can only report battery percentage or time left 65 | * but not both. 66 | * 67 | * \param seconds seconds of battery life left, you can pass a NULL here if 68 | * you don't care, will return -1 if we can't determine a 69 | * value, or we're not running on a battery. 70 | * \param percent percentage of battery life left, between 0 and 100, you can 71 | * pass a NULL here if you don't care, will return -1 if we 72 | * can't determine a value, or we're not running on a battery. 73 | * \returns an SDL_PowerState enum representing the current battery state. 74 | * 75 | * \since This function is available since SDL 2.0.0. 76 | */ 77 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent); 78 | 79 | /* Ends C function definitions when using C++ */ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* SDL_power_h_ */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * # CategoryQuit 24 | * 25 | * An SDL_QUIT event is generated when the user tries to close the application 26 | * window. If it is ignored or filtered out, the window will remain open. If 27 | * it is not ignored or filtered, it is queued normally and the window is 28 | * allowed to close. When the window is closed, screen updates will complete, 29 | * but have no effect. 30 | * 31 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) and 32 | * SIGTERM (system termination request), if handlers do not already exist, 33 | * that generate SDL_QUIT events as well. There is no way to determine the 34 | * cause of an SDL_QUIT event, but setting a signal handler in your 35 | * application will override the default generation of quit events for that 36 | * signal. 37 | */ 38 | 39 | #ifndef SDL_quit_h_ 40 | #define SDL_quit_h_ 41 | 42 | #include "SDL_stdinc.h" 43 | #include "SDL_error.h" 44 | 45 | /* There are no functions directly affecting the quit event */ 46 | 47 | #define SDL_QuitRequested() \ 48 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 49 | 50 | #endif /* SDL_quit_h_ */ 51 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #ifdef SDL_VENDOR_INFO 2 | #define SDL_REVISION SDL_VENDOR_INFO 3 | #else 4 | #define SDL_REVISION "" 5 | #endif 6 | #define SDL_REVISION_NUMBER 0 7 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_revision.h.cmake: -------------------------------------------------------------------------------- 1 | #cmakedefine SDL_VENDOR_INFO "@SDL_VENDOR_INFO@" 2 | #define SDL_REVISION_NUMBER 0 3 | 4 | #ifdef SDL_VENDOR_INFO 5 | #define SDL_REVISION "@SDL_REVISION@ (" SDL_VENDOR_INFO ")" 6 | #else 7 | #define SDL_REVISION "@SDL_REVISION@" 8 | #endif 9 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_h_ 31 | #define SDL_test_h_ 32 | 33 | #include "SDL.h" 34 | #include "SDL_test_assert.h" 35 | #include "SDL_test_common.h" 36 | #include "SDL_test_compare.h" 37 | #include "SDL_test_crc32.h" 38 | #include "SDL_test_font.h" 39 | #include "SDL_test_fuzzer.h" 40 | #include "SDL_test_harness.h" 41 | #include "SDL_test_images.h" 42 | #include "SDL_test_log.h" 43 | #include "SDL_test_md5.h" 44 | #include "SDL_test_memory.h" 45 | #include "SDL_test_random.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /* Global definitions */ 54 | 55 | /* 56 | * Note: Maximum size of SDLTest log message is less than SDL's limit 57 | * to ensure we can fit additional information such as the timestamp. 58 | */ 59 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test_assert.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Assert API for test code and test cases 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_assert_h_ 37 | #define SDL_test_assert_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* 46 | * \brief Fails the assert. 47 | */ 48 | #define ASSERT_FAIL 0 49 | 50 | /* 51 | * \brief Passes the assert. 52 | */ 53 | #define ASSERT_PASS 1 54 | 55 | /* 56 | * \brief Assert that logs and break execution flow on failures. 57 | * 58 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 59 | * \param assertDescription Message to log with the assert describing it. 60 | */ 61 | void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 62 | 63 | /* 64 | * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. 65 | * 66 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 67 | * \param assertDescription Message to log with the assert describing it. 68 | * 69 | * \returns the assertCondition so it can be used to externally to break execution flow if desired. 70 | */ 71 | int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 72 | 73 | /* 74 | * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. 75 | * 76 | * \param assertDescription Message to log with the assert describing it. 77 | */ 78 | void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); 79 | 80 | /* 81 | * \brief Resets the assert summary counters to zero. 82 | */ 83 | void SDLTest_ResetAssertSummary(void); 84 | 85 | /* 86 | * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. 87 | */ 88 | void SDLTest_LogAssertSummary(void); 89 | 90 | 91 | /* 92 | * \brief Converts the current assert summary state to a test result. 93 | * 94 | * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT 95 | */ 96 | int SDLTest_AssertSummaryToTestResult(void); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | #include "close_code.h" 102 | 103 | #endif /* SDL_test_assert_h_ */ 104 | 105 | /* vi: set ts=4 sw=4 expandtab: */ 106 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test_compare.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines comparison functions (i.e. for surfaces). 33 | 34 | */ 35 | 36 | #ifndef SDL_test_compare_h_ 37 | #define SDL_test_compare_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "SDL_test_images.h" 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* 50 | * \brief Compares a surface and with reference image data for equality 51 | * 52 | * \param surface Surface used in comparison 53 | * \param referenceSurface Test Surface used in comparison 54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. 55 | * 56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. 57 | */ 58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); 59 | 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_compare_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test_crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test_crc32.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Implements CRC32 calculations (default output is Perl String::CRC32 compatible). 33 | 34 | */ 35 | 36 | #ifndef SDL_test_crc32_h_ 37 | #define SDL_test_crc32_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /* ------------ Definitions --------- */ 47 | 48 | /* Definition shared by all CRC routines */ 49 | 50 | #ifndef CrcUint32 51 | #define CrcUint32 unsigned int 52 | #endif 53 | #ifndef CrcUint8 54 | #define CrcUint8 unsigned char 55 | #endif 56 | 57 | #ifdef ORIGINAL_METHOD 58 | #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ 59 | #else 60 | #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ 61 | #endif 62 | 63 | /* 64 | * Data structure for CRC32 (checksum) computation 65 | */ 66 | typedef struct { 67 | CrcUint32 crc32_table[256]; /* CRC table */ 68 | } SDLTest_Crc32Context; 69 | 70 | /* ---------- Function Prototypes ------------- */ 71 | 72 | /* 73 | * \brief Initialize the CRC context 74 | * 75 | * Note: The function initializes the crc table required for all crc calculations. 76 | * 77 | * \param crcContext pointer to context variable 78 | * 79 | * \returns 0 for OK, -1 on error 80 | * 81 | */ 82 | int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); 83 | 84 | 85 | /* 86 | * \brief calculate a crc32 from a data block 87 | * 88 | * \param crcContext pointer to context variable 89 | * \param inBuf input buffer to checksum 90 | * \param inLen length of input buffer 91 | * \param crc32 pointer to Uint32 to store the final CRC into 92 | * 93 | * \returns 0 for OK, -1 on error 94 | * 95 | */ 96 | int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 97 | 98 | /* Same routine broken down into three steps */ 99 | int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 100 | int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 101 | int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 102 | 103 | 104 | /* 105 | * \brief clean up CRC context 106 | * 107 | * \param crcContext pointer to context variable 108 | * 109 | * \returns 0 for OK, -1 on error 110 | * 111 | */ 112 | 113 | int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); 114 | 115 | 116 | /* Ends C function definitions when using C++ */ 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | #include "close_code.h" 121 | 122 | #endif /* SDL_test_crc32_h_ */ 123 | 124 | /* vi: set ts=4 sw=4 expandtab: */ 125 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test_images.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines some images for tests. 33 | 34 | */ 35 | 36 | #ifndef SDL_test_images_h_ 37 | #define SDL_test_images_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* 48 | *Type for test images. 49 | */ 50 | typedef struct SDLTest_SurfaceImage_s { 51 | int width; 52 | int height; 53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ 54 | const char *pixel_data; 55 | } SDLTest_SurfaceImage_t; 56 | 57 | /* Test images */ 58 | SDL_Surface *SDLTest_ImageBlit(void); 59 | SDL_Surface *SDLTest_ImageBlitColor(void); 60 | SDL_Surface *SDLTest_ImageBlitAlpha(void); 61 | SDL_Surface *SDLTest_ImageBlitBlendAdd(void); 62 | SDL_Surface *SDLTest_ImageBlitBlend(void); 63 | SDL_Surface *SDLTest_ImageBlitBlendMod(void); 64 | SDL_Surface *SDLTest_ImageBlitBlendNone(void); 65 | SDL_Surface *SDLTest_ImageBlitBlendAll(void); 66 | SDL_Surface *SDLTest_ImageFace(void); 67 | SDL_Surface *SDLTest_ImagePrimitives(void); 68 | SDL_Surface *SDLTest_ImagePrimitivesBlend(void); 69 | 70 | /* Ends C function definitions when using C++ */ 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #include "close_code.h" 75 | 76 | #endif /* SDL_test_images_h_ */ 77 | 78 | /* vi: set ts=4 sw=4 expandtab: */ 79 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test_log.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Wrapper to log in the TEST category 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_log_h_ 37 | #define SDL_test_log_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* 46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority. 47 | * 48 | * \param fmt Message to be logged 49 | */ 50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 51 | 52 | /* 53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. 54 | * 55 | * \param fmt Message to be logged 56 | */ 57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 58 | 59 | /* Ends C function definitions when using C++ */ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #include "close_code.h" 64 | 65 | #endif /* SDL_test_log_h_ */ 66 | 67 | /* vi: set ts=4 sw=4 expandtab: */ 68 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test_memory.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_memory_h_ 31 | #define SDL_test_memory_h_ 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | 40 | /* 41 | * \brief Start tracking SDL memory allocations 42 | * 43 | * \note This should be called before any other SDL functions for complete tracking coverage 44 | */ 45 | int SDLTest_TrackAllocations(void); 46 | 47 | /* 48 | * \brief Print a log of any outstanding allocations 49 | * 50 | * \note This can be called after SDL_Quit() 51 | */ 52 | void SDLTest_LogAllocations(void); 53 | 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* SDL_test_memory_h_ */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_test_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | * \file SDL_test_random.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | A "32-bit Multiply with carry random number generator. Very fast. 33 | Includes a list of recommended multipliers. 34 | 35 | multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. 36 | period: (a*2^31)-1 37 | 38 | */ 39 | 40 | #ifndef SDL_test_random_h_ 41 | #define SDL_test_random_h_ 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* --- Definitions */ 50 | 51 | /* 52 | * Macros that return a random number in a specific format. 53 | */ 54 | #define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) 55 | 56 | /* 57 | * Context structure for the random number generator state. 58 | */ 59 | typedef struct { 60 | unsigned int a; 61 | unsigned int x; 62 | unsigned int c; 63 | unsigned int ah; 64 | unsigned int al; 65 | } SDLTest_RandomContext; 66 | 67 | 68 | /* --- Function prototypes */ 69 | 70 | /* 71 | * \brief Initialize random number generator with two integers. 72 | * 73 | * Note: The random sequence of numbers returned by ...Random() is the 74 | * same for the same two integers and has a period of 2^31. 75 | * 76 | * \param rndContext pointer to context structure 77 | * \param xi integer that defines the random sequence 78 | * \param ci integer that defines the random sequence 79 | * 80 | */ 81 | void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, 82 | unsigned int ci); 83 | 84 | /* 85 | * \brief Initialize random number generator based on current system time. 86 | * 87 | * \param rndContext pointer to context structure 88 | * 89 | */ 90 | void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); 91 | 92 | 93 | /* 94 | * \brief Initialize random number generator based on current system time. 95 | * 96 | * Note: ...RandomInit() or ...RandomInitTime() must have been called 97 | * before using this function. 98 | * 99 | * \param rndContext pointer to context structure 100 | * 101 | * \returns a random number (32bit unsigned integer) 102 | * 103 | */ 104 | unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* SDL_test_random_h_ */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /extlib/SDL2/include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* DEPRECATED */ 23 | 24 | #include "SDL_stdinc.h" 25 | -------------------------------------------------------------------------------- /extlib/SDL2/include/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2025 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #ifndef SDL_begin_code_h 30 | #error close_code.h included without matching begin_code.h 31 | #endif 32 | #undef SDL_begin_code_h 33 | 34 | /* Reset structure packing at previous byte alignment */ 35 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 36 | #ifdef __BORLANDC__ 37 | #pragma nopackwarning 38 | #endif 39 | #pragma pack(pop) 40 | #endif /* Compiler needs structure packing set */ 41 | -------------------------------------------------------------------------------- /extlib/SDL2/lib/x86/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/SDL2/lib/x86/SDL2.dll -------------------------------------------------------------------------------- /extlib/SDL2/lib/x86/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/SDL2/lib/x86/SDL2.lib -------------------------------------------------------------------------------- /extlib/SDL2/lib/x86/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/SDL2/lib/x86/SDL2main.lib -------------------------------------------------------------------------------- /extlib/SDL2/lib/x86/SDL2test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/SDL2/lib/x86/SDL2test.lib -------------------------------------------------------------------------------- /extlib/bass/COPYING_BASS_VGMSTREAM: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, angryzor 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /extlib/bass/COPYING_VGMSTREAM: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2009 Adam Gashlin, Fastelbja, Ronny Elfert 2 | 3 | Portions Copyright (c) 2004-2008, Marko Kreen 4 | Portions Copyright 2001-2007 jagarl / Kazunori Ueno 5 | Portions Copyright (c) 1998, Justin Frankel/Nullsoft Inc. 6 | Portions Copyright (C) 2006 Nullsoft, Inc. 7 | Portions Copyright (c) 2005-2007 Paul Hsieh 8 | Portions Public Domain originating with Sun Microsystems 9 | 10 | Permission to use, copy, modify, and distribute this software for any 11 | purpose with or without fee is hereby granted, provided that the above 12 | copyright notice and this permission notice appear in all copies. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 15 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 17 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 | -------------------------------------------------------------------------------- /extlib/bass/avcodec-vgmstream-59.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/avcodec-vgmstream-59.dll -------------------------------------------------------------------------------- /extlib/bass/avformat-vgmstream-59.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/avformat-vgmstream-59.dll -------------------------------------------------------------------------------- /extlib/bass/avutil-vgmstream-57.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/avutil-vgmstream-57.dll -------------------------------------------------------------------------------- /extlib/bass/bass.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/bass.dll -------------------------------------------------------------------------------- /extlib/bass/bass.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/bass.lib -------------------------------------------------------------------------------- /extlib/bass/bass_vgmstream.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/bass_vgmstream.dll -------------------------------------------------------------------------------- /extlib/bass/bass_vgmstream.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2008, Ruben "angryzor" Tytgat 3 | * 4 | * Permission to use, copy, modify, and/or distribute this 5 | * software for any purpose with or without fee is hereby granted, 6 | * provided that the above copyright notice and this permission 7 | * notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS 10 | * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 11 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 12 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 13 | * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 15 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH 17 | * THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #ifndef _BASS_VGMSTREAM_H_ 21 | #define _BASS_VGMSTREAM_H_ 22 | 23 | #ifdef BASS_VGMSTREAM_EXPORTS 24 | #define BASS_VGMSTREAM_API __declspec(dllexport) 25 | #else 26 | #define BASS_VGMSTREAM_API __declspec(dllimport) 27 | #endif 28 | 29 | #include 30 | 31 | 32 | #ifdef __cplusplus 33 | extern "C" 34 | { 35 | #endif 36 | 37 | BASS_VGMSTREAM_API HSTREAM BASS_VGMSTREAM_StreamCreate(const char* file, DWORD flags); 38 | BASS_VGMSTREAM_API HSTREAM BASS_VGMSTREAM_StreamCreateFromMemory(unsigned char* buf, int bufsize, const char* name, DWORD flags); 39 | BASS_VGMSTREAM_API void* BASS_VGMSTREAM_InitVGMStreamFromMemory(void* data, int size, const char* name); 40 | BASS_VGMSTREAM_API void BASS_VGMSTREAM_CloseVGMStream(void* vgmstream); 41 | BASS_VGMSTREAM_API int BASS_VGMSTREAM_GetVGMStreamOutputSize(void* vgmstream); 42 | BASS_VGMSTREAM_API int BASS_VGMSTREAM_ConvertVGMStreamToWav(void* vgmstream, unsigned char* outputdata); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | 49 | #endif -------------------------------------------------------------------------------- /extlib/bass/bass_vgmstream.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/bass_vgmstream.lib -------------------------------------------------------------------------------- /extlib/bass/libmpg123-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/libmpg123-0.dll -------------------------------------------------------------------------------- /extlib/bass/libvorbis.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/libvorbis.dll -------------------------------------------------------------------------------- /extlib/bass/swresample-vgmstream-4.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/bass/swresample-vgmstream-4.dll -------------------------------------------------------------------------------- /extlib/d3d8to11/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Michael Fadely 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /extlib/d3d8to11/config.ini: -------------------------------------------------------------------------------- 1 | [OIT] 2 | enabled = true -------------------------------------------------------------------------------- /extlib/d3d8to11/d3d8to11.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/d3d8to11/d3d8to11.dll -------------------------------------------------------------------------------- /extlib/d3d8to11/shader.hlsl: -------------------------------------------------------------------------------- 1 | // Before including the shader library header, define OIT_NODE_WRITE 2 | // so that the OIT subsystem knows that, if anything, we will be 3 | // storing OIT nodes rather than reading them. 4 | #define OIT_NODE_WRITE 5 | 6 | #include "d3d8to11.hlsl" 7 | 8 | // When UBER_DEMO_MODE is defined, uber shaders will replace the RGB 9 | // components of the pixel shader result with red, so that uber shader 10 | // use is visible in the scene. 11 | //#define UBER_DEMO_MODE 12 | 13 | VS_OUTPUT vs_main(VS_INPUT input) 14 | { 15 | return fixed_func_vs(input); 16 | } 17 | 18 | float4 ps_main(VS_OUTPUT input) : SV_TARGET 19 | { 20 | float4 diffuse; 21 | float4 specular; 22 | 23 | get_input_colors(input, diffuse, specular); 24 | 25 | float4 result = handle_texture_stages(input, diffuse, specular); 26 | result = apply_fog(result, input.fog); 27 | 28 | const bool standard_blending = is_standard_blending(); 29 | 30 | do_alpha_test(result, standard_blending); 31 | do_oit(result, input, standard_blending); 32 | 33 | #if UBER == 1 && defined(UBER_DEMO_MODE) 34 | result.rgb = float3(1, 0, 0); 35 | #endif 36 | 37 | return result; 38 | } 39 | -------------------------------------------------------------------------------- /extlib/d3d8to9/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015 Patrick Mours. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 8 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 9 | -------------------------------------------------------------------------------- /extlib/d3d8to9/d3d8.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/X-Hax/sadx-mod-loader/b97ef58fd04fe7fe2eb4fe1b8b38dd0084691ec7/extlib/d3d8to9/d3d8.dll -------------------------------------------------------------------------------- /libmodutils/AnimationFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "SADXModLoader.h" 8 | 9 | class AnimationFile 10 | { 11 | public: 12 | AnimationFile(const char* filename); 13 | AnimationFile(const wchar_t* filename); 14 | AnimationFile(const std::string& filename); 15 | AnimationFile(const std::wstring& filename); 16 | AnimationFile(std::istream& stream); 17 | 18 | NJS_MOTION* getmotion() const; 19 | int getmodelcount() const; 20 | bool isshortrot() const; 21 | const std::string& getlabel(); 22 | const std::string& getlabel(void* data); 23 | void* getdata(const std::string& label); 24 | const std::unordered_map* getlabels() const; 25 | 26 | private: 27 | static const uint64_t SAANIM = 0x4D494E414153u; 28 | static const uint64_t FormatMask = 0xFFFFFFFFFFFFu; 29 | static const uint8_t CurrentVersion = 2; 30 | static const int headersize = 0x14; 31 | 32 | NJS_MOTION* motion; 33 | int modelcount; 34 | bool shortrot; 35 | std::unordered_map labels1; 36 | std::unordered_map labels2; 37 | std::vector> allocatedmem; 38 | std::unordered_set fixedpointers; 39 | 40 | enum ChunkTypes : uint32_t 41 | { 42 | ChunkTypes_Label = 0x4C42414C, 43 | ChunkTypes_End = 0x444E45 44 | }; 45 | 46 | void init(std::istream& stream); 47 | }; -------------------------------------------------------------------------------- /libmodutils/ArchiveX.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "ArchiveX.h" 3 | #include 4 | #include 5 | 6 | ArchiveX::ArchiveX(const char* filename) 7 | { 8 | stream.open(filename, std::ios::binary); 9 | open(); 10 | } 11 | 12 | ArchiveX::ArchiveX(const std::string& filename) 13 | { 14 | stream.open(filename, std::ios::binary); 15 | open(); 16 | } 17 | 18 | #ifdef _MSC_VER 19 | ArchiveX::ArchiveX(const wchar_t* filename) 20 | { 21 | stream.open(filename, std::ios::binary); 22 | open(); 23 | } 24 | 25 | ArchiveX::ArchiveX(const std::wstring& filename) 26 | { 27 | stream.open(filename, std::ios::binary); 28 | open(); 29 | } 30 | #endif /* _MSC_VER */ 31 | 32 | ArchiveX::~ArchiveX() 33 | { 34 | stream.close(); 35 | } 36 | 37 | ArchiveX::ArcFile* ArchiveX::FindFile(const std::string& path) 38 | { 39 | for (auto& i : files) 40 | { 41 | if (i.folder.size() > 0) 42 | { 43 | if (!path.compare(i.folder + "\\" + i.name)) 44 | { 45 | return &i; 46 | } 47 | } 48 | else 49 | { 50 | if (!path.compare(i.name)) 51 | { 52 | return &i; 53 | } 54 | } 55 | } 56 | 57 | return nullptr; 58 | } 59 | 60 | void ArchiveX::GetFile(const std::string& path, std::stringstream& str) 61 | { 62 | ArcFile* file = FindFile(path); 63 | 64 | if (file) 65 | { 66 | stream.seekg(file->offset); 67 | auto size = file->size; 68 | char* buf = new char[size]; 69 | stream.read(buf, size); 70 | str.write(buf, size); 71 | } 72 | } 73 | 74 | void ArchiveX::GetFile(const char* path, std::stringstream& str) 75 | { 76 | return GetFile(static_cast(path), str); 77 | } 78 | 79 | ModelInfo* ArchiveX::GetModel(const std::string& path) 80 | { 81 | ArcFile* file = FindFile(path); 82 | 83 | if (file) 84 | { 85 | stream.seekg(file->offset); 86 | return new ModelInfo(stream); 87 | } 88 | else 89 | { 90 | return nullptr; 91 | } 92 | } 93 | 94 | ModelInfo* ArchiveX::GetModel(const char* path) 95 | { 96 | return GetModel(static_cast(path)); 97 | } 98 | 99 | AnimationFile* ArchiveX::GetAnimation(const std::string& path) 100 | { 101 | ArcFile* file = FindFile(path); 102 | 103 | if (file) 104 | { 105 | stream.seekg(file->offset); 106 | return new AnimationFile(stream); 107 | } 108 | else 109 | { 110 | return nullptr; 111 | } 112 | } 113 | 114 | AnimationFile* ArchiveX::GetAnimation(const char* path) 115 | { 116 | return GetAnimation(static_cast(path)); 117 | } 118 | 119 | LandTableInfo* ArchiveX::GetLandTable(const std::string& path) 120 | { 121 | ArcFile* file = FindFile(path); 122 | 123 | if (file) 124 | { 125 | stream.seekg(file->offset); 126 | return new LandTableInfo(stream); 127 | } 128 | else 129 | { 130 | return nullptr; 131 | } 132 | } 133 | 134 | LandTableInfo* ArchiveX::GetLandTable(const char* path) 135 | { 136 | return GetLandTable(static_cast(path)); 137 | } 138 | 139 | template 140 | auto& read_t(std::ifstream& file, T& data) 141 | { 142 | return file.read(reinterpret_cast(&data), sizeof(T)); 143 | } 144 | 145 | void read_string(std::ifstream& file, std::string& out) 146 | { 147 | std::stringstream buffer; 148 | 149 | while (true) 150 | { 151 | char c; 152 | read_t(file, c); 153 | 154 | if (c == '\0') 155 | { 156 | break; 157 | } 158 | 159 | buffer.put(c); 160 | } 161 | 162 | out = buffer.str(); 163 | } 164 | 165 | void ArchiveX::open() 166 | { 167 | uint32_t magic; 168 | read_t(stream, magic); 169 | 170 | if (magic != ARCX) 171 | { 172 | return; 173 | } 174 | 175 | uint8_t version; 176 | read_t(stream, version); 177 | 178 | if (version > CurrentVersion) 179 | { 180 | return; 181 | } 182 | 183 | ArcField field = ArcField::None; 184 | 185 | for (read_t(stream, field); field != ArcField::None; read_t(stream, field)) 186 | { 187 | ArcFile file = {}; 188 | 189 | while (field != ArcField::None) 190 | { 191 | switch (field) 192 | { 193 | case ArcField::Folder: 194 | read_string(stream, file.folder); 195 | break; 196 | case ArcField::Name: 197 | read_string(stream, file.name); 198 | break; 199 | default: 200 | break; 201 | } 202 | 203 | read_t(stream, field); 204 | } 205 | 206 | read_t(stream, file.offset); 207 | read_t(stream, file.size); 208 | 209 | files.push_back(file); 210 | } 211 | } -------------------------------------------------------------------------------- /libmodutils/ArchiveX.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "SADXModLoader.h" 8 | #include "ModelInfo.h" 9 | #include "AnimationFile.h" 10 | #include "LandTableInfo.h" 11 | 12 | class ArchiveX 13 | { 14 | public: 15 | ArchiveX(const char* filename); 16 | ArchiveX(const wchar_t* filename); 17 | ArchiveX(const std::string& filename); 18 | ArchiveX(const std::wstring& filename); 19 | ~ArchiveX(); 20 | 21 | void GetFile(const std::string& path, std::stringstream& str); 22 | void GetFile(const char* path, std::stringstream& str); 23 | 24 | ModelInfo* GetModel(const std::string& path); 25 | ModelInfo* GetModel(const char* path); 26 | 27 | AnimationFile* GetAnimation(const std::string& path); 28 | AnimationFile* GetAnimation(const char* path); 29 | 30 | LandTableInfo* GetLandTable(const std::string& path); 31 | LandTableInfo* GetLandTable(const char* path); 32 | 33 | private: 34 | struct ArcFile 35 | { 36 | std::string folder, name; 37 | uint64_t offset; 38 | uint64_t size; 39 | }; 40 | 41 | enum class ArcField : uint8_t 42 | { 43 | None, 44 | Folder, 45 | Name 46 | }; 47 | 48 | static constexpr uint32_t ARCX = 0x58435241u; 49 | static constexpr uint8_t CurrentVersion = 0; 50 | 51 | std::ifstream stream; 52 | std::vector files; 53 | 54 | void open(); 55 | ArcFile* FindFile(const std::string& path); 56 | }; -------------------------------------------------------------------------------- /libmodutils/GameObject.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "GameObject.h" 3 | 4 | 5 | GameObject::GameObject(LoadObj flags, int index) 6 | { 7 | objData = LoadObject(flags, index, CallMain); 8 | if (objData) 9 | { 10 | objData->DisplaySub = CallDisplay; 11 | objData->DeleteSub = CallDelete; 12 | objData->Data2 = this; 13 | } 14 | initFromObj = false; 15 | } 16 | 17 | GameObject::GameObject(int index) 18 | : GameObject((LoadObj)0, index) 19 | { 20 | } 21 | 22 | GameObject::GameObject(ObjectMaster* obj) 23 | { 24 | objData = obj; 25 | objData->MainSub = CallMain; 26 | objData->DisplaySub = CallDisplay; 27 | objData->DeleteSub = CallDelete; 28 | objData->Data2 = this; 29 | initFromObj = true; 30 | } 31 | 32 | void GameObject::CallMain(ObjectMaster* obj) 33 | { 34 | ((GameObject*)obj->Data2)->Main(); 35 | } 36 | 37 | void GameObject::CallDisplay(ObjectMaster* obj) 38 | { 39 | ((GameObject*)obj->Data2)->Display(); 40 | } 41 | 42 | void GameObject::CallDelete(ObjectMaster* obj) 43 | { 44 | auto cgo = (GameObject*)obj->Data2; 45 | cgo->Delete(); 46 | obj->Data2 = nullptr; 47 | cgo->objData = nullptr; 48 | if (cgo->initFromObj) 49 | delete cgo; 50 | } 51 | 52 | void GameObject::Display() 53 | { 54 | } 55 | 56 | void GameObject::Delete() 57 | { 58 | } 59 | 60 | SETDataUnion GameObject::GetSETData() const { return objData->SETData; } 61 | 62 | GameObject::~GameObject() 63 | { 64 | if (objData) 65 | { 66 | Delete(); 67 | objData->Data2 = nullptr; 68 | objData->DeleteSub = nullptr; 69 | DeleteObject_(objData); 70 | } 71 | } 72 | 73 | GameEntity::GameEntity(int index) 74 | : GameObject(LoadObj_Data1, index) 75 | { 76 | } 77 | 78 | EntityData1* GameEntity::GetData() const { return objData->Data1; } 79 | 80 | char GameEntity::GetAction() const { return GetData()->Action; } 81 | 82 | void GameEntity::SetAction(char action) const { GetData()->Action = action; } 83 | 84 | short GameEntity::GetInvulnerableTime() const { return GetData()->InvulnerableTime; } 85 | 86 | void GameEntity::SetInvulnerableTime(short time) const { GetData()->InvulnerableTime = time; } 87 | 88 | char GameEntity::GetCharIndex() const { return GetData()->CharIndex; } 89 | 90 | void GameEntity::SetCharIndex(char index) const { GetData()->CharIndex = index; } 91 | 92 | Rotation3& GameEntity::GetRotation() const { return GetData()->Rotation; } 93 | 94 | void GameEntity::SetRotation(Rotation3& rotation) const { GetData()->Rotation = rotation; } 95 | 96 | NJS_VECTOR& GameEntity::GetPosition() const { return GetData()->Position; } 97 | 98 | void GameEntity::SetPosition(NJS_VECTOR& position) const { GetData()->Position = position; } 99 | 100 | NJS_VECTOR& GameEntity::GetScale() const { return GetData()->Scale; } 101 | 102 | void GameEntity::SetScale(NJS_VECTOR& scale) const { GetData()->Scale = scale; } 103 | 104 | CollisionInfo* GameEntity::GetCollisionInfo() const { return GetData()->CollisionInfo; } 105 | -------------------------------------------------------------------------------- /libmodutils/GameObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SADXModLoader.h" 3 | 4 | class GameObject 5 | { 6 | private: 7 | static void CallMain(ObjectMaster* obj); 8 | static void CallDisplay(ObjectMaster* obj); 9 | static void CallDelete(ObjectMaster* obj); 10 | bool initFromObj; 11 | protected: 12 | ObjectMaster* objData; 13 | GameObject(LoadObj flags, int index); 14 | explicit GameObject(ObjectMaster* obj); 15 | virtual void Delete(); 16 | public: 17 | explicit GameObject(int index); 18 | ~GameObject(); 19 | virtual void Main() = 0; 20 | virtual void Display(); 21 | 22 | template 23 | static void Load(ObjectMaster* obj) 24 | { 25 | T* t = new T(obj); 26 | t->Main(); 27 | } 28 | 29 | SETDataUnion GetSETData() const; 30 | // MSVC-specific property emulation. 31 | #ifdef _MSC_VER 32 | __declspec(property(get = GetSETData)) SETDataUnion SETData; 33 | #endif 34 | }; 35 | 36 | class GameEntity : GameObject 37 | { 38 | protected: 39 | EntityData1* GetData() const; 40 | public: 41 | explicit GameEntity(int index); 42 | char GetAction() const; 43 | void SetAction(char action) const; 44 | short GetInvulnerableTime() const; 45 | void SetInvulnerableTime(short time) const; 46 | char GetCharIndex() const; 47 | void SetCharIndex(char index) const; 48 | Rotation3& GetRotation() const; 49 | void SetRotation(Rotation3& rotation) const; 50 | NJS_VECTOR& GetPosition() const; 51 | void SetPosition(NJS_VECTOR& position) const; 52 | NJS_VECTOR& GetScale() const; 53 | void SetScale(NJS_VECTOR& scale) const; 54 | CollisionInfo* GetCollisionInfo() const; 55 | // MSVC-specific property emulation. 56 | #ifdef _MSC_VER 57 | __declspec(property(get = GetAction, put = SetAction)) char Action; 58 | __declspec(property(get = GetInvulnerableTime, put = SetInvulnerableTime)) short InvulnerableTime; 59 | __declspec(property(get = GetCharIndex, put = SetCharIndex)) char CharIndex; 60 | __declspec(property(get = GetRotation, put = SetRotation)) Rotation3& Rotation; 61 | __declspec(property(get = GetPosition, put = SetPosition)) NJS_VECTOR& Position; 62 | __declspec(property(get = GetScale, put = SetScale)) NJS_VECTOR& Scale; 63 | __declspec(property(get = GetCollisionInfo)) CollisionInfo* CollisionInfo; 64 | #endif 65 | }; 66 | -------------------------------------------------------------------------------- /libmodutils/GoalRing.cpp: -------------------------------------------------------------------------------- 1 | // Example object class. 2 | 3 | #include "stdafx.h" 4 | #include "SADXModLoader.h" 5 | #include "GameObject.h" 6 | extern NJS_OBJECT object_GoalRing; 7 | extern NJS_OBJECT object_GoalText; 8 | extern NJS_TEXLIST GoalRingTextures; 9 | #define GoalRingSize 34 10 | 11 | FunctionPointer(void, sub_408530, (NJS_OBJECT *), 0x408530); 12 | 13 | class GoalRing : public GameEntity 14 | { 15 | void Main(); 16 | void Display(); 17 | }; 18 | 19 | void GoalRing::Display() 20 | { 21 | njSetTexture(&GoalRingTextures); 22 | njPushMatrix(nullptr); 23 | njTranslateV(nullptr, &Position); 24 | int yrot = Rotation.y; 25 | if (yrot) 26 | njRotateY(nullptr, yrot); 27 | if (FrameCounter % 40 >= 25) 28 | object_GoalText.evalflags |= NJD_EVAL_HIDE; 29 | else 30 | object_GoalText.evalflags &= ~NJD_EVAL_HIDE; 31 | sub_408530(&object_GoalRing); 32 | njPopMatrix(1); 33 | } 34 | 35 | void GoalRing::Main() 36 | { 37 | switch (Action) 38 | { 39 | case 0: 40 | Rotation.y = 0; 41 | Action = 1; 42 | break; 43 | case 1: 44 | if (GetCurrentCharacterID() == Characters_Tails) 45 | { 46 | switch (IsPlayerInsideSphere(&Position, GoalRingSize)) 47 | { 48 | case 0: 49 | break; 50 | case 1: 51 | SetTailsRaceVictory(); 52 | LoadLevelResults(); 53 | Action = 2; 54 | break; 55 | default: 56 | SetOpponentRaceVictory(); 57 | LoadLevelResults(); 58 | Action = 2; 59 | break; 60 | } 61 | } 62 | else if ( IsPlayerInsideSphere(&Position, GoalRingSize) == 1 ) 63 | { 64 | LoadLevelResults(); 65 | Action = 2; 66 | } 67 | Rotation.y += 0x180; 68 | Display(); 69 | break; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /libmodutils/LandTableInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef LANDTABLEINFO_H 2 | #define LANDTABLEINFO_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "SADXModLoader.h" 10 | 11 | class LandTableInfo 12 | { 13 | public: 14 | struct Metadata 15 | { 16 | uint32_t size; 17 | const uint8_t* data; 18 | }; 19 | 20 | explicit LandTableInfo(const char* filename); 21 | explicit LandTableInfo(const std::string& filename); 22 | #ifdef _MSC_VER 23 | explicit LandTableInfo(const wchar_t* filename); 24 | explicit LandTableInfo(const std::wstring& filename); 25 | #endif /* _MSC_VER */ 26 | explicit LandTableInfo(std::istream& stream); 27 | 28 | LandTable* getlandtable() const; 29 | _OBJ_LANDTABLE* getobjlandtable() const; 30 | const std::string& getauthor() const; 31 | const std::string& gettool() const; 32 | const std::string& getdescription() const; 33 | const uint8_t* getmetadata(uint32_t identifier, uint32_t& size); 34 | const std::string& getlabel(void* data); 35 | void* getdata(const std::string& label); 36 | const std::unordered_map* getlabels() const; 37 | 38 | private: 39 | static const uint64_t SA1LVL = 0x4C564C314153ULL; 40 | static const uint64_t FormatMask = 0xFFFFFFFFFFFFULL; 41 | static const uint8_t CurrentVersion = 3; 42 | 43 | static constexpr size_t headerSize = 0x10; 44 | 45 | _OBJ_LANDTABLE* landtable = nullptr; 46 | std::string author, tool, description; 47 | std::unordered_map metadata; 48 | std::unordered_map labels1; 49 | std::unordered_map labels2; 50 | std::vector> allocatedmem; 51 | std::unordered_set fixedpointers; 52 | std::unordered_map reallocateddata; 53 | 54 | enum ChunkTypes : uint32_t 55 | { 56 | ChunkTypes_Label = 0x4C42414C, 57 | ChunkTypes_Author = 0x48545541, 58 | ChunkTypes_Tool = 0x4C4F4F54, 59 | ChunkTypes_Description = 0x43534544, 60 | ChunkTypes_End = 0x444E45 61 | }; 62 | 63 | void fixmodelpointers(NJS_MODEL_SADX* model, intptr_t base); 64 | void fixobjectpointers(NJS_OBJECT* object, intptr_t base); 65 | void fixmotionpointers(NJS_MOTION* motion, intptr_t base, int count); 66 | void fixactionpointers(NJS_ACTION* action, intptr_t base); 67 | void fixlandtablepointers(_OBJ_LANDTABLE* landtable, intptr_t base); 68 | void init(std::istream& stream); 69 | }; 70 | 71 | #endif /* LANDTABLEINFO_H */ 72 | -------------------------------------------------------------------------------- /libmodutils/ModelInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef MODELINFO_H 2 | #define MODELINFO_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "ninja.h" 11 | #include "WeightInfo.h" 12 | 13 | enum ModelFormat 14 | { 15 | ModelFormat_Invalid, 16 | ModelFormat_Basic, 17 | ModelFormat_Chunk 18 | }; 19 | 20 | class ModelInfo 21 | { 22 | public: 23 | struct Metadata 24 | { 25 | uint32_t size; 26 | const uint8_t* data; 27 | }; 28 | 29 | explicit ModelInfo(const char* filename); 30 | explicit ModelInfo(const std::string& filename); 31 | #ifdef _MSC_VER 32 | explicit ModelInfo(const wchar_t* filename); 33 | explicit ModelInfo(const std::wstring& filename); 34 | #endif /* _MSC_VER */ 35 | explicit ModelInfo(std::istream& stream); 36 | 37 | ModelFormat getformat() const; 38 | NJS_OBJECT* getmodel() const; 39 | const std::string& getauthor() const; 40 | const std::string& gettool() const; 41 | const std::string& getdescription() const; 42 | const uint8_t* getmetadata(uint32_t identifier, uint32_t& size); 43 | const std::string& getlabel(void* data); 44 | void* getdata(const std::string& label); 45 | const std::unordered_map* getlabels() const; 46 | const std::list& getanimations() const; 47 | const std::list& getmorphs() const; 48 | WeightInfo* getweightinfo(); 49 | 50 | private: 51 | static const uint64_t SA1MDL = 0x4C444D314153ULL; 52 | static const uint64_t SA2MDL = 0x4C444D324153ULL; 53 | static const uint64_t FormatMask = 0xFFFFFFFFFFFFULL; 54 | static const uint8_t CurrentVersion = 3; 55 | 56 | static constexpr size_t headerSize = 0x10; 57 | 58 | ModelFormat format = ModelFormat_Invalid; 59 | NJS_OBJECT* model = nullptr; 60 | std::string author, tool, description; 61 | std::unordered_map metadata; 62 | std::unordered_map labels1; 63 | std::unordered_map labels2; 64 | std::vector> allocatedmem; 65 | std::unordered_set fixedpointers; 66 | std::unordered_map reallocateddata; 67 | std::list animations, morphs; 68 | std::vector weightNodes; 69 | WeightInfo weightInfo{}; 70 | 71 | enum ChunkTypes : uint32_t 72 | { 73 | ChunkTypes_Label = 0x4C42414C, 74 | ChunkTypes_Animation = 0x4D494E41, 75 | ChunkTypes_Morph = 0x46524F4D, 76 | ChunkTypes_Author = 0x48545541, 77 | ChunkTypes_Tool = 0x4C4F4F54, 78 | ChunkTypes_Description = 0x43534544, 79 | ChunkTypes_Texture = 0x584554, 80 | ChunkTypes_Weights = 0x54484757, 81 | ChunkTypes_End = 0x444E45 82 | }; 83 | 84 | void fixbasicmodelpointers(NJS_MODEL_SADX* model, intptr_t base); 85 | static void fixchunkmodelpointers(NJS_CNK_MODEL* model, intptr_t base); 86 | void fixobjectpointers(NJS_OBJECT* object, intptr_t base); 87 | void init(std::istream& stream); 88 | }; 89 | 90 | #endif /* MODELINFO_H */ 91 | -------------------------------------------------------------------------------- /libmodutils/Trampoline.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Trampoline.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | Trampoline::Trampoline(intptr_t start, intptr_t end, void* func, bool destructRevert) 11 | : target(reinterpret_cast(start)) 12 | , detour(func) 13 | , codeData(nullptr) 14 | , originalSize(0) 15 | , revert(destructRevert) 16 | { 17 | if (start > end) 18 | { 19 | throw std::exception("Start address cannot exceed end address."); 20 | } 21 | 22 | if (end - start < 5) 23 | { 24 | throw std::exception("Length cannot be less than 5 bytes."); 25 | } 26 | 27 | originalSize = end - start; 28 | 29 | // Copy original instructions 30 | codeData = VirtualAlloc(nullptr, originalSize + 5, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); 31 | 32 | if (codeData == nullptr) 33 | { 34 | throw std::exception("VirtualAlloc failure."); 35 | } 36 | 37 | // memcpy() can be used instead of ReadProcessMemory 38 | // because we're not reading memory from another process. 39 | memcpy(codeData, target, originalSize); 40 | 41 | const auto ptr = static_cast(codeData); 42 | 43 | if (ptr[0] == 0xE8) 44 | { 45 | // If the start address has a function call right off the bat, 46 | // just repair it for the sake of convenience. 47 | intptr_t addr = start + 5 + *reinterpret_cast(&ptr[1]); 48 | WriteCall(ptr, (void*)addr); 49 | } 50 | else if (ptr[0] == 0xE9) 51 | { 52 | // If an existing (hopefully) trampoline has been applied to this address, 53 | // correct the jump offset for it. 54 | intptr_t addr = start + 5 + *reinterpret_cast(&ptr[1]); 55 | WriteJump(ptr, (void*)addr); 56 | } 57 | 58 | // Append jump 59 | WriteJump(&ptr[originalSize], (void*)end); 60 | 61 | // NOP the original code. 62 | // NOTE: This is in .text, so we have to use WriteData(). 63 | // Using memset() will crash. 64 | std::vector nop(originalSize, 0x90); 65 | WriteData(target, nop.data(), nop.size()); 66 | 67 | // Write a Jump to the new target function. 68 | WriteJump(target, func); 69 | } 70 | 71 | Trampoline::~Trampoline() 72 | { 73 | if (codeData) 74 | { 75 | if (revert) 76 | { 77 | WriteData(target, codeData, originalSize); 78 | } 79 | 80 | VirtualFree(codeData, 0, MEM_RELEASE); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /libmodutils/Trampoline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // TODO: Better documentation 6 | // TODO: Clearer member names 7 | 8 | class Trampoline 9 | { 10 | private: 11 | void* target; 12 | void* detour; 13 | LPVOID codeData; 14 | size_t originalSize; 15 | const bool revert; 16 | 17 | public: 18 | /// 19 | /// Initializes a new , allowing you to replace functions and still call the original code. 20 | /// 21 | /// Start offset (address of function). 22 | /// End offset. 23 | /// Your detour function. 24 | /// If true, code changes will be reverted when this instance is destroyed. 25 | /// 26 | /// If the start address begins with a jump or call instruction, the relative address will be automatically repaired. 27 | /// Any subsequent jumps or calls caught in the range of and will need 28 | /// to be repaired manually. 29 | /// 30 | Trampoline(intptr_t start, intptr_t end, void* func, bool destructRevert = true); 31 | ~Trampoline(); 32 | 33 | // Pointer to original code. 34 | LPVOID Target() const 35 | { 36 | return codeData; 37 | } 38 | // Pointer to your detour. 39 | void* Detour() const 40 | { 41 | return detour; 42 | } 43 | // Original data size. 44 | size_t OriginalSize() const 45 | { 46 | return originalSize; 47 | } 48 | // Size of Target including appended jump to remaining original code. 49 | size_t CodeSize() const 50 | { 51 | return originalSize + 5; 52 | } 53 | }; 54 | 55 | // Convenient macros for trampolines. 56 | #define TARGET_DYNAMIC(name) ((decltype(name##_r)*)name##_t->Target()) 57 | #define TARGET_STATIC(name) ((decltype(name##_r)*)name##_t.Target()) -------------------------------------------------------------------------------- /libmodutils/libmodutils.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | Source Files 70 | 71 | 72 | -------------------------------------------------------------------------------- /libmodutils/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SADXModLoader.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /libmodutils/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | 12 | // Windows Header Files: 13 | #include 14 | 15 | // TODO: reference additional headers your program requires here 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "ninja.h" -------------------------------------------------------------------------------- /libmodutils/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | #define _WIN32_WINNT _WIN32_WINNT_WINXP 10 | #define WINVER _WIN32_WINNT_WINXP -------------------------------------------------------------------------------- /sadx_programming.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! command -v zip &> /dev/null; then 4 | echo "zip command not found. Installing zip..." 5 | # Install zip using pacman 6 | pacman -S zip 7 | fi 8 | 9 | 10 | # Specify the directory containing headers 11 | loaderDirectory="SADXModLoader/include" 12 | commonDirectory="mod-loader-common/ModLoaderCommon" 13 | libmodDir="libmodutils" 14 | 15 | # Use find to locate all header files in the specified directory 16 | headers=($(find "$loaderDirectory" -type f -name "*.h")) 17 | 18 | # Add headers from other projects 19 | headers+=("$commonDirectory/IniFile.hpp" "$commonDirectory/IniFile.cpp", "$commonDirectory/Utils.hpp", "$commonDirectory/TextConv.hpp, $commonDirectory/TextConv.cpp") 20 | 21 | files=($(find "$libmodDir" \( -name "*.cpp" -or -name "*.h" \) -and -not -name "stdafx.*")) 22 | 23 | # Combine the headers and files arrays 24 | all_files=("${headers[@]}" "${files[@]}") 25 | 26 | # Create a temporary directory 27 | temp_dir=$(mktemp -d) 28 | 29 | # Loop through all files and copy them to the temporary directory 30 | for file in "${all_files[@]}"; do 31 | cp "$file" "$temp_dir" 32 | done 33 | 34 | # Create a zip file 35 | Compress-Archive -LiteralPath sadx_programming.zip "$temp_dir" 36 | 37 | # Clean up temporary directory 38 | rm -r "$temp_dir" 39 | 40 | # Prompt user to press Enter before closing the window 41 | read -p "Press Enter to exit" --------------------------------------------------------------------------------