├── .gitattributes ├── .gitignore ├── README.md ├── data ├── function_hash_list.txt ├── hashdb.bin ├── hashtable.txt ├── mk11_def.txt ├── mk12_def.txt ├── mka_def.txt ├── mkd_def.txt ├── mkda_def.txt └── mku_def.txt ├── mkoasm.sln └── mkoasm ├── INIReader.cpp ├── INIReader.h ├── MKOReader.cpp ├── MKOReader.h ├── code ├── FileFunctions.cpp ├── FileFunctions.h ├── MKODict.cpp ├── MKODict.h ├── MKScript.h ├── MKScriptTypes.h ├── MKScript_DCF.h ├── MKScript_DCF2.h ├── MKScript_MK10.h ├── MKScript_MK11.h ├── MKScript_MK12.h ├── MKScript_MK8.h ├── MKScript_MK9.h ├── misc.cpp └── misc.h ├── compiler ├── MKOCompiler.cpp └── MKOCompiler.h ├── enums.h ├── ini.c ├── ini.h ├── lz4 ├── liblz4_static.lib └── lz4.h ├── mkoasm.cpp ├── mkoasm.vcxproj └── mkoasm.vcxproj.filters /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mkoasm 2 | 3 | MKO Assembler (mkoasm) is a work in progress tool designed to work with .MKO scripts from Mortal Kombat games. 4 | 5 | Not ready for public usage yet, but feel free to make use of whats available. 6 | 7 | Run without params to get usage. 8 | 9 | 10 | # Support Table 11 | 12 | **Note: There's no way to detect the format of the MKO script, use -m param to change 13 | game mode** 14 | 15 | | Icon | Description | 16 | | --- | --- | 17 | | ✔️ | Full support | 18 | | ⚠ | Partial support, data might not be extracted correctly | 19 | | ❌ | Not supported | 20 | 21 | 22 | | Game | View | Extract | Decompile | Compile | Platforms | 23 | | --- | --- | --- | --- | --- | --- | 24 | | MK Deadly Alliance | ✔️ | ✔️ | ✔️| ❌ | PS2 | 25 | | MK Deception | ✔️ | ✔️ | ✔️| ✔️ |PS2, GC, XBOX | 26 | | MK Unchained | ✔️ | ✔️ | ✔️| ✔️ |PSP| 27 | | MK Armageddon | ✔️ | ✔️ | ✔️| ✔️ |PS2, Wii, XBOX| 28 | | MK VS DC | ✔️ | ✔️ | ✔️| ❌ |PS3| 29 | | MK9 | ✔️ | ✔️ | ✔️| ❌ |PC, Vita | 30 | | Injustice | ✔️ | ⚠ | ❌| ❌ | PC | 31 | | Mortal Kombat X | ✔️ | ✔️ | ✔️| ❌ | PC| 32 | | Injustice 2 | ✔️ | ✔️ | ✔️| ❌ | PC| 33 | | Mortal Kombat 11 | ✔️ | ✔️ | ✔️| ❌ | PC| 34 | | Mortal Kombat 12 (1) | ✔️ | ✔️ | ✔️| ❌ | PC| 35 | 36 | **Mortal Kombat X and up requires x64 version of mkoasm! For MK12, the MKO file will be decompressed if it doesn't have "raw_" in fiename. Only use "raw_" files for MK12 mode!** 37 | 38 | 39 | 40 | # Decompilation 41 | 42 | MKOASM is able to decompile functions for supported games using definition tables, there's a table 43 | with plenty of functions for every supported game (except MKvsDC+) which should produce human readable 44 | output. 45 | 46 | 47 | # Building 48 | 49 | | Game | Note | 50 | | --- | --- | 51 | | MK Deception | Works | 52 | | MK Unchained | Works | 53 | | MK Armageddon | Works, some MKOs will be larger than original | 54 | 55 | 56 | 57 | # MKO Overview 58 | 59 | ## MK Deadly Alliance 60 | - First version of MKO (cmo) script format 61 | - Only functions can be used 62 | - No variables 63 | - Heavily dependant on executable functions for almost everything 64 | 65 | ## MK Deception 66 | - Added static variables 67 | - Added local variables 68 | - Added operations on local and static variables 69 | - Script functions can be called from other script functions 70 | - Script function calls can have parameters (underused in MKD) 71 | - Function calls can have variable/dynamic variables 72 | - Limited procedure creation from scripts 73 | - Most executable objects exported into MKO (fightstyle, character, stage data and more) 74 | - FX fully moved to MKO 75 | 76 | ## MK Armageddon 77 | - Added variable links 78 | - Added multiple function sets (eg. FX, game, core) 79 | - Added ID based string variables instead of data offsets 80 | - Functions and variables no longer have access to every variable, they need to be linked first 81 | 82 | ## MK VS DC 83 | - Added imports from other MKOs 84 | - Added assets section, which replaces previously hardcoded asset tables 85 | - Changed bytecode format 86 | 87 | ## MK 9 88 | - Added seperate sounds asset section which includes character specific sounds 89 | - Added variable name hashing (FNV1) 90 | - Added tweakvars section which allows quick access to important variables 91 | - Added "fixup" section for quick file patches/edits 92 | 93 | ## Injustice 94 | - Basically identical to MK9 structure wise 95 | 96 | ## Mortal Kombat X 97 | - Changed bytecode format 98 | - Tweakvars exported to a seperate file 99 | - Merged sounds section with assets like in MKvsDC 100 | 101 | ## Injustice 2 102 | - New tweakvar info section 103 | - Moved bytecode section right after header 104 | - Otherwise identical to MKX 105 | 106 | ## Mortal Kombat 11 107 | - Changed function entry struct 108 | - Changed extern/extern vars entry struct 109 | - Otherwise identical to Injustice 2 110 | 111 | ## Mortal Kombat 12 (1) 112 | - Removed variable and function name hashing 113 | - Functions now require multiple callback types (Brutality, Victory etc.) 114 | - All data is now directly after size/amount 115 | - Changed function entry struct, bytecode is now in function struct 116 | - Variables data was moved into `__global__` stack data 117 | - Otherwise identical to Mortal Kombat 11 118 | -------------------------------------------------------------------------------- /data/function_hash_list.txt: -------------------------------------------------------------------------------- 1 | ; hash table 2 | ; format: hash name 3 | ; 4 | 0xB216C246 SlotFileManager_UnloadSlot 5 | 0xF5C9D5A7 FGLadderMode_GetCachedSecretFightDataC 6 | 0x815ABB8E GetLadderMode 7 | 0xBA827B70 FGLadderMode_CacheSecretFightData 8 | 0x56D22214 FGGameInfo_SetFightingState 9 | 0x11D74C41 FGLadderMode_ResetSecretFightData 10 | 0xC5367FE1 FGLadderMode_RefreshPlayerLevelAndLoadout 11 | 0x592F336A FGLadderMode_WonLadderFight 12 | 0xDE148F14 GamelogicJump 13 | 0x1BB2B800 PLAYER_INFO_GetLadderEndingC 14 | 0x5B06C2B6 sleep 15 | 0x364A6DFE NRSString_GetCharPtrC 16 | 0x5239A468 MKS_HashString 17 | 0xE6192EF LadderGetUserEntity 18 | 0x8B312D40 MK11ExperienceManager_ResetFinalizeFlag 19 | 0x775616EB FGUserEntity_GetUnlockTracker 20 | 0xDF2AF9F1 UnlockTracker_ClearUnlockMessages 21 | 0xFBD1E1BE UnlockTracker_IgnoreAddOnFinalizeAssert 22 | 0x185640BF LootDropList_StackCtor 23 | 0xFC3B08B7 LootTable_GetResult_LootDropListP_FGUserEntityP 24 | 0x59291560 LootDropList_NumC 25 | 0xCC83AC68 BILootDropSourceDataMatch_StackCtor 26 | 0x9C27D448 LootDropList_RewardItems_FGUserEntityP_BILootDropSourceData_constR 27 | 0x36FBFC01 MK11ExperienceManager_FinalizeExperience 28 | 0xF152C543 ShowGenericUnlockScreen_UIScreenUnlockStyle_MKStringType_MKStringType_FGUserEntityP_MK_BOOL_MK_BOOL 29 | 0x8493FA93 ShowGenericUnlockScreen_UIScreenUnlockStyle_MKStringType_MKStringType_FGUserEntityP_MK_BOOL_MK_BOOL 30 | 0xCAAA8DC1 FadeToBlack 31 | 0x291CDEE9 FGGameInfo_KillAllHUD 32 | 0xAA7360AA CurrentLadder_GetCurrentLadderFight 33 | 0x1360A21B SecretFightData_IsSetC 34 | 0xCA30FD87 SecretFightData_IsChallengeMet 35 | 0x9E37968 UIEndOfMatchScreen_GetScreenInstance 36 | 0xCEF1CD2 FGAudio_StopMusic 37 | 0x49BA402F FGGameInfo_MustGetActivePlayerInfoFromTeamC 38 | ; MK12 39 | 0x700CC6D2 MKCharacter_IsQuickUppercutRecoveryEnabled 40 | 0x1F23F5F0 MKCharacter_IsSupermoveAllowed 41 | 0x455735B7 MK12BrutalityBlood_Start -------------------------------------------------------------------------------- /data/hashdb.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ermaccer/mkoasm/dffef55ec0388bc507ddb5071d47e78ed44f4b6e/data/hashdb.bin -------------------------------------------------------------------------------- /data/hashtable.txt: -------------------------------------------------------------------------------- 1 | ; hash table 2 | ; format: hash name 3 | ; 4 | 0xBBF43F8F void. 5 | 0x63DC55F1 U32. 6 | 0x685F5457 void.U32. 7 | 0x2C2FAF20 char_shaokahn_player_data 8 | 0xC508502F shaokahn_globals 9 | 0x6CB13B28 shaokahn_hammer_toss_pad_info 10 | 0x5F332117 shaokahn_hammer_uppercut_pad_info 11 | 0xF4D77FFB shaokahn_spear_toss_pad_info 12 | 0x36A7383 shaokahn_hammer_toss 13 | 0x9C796476 shaokahn_hammer_uppercut 14 | 0x8F7E2202 shaokahn_spear_toss 15 | ; from mkvsdc 16 | 0x24414499 FIELD_OF_VIEW_SETTINGS 17 | 0x4650CB8B FaceBlendSequences 18 | 0x5EC63E29 HeadTracker 19 | 0xE19A736B MKCharacterBones 20 | 0x8034924E MKCharacterFaceBones 21 | 0x215D2023 MKCharacterFlippedBones 22 | 0xD9E4C367 MKCharacterLeftHandBones 23 | 0x7BA829DC MKCharacterRightHandBones 24 | 0x898E0AFE MKDefaultGroundCollisions 25 | 0xBCA6E140 MKONLINE_CHAT_USER_NAME_CLOSETAG 26 | 0x8F3B437C MKONLINE_CHAT_USER_NAME_OPENTAG 27 | 0x52285A46 MKONLINE_CHAT_USER_NAME_OPENTAG_HILITE 28 | 0xE28B391C MKONLINE_CHAT_USER_SEP 29 | 0xECFA5994 MKONLINE_CHAT_USER_TEXT_CLOSETAG 30 | 0x17568018 MKONLINE_CHAT_USER_TEXT_OPENTAG 31 | 0xB0691527 MKONLINE_GAME_FLAGS_PARAM_KEY 32 | 0xB7B00D47 MKONLINE_GAME_MODE_PARAM_KEY 33 | 0xBE164D97 MKONLINE_GAME_PRI_SLOTS_PARAM_KEY 34 | 0x70F81025 MKONLINE_GAME_PUB_SLOTS_PARAM_KEY 35 | 0x338CDDFA MKONLINE_GAME_TYPE_PARAM_KEY 36 | 0x9C5DC106 MKONLINE_GAME_VERSION_PARAM_KEY 37 | 0xD71020BC MKONLINE_MATCH_ID_PARAM_KEY 38 | 0x51461FD1 MKONLINE_NAT_TYPE_PARAM_KEY 39 | 0xA0B56D98 MKONLINE_PLAYER_ADDR_PARAM_KEY 40 | 0xB30B15C4 MKONLINE_PLAYER_NAME_PARAM_KEY 41 | 0x9A6227D1 MKONLINE_PLAYER_PING_PARAM_KEY 42 | 0xC5C53A34 MKONLINE_PLAYER_STATE_PARAM_KEY 43 | 0x4872951E MKONLINE_RESTRICTED_FO_KEY 44 | 0x1566A17 anti_air_attack 45 | 0xCB3C6D10 anti_jump_away_attack 46 | 0x390AAB2A anti_laydown 47 | 0x95CA99EE asset_package 48 | 0xB24DFC43 burn_loop 49 | 0x49F32248 distance 50 | 0xC9CA1C0C dizzy_attack 51 | 0xEC675524 ending 52 | 0xBCE4BFA0 escape 53 | 0x182D43EE fatality_attack 54 | 0xC3114BE9 hi_fast 55 | 0x1532075 high_reach 56 | 0xEC92E21A his_info 57 | 0x8D5345C9 his_obj 58 | 0x72B17156 jumping_attack 59 | 0xCFDF8DBD knock_down_attack 60 | 0xA1F2686B likelihood_freefall_dodge_mistake_table 61 | 0xEF615CB7 likelihood_freefall_dodge_success3_table 62 | 0x9E19AE8A likelihood_to_cause_switcharoo_table 63 | 0x4C53BD54 low_attack 64 | 0xBB16D0C7 medium_attack 65 | 0x97C32E29 mk_game_info 66 | 0x1F8E9276 movelist 67 | 0x98FF152 my_info 68 | 0x8C580C81 my_obj 69 | 0x27988A75 pop_up_attack 70 | 0xA0A8FD02 super_far_distance 71 | 0xE4CD2D3D supermovelist 72 | 0x864A987E taunt_attack 73 | 0xBC2C0BE9 test 74 | 0x8D1B5A98 threeD_attack 75 | 0xAB4518D2 throw_attack 76 | 0x9AE9858B training 77 | ; dumped 78 | 0x132415D9 numKeypoints 79 | 0x164D172C slowMoTicks 80 | 0x193A6E01 playedFromLeftValues 81 | 0x19A8017A keypointLocOffsets 82 | 0x1BAE1201 shakeTicks 83 | 0x1D00E8BA bgnd_stgardensn_background_data 84 | 0x1F6B5E11 load_screen_names 85 | 0x2411C343 CameraVariables 86 | 0x26B34A96 player_locked_list 87 | 0x32E92402 char_reptile_player_data 88 | 0x3BB64CA9 GOTY_player_unlocked_list 89 | 0x4D73CA05 numCameras 90 | 0x529CBE7D char_reptile_audio_override 91 | 0x58A7FE35 postFxTicks 92 | 0x5B7632BE numSequenceTicks 93 | 0x69CAB6F9 shakeCounts 94 | 0x7769EE6B numSlowMos 95 | 0x78E32E34 char_scorpion_player_data 96 | 0x7932D11A numPostFxs 97 | 0x797B1DA8 keypointBlendTypes 98 | 0x7E51C1BB version 99 | 0x887CC6CE slowMoSpeeds 100 | 0x8DC0852D background_locked_list 101 | 0x918F441C char_mileena_player_data 102 | 0x93A97A20 cameraNames 103 | 0x93B1031A slowMoBlendTypes 104 | 0x974D7FC4 shakeIntensities 105 | 0xA1B65B89 keypointRotOffsets 106 | 0xA8F08E43 char_mileena_audio_override 107 | 0xAC14249A player_start_table 108 | 0xADFF5BA7 postFxNames 109 | 0xBA50B66B char_scorpion_audio_override 110 | 0xC3849346 keypointTicks 111 | 0xD1C4E533 keypointGameCamKeys 112 | 0xEBFECCC8 keypointFovs 113 | 0xED5571CE numShakes 114 | 0xF1308524 slowMoNumTicks -------------------------------------------------------------------------------- /data/mk11_def.txt: -------------------------------------------------------------------------------- 1 | ; MK11 definition file 2 | ; format: name functionType functionSet id numArgs argTypes 3 | ; 4 | ; 5 | ; 6 | ; 7 | ; 8 | jump 15 0 1 1 0 9 | push_arg 1 0 529 3 0 0 0 10 | get_stack_addr 7 0 4096 1 9 11 | set_stack_val 1 0 513 2 0 9 12 | load_and_run_script_function 1 0 533 3 0 4 6 13 | call_script_function 11 0 517 2 8 1 14 | call_script_function 11 0 5 2 8 1 15 | call_builtin_function 12 0 2561 1 7 16 | call_builtin_function 12 0 2049 1 7 17 | 18 | -------------------------------------------------------------------------------- /data/mk12_def.txt: -------------------------------------------------------------------------------- 1 | ; MK12 definition file 2 | ; format: name functionType functionSet id numArgs argTypes 3 | ; 4 | ; 5 | ; 6 | ; 7 | ; 8 | push_arg 5 0 20 3 0 0 5 9 | push_single_to_stack 1 0 517 2 0 0 10 | push_to_stack 1 0 513 1 0 11 | call_script_function 11 0 5 2 8 0 12 | call_builtin_function 12 0 2561 1 7 13 | call_builtin_function 12 0 2049 1 7 -------------------------------------------------------------------------------- /data/mka_def.txt: -------------------------------------------------------------------------------- 1 | ; MKA definition file 2 | ; format: name functionSet id numArgs argTypes 3 | ; 4 | ; 5 | ; FUNCTION SETS 6 | ; 0 - internal 7 | ; 1 - common table 8 | ; 2 - background table 9 | ; 3 - game (like mkd/u/da) 10 | ; 128 - fx 11 | ; 12 | ; 13 | ; 14 | ; COMMON TABLE 15 | sleep 1 0 1 0 16 | true_branch 1 1 1 0 17 | branch 1 2 1 0 18 | script_exit 1 9 1 0 19 | get_new_mkobj 1 40 1 5 20 | insert_item_obj 1 41 2 5 5 21 | ck_item_obj 1 43 1 5 22 | destroy_item_obj 1 52 1 5 23 | update_mkobj 1 57 1 5 24 | set_obj_flag 1 56 3 5 0 0 25 | shake_camera 1 82 2 0 1 26 | snd_req 1 87 1 2 27 | random_voice 1 95 1 0 28 | obj_set_scale 1 195 2 5 5 29 | obj_get_pos_vel 1 218 2 5 5 30 | obj_set_pos_vel 1 219 2 5 5 31 | get_adjusted_speed 1 260 2 1 1 32 | flying_collision 1 262 10 0 1 0 0 0 1 1 1 1 1 33 | get_bid_with_flip 1 271 2 5 0 34 | insert_particle_mkobj 1 357 1 5 35 | is_boss_character 1 391 1 5 36 | is_super_boss_character 1 392 1 5 37 | start_blood_particles 1 398 4 0 0 5 5 38 | start_blood_particles_scripts 1 400 2 0 0 39 | pfxhandle_spawn_at_bid_next 1 416 3 5 5 0 40 | pfxhandle_spawn_at_bid 1 417 3 0 5 5 41 | pfxhandle_spawn_at_bid_next_bind_render 1 420 3 5 5 5 42 | obj_set_pos 1 434 2 5 5 43 | obj_get_pos 1 435 2 5 0 44 | obj_set_light_flag 1 448 2 5 0 45 | scale_v3 1 461 3 5 5 5 46 | ; BACKGROUND TABLE 47 | bgnd_place_point_light_for_ticks 2 282 4 5 0 5 0 48 | ; GAME TABLE 49 | exit_react 3 5 6 0 0 0 0 0 0 50 | am_i_flipped 3 7 0 51 | am_i_airborn 3 15 0 52 | was_button_pressed 3 16 1 0 53 | two_player_animation 3 19 2 0 1 54 | two_player_animation_flip 3 25 2 0 1 55 | attack_to_frame_x 3 26 8 0 1 1 1 1 0 0 0 56 | launch_n_land_ani 3 27 8 0 1 1 1 0 1 1 1 57 | miss_branch 3 31 1 0 58 | block_branch 3 32 1 0 59 | hit_branch 3 33 1 0 60 | was_button_and_direction 3 34 2 0 0 61 | true_branch_next_style 3 36 1 0 62 | if_switching_to 3 37 1 0 63 | exit_attack_with 3 44 6 0 0 0 0 0 0 64 | ani_col_abort 3 45 7 1 0 1 1 0 1 0 65 | attack_opponent_with 3 46 3 0 5 0 66 | get_current_player_number 3 50 0 67 | set_player_step 3 52 1 1 68 | disable_grounding 3 54 0 69 | disable_grounding2 3 55 0 70 | blend_to_ani 3 56 3 0 0 1 71 | glitch_to_ani 3 57 2 0 0 72 | blend_to_ani_frame 3 59 4 0 0 1 1 73 | back_to_normal 3 82 0 74 | set_my_state 3 83 1 0 75 | set_my_secondary_state 3 87 1 0 76 | ani_to_frame_x 3 76 1 1 77 | ani_to_blend_frame 3 77 1 1 78 | slow_ani_x 3 78 2 1 1 79 | set_ani_speed 3 88 1 1 80 | init_ground_move 3 90 0 81 | init_ground_move_no_aniproc 3 91 0 82 | init_air_move 3 93 0 83 | init_air_move_no_aniproc 3 94 0 84 | init_3d_move 3 96 0 85 | tightrope_restrictions_off 3 100 0 86 | launch_me_up 3 101 2 1 1 87 | face_opponent_now 3 105 0 88 | ani_to_end 3 108 0 89 | ani_through_end 3 109 0 90 | force_away 3 113 4 1 0 1 0 91 | shake_hit_voice 3 116 4 0 1 0 0 92 | random_hit 3 118 1 0 93 | plyr_snd_req 3 119 1 0 94 | stop_me 3 121 0 95 | plyr_rotate_obj_y180 3 124 0 96 | random_voice_him 3 128 1 0 97 | clear_my_face_opponent_flag 3 135 0 98 | disable_this_move_exec 3 138 2 0 0 99 | turn_me_pi 3 139 0 100 | damage_me 3 141 1 1 101 | damage_him 3 142 1 1 102 | ejb_release_other_player 3 147 1 0 103 | ejb_too_close_repell 3 148 0 104 | player_feet_land_chores 3 152 0 105 | wait_to_land 3 153 0 106 | disable_both_repel_flags 3 154 0 107 | rotate_towards_him 3 156 1 1 108 | ejb_call 3 158 1 0 109 | back_rollup_check 3 160 0 110 | myvel_my_angle_y 3 157 3 1 1 1 111 | set_ani_weight 3 171 1 1 112 | weapon_trail_off 3 173 0 113 | plyr_weapon_grab 3 174 2 5 1 114 | face_bleed_me 3 180 1 0 115 | wall_eligible_on 3 181 0 116 | adjust_my_damage_multiplier 3 185 1 1 117 | if_collision_autoface_me 3 188 0 118 | if_collision_autoface_him 3 189 0 119 | ani_to_frame_x_col 3 190 7 1 0 1 1 0 1 0 120 | got_hit_fx 3 191 7 0 0 0 0 0 0 0 121 | whoosh_fx 3 195 1 0 122 | special_move_cam_setup 3 197 8 1 1 1 1 1 0 0 0 123 | set_block_requirement 3 199 1 0 124 | mks_set_flipped_bones 3 229 1 0 125 | mks_start_goro_arms_fixup 3 230 0 126 | mks_cloth_bones_init_by_tbl 3 231 2 5 0 127 | mks_mat_id_set_zbias 3 233 2 0 1 128 | mks_cb1_eq_cloth_bone 3 234 1 0 129 | mks_cb2_eq_cloth_bone 3 235 1 0 130 | mks_insert_cloth_force_bones 3 236 2 1 1 131 | mks_cb1_set_ground_y 3 238 1 1 132 | mks_cb1_add_coll_pt 3 239 3 1 1 1 133 | mks_cb1_set_coll_offset_x 3 240 2 1 1 134 | mks_cc1_eq_insert_cloth_coll 3 243 2 0 1 135 | mks_cc1_expand_cyl 3 244 2 1 1 136 | mks_ccp1_eq_insert_cloth_coll_plane 3 245 5 0 1 1 1 1 137 | mks_cc1_insert_cb1 3 246 0 138 | mks_ccp1_insert_cb1 3 247 0 139 | mks_cc1_set_coll_fnc_eq_cloth_coll_point_cyl_abs 3 249 0 140 | taunt_increase_life 3 301 2 1 1 141 | do_victory_camera 3 310 1 5 142 | get_victory_flip_flags 3 312 0 143 | do_i_have_life_left 3 315 0 144 | high_flash_check 3 316 0 145 | medium_flash_check 3 317 0 146 | get_my_particle_player_bank_num 3 323 0 147 | start_baraka_blades_monitor 3 326 0 148 | register_baraka_cb_functions 3 327 0 149 | plyr_start_script_in_proc 3 328 2 0 0 150 | ani_1_frame 3 330 0 151 | ani_loop_more_frames 3 332 1 1 152 | head_tracking_off 3 335 0 153 | player_area_collision_ticks 3 347 8 1 1 0 1 0 1 0 1 154 | is_local_plyr 3 369 0 155 | local_collision_allowed_plyr_pdata 3 371 0 156 | start_special_weapon_monitor 3 383 1 0 157 | is_he_airborn 3 387 0 158 | single_frame_collision_check 3 388 6 0 1 0 0 0 1 159 | reaction_sync_advance 3 395 0 160 | wait_for_collision_result 3 396 0 161 | clear_collision_result 3 397 0 162 | collision_result_dont_care 3 398 0 163 | get_projectile_script_plyr_num 3 399 0 164 | get_projectile_script_plyr_pdata 3 401 0 165 | get_projectile_script_last_pos 3 403 1 5 166 | get_projectile_script_velocity 3 404 1 5 167 | set_active_projectile_continue_thru_hit 3 409 0 168 | set_active_projectile_tracking_light 3 410 1 5 169 | set_active_projectile_collision_info 3 411 4 1 0 1 1 170 | start_plyr_attack 3 412 1 0 171 | ani_x_more_frames 3 421 1 1 172 | resume_effect_at_obj_bid 3 424 5 5 5 5 0 0 173 | reaction_xfer_him 3 445 3 0 1 0 174 | start_projectile_from_plyr_bone 3 454 6 5 0 0 1 1 5 175 | set_active_projectile_rx_info 3 455 3 0 1 0 176 | set_active_projectile_not_duckable 3 456 0 177 | set_active_projectile_hit_script 3 458 1 0 178 | set_active_projectile_end_script 3 460 1 0 179 | set_active_projectile_hit_gnd_script 3 461 1 0 180 | active_projectile_setup_done 3 465 0 181 | set_active_projectile_sound 3 473 3 0 2 2 182 | mks_debug_display_cloth_ontop 3 482 1 0 183 | check_to_register_miss 3 484 0 184 | advance_to_weapon_style 3 503 1 5 185 | get_his_plyr_obj 3 541 0 186 | get_my_plyr_obj 3 542 0 187 | get_his_plyr_pdata 3 544 0 188 | get_my_plyr_pdata 3 545 0 189 | plyr_pdata_get_cmo 3 556 1 5 190 | plyr_pdata_get_plyr_num 3 557 1 5 191 | plyr_pdata_get_pchr 3 558 1 5 192 | get_bone_world_pos 3 566 3 5 0 5 193 | get_bone_offset_world_pos 3 567 4 5 0 5 5 194 | ; FX TABLE 195 | fx 128 0 1 0 196 | create_step_fx 128 7 2 5 0 197 | create_multiemit_step_fx 128 8 3 5 0 0 198 | z_bias 128 14 1 1 199 | fx_by_owner 128 20 2 0 5 200 | emit_in_range 128 21 3 0 1 1 201 | emit_color 128 22 5 0 0 0 0 0 202 | emit_uv 128 23 3 0 0 0 203 | emit_cuboid 128 25 4 0 1 1 1 204 | emit_cartesian 128 28 7 0 1 1 1 1 1 1 205 | emission_duration 128 30 1 1 206 | texture_animation_with_vsize 128 33 4 0 1 1 1 207 | emit_spherical 128 34 2 0 1 208 | emit_from_pos 128 37 7 0 0 0 0 1 1 1 209 | emit_value 128 39 2 0 1 210 | emit_value_i 128 40 2 0 0 211 | spawn_random_size 128 47 1 5 212 | fx_reset 128 50 1 5 213 | fx_resume_emit 128 52 1 5 214 | fx_pause_emit 128 53 1 5 215 | fx_reset_emit 128 54 1 5 216 | initial_set_float 128 66 3 0 0 0 217 | update_add 128 68 2 0 0 218 | update_copy 128 69 1 0 219 | update_add_constant_v3 128 70 4 0 1 1 1 220 | update_add_constant 128 71 2 0 1 221 | update_fade_alpha 128 76 4 0 0 1 1 222 | update_fade_alpha2 128 77 6 0 0 0 1 0 0 223 | update_lerp_color 128 78 6 0 0 1 0 0 0 224 | update_texanim 128 79 5 0 0 1 0 0 225 | update_texanim_hold 128 80 5 0 0 1 0 0 226 | update_bounce 128 81 4 0 0 0 1 227 | change_on_less 128 90 2 0 1 228 | kill_on_greater 128 86 2 0 1 229 | fx_set_param_v3 128 97 5 5 0 1 1 1 230 | fx_set_render_priority 128 101 2 5 0 231 | -------------------------------------------------------------------------------- /data/mkd_def.txt: -------------------------------------------------------------------------------- 1 | ; MKD definition file 2 | ; format: name id numArgs argTypes 3 | ; 4 | ; 5 | sleep 0 1 0 6 | true_branch 1 1 0 7 | branch 2 1 0 8 | script_return 8 0 9 | script_exit 9 1 0 10 | exit_6 11 6 0 0 0 0 0 0 11 | exit_react 12 6 0 0 0 0 0 0 12 | blend_to_ani 13 3 0 0 1 13 | am_i_flipped 15 00 14 | am_i_on_the_left 18 0 15 | am_i_airborn 23 0 16 | was_button_pressed 24 1 0 17 | two_player_animation 26 2 0 1 18 | two_player_animation_match_attacker 27 2 0 1 19 | two_player_animation_flip 28 2 0 1 20 | attack_to_frame_x 29 8 0 1 1 1 1 0 0 0 21 | launch_n_land_ani 31 8 0 1 1 1 0 1 1 1 22 | glitch_to_ani 33 2 0 0 23 | glitch_him_to_ani 34 2 0 0 24 | blend_to_ani_frame 35 4 0 0 1 1 25 | set_player_step 40 1 1 26 | miss_branch 42 1 0 27 | block_branch 43 1 0 28 | hit_branch 44 1 0 29 | was_button_and_direction 45 2 0 0 30 | ani_col_abort 46 7 1 0 1 1 0 1 0 31 | true_branch_next_style 48 1 0 32 | if_switching_to 50 1 0 33 | disable_grounding 52 0 34 | camera_set_lookat_focus 58 1 0 35 | camera_set_movement_focus 59 1 0 36 | attack_opponent_with 70 3 0 0 0 37 | randu 73 1 0 38 | exit_attack_with 74 6 0 0 0 0 0 0 39 | get_current_player_number 75 0 40 | get_plyr_pdata_flag 77 2 5 0 41 | trial_add_required_attack 84 2 0 0 42 | get_new_mkobj 95 1 5 43 | insert_item_obj 96 2 5 5 44 | ck_item_obj 98 1 5 45 | destroy_item_obj 99 1 5 46 | get_limb_obj 100 2 5 5 47 | set_obj_flag 102 3 5 0 0 48 | update_mkobj 103 1 5 49 | xfer_proc 110 2 5 0 50 | plyr_spawn_his_anim_limb 111 7 5 5 0 0 0 0 1 51 | start_gusher 112 5 5 5 0 0 0 52 | ani_to_frame_x 128 1 1 53 | ani_to_blend_frame 129 1 1 54 | slow_ani_x 130 2 1 1 55 | slow_ani_x_if_miss 131 3 1 1 1 56 | back_to_normal 134 0 57 | set_my_state 135 1 0 58 | set_my_secondary_state 136 1 0 59 | set_ani_speed 137 1 1 60 | init_ground_move 139 0 61 | init_ground_move_no_aniproc 140 0 62 | init_air_move 142 0 63 | init_air_move_no_aniproc 143 0 64 | init_3d_move 145 0 65 | tightrope_restrictions_on 148 0 66 | tightrope_restrictions_off 149 0 67 | launch_me_up 150 2 1 1 68 | face_opponent_now 153 0 69 | ani_to_end 155 0 70 | ani_through_end 156 0 71 | force_away 158 4 1 0 1 0 72 | shake_camera 159 2 0 1 73 | snd_req 161 1 2 74 | pan_vol_pitch_random_hit 166 4 0 1 1 1 75 | random_voice 168 1 0 76 | random_foot 169 1 0 77 | snd_stop 170 1 5 78 | shake_hit_voice 172 4 0 1 0 0 79 | random_hit 174 1 0 80 | plyr_snd_req 175 1 0 81 | get_mode_of_play 178 0 82 | stop_me 181 0 83 | plyr_rotate_obj_y180 184 0 84 | myvel_his_angle_y 182 3 0 1 1 85 | random_voice_him 188 1 0 86 | step_throw_into_check 190 0 87 | clear_my_face_opponent_flag 193 0 88 | disable_this_move_exec 196 2 0 0 89 | turn_me_pi 197 0 90 | damage_me 199 1 1 91 | damage_him 200 1 1 92 | ejb_release_other_player 201 1 0 93 | ejb_too_close_repell 202 0 94 | player_feet_land_chores 205 0 95 | wait_to_land 206 0 96 | disable_both_repel_flags 207 0 97 | rotate_towards_him 208 1 1 98 | myvel_my_angle_y 209 3 1 1 1 99 | ejb_call 210 1 0 100 | back_rollup_check 212 0 101 | set_ani_weight 221 1 1 102 | weapon_trail_off 223 0 103 | plyr_weapon_grab 224 2 5 1 104 | face_bleed_me 227 1 0 105 | wall_eligible_on 228 0 106 | wall_eligible_off 229 0 107 | adjust_my_damage_multiplier 232 1 1 108 | if_collision_autoface_me 236 0 109 | if_collision_autoface_him 237 0 110 | ani_to_frame_x_col 238 7 1 0 1 1 0 1 0 111 | camera_set_movement_mode 250 1 0 112 | camera_set_look_mode 251 1 0 113 | camera_set_glitch_flag 252 0 114 | camera_set_movement_rate 255 1 1 115 | camera_set_rotation_rate 256 1 1 116 | camera_setup_radial_position 268 3 1 1 1 117 | camera_setup_tightrope_angle_offset 269 2 1 1 118 | camera_special_function 270 1 0 119 | camera_set_speed_scalar 275 1 1 120 | got_hit_fx 292 7 0 0 0 0 0 0 0 121 | whoosh_fx 296 1 0 122 | special_move_cam_setup 297 8 1 1 1 1 1 0 0 0 123 | set_block_requirement 299 1 0 124 | ; clothing stuff 125 | mks_cloth_bones_init_by_tbl 302 2 0 0 126 | mks_mat_id_set_zbias 303 2 0 1 127 | mks_cb1_eq_cloth_bone 304 1 0 128 | mks_cb2_eq_cloth_bone 305 1 0 129 | mks_insert_cloth_force_bones 306 2 1 1 130 | mks_set_ground_y_all_cloth_bones 307 1 1 131 | mks_cb1_set_ground_y 308 1 1 132 | mks_cb1_add_coll_pt 309 3 1 1 1 133 | mks_cb1_set_coll_offset_x 310 2 1 1 134 | mks_cb1_set_scale 312 4 0 1 1 1 135 | mks_cc1_eq_insert_cloth_coll 313 2 0 1 136 | mks_cc1_expand_cyl 314 2 1 1 137 | mks_ccp1_eq_insert_cloth_coll_plane 315 5 0 1 1 1 1 138 | mks_cc1_insert_cb1 316 0 139 | mks_ccp1_insert_cb1 317 0 140 | mks_cc1_set_coll_fnc_eq_cloth_coll_point_cyl_abs 319 0 141 | ; end clothing 142 | jab_attach_point_light_to_obj_bone 552 3 0 5 0 143 | jab_spawn_point_light_at_world_pos 553 2 0 0 144 | camera_set_anim_aux_data 591 1 0 145 | build_bones_tbl 599 2 0 5 146 | player_has_item 653 2 0 0 147 | set_active_projectile_block_script 669 1 0 148 | kick_the_camera 676 0 149 | pz_fighter_create_space_between_fighters_for_special_moves 700 0 150 | get_collision_result 711 0 151 | taunt_increase_life 712 2 1 1 152 | face_ang_from_pos_to_him 720 3 5 0 0 153 | do_victory_camera 726 1 0 154 | get_my_plyr_num 727 0 155 | get_victory_flip_flags 729 0 156 | do_i_have_life_left 732 0 157 | bgnd_create_danger_zone 734 5 0 0 0 1 0 158 | bgnd_enable_danger_zone 735 2 0 0 159 | bgnd_set_danger_zone_center_position 736 3 1 1 1 160 | bgnd_set_danger_zone_radius 741 1 1 161 | bgnd_delete_danger_zone 743 1 0 162 | bgnd_place_point_light_for_ticks 744 4 0 0 1 0 163 | high_flash_check 745 0 164 | medium_flash_check 746 0 165 | get_my_particle_player_bank_num 752 0 166 | start_baraka_blades_monitor 769 0 167 | register_baraka_cb_functions 770 0 168 | bgnd_start_sobj_uv_scroll 773 6 0 1 1 0 0 0 169 | plyr_start_script_in_proc 776 2 0 0 170 | frand 778 1 1 171 | ani_1_frame 786 0 172 | ani_loop_more_frames 787 1 1 173 | load_aux_weapon 788 1 0 174 | head_tracking_off 789 0 175 | bgnd_hide_sobj_and_children 793 1 0 176 | bgnd_unhide_sobj_and_children 794 1 0 177 | obj_set_scale 806 2 5 0 178 | bgnd_preload_named_model 809 2 0 0 179 | pz_fighter_reaction_xfer_him 816 1 0 180 | restart_effect 872 1 0 181 | sfrand 894 1 1 182 | bgnd_current_rx_get_info 912 1 0 183 | set_background_obstacle_repel_flag 922 2 0 0 184 | set_background_obstacle_disable_flag 923 2 0 0 185 | get_adjusted_speed 1105 2 1 1 186 | player_area_collision_ticks 1106 6 1 1 0 1 0 1 187 | flying_collision 1107 10 0 1 0 0 0 1 1 1 1 1 188 | set_constrain_last_pos_pdata 1110 1 0 189 | force_ai_style 1135 1 0 190 | pan_vol_pitch_snd_req 1136 4 0 0 1 1 191 | is_local_plyr 1139 0 192 | local_collision_allowed_plyr_pdata 1141 0 193 | xz_distance_between_players 1149 0 194 | start_special_weapon_monitor 1150 1 0 195 | is_he_airborn 1154 0 196 | single_frame_collision_check 1155 6 0 1 0 0 0 1 197 | player_area_collision_check 1156 5 1 1 0 0 0 198 | reaction_sync_advance 1163 0 199 | wait_for_collision_result 1164 0 200 | clear_collision_result 1165 0 201 | collision_result_dont_care 1166 0 202 | ani_x_more_frames 1187 1 1 203 | get_projectile_script_plyr_num 1189 0 204 | get_projectile_his_plyr_num 1190 0 205 | get_projectile_script_plyr_pdata 1191 0 206 | get_projectile_script_last_pos 1192 1 0 207 | get_projectile_script_velocity 1193 1 0 208 | set_active_projectile_continue_thru_hit 1197 0 209 | set_active_projectile_tracking_light 1198 1 0 210 | set_active_projectile_collision_info 1199 4 1 0 1 1 211 | resume_effect_at_obj_bid 1219 5 5 5 5 0 0 212 | resume_effect_at_plyr_num_bid 1220 5 5 0 5 0 0 213 | reaction_xfer_him 1227 3 0 1 0 214 | start_projectile_from_plyr_bone 1229 6 5 0 0 1 1 0 215 | set_active_projectile_rx_info 1230 3 0 1 0 216 | set_active_projectile_not_duckable 1231 0 217 | set_active_projectile_hit_script 1233 1 0 218 | set_active_projectile_end_script 1234 1 0 219 | set_active_projectile_hit_gnd_script 1235 1 0 220 | active_projectile_setup_done 1236 0 221 | set_active_projectile_velocity 1237 1 0 222 | set_active_projectile_target_ground 1238 3 1 1 1 223 | set_active_projectile_sound 1244 3 0 0 0 224 | start_plyr_attack 1249 1 0 225 | get_bid_with_flip 1250 2 5 0 226 | mks_debug_display_cloth_ontop 1252 1 0 227 | bgnd_get_int 1255 1 0 228 | bgnd_get_float 1257 1 0 229 | set_obj_light_flags 1293 2 0 0 230 | load_named_model_for_player 1296 4 0 5 0 0 231 | get_player_number 1297 1 5 232 | insert_fgnd_mkobj 1298 1 0 233 | obj_set_gravity 1299 2 5 1 234 | obj_turn_gravity_off 1300 1 5 235 | destroy_mkobj 1301 1 5 236 | pfx_plyr_bankowner 1375 1 5 237 | obj_get_bid_for_tid 1384 2 5 5 238 | insert_particle_mkobj 1386 1 5 239 | check_to_register_miss 1398 0 240 | mks_animpdata_set_cur_frame 1400 2 5 1 241 | plyr_turn_off_mirrorguy 1407 1 5 242 | plyr_turn_on_mirrorguy 1408 1 5 243 | plyr_turn_off_shadowbox 1409 1 5 244 | set_pdata_anim_step 1412 2 5 1 245 | limb_sever_update_slide_end_coeff 1414 2 5 1 246 | limb_sever_set_motion 1415 11 5 0 0 1 5 0 1 0 1 0 0 0 247 | limb_sever_find_existing_update_proc 1416 3 5 0 0 248 | mks_limb_sever 1417 3 5 0 0 249 | limb_sever_pop_head_up 1418 5 5 0 1 1 0 250 | limb_sever_bone_attach 1419 8 5 5 0 0 5 0 0 0 251 | fatality_release_other_player 1423 0 252 | ft_fake_bone_matcher 1425 8 5 5 0 0 0 0 0 0 253 | fat_bgnd_char_setup_radius_check 1427 1 0 254 | bm_force_fake_child_bid 1428 2 5 5 255 | play_his_random_voice 1431 1 0 256 | play_his_snd_req 1432 1 0 257 | advance_to_weapon_style 1437 1 5 258 | show_single_weapon 1440 2 5 0 259 | weapon_reflection_show_hide 1441 3 5 0 0 260 | weapon_bm_ignore 1443 2 0 0 261 | bone_matcher_set_ang_pos 1444 6 5 5 0 0 0 0 0 262 | spawn_blood_pool_at_bid 1449 3 5 0 0 263 | start_blood_particles 1451 4 0 0 5 5 264 | start_sweat_particles 1452 4 0 0 5 5 265 | start_blood_particles_scripts 1453 2 0 0 266 | fatality_explode_victim 1456 3 5 1 1 267 | start_gore2_pebbles 1459 11 0 0 5 5 5 0 0 0 5 5 5 268 | limb_sever_show_z_meat_chunks 1466 3 5 0 0 269 | auto_calc_limbobj_bone_world_pos 1467 2 5 0 270 | limb_sever_throw_away 1468 3 5 0 0 271 | pfx_spawn_at_bid 1469 3 0 5 0 272 | pfxhandle_spawn_at_bid_next 1470 3 5 5 0 273 | pfxhandle_spawn_at_bid 1471 3 0 5 5 274 | pfxhandle_spawn_at_bid_next_bind_render 1473 3 5 5 0 275 | show_baraka_one_blade_only 1476 2 5 5 276 | mkscripts_destroy_bonematcher 1500 1 0 277 | obj_set_pos 1522 2 5 0 278 | obj_get_pos 1523 2 5 0 279 | obj_set_ang 1524 2 5 0 280 | obj_get_ang 1525 2 5 0 281 | obj_set_light_flag 1534 2 5 0 282 | obj_find_sobj_by_id 1535 2 5 0 283 | get_plyr_info 1536 0 284 | get_his_plyr_obj 1537 0 285 | get_my_plyr_obj 1538 0 286 | get_his_plyr_pdata 1541 0 287 | get_my_plyr_pdata 1542 0 288 | get_my_plyr_anim_pdata 1543 0 289 | plyr_pdata_get_his_plyr_pdata 1546 1 5 290 | plyr_pdata_get_plyr_obj 1547 1 5 291 | plyr_pdata_get_cmo 1550 1 5 292 | plyr_pdata_get_plyr_num 1551 1 5 293 | plyr_pdata_get_pchr 1553 1 5 294 | obj_set_pos_vel 1558 2 5 0 295 | obj_set_ang_vel 1559 2 5 0 296 | obj_get_ang_vel 1560 2 5 0 297 | start_bone_matcher 1561 5 5 0 0 0 0 298 | bone_matcher_parent_set_offset 1562 2 5 0 299 | bone_matcher_child_set_offset 1563 2 5 0 300 | get_bone_world_pos 1564 3 5 0 0 301 | mkobj_get_matrix 1569 2 5 0 302 | mkobj_get_matrix_right 1571 2 5 0 303 | v3_x_mat 1573 3 0 0 5 304 | v3_sub_v3 1574 3 0 0 0 305 | v3_add_v3 1575 3 0 0 0 306 | v3_add_v3_scaled 1576 4 0 0 0 1 307 | scale_v3 1577 3 0 0 5 308 | normalize_v3 1578 1 0 309 | length_v3 1592 1 0 310 | bind_to_bone 1598 1 0 311 | create_step_fx 1599 2 0 0 312 | create_multiemit_step_fx 1600 3 0 0 0 313 | create_multiemit_parametric_fx 1602 3 0 0 0 314 | set_decal_plane 1603 1 0 315 | z_bias 1606 1 1 316 | fx 1612 1 0 317 | fx_by_owner 1614 2 0 5 318 | emit_in_range 1615 3 0 1 1 319 | emit_color 1616 5 0 0 0 0 0 320 | emit_uv 1617 3 0 0 0 321 | emit_cuboid 1619 4 0 1 1 1 322 | emit_disc 1620 5 0 1 1 1 1 323 | emit_disc2 1621 6 0 0 0 1 1 1 324 | emit_cartesian 1622 7 0 1 1 1 1 1 1 325 | emit_cylindrical 1623 8 0 0 1 0 1 1 0 1 326 | emission_duration 1624 1 1 327 | texture_animation_with_vsize 1626 4 0 1 1 1 328 | emit_spherical 1627 2 0 1 329 | emit_from_pos 1630 7 0 0 0 0 1 1 1 330 | emit_value 1632 2 0 1 331 | emit_value_i 1633 2 0 0 332 | spawn_random_size 1639 1 0 333 | fx_reset 1644 1 5 334 | fx_next_emitter 1645 1 0 335 | fx_resume_emit 1646 1 5 336 | fx_pause_emit 1647 1 5 337 | fx_reset_emit 1648 1 5 338 | set_cycle_emission 1650 1 0 339 | initial_add_v3 1653 2 0 0 340 | initial_set_float 1654 3 0 0 0 341 | update_add 1656 2 0 0 342 | update_copy 1657 1 0 343 | update_add_constant_v3 1658 4 0 1 1 1 344 | update_add_constant 1659 2 0 1 345 | update_fade_alpha 1662 4 0 0 1 1 346 | update_fade_alpha2 1663 6 0 0 0 1 0 0 347 | update_lerp_color 1664 6 0 0 1 0 0 0 348 | update_texanim 1665 5 0 0 1 0 0 349 | update_texanim_hold 1666 5 0 0 1 0 0 350 | update_bounce 1667 4 0 0 0 1 351 | update_attract 1668 3 0 0 1 352 | kill_on_greater 1671 2 0 1 353 | change_on_greater 1674 2 0 1 354 | change_on_less 1675 2 0 1 355 | kill_on_y_less_than_field 1678 2 0 0 356 | fx_set_param_v3 1680 5 5 0 1 1 1 357 | fx_set_render_priority 1684 2 5 0 358 | get_active_moveset_from_pdata 1695 1 5 359 | advance_active_moveset 1696 1 5 360 | load_and_set_refl_on_weapon 1697 0 361 | kitana_1717 1717 2 5 5 362 | frost_1718 1718 0 363 | frost_1719 1719 1 5 364 | jax_1720 1720 2 5 0 365 | jax_1721 1721 0 366 | blaze_start_flaming_limbs 1725 1 5 367 | blaze_reset_flaming_limbs 1726 1 5 368 | ; gc ported to umkd 369 | get_taunts_performed 1900 0 370 | increment_taunts_performed 1901 0 371 | mks_set_flipped_bones 1902 1 0 372 | mks_start_goro_arms_fixup 1903 0 373 | reset_fake_bone_matcher 1904 7 0 5 0 5 0 5 1 374 | ; edits 375 | obj_bone_collapse_set 1905 3 5 0 0 376 | hide_aux_weapon 1906 1 5 377 | show_aux_weapon 1907 1 5 378 | set_active_projectile_ball_effect 1908 2 1 1 379 | am_i_alt_costume 1909 0 380 | set_robot_voice 1910 2 5 0 381 | ; umkd 382 | jax_taunt 2001 0 383 | freeze_victim 2002 0 384 | force_fatality_end 2003 0 385 | camera_setup_simple_rotation 2004 2 1 0 386 | start_shang_balls 2008 2 5 0 387 | shang_explode_ball 2009 1 0 388 | rain_teleport 2010 0 389 | sektor_set_chest_status 2011 2 0 0 -------------------------------------------------------------------------------- /data/mkda_def.txt: -------------------------------------------------------------------------------- 1 | ; MKDA definition file 2 | ; format: name id numArgs argTypes 3 | ; 4 | ; 5 | sleep 0 1 0 6 | true_branch 1 1 0 7 | branch 2 1 0 8 | exit_4 7 4 0 0 0 0 9 | exit_6 8 6 0 0 0 0 0 0 10 | blend_to_ani 9 3 0 0 1 11 | ani_to_frame_x 13 1 1 12 | ani_to_blend_frame 14 1 1 13 | slow_ani_x 15 2 1 1 14 | set_my_state 20 1 0 15 | set_my_secondary_state 21 1 0 16 | set_ani_speed 22 1 1 17 | init_ground_move 24 1 0 18 | init_air_move 27 1 0 19 | init_air_move_no_aniproc 28 0 20 | was_button_pressed 50 1 0 21 | ani_to_end 53 0 22 | force_away 56 4 1 0 1 0 23 | glitch_to_ani 57 2 0 0 24 | snd_req 61 1 0 25 | miss_branch 72 1 0 26 | block_branch 73 1 0 27 | hit_branch 74 1 0 28 | step_throw_into_check 84 0 29 | super_charge_me 87 1 0 30 | disable_this_move_exec 91 2 0 0 31 | myvel_my_angle_y 106 3 1 1 1 32 | ejb_call 107 1 0 33 | enable_his_blocking 111 0 34 | attack_to_frame_x 117 8 0 1 1 1 1 0 0 0 35 | random_hit 127 1 0 36 | random_voice 128 1 0 37 | set_his_damage_multiplier 132 1 1 38 | nick_function 133 1 0 39 | bulvan_function 135 1 0 40 | was_button_and_direction 137 2 0 0 41 | ani_to_frame_x_col 138 6 1 0 1 1 0 1 42 | ani_col_abort 140 7 1 0 1 0 0 1 0 43 | true_branch_next_style 142 1 0 44 | if_switching_to 143 1 0 45 | trial_register_attack 164 2 0 0 46 | trial_increment_state_value 171 2 0 0 47 | drone_combo 175 4 0 0 0 0 48 | set_block_requirement 177 1 0 49 | camera_set_movement_mode 190 1 0 50 | camera_set_look_mode 191 1 0 51 | camera_set_glitch_flag 194 0 52 | camera_set_movement_rate 195 1 1 53 | camera_set_rotation_rate 196 1 1 54 | camera_set_lookat_focus 200 1 0 55 | camera_set_movement_focus 201 1 0 56 | camera_setup_radial_position 202 3 1 1 1 57 | camera_setup_tightrope_angle_offset 204 2 1 1 58 | camera_setup_simple_rotation 205 2 1 0 59 | camera_special_function 206 1 0 60 | add_move_desc 208 3 0 4 4 61 | set_attack_type 214 1 0 62 | drone_super_combo 216 1 0 63 | special_move_cam_setup 222 8 1 1 1 1 1 0 0 0 64 | 65 | -------------------------------------------------------------------------------- /data/mku_def.txt: -------------------------------------------------------------------------------- 1 | ; MKU definition file 2 | ; format: name id numArgs argTypes 3 | ; 4 | ; 5 | sleep 0 1 0 6 | true_branch 1 1 0 7 | branch 2 1 0 8 | script_return 8 0 9 | script_exit 9 1 0 10 | exit_6 11 6 0 0 0 0 0 0 11 | exit_react 12 6 0 0 0 0 0 0 12 | blend_to_ani 13 3 0 0 1 13 | am_i_flipped 15 00 14 | am_i_on_the_left 18 0 15 | was_button_pressed 24 1 0 16 | two_player_animation 26 2 0 1 17 | two_player_animation_match_attacker 27 2 0 1 18 | two_player_animation_flip 28 2 0 1 19 | attack_to_frame_x 29 8 0 1 1 1 1 0 0 0 20 | launch_n_land_ani 31 8 0 1 1 1 0 1 1 1 21 | glitch_to_ani 33 2 0 0 22 | glitch_him_to_ani 34 2 0 0 23 | set_player_step 40 1 1 24 | miss_branch 42 1 0 25 | block_branch 43 1 0 26 | hit_branch 44 1 0 27 | was_button_and_direction 45 2 0 0 28 | ani_col_abort 46 7 1 0 1 1 0 1 0 29 | true_branch_next_style 48 1 0 30 | if_switching_to 50 1 0 31 | disable_grounding 52 0 32 | camera_set_lookat_focus 58 1 0 33 | camera_set_movement_focus 59 1 0 34 | attack_opponent_with 70 3 0 0 0 35 | randu 73 1 0 36 | exit_attack_with 74 6 0 0 0 0 0 0 37 | get_current_player_number 75 0 38 | get_plyr_pdata_flag 77 2 5 0 39 | trial_add_required_attack 84 2 0 0 40 | get_new_mkobj 95 1 5 41 | insert_item_obj 96 2 5 5 42 | ck_item_obj 98 1 5 43 | destroy_item_obj 99 1 5 44 | get_limb_obj 100 2 5 5 45 | set_obj_flag 102 3 5 0 0 46 | update_mkobj 103 1 5 47 | xfer_proc 110 2 5 0 48 | plyr_spawn_his_anim_limb 111 7 5 5 0 0 0 0 1 49 | start_gusher 112 5 5 5 0 0 0 50 | ani_to_frame_x 128 1 1 51 | ani_to_blend_frame 129 1 1 52 | slow_ani_x 130 2 1 1 53 | slow_ani_x_if_miss 131 3 1 1 1 54 | back_to_normal 134 0 55 | set_my_state 135 1 0 56 | set_my_secondary_state 136 1 0 57 | set_ani_speed 137 1 1 58 | init_ground_move 139 0 59 | init_ground_move_no_aniproc 140 0 60 | init_air_move 142 0 61 | init_air_move_no_aniproc 143 0 62 | init_3d_move 145 0 63 | tightrope_restrictions_off 149 0 64 | launch_me_up 150 2 1 1 65 | face_opponent_now 153 0 66 | ani_to_end 155 0 67 | force_away 158 4 1 0 1 0 68 | shake_camera 159 2 0 1 69 | snd_req 161 1 2 70 | pan_vol_pitch_random_hit 166 4 0 1 1 1 71 | random_voice 168 1 0 72 | random_foot 169 1 0 73 | snd_stop 170 1 5 74 | shake_hit_voice 172 4 0 1 0 0 75 | random_hit 174 1 0 76 | plyr_snd_req 175 1 0 77 | get_mode_of_play 178 0 78 | stop_me 181 0 79 | myvel_his_angle_y 182 3 0 1 1 80 | random_voice_him 188 1 0 81 | step_throw_into_check 190 0 82 | clear_my_face_opponent_flag 193 0 83 | clear_my_face_opponent_flag 194 0 84 | disable_this_move_exec 196 2 0 0 85 | turn_me_pi 197 0 86 | damage_me 199 1 1 87 | damage_him 200 1 1 88 | ejb_release_other_player 201 1 0 89 | player_feet_land_chores 205 0 90 | wait_to_land 206 0 91 | disable_both_repel_flags 207 0 92 | rotate_towards_him 208 1 1 93 | myvel_my_angle_y 209 3 1 1 1 94 | ejb_call 210 1 0 95 | back_rollup_check 212 0 96 | set_ani_weight 221 1 1 97 | weapon_trail_off 223 0 98 | face_bleed_me 227 1 0 99 | wall_eligible_on 228 0 100 | wall_eligible_off 229 0 101 | adjust_my_damage_multiplier 232 1 1 102 | set_his_damage_multiplier 234 1 1 103 | if_collision_autoface_me 236 0 104 | if_collision_autoface_him 237 0 105 | ani_to_frame_x_col 238 7 1 0 1 1 0 1 0 106 | camera_set_speed_scalar 275 1 1 107 | fade_to_black 279 2 0 0 108 | fade_from_black 280 2 0 0 109 | got_hit_fx 292 7 0 0 0 0 0 0 0 110 | whoosh_fx 296 1 0 111 | special_move_cam_setup 297 8 1 1 1 1 1 0 0 0 112 | set_block_requirement 299 1 0 113 | is_he_blocking 301 0 114 | mks_set_flipped_bones 302 1 0 115 | mks_start_goro_arms_fixup 303 0 116 | mks_cloth_bones_init_by_tbl 304 2 0 0 117 | mks_mat_id_set_zbias 305 2 0 1 118 | mks_cb1_eq_cloth_bone 306 1 0 119 | mks_cb2_eq_cloth_bone 307 1 0 120 | mks_insert_cloth_force_bones 308 2 1 1 121 | mks_set_ground_y_all_cloth_bones 309 1 1 122 | mks_cb1_set_ground_y 310 1 1 123 | mks_cb1_add_coll_pt 311 3 1 1 1 124 | mks_cb1_set_coll_offset_x 312 2 1 1 125 | mks_cb1_set_scale 314 4 0 1 1 1 126 | mks_cc1_eq_insert_cloth_coll 315 2 0 1 127 | mks_cc1_expand_cyl 316 2 1 1 128 | mks_ccp1_eq_insert_cloth_coll_plane 317 5 0 1 1 1 1 129 | mks_cc1_insert_cb1 318 0 130 | mks_ccp1_insert_cb1 319 0 131 | mks_cc1_set_coll_fnc_eq_cloth_coll_point_cyl_abs 321 0 132 | jab_attach_point_light_to_obj_bone 555 3 0 5 0 133 | jab_spawn_point_light_at_world_pos 556 2 0 0 134 | trial_set_num_rounds 559 1 0 135 | trial_set_round_timer 560 1 0 136 | trial_set_tick_function 561 1 0 137 | trial_set_ending_functions 562 2 0 0 138 | trial_show_text_window 563 6 5 1 1 1 0 0 139 | trial_show_spoken_text_window 564 9 5 1 1 1 0 0 0 0 0 140 | trial_add_required_sequence 568 2 0 0 141 | trial_set_type 565 1 0 142 | trial_add_success_condition 566 3 0 0 0 143 | trial_setup_onscreen_display_items 567 3 0 0 0 144 | trial_set_next_setup_function 570 1 0 145 | drone_set_difficulty_level 576 1 0 146 | drone_apply_damage 591 2 0 1 147 | camera_set_anim_aux_data 594 1 0 148 | give_koin_award 597 2 0 5 149 | trial_get_background_root 600 0 150 | build_bones_tbl 602 2 0 5 151 | player_has_item 661 2 0 0 152 | set_active_projectile_block_script 677 1 0 153 | kick_the_camera 684 0 154 | pz_fighter_create_space_between_fighters_for_special_moves 708 0 155 | get_collision_result 719 0 156 | taunt_increase_life 720 2 1 1 157 | face_ang_from_pos_to_him 728 3 5 0 0 158 | do_victory_camera 734 1 0 159 | get_my_plyr_num 735 0 160 | get_victory_flip_flags 737 0 161 | do_i_have_life_left 740 0 162 | high_flash_check 753 0 163 | bgnd_place_point_light_for_ticks 752 4 0 0 1 0 164 | medium_flash_check 754 0 165 | get_my_particle_player_bank_num 760 0 166 | start_baraka_blades_monitor 777 0 167 | register_baraka_cb_functions 778 0 168 | bgnd_create_sobjs 780 0 169 | bgnd_start_sobj_uv_scroll 781 6 0 1 1 1 0 0 170 | plyr_start_script_in_proc 784 2 0 0 171 | frand 786 1 1 172 | bgnd_hide_sobj 799 1 5 173 | ani_1_frame 794 0 174 | ani_loop_more_frames 795 1 1 175 | head_tracking_off 797 0 176 | load_aux_weapon 796 1 0 177 | obj_set_scale 814 2 5 0 178 | bgnd_preload_named_model 817 2 0 0 179 | pz_fighter_reaction_xfer_him 824 1 0 180 | restart_effect 880 1 0 181 | sfrand 902 1 1 182 | bgnd_current_rx_get_info 920 1 0 183 | bgnd_set_active_sobj_in_obj 938 2 0 0 184 | bgnd_create_pebbles 947 5 0 0 0 0 0 185 | bgnd_pebble_set_current_info 958 2 0 1 186 | bgnd_unhide_pebbles 963 1 0 187 | bgnd_pebble_set_current_pebble 967 2 0 0 188 | bgnd_set_active_sobj_zoffset 979 1 1 189 | bgnd_active_sobj_no_zwrite 980 0 190 | get_taunts_performed 1107 0 191 | increment_taunts_performed 1108 0 192 | get_adjusted_speed 1117 2 1 1 193 | player_area_collision_ticks 1118 6 1 1 0 1 0 1 194 | flying_collision 1119 10 0 1 0 0 0 1 1 1 1 1 195 | set_constrain_last_pos_pdata 1122 1 0 196 | switch_plyr_positions 1126 0 197 | force_ai_style 1147 1 0 198 | pan_vol_pitch_snd_req 1148 4 0 0 1 1 199 | is_local_plyr 1151 0 200 | local_collision_allowed_plyr_pdata 1153 0 201 | xz_distance_between_players 1161 0 202 | start_special_weapon_monitor 1162 1 0 203 | is_he_airborn 1166 0 204 | single_frame_collision_check 1167 6 0 1 0 0 0 1 205 | player_area_collision_check 1168 5 1 1 0 0 0 206 | reaction_sync_advance 1175 0 207 | wait_for_collision_result 1176 0 208 | clear_collision_result 1177 0 209 | collision_result_dont_care 1178 0 210 | ani_x_more_frames 1199 1 1 211 | get_projectile_script_plyr_num 1201 0 212 | get_projectile_his_plyr_num 1202 0 213 | get_projectile_script_plyr_pdata 1203 0 214 | get_projectile_script_last_pos 1204 1 0 215 | get_projectile_script_velocity 1205 1 0 216 | set_active_projectile_continue_thru_hit 1209 0 217 | set_active_projectile_tracking_light 1210 1 0 218 | set_active_projectile_collision_info 1211 4 1 0 1 1 219 | resume_effect_at_obj_bid 1231 5 5 5 5 0 0 220 | resume_effect_at_plyr_num_bid 1232 5 5 0 5 0 0 221 | reaction_xfer_him 1239 3 0 1 0 222 | start_projectile_from_plyr_bone 1241 6 5 0 0 1 1 0 223 | set_active_projectile_rx_info 1242 3 0 1 0 224 | set_active_projectile_not_duckable 1243 0 225 | set_active_projectile_hit_script 1245 1 0 226 | set_active_projectile_end_script 1246 1 0 227 | active_projectile_setup_done 1248 0 228 | set_active_projectile_target_ground 1250 3 1 1 1 229 | set_active_projectile_sound 1256 3 0 0 0 230 | set_active_add_ang_y 1259 1 1 231 | start_plyr_attack 1261 1 0 232 | get_bid_with_flip 1262 2 5 0 233 | mks_debug_display_cloth_ontop 1264 1 0 234 | bgnd_get_float 1269 1 0 235 | set_obj_light_flags 1305 2 0 0 236 | load_named_model_for_player 1308 4 0 5 0 0 237 | get_player_number 1309 1 5 238 | insert_fgnd_mkobj 1310 1 0 239 | obj_set_gravity 1311 2 5 1 240 | obj_turn_gravity_off 1312 1 5 241 | destroy_mkobj 1313 1 5 242 | pfx_plyr_bankowner 1388 1 5 243 | obj_get_bid_for_tid 1397 2 5 5 244 | insert_particle_mkobj 1399 1 5 245 | check_to_register_miss 1411 0 246 | mks_animpdata_set_cur_frame 1413 2 5 1 247 | plyr_turn_off_mirrorguy 1420 1 5 248 | plyr_turn_off_shadowbox 1422 1 5 249 | set_pdata_anim_step 1425 2 5 1 250 | limb_sever_update_slide_end_coeff 1427 2 5 1 251 | limb_sever_set_motion 1428 11 5 0 0 1 5 0 1 0 1 0 0 0 252 | limb_sever_find_existing_update_proc 1429 3 5 0 0 253 | mks_limb_sever 1430 3 5 0 0 254 | limb_sever_pop_head_up 1431 5 5 0 1 1 0 255 | limb_sever_bone_attach 1432 8 5 5 0 0 5 0 0 0 256 | fatality_release_other_player 1436 0 257 | ft_fake_bone_matcher 1438 8 5 5 0 0 0 0 0 0 258 | reset_fake_bone_matcher 1439 7 0 5 0 5 0 5 1 259 | bm_force_fake_child_bid 1442 2 5 5 260 | play_his_random_voice 1445 1 0 261 | play_his_snd_req 1446 1 0 262 | advance_to_weapon_style 1451 1 5 263 | show_single_weapon 1454 2 5 0 264 | weapon_reflection_show_hide 1455 3 5 0 0 265 | weapon_bm_ignore 1457 2 0 0 266 | bone_matcher_set_ang_pos 1458 6 5 5 0 0 0 0 267 | spawn_blood_pool_at_bid 1463 3 5 0 0 268 | start_blood_particles 1465 4 0 0 5 5 269 | start_sweat_particles 1466 4 0 0 5 5 270 | start_blood_particles_scripts 1467 2 0 0 271 | fatality_explode_victim 1470 3 5 1 1 272 | start_bodyslam_bodysplat 1472 5 5 5 1 1 1 273 | start_gore2_pebbles 1473 11 0 0 5 5 5 0 0 0 5 5 5 274 | attach_gore2_obj 1474 5 5 0 0 0 0 275 | destroy_gore2_obj 1475 2 0 5 276 | limb_sever_show_z_meat_chunks 1480 3 5 0 0 277 | limb_sever_throw_away 1482 3 5 0 0 278 | auto_calc_limbobj_bone_world_pos 1481 2 5 0 279 | pfx_spawn_at_bid 1483 3 0 5 0 280 | pfxhandle_spawn_at_bid_next 1484 3 5 5 0 281 | pfxhandle_spawn_at_bid 1485 3 0 5 5 282 | pfxhandle_spawn_at_bid_next_bind_render 1487 3 5 5 0 283 | show_baraka_one_blade_only 1490 2 5 5 284 | mkscripts_destroy_bonematcher 1515 1 0 285 | mkscripts_destroy_gusher 1517 1 5 286 | obj_set_pos 1538 2 5 0 287 | obj_get_pos 1539 2 5 0 288 | obj_set_ang 1540 2 5 0 289 | obj_get_ang 1541 2 5 0 290 | obj_set_light_flag 1550 2 5 0 291 | get_his_plyr_obj 1553 0 292 | get_my_plyr_obj 1554 0 293 | get_his_plyr_pdata 1557 0 294 | get_my_plyr_pdata 1558 0 295 | get_my_plyr_anim_pdata 1559 0 296 | plyr_pdata_get_his_plyr_pdata 1562 1 5 297 | plyr_pdata_get_plyr_obj 1563 1 5 298 | plyr_pdata_get_cmo 1566 1 5 299 | plyr_pdata_get_plyr_num 1567 1 5 300 | plyr_pdata_get_pchr 1569 1 5 301 | obj_set_pos_vel 1574 2 5 0 302 | obj_set_ang_vel 1575 2 5 0 303 | obj_get_ang_vel 1576 2 5 0 304 | start_bone_matcher 1577 5 5 0 0 0 0 305 | bone_matcher_parent_set_offset 1578 2 5 0 306 | bone_matcher_child_set_offset 1579 2 5 0 307 | get_bone_world_pos 1580 3 5 0 0 308 | force_calc_bone_world_mat 1584 2 5 0 309 | mkobj_get_matrix 1586 2 5 0 310 | mkobj_get_matrix_right 1588 2 5 0 311 | v3_x_mat 1590 3 0 0 5 312 | v3_sub_v3 1591 3 0 0 0 313 | v3_add_v3 1592 3 0 0 0 314 | v3_add_v3_scaled 1593 4 0 0 0 1 315 | scale_v3 1594 3 0 0 5 316 | normalize_v3 1595 1 0 317 | length_v3 1609 1 0 318 | bind_to_bone 1615 1 0 319 | create_step_fx 1616 2 0 0 320 | create_multiemit_step_fx 1617 3 0 0 0 321 | create_multiemit_parametric_fx 1619 3 0 0 0 322 | set_decal_plane 1620 1 0 323 | z_bias 1623 1 1 324 | fx 1629 1 0 325 | fx_by_owner 1631 2 0 5 326 | emit_in_range 1632 3 0 1 1 327 | emit_color 1633 5 0 0 0 0 0 328 | emit_uv 1634 3 0 0 0 329 | emit_cuboid 1636 4 0 1 1 1 330 | emit_disc 1637 5 0 1 1 1 1 331 | emit_disc2 1638 6 0 0 0 1 1 1 332 | emit_cartesian 1639 7 0 1 1 1 1 1 1 333 | emit_cylindrical 1640 8 0 0 1 0 1 1 0 1 334 | emission_duration 1641 1 1 335 | texture_animation 1642 3 1 0 1 336 | emit_spherical 1644 2 0 1 337 | emit_from_pos 1647 7 0 0 0 0 1 1 1 338 | emit_value 1649 2 0 1 339 | emit_value_i 1650 2 0 0 340 | emit_roundrobin_mechanism 1651 2 0 0 341 | spawn_random_size 1657 1 0 342 | fx_reset 1662 1 5 343 | fx_next_emitter 1663 1 0 344 | fx_resume_emit 1664 1 5 345 | fx_pause_emit 1665 1 5 346 | fx_reset_emit 1666 1 5 347 | set_cycle_emission 1668 1 0 348 | initial_add_v3 1671 2 0 0 349 | initial_set_float 1672 3 0 0 0 350 | update_add 1674 2 0 0 351 | update_copy 1675 1 0 352 | update_add_constant_v3 1676 4 0 1 1 1 353 | update_add_constant 1677 2 0 1 354 | update_fade_alpha 1680 4 0 0 0 1 355 | update_fade_alpha2 1681 6 0 0 0 1 0 0 356 | update_lerp_color 1682 6 0 0 1 0 0 0 357 | update_texanim_hold 1684 5 0 0 1 0 0 358 | update_bounce 1685 4 0 0 0 1 359 | update_attract 1686 3 0 0 1 360 | udpate_roundrobin 1688 1 0 361 | kill_on_greater 1689 2 0 1 362 | kill_roundrobin 1691 1 0 363 | change_on_greater 1692 2 0 1 364 | change_on_less 1693 2 0 1 365 | change_on_y_less_than_field 1695 2 0 0 366 | kill_on_y_less_than_field 1696 2 0 0 367 | fx_set_param_v3 1698 5 5 0 1 1 1 368 | fx_set_render_priority 1702 2 5 0 369 | get_active_moveset_from_pdata 1713 1 5 370 | advance_active_moveset 1714 1 5 371 | load_and_set_refl_on_weapon 1715 0 372 | kitana_1717 1717 2 5 5 373 | frost_1718 1718 0 374 | frost_1719 1719 1 5 375 | jax_1720 1720 2 5 0 376 | jax_1721 1721 0 377 | blaze_start_flaming_limbs 1725 1 5 378 | blaze_reset_flaming_limbs 1726 1 5 379 | 380 | -------------------------------------------------------------------------------- /mkoasm.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32002.261 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mkoasm", "mkoasm\mkoasm.vcxproj", "{7A724DC0-5655-4BA3-80D4-40D23F34EEFF}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Debug|x64.ActiveCfg = Debug|x64 17 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Debug|x64.Build.0 = Debug|x64 18 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Debug|x86.ActiveCfg = Debug|Win32 19 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Debug|x86.Build.0 = Debug|Win32 20 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Release|x64.ActiveCfg = Release|x64 21 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Release|x64.Build.0 = Release|x64 22 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Release|x86.ActiveCfg = Release|Win32 23 | {7A724DC0-5655-4BA3-80D4-40D23F34EEFF}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {E1B89AE2-3424-4ABB-AC95-ACFD67F640EB} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /mkoasm/INIReader.cpp: -------------------------------------------------------------------------------- 1 | // Read an INI file into easy-to-access name/value pairs. 2 | 3 | // SPDX-License-Identifier: BSD-3-Clause 4 | 5 | // Copyright (C) 2009-2020, Ben Hoyt 6 | 7 | // inih and INIReader are released under the New BSD license (see LICENSE.txt). 8 | // Go to the project home page for more info: 9 | // 10 | // https://github.com/benhoyt/inih 11 | 12 | #include 13 | #include 14 | #include 15 | #include "ini.h" 16 | #include "INIReader.h" 17 | 18 | using std::string; 19 | 20 | INIReader::INIReader(const string& filename) 21 | { 22 | _error = ini_parse(filename.c_str(), ValueHandler, this); 23 | } 24 | 25 | INIReader::INIReader(const char *buffer, size_t buffer_size) 26 | { 27 | string content(buffer, buffer_size); 28 | _error = ini_parse_string(content.c_str(), ValueHandler, this); 29 | } 30 | 31 | int INIReader::ParseError() const 32 | { 33 | return _error; 34 | } 35 | 36 | string INIReader::Get(const string& section, const string& name, const string& default_value) const 37 | { 38 | string key = MakeKey(section, name); 39 | // Use _values.find() here instead of _values.at() to support pre C++11 compilers 40 | return _values.count(key) ? _values.find(key)->second : default_value; 41 | } 42 | 43 | string INIReader::GetString(const string& section, const string& name, const string& default_value) const 44 | { 45 | const string str = Get(section, name, ""); 46 | return str.empty() ? default_value : str; 47 | } 48 | 49 | long INIReader::GetInteger(const string& section, const string& name, long default_value) const 50 | { 51 | string valstr = Get(section, name, ""); 52 | const char* value = valstr.c_str(); 53 | char* end; 54 | // This parses "1234" (decimal) and also "0x4D2" (hex) 55 | long n = strtol(value, &end, 0); 56 | return end > value ? n : default_value; 57 | } 58 | 59 | double INIReader::GetReal(const string& section, const string& name, double default_value) const 60 | { 61 | string valstr = Get(section, name, ""); 62 | const char* value = valstr.c_str(); 63 | char* end; 64 | double n = strtod(value, &end); 65 | return end > value ? n : default_value; 66 | } 67 | 68 | INI_API double INIReader::GetFloat(const std::string& section, const std::string& name, double default_value) const 69 | { 70 | string valstr = Get(section, name, ""); 71 | const char* value = valstr.c_str(); 72 | char* end; 73 | float n = strtof(value, &end); 74 | return end > value ? n : default_value; 75 | } 76 | 77 | bool INIReader::GetBoolean(const string& section, const string& name, bool default_value) const 78 | { 79 | string valstr = Get(section, name, ""); 80 | // Convert to lower case to make string comparisons case-insensitive 81 | std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower); 82 | if (valstr == "true" || valstr == "yes" || valstr == "on" || valstr == "1") 83 | return true; 84 | else if (valstr == "false" || valstr == "no" || valstr == "off" || valstr == "0") 85 | return false; 86 | else 87 | return default_value; 88 | } 89 | 90 | bool INIReader::HasSection(const string& section) const 91 | { 92 | const string key = MakeKey(section, ""); 93 | std::map::const_iterator pos = _values.lower_bound(key); 94 | if (pos == _values.end()) 95 | return false; 96 | // Does the key at the lower_bound pos start with "section"? 97 | return pos->first.compare(0, key.length(), key) == 0; 98 | } 99 | 100 | bool INIReader::HasValue(const string& section, const string& name) const 101 | { 102 | string key = MakeKey(section, name); 103 | return _values.count(key); 104 | } 105 | 106 | string INIReader::MakeKey(const string& section, const string& name) 107 | { 108 | string key = section + "=" + name; 109 | // Convert to lower case to make section/name lookups case-insensitive 110 | std::transform(key.begin(), key.end(), key.begin(), ::tolower); 111 | return key; 112 | } 113 | 114 | int INIReader::ValueHandler(void* user, const char* section, const char* name, 115 | const char* value) 116 | { 117 | if (!name) // Happens when INI_CALL_HANDLER_ON_NEW_SECTION enabled 118 | return 1; 119 | INIReader* reader = static_cast(user); 120 | string key = MakeKey(section, name); 121 | if (reader->_values[key].size() > 0) 122 | reader->_values[key] += "\n"; 123 | reader->_values[key] += value ? value : ""; 124 | return 1; 125 | } 126 | -------------------------------------------------------------------------------- /mkoasm/INIReader.h: -------------------------------------------------------------------------------- 1 | // Read an INI file into easy-to-access name/value pairs. 2 | 3 | // SPDX-License-Identifier: BSD-3-Clause 4 | 5 | // Copyright (C) 2009-2020, Ben Hoyt 6 | 7 | // inih and INIReader are released under the New BSD license (see LICENSE.txt). 8 | // Go to the project home page for more info: 9 | // 10 | // https://github.com/benhoyt/inih 11 | 12 | #ifndef INIREADER_H 13 | #define INIREADER_H 14 | 15 | #include 16 | #include 17 | 18 | // Visibility symbols, required for Windows DLLs 19 | #ifndef INI_API 20 | #if defined _WIN32 || defined __CYGWIN__ 21 | # ifdef INI_SHARED_LIB 22 | # ifdef INI_SHARED_LIB_BUILDING 23 | # define INI_API __declspec(dllexport) 24 | # else 25 | # define INI_API __declspec(dllimport) 26 | # endif 27 | # else 28 | # define INI_API 29 | # endif 30 | #else 31 | # if defined(__GNUC__) && __GNUC__ >= 4 32 | # define INI_API __attribute__ ((visibility ("default"))) 33 | # else 34 | # define INI_API 35 | # endif 36 | #endif 37 | #endif 38 | 39 | // Read an INI file into easy-to-access name/value pairs. (Note that I've gone 40 | // for simplicity here rather than speed, but it should be pretty decent.) 41 | class INIReader 42 | { 43 | public: 44 | // Construct INIReader and parse given filename. See ini.h for more info 45 | // about the parsing. 46 | INI_API explicit INIReader(const std::string& filename); 47 | 48 | // Construct INIReader and parse given buffer. See ini.h for more info 49 | // about the parsing. 50 | INI_API explicit INIReader(const char *buffer, size_t buffer_size); 51 | 52 | // Return the result of ini_parse(), i.e., 0 on success, line number of 53 | // first error on parse error, or -1 on file open error. 54 | INI_API int ParseError() const; 55 | 56 | // Get a string value from INI file, returning default_value if not found. 57 | INI_API std::string Get(const std::string& section, const std::string& name, 58 | const std::string& default_value) const; 59 | 60 | // Get a string value from INI file, returning default_value if not found, 61 | // empty, or contains only whitespace. 62 | INI_API std::string GetString(const std::string& section, const std::string& name, 63 | const std::string& default_value) const; 64 | 65 | // Get an integer (long) value from INI file, returning default_value if 66 | // not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2"). 67 | INI_API long GetInteger(const std::string& section, const std::string& name, long default_value) const; 68 | 69 | // Get a real (floating point double) value from INI file, returning 70 | // default_value if not found or not a valid floating point value 71 | // according to strtod(). 72 | INI_API double GetReal(const std::string& section, const std::string& name, double default_value) const; 73 | 74 | // Get a float value from INI file, returning 75 | // default_value if not found or not a valid floating point value 76 | // according to strtof(). 77 | INI_API double GetFloat(const std::string& section, const std::string& name, double default_value) const; 78 | 79 | // Get a boolean value from INI file, returning default_value if not found or if 80 | // not a valid true/false value. Valid true values are "true", "yes", "on", "1", 81 | // and valid false values are "false", "no", "off", "0" (not case sensitive). 82 | INI_API bool GetBoolean(const std::string& section, const std::string& name, bool default_value) const; 83 | 84 | // Return true if the given section exists (section must contain at least 85 | // one name=value pair). 86 | INI_API bool HasSection(const std::string& section) const; 87 | 88 | // Return true if a value exists with the given section and field names. 89 | INI_API bool HasValue(const std::string& section, const std::string& name) const; 90 | 91 | private: 92 | int _error; 93 | std::map _values; 94 | static std::string MakeKey(const std::string& section, const std::string& name); 95 | static int ValueHandler(void* user, const char* section, const char* name, 96 | const char* value); 97 | }; 98 | 99 | #endif // INIREADER_H 100 | -------------------------------------------------------------------------------- /mkoasm/MKOReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "code/MKScript.h" 4 | #include "code/MKScript_MK8.h" 5 | #include "code/MKScript_MK9.h" 6 | #include "code/MKScript_DCF.h" 7 | #include "code/MKScript_MK10.h" 8 | #include "code/MKScript_DCF2.h" 9 | #include "code/MKScript_MK11.h" 10 | #include "code/MKScript_MK12.h" 11 | 12 | #include 13 | #include "code/MKScriptTypes.h" 14 | #include "code/MKODict.h" 15 | 16 | #include "enums.h" 17 | 18 | #define VARIABLESFOLDER_NAME "vars" 19 | #define FUNCTIONFOLDER_NAME "funcs" 20 | 21 | #define STRING_PAD_SIZE 4 22 | 23 | 24 | union MKOVariable { 25 | int integerData; 26 | float floatData; 27 | unsigned short shortData; 28 | unsigned int uintData; 29 | int64 qwordData; 30 | 31 | }; 32 | 33 | 34 | struct MKOCodeEntry { 35 | int functionID; 36 | int functionSet; 37 | bool isInternal; 38 | std::vector arguments; 39 | 40 | // debug/helper 41 | int offset; 42 | int size; 43 | int localOffset; 44 | 45 | }; 46 | 47 | struct MKOCodeEntry_MK8 { 48 | int functionID; 49 | int type; 50 | int unk1; 51 | int unk2; 52 | int pad; 53 | std::vector arguments; 54 | 55 | // debug/helper 56 | int offset; 57 | int size; 58 | int localOffset; 59 | }; 60 | 61 | struct MKOCodeEntry_MK9 { 62 | int type; 63 | int subType; 64 | int unk1; 65 | int unk2; 66 | int pad; 67 | std::vector arguments; 68 | 69 | // debug/helper 70 | int offset; 71 | int size; 72 | int localOffset; 73 | }; 74 | 75 | 76 | 77 | 78 | struct MKOCodeEntry_MK10 { 79 | int type; 80 | int functionSet; 81 | int unk1; 82 | int functionID; 83 | int pad; 84 | std::vector arguments; 85 | 86 | // debug/helper 87 | int offset; 88 | int size; 89 | int localOffset; 90 | }; 91 | 92 | 93 | struct MKOFunctionEntry { 94 | std::string name; 95 | mko_function_header func = {}; 96 | float flt; 97 | int mka_size; 98 | }; 99 | 100 | struct MKODataLink { 101 | int type; 102 | int value; 103 | }; 104 | 105 | struct MKOVariableEntry { 106 | std::string name; 107 | mko_variable_header var = {}; 108 | int scriptID; 109 | }; 110 | 111 | 112 | 113 | class MKOReader { 114 | public: 115 | bool m_bIsValid = false; 116 | bool m_bDebugMKO = false; 117 | bool m_bExtractOnly = false; 118 | bool m_bGameCube = false; 119 | bool m_bBuildMode = false; 120 | 121 | EGameMode game = Game_Deception; 122 | std::string m_szInputName; 123 | 124 | uintptr_t m_pDataStartOffset = 0; 125 | uintptr_t m_pFunctionsStartOffset = 0; 126 | 127 | std::vector funcs; 128 | std::vector vars; 129 | std::vector var_sizes; 130 | std::vector func_sizes; 131 | mko_header header; 132 | 133 | 134 | std::vector mka_funcSizes; 135 | std::vector> mka_funcLinks; 136 | std::vector> mka_varLinks; 137 | 138 | // mk8 (Mortal Kombat vs DC Universe) 139 | mko_header_mk8 mk8_header; 140 | std::vector mk8_funcs; 141 | std::vector mk8_vars; 142 | std::vector mk8_externs; 143 | std::vector mk8_assets; 144 | 145 | // mk9 146 | mko_header_mk9 mk9_header; 147 | std::vector mk9_funcs; 148 | std::vector mk9_vars; 149 | std::vector mk9_extern_vars; 150 | std::vector mk9_externs; 151 | std::vector mk9_assets; 152 | std::vector mk9_sounds; 153 | std::vector mk9_fixup; 154 | 155 | // dcf1 (injustice) 156 | mko_header_dcf dcf_header; 157 | std::vector dcf_funcs; 158 | std::vector dcf_vars; 159 | std::vector dcf_dyn_vars; 160 | std::vector dcf_externs; 161 | std::vector dcf_assets; 162 | std::vector dcf_sounds; 163 | 164 | // mk10 165 | mko_header_mk10 mk10_header; 166 | std::vector mk10_funcs; 167 | std::vector mk10_vars; 168 | std::vector mk10_dyn_vars; 169 | std::vector mk10_externs; 170 | std::vector mk10_extern_vars; 171 | std::vector mk10_srcs; 172 | std::vector mk10_assets; 173 | std::vector mk10_fixup; 174 | std::unique_ptr mk10_pointers; 175 | std::unique_ptr tweakstring_data; 176 | 177 | 178 | // dcf2 (injustice 2) 179 | mko_header_dcf2 dcf2_header; 180 | std::vector dcf2_funcs; 181 | std::vector dcf2_vars; 182 | std::vector dcf2_dyn_vars; 183 | std::vector dcf2_externs; 184 | std::vector dcf2_extern_vars; 185 | std::vector dcf2_srcs; 186 | std::vector dcf2_assets; 187 | std::vector dcf2_fixup; 188 | std::vector dcf2_tweakvar; 189 | std::unique_ptr dcf2_pointers; 190 | 191 | 192 | // mk11 193 | mko_header_dcf2 mk11_header; 194 | std::vector mk11_funcs; 195 | std::vector mk11_vars; 196 | std::vector mk11_dyn_vars; 197 | std::vector mk11_externs; 198 | std::vector mk11_extern_vars; 199 | std::vector mk11_srcs; 200 | std::vector mk11_assets; 201 | std::vector mk11_fixup; 202 | std::vector mk11_tweakvar; 203 | std::unique_ptr mk11_pointers; 204 | 205 | // mk12 206 | mko_header_mk12 mk12_header; 207 | std::vector mk12_funcs; 208 | std::vector mk12_vars; 209 | std::vector mk12_dyn_vars; 210 | std::vector mk12_srcs; 211 | std::vector mk12_fixup; 212 | std::vector mk12_assets; 213 | 214 | std::unique_ptr script_names; 215 | std::unique_ptr string_data; 216 | std::unique_ptr unk_data; 217 | 218 | 219 | 220 | int nBytesRead = 0; 221 | 222 | std::ifstream pFile; 223 | 224 | MKOReader(const char* file, bool isGameCube = false, EGameMode game = Game_Deception); 225 | 226 | bool Read(const char* file); 227 | bool ReadMK8(); 228 | bool ReadMK9(); 229 | bool ReadDCF(); 230 | bool ReadMK10(); 231 | bool ReadDCF2(); 232 | bool ReadMK11(); 233 | bool ReadMK12(); 234 | 235 | std::string GetExtension(); 236 | 237 | int GetAllFunctionsSize(); 238 | int GetAllVariablesSize(); 239 | int GetAllVariablesSizeMK8(); 240 | int GetAllFunctionsSizeMK8(); 241 | int GetAllFunctionsUnkSizeMK8(); 242 | 243 | std::string GetFileName(); 244 | 245 | std::string GetFunctionName(int functionID); 246 | std::string GetFunctionNameMK8(int functionID); 247 | std::string GetFunctionNameMK9(int functionID); 248 | std::string GetFunctionNameDCF(int functionID); 249 | std::string GetFunctionNameMK10(int functionID); 250 | int GetFunctionIDWithHashMK10(unsigned int hash); 251 | std::string GetFunctionNameDCF2(int functionID); 252 | int GetFunctionIDWithHashDCF2(unsigned int hash); 253 | std::string GetFunctionNameMK11(int functionID); 254 | int GetFunctionIDWithHashMK11(unsigned int hash); 255 | std::string GetFunctionNameMK12(int functionID); 256 | int GetFunctionIDWithHashMK12(unsigned int hash); 257 | 258 | uint32_t GetFunctionOffset(int functionID); 259 | uint32_t GetFunctionOffsetMK8(int functionID); 260 | uint32_t GetFunctionOffsetMK9(int functionID); 261 | uintptr_t GetFunctionOffsetMK10(int functionID); 262 | uintptr_t GetFunctionOffsetDCF2(int functionID); 263 | uintptr_t GetFunctionOffsetMK11(int functionID); 264 | uintptr_t GetFunctionOffsetMK12(int functionID); 265 | 266 | std::string GetVariableName(int variableID); 267 | std::string GetVariableNameMK8(int variableID); 268 | std::string GetVariableNameMK9(int variableID); 269 | std::string GetVariableNameDCF(int variableID); 270 | std::string GetVariableNameMK10(int variableID); 271 | std::string GetVariableNameDCF2(int variableID); 272 | std::string GetVariableNameMK11(int variableID); 273 | std::string GetVariableNameMK12(int variableID); 274 | 275 | uint32_t GetVariableOffset(int variableID); 276 | uint32_t GetVariableOffsetMK8(int variableID); 277 | uint32_t GetVariableOffsetMK9(int variableID); 278 | uint32_t GetVariableOffsetDCF(int variableID); 279 | uint32_t GetVariableOffsetMK10(int variableID); 280 | uint32_t GetVariableOffsetDCF2(int variableID); 281 | uint32_t GetVariableOffsetMK11(int variableID); 282 | uint32_t GetVariableOffsetMK12(int variableID); 283 | 284 | std::string GetString(int stringStart); 285 | 286 | void ExtractData(); 287 | void ExtractDataMKDADU(); 288 | void ExtractDataMK8(); 289 | void ExtractDataMK9(); 290 | void ExtractDataDCF(); 291 | void ExtractDataMK10(); 292 | void ExtractDataDCF2(); 293 | void ExtractDataMK11(); 294 | void ExtractDataMK12(); 295 | 296 | void ExtractVariables(); 297 | void ExtractVariablesMK8(); 298 | void ExtractVariablesMK9(); 299 | void ExtractVariablesDCF(); 300 | void ExtractVariablesMK10(); 301 | void ExtractVariablesDCF2(); 302 | void ExtractVariablesMK11(); 303 | void ExtractVariablesMK12(); 304 | 305 | void ExtractFunctions(); 306 | void ExtractFunctionsMK8(); 307 | void ExtractFunctionsMK9(); 308 | void ExtractFunctionsDCF(); 309 | void ExtractFunctionsMK10(); 310 | void ExtractFunctionsDCF2(); 311 | void ExtractFunctionsMK11(); 312 | void ExtractFunctionsMK12(); 313 | 314 | void DecompileFunction(int functionID); 315 | void DecompileFunctionMK8(int functionID); 316 | void DecompileFunctionMK9(int functionID); 317 | void DecompileFunctionMK10(int functionID); 318 | void DecompileFunctionDCF2(int functionID); 319 | void DecompileFunctionMK11(int functionID); 320 | void DecompileFunctionMK12(int functionID); 321 | 322 | void UnpackVariable(int variableID); 323 | 324 | void UnpackVariableMK8(int variableID); 325 | void UnpackVariableMK9(int variableID); 326 | void UnpackVariableDCF(int variableID); 327 | void UnpackVariableMK10(int variableID); 328 | void UnpackVariableDCF2(int variableID); 329 | void UnpackVariableMK11(int variableID); 330 | 331 | // unpackers 332 | void Unpack_Movelist(int variableID); 333 | void Unpack_MovelistU(int variableID); 334 | void Unpack_Styles(int variableID); 335 | void Unpack_RArt(int variableID); 336 | void Unpack_BList(int variableID); 337 | void Unpack_SList(int variableID); 338 | void Unpack_Attributes(int variableID); 339 | void Unpack_PlayerData_MKDU(int variableID); 340 | 341 | // mk8 unpackers 342 | void MK8_Unpack_RArt(int variableID); 343 | void MK8_Unpack_Movelist(int variableID); 344 | void MK8_Unpack_CHRBones(int variableID); 345 | 346 | // mk9 unpackers 347 | void MK9_Unpack_RArt(int variableID); 348 | void MK9_Unpack_Movelist(int variableID); 349 | 350 | 351 | void DecompileAllFunctions(); 352 | void DecompileAllFunctionsMK8(); 353 | void DecompileAllFunctionsMK9(); 354 | void DecompileAllFunctionsMK10(); 355 | void DecompileAllFunctionsDCF2(); 356 | void DecompileAllFunctionsMK11(); 357 | void DecompileAllFunctionsMK12(); 358 | 359 | void UnpackVariables(); 360 | void UnpackVariablesMK8(); 361 | void UnpackVariablesMK9(); 362 | void UnpackVariablesDCF(); 363 | void UnpackVariablesMK10(); 364 | void UnpackVariablesDCF2(); 365 | void UnpackVariablesMK11(); 366 | 367 | void PrintInfo(); 368 | 369 | void PrintInfoMKDADU(); 370 | void PrintInfoMK8(); 371 | void PrintInfoMK9(); 372 | void PrintInfoDCF(); 373 | void PrintInfoMK10(); 374 | void PrintInfoDCF2(); 375 | void PrintInfoMK11(); 376 | void PrintInfoMK12(); 377 | 378 | void DumpInfoMKDADU(std::string name); 379 | void DumpInfoMK8(std::string name); 380 | void DumpInfoMK9(std::string name); 381 | void DumpInfoDCF(std::string name); 382 | void DumpInfoMK10(std::string name); 383 | void DumpInfoDCF2(std::string name); 384 | void DumpInfoMK11(std::string name); 385 | void DumpInfoMK12(std::string name); 386 | 387 | void DumpHeader(std::string header); 388 | 389 | void ReadFunctionBytecode(std::vector& data, int functionID); 390 | void ParseMKOCommand(mko_command& bc); 391 | void ParseMKOCommand_MKDU(mko_command& bc); 392 | void ParseMKOCommand_MKA(mko_command& bc); 393 | void ParseMKOCommand_MKDA(mko_command& bc); 394 | 395 | void ReadFunctionBytecode_MK8(std::vector& data, int functionID); 396 | void ReadFunctionBytecode_MK9(std::vector& data, int functionID); 397 | void ReadFunctionBytecode_MK10(std::vector& data, int functionID); 398 | void ReadFunctionBytecode_DCF2(std::vector& data, int functionID); 399 | void ReadFunctionBytecode_MK11(std::vector& data, int functionID); 400 | void ReadFunctionBytecode_MK12(std::vector& data, int functionID); 401 | 402 | 403 | void ParseMKOCommand_MK8(mko_command_mk8& bc); 404 | void ParseMKOCommand_MK9_Vita(mko_command_mk8& bc); 405 | 406 | void ParseMKOCommand_MK10(mko_command_mk10& bc); 407 | // building 408 | 409 | bool Build(); 410 | bool IsBuildingSupported(EGameMode game); 411 | 412 | bool IsDecompSupported(); 413 | static bool Is64BitSupported(); 414 | 415 | 416 | // packing 417 | 418 | static void Pack(std::string name, std::string param, EGameMode game); 419 | 420 | static void PackMovelistMKD(std::string name, std::string param); 421 | 422 | operator bool(); 423 | 424 | void SwapINT(int* value); 425 | void SwapSHORT(short* value); 426 | }; -------------------------------------------------------------------------------- /mkoasm/code/FileFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "FileFunctions.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | std::streampos getSizeToEnd(std::ifstream& is) 8 | { 9 | auto currentPosition = is.tellg(); 10 | is.seekg(0, is.end); 11 | auto length = is.tellg() - currentPosition; 12 | is.seekg(currentPosition, is.beg); 13 | return length; 14 | } 15 | 16 | bool checkSlash(std::string& str, bool first) 17 | { 18 | int fnd = str.find_last_of("/\\"); 19 | if (first == true) 20 | fnd = str.find_first_of("/\\"); 21 | 22 | if (fnd == std::string::npos) 23 | return false; 24 | else 25 | return true; 26 | } 27 | 28 | bool wcheckSlash(std::wstring& str, bool first) 29 | { 30 | int fnd = str.find_last_of(L"/\\"); 31 | if (first == true) 32 | fnd = str.find_first_of(L"/\\"); 33 | 34 | if (fnd == std::wstring::npos) 35 | return false; 36 | else 37 | return true; 38 | } 39 | 40 | std::string getWideStr(std::ifstream& file, bool f) 41 | { 42 | auto buff = std::make_unique(_MAX_PATH); 43 | int strlen = 0; 44 | for (int i = 0; i < _MAX_PATH; i++) 45 | { 46 | char temp[2]; 47 | file.read((char*)&temp, sizeof(temp)); 48 | buff[i] = temp[0]; 49 | if (!(temp[0] == 0 && temp[1] == 0)) 50 | strlen++; 51 | else 52 | break; 53 | 54 | } 55 | if (f == true) strlen -= 2; 56 | return std::string(buff.get(), strlen); 57 | } 58 | 59 | std::wstring getWideString(std::ifstream& file) 60 | { 61 | auto buff = std::make_unique(_MAX_PATH); 62 | int strlen = 0; 63 | for (int i = 0; i < _MAX_PATH; i++) 64 | { 65 | wchar_t temp; 66 | file.read((char*)&temp, sizeof(temp)); 67 | buff[i] = temp; 68 | if (!(temp == 0)) 69 | strlen++; 70 | else 71 | break; 72 | 73 | } 74 | 75 | return std::wstring(buff.get(), strlen); 76 | } 77 | 78 | std::string convertWide(std::string& str) 79 | { 80 | int strlen = str.length(); 81 | std::string temp; 82 | for (int i = 0; i < strlen; i++) 83 | { 84 | temp += str[i]; 85 | i++; 86 | } 87 | return temp; 88 | } 89 | 90 | std::string convertWideToChar(std::wstring& str) 91 | { 92 | int wcslen = str.length(); 93 | 94 | std::string temp; 95 | 96 | for (int i = 0; i < wcslen; i++) 97 | { 98 | temp += *(char*)(&str + i); 99 | i++; 100 | } 101 | 102 | return temp; 103 | } 104 | 105 | std::string splitString(std::string& str, bool file) { 106 | 107 | std::string str_ret; 108 | int fnd = str.find_last_of("/\\"); 109 | 110 | if (file == true) str_ret = str.substr(fnd + 1); 111 | if (file == false) str_ret = str.substr(0, fnd); 112 | return str_ret; 113 | 114 | } 115 | 116 | std::wstring wsplitString(std::wstring& str, bool file) { 117 | 118 | std::wstring str_ret; 119 | int fnd = str.find_last_of(L"/\\"); 120 | 121 | if (file == true) str_ret = str.substr(fnd + 1); 122 | if (file == false) str_ret = str.substr(0, fnd); 123 | return str_ret; 124 | 125 | } 126 | 127 | int calcOffsetFromPad(int val, int padsize) 128 | { 129 | int retval = val; 130 | if (!(retval % padsize == 0)) 131 | { 132 | do 133 | { 134 | retval++; 135 | } while (retval % padsize != 0); 136 | 137 | } 138 | return retval; 139 | } 140 | 141 | // faster 142 | int makePad(int value, int pad) 143 | { 144 | return (value + pad - 1) & -pad; 145 | } 146 | 147 | 148 | std::wstring getExecutablePath() 149 | { 150 | wchar_t path[260]; 151 | GetModuleFileNameW(NULL, path, sizeof(path)); 152 | 153 | wchar_t* end = wcsrchr(path, L'\\'); 154 | if (end) 155 | end[1] = 0x00; 156 | std::wstring wpath(path, wcslen(path)); 157 | return wpath; 158 | } 159 | 160 | std::string getExecutablePath_str() 161 | { 162 | char path[260]; 163 | GetModuleFileNameA(NULL, path, sizeof(path)); 164 | 165 | char* end = strrchr(path, '\\'); 166 | if (end) 167 | end[1] = 0x00; 168 | std::string spath(path, strlen(path)); 169 | return spath; 170 | } 171 | 172 | std::string getExtension(std::string& str) 173 | { 174 | if (str.find_last_of(".") != std::string::npos) 175 | return str.substr(str.find_last_of(".") + 1); 176 | else 177 | return " "; 178 | } 179 | -------------------------------------------------------------------------------- /mkoasm/code/FileFunctions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | std::streampos getSizeToEnd(std::ifstream& is); 6 | bool checkSlash(std::string& str, bool first = false); 7 | bool wcheckSlash(std::wstring& str, bool first = false); 8 | std::string getWideStr(std::ifstream& file, bool f = false); 9 | std::wstring getWideString(std::ifstream& file); 10 | std::string convertWide(std::string& str); 11 | std::string convertWideToChar(std::wstring& str); 12 | std::string splitString(std::string& str, bool file); 13 | std::wstring wsplitString(std::wstring& str, bool file); 14 | int calcOffsetFromPad(int val, int padsize); 15 | int makePad(int value, int pad); 16 | std::wstring getExecutablePath(); 17 | std::string getExecutablePath_str(); 18 | std::string getExtension(std::string& str); 19 | -------------------------------------------------------------------------------- /mkoasm/code/MKODict.cpp: -------------------------------------------------------------------------------- 1 | #include "MKODict.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | const char* szInternalNames[] = { 8 | "copy_register_to_instruction", 9 | "copy_constant_to_register", 10 | "copy_register_to_register", 11 | "copy_variable_to_register", 12 | "copy_register_to_variable", 13 | "copy_constant_to_variable", 14 | "copy_column_to_register", 15 | "copy_column_address_to_register", 16 | "copy_register_to_address", 17 | "combine_int_int", 18 | "combine_uint_uint", 19 | "combine_float_float", 20 | "compare_int_int", 21 | "compare_uint_uint", 22 | "compare_float_float", 23 | "conditional_branch", 24 | "unconditional_branch", 25 | "load_table_address", 26 | "call_script_function", 27 | "copy_stream_to_address", 28 | "get_bit_field", 29 | "set_bit_field", 30 | // new in MKA 31 | "load_string_variable", 32 | }; 33 | 34 | std::vector MKODict::ms_vFunctions; 35 | std::vector MKODict::ms_vHashes; 36 | std::vector MKODict::ms_vFunctionHashes; 37 | EGameMode MKODict::ms_gameMode; 38 | 39 | #ifdef SORT_FUNCTIONS 40 | bool sort_functions(MKOFunctionDefinition& a, MKOFunctionDefinition& b) 41 | { 42 | return b.functionID > a.functionID; 43 | } 44 | #endif 45 | 46 | void MKODict::InitDict(EGameMode game) 47 | { 48 | const char* file = nullptr; 49 | 50 | switch (game) 51 | { 52 | case Game_Deception: 53 | file = "data\\mkd_def.txt"; 54 | break; 55 | case Game_Armageddon: 56 | file = "data\\mka_def.txt"; 57 | break; 58 | case Game_DeadlyAlliance: 59 | file = "data\\mkda_def.txt"; 60 | break; 61 | case Game_Unchained: 62 | file = "data\\mku_def.txt"; 63 | break; 64 | case Game_MK11: 65 | file = "data\\mk11_def.txt"; 66 | break; 67 | case Game_MK12: 68 | file = "data\\mk12_def.txt"; 69 | break; 70 | default: 71 | break; 72 | } 73 | 74 | if (file == nullptr) 75 | return; 76 | 77 | ms_gameMode = game; 78 | 79 | printf("Reading: %s\n", file); 80 | FILE* pFile = fopen(file, "rb"); 81 | if (pFile) 82 | { 83 | char szLine[2048]; 84 | char* tempLine; 85 | int errorCheck = 0; 86 | while (fgets(szLine, sizeof(szLine), pFile)) 87 | { 88 | if (szLine[0] == ';' || szLine[0] == '#' || szLine[0] == '\n') 89 | continue; 90 | tempLine = strtok(szLine, " "); 91 | char name[256] = {}; 92 | if (sscanf(szLine, "%s", &name) == 1) 93 | { 94 | std::unique_ptr argTypes; 95 | int funcID = -1; 96 | int numArgs = 0; 97 | int funcSet = 0; 98 | int funcType = 0; 99 | 100 | if (game == Game_MK11 || game == Game_MK12) 101 | { 102 | tempLine = strtok(NULL, " "); 103 | sscanf(tempLine, "%d", &funcType); 104 | } 105 | 106 | if (game == Game_Armageddon || game == Game_MK11 || game == Game_MK12) 107 | { 108 | tempLine = strtok(NULL, " "); 109 | sscanf(tempLine, "%d", &funcSet); 110 | } 111 | 112 | tempLine = strtok(NULL, " "); 113 | sscanf(tempLine, "%d", &funcID); 114 | tempLine = strtok(NULL, " "); 115 | sscanf(tempLine, "%d", &numArgs); 116 | 117 | argTypes = std::make_unique(numArgs); 118 | 119 | for (int i = 0; i < numArgs; i++) 120 | { 121 | tempLine = strtok(NULL, " "); 122 | 123 | if (!tempLine) 124 | { 125 | printf("error at definition: %s\n", name); 126 | break; 127 | } 128 | errorCheck++; 129 | sscanf(tempLine, "%d", &argTypes[i]); 130 | } 131 | 132 | MKOFunctionDefinition def; 133 | sprintf(def.name, name); 134 | def.num_arguments = numArgs; 135 | def.functionID = funcID; 136 | def.functionSet = funcSet; 137 | def.functionType = funcType; 138 | 139 | for (int i = 0; i < numArgs; i++) 140 | { 141 | def.args.push_back((EMKOFunctionArgumentDefinition_Type)argTypes[i]); 142 | } 143 | 144 | ms_vFunctions.push_back(def); 145 | } 146 | } 147 | fclose(pFile); 148 | } 149 | #ifdef SORT_FUNCTIONS 150 | std::sort(ms_vFunctions.begin(), ms_vFunctions.end(), sort_functions); 151 | 152 | for (unsigned int i = 0; i < ms_vFunctions.size(); i++) 153 | { 154 | MKOFunctionDefinition def = {}; 155 | def = ms_vFunctions[i]; 156 | printf("%s %d %d ", def.name, def.functionID, def.num_arguments); 157 | for (int a = 0; a < def.num_arguments; a++) 158 | { 159 | printf("%d ", def.args[a]); 160 | } 161 | printf("\n"); 162 | } 163 | #endif 164 | } 165 | 166 | void MKODict::InitHashTable() 167 | { 168 | InitFunctionHashes(); 169 | std::ifstream pFile("data\\hashdb.bin", std::ifstream::binary); 170 | 171 | if (pFile) 172 | { 173 | int hashNum = 0; 174 | 175 | pFile.read((char*)&hashNum, sizeof(int)); 176 | 177 | for (int i = 0; i < hashNum; i++) 178 | { 179 | HashEntry h; 180 | pFile.read((char*)&h, sizeof(HashEntry)); 181 | ms_vHashes.push_back(h); 182 | } 183 | 184 | } 185 | else 186 | { 187 | std::cout << "INFO: Could not open hashdb.bin!" << std::endl; 188 | } 189 | std::cout << "INFO: Read " << ms_vHashes.size() << " hash entries!" << std::endl; 190 | } 191 | 192 | void MKODict::InitFunctionHashes() 193 | { 194 | FILE* pFile = fopen("data\\function_hash_list.txt", "rb"); 195 | if (pFile) 196 | { 197 | char szLine[2048] = {}; 198 | char* tempLine; 199 | int errorCheck = 0; 200 | while (fgets(szLine, sizeof(szLine), pFile)) 201 | { 202 | if (szLine[0] == ';' || szLine[0] == '#' || szLine[0] == '\n') 203 | continue; 204 | 205 | char name[256] = {}; 206 | unsigned int hash = 0; 207 | sscanf(szLine, "0x%X %s", &hash, &name); 208 | 209 | HashEntry h; 210 | h.hash = hash; 211 | sprintf(h.name, name); 212 | ms_vFunctionHashes.push_back(h); 213 | } 214 | fclose(pFile); 215 | } 216 | 217 | } 218 | 219 | void MKODict::hash2txt() 220 | { 221 | 222 | } 223 | 224 | void MKODict::txt2hash() 225 | { 226 | FILE* pFile = fopen("data\\hashlist.txt", "rb"); 227 | if (pFile) 228 | { 229 | char szLine[2048] = {}; 230 | while (fgets(szLine, sizeof(szLine), pFile)) 231 | { 232 | if (szLine[0] == ';' || szLine[0] == '#' || szLine[0] == '\n') 233 | continue; 234 | 235 | char name[256] = {}; 236 | 237 | sscanf(szLine, "%s", &name); 238 | 239 | HashEntry h; 240 | h.hash = _hash(name); 241 | sprintf(h.name, name); 242 | ms_vHashes.push_back(h); 243 | } 244 | fclose(pFile); 245 | } 246 | std::ofstream oFile("data\\hashdb.bin", std::ofstream::binary); 247 | 248 | int hashNum = ms_vHashes.size(); 249 | oFile.write((char*)&hashNum, sizeof(int)); 250 | 251 | for (unsigned int i = 0; i < ms_vHashes.size(); i++) 252 | { 253 | oFile.write((char*)&ms_vHashes[i], sizeof(HashEntry)); 254 | } 255 | 256 | std::cout << "INFO: Built " << ms_vHashes.size() << " hash entries!" << std::endl; 257 | } 258 | 259 | 260 | const char* MKODict::GetInternalName(int functionID) 261 | { 262 | static int internalSize = sizeof(szInternalNames) / sizeof(szInternalNames[0]); 263 | 264 | if (functionID > internalSize) 265 | { 266 | static char buff[128] = {}; 267 | sprintf(buff, "internal_%d", functionID); 268 | return buff; 269 | } 270 | else 271 | return szInternalNames[functionID - 1]; 272 | } 273 | 274 | int MKODict::GetInternalID(const char* name) 275 | { 276 | static int internalSize = sizeof(szInternalNames) / sizeof(szInternalNames[0]); 277 | 278 | for (int i = 0; i < internalSize; i++) 279 | { 280 | if (strcmp(name, szInternalNames[i]) == 0) 281 | return i; 282 | } 283 | return 0; 284 | } 285 | 286 | bool MKODict::IsFunctionInternal(const char* name) 287 | { 288 | static int internalSize = sizeof(szInternalNames) / sizeof(szInternalNames[0]); 289 | 290 | for (int i = 0; i < internalSize; i++) 291 | { 292 | if (strcmp(name, szInternalNames[i]) == 0) 293 | return true; 294 | } 295 | return false; 296 | } 297 | 298 | bool MKODict::IsDefinitionAvailable(int functionID, int functionSet, int functionType) 299 | { 300 | for (unsigned int i = 0; i < ms_vFunctions.size(); i++) 301 | { 302 | if (ms_gameMode == Game_MK12) 303 | { 304 | if (ms_vFunctions[i].functionID == functionID && ms_vFunctions[i].functionType == functionType) 305 | return true; 306 | } 307 | else if (ms_gameMode == Game_MK11) 308 | { 309 | if (ms_vFunctions[i].functionID == functionID && ms_vFunctions[i].functionSet == functionSet && ms_vFunctions[i].functionType == functionType) 310 | return true; 311 | } 312 | else if (ms_gameMode == Game_Armageddon) 313 | { 314 | if (ms_vFunctions[i].functionID == functionID && ms_vFunctions[i].functionSet == functionSet) 315 | return true; 316 | } 317 | else 318 | { 319 | if (ms_vFunctions[i].functionID == functionID) 320 | return true; 321 | } 322 | } 323 | 324 | return false; 325 | } 326 | 327 | bool MKODict::IsDefinitionAvailable(const char* name) 328 | { 329 | for (unsigned int i = 0; i < ms_vFunctions.size(); i++) 330 | { 331 | if (strcmp(ms_vFunctions[i].name, name) == 0) 332 | return true; 333 | } 334 | return false; 335 | } 336 | 337 | MKOFunctionDefinition MKODict::GetDefinition(int functionID, int functionSet, int functionType) 338 | { 339 | MKOFunctionDefinition def = {}; 340 | 341 | for (unsigned int i = 0; i < ms_vFunctions.size(); i++) 342 | { 343 | if (ms_gameMode == Game_MK11) 344 | { 345 | if (ms_vFunctions[i].functionID == functionID && ms_vFunctions[i].functionSet == functionSet && ms_vFunctions[i].functionType == functionType) 346 | { 347 | def = ms_vFunctions[i]; 348 | break; 349 | } 350 | } 351 | if (ms_gameMode == Game_MK12) 352 | { 353 | if (ms_vFunctions[i].functionID == functionID && ms_vFunctions[i].functionType == functionType) 354 | { 355 | def = ms_vFunctions[i]; 356 | break; 357 | } 358 | } 359 | if (ms_gameMode == Game_Armageddon) 360 | { 361 | if (ms_vFunctions[i].functionID == functionID && ms_vFunctions[i].functionSet == functionSet) 362 | { 363 | def = ms_vFunctions[i]; 364 | break; 365 | } 366 | } 367 | else 368 | { 369 | if (ms_vFunctions[i].functionID == functionID) 370 | { 371 | def = ms_vFunctions[i]; 372 | break; 373 | } 374 | } 375 | 376 | } 377 | 378 | return def; 379 | } 380 | 381 | MKOFunctionDefinition MKODict::GetDefinition(const char* name) 382 | { 383 | MKOFunctionDefinition def = {}; 384 | 385 | for (unsigned int i = 0; i < ms_vFunctions.size(); i++) 386 | { 387 | if (strcmp(ms_vFunctions[i].name, name) == 0) 388 | { 389 | def = ms_vFunctions[i]; 390 | break; 391 | } 392 | } 393 | 394 | return def; 395 | } 396 | 397 | std::string MKODict::GetHashString(unsigned int hash) 398 | { 399 | static char tmp[256] = {}; 400 | sprintf(tmp, "0x%X", hash); 401 | for (unsigned int i = 0; i < ms_vHashes.size(); i++) 402 | { 403 | if (ms_vHashes[i].hash == hash) 404 | { 405 | sprintf(tmp, ms_vHashes[i].name); 406 | break; 407 | } 408 | } 409 | return tmp; 410 | } 411 | 412 | std::string MKODict::GetFunctionHashString(unsigned int hash) 413 | { 414 | static char tmp[256] = {}; 415 | sprintf(tmp, "0x%X", hash); 416 | for (unsigned int i = 0; i < ms_vFunctionHashes.size(); i++) 417 | { 418 | if (ms_vFunctionHashes[i].hash == hash) 419 | { 420 | sprintf(tmp, ms_vFunctionHashes[i].name); 421 | break; 422 | } 423 | } 424 | return tmp; 425 | } 426 | 427 | bool MKODict::IsHashAvailable(unsigned int hash) 428 | { 429 | for (unsigned int i = 0; i < ms_vHashes.size(); i++) 430 | { 431 | if (ms_vHashes[i].hash == hash) 432 | { 433 | return true; 434 | } 435 | } 436 | return false; 437 | } 438 | 439 | unsigned int _hash(const char* input) 440 | { 441 | unsigned int result; 442 | int stringLength; 443 | int character; 444 | 445 | if (!input) 446 | return 0; 447 | stringLength = -1; 448 | 449 | do 450 | ++stringLength; 451 | while (input[stringLength]); 452 | 453 | for (result = 0x811C9DC5; stringLength; --stringLength) 454 | { 455 | character = *(unsigned char*)input++; 456 | result = character ^ (unsigned int)(0x1000193 * result); 457 | } 458 | return result; 459 | } 460 | -------------------------------------------------------------------------------- /mkoasm/code/MKODict.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "..\enums.h" 5 | 6 | //#define SORT_FUNCTIONS 7 | 8 | enum EMKOFunctionArgumentDefinition_Type { 9 | EMKOFAD_Integer, 10 | EMKOFAD_Float, 11 | EMKOFAD_Short, 12 | EMKOFAD_UInt, 13 | EMKOFAD_String, 14 | EMKOFAD_Hex, 15 | EMKOFAD_Hash, 16 | EMKOFAD_HashFunction, 17 | EMKOFAD_ScriptHashFunction, 18 | EMKOFAD_Int64 19 | }; 20 | 21 | struct MKOFunctionArgumentDefinition { 22 | EMKOFunctionArgumentDefinition_Type type; 23 | union argData { 24 | float flt; 25 | int integer; 26 | unsigned int uint; 27 | short word; 28 | }data; 29 | }; 30 | 31 | struct MKOFunctionDefinition { 32 | char name[256] = {}; 33 | int functionID; 34 | int functionType; 35 | int functionSet; 36 | int num_arguments; 37 | std::vector args; 38 | }; 39 | 40 | 41 | struct HashEntry { 42 | unsigned int hash; 43 | char name[128] = {}; 44 | }; 45 | 46 | unsigned int _hash(const char* input); 47 | 48 | class MKODict { 49 | public: 50 | static EGameMode ms_gameMode; 51 | 52 | static std::vector ms_vFunctions; 53 | static std::vector ms_vHashes; 54 | static std::vector ms_vFunctionHashes; 55 | static void InitDict(EGameMode game); 56 | static void InitHashTable(); 57 | static void InitFunctionHashes(); 58 | 59 | static void hash2txt(); 60 | static void txt2hash(); 61 | 62 | static const char* GetInternalName(int functionID); 63 | static int GetInternalID(const char* name); 64 | static bool IsFunctionInternal(const char* name); 65 | 66 | static bool IsDefinitionAvailable(int functionID, int functionSet = 0, int functionType = 0); 67 | static bool IsDefinitionAvailable(const char* name); 68 | static MKOFunctionDefinition GetDefinition(int functionID, int functionSet = 0, int functionType = 0); 69 | static MKOFunctionDefinition GetDefinition(const char* name); 70 | static std::string GetHashString(unsigned int hash); 71 | static std::string GetFunctionHashString(unsigned int hash); 72 | static bool IsHashAvailable(unsigned int hash); 73 | }; -------------------------------------------------------------------------------- /mkoasm/code/MKScript.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MKScriptTypes.h" 3 | 4 | struct mko_header { 5 | int functions; 6 | int last_function_offset; 7 | int script_string_size; 8 | int string_data_size; 9 | 10 | int unknown_data_size; // post mkda 11 | int field20; 12 | int static_variables; 13 | int last_variable_offset; 14 | }; 15 | 16 | 17 | struct mko_function_header { 18 | int name_offset; 19 | int offset; 20 | int unknown; // post mkda 21 | }; 22 | 23 | 24 | struct mko_function_header_mka { 25 | int name_offset; 26 | int offset; 27 | int unknown; // post mkda 28 | }; 29 | 30 | 31 | struct mko_variable_header { 32 | int name_offset; 33 | int unknown; 34 | int offset; 35 | int numElems; 36 | }; 37 | 38 | 39 | struct mko_command { 40 | short functionID; 41 | short isInternal; 42 | short numVariables; 43 | short unk2; 44 | // new in mka 45 | short functionSet; 46 | 47 | // padding for jumps 48 | bool is_pad; 49 | }; 50 | 51 | 52 | enum EMKOAICommandButton { 53 | EAICommandButton_Attack1, 54 | EAICommandButton_Attack1Up, 55 | EAICommandButton_Attack1Down, 56 | EAICommandButton_Attack1Towards, 57 | EAICommandButton_Attack1Away, 58 | 59 | EAICommandButton_Attack2, 60 | EAICommandButton_Attack2Up, 61 | EAICommandButton_Attack2Down, 62 | EAICommandButton_Attack2Towards, 63 | EAICommandButton_Attack2Away, 64 | 65 | EAICommandButton_Attack3, 66 | EAICommandButton_Attack3Up, 67 | EAICommandButton_Attack3Down, 68 | EAICommandButton_Attack3Towards, 69 | EAICommandButton_Attack3Away, 70 | 71 | EAICommandButton_Attack4, 72 | EAICommandButton_Attack4Up, 73 | EAICommandButton_Attack4Down, 74 | EAICommandButton_Attack4Towards, 75 | EAICommandButton_Attack4Away, 76 | 77 | EAICommandButton_Attack5, 78 | EAICommandButton_Attack5Up, 79 | EAICommandButton_Attack5Down, 80 | EAICommandButton_Attack5Towards, 81 | EAICommandButton_Attack5Away, 82 | }; 83 | 84 | enum EMKOAICommandType { 85 | EAICommandType_Button, 86 | EAICommandType_ChangeStyle, 87 | EAICommandType_SpecialMove = 4, 88 | EAICommandType_WaitAfterPopup = 20, 89 | }; -------------------------------------------------------------------------------- /mkoasm/code/MKScriptTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _M_X64 4 | typedef int int64; 5 | #else 6 | typedef __int64 int64; 7 | #endif 8 | 9 | enum EMovelistTypes { 10 | EMovelist_Style_One, 11 | EMovelist_Style_Two, 12 | EMovelist_Style_Three, 13 | EMovelist_SpecialMove 14 | 15 | }; 16 | 17 | struct type_movelist { 18 | int category; 19 | int name; 20 | int tip; 21 | int command; 22 | int command2; 23 | int unk; 24 | }; 25 | 26 | struct type_attributes { 27 | float activeFrame; 28 | float field4; 29 | float field8; 30 | float animSpeed; 31 | float movementSpeed; 32 | short field20; 33 | short field22; 34 | short field24; 35 | short field26; 36 | short field28; 37 | short field30; 38 | int field32; 39 | float field36; 40 | float field40; 41 | float damage; 42 | int hitLevel; 43 | short field52; 44 | short field54; 45 | float field56; 46 | }; 47 | 48 | struct type_plrdata_model { 49 | int archiveNameOffset; 50 | int headNameOffset; 51 | int animsNameOffset; 52 | int field12; 53 | int field16; 54 | int field20; 55 | float field24; 56 | int startupFunctionID; 57 | int reloadFunctionID; 58 | }; 59 | 60 | // MKD/MKU 61 | struct type_player_data { 62 | int field0; 63 | type_plrdata_model primary; 64 | type_plrdata_model alt; 65 | int apArchiveNameOffset; 66 | int apHeadNameOffset; 67 | int apAltArchiveNameOffset; 68 | int apAltHeadNameOffset; 69 | int sharedArchiveNameOffset; 70 | int specialsSbankID; 71 | int voiceID; 72 | int field104; 73 | int winVoiceID; 74 | int field112; 75 | int field116; 76 | int field120; 77 | int field124; 78 | int stylesVariableID; 79 | int fatDataVariableID; 80 | int field136; 81 | float vec[3]; 82 | int puzzleAnimNameOffset; 83 | int field156; 84 | int particleVariableIDs[2]; 85 | int field168; 86 | int limbPiecePivotsID; 87 | int limbAssemblyPivotsID; 88 | int field180; 89 | int field184; 90 | int field188; 91 | int attackHighFastID; 92 | int field196; 93 | int field200; 94 | int field204; 95 | int distanceID; 96 | int field212; 97 | int field216; 98 | int field220; 99 | int field224; 100 | int field228; 101 | int field232; 102 | int field236; 103 | int field240; 104 | int field244; 105 | int field248; 106 | int field252; 107 | int field256; 108 | int field260; 109 | int field264; 110 | int field268; 111 | int field272; 112 | int field276; 113 | int throwAttackID; 114 | int field284; 115 | int field288; 116 | int field292; 117 | int field296; 118 | int field300; 119 | int field304; 120 | int reactionCleanUpFunctionID; 121 | int victoryFunctionID; 122 | int throwFunctionID; 123 | int field320; 124 | }; -------------------------------------------------------------------------------- /mkoasm/code/MKScript_DCF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | struct mko_header_dcf { 3 | int functions; 4 | int static_variables; 5 | int externs; 6 | int externVariables; 7 | int assets; 8 | int soundAssets; 9 | int field24; 10 | int field28; 11 | int bytecodeSize; 12 | int string_size; 13 | int functionsOffset; 14 | int unknowns; 15 | int tweakVarsOffset; 16 | int tweakVarsSize; 17 | // new in dcf 18 | int field56; 19 | 20 | }; 21 | 22 | struct mko_asset_dcf { 23 | int archiveNameOffset; 24 | int field4; 25 | int nameOffset; 26 | int field12; 27 | int field16; 28 | }; 29 | -------------------------------------------------------------------------------- /mkoasm/code/MKScript_DCF2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MKScriptTypes.h" 3 | 4 | struct mko_header_dcf2 { 5 | int functions; 6 | int static_variables; 7 | int dynamic_variables; 8 | int externs; 9 | int extern_variables; 10 | int assets; 11 | int global_pointers; 12 | int total_pointers; 13 | int bytecodeSize; 14 | int string_size; 15 | int stack_size; 16 | int fixups; 17 | int tweakvars; // only difference from mkx 18 | int numSource; 19 | int tweakvars_stringSize; 20 | int globalstack_size; 21 | }; 22 | 23 | #pragma pack(push, 1) 24 | struct mko_tweakvar_dcf2 { 25 | int type; 26 | int offset; 27 | int size; 28 | int index; 29 | int index2; 30 | int unk; 31 | int64 unk2; 32 | }; 33 | #pragma pack(pop) 34 | -------------------------------------------------------------------------------- /mkoasm/code/MKScript_MK10.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MKScriptTypes.h" 3 | 4 | struct mko_header_mk10 { 5 | int functions; 6 | int static_variables; 7 | int dynamic_variables; 8 | int externs; 9 | int extern_variables; 10 | int assets; 11 | int global_pointers; 12 | int total_pointers; 13 | int bytecodeSize; 14 | int string_size; 15 | int stack_size; 16 | int fixups; 17 | int tweakvars_size; 18 | int numSource; 19 | int tweakvars_stringSize; 20 | int globalstack_size; 21 | }; 22 | 23 | #pragma pack(push, 1) 24 | struct mko_function_header_mk10 { 25 | int64 nameOffset; 26 | int64 functionOffset; 27 | int64 field16; 28 | int64 field24; 29 | int64 field32; 30 | unsigned int functionHash; 31 | int size; 32 | int field48; 33 | int field52; 34 | int num_args; 35 | int function_index; 36 | int local_fixup_count; 37 | int checked_object_count; 38 | unsigned int paramsHash; 39 | int field72; 40 | }; 41 | #pragma pack(pop) 42 | 43 | struct mko_variable_header_mk10 { 44 | int stack_offset; 45 | int data; 46 | unsigned int nameHash; 47 | int size; 48 | int stride; 49 | int pad; 50 | }; 51 | 52 | 53 | struct mko_extern_mk10 { 54 | int file_name_offset; 55 | int file_name; 56 | int name_offset; 57 | int name; 58 | unsigned int nameHash; 59 | int pad; 60 | }; 61 | 62 | struct mko_extern_var_mk10 { 63 | int FName_Index; 64 | int FName_Flags; 65 | int64 addr; 66 | int flags; 67 | unsigned int name_offset; 68 | }; 69 | 70 | struct mko_source_header_mk10 { 71 | int name_offset; 72 | int pad; 73 | }; 74 | 75 | struct mko_asset_mk10 { 76 | int package_name_offset; 77 | int package_name; 78 | int item_name_offset; 79 | int item_name; 80 | int asset; 81 | int sound; 82 | int type; 83 | int index; 84 | }; 85 | 86 | struct mko_fixup_mk10 { 87 | int type; 88 | int offset; 89 | int64 data; 90 | }; 91 | 92 | 93 | 94 | enum mko_bc_type_mk10 { 95 | MK10_BC_Type_MKO = 1 96 | }; 97 | 98 | struct mko_command_mk10 { 99 | int64 type; 100 | short subType; 101 | short field10; 102 | short numVars; 103 | short field14; 104 | bool is_pad; 105 | }; -------------------------------------------------------------------------------- /mkoasm/code/MKScript_MK11.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MKScriptTypes.h" 3 | 4 | 5 | 6 | #pragma pack(push, 1) 7 | struct mko_function_header_mk11 { 8 | int64 nameOffset; 9 | unsigned int functionHash; 10 | int field12; 11 | int function_index; 12 | unsigned int paramsHash; 13 | int64 field24; 14 | int64 functionOffset; 15 | int64 field40; 16 | int64 field48; 17 | int64 field56; 18 | int size; 19 | int field68; 20 | int field72; 21 | int field76; 22 | int field80; 23 | unsigned int hash; 24 | unsigned int hash2; 25 | int field92; 26 | int field96; 27 | int field100; 28 | int field104; 29 | int field112; 30 | }; 31 | #pragma pack(pop) 32 | 33 | struct mko_extern_mk11 { 34 | int file_name_offset; 35 | int file_name; 36 | unsigned int nameHash; 37 | int field12; 38 | int field16; 39 | int field20; 40 | int field24; 41 | int field28; 42 | int name_offset; 43 | int name; 44 | }; 45 | 46 | struct mko_extern_var_mk11 { 47 | int name_offset; 48 | int field4; 49 | int64 addr; 50 | int field16; 51 | int field20; 52 | }; 53 | -------------------------------------------------------------------------------- /mkoasm/code/MKScript_MK12.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MKScriptTypes.h" 3 | #include 4 | 5 | // wrapper only, in mk12 data is after each size 6 | struct mko_header_mk12 { 7 | int functions; 8 | int static_variables; 9 | int dynamic_variables; 10 | int assets; 11 | int numSource; 12 | int string_size; 13 | int tweakvars_stringSize; 14 | int fixups; 15 | }; 16 | 17 | // returns in mk12, similar to mka 18 | struct mko_link_mk12 { 19 | int type; 20 | int field4; 21 | int data; 22 | }; 23 | 24 | 25 | #pragma pack(push, 1) 26 | struct mko_function_header_mk12 { 27 | int nameOffset; 28 | unsigned int functionHash; 29 | int nameOffset2; 30 | int field12; 31 | int field16; 32 | int numLinks; 33 | int linksOffset; 34 | //mko_link_mk12 links[numLinks]; 35 | int numArgs; 36 | std::vector args; 37 | int size; 38 | int bytecodeOffset; 39 | // char bytecode[bytecodeSize]; 40 | int stackSize; 41 | int stackOffset; 42 | // char stackData[stackSize]; 43 | char unkData[24]; 44 | }; 45 | #pragma pack(pop) 46 | 47 | struct mko_variable_header_mk12 { 48 | int stack_offset; 49 | int hash; 50 | int name_offset; 51 | int type_offset; 52 | int size; 53 | int field20; 54 | }; 55 | 56 | 57 | struct mko_fixup_mk12 { 58 | int field0; 59 | int field4; 60 | int field8; 61 | int field12; 62 | int field16; 63 | }; 64 | 65 | 66 | struct mko_asset_mk12 { 67 | int pathOffset; 68 | int nameOffset; 69 | }; 70 | 71 | // new unknown sections 72 | 73 | struct mko_function_data1_mk12 { 74 | int field0; 75 | int field4; 76 | int field8; 77 | int field12; 78 | int feild16; 79 | int field20; 80 | }; 81 | 82 | struct mko_function_data2_mk12 { 83 | int field0; 84 | int field4; 85 | int field8; 86 | int field12; 87 | int feild16; 88 | int field20; 89 | int field24; 90 | }; -------------------------------------------------------------------------------- /mkoasm/code/MKScript_MK8.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct mko_header_mk8 { 4 | int functions; 5 | int static_variables; 6 | int externs; 7 | int assets; 8 | int field36; 9 | int field40; 10 | int field44; 11 | int string_size; 12 | int field52; 13 | int field56; 14 | 15 | }; 16 | 17 | struct mko_function_header_mk8 { 18 | int nameOffset; 19 | int argTypeOffset; 20 | int field8; 21 | int size; 22 | int field16; 23 | // probably stack size? 24 | int unkSize; 25 | int field24; 26 | int field28; 27 | int id; 28 | int numUnk; 29 | int field40; 30 | }; 31 | 32 | struct mko_function_header_mk8_unk { 33 | int field0; 34 | int field4; 35 | int field8; 36 | int field12; 37 | int field16; 38 | }; 39 | 40 | 41 | struct mko_extern_mk8 { 42 | int nameOffset; 43 | int importName; 44 | unsigned int field8; 45 | int field12; 46 | int field16; 47 | int field20; 48 | }; 49 | 50 | 51 | struct mko_asset_mk8 { 52 | int archiveNameOffset; 53 | int nameOffset; 54 | int field8; 55 | }; 56 | 57 | 58 | struct mko_variable_header_mk8 { 59 | int name_offset; 60 | int size; 61 | int elemSize; 62 | int offset; 63 | }; 64 | 65 | enum mko_command_mk8_type { 66 | MK8_CT_INTERNAL = 0, 67 | MK8_CT_STEP = 0x4000, 68 | MK8_CT_EXTERN = 0x8000, 69 | }; 70 | 71 | struct mko_command_mk8_bytecode { 72 | int field0; 73 | int field4; 74 | int data; // first half - numData, second half - unknown, but seems to be same as previous mks 75 | int commandData; // first half - func id, second is type; 76 | 77 | // var data 78 | }; 79 | struct mko_command_mk8 { 80 | int field0; 81 | int field4; 82 | int numData; 83 | int functionID; 84 | int functionType; 85 | bool is_pad; 86 | }; 87 | -------------------------------------------------------------------------------- /mkoasm/code/MKScript_MK9.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct mko_header_mk9 { 4 | int functions; 5 | int static_variables; 6 | int externs; 7 | int externVariables; 8 | int assets; 9 | int soundAssets; 10 | int field24; 11 | int field28; 12 | int bytecodeSize; 13 | int string_size; 14 | int stack_size; 15 | int fixups; 16 | int tweakVarsOffset; 17 | int tweakVarsSize; 18 | 19 | }; 20 | 21 | struct mko_function_header_mk9 { 22 | int nameOffset; 23 | unsigned int functionHash; 24 | int functionOffset; 25 | int size; 26 | int field16; 27 | int field20; 28 | int field24; 29 | int field28; 30 | int function_index; 31 | int local_fixup_count; 32 | int field40; 33 | unsigned int paramsHash; 34 | }; 35 | 36 | struct mko_function_header_mk9_unk { 37 | int field0; 38 | //int data[field0]; 39 | }; 40 | 41 | 42 | struct mko_extern_mk9 { 43 | unsigned int nameHash; 44 | int importName; 45 | unsigned int field8; 46 | int field12; 47 | int field16; 48 | int field20; 49 | int field24; 50 | }; 51 | 52 | 53 | struct mko_extern_variable_mk9 { 54 | int name_offset; 55 | int field4; 56 | int field8; 57 | int field12; 58 | }; 59 | 60 | 61 | struct mko_asset_mk9 { 62 | int archiveNameOffset; 63 | int nameOffset; 64 | int field8; 65 | int field12; 66 | }; 67 | 68 | struct mko_sound_asset_mk9 { 69 | int archiveNameOffset; 70 | int nameOffset; 71 | int field8; 72 | int field12; 73 | int field16; 74 | }; 75 | 76 | 77 | struct mko_variable_header_mk9 { 78 | unsigned int name_hash; 79 | int size; 80 | int elemSize; 81 | int offset; 82 | }; 83 | 84 | 85 | struct mko_fixup_mk9 { 86 | int field0; 87 | int offset; // ? 88 | int name_offset; 89 | int field12; 90 | }; 91 | -------------------------------------------------------------------------------- /mkoasm/code/misc.cpp: -------------------------------------------------------------------------------- 1 | #include "misc.h" 2 | 3 | void changeEndINT(int* value) 4 | { 5 | *value = (*value & 0x000000FFU) << 24 | (*value & 0x0000FF00U) << 8 | (*value & 0x00FF0000U) >> 8 | (*value & 0xFF000000U) >> 24; 6 | } 7 | 8 | void changeEndSHORT(short* value) 9 | { 10 | *value = (*value & 0x00FFU) << 8 | (*value & 0xFF00U) >> 8; 11 | } 12 | -------------------------------------------------------------------------------- /mkoasm/code/misc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void changeEndINT(int* value); 4 | void changeEndSHORT(short* value); -------------------------------------------------------------------------------- /mkoasm/compiler/MKOCompiler.cpp: -------------------------------------------------------------------------------- 1 | #include "MKOCompiler.h" 2 | #include "..\code\MKODict.h" 3 | #include "..\code\misc.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef _WIN32 10 | #include 11 | #endif // _WIN32 12 | 13 | void MKOCompiler::ParseFunctionLine(char* line, bool& error, std::ofstream& file, EGameMode game) 14 | { 15 | char buff[512] = {}; 16 | char args[1024] = {}; 17 | sprintf(buff, line); 18 | 19 | // name 20 | 21 | char* pLine = strtok(buff, "("); 22 | 23 | std::string functionName = pLine; 24 | std::string fullLine = line; 25 | 26 | int funcID = -1; 27 | int funcSet = -1; 28 | int numArgs = 0; 29 | int expectedArgs = 0; 30 | bool isInternal = false; 31 | std::vector argsData; 32 | MKOFunctionDefinition def; 33 | 34 | bool def_available = MKODict::IsDefinitionAvailable(functionName.c_str()); 35 | 36 | if (def_available) 37 | { 38 | def = MKODict::GetDefinition(functionName.c_str()); 39 | funcID = def.functionID; 40 | 41 | if (game == Game_Armageddon) 42 | funcSet = def.functionSet; 43 | 44 | expectedArgs = def.args.size(); 45 | } 46 | else if (MKODict::IsFunctionInternal(functionName.c_str())) 47 | { 48 | funcID = MKODict::GetInternalID(functionName.c_str()); 49 | isInternal = true; 50 | if (game == Game_Armageddon) 51 | funcSet = 0; 52 | } 53 | else 54 | { 55 | SetColor(CT_Warning); 56 | printf("WARNING: Definition for %s is not available! Detailed information is not available.\n", functionName.c_str()); 57 | if (size_t pos = functionName.find("function_") != std::string::npos) 58 | { 59 | if (game == Game_Deception) 60 | { 61 | std::string number = functionName.substr(functionName.find_last_of("function_") + 1); 62 | std::stringstream ss(number); 63 | ss >> funcID; 64 | } 65 | 66 | 67 | if (game == Game_Armageddon) 68 | { 69 | std::string combo = functionName.substr(strlen("function_")); 70 | std::string setStr = combo.substr(0, combo.find_first_of("_")); 71 | std::string funcStr = combo.substr(combo.find_last_of("_") + 1); 72 | 73 | std::stringstream set(setStr); 74 | set >> funcSet; 75 | 76 | std::stringstream func(funcStr); 77 | func >> funcID; 78 | 79 | } 80 | } 81 | else 82 | { 83 | SetColor(CT_Error); 84 | printf_s("ERROR: Cannot get the function ID of %s.\n", functionName.c_str()); 85 | error = true; 86 | return; 87 | } 88 | 89 | } 90 | SetColor(CT_Reset); 91 | 92 | // arguments 93 | pLine = strtok(NULL, ")"); 94 | std::string argStr = pLine; 95 | 96 | if (fullLine.find("();") == std::string::npos) 97 | { 98 | sprintf(args, pLine); 99 | 100 | char* argLine = strtok(args, ","); 101 | while (!(argLine == NULL) && !(strcmp(argLine, ";") == 0)) 102 | { 103 | MKOFunctionArgumentDefinition arg; 104 | if (def_available) 105 | { 106 | EMKOFunctionArgumentDefinition_Type type = def.args[numArgs]; 107 | arg.type = type; 108 | switch (type) 109 | { 110 | case EMKOFAD_Integer: 111 | sscanf(argLine, "%d", &arg.data.integer); 112 | break; 113 | case EMKOFAD_Float: 114 | sscanf(argLine, "%f", &arg.data.flt); 115 | break; 116 | case EMKOFAD_Short: 117 | sscanf(argLine, "%d", &arg.data.word); 118 | break; 119 | case EMKOFAD_UInt: 120 | sscanf(argLine, "%d", &arg.data.uint); 121 | break; 122 | case EMKOFAD_String: 123 | printf("INFO: String arguments are not supported for now."); 124 | break; 125 | case EMKOFAD_Hex: 126 | sscanf(argLine, "%x", &arg.data.uint); 127 | break; 128 | default: 129 | break; 130 | } 131 | argsData.push_back(arg); 132 | } 133 | else 134 | { 135 | arg.type = EMKOFAD_Integer; 136 | sscanf(argLine, "%d", &arg.data.integer); 137 | argsData.push_back(arg); 138 | } 139 | 140 | argLine = strtok(NULL, ","); 141 | numArgs++; 142 | } 143 | } 144 | 145 | 146 | if (def_available) 147 | { 148 | SetColor(CT_Warning); 149 | if (numArgs > expectedArgs) 150 | { 151 | printf_s("WARNING: Too many arguments for %s! %d required, got %d.\n", functionName.c_str(), expectedArgs, numArgs); 152 | } 153 | 154 | 155 | if (numArgs < expectedArgs) 156 | { 157 | printf_s("WARNING: Not enough arguments for %s! %d required, got %d.\n", functionName.c_str(), expectedArgs, numArgs); 158 | } 159 | 160 | 161 | } 162 | SetColor(CT_Reset); 163 | 164 | SetColor(CT_Good); 165 | printf_s("INFO: %-35s\t Args: %03d Definition: %s\n", functionName.c_str(), numArgs, def_available ? "yes" : "no"); 166 | 167 | 168 | int a1 = 0; 169 | int a2 = 0; 170 | 171 | 172 | 173 | if (game == Game_Deception || game == Game_Unchained) 174 | a1 = MAKELONG(funcID + 1, isInternal ? 0xFF00 : 0); 175 | else if (game == Game_Armageddon) 176 | { 177 | short outSet = funcSet; 178 | changeEndSHORT(&outSet); 179 | a1 = MAKELONG(funcID + 1, outSet); 180 | } 181 | 182 | 183 | 184 | file.write((char*)&a1, sizeof(int)); 185 | 186 | a2 = MAKELONG(numArgs, -1); 187 | file.write((char*)&a2, sizeof(int)); 188 | 189 | for (unsigned int i = 0; i < argsData.size(); i++) 190 | { 191 | MKOFunctionArgumentDefinition arg = argsData[i]; 192 | switch (arg.type) 193 | { 194 | case EMKOFAD_Integer: 195 | file.write((char*)&arg.data.integer, sizeof(int)); 196 | break; 197 | case EMKOFAD_Float: 198 | file.write((char*)&arg.data.flt, sizeof(float)); 199 | break; 200 | case EMKOFAD_Short: 201 | file.write((char*)&arg.data.word, sizeof(int)); 202 | break; 203 | case EMKOFAD_UInt: 204 | file.write((char*)&arg.data.integer, sizeof(int)); 205 | break; 206 | case EMKOFAD_String: 207 | printf("N/A\n"); 208 | break; 209 | case EMKOFAD_Hex: 210 | file.write((char*)&arg.data.integer, sizeof(int)); 211 | break; 212 | default: 213 | break; 214 | } 215 | } 216 | #ifdef _DEBUG 217 | 218 | for (int i = 0; i < argsData.size(); i++) 219 | { 220 | MKOFunctionArgumentDefinition arg = argsData[i]; 221 | printf("Arg %d:", i); 222 | switch (arg.type) 223 | { 224 | case EMKOFAD_Integer: 225 | printf("%d\n", arg.data.integer); 226 | break; 227 | case EMKOFAD_Float: 228 | printf("%f\n", arg.data.flt); 229 | break; 230 | case EMKOFAD_Short: 231 | printf("%d\n", arg.data.word); 232 | break; 233 | case EMKOFAD_UInt: 234 | printf("%d\n", arg.data.uint); 235 | break; 236 | case EMKOFAD_String: 237 | printf("N/A\n"); 238 | break; 239 | case EMKOFAD_Hex: 240 | printf("0x%X\n", arg.data.uint); 241 | break; 242 | default: 243 | break; 244 | } 245 | } 246 | #endif // _DEBUG 247 | 248 | SetColor(CT_Reset); 249 | } 250 | 251 | void MKOCompiler::CompileFile(const char* file, EGameMode game) 252 | { 253 | FILE* pFile = fopen(file, "rb"); 254 | if (pFile) 255 | { 256 | std::string output = file; 257 | output = output.substr(0, output.find_last_of(".")); 258 | 259 | std::ofstream oFile(output, std::ofstream::binary); 260 | 261 | char szLine[2048] = {}; 262 | bool error = false; 263 | int line = 0; 264 | SetColor(CT_Info); 265 | printf("Processing file: %s\n", file); 266 | SetColor(CT_Reset); 267 | while (fgets(szLine, sizeof(szLine), pFile)) 268 | { 269 | line++; 270 | if (szLine[0] == ';' || szLine[0] == '#' || szLine[0] == '\n') 271 | continue; 272 | 273 | 274 | MKOCodeEntry c; 275 | ParseFunctionLine(szLine, error, oFile, game); 276 | 277 | SetColor(CT_Reset); 278 | if (error) 279 | { 280 | SetColor(CT_Error); 281 | printf("An error occured on line %d in \"%s\". Compilation stopped.\n", line, file); 282 | oFile.close(); 283 | std::remove(output.c_str()); 284 | SetColor(CT_Reset); 285 | break; 286 | } 287 | 288 | } 289 | if (!error) 290 | { 291 | SetColor(CT_Info); 292 | printf("Build succesful. Output: %s\n", output.c_str()); 293 | SetColor(CT_Reset); 294 | } 295 | 296 | fclose(pFile); 297 | } 298 | } 299 | 300 | void MKOCompiler::SetColor(EColorType ct) 301 | { 302 | #ifdef _WIN32 303 | HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 304 | switch (ct) 305 | { 306 | case CT_Warning: 307 | SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY); 308 | break; 309 | case CT_Error: 310 | SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY); 311 | break; 312 | case CT_Good: 313 | SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY); 314 | break; 315 | case CT_Reset: 316 | SetConsoleTextAttribute(hConsole, 7); 317 | break; 318 | case CT_Info: 319 | SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY); 320 | break; 321 | default: 322 | break; 323 | } 324 | #endif // _WIN32 325 | 326 | } 327 | -------------------------------------------------------------------------------- /mkoasm/compiler/MKOCompiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\MKOReader.h" 3 | #include 4 | 5 | enum EColorType { 6 | CT_Warning, 7 | CT_Error, 8 | CT_Good, 9 | CT_Reset, 10 | CT_Info 11 | }; 12 | 13 | class MKOCompiler { 14 | public: 15 | 16 | static void ParseFunctionLine(char* line, bool& error, std::ofstream& file, EGameMode game = Game_Deception); 17 | static void CompileFile(const char* file, EGameMode game = Game_Deception); 18 | 19 | static void SetColor(EColorType ct); 20 | }; -------------------------------------------------------------------------------- /mkoasm/enums.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | enum EGameMode { 3 | Game_Deception, 4 | Game_Armageddon, 5 | Game_DeadlyAlliance, 6 | Game_Unchained, 7 | Game_MKVSDC, 8 | Game_MK9, 9 | Game_MK9_Vita, 10 | Game_Injustice, 11 | Game_MK10, 12 | Game_Injustice2, 13 | Game_MK11, 14 | Game_MK12 15 | }; 16 | -------------------------------------------------------------------------------- /mkoasm/ini.c: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | SPDX-License-Identifier: BSD-3-Clause 4 | 5 | Copyright (C) 2009-2020, Ben Hoyt 6 | 7 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 8 | home page for more info: 9 | 10 | https://github.com/benhoyt/inih 11 | 12 | */ 13 | 14 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) 15 | #define _CRT_SECURE_NO_WARNINGS 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "ini.h" 23 | 24 | #if !INI_USE_STACK 25 | #if INI_CUSTOM_ALLOCATOR 26 | #include 27 | void* ini_malloc(size_t size); 28 | void ini_free(void* ptr); 29 | void* ini_realloc(void* ptr, size_t size); 30 | #else 31 | #include 32 | #define ini_malloc malloc 33 | #define ini_free free 34 | #define ini_realloc realloc 35 | #endif 36 | #endif 37 | 38 | #define MAX_SECTION 50 39 | #define MAX_NAME 50 40 | 41 | /* Used by ini_parse_string() to keep track of string parsing state. */ 42 | typedef struct { 43 | const char* ptr; 44 | size_t num_left; 45 | } ini_parse_string_ctx; 46 | 47 | /* Strip whitespace chars off end of given string, in place. Return s. */ 48 | static char* rstrip(char* s) 49 | { 50 | char* p = s + strlen(s); 51 | while (p > s && isspace((unsigned char)(*--p))) 52 | *p = '\0'; 53 | return s; 54 | } 55 | 56 | /* Return pointer to first non-whitespace char in given string. */ 57 | static char* lskip(const char* s) 58 | { 59 | while (*s && isspace((unsigned char)(*s))) 60 | s++; 61 | return (char*)s; 62 | } 63 | 64 | /* Return pointer to first char (of chars) or inline comment in given string, 65 | or pointer to NUL at end of string if neither found. Inline comment must 66 | be prefixed by a whitespace character to register as a comment. */ 67 | static char* find_chars_or_comment(const char* s, const char* chars) 68 | { 69 | #if INI_ALLOW_INLINE_COMMENTS 70 | int was_space = 0; 71 | while (*s && (!chars || !strchr(chars, *s)) && 72 | !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) { 73 | was_space = isspace((unsigned char)(*s)); 74 | s++; 75 | } 76 | #else 77 | while (*s && (!chars || !strchr(chars, *s))) { 78 | s++; 79 | } 80 | #endif 81 | return (char*)s; 82 | } 83 | 84 | /* Similar to strncpy, but ensures dest (size bytes) is 85 | NUL-terminated, and doesn't pad with NULs. */ 86 | static char* strncpy0(char* dest, const char* src, size_t size) 87 | { 88 | /* Could use strncpy internally, but it causes gcc warnings (see issue #91) */ 89 | size_t i; 90 | for (i = 0; i < size - 1 && src[i]; i++) 91 | dest[i] = src[i]; 92 | dest[i] = '\0'; 93 | return dest; 94 | } 95 | 96 | /* See documentation in header file. */ 97 | int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, 98 | void* user) 99 | { 100 | /* Uses a fair bit of stack (use heap instead if you need to) */ 101 | #if INI_USE_STACK 102 | char line[INI_MAX_LINE]; 103 | size_t max_line = INI_MAX_LINE; 104 | #else 105 | char* line; 106 | size_t max_line = INI_INITIAL_ALLOC; 107 | #endif 108 | #if INI_ALLOW_REALLOC && !INI_USE_STACK 109 | char* new_line; 110 | size_t offset; 111 | #endif 112 | char section[MAX_SECTION] = ""; 113 | char prev_name[MAX_NAME] = ""; 114 | 115 | char* start; 116 | char* end; 117 | char* name; 118 | char* value; 119 | int lineno = 0; 120 | int error = 0; 121 | 122 | #if !INI_USE_STACK 123 | line = (char*)ini_malloc(INI_INITIAL_ALLOC); 124 | if (!line) { 125 | return -2; 126 | } 127 | #endif 128 | 129 | #if INI_HANDLER_LINENO 130 | #define HANDLER(u, s, n, v) handler(u, s, n, v, lineno) 131 | #else 132 | #define HANDLER(u, s, n, v) handler(u, s, n, v) 133 | #endif 134 | 135 | /* Scan through stream line by line */ 136 | while (reader(line, (int)max_line, stream) != NULL) { 137 | #if INI_ALLOW_REALLOC && !INI_USE_STACK 138 | offset = strlen(line); 139 | while (offset == max_line - 1 && line[offset - 1] != '\n') { 140 | max_line *= 2; 141 | if (max_line > INI_MAX_LINE) 142 | max_line = INI_MAX_LINE; 143 | new_line = ini_realloc(line, max_line); 144 | if (!new_line) { 145 | ini_free(line); 146 | return -2; 147 | } 148 | line = new_line; 149 | if (reader(line + offset, (int)(max_line - offset), stream) == NULL) 150 | break; 151 | if (max_line >= INI_MAX_LINE) 152 | break; 153 | offset += strlen(line + offset); 154 | } 155 | #endif 156 | 157 | lineno++; 158 | 159 | start = line; 160 | #if INI_ALLOW_BOM 161 | if (lineno == 1 && (unsigned char)start[0] == 0xEF && 162 | (unsigned char)start[1] == 0xBB && 163 | (unsigned char)start[2] == 0xBF) { 164 | start += 3; 165 | } 166 | #endif 167 | start = lskip(rstrip(start)); 168 | 169 | if (strchr(INI_START_COMMENT_PREFIXES, *start)) { 170 | /* Start-of-line comment */ 171 | } 172 | #if INI_ALLOW_MULTILINE 173 | else if (*prev_name && *start && start > line) { 174 | #if INI_ALLOW_INLINE_COMMENTS 175 | end = find_chars_or_comment(start, NULL); 176 | if (*end) 177 | *end = '\0'; 178 | rstrip(start); 179 | #endif 180 | /* Non-blank line with leading whitespace, treat as continuation 181 | of previous name's value (as per Python configparser). */ 182 | if (!HANDLER(user, section, prev_name, start) && !error) 183 | error = lineno; 184 | } 185 | #endif 186 | else if (*start == '[') { 187 | /* A "[section]" line */ 188 | end = find_chars_or_comment(start + 1, "]"); 189 | if (*end == ']') { 190 | *end = '\0'; 191 | strncpy0(section, start + 1, sizeof(section)); 192 | *prev_name = '\0'; 193 | #if INI_CALL_HANDLER_ON_NEW_SECTION 194 | if (!HANDLER(user, section, NULL, NULL) && !error) 195 | error = lineno; 196 | #endif 197 | } 198 | else if (!error) { 199 | /* No ']' found on section line */ 200 | error = lineno; 201 | } 202 | } 203 | else if (*start) { 204 | /* Not a comment, must be a name[=:]value pair */ 205 | end = find_chars_or_comment(start, "=:"); 206 | if (*end == '=' || *end == ':') { 207 | *end = '\0'; 208 | name = rstrip(start); 209 | value = end + 1; 210 | #if INI_ALLOW_INLINE_COMMENTS 211 | end = find_chars_or_comment(value, NULL); 212 | if (*end) 213 | *end = '\0'; 214 | #endif 215 | value = lskip(value); 216 | rstrip(value); 217 | 218 | /* Valid name[=:]value pair found, call handler */ 219 | strncpy0(prev_name, name, sizeof(prev_name)); 220 | if (!HANDLER(user, section, name, value) && !error) 221 | error = lineno; 222 | } 223 | else if (!error) { 224 | /* No '=' or ':' found on name[=:]value line */ 225 | #if INI_ALLOW_NO_VALUE 226 | *end = '\0'; 227 | name = rstrip(start); 228 | if (!HANDLER(user, section, name, NULL) && !error) 229 | error = lineno; 230 | #else 231 | error = lineno; 232 | #endif 233 | } 234 | } 235 | 236 | #if INI_STOP_ON_FIRST_ERROR 237 | if (error) 238 | break; 239 | #endif 240 | } 241 | 242 | #if !INI_USE_STACK 243 | ini_free(line); 244 | #endif 245 | 246 | return error; 247 | } 248 | 249 | /* See documentation in header file. */ 250 | int ini_parse_file(FILE* file, ini_handler handler, void* user) 251 | { 252 | return ini_parse_stream((ini_reader)fgets, file, handler, user); 253 | } 254 | 255 | /* See documentation in header file. */ 256 | int ini_parse(const char* filename, ini_handler handler, void* user) 257 | { 258 | FILE* file; 259 | int error; 260 | 261 | file = fopen(filename, "r"); 262 | if (!file) 263 | return -1; 264 | error = ini_parse_file(file, handler, user); 265 | fclose(file); 266 | return error; 267 | } 268 | 269 | /* An ini_reader function to read the next line from a string buffer. This 270 | is the fgets() equivalent used by ini_parse_string(). */ 271 | static char* ini_reader_string(char* str, int num, void* stream) { 272 | ini_parse_string_ctx* ctx = (ini_parse_string_ctx*)stream; 273 | const char* ctx_ptr = ctx->ptr; 274 | size_t ctx_num_left = ctx->num_left; 275 | char* strp = str; 276 | char c; 277 | 278 | if (ctx_num_left == 0 || num < 2) 279 | return NULL; 280 | 281 | while (num > 1 && ctx_num_left != 0) { 282 | c = *ctx_ptr++; 283 | ctx_num_left--; 284 | *strp++ = c; 285 | if (c == '\n') 286 | break; 287 | num--; 288 | } 289 | 290 | *strp = '\0'; 291 | ctx->ptr = ctx_ptr; 292 | ctx->num_left = ctx_num_left; 293 | return str; 294 | } 295 | 296 | /* See documentation in header file. */ 297 | int ini_parse_string(const char* string, ini_handler handler, void* user) { 298 | ini_parse_string_ctx ctx; 299 | 300 | ctx.ptr = string; 301 | ctx.num_left = strlen(string); 302 | return ini_parse_stream((ini_reader)ini_reader_string, &ctx, handler, 303 | user); 304 | } 305 | -------------------------------------------------------------------------------- /mkoasm/ini.h: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | SPDX-License-Identifier: BSD-3-Clause 4 | 5 | Copyright (C) 2009-2020, Ben Hoyt 6 | 7 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 8 | home page for more info: 9 | 10 | https://github.com/benhoyt/inih 11 | 12 | */ 13 | 14 | #ifndef INI_H 15 | #define INI_H 16 | 17 | /* Make this header file easier to include in C++ code */ 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include 23 | 24 | /* Nonzero if ini_handler callback should accept lineno parameter. */ 25 | #ifndef INI_HANDLER_LINENO 26 | #define INI_HANDLER_LINENO 0 27 | #endif 28 | 29 | /* Visibility symbols, required for Windows DLLs */ 30 | #ifndef INI_API 31 | #if defined _WIN32 || defined __CYGWIN__ 32 | # ifdef INI_SHARED_LIB 33 | # ifdef INI_SHARED_LIB_BUILDING 34 | # define INI_API __declspec(dllexport) 35 | # else 36 | # define INI_API __declspec(dllimport) 37 | # endif 38 | # else 39 | # define INI_API 40 | # endif 41 | #else 42 | # if defined(__GNUC__) && __GNUC__ >= 4 43 | # define INI_API __attribute__ ((visibility ("default"))) 44 | # else 45 | # define INI_API 46 | # endif 47 | #endif 48 | #endif 49 | 50 | /* Typedef for prototype of handler function. */ 51 | #if INI_HANDLER_LINENO 52 | typedef int (*ini_handler)(void* user, const char* section, 53 | const char* name, const char* value, 54 | int lineno); 55 | #else 56 | typedef int (*ini_handler)(void* user, const char* section, 57 | const char* name, const char* value); 58 | #endif 59 | 60 | /* Typedef for prototype of fgets-style reader function. */ 61 | typedef char* (*ini_reader)(char* str, int num, void* stream); 62 | 63 | /* Parse given INI-style file. May have [section]s, name=value pairs 64 | (whitespace stripped), and comments starting with ';' (semicolon). Section 65 | is "" if name=value pair parsed before any section heading. name:value 66 | pairs are also supported as a concession to Python's configparser. 67 | 68 | For each name=value pair parsed, call handler function with given user 69 | pointer as well as section, name, and value (data only valid for duration 70 | of handler call). Handler should return nonzero on success, zero on error. 71 | 72 | Returns 0 on success, line number of first error on parse error (doesn't 73 | stop on first error), -1 on file open error, or -2 on memory allocation 74 | error (only when INI_USE_STACK is zero). 75 | */ 76 | INI_API int ini_parse(const char* filename, ini_handler handler, void* user); 77 | 78 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't 79 | close the file when it's finished -- the caller must do that. */ 80 | INI_API int ini_parse_file(FILE* file, ini_handler handler, void* user); 81 | 82 | /* Same as ini_parse(), but takes an ini_reader function pointer instead of 83 | filename. Used for implementing custom or string-based I/O (see also 84 | ini_parse_string). */ 85 | INI_API int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, 86 | void* user); 87 | 88 | /* Same as ini_parse(), but takes a zero-terminated string with the INI data 89 | instead of a file. Useful for parsing INI data from a network socket or 90 | already in memory. */ 91 | INI_API int ini_parse_string(const char* string, ini_handler handler, void* user); 92 | 93 | /* Nonzero to allow multi-line value parsing, in the style of Python's 94 | configparser. If allowed, ini_parse() will call the handler with the same 95 | name for each subsequent line parsed. */ 96 | #ifndef INI_ALLOW_MULTILINE 97 | #define INI_ALLOW_MULTILINE 1 98 | #endif 99 | 100 | /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of 101 | the file. See https://github.com/benhoyt/inih/issues/21 */ 102 | #ifndef INI_ALLOW_BOM 103 | #define INI_ALLOW_BOM 1 104 | #endif 105 | 106 | /* Chars that begin a start-of-line comment. Per Python configparser, allow 107 | both ; and # comments at the start of a line by default. */ 108 | #ifndef INI_START_COMMENT_PREFIXES 109 | #define INI_START_COMMENT_PREFIXES ";#" 110 | #endif 111 | 112 | /* Nonzero to allow inline comments (with valid inline comment characters 113 | specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match 114 | Python 3.2+ configparser behaviour. */ 115 | #ifndef INI_ALLOW_INLINE_COMMENTS 116 | #define INI_ALLOW_INLINE_COMMENTS 1 117 | #endif 118 | #ifndef INI_INLINE_COMMENT_PREFIXES 119 | #define INI_INLINE_COMMENT_PREFIXES ";" 120 | #endif 121 | 122 | /* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */ 123 | #ifndef INI_USE_STACK 124 | #define INI_USE_STACK 1 125 | #endif 126 | 127 | /* Maximum line length for any line in INI file (stack or heap). Note that 128 | this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */ 129 | #ifndef INI_MAX_LINE 130 | #define INI_MAX_LINE 200 131 | #endif 132 | 133 | /* Nonzero to allow heap line buffer to grow via realloc(), zero for a 134 | fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is 135 | zero. */ 136 | #ifndef INI_ALLOW_REALLOC 137 | #define INI_ALLOW_REALLOC 0 138 | #endif 139 | 140 | /* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK 141 | is zero. */ 142 | #ifndef INI_INITIAL_ALLOC 143 | #define INI_INITIAL_ALLOC 200 144 | #endif 145 | 146 | /* Stop parsing on first error (default is to keep parsing). */ 147 | #ifndef INI_STOP_ON_FIRST_ERROR 148 | #define INI_STOP_ON_FIRST_ERROR 0 149 | #endif 150 | 151 | /* Nonzero to call the handler at the start of each new section (with 152 | name and value NULL). Default is to only call the handler on 153 | each name=value pair. */ 154 | #ifndef INI_CALL_HANDLER_ON_NEW_SECTION 155 | #define INI_CALL_HANDLER_ON_NEW_SECTION 0 156 | #endif 157 | 158 | /* Nonzero to allow a name without a value (no '=' or ':' on the line) and 159 | call the handler with value NULL in this case. Default is to treat 160 | no-value lines as an error. */ 161 | #ifndef INI_ALLOW_NO_VALUE 162 | #define INI_ALLOW_NO_VALUE 0 163 | #endif 164 | 165 | /* Nonzero to use custom ini_malloc, ini_free, and ini_realloc memory 166 | allocation functions (INI_USE_STACK must also be 0). These functions must 167 | have the same signatures as malloc/free/realloc and behave in a similar 168 | way. ini_realloc is only needed if INI_ALLOW_REALLOC is set. */ 169 | #ifndef INI_CUSTOM_ALLOCATOR 170 | #define INI_CUSTOM_ALLOCATOR 0 171 | #endif 172 | 173 | 174 | #ifdef __cplusplus 175 | } 176 | #endif 177 | 178 | #endif /* INI_H */ 179 | -------------------------------------------------------------------------------- /mkoasm/lz4/liblz4_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ermaccer/mkoasm/dffef55ec0388bc507ddb5071d47e78ed44f4b6e/mkoasm/lz4/liblz4_static.lib -------------------------------------------------------------------------------- /mkoasm/lz4/lz4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LZ4 - Fast LZ compression algorithm 3 | * Header File 4 | * Copyright (C) 2011-2023, Yann Collet. 5 | 6 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the following disclaimer 16 | in the documentation and/or other materials provided with the 17 | distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | You can contact the author at : 32 | - LZ4 homepage : http://www.lz4.org 33 | - LZ4 source repository : https://github.com/lz4/lz4 34 | */ 35 | #if defined (__cplusplus) 36 | extern "C" { 37 | #endif 38 | 39 | #ifndef LZ4_H_2983827168210 40 | #define LZ4_H_2983827168210 41 | 42 | /* --- Dependency --- */ 43 | #include /* size_t */ 44 | 45 | 46 | /** 47 | Introduction 48 | 49 | LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core, 50 | scalable with multi-cores CPU. It features an extremely fast decoder, with speed in 51 | multiple GB/s per core, typically reaching RAM speed limits on multi-core systems. 52 | 53 | The LZ4 compression library provides in-memory compression and decompression functions. 54 | It gives full buffer control to user. 55 | Compression can be done in: 56 | - a single step (described as Simple Functions) 57 | - a single step, reusing a context (described in Advanced Functions) 58 | - unbounded multiple steps (described as Streaming compression) 59 | 60 | lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md). 61 | Decompressing such a compressed block requires additional metadata. 62 | Exact metadata depends on exact decompression function. 63 | For the typical case of LZ4_decompress_safe(), 64 | metadata includes block's compressed size, and maximum bound of decompressed size. 65 | Each application is free to encode and pass such metadata in whichever way it wants. 66 | 67 | lz4.h only handle blocks, it can not generate Frames. 68 | 69 | Blocks are different from Frames (doc/lz4_Frame_format.md). 70 | Frames bundle both blocks and metadata in a specified manner. 71 | Embedding metadata is required for compressed data to be self-contained and portable. 72 | Frame format is delivered through a companion API, declared in lz4frame.h. 73 | The `lz4` CLI can only manage frames. 74 | */ 75 | 76 | /*^*************************************************************** 77 | * Export parameters 78 | *****************************************************************/ 79 | /* 80 | * LZ4_DLL_EXPORT : 81 | * Enable exporting of functions when building a Windows DLL 82 | * LZ4LIB_VISIBILITY : 83 | * Control library symbols visibility. 84 | */ 85 | #ifndef LZ4LIB_VISIBILITY 86 | # if defined(__GNUC__) && (__GNUC__ >= 4) 87 | # define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default"))) 88 | # else 89 | # define LZ4LIB_VISIBILITY 90 | # endif 91 | #endif 92 | #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) 93 | # define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY 94 | #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1) 95 | # define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ 96 | #else 97 | # define LZ4LIB_API LZ4LIB_VISIBILITY 98 | #endif 99 | 100 | /*! LZ4_FREESTANDING : 101 | * When this macro is set to 1, it enables "freestanding mode" that is 102 | * suitable for typical freestanding environment which doesn't support 103 | * standard C library. 104 | * 105 | * - LZ4_FREESTANDING is a compile-time switch. 106 | * - It requires the following macros to be defined: 107 | * LZ4_memcpy, LZ4_memmove, LZ4_memset. 108 | * - It only enables LZ4/HC functions which don't use heap. 109 | * All LZ4F_* functions are not supported. 110 | * - See tests/freestanding.c to check its basic setup. 111 | */ 112 | #if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1) 113 | # define LZ4_HEAPMODE 0 114 | # define LZ4HC_HEAPMODE 0 115 | # define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1 116 | # if !defined(LZ4_memcpy) 117 | # error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'." 118 | # endif 119 | # if !defined(LZ4_memset) 120 | # error "LZ4_FREESTANDING requires macro 'LZ4_memset'." 121 | # endif 122 | # if !defined(LZ4_memmove) 123 | # error "LZ4_FREESTANDING requires macro 'LZ4_memmove'." 124 | # endif 125 | #elif ! defined(LZ4_FREESTANDING) 126 | # define LZ4_FREESTANDING 0 127 | #endif 128 | 129 | 130 | /*------ Version ------*/ 131 | #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ 132 | #define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */ 133 | #define LZ4_VERSION_RELEASE 5 /* for tweaks, bug-fixes, or development */ 134 | 135 | #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) 136 | 137 | #define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE 138 | #define LZ4_QUOTE(str) #str 139 | #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str) 140 | #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) /* requires v1.7.3+ */ 141 | 142 | LZ4LIB_API int LZ4_versionNumber (void); /**< library version number; useful to check dll version; requires v1.3.0+ */ 143 | LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; useful to check dll version; requires v1.7.5+ */ 144 | 145 | 146 | /*-************************************ 147 | * Tuning memory usage 148 | **************************************/ 149 | /*! 150 | * LZ4_MEMORY_USAGE : 151 | * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB) 152 | * Increasing memory usage improves compression ratio, generally at the cost of speed. 153 | * Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality. 154 | * Default value is 14, for 16KB, which nicely fits into most L1 caches. 155 | */ 156 | #ifndef LZ4_MEMORY_USAGE 157 | # define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT 158 | #endif 159 | 160 | #define LZ4_MEMORY_USAGE_MIN 10 161 | #define LZ4_MEMORY_USAGE_DEFAULT 14 162 | #define LZ4_MEMORY_USAGE_MAX 20 163 | 164 | #if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN) 165 | # error "LZ4_MEMORY_USAGE is too small !" 166 | #endif 167 | 168 | #if (LZ4_MEMORY_USAGE > LZ4_MEMORY_USAGE_MAX) 169 | # error "LZ4_MEMORY_USAGE is too large !" 170 | #endif 171 | 172 | /*-************************************ 173 | * Simple Functions 174 | **************************************/ 175 | /*! LZ4_compress_default() : 176 | * Compresses 'srcSize' bytes from buffer 'src' 177 | * into already allocated 'dst' buffer of size 'dstCapacity'. 178 | * Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize). 179 | * It also runs faster, so it's a recommended setting. 180 | * If the function cannot compress 'src' into a more limited 'dst' budget, 181 | * compression stops *immediately*, and the function result is zero. 182 | * In which case, 'dst' content is undefined (invalid). 183 | * srcSize : max supported value is LZ4_MAX_INPUT_SIZE. 184 | * dstCapacity : size of buffer 'dst' (which must be already allocated) 185 | * @return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity) 186 | * or 0 if compression fails 187 | * Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer). 188 | */ 189 | LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity); 190 | 191 | /*! LZ4_decompress_safe() : 192 | * @compressedSize : is the exact complete size of the compressed block. 193 | * @dstCapacity : is the size of destination buffer (which must be already allocated), 194 | * presumed an upper bound of decompressed size. 195 | * @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity) 196 | * If destination buffer is not large enough, decoding will stop and output an error code (negative value). 197 | * If the source stream is detected malformed, the function will stop decoding and return a negative result. 198 | * Note 1 : This function is protected against malicious data packets : 199 | * it will never writes outside 'dst' buffer, nor read outside 'source' buffer, 200 | * even if the compressed block is maliciously modified to order the decoder to do these actions. 201 | * In such case, the decoder stops immediately, and considers the compressed block malformed. 202 | * Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them. 203 | * The implementation is free to send / store / derive this information in whichever way is most beneficial. 204 | * If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead. 205 | */ 206 | LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity); 207 | 208 | 209 | /*-************************************ 210 | * Advanced Functions 211 | **************************************/ 212 | #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */ 213 | #define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) 214 | 215 | /*! LZ4_compressBound() : 216 | Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible) 217 | This function is primarily useful for memory allocation purposes (destination buffer size). 218 | Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example). 219 | Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize) 220 | inputSize : max supported value is LZ4_MAX_INPUT_SIZE 221 | return : maximum output size in a "worst case" scenario 222 | or 0, if input size is incorrect (too large or negative) 223 | */ 224 | LZ4LIB_API int LZ4_compressBound(int inputSize); 225 | 226 | /*! LZ4_compress_fast() : 227 | Same as LZ4_compress_default(), but allows selection of "acceleration" factor. 228 | The larger the acceleration value, the faster the algorithm, but also the lesser the compression. 229 | It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. 230 | An acceleration value of "1" is the same as regular LZ4_compress_default() 231 | Values <= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c). 232 | Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c). 233 | */ 234 | LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); 235 | 236 | 237 | /*! LZ4_compress_fast_extState() : 238 | * Same as LZ4_compress_fast(), using an externally allocated memory space for its state. 239 | * Use LZ4_sizeofState() to know how much memory must be allocated, 240 | * and allocate it on 8-bytes boundaries (using `malloc()` typically). 241 | * Then, provide this buffer as `void* state` to compression function. 242 | */ 243 | LZ4LIB_API int LZ4_sizeofState(void); 244 | LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); 245 | 246 | /*! LZ4_compress_fast_extState_destSize() : 247 | * Same as LZ4_compress_fast(), but compresses as much data as possible from 'src' buffer into 248 | * already allocated buffer 'dst', of size >= 'dstCapacity'. This function either compresses the 249 | * entire 'src' content into 'dst' if it's large enough, or fills 'dst' buffer completely with as 250 | * much data as possible from 'src'. 251 | */ 252 | LZ4LIB_API int LZ4_compress_fast_extState_destSize(void* state, const char* src, char* dst, int *srcSizePtr, int dstCapacity, int acceleration); 253 | 254 | /*! LZ4_compress_destSize() : 255 | * Reverse the logic : compresses as much data as possible from 'src' buffer 256 | * into already allocated buffer 'dst', of size >= 'targetDestSize'. 257 | * This function either compresses the entire 'src' content into 'dst' if it's large enough, 258 | * or fill 'dst' buffer completely with as much data as possible from 'src'. 259 | * note: acceleration parameter is fixed to "default". 260 | * 261 | * *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'. 262 | * New value is necessarily <= input value. 263 | * @return : Nb bytes written into 'dst' (necessarily <= targetDestSize) 264 | * or 0 if compression fails. 265 | * 266 | * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+): 267 | * the produced compressed content could, in specific circumstances, 268 | * require to be decompressed into a destination buffer larger 269 | * by at least 1 byte than the content to decompress. 270 | * If an application uses `LZ4_compress_destSize()`, 271 | * it's highly recommended to update liblz4 to v1.9.2 or better. 272 | * If this can't be done or ensured, 273 | * the receiving decompression function should provide 274 | * a dstCapacity which is > decompressedSize, by at least 1 byte. 275 | * See https://github.com/lz4/lz4/issues/859 for details 276 | */ 277 | LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize); 278 | 279 | 280 | /*! LZ4_decompress_safe_partial() : 281 | * Decompress an LZ4 compressed block, of size 'srcSize' at position 'src', 282 | * into destination buffer 'dst' of size 'dstCapacity'. 283 | * Up to 'targetOutputSize' bytes will be decoded. 284 | * The function stops decoding on reaching this objective. 285 | * This can be useful to boost performance 286 | * whenever only the beginning of a block is required. 287 | * 288 | * @return : the number of bytes decoded in `dst` (necessarily <= targetOutputSize) 289 | * If source stream is detected malformed, function returns a negative result. 290 | * 291 | * Note 1 : @return can be < targetOutputSize, if compressed block contains less data. 292 | * 293 | * Note 2 : targetOutputSize must be <= dstCapacity 294 | * 295 | * Note 3 : this function effectively stops decoding on reaching targetOutputSize, 296 | * so dstCapacity is kind of redundant. 297 | * This is because in older versions of this function, 298 | * decoding operation would still write complete sequences. 299 | * Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize, 300 | * it could write more bytes, though only up to dstCapacity. 301 | * Some "margin" used to be required for this operation to work properly. 302 | * Thankfully, this is no longer necessary. 303 | * The function nonetheless keeps the same signature, in an effort to preserve API compatibility. 304 | * 305 | * Note 4 : If srcSize is the exact size of the block, 306 | * then targetOutputSize can be any value, 307 | * including larger than the block's decompressed size. 308 | * The function will, at most, generate block's decompressed size. 309 | * 310 | * Note 5 : If srcSize is _larger_ than block's compressed size, 311 | * then targetOutputSize **MUST** be <= block's decompressed size. 312 | * Otherwise, *silent corruption will occur*. 313 | */ 314 | LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity); 315 | 316 | 317 | /*-********************************************* 318 | * Streaming Compression Functions 319 | ***********************************************/ 320 | typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */ 321 | 322 | /*! 323 | Note about RC_INVOKED 324 | 325 | - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio). 326 | https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros 327 | 328 | - Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars) 329 | and reports warning "RC4011: identifier truncated". 330 | 331 | - To eliminate the warning, we surround long preprocessor symbol with 332 | "#if !defined(RC_INVOKED) ... #endif" block that means 333 | "skip this block when rc.exe is trying to read it". 334 | */ 335 | #if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */ 336 | #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) 337 | LZ4LIB_API LZ4_stream_t* LZ4_createStream(void); 338 | LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr); 339 | #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */ 340 | #endif 341 | 342 | /*! LZ4_resetStream_fast() : v1.9.0+ 343 | * Use this to prepare an LZ4_stream_t for a new chain of dependent blocks 344 | * (e.g., LZ4_compress_fast_continue()). 345 | * 346 | * An LZ4_stream_t must be initialized once before usage. 347 | * This is automatically done when created by LZ4_createStream(). 348 | * However, should the LZ4_stream_t be simply declared on stack (for example), 349 | * it's necessary to initialize it first, using LZ4_initStream(). 350 | * 351 | * After init, start any new stream with LZ4_resetStream_fast(). 352 | * A same LZ4_stream_t can be re-used multiple times consecutively 353 | * and compress multiple streams, 354 | * provided that it starts each new stream with LZ4_resetStream_fast(). 355 | * 356 | * LZ4_resetStream_fast() is much faster than LZ4_initStream(), 357 | * but is not compatible with memory regions containing garbage data. 358 | * 359 | * Note: it's only useful to call LZ4_resetStream_fast() 360 | * in the context of streaming compression. 361 | * The *extState* functions perform their own resets. 362 | * Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive. 363 | */ 364 | LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr); 365 | 366 | /*! LZ4_loadDict() : 367 | * Use this function to reference a static dictionary into LZ4_stream_t. 368 | * The dictionary must remain available during compression. 369 | * LZ4_loadDict() triggers a reset, so any previous data will be forgotten. 370 | * The same dictionary will have to be loaded on decompression side for successful decoding. 371 | * Dictionary are useful for better compression of small data (KB range). 372 | * While LZ4 accept any input as dictionary, 373 | * results are generally better when using Zstandard's Dictionary Builder. 374 | * Loading a size of 0 is allowed, and is the same as reset. 375 | * @return : loaded dictionary size, in bytes (necessarily <= 64 KB) 376 | */ 377 | LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); 378 | 379 | /*! LZ4_compress_fast_continue() : 380 | * Compress 'src' content using data from previously compressed blocks, for better compression ratio. 381 | * 'dst' buffer must be already allocated. 382 | * If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. 383 | * 384 | * @return : size of compressed block 385 | * or 0 if there is an error (typically, cannot fit into 'dst'). 386 | * 387 | * Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block. 388 | * Each block has precise boundaries. 389 | * Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata. 390 | * It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together. 391 | * 392 | * Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory ! 393 | * 394 | * Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB. 395 | * Make sure that buffers are separated, by at least one byte. 396 | * This construction ensures that each block only depends on previous block. 397 | * 398 | * Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB. 399 | * 400 | * Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed. 401 | */ 402 | LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); 403 | 404 | /*! LZ4_saveDict() : 405 | * If last 64KB data cannot be guaranteed to remain available at its current memory location, 406 | * save it into a safer place (char* safeBuffer). 407 | * This is schematically equivalent to a memcpy() followed by LZ4_loadDict(), 408 | * but is much faster, because LZ4_saveDict() doesn't need to rebuild tables. 409 | * @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error. 410 | */ 411 | LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize); 412 | 413 | 414 | /*-********************************************** 415 | * Streaming Decompression Functions 416 | * Bufferless synchronous API 417 | ************************************************/ 418 | typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */ 419 | 420 | /*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() : 421 | * creation / destruction of streaming decompression tracking context. 422 | * A tracking context can be re-used multiple times. 423 | */ 424 | #if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */ 425 | #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) 426 | LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void); 427 | LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); 428 | #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */ 429 | #endif 430 | 431 | /*! LZ4_setStreamDecode() : 432 | * An LZ4_streamDecode_t context can be allocated once and re-used multiple times. 433 | * Use this function to start decompression of a new stream of blocks. 434 | * A dictionary can optionally be set. Use NULL or size 0 for a reset order. 435 | * Dictionary is presumed stable : it must remain accessible and unmodified during next decompression. 436 | * @return : 1 if OK, 0 if error 437 | */ 438 | LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); 439 | 440 | /*! LZ4_decoderRingBufferSize() : v1.8.2+ 441 | * Note : in a ring buffer scenario (optional), 442 | * blocks are presumed decompressed next to each other 443 | * up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize), 444 | * at which stage it resumes from beginning of ring buffer. 445 | * When setting such a ring buffer for streaming decompression, 446 | * provides the minimum size of this ring buffer 447 | * to be compatible with any source respecting maxBlockSize condition. 448 | * @return : minimum ring buffer size, 449 | * or 0 if there is an error (invalid maxBlockSize). 450 | */ 451 | LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize); 452 | #define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */ 453 | 454 | /*! LZ4_decompress_safe_continue() : 455 | * This decoding function allows decompression of consecutive blocks in "streaming" mode. 456 | * The difference with the usual independent blocks is that 457 | * new blocks are allowed to find references into former blocks. 458 | * A block is an unsplittable entity, and must be presented entirely to the decompression function. 459 | * LZ4_decompress_safe_continue() only accepts one block at a time. 460 | * It's modeled after `LZ4_decompress_safe()` and behaves similarly. 461 | * 462 | * @LZ4_streamDecode : decompression state, tracking the position in memory of past data 463 | * @compressedSize : exact complete size of one compressed block. 464 | * @dstCapacity : size of destination buffer (which must be already allocated), 465 | * must be an upper bound of decompressed size. 466 | * @return : number of bytes decompressed into destination buffer (necessarily <= dstCapacity) 467 | * If destination buffer is not large enough, decoding will stop and output an error code (negative value). 468 | * If the source stream is detected malformed, the function will stop decoding and return a negative result. 469 | * 470 | * The last 64KB of previously decoded data *must* remain available and unmodified 471 | * at the memory position where they were previously decoded. 472 | * If less than 64KB of data has been decoded, all the data must be present. 473 | * 474 | * Special : if decompression side sets a ring buffer, it must respect one of the following conditions : 475 | * - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize). 476 | * maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes. 477 | * In which case, encoding and decoding buffers do not need to be synchronized. 478 | * Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize. 479 | * - Synchronized mode : 480 | * Decompression buffer size is _exactly_ the same as compression buffer size, 481 | * and follows exactly same update rule (block boundaries at same positions), 482 | * and decoding function is provided with exact decompressed size of each block (exception for last block of the stream), 483 | * _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB). 484 | * - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes. 485 | * In which case, encoding and decoding buffers do not need to be synchronized, 486 | * and encoding ring buffer can have any size, including small ones ( < 64 KB). 487 | * 488 | * Whenever these conditions are not possible, 489 | * save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression, 490 | * then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block. 491 | */ 492 | LZ4LIB_API int 493 | LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, 494 | const char* src, char* dst, 495 | int srcSize, int dstCapacity); 496 | 497 | 498 | /*! LZ4_decompress_safe_usingDict() : 499 | * Works the same as 500 | * a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue() 501 | * However, it's stateless: it doesn't need any LZ4_streamDecode_t state. 502 | * Dictionary is presumed stable : it must remain accessible and unmodified during decompression. 503 | * Performance tip : Decompression speed can be substantially increased 504 | * when dst == dictStart + dictSize. 505 | */ 506 | LZ4LIB_API int 507 | LZ4_decompress_safe_usingDict(const char* src, char* dst, 508 | int srcSize, int dstCapacity, 509 | const char* dictStart, int dictSize); 510 | 511 | /*! LZ4_decompress_safe_partial_usingDict() : 512 | * Behaves the same as LZ4_decompress_safe_partial() 513 | * with the added ability to specify a memory segment for past data. 514 | * Performance tip : Decompression speed can be substantially increased 515 | * when dst == dictStart + dictSize. 516 | */ 517 | LZ4LIB_API int 518 | LZ4_decompress_safe_partial_usingDict(const char* src, char* dst, 519 | int compressedSize, 520 | int targetOutputSize, int maxOutputSize, 521 | const char* dictStart, int dictSize); 522 | 523 | #endif /* LZ4_H_2983827168210 */ 524 | 525 | 526 | /*^************************************* 527 | * !!!!!! STATIC LINKING ONLY !!!!!! 528 | ***************************************/ 529 | 530 | /*-**************************************************************************** 531 | * Experimental section 532 | * 533 | * Symbols declared in this section must be considered unstable. Their 534 | * signatures or semantics may change, or they may be removed altogether in the 535 | * future. They are therefore only safe to depend on when the caller is 536 | * statically linked against the library. 537 | * 538 | * To protect against unsafe usage, not only are the declarations guarded, 539 | * the definitions are hidden by default 540 | * when building LZ4 as a shared/dynamic library. 541 | * 542 | * In order to access these declarations, 543 | * define LZ4_STATIC_LINKING_ONLY in your application 544 | * before including LZ4's headers. 545 | * 546 | * In order to make their implementations accessible dynamically, you must 547 | * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library. 548 | ******************************************************************************/ 549 | 550 | #ifdef LZ4_STATIC_LINKING_ONLY 551 | 552 | #ifndef LZ4_STATIC_3504398509 553 | #define LZ4_STATIC_3504398509 554 | 555 | #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS 556 | # define LZ4LIB_STATIC_API LZ4LIB_API 557 | #else 558 | # define LZ4LIB_STATIC_API 559 | #endif 560 | 561 | 562 | /*! LZ4_compress_fast_extState_fastReset() : 563 | * A variant of LZ4_compress_fast_extState(). 564 | * 565 | * Using this variant avoids an expensive initialization step. 566 | * It is only safe to call if the state buffer is known to be correctly initialized already 567 | * (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized"). 568 | * From a high level, the difference is that 569 | * this function initializes the provided state with a call to something like LZ4_resetStream_fast() 570 | * while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream(). 571 | */ 572 | LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); 573 | 574 | /*! LZ4_attach_dictionary() : 575 | * This is an experimental API that allows 576 | * efficient use of a static dictionary many times. 577 | * 578 | * Rather than re-loading the dictionary buffer into a working context before 579 | * each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a 580 | * working LZ4_stream_t, this function introduces a no-copy setup mechanism, 581 | * in which the working stream references the dictionary stream in-place. 582 | * 583 | * Several assumptions are made about the state of the dictionary stream. 584 | * Currently, only streams which have been prepared by LZ4_loadDict() should 585 | * be expected to work. 586 | * 587 | * Alternatively, the provided dictionaryStream may be NULL, 588 | * in which case any existing dictionary stream is unset. 589 | * 590 | * If a dictionary is provided, it replaces any pre-existing stream history. 591 | * The dictionary contents are the only history that can be referenced and 592 | * logically immediately precede the data compressed in the first subsequent 593 | * compression call. 594 | * 595 | * The dictionary will only remain attached to the working stream through the 596 | * first compression call, at the end of which it is cleared. The dictionary 597 | * stream (and source buffer) must remain in-place / accessible / unchanged 598 | * through the completion of the first compression call on the stream. 599 | */ 600 | LZ4LIB_STATIC_API void 601 | LZ4_attach_dictionary(LZ4_stream_t* workingStream, 602 | const LZ4_stream_t* dictionaryStream); 603 | 604 | 605 | /*! In-place compression and decompression 606 | * 607 | * It's possible to have input and output sharing the same buffer, 608 | * for highly constrained memory environments. 609 | * In both cases, it requires input to lay at the end of the buffer, 610 | * and decompression to start at beginning of the buffer. 611 | * Buffer size must feature some margin, hence be larger than final size. 612 | * 613 | * |<------------------------buffer--------------------------------->| 614 | * |<-----------compressed data--------->| 615 | * |<-----------decompressed size------------------>| 616 | * |<----margin---->| 617 | * 618 | * This technique is more useful for decompression, 619 | * since decompressed size is typically larger, 620 | * and margin is short. 621 | * 622 | * In-place decompression will work inside any buffer 623 | * which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize). 624 | * This presumes that decompressedSize > compressedSize. 625 | * Otherwise, it means compression actually expanded data, 626 | * and it would be more efficient to store such data with a flag indicating it's not compressed. 627 | * This can happen when data is not compressible (already compressed, or encrypted). 628 | * 629 | * For in-place compression, margin is larger, as it must be able to cope with both 630 | * history preservation, requiring input data to remain unmodified up to LZ4_DISTANCE_MAX, 631 | * and data expansion, which can happen when input is not compressible. 632 | * As a consequence, buffer size requirements are much higher, 633 | * and memory savings offered by in-place compression are more limited. 634 | * 635 | * There are ways to limit this cost for compression : 636 | * - Reduce history size, by modifying LZ4_DISTANCE_MAX. 637 | * Note that it is a compile-time constant, so all compressions will apply this limit. 638 | * Lower values will reduce compression ratio, except when input_size < LZ4_DISTANCE_MAX, 639 | * so it's a reasonable trick when inputs are known to be small. 640 | * - Require the compressor to deliver a "maximum compressed size". 641 | * This is the `dstCapacity` parameter in `LZ4_compress*()`. 642 | * When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can fail, 643 | * in which case, the return code will be 0 (zero). 644 | * The caller must be ready for these cases to happen, 645 | * and typically design a backup scheme to send data uncompressed. 646 | * The combination of both techniques can significantly reduce 647 | * the amount of margin required for in-place compression. 648 | * 649 | * In-place compression can work in any buffer 650 | * which size is >= (maxCompressedSize) 651 | * with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed compression success. 652 | * LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both maxCompressedSize and LZ4_DISTANCE_MAX, 653 | * so it's possible to reduce memory requirements by playing with them. 654 | */ 655 | 656 | #define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32) 657 | #define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize)) /**< note: presumes that compressedSize < decompressedSize. note2: margin is overestimated a bit, since it could use compressedSize instead */ 658 | 659 | #ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */ 660 | # define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ 661 | #endif 662 | 663 | #define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */ 664 | #define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */ 665 | 666 | #endif /* LZ4_STATIC_3504398509 */ 667 | #endif /* LZ4_STATIC_LINKING_ONLY */ 668 | 669 | 670 | 671 | #ifndef LZ4_H_98237428734687 672 | #define LZ4_H_98237428734687 673 | 674 | /*-************************************************************ 675 | * Private Definitions 676 | ************************************************************** 677 | * Do not use these definitions directly. 678 | * They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`. 679 | * Accessing members will expose user code to API and/or ABI break in future versions of the library. 680 | **************************************************************/ 681 | #define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2) 682 | #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE) 683 | #define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */ 684 | 685 | #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) 686 | # include 687 | typedef int8_t LZ4_i8; 688 | typedef uint8_t LZ4_byte; 689 | typedef uint16_t LZ4_u16; 690 | typedef uint32_t LZ4_u32; 691 | #else 692 | typedef signed char LZ4_i8; 693 | typedef unsigned char LZ4_byte; 694 | typedef unsigned short LZ4_u16; 695 | typedef unsigned int LZ4_u32; 696 | #endif 697 | 698 | /*! LZ4_stream_t : 699 | * Never ever use below internal definitions directly ! 700 | * These definitions are not API/ABI safe, and may change in future versions. 701 | * If you need static allocation, declare or allocate an LZ4_stream_t object. 702 | **/ 703 | 704 | typedef struct LZ4_stream_t_internal LZ4_stream_t_internal; 705 | struct LZ4_stream_t_internal { 706 | LZ4_u32 hashTable[LZ4_HASH_SIZE_U32]; 707 | const LZ4_byte* dictionary; 708 | const LZ4_stream_t_internal* dictCtx; 709 | LZ4_u32 currentOffset; 710 | LZ4_u32 tableType; 711 | LZ4_u32 dictSize; 712 | /* Implicit padding to ensure structure is aligned */ 713 | }; 714 | 715 | #define LZ4_STREAM_MINSIZE ((1UL << (LZ4_MEMORY_USAGE)) + 32) /* static size, for inter-version compatibility */ 716 | union LZ4_stream_u { 717 | char minStateSize[LZ4_STREAM_MINSIZE]; 718 | LZ4_stream_t_internal internal_donotuse; 719 | }; /* previously typedef'd to LZ4_stream_t */ 720 | 721 | 722 | /*! LZ4_initStream() : v1.9.0+ 723 | * An LZ4_stream_t structure must be initialized at least once. 724 | * This is automatically done when invoking LZ4_createStream(), 725 | * but it's not when the structure is simply declared on stack (for example). 726 | * 727 | * Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t. 728 | * It can also initialize any arbitrary buffer of sufficient size, 729 | * and will @return a pointer of proper type upon initialization. 730 | * 731 | * Note : initialization fails if size and alignment conditions are not respected. 732 | * In which case, the function will @return NULL. 733 | * Note2: An LZ4_stream_t structure guarantees correct alignment and size. 734 | * Note3: Before v1.9.0, use LZ4_resetStream() instead 735 | **/ 736 | LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size); 737 | 738 | 739 | /*! LZ4_streamDecode_t : 740 | * Never ever use below internal definitions directly ! 741 | * These definitions are not API/ABI safe, and may change in future versions. 742 | * If you need static allocation, declare or allocate an LZ4_streamDecode_t object. 743 | **/ 744 | typedef struct { 745 | const LZ4_byte* externalDict; 746 | const LZ4_byte* prefixEnd; 747 | size_t extDictSize; 748 | size_t prefixSize; 749 | } LZ4_streamDecode_t_internal; 750 | 751 | #define LZ4_STREAMDECODE_MINSIZE 32 752 | union LZ4_streamDecode_u { 753 | char minStateSize[LZ4_STREAMDECODE_MINSIZE]; 754 | LZ4_streamDecode_t_internal internal_donotuse; 755 | } ; /* previously typedef'd to LZ4_streamDecode_t */ 756 | 757 | 758 | 759 | /*-************************************ 760 | * Obsolete Functions 761 | **************************************/ 762 | 763 | /*! Deprecation warnings 764 | * 765 | * Deprecated functions make the compiler generate a warning when invoked. 766 | * This is meant to invite users to update their source code. 767 | * Should deprecation warnings be a problem, it is generally possible to disable them, 768 | * typically with -Wno-deprecated-declarations for gcc 769 | * or _CRT_SECURE_NO_WARNINGS in Visual. 770 | * 771 | * Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS 772 | * before including the header file. 773 | */ 774 | #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS 775 | # define LZ4_DEPRECATED(message) /* disable deprecation warnings */ 776 | #else 777 | # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */ 778 | # define LZ4_DEPRECATED(message) [[deprecated(message)]] 779 | # elif defined(_MSC_VER) 780 | # define LZ4_DEPRECATED(message) __declspec(deprecated(message)) 781 | # elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45)) 782 | # define LZ4_DEPRECATED(message) __attribute__((deprecated(message))) 783 | # elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31) 784 | # define LZ4_DEPRECATED(message) __attribute__((deprecated)) 785 | # else 786 | # pragma message("WARNING: LZ4_DEPRECATED needs custom implementation for this compiler") 787 | # define LZ4_DEPRECATED(message) /* disabled */ 788 | # endif 789 | #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */ 790 | 791 | /*! Obsolete compression functions (since v1.7.3) */ 792 | LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* src, char* dest, int srcSize); 793 | LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* src, char* dest, int srcSize, int maxOutputSize); 794 | LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); 795 | LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); 796 | LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); 797 | LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); 798 | 799 | /*! Obsolete decompression functions (since v1.8.0) */ 800 | LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize); 801 | LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); 802 | 803 | /* Obsolete streaming functions (since v1.7.0) 804 | * degraded functionality; do not use! 805 | * 806 | * In order to perform streaming compression, these functions depended on data 807 | * that is no longer tracked in the state. They have been preserved as well as 808 | * possible: using them will still produce a correct output. However, they don't 809 | * actually retain any history between compression calls. The compression ratio 810 | * achieved will therefore be no better than compressing each chunk 811 | * independently. 812 | */ 813 | LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer); 814 | LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void); 815 | LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer); 816 | LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state); 817 | 818 | /*! Obsolete streaming decoding functions (since v1.7.0) */ 819 | LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize); 820 | LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize); 821 | 822 | /*! Obsolete LZ4_decompress_fast variants (since v1.9.0) : 823 | * These functions used to be faster than LZ4_decompress_safe(), 824 | * but this is no longer the case. They are now slower. 825 | * This is because LZ4_decompress_fast() doesn't know the input size, 826 | * and therefore must progress more cautiously into the input buffer to not read beyond the end of block. 827 | * On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability. 828 | * As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated. 829 | * 830 | * The last remaining LZ4_decompress_fast() specificity is that 831 | * it can decompress a block without knowing its compressed size. 832 | * Such functionality can be achieved in a more secure manner 833 | * by employing LZ4_decompress_safe_partial(). 834 | * 835 | * Parameters: 836 | * originalSize : is the uncompressed size to regenerate. 837 | * `dst` must be already allocated, its size must be >= 'originalSize' bytes. 838 | * @return : number of bytes read from source buffer (== compressed size). 839 | * The function expects to finish at block's end exactly. 840 | * If the source stream is detected malformed, the function stops decoding and returns a negative result. 841 | * note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer. 842 | * However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds. 843 | * Also, since match offsets are not validated, match reads from 'src' may underflow too. 844 | * These issues never happen if input (compressed) data is correct. 845 | * But they may happen if input data is invalid (error or intentional tampering). 846 | * As a consequence, use these functions in trusted environments with trusted data **only**. 847 | */ 848 | LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial() instead") 849 | LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize); 850 | LZ4_DEPRECATED("This function is deprecated and unsafe. Consider migrating towards LZ4_decompress_safe_continue() instead. " 851 | "Note that the contract will change (requires block's compressed size, instead of decompressed size)") 852 | LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize); 853 | LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial_usingDict() instead") 854 | LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize); 855 | 856 | /*! LZ4_resetStream() : 857 | * An LZ4_stream_t structure must be initialized at least once. 858 | * This is done with LZ4_initStream(), or LZ4_resetStream(). 859 | * Consider switching to LZ4_initStream(), 860 | * invoking LZ4_resetStream() will trigger deprecation warnings in the future. 861 | */ 862 | LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr); 863 | 864 | 865 | #endif /* LZ4_H_98237428734687 */ 866 | 867 | 868 | #if defined (__cplusplus) 869 | } 870 | #endif 871 | -------------------------------------------------------------------------------- /mkoasm/mkoasm.cpp: -------------------------------------------------------------------------------- 1 | // mkoasm.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "code/MKScript.h" 11 | #include "MKOReader.h" 12 | #include "compiler/MKOCompiler.h" 13 | 14 | 15 | int main(int argc, char* argv[]) 16 | { 17 | bool _d_switch = false; 18 | bool _b_switch = false; 19 | bool _v_switch = false; 20 | bool _e_switch = false; 21 | bool _g_switch = false; 22 | bool _c_switch = false; 23 | bool _p_switch = false; 24 | std::string m_param; 25 | std::string a_param; 26 | 27 | if (argc == 1) { 28 | std::cout << "Usage: mkoasm \n" 29 | << " -b Build hash database.\n" 30 | << " -d Adds offset and size to every decompiled instruction.\n" 31 | << " -v Only prints MKO information.\n" 32 | << " -g Gamecube/Wii file.\n" 33 | << " -e Extracts data only.\n" 34 | << " -c Compile specified file.\n" 35 | << " -p Pack variable.\n" 36 | << " -a Argument for variable packer.\n" 37 | << " -m Set mode: mku, mkd, mka, mkda, mkvsdc, mk9, mk9_vita, inj\n" 38 | #ifdef _M_X64 39 | << " X64 modes: mkx (mk10), i2 (dcf2), mk11, mk12\n" 40 | #endif // _M_X64 41 | ; 42 | 43 | return 1; 44 | } 45 | 46 | // params 47 | for (int i = 1; i < argc - 1; i++) 48 | { 49 | if (argv[i][0] != '-' || strlen(argv[i]) != 2) { 50 | return 1; 51 | } 52 | switch (argv[i][1]) 53 | { 54 | case 'b': _b_switch = true; 55 | break; 56 | case 'd': _d_switch = true; 57 | break; 58 | case 'v': _v_switch = true; 59 | break; 60 | case 'e': _e_switch = true; 61 | break; 62 | case 'g': _g_switch = true; 63 | break; 64 | case 'c': _c_switch = true; 65 | break; 66 | case 'p': _p_switch = true; 67 | break; 68 | case 'm': 69 | i++; 70 | m_param = argv[i]; 71 | break; 72 | case 'a': 73 | i++; 74 | a_param = argv[i]; 75 | break; 76 | default: 77 | std::cout << "ERROR: Param does not exist: " << argv[i] << std::endl; 78 | return 0; 79 | break; 80 | } 81 | } 82 | 83 | if (_b_switch) 84 | { 85 | MKODict::txt2hash(); 86 | return 0; 87 | } 88 | 89 | EGameMode game = Game_Deception; 90 | 91 | if (m_param == "mkd") game = Game_Deception; 92 | if (m_param == "mku") game = Game_Unchained; 93 | if (m_param == "mka") game = Game_Armageddon; 94 | if (m_param == "mkda") game = Game_DeadlyAlliance; 95 | if (m_param == "mkvsdc") game = Game_MKVSDC; 96 | if (m_param == "mk9") game = Game_MK9; 97 | if (m_param == "mk9_vita") game = Game_MK9_Vita; 98 | if (m_param == "inj") game = Game_Injustice; 99 | if (m_param == "mkx" || m_param == "mk10") game = Game_MK10; 100 | if (m_param == "dcf2" || m_param == "i2") game = Game_Injustice2; 101 | if (m_param == "mk11") game = Game_MK11; 102 | if (m_param == "mk12") game = Game_MK12; 103 | 104 | if (game >= Game_MK10 && !MKOReader::Is64BitSupported()) 105 | { 106 | std::cout << "ERROR: MK10+ is only supported in 64bit version of mkoasm!" << std::endl; 107 | return 0; 108 | } 109 | 110 | 111 | const char* path = nullptr; 112 | if (argc > 2) 113 | path = argv[argc - 1]; 114 | else if (argc == 2) 115 | path = argv[1]; 116 | 117 | if (!path) 118 | return 0; 119 | 120 | 121 | MKODict::InitDict(game); 122 | if (game > Game_MKVSDC) 123 | MKODict::InitHashTable(); 124 | 125 | 126 | if (_p_switch) 127 | { 128 | MKOReader::Pack(path, a_param, game); 129 | return 0; 130 | } 131 | 132 | if (_c_switch) 133 | { 134 | MKOCompiler::CompileFile(path, game); 135 | return 0; 136 | } 137 | 138 | MKOReader mko(path, _g_switch, game); 139 | 140 | if (mko && !mko.m_bBuildMode) 141 | { 142 | mko.m_bDebugMKO = _d_switch; 143 | mko.m_bExtractOnly = _e_switch; 144 | if (!_v_switch) 145 | mko.ExtractData(); 146 | else 147 | mko.PrintInfo(); 148 | } 149 | 150 | 151 | return 0; 152 | } -------------------------------------------------------------------------------- /mkoasm/mkoasm.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {7a724dc0-5655-4ba3-80d4-40d23f34eeff} 25 | mkoasm 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | MultiByte 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | MultiByte 41 | false 42 | 43 | 44 | Application 45 | true 46 | v143 47 | MultiByte 48 | 49 | 50 | Application 51 | false 52 | v143 53 | true 54 | MultiByte 55 | false 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | true 83 | 84 | 85 | false 86 | 87 | 88 | 89 | Level3 90 | true 91 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | stdcpp17 94 | 95 | 96 | Console 97 | true 98 | 99 | 100 | 101 | 102 | Level3 103 | true 104 | true 105 | true 106 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 107 | true 108 | stdcpp17 109 | 110 | 111 | Console 112 | true 113 | true 114 | true 115 | 116 | 117 | 118 | 119 | Level3 120 | true 121 | _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 122 | true 123 | stdcpp17 124 | 125 | 126 | Console 127 | true 128 | 129 | 130 | 131 | 132 | Level3 133 | true 134 | true 135 | true 136 | _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 137 | true 138 | stdcpp17 139 | 140 | 141 | Console 142 | true 143 | true 144 | true 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /mkoasm/mkoasm.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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 | {784deded-dc6f-4f5a-94f7-339bd502252c} 18 | 19 | 20 | 21 | 22 | Source 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 | Header Files 44 | 45 | 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files\lz4 97 | 98 | 99 | Header Files\lz4 100 | 101 | 102 | Header Files\lz4 103 | 104 | 105 | Header Files 106 | 107 | 108 | 109 | 110 | Resource Files 111 | 112 | 113 | --------------------------------------------------------------------------------