├── version.ini ├── installer.dll ├── tzf_dsound ├── version.rc ├── control_panel.cpp ├── symbols.def ├── include │ └── lzma │ │ ├── Precomp.h │ │ ├── Sort.h │ │ ├── delta.h │ │ ├── 7zAlloc.h │ │ ├── Sha256.h │ │ ├── 7zVersion.h │ │ ├── 7zCrc.h │ │ ├── XzCrc64.h │ │ ├── RotateDefs.h │ │ ├── 7zBuf.h │ │ ├── Alloc.h │ │ ├── XzEnc.h │ │ ├── Compiler.h │ │ ├── Aes.h │ │ ├── 7zVersion.rc │ │ ├── 7zFile.h │ │ ├── LzHash.h │ │ ├── Lzma2Enc.h │ │ ├── Bra.h │ │ ├── Threads.h │ │ ├── Ppmd.h │ │ ├── MtCoder.h │ │ ├── Lzma2Dec.h │ │ ├── LzFindMt.h │ │ ├── LzmaEnc.h │ │ ├── Lzma86.h │ │ ├── Bcj2.h │ │ ├── LzFind.h │ │ ├── Ppmd7.h │ │ ├── LzmaLib.h │ │ └── 7z.h ├── resource.h ├── lzma │ ├── 7zBuf.c │ ├── 7zBuf2.c │ ├── LzmaLib.c │ ├── Lzma86Dec.c │ ├── Delta.c │ ├── 7zAlloc.c │ ├── BraIA64.c │ ├── Bra86.c │ ├── XzCrc64Opt.c │ ├── Xz.c │ ├── XzCrc64.c │ ├── Threads.c │ ├── Lzma86Enc.c │ ├── Sort.c │ ├── 7zCrc.c │ ├── Alloc.c │ ├── Bra.c │ ├── 7zCrcOpt.c │ ├── 7zStream.c │ ├── CpuArch.c │ ├── Ppmd7Enc.c │ ├── AesOpt.c │ ├── Ppmd7Dec.c │ └── Sha256.c ├── DLL_VERSION.H ├── general_io.h ├── scanner.h ├── keyboard.h ├── ini.cpp ├── log.cpp ├── command.cpp ├── steam.h ├── sound.h ├── ReadMe.txt ├── imgui │ └── imconfig.h ├── scanner.cpp ├── log.h ├── framerate.h ├── ini.h ├── hook.h ├── config.h ├── keyboard.cpp ├── steam.cpp ├── command.h ├── compatibility.cpp └── parameter.h ├── AUTHORS ├── tzf_dsound.sln ├── .gitignore └── README.md /version.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaldaien/TZF/HEAD/version.ini -------------------------------------------------------------------------------- /installer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaldaien/TZF/HEAD/installer.dll -------------------------------------------------------------------------------- /tzf_dsound/version.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaldaien/TZF/HEAD/tzf_dsound/version.rc -------------------------------------------------------------------------------- /tzf_dsound/control_panel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaldaien/TZF/HEAD/tzf_dsound/control_panel.cpp -------------------------------------------------------------------------------- /tzf_dsound/symbols.def: -------------------------------------------------------------------------------- 1 | LIBRARY "tzfix" 2 | 3 | EXPORTS 4 | SKPlugIn_Init = SKPlugIn_Init @1 5 | SKPlugIn_Shutdown = SKPlugIn_Shutdown @2 -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Precomp.h: -------------------------------------------------------------------------------- 1 | /* Precomp.h -- StdAfx 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_PRECOMP_H 5 | #define __7Z_PRECOMP_H 6 | 7 | #include "Compiler.h" 8 | /* #include "7zTypes.h" */ 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Sort.h: -------------------------------------------------------------------------------- 1 | /* Sort.h -- Sort functions 2 | 2014-04-05 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_SORT_H 5 | #define __7Z_SORT_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | void HeapSort(UInt32 *p, size_t size); 12 | void HeapSort64(UInt64 *p, size_t size); 13 | 14 | /* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */ 15 | 16 | EXTERN_C_END 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /tzf_dsound/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by version.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/delta.h: -------------------------------------------------------------------------------- 1 | /* Delta.h -- Delta converter 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __DELTA_H 5 | #define __DELTA_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define DELTA_STATE_SIZE 256 12 | 13 | void Delta_Init(Byte *state); 14 | void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size); 15 | void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size); 16 | 17 | EXTERN_C_END 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/7zAlloc.h: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.h -- Allocation functions 2 | 2013-03-25 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_ALLOC_H 5 | #define __7Z_ALLOC_H 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | void *SzAlloc(void *p, size_t size); 14 | void SzFree(void *p, void *address); 15 | 16 | void *SzAllocTemp(void *p, size_t size); 17 | void SzFreeTemp(void *p, void *address); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Sha256.h: -------------------------------------------------------------------------------- 1 | /* Sha256.h -- SHA-256 Hash 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __CRYPTO_SHA256_H 5 | #define __CRYPTO_SHA256_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define SHA256_DIGEST_SIZE 32 12 | 13 | typedef struct 14 | { 15 | UInt32 state[8]; 16 | UInt64 count; 17 | Byte buffer[64]; 18 | } CSha256; 19 | 20 | void Sha256_Init(CSha256 *p); 21 | void Sha256_Update(CSha256 *p, const Byte *data, size_t size); 22 | void Sha256_Final(CSha256 *p, Byte *digest); 23 | 24 | EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/7zVersion.h: -------------------------------------------------------------------------------- 1 | #define MY_VER_MAJOR 16 2 | #define MY_VER_MINOR 02 3 | #define MY_VER_BUILD 0 4 | #define MY_VERSION_NUMBERS "16.02" 5 | #define MY_VERSION "16.02" 6 | #define MY_DATE "2016-05-21" 7 | #undef MY_COPYRIGHT 8 | #undef MY_VERSION_COPYRIGHT_DATE 9 | #define MY_AUTHOR_NAME "Igor Pavlov" 10 | #define MY_COPYRIGHT_PD "Igor Pavlov : Public domain" 11 | #define MY_COPYRIGHT_CR "Copyright (c) 1999-2016 Igor Pavlov" 12 | 13 | #ifdef USE_COPYRIGHT_CR 14 | #define MY_COPYRIGHT MY_COPYRIGHT_CR 15 | #else 16 | #define MY_COPYRIGHT MY_COPYRIGHT_PD 17 | #endif 18 | 19 | #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " : " MY_COPYRIGHT " : " MY_DATE 20 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/7zBuf.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf.c -- Byte Buffer 2 | 2013-01-21 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | void Buf_Init(CBuf *p) 9 | { 10 | p->data = 0; 11 | p->size = 0; 12 | } 13 | 14 | int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) 15 | { 16 | p->size = 0; 17 | if (size == 0) 18 | { 19 | p->data = 0; 20 | return 1; 21 | } 22 | p->data = (Byte *)alloc->Alloc(alloc, size); 23 | if (p->data != 0) 24 | { 25 | p->size = size; 26 | return 1; 27 | } 28 | return 0; 29 | } 30 | 31 | void Buf_Free(CBuf *p, ISzAlloc *alloc) 32 | { 33 | alloc->Free(alloc, p->data); 34 | p->data = 0; 35 | p->size = 0; 36 | } 37 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/7zCrc.h: -------------------------------------------------------------------------------- 1 | /* 7zCrc.h -- CRC32 calculation 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_CRC_H 5 | #define __7Z_CRC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | extern UInt32 g_CrcTable[]; 12 | 13 | /* Call CrcGenerateTable one time before other CRC functions */ 14 | void MY_FAST_CALL CrcGenerateTable(void); 15 | 16 | #define CRC_INIT_VAL 0xFFFFFFFF 17 | #define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) 18 | #define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 19 | 20 | UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size); 21 | UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size); 22 | 23 | EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tzf_dsound/DLL_VERSION.H: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #define TZF_MAJOR 1 5 | #define TZF_MINOR 8 6 | #define TZF_BUILD 5 7 | #define TZF_REV 0 8 | 9 | 10 | 11 | 12 | 13 | #define _A2(a) #a 14 | #define _A(a) _A2(a) 15 | #define _L2(w) L ## w 16 | #define _L(w) _L2(w) 17 | 18 | 19 | #if (TZF_REV > 0) 20 | #define TZF_VERSION_STR_A _A(TZF_MAJOR) "." _A(TZF_MINOR) "." _A(TZF_BUILD) "." _A(TZF_REV) 21 | #else 22 | #define TZF_VERSION_STR_A _A(TZF_MAJOR) "." _A(TZF_MINOR) "." _A(TZF_BUILD) 23 | #endif 24 | 25 | #define TZF_VERSION_STR_W _L(TZF_VERSION_STR_A) 26 | 27 | 28 | #define TZF_FILE_VERSION TZF_MAJOR,TZF_MINOR,TZF_BUILD,TZF_REV 29 | #define TZF_PRODUCT_VERSION TZF_MAJOR,TZF_MINOR,TZF_BUILD,TZF_REV 30 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/XzCrc64.h: -------------------------------------------------------------------------------- 1 | /* XzCrc64.h -- CRC64 calculation 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __XZ_CRC64_H 5 | #define __XZ_CRC64_H 6 | 7 | #include 8 | 9 | #include "7zTypes.h" 10 | 11 | EXTERN_C_BEGIN 12 | 13 | extern UInt64 g_Crc64Table[]; 14 | 15 | void MY_FAST_CALL Crc64GenerateTable(void); 16 | 17 | #define CRC64_INIT_VAL UINT64_CONST(0xFFFFFFFFFFFFFFFF) 18 | #define CRC64_GET_DIGEST(crc) ((crc) ^ CRC64_INIT_VAL) 19 | #define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 20 | 21 | UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size); 22 | UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size); 23 | 24 | EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/RotateDefs.h: -------------------------------------------------------------------------------- 1 | /* RotateDefs.h -- Rotate functions 2 | 2015-03-25 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __ROTATE_DEFS_H 5 | #define __ROTATE_DEFS_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #include 10 | 11 | /* don't use _rotl with MINGW. It can insert slow call to function. */ 12 | 13 | /* #if (_MSC_VER >= 1200) */ 14 | #pragma intrinsic(_rotl) 15 | #pragma intrinsic(_rotr) 16 | /* #endif */ 17 | 18 | #define rotlFixed(x, n) _rotl((x), (n)) 19 | #define rotrFixed(x, n) _rotr((x), (n)) 20 | 21 | #else 22 | 23 | /* new compilers can translate these macros to fast commands. */ 24 | 25 | #define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) 26 | #define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/7zBuf.h: -------------------------------------------------------------------------------- 1 | /* 7zBuf.h -- Byte Buffer 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_BUF_H 5 | #define __7Z_BUF_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef struct 12 | { 13 | Byte *data; 14 | size_t size; 15 | } CBuf; 16 | 17 | void Buf_Init(CBuf *p); 18 | int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); 19 | void Buf_Free(CBuf *p, ISzAlloc *alloc); 20 | 21 | typedef struct 22 | { 23 | Byte *data; 24 | size_t size; 25 | size_t pos; 26 | } CDynBuf; 27 | 28 | void DynBuf_Construct(CDynBuf *p); 29 | void DynBuf_SeekToBeg(CDynBuf *p); 30 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc); 31 | void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc); 32 | 33 | EXTERN_C_END 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Alloc.h: -------------------------------------------------------------------------------- 1 | /* Alloc.h -- Memory allocation functions 2 | 2015-02-21 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __COMMON_ALLOC_H 5 | #define __COMMON_ALLOC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | void *MyAlloc(size_t size); 12 | void MyFree(void *address); 13 | 14 | #ifdef _WIN32 15 | 16 | void SetLargePageSize(); 17 | 18 | void *MidAlloc(size_t size); 19 | void MidFree(void *address); 20 | void *BigAlloc(size_t size); 21 | void BigFree(void *address); 22 | 23 | #else 24 | 25 | #define MidAlloc(size) MyAlloc(size) 26 | #define MidFree(address) MyFree(address) 27 | #define BigAlloc(size) MyAlloc(size) 28 | #define BigFree(address) MyFree(address) 29 | 30 | #endif 31 | 32 | extern ISzAlloc g_Alloc; 33 | extern ISzAlloc g_BigAlloc; 34 | 35 | EXTERN_C_END 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/XzEnc.h: -------------------------------------------------------------------------------- 1 | /* XzEnc.h -- Xz Encode 2 | 2011-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __XZ_ENC_H 5 | #define __XZ_ENC_H 6 | 7 | #include "Lzma2Enc.h" 8 | 9 | #include "Xz.h" 10 | 11 | EXTERN_C_BEGIN 12 | 13 | typedef struct 14 | { 15 | UInt32 id; 16 | UInt32 delta; 17 | UInt32 ip; 18 | int ipDefined; 19 | } CXzFilterProps; 20 | 21 | void XzFilterProps_Init(CXzFilterProps *p); 22 | 23 | typedef struct 24 | { 25 | const CLzma2EncProps *lzma2Props; 26 | const CXzFilterProps *filterProps; 27 | unsigned checkId; 28 | } CXzProps; 29 | 30 | void XzProps_Init(CXzProps *p); 31 | 32 | SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream, 33 | const CXzProps *props, ICompressProgress *progress); 34 | 35 | SRes Xz_EncodeEmpty(ISeqOutStream *outStream); 36 | 37 | EXTERN_C_END 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Tales of Zestiria "Fix" started out as a simple single-author DirectSound / WASAPI fix for audio-related game crashes. 2 | 3 | 4 | Thanks to the work of multiple contributors, the scope has broadened to encompass virtually all aspects of gameplay. 5 | 6 | Andon "Kaldaien" Coleman Core Project and d3d9.dll 7 | Niklas "DrDaxxy" Kielblock 60 FPS and Related Features 8 | Peter "Durante" Thoman Character Shadow Resolution 9 | 10 | 11 | The community would like to extend thanks to the following individuals for tools and other support: 12 | 13 | Eric "Dark Byte" Heijnen Cheat Engine 14 | Peter "Durante" Thoman GeDoSaTo 15 | Steve P. Miller Dependency Walker 16 | 17 | Steam User: Crache Unofficial Community Manager 18 | 19 | 20 | Everyone who has ever posted in the development thread on the Steam forums. 21 | 22 | * This project would be nothing but a throw-away 7.1 channel audio fix without your support. 23 | -------------------------------------------------------------------------------- /tzf_dsound.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tzf_dsound", "tzf_dsound\tzf_dsound.vcxproj", "{66F0B0ED-F640-46EF-9E3A-0C524628D7AE}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {66F0B0ED-F640-46EF-9E3A-0C524628D7AE}.Debug|x86.ActiveCfg = Release|Win32 15 | {66F0B0ED-F640-46EF-9E3A-0C524628D7AE}.Debug|x86.Build.0 = Release|Win32 16 | {66F0B0ED-F640-46EF-9E3A-0C524628D7AE}.Release|x86.ActiveCfg = Release|Win32 17 | {66F0B0ED-F640-46EF-9E3A-0C524628D7AE}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /tzf_dsound/general_io.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | 23 | #ifndef __TZF__GENERAL_IO_H__ 24 | #define __TZF__GENERAL_IO_H__ 25 | 26 | namespace tzf 27 | { 28 | namespace FileIO 29 | { 30 | void Init (void); 31 | void Shutdown (void); 32 | } 33 | } 34 | 35 | #endif /* __TZF__GENERAL_IO_H__ */ 36 | -------------------------------------------------------------------------------- /tzf_dsound/scanner.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | 23 | #ifndef __TZF__SCANNER_H__ 24 | #define __TZF__SCANNER_H__ 25 | 26 | #include 27 | 28 | uintptr_t TZF_GetBaseAddr (void); 29 | void* TZF_Scan (uint8_t* pattern, size_t len, uint8_t* mask = nullptr); 30 | 31 | #endif /* __TZF__SCANNER_H__ */ -------------------------------------------------------------------------------- /tzf_dsound/lzma/7zBuf2.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf2.c -- Byte Buffer 2 | 2014-08-22 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | void DynBuf_Construct(CDynBuf *p) 11 | { 12 | p->data = 0; 13 | p->size = 0; 14 | p->pos = 0; 15 | } 16 | 17 | void DynBuf_SeekToBeg(CDynBuf *p) 18 | { 19 | p->pos = 0; 20 | } 21 | 22 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc) 23 | { 24 | if (size > p->size - p->pos) 25 | { 26 | size_t newSize = p->pos + size; 27 | Byte *data; 28 | newSize += newSize / 4; 29 | data = (Byte *)alloc->Alloc(alloc, newSize); 30 | if (data == 0) 31 | return 0; 32 | p->size = newSize; 33 | memcpy(data, p->data, p->pos); 34 | alloc->Free(alloc, p->data); 35 | p->data = data; 36 | } 37 | if (size != 0) 38 | { 39 | memcpy(p->data + p->pos, buf, size); 40 | p->pos += size; 41 | } 42 | return 1; 43 | } 44 | 45 | void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc) 46 | { 47 | alloc->Free(alloc, p->data); 48 | p->data = 0; 49 | p->size = 0; 50 | p->pos = 0; 51 | } 52 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Compiler.h: -------------------------------------------------------------------------------- 1 | /* Compiler.h 2 | 2015-08-02 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_COMPILER_H 5 | #define __7Z_COMPILER_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #ifdef UNDER_CE 10 | #define RPC_NO_WINDOWS_H 11 | /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ 12 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union 13 | #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int 14 | #endif 15 | 16 | #if _MSC_VER >= 1300 17 | #pragma warning(disable : 4996) // This function or variable may be unsafe 18 | #else 19 | #pragma warning(disable : 4511) // copy constructor could not be generated 20 | #pragma warning(disable : 4512) // assignment operator could not be generated 21 | #pragma warning(disable : 4514) // unreferenced inline function has been removed 22 | #pragma warning(disable : 4702) // unreachable code 23 | #pragma warning(disable : 4710) // not inlined 24 | #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information 25 | #endif 26 | 27 | #endif 28 | 29 | #define UNUSED_VAR(x) (void)x; 30 | /* #define UNUSED_VAR(x) x=x; */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /tzf_dsound/keyboard.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | 23 | #ifndef __TZF__KEYBOARD_H__ 24 | #define __TZF__KEYBOARD_H__ 25 | 26 | #include 27 | #include 28 | 29 | namespace tzf { 30 | namespace KeyboardFix { 31 | void Init (void); 32 | void Shutdown (void); 33 | 34 | extern std::set remapped_scancodes; 35 | extern std::vector > swapped_keys; 36 | } 37 | } 38 | 39 | #endif /* __TZF__KEYBOARD_H__ */ -------------------------------------------------------------------------------- /tzf_dsound/lzma/LzmaLib.c: -------------------------------------------------------------------------------- 1 | /* LzmaLib.c -- LZMA library wrapper 2 | 2015-06-13 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, 10 | unsigned char *outProps, size_t *outPropsSize, 11 | int level, /* 0 <= level <= 9, default = 5 */ 12 | unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */ 13 | int lc, /* 0 <= lc <= 8, default = 3 */ 14 | int lp, /* 0 <= lp <= 4, default = 0 */ 15 | int pb, /* 0 <= pb <= 4, default = 2 */ 16 | int fb, /* 5 <= fb <= 273, default = 32 */ 17 | int numThreads /* 1 or 2, default = 2 */ 18 | ) 19 | { 20 | CLzmaEncProps props; 21 | LzmaEncProps_Init(&props); 22 | props.level = level; 23 | props.dictSize = dictSize; 24 | props.lc = lc; 25 | props.lp = lp; 26 | props.pb = pb; 27 | props.fb = fb; 28 | props.numThreads = numThreads; 29 | 30 | return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0, 31 | NULL, &g_Alloc, &g_Alloc); 32 | } 33 | 34 | 35 | MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen, 36 | const unsigned char *props, size_t propsSize) 37 | { 38 | ELzmaStatus status; 39 | return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc); 40 | } 41 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Aes.h: -------------------------------------------------------------------------------- 1 | /* Aes.h -- AES encryption / decryption 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __AES_H 5 | #define __AES_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define AES_BLOCK_SIZE 16 12 | 13 | /* Call AesGenTables one time before other AES functions */ 14 | void AesGenTables(void); 15 | 16 | /* UInt32 pointers must be 16-byte aligned */ 17 | 18 | /* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */ 19 | #define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4) 20 | 21 | /* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */ 22 | /* keySize = 16 or 24 or 32 (bytes) */ 23 | typedef void (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize); 24 | void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize); 25 | void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize); 26 | 27 | /* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */ 28 | void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */ 29 | /* data - 16-byte aligned pointer to data */ 30 | /* numBlocks - the number of 16-byte blocks in data array */ 31 | typedef void (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks); 32 | extern AES_CODE_FUNC g_AesCbc_Encode; 33 | extern AES_CODE_FUNC g_AesCbc_Decode; 34 | extern AES_CODE_FUNC g_AesCtr_Code; 35 | 36 | EXTERN_C_END 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Lzma86Dec.c: -------------------------------------------------------------------------------- 1 | /* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder 2 | 2016-05-16 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize) 13 | { 14 | unsigned i; 15 | if (srcLen < LZMA86_HEADER_SIZE) 16 | return SZ_ERROR_INPUT_EOF; 17 | *unpackSize = 0; 18 | for (i = 0; i < sizeof(UInt64); i++) 19 | *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i); 20 | return SZ_OK; 21 | } 22 | 23 | SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen) 24 | { 25 | SRes res; 26 | int useFilter; 27 | SizeT inSizePure; 28 | ELzmaStatus status; 29 | 30 | if (*srcLen < LZMA86_HEADER_SIZE) 31 | return SZ_ERROR_INPUT_EOF; 32 | 33 | useFilter = src[0]; 34 | 35 | if (useFilter > 1) 36 | { 37 | *destLen = 0; 38 | return SZ_ERROR_UNSUPPORTED; 39 | } 40 | 41 | inSizePure = *srcLen - LZMA86_HEADER_SIZE; 42 | res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure, 43 | src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc); 44 | *srcLen = inSizePure + LZMA86_HEADER_SIZE; 45 | if (res != SZ_OK) 46 | return res; 47 | if (useFilter == 1) 48 | { 49 | UInt32 x86State; 50 | x86_Convert_Init(x86State); 51 | x86_Convert(dest, *destLen, 0, &x86State, 0); 52 | } 53 | return SZ_OK; 54 | } 55 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Delta.c: -------------------------------------------------------------------------------- 1 | /* Delta.c -- Delta converter 2 | 2009-05-26 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | void Delta_Init(Byte *state) 9 | { 10 | unsigned i; 11 | for (i = 0; i < DELTA_STATE_SIZE; i++) 12 | state[i] = 0; 13 | } 14 | 15 | static void MyMemCpy(Byte *dest, const Byte *src, unsigned size) 16 | { 17 | unsigned i; 18 | for (i = 0; i < size; i++) 19 | dest[i] = src[i]; 20 | } 21 | 22 | void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size) 23 | { 24 | Byte buf[DELTA_STATE_SIZE]; 25 | unsigned j = 0; 26 | MyMemCpy(buf, state, delta); 27 | { 28 | SizeT i; 29 | for (i = 0; i < size;) 30 | { 31 | for (j = 0; j < delta && i < size; i++, j++) 32 | { 33 | Byte b = data[i]; 34 | data[i] = (Byte)(b - buf[j]); 35 | buf[j] = b; 36 | } 37 | } 38 | } 39 | if (j == delta) 40 | j = 0; 41 | MyMemCpy(state, buf + j, delta - j); 42 | MyMemCpy(state + delta - j, buf, j); 43 | } 44 | 45 | void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size) 46 | { 47 | Byte buf[DELTA_STATE_SIZE]; 48 | unsigned j = 0; 49 | MyMemCpy(buf, state, delta); 50 | { 51 | SizeT i; 52 | for (i = 0; i < size;) 53 | { 54 | for (j = 0; j < delta && i < size; i++, j++) 55 | { 56 | buf[j] = data[i] = (Byte)(buf[j] + data[i]); 57 | } 58 | } 59 | } 60 | if (j == delta) 61 | j = 0; 62 | MyMemCpy(state, buf + j, delta - j); 63 | MyMemCpy(state + delta - j, buf, j); 64 | } 65 | -------------------------------------------------------------------------------- /tzf_dsound/ini.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #define _CRT_SECURE_NO_WARNINGS 23 | 24 | #include 25 | 26 | #include "ini.h" 27 | iSK_INI* 28 | TZF_CreateINI (const wchar_t* const wszName) 29 | { 30 | extern HMODULE hInjectorDLL; 31 | 32 | typedef iSK_INI* (__stdcall *SK_CreateINI_pfn)(const wchar_t* const wszName); 33 | static SK_CreateINI_pfn SK_CreateINI = nullptr; 34 | 35 | if (SK_CreateINI == nullptr) { 36 | SK_CreateINI = 37 | (SK_CreateINI_pfn) 38 | GetProcAddress ( 39 | hInjectorDLL, 40 | "SK_CreateINI" 41 | ); 42 | } 43 | 44 | iSK_INI* pINI = SK_CreateINI (wszName); 45 | 46 | if (pINI != nullptr) { 47 | return pINI; 48 | } else { 49 | // ASSERT: WHAT THE HELL?! 50 | return nullptr; 51 | } 52 | } -------------------------------------------------------------------------------- /tzf_dsound/log.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #define _CRT_SECURE_NO_WARNINGS 23 | 24 | #include 25 | #include "log.h" 26 | 27 | iSK_Logger* dll_log; 28 | 29 | iSK_Logger* 30 | TZF_CreateLog (const wchar_t* const wszName) 31 | { 32 | extern HMODULE hInjectorDLL; 33 | 34 | typedef iSK_Logger* (__stdcall *SK_CreateLog_pfn)(const wchar_t* const wszName); 35 | static SK_CreateLog_pfn SK_CreateLog = nullptr; 36 | 37 | if (SK_CreateLog == nullptr) { 38 | SK_CreateLog = 39 | (SK_CreateLog_pfn) 40 | GetProcAddress ( 41 | hInjectorDLL, 42 | "SK_CreateLog" 43 | ); 44 | } 45 | 46 | iSK_Logger* pLog = SK_CreateLog (wszName); 47 | 48 | if (pLog != nullptr) { 49 | return pLog; 50 | } else { 51 | // ASSERT: WHAT THE HELL?! 52 | return nullptr; 53 | } 54 | } -------------------------------------------------------------------------------- /tzf_dsound/command.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #include "command.h" 23 | 24 | SK_GetCommandProcessor_pfn SK_GetCommandProcessor = nullptr; 25 | 26 | typedef SK_IVariable* (__stdcall *SK_CreateVar_pfn)( SK_IVariable::VariableType type, 27 | void* var, 28 | SK_IVariableListener *pListener ); 29 | SK_CreateVar_pfn SK_CreateVar = nullptr; 30 | 31 | SK_IVariable* 32 | TZF_CreateVar ( SK_IVariable::VariableType type, 33 | void* var, 34 | SK_IVariableListener *pListener ) 35 | { 36 | extern HMODULE hInjectorDLL; 37 | 38 | if (SK_CreateVar == nullptr) { 39 | SK_CreateVar = 40 | (SK_CreateVar_pfn)GetProcAddress (hInjectorDLL, "SK_CreateVar"); 41 | } 42 | 43 | return SK_CreateVar (type, var, pListener); 44 | } -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/7zVersion.rc: -------------------------------------------------------------------------------- 1 | #define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL 2 | #define MY_VOS_NT_WINDOWS32 0x00040004L 3 | #define MY_VOS_CE_WINDOWS32 0x00050004L 4 | 5 | #define MY_VFT_APP 0x00000001L 6 | #define MY_VFT_DLL 0x00000002L 7 | 8 | // #include 9 | 10 | #ifndef MY_VERSION 11 | #include "7zVersion.h" 12 | #endif 13 | 14 | #define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 15 | 16 | #ifdef DEBUG 17 | #define DBG_FL VS_FF_DEBUG 18 | #else 19 | #define DBG_FL 0 20 | #endif 21 | 22 | #define MY_VERSION_INFO(fileType, descr, intName, origName) \ 23 | LANGUAGE 9, 1 \ 24 | 1 VERSIONINFO \ 25 | FILEVERSION MY_VER \ 26 | PRODUCTVERSION MY_VER \ 27 | FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \ 28 | FILEFLAGS DBG_FL \ 29 | FILEOS MY_VOS_NT_WINDOWS32 \ 30 | FILETYPE fileType \ 31 | FILESUBTYPE 0x0L \ 32 | BEGIN \ 33 | BLOCK "StringFileInfo" \ 34 | BEGIN \ 35 | BLOCK "040904b0" \ 36 | BEGIN \ 37 | VALUE "CompanyName", "Igor Pavlov" \ 38 | VALUE "FileDescription", descr \ 39 | VALUE "FileVersion", MY_VERSION \ 40 | VALUE "InternalName", intName \ 41 | VALUE "LegalCopyright", MY_COPYRIGHT \ 42 | VALUE "OriginalFilename", origName \ 43 | VALUE "ProductName", "7-Zip" \ 44 | VALUE "ProductVersion", MY_VERSION \ 45 | END \ 46 | END \ 47 | BLOCK "VarFileInfo" \ 48 | BEGIN \ 49 | VALUE "Translation", 0x409, 1200 \ 50 | END \ 51 | END 52 | 53 | #define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe") 54 | 55 | #define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll") 56 | -------------------------------------------------------------------------------- /tzf_dsound/steam.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__STEAM_H__ 23 | #define __TZF__STEAM_H__ 24 | 25 | #include "command.h" 26 | 27 | namespace tzf 28 | { 29 | namespace SteamFix 30 | { 31 | void Init (void); 32 | void Shutdown (void); 33 | 34 | void SetOverlayState (bool active); 35 | 36 | class CommandProcessor : public SK_IVariableListener { 37 | public: 38 | CommandProcessor (void); 39 | 40 | virtual bool OnVarChange (SK_IVariable* var, void* val = NULL); 41 | 42 | static CommandProcessor* getInstance (void) 43 | { 44 | if (pCommProc == NULL) 45 | pCommProc = new CommandProcessor (); 46 | 47 | return pCommProc; 48 | } 49 | 50 | protected: 51 | SK_IVariable* allow_broadcasts_; 52 | 53 | private: 54 | static CommandProcessor* pCommProc; 55 | }; 56 | 57 | // Hold a reference to the Steam DLL 58 | extern HMODULE steam_dll; 59 | } 60 | } 61 | 62 | 63 | #endif /* __TZF__STEAM_H__ */ -------------------------------------------------------------------------------- /tzf_dsound/lzma/7zAlloc.c: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.c -- Allocation functions 2 | 2015-11-09 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | //#define _SZ_ALLOC_DEBUG 9 | /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ 10 | 11 | #ifdef _SZ_ALLOC_DEBUG 12 | 13 | #ifdef _WIN32 14 | #include 15 | #endif 16 | 17 | #include 18 | int g_allocCount = 0; 19 | int g_allocCountTemp = 0; 20 | 21 | #endif 22 | 23 | void *SzAlloc(void *p, size_t size) 24 | { 25 | UNUSED_VAR(p); 26 | if (size == 0) 27 | return 0; 28 | #ifdef _SZ_ALLOC_DEBUG 29 | fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount); 30 | g_allocCount++; 31 | #endif 32 | return malloc(size); 33 | } 34 | 35 | void SzFree(void *p, void *address) 36 | { 37 | UNUSED_VAR(p); 38 | #ifdef _SZ_ALLOC_DEBUG 39 | if (address != 0) 40 | { 41 | g_allocCount--; 42 | fprintf(stderr, "\nFree; count = %10d", g_allocCount); 43 | } 44 | #endif 45 | free(address); 46 | } 47 | 48 | void *SzAllocTemp(void *p, size_t size) 49 | { 50 | UNUSED_VAR(p); 51 | if (size == 0) 52 | return 0; 53 | #ifdef _SZ_ALLOC_DEBUG 54 | fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp); 55 | g_allocCountTemp++; 56 | #ifdef _WIN32 57 | return HeapAlloc(GetProcessHeap(), 0, size); 58 | #endif 59 | #endif 60 | return malloc(size); 61 | } 62 | 63 | void SzFreeTemp(void *p, void *address) 64 | { 65 | UNUSED_VAR(p); 66 | #ifdef _SZ_ALLOC_DEBUG 67 | if (address != 0) 68 | { 69 | g_allocCountTemp--; 70 | fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); 71 | } 72 | #ifdef _WIN32 73 | HeapFree(GetProcessHeap(), 0, address); 74 | return; 75 | #endif 76 | #endif 77 | free(address); 78 | } 79 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/7zFile.h: -------------------------------------------------------------------------------- 1 | /* 7zFile.h -- File IO 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_FILE_H 5 | #define __7Z_FILE_H 6 | 7 | #ifdef _WIN32 8 | #define USE_WINDOWS_FILE 9 | #endif 10 | 11 | #ifdef USE_WINDOWS_FILE 12 | #include 13 | #else 14 | #include 15 | #endif 16 | 17 | #include "7zTypes.h" 18 | 19 | EXTERN_C_BEGIN 20 | 21 | /* ---------- File ---------- */ 22 | 23 | typedef struct 24 | { 25 | #ifdef USE_WINDOWS_FILE 26 | HANDLE handle; 27 | #else 28 | FILE *file; 29 | #endif 30 | } CSzFile; 31 | 32 | void File_Construct(CSzFile *p); 33 | #if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) 34 | WRes InFile_Open(CSzFile *p, const char *name); 35 | WRes OutFile_Open(CSzFile *p, const char *name); 36 | #endif 37 | #ifdef USE_WINDOWS_FILE 38 | WRes InFile_OpenW(CSzFile *p, const WCHAR *name); 39 | WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); 40 | #endif 41 | WRes File_Close(CSzFile *p); 42 | 43 | /* reads max(*size, remain file's size) bytes */ 44 | WRes File_Read(CSzFile *p, void *data, size_t *size); 45 | 46 | /* writes *size bytes */ 47 | WRes File_Write(CSzFile *p, const void *data, size_t *size); 48 | 49 | WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); 50 | WRes File_GetLength(CSzFile *p, UInt64 *length); 51 | 52 | 53 | /* ---------- FileInStream ---------- */ 54 | 55 | typedef struct 56 | { 57 | ISeqInStream s; 58 | CSzFile file; 59 | } CFileSeqInStream; 60 | 61 | void FileSeqInStream_CreateVTable(CFileSeqInStream *p); 62 | 63 | 64 | typedef struct 65 | { 66 | ISeekInStream s; 67 | CSzFile file; 68 | } CFileInStream; 69 | 70 | void FileInStream_CreateVTable(CFileInStream *p); 71 | 72 | 73 | typedef struct 74 | { 75 | ISeqOutStream s; 76 | CSzFile file; 77 | } CFileOutStream; 78 | 79 | void FileOutStream_CreateVTable(CFileOutStream *p); 80 | 81 | EXTERN_C_END 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/LzHash.h: -------------------------------------------------------------------------------- 1 | /* LzHash.h -- HASH functions for LZ algorithms 2 | 2015-04-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_HASH_H 5 | #define __LZ_HASH_H 6 | 7 | #define kHash2Size (1 << 10) 8 | #define kHash3Size (1 << 16) 9 | #define kHash4Size (1 << 20) 10 | 11 | #define kFix3HashSize (kHash2Size) 12 | #define kFix4HashSize (kHash2Size + kHash3Size) 13 | #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) 14 | 15 | #define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8); 16 | 17 | #define HASH3_CALC { \ 18 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 19 | h2 = temp & (kHash2Size - 1); \ 20 | hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } 21 | 22 | #define HASH4_CALC { \ 23 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 24 | h2 = temp & (kHash2Size - 1); \ 25 | temp ^= ((UInt32)cur[2] << 8); \ 26 | h3 = temp & (kHash3Size - 1); \ 27 | hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; } 28 | 29 | #define HASH5_CALC { \ 30 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 31 | h2 = temp & (kHash2Size - 1); \ 32 | temp ^= ((UInt32)cur[2] << 8); \ 33 | h3 = temp & (kHash3Size - 1); \ 34 | temp ^= (p->crc[cur[3]] << 5); \ 35 | h4 = temp & (kHash4Size - 1); \ 36 | hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; } 37 | 38 | /* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ 39 | #define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; 40 | 41 | 42 | #define MT_HASH2_CALC \ 43 | h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); 44 | 45 | #define MT_HASH3_CALC { \ 46 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 47 | h2 = temp & (kHash2Size - 1); \ 48 | h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } 49 | 50 | #define MT_HASH4_CALC { \ 51 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 52 | h2 = temp & (kHash2Size - 1); \ 53 | temp ^= ((UInt32)cur[2] << 8); \ 54 | h3 = temp & (kHash3Size - 1); \ 55 | h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Lzma2Enc.h: -------------------------------------------------------------------------------- 1 | /* Lzma2Enc.h -- LZMA2 Encoder 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA2_ENC_H 5 | #define __LZMA2_ENC_H 6 | 7 | #include "LzmaEnc.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef struct 12 | { 13 | CLzmaEncProps lzmaProps; 14 | size_t blockSize; 15 | int numBlockThreads; 16 | int numTotalThreads; 17 | } CLzma2EncProps; 18 | 19 | void Lzma2EncProps_Init(CLzma2EncProps *p); 20 | void Lzma2EncProps_Normalize(CLzma2EncProps *p); 21 | 22 | /* ---------- CLzmaEnc2Handle Interface ---------- */ 23 | 24 | /* Lzma2Enc_* functions can return the following exit codes: 25 | Returns: 26 | SZ_OK - OK 27 | SZ_ERROR_MEM - Memory allocation error 28 | SZ_ERROR_PARAM - Incorrect paramater in props 29 | SZ_ERROR_WRITE - Write callback error 30 | SZ_ERROR_PROGRESS - some break from progress callback 31 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 32 | */ 33 | 34 | typedef void * CLzma2EncHandle; 35 | 36 | CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig); 37 | void Lzma2Enc_Destroy(CLzma2EncHandle p); 38 | SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props); 39 | Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p); 40 | SRes Lzma2Enc_Encode(CLzma2EncHandle p, 41 | ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress); 42 | 43 | /* ---------- One Call Interface ---------- */ 44 | 45 | /* Lzma2Encode 46 | Return code: 47 | SZ_OK - OK 48 | SZ_ERROR_MEM - Memory allocation error 49 | SZ_ERROR_PARAM - Incorrect paramater 50 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 51 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 52 | */ 53 | 54 | /* 55 | SRes Lzma2Encode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 56 | const CLzmaEncProps *props, Byte *propsEncoded, int writeEndMark, 57 | ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 58 | */ 59 | 60 | EXTERN_C_END 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/BraIA64.c: -------------------------------------------------------------------------------- 1 | /* BraIA64.c -- Converter for IA-64 code 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | static const Byte kBranchTable[32] = 9 | { 10 | 0, 0, 0, 0, 0, 0, 0, 0, 11 | 0, 0, 0, 0, 0, 0, 0, 0, 12 | 4, 4, 6, 6, 0, 0, 7, 7, 13 | 4, 4, 0, 0, 4, 4, 0, 0 14 | }; 15 | 16 | SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 17 | { 18 | SizeT i; 19 | if (size < 16) 20 | return 0; 21 | size -= 16; 22 | for (i = 0; i <= size; i += 16) 23 | { 24 | UInt32 instrTemplate = data[i] & 0x1F; 25 | UInt32 mask = kBranchTable[instrTemplate]; 26 | UInt32 bitPos = 5; 27 | int slot; 28 | for (slot = 0; slot < 3; slot++, bitPos += 41) 29 | { 30 | UInt32 bytePos, bitRes; 31 | UInt64 instruction, instNorm; 32 | int j; 33 | if (((mask >> slot) & 1) == 0) 34 | continue; 35 | bytePos = (bitPos >> 3); 36 | bitRes = bitPos & 0x7; 37 | instruction = 0; 38 | for (j = 0; j < 6; j++) 39 | instruction += (UInt64)data[i + j + bytePos] << (8 * j); 40 | 41 | instNorm = instruction >> bitRes; 42 | if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0) 43 | { 44 | UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF); 45 | UInt32 dest; 46 | src |= ((UInt32)(instNorm >> 36) & 1) << 20; 47 | 48 | src <<= 4; 49 | 50 | if (encoding) 51 | dest = ip + (UInt32)i + src; 52 | else 53 | dest = src - (ip + (UInt32)i); 54 | 55 | dest >>= 4; 56 | 57 | instNorm &= ~((UInt64)(0x8FFFFF) << 13); 58 | instNorm |= ((UInt64)(dest & 0xFFFFF) << 13); 59 | instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20)); 60 | 61 | instruction &= (1 << bitRes) - 1; 62 | instruction |= (instNorm << bitRes); 63 | for (j = 0; j < 6; j++) 64 | data[i + j + bytePos] = (Byte)(instruction >> (8 * j)); 65 | } 66 | } 67 | } 68 | return i; 69 | } 70 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Bra86.c: -------------------------------------------------------------------------------- 1 | /* Bra86.c -- Converter for x86 code (BCJ) 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0) 9 | 10 | SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding) 11 | { 12 | SizeT pos = 0; 13 | UInt32 mask = *state & 7; 14 | if (size < 5) 15 | return 0; 16 | size -= 4; 17 | ip += 5; 18 | 19 | for (;;) 20 | { 21 | Byte *p = data + pos; 22 | const Byte *limit = data + size; 23 | for (; p < limit; p++) 24 | if ((*p & 0xFE) == 0xE8) 25 | break; 26 | 27 | { 28 | SizeT d = (SizeT)(p - data - pos); 29 | pos = (SizeT)(p - data); 30 | if (p >= limit) 31 | { 32 | *state = (d > 2 ? 0 : mask >> (unsigned)d); 33 | return pos; 34 | } 35 | if (d > 2) 36 | mask = 0; 37 | else 38 | { 39 | mask >>= (unsigned)d; 40 | if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(mask >> 1) + 1]))) 41 | { 42 | mask = (mask >> 1) | 4; 43 | pos++; 44 | continue; 45 | } 46 | } 47 | } 48 | 49 | if (Test86MSByte(p[4])) 50 | { 51 | UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); 52 | UInt32 cur = ip + (UInt32)pos; 53 | pos += 5; 54 | if (encoding) 55 | v += cur; 56 | else 57 | v -= cur; 58 | if (mask != 0) 59 | { 60 | unsigned sh = (mask & 6) << 2; 61 | if (Test86MSByte((Byte)(v >> sh))) 62 | { 63 | v ^= (((UInt32)0x100 << sh) - 1); 64 | if (encoding) 65 | v += cur; 66 | else 67 | v -= cur; 68 | } 69 | mask = 0; 70 | } 71 | p[1] = (Byte)v; 72 | p[2] = (Byte)(v >> 8); 73 | p[3] = (Byte)(v >> 16); 74 | p[4] = (Byte)(0 - ((v >> 24) & 1)); 75 | } 76 | else 77 | { 78 | mask = (mask >> 1) | 4; 79 | pos++; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Bra.h: -------------------------------------------------------------------------------- 1 | /* Bra.h -- Branch converters for executables 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __BRA_H 5 | #define __BRA_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* 12 | These functions convert relative addresses to absolute addresses 13 | in CALL instructions to increase the compression ratio. 14 | 15 | In: 16 | data - data buffer 17 | size - size of data 18 | ip - current virtual Instruction Pinter (IP) value 19 | state - state variable for x86 converter 20 | encoding - 0 (for decoding), 1 (for encoding) 21 | 22 | Out: 23 | state - state variable for x86 converter 24 | 25 | Returns: 26 | The number of processed bytes. If you call these functions with multiple calls, 27 | you must start next call with first byte after block of processed bytes. 28 | 29 | Type Endian Alignment LookAhead 30 | 31 | x86 little 1 4 32 | ARMT little 2 2 33 | ARM little 4 0 34 | PPC big 4 0 35 | SPARC big 4 0 36 | IA64 little 16 0 37 | 38 | size must be >= Alignment + LookAhead, if it's not last block. 39 | If (size < Alignment + LookAhead), converter returns 0. 40 | 41 | Example: 42 | 43 | UInt32 ip = 0; 44 | for () 45 | { 46 | ; size must be >= Alignment + LookAhead, if it's not last block 47 | SizeT processed = Convert(data, size, ip, 1); 48 | data += processed; 49 | size -= processed; 50 | ip += processed; 51 | } 52 | */ 53 | 54 | #define x86_Convert_Init(state) { state = 0; } 55 | SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding); 56 | SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 57 | SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 58 | SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 59 | SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 60 | SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 61 | 62 | EXTERN_C_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /tzf_dsound/sound.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__SOUND_H__ 23 | #define __TZF__SOUND_H__ 24 | 25 | #include 26 | 27 | #include "command.h" 28 | 29 | namespace tzf 30 | { 31 | namespace SoundFix 32 | { 33 | void Init (void); 34 | void Shutdown (void); 35 | 36 | class CommandProcessor : public SK_IVariableListener { 37 | public: 38 | CommandProcessor (void); 39 | 40 | virtual bool OnVarChange (SK_IVariable* var, void* val = NULL); 41 | 42 | static CommandProcessor* getInstance (void) 43 | { 44 | if (pCommProc == NULL) 45 | pCommProc = new CommandProcessor (); 46 | 47 | return pCommProc; 48 | } 49 | 50 | protected: 51 | SK_IVariable* sample_rate_; 52 | SK_IVariable* channels_; 53 | SK_IVariable* enable_; 54 | SK_IVariable* compatibility_; 55 | 56 | private: 57 | static CommandProcessor* pCommProc; 58 | }; 59 | 60 | // True once the game has initialized sound 61 | extern bool wasapi_init; 62 | 63 | extern WAVEFORMATEX snd_core_fmt; 64 | extern WAVEFORMATEX snd_bink_fmt; 65 | extern WAVEFORMATEX snd_device_fmt; 66 | 67 | // Hold references to these DLLs 68 | extern HMODULE dsound_dll; 69 | extern HMODULE ole32_dll; 70 | } 71 | } 72 | 73 | #endif /* __TZF__SOUND_H__ */ -------------------------------------------------------------------------------- /tzf_dsound/lzma/XzCrc64Opt.c: -------------------------------------------------------------------------------- 1 | /* XzCrc64Opt.c -- CRC64 calculation 2 | 2015-03-01 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #ifndef MY_CPU_BE 9 | 10 | #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 11 | 12 | UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table) 13 | { 14 | const Byte *p = (const Byte *)data; 15 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 16 | v = CRC_UPDATE_BYTE_2(v, *p); 17 | for (; size >= 4; size -= 4, p += 4) 18 | { 19 | UInt32 d = (UInt32)v ^ *(const UInt32 *)p; 20 | v = (v >> 32) 21 | ^ table[0x300 + ((d ) & 0xFF)] 22 | ^ table[0x200 + ((d >> 8) & 0xFF)] 23 | ^ table[0x100 + ((d >> 16) & 0xFF)] 24 | ^ table[0x000 + ((d >> 24))]; 25 | } 26 | for (; size > 0; size--, p++) 27 | v = CRC_UPDATE_BYTE_2(v, *p); 28 | return v; 29 | } 30 | 31 | #endif 32 | 33 | 34 | #ifndef MY_CPU_LE 35 | 36 | #define CRC_UINT64_SWAP(v) \ 37 | ((v >> 56) \ 38 | | ((v >> 40) & ((UInt64)0xFF << 8)) \ 39 | | ((v >> 24) & ((UInt64)0xFF << 16)) \ 40 | | ((v >> 8) & ((UInt64)0xFF << 24)) \ 41 | | ((v << 8) & ((UInt64)0xFF << 32)) \ 42 | | ((v << 24) & ((UInt64)0xFF << 40)) \ 43 | | ((v << 40) & ((UInt64)0xFF << 48)) \ 44 | | ((v << 56))) 45 | 46 | #define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8)) 47 | 48 | UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table) 49 | { 50 | const Byte *p = (const Byte *)data; 51 | table += 0x100; 52 | v = CRC_UINT64_SWAP(v); 53 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 54 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 55 | for (; size >= 4; size -= 4, p += 4) 56 | { 57 | UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)p; 58 | v = (v << 32) 59 | ^ table[0x000 + ((d ) & 0xFF)] 60 | ^ table[0x100 + ((d >> 8) & 0xFF)] 61 | ^ table[0x200 + ((d >> 16) & 0xFF)] 62 | ^ table[0x300 + ((d >> 24))]; 63 | } 64 | for (; size > 0; size--, p++) 65 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 66 | return CRC_UINT64_SWAP(v); 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Threads.h: -------------------------------------------------------------------------------- 1 | /* Threads.h -- multithreading library 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_THREADS_H 5 | #define __7Z_THREADS_H 6 | 7 | #ifdef _WIN32 8 | #include 9 | #endif 10 | 11 | #include "7zTypes.h" 12 | 13 | EXTERN_C_BEGIN 14 | 15 | WRes HandlePtr_Close(HANDLE *h); 16 | WRes Handle_WaitObject(HANDLE h); 17 | 18 | typedef HANDLE CThread; 19 | #define Thread_Construct(p) *(p) = NULL 20 | #define Thread_WasCreated(p) (*(p) != NULL) 21 | #define Thread_Close(p) HandlePtr_Close(p) 22 | #define Thread_Wait(p) Handle_WaitObject(*(p)) 23 | 24 | typedef 25 | #ifdef UNDER_CE 26 | DWORD 27 | #else 28 | unsigned 29 | #endif 30 | THREAD_FUNC_RET_TYPE; 31 | 32 | #define THREAD_FUNC_CALL_TYPE MY_STD_CALL 33 | #define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE 34 | typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *); 35 | WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param); 36 | 37 | typedef HANDLE CEvent; 38 | typedef CEvent CAutoResetEvent; 39 | typedef CEvent CManualResetEvent; 40 | #define Event_Construct(p) *(p) = NULL 41 | #define Event_IsCreated(p) (*(p) != NULL) 42 | #define Event_Close(p) HandlePtr_Close(p) 43 | #define Event_Wait(p) Handle_WaitObject(*(p)) 44 | WRes Event_Set(CEvent *p); 45 | WRes Event_Reset(CEvent *p); 46 | WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); 47 | WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); 48 | WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); 49 | WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); 50 | 51 | typedef HANDLE CSemaphore; 52 | #define Semaphore_Construct(p) (*p) = NULL 53 | #define Semaphore_Close(p) HandlePtr_Close(p) 54 | #define Semaphore_Wait(p) Handle_WaitObject(*(p)) 55 | WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); 56 | WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); 57 | WRes Semaphore_Release1(CSemaphore *p); 58 | 59 | typedef CRITICAL_SECTION CCriticalSection; 60 | WRes CriticalSection_Init(CCriticalSection *p); 61 | #define CriticalSection_Delete(p) DeleteCriticalSection(p) 62 | #define CriticalSection_Enter(p) EnterCriticalSection(p) 63 | #define CriticalSection_Leave(p) LeaveCriticalSection(p) 64 | 65 | EXTERN_C_END 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /tzf_dsound/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : tzf_dsound Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this tzf_dsound DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your tzf_dsound application. 9 | 10 | 11 | tzf_dsound.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | tzf_dsound.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | tzf_dsound.cpp 25 | This is the main DLL source file. 26 | 27 | When created, this DLL does not export any symbols. As a result, it 28 | will not produce a .lib file when it is built. If you wish this project 29 | to be a project dependency of some other project, you will either need to 30 | add code to export some symbols from the DLL so that an export library 31 | will be produced, or you can set the Ignore Input Library property to Yes 32 | on the General propert page of the Linker folder in the project's Property 33 | Pages dialog box. 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | Other standard files: 37 | 38 | StdAfx.h, StdAfx.cpp 39 | These files are used to build a precompiled header (PCH) file 40 | named tzf_dsound.pch and a precompiled types file named StdAfx.obj. 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | Other notes: 44 | 45 | AppWizard uses "TODO:" comments to indicate parts of the source code you 46 | should add to or customize. 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Xz.c: -------------------------------------------------------------------------------- 1 | /* Xz.c - Xz 2 | 2015-05-01 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | const Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 }; 12 | const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' }; 13 | 14 | unsigned Xz_WriteVarInt(Byte *buf, UInt64 v) 15 | { 16 | unsigned i = 0; 17 | do 18 | { 19 | buf[i++] = (Byte)((v & 0x7F) | 0x80); 20 | v >>= 7; 21 | } 22 | while (v != 0); 23 | buf[i - 1] &= 0x7F; 24 | return i; 25 | } 26 | 27 | void Xz_Construct(CXzStream *p) 28 | { 29 | p->numBlocks = p->numBlocksAllocated = 0; 30 | p->blocks = 0; 31 | p->flags = 0; 32 | } 33 | 34 | void Xz_Free(CXzStream *p, ISzAlloc *alloc) 35 | { 36 | alloc->Free(alloc, p->blocks); 37 | p->numBlocks = p->numBlocksAllocated = 0; 38 | p->blocks = 0; 39 | } 40 | 41 | unsigned XzFlags_GetCheckSize(CXzStreamFlags f) 42 | { 43 | unsigned t = XzFlags_GetCheckType(f); 44 | return (t == 0) ? 0 : (4 << ((t - 1) / 3)); 45 | } 46 | 47 | void XzCheck_Init(CXzCheck *p, unsigned mode) 48 | { 49 | p->mode = mode; 50 | switch (mode) 51 | { 52 | case XZ_CHECK_CRC32: p->crc = CRC_INIT_VAL; break; 53 | case XZ_CHECK_CRC64: p->crc64 = CRC64_INIT_VAL; break; 54 | case XZ_CHECK_SHA256: Sha256_Init(&p->sha); break; 55 | } 56 | } 57 | 58 | void XzCheck_Update(CXzCheck *p, const void *data, size_t size) 59 | { 60 | switch (p->mode) 61 | { 62 | case XZ_CHECK_CRC32: p->crc = CrcUpdate(p->crc, data, size); break; 63 | case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break; 64 | case XZ_CHECK_SHA256: Sha256_Update(&p->sha, (const Byte *)data, size); break; 65 | } 66 | } 67 | 68 | int XzCheck_Final(CXzCheck *p, Byte *digest) 69 | { 70 | switch (p->mode) 71 | { 72 | case XZ_CHECK_CRC32: 73 | SetUi32(digest, CRC_GET_DIGEST(p->crc)); 74 | break; 75 | case XZ_CHECK_CRC64: 76 | { 77 | int i; 78 | UInt64 v = CRC64_GET_DIGEST(p->crc64); 79 | for (i = 0; i < 8; i++, v >>= 8) 80 | digest[i] = (Byte)(v & 0xFF); 81 | break; 82 | } 83 | case XZ_CHECK_SHA256: 84 | Sha256_Final(&p->sha, digest); 85 | break; 86 | default: 87 | return 0; 88 | } 89 | return 1; 90 | } 91 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Ppmd.h: -------------------------------------------------------------------------------- 1 | /* Ppmd.h -- PPMD codec common code 2 | 2016-05-16 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | #ifndef __PPMD_H 6 | #define __PPMD_H 7 | 8 | #include "CpuArch.h" 9 | 10 | EXTERN_C_BEGIN 11 | 12 | #ifdef MY_CPU_32BIT 13 | #define PPMD_32BIT 14 | #endif 15 | 16 | #define PPMD_INT_BITS 7 17 | #define PPMD_PERIOD_BITS 7 18 | #define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) 19 | 20 | #define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) 21 | #define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) 22 | #define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) 23 | #define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) 24 | 25 | #define PPMD_N1 4 26 | #define PPMD_N2 4 27 | #define PPMD_N3 4 28 | #define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) 29 | #define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) 30 | 31 | #pragma pack(push, 1) 32 | /* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ 33 | 34 | /* SEE-contexts for PPM-contexts with masked symbols */ 35 | typedef struct 36 | { 37 | UInt16 Summ; /* Freq */ 38 | Byte Shift; /* Speed of Freq change; low Shift is for fast change */ 39 | Byte Count; /* Count to next change of Shift */ 40 | } CPpmd_See; 41 | 42 | #define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ 43 | { (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); } 44 | 45 | typedef struct 46 | { 47 | Byte Symbol; 48 | Byte Freq; 49 | UInt16 SuccessorLow; 50 | UInt16 SuccessorHigh; 51 | } CPpmd_State; 52 | 53 | #pragma pack(pop) 54 | 55 | typedef 56 | #ifdef PPMD_32BIT 57 | CPpmd_State * 58 | #else 59 | UInt32 60 | #endif 61 | CPpmd_State_Ref; 62 | 63 | typedef 64 | #ifdef PPMD_32BIT 65 | void * 66 | #else 67 | UInt32 68 | #endif 69 | CPpmd_Void_Ref; 70 | 71 | typedef 72 | #ifdef PPMD_32BIT 73 | Byte * 74 | #else 75 | UInt32 76 | #endif 77 | CPpmd_Byte_Ref; 78 | 79 | #define PPMD_SetAllBitsIn256Bytes(p) \ 80 | { unsigned z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \ 81 | p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }} 82 | 83 | EXTERN_C_END 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/MtCoder.h: -------------------------------------------------------------------------------- 1 | /* MtCoder.h -- Multi-thread Coder 2 | 2009-11-19 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __MT_CODER_H 5 | #define __MT_CODER_H 6 | 7 | #include "Threads.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef struct 12 | { 13 | CThread thread; 14 | CAutoResetEvent startEvent; 15 | CAutoResetEvent finishedEvent; 16 | int stop; 17 | 18 | THREAD_FUNC_TYPE func; 19 | LPVOID param; 20 | THREAD_FUNC_RET_TYPE res; 21 | } CLoopThread; 22 | 23 | void LoopThread_Construct(CLoopThread *p); 24 | void LoopThread_Close(CLoopThread *p); 25 | WRes LoopThread_Create(CLoopThread *p); 26 | WRes LoopThread_StopAndWait(CLoopThread *p); 27 | WRes LoopThread_StartSubThread(CLoopThread *p); 28 | WRes LoopThread_WaitSubThread(CLoopThread *p); 29 | 30 | #ifndef _7ZIP_ST 31 | #define NUM_MT_CODER_THREADS_MAX 32 32 | #else 33 | #define NUM_MT_CODER_THREADS_MAX 1 34 | #endif 35 | 36 | typedef struct 37 | { 38 | UInt64 totalInSize; 39 | UInt64 totalOutSize; 40 | ICompressProgress *progress; 41 | SRes res; 42 | CCriticalSection cs; 43 | UInt64 inSizes[NUM_MT_CODER_THREADS_MAX]; 44 | UInt64 outSizes[NUM_MT_CODER_THREADS_MAX]; 45 | } CMtProgress; 46 | 47 | SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize); 48 | 49 | struct _CMtCoder; 50 | 51 | typedef struct 52 | { 53 | struct _CMtCoder *mtCoder; 54 | Byte *outBuf; 55 | size_t outBufSize; 56 | Byte *inBuf; 57 | size_t inBufSize; 58 | unsigned index; 59 | CLoopThread thread; 60 | 61 | Bool stopReading; 62 | Bool stopWriting; 63 | CAutoResetEvent canRead; 64 | CAutoResetEvent canWrite; 65 | } CMtThread; 66 | 67 | typedef struct 68 | { 69 | SRes (*Code)(void *p, unsigned index, Byte *dest, size_t *destSize, 70 | const Byte *src, size_t srcSize, int finished); 71 | } IMtCoderCallback; 72 | 73 | typedef struct _CMtCoder 74 | { 75 | size_t blockSize; 76 | size_t destBlockSize; 77 | unsigned numThreads; 78 | 79 | ISeqInStream *inStream; 80 | ISeqOutStream *outStream; 81 | ICompressProgress *progress; 82 | ISzAlloc *alloc; 83 | 84 | IMtCoderCallback *mtCallback; 85 | CCriticalSection cs; 86 | SRes res; 87 | 88 | CMtProgress mtProgress; 89 | CMtThread threads[NUM_MT_CODER_THREADS_MAX]; 90 | } CMtCoder; 91 | 92 | void MtCoder_Construct(CMtCoder* p); 93 | void MtCoder_Destruct(CMtCoder* p); 94 | SRes MtCoder_Code(CMtCoder *p); 95 | 96 | EXTERN_C_END 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/XzCrc64.c: -------------------------------------------------------------------------------- 1 | /* XzCrc64.c -- CRC64 calculation 2 | 2015-03-01 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42) 10 | 11 | #ifdef MY_CPU_LE 12 | #define CRC_NUM_TABLES 4 13 | #else 14 | #define CRC_NUM_TABLES 5 15 | #define CRC_UINT64_SWAP(v) \ 16 | ((v >> 56) \ 17 | | ((v >> 40) & ((UInt64)0xFF << 8)) \ 18 | | ((v >> 24) & ((UInt64)0xFF << 16)) \ 19 | | ((v >> 8) & ((UInt64)0xFF << 24)) \ 20 | | ((v << 8) & ((UInt64)0xFF << 32)) \ 21 | | ((v << 24) & ((UInt64)0xFF << 40)) \ 22 | | ((v << 40) & ((UInt64)0xFF << 48)) \ 23 | | ((v << 56))) 24 | 25 | UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table); 26 | #endif 27 | 28 | #ifndef MY_CPU_BE 29 | UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table); 30 | #endif 31 | 32 | typedef UInt64 (MY_FAST_CALL *CRC_FUNC)(UInt64 v, const void *data, size_t size, const UInt64 *table); 33 | 34 | static CRC_FUNC g_Crc64Update; 35 | UInt64 g_Crc64Table[256 * CRC_NUM_TABLES]; 36 | 37 | UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size) 38 | { 39 | return g_Crc64Update(v, data, size, g_Crc64Table); 40 | } 41 | 42 | UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size) 43 | { 44 | return g_Crc64Update(CRC64_INIT_VAL, data, size, g_Crc64Table) ^ CRC64_INIT_VAL; 45 | } 46 | 47 | void MY_FAST_CALL Crc64GenerateTable() 48 | { 49 | UInt32 i; 50 | for (i = 0; i < 256; i++) 51 | { 52 | UInt64 r = i; 53 | unsigned j; 54 | for (j = 0; j < 8; j++) 55 | r = (r >> 1) ^ (kCrc64Poly & ~((r & 1) - 1)); 56 | g_Crc64Table[i] = r; 57 | } 58 | for (; i < 256 * CRC_NUM_TABLES; i++) 59 | { 60 | UInt64 r = g_Crc64Table[i - 256]; 61 | g_Crc64Table[i] = g_Crc64Table[r & 0xFF] ^ (r >> 8); 62 | } 63 | 64 | #ifdef MY_CPU_LE 65 | 66 | g_Crc64Update = XzCrc64UpdateT4; 67 | 68 | #else 69 | { 70 | #ifndef MY_CPU_BE 71 | UInt32 k = 1; 72 | if (*(const Byte *)&k == 1) 73 | g_Crc64Update = XzCrc64UpdateT4; 74 | else 75 | #endif 76 | { 77 | for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--) 78 | { 79 | UInt64 x = g_Crc64Table[i - 256]; 80 | g_Crc64Table[i] = CRC_UINT64_SWAP(x); 81 | } 82 | g_Crc64Update = XzCrc64UpdateT1_BeT4; 83 | } 84 | } 85 | #endif 86 | } 87 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Lzma2Dec.h: -------------------------------------------------------------------------------- 1 | /* Lzma2Dec.h -- LZMA2 Decoder 2 | 2015-05-13 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA2_DEC_H 5 | #define __LZMA2_DEC_H 6 | 7 | #include "LzmaDec.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* ---------- State Interface ---------- */ 12 | 13 | typedef struct 14 | { 15 | CLzmaDec decoder; 16 | UInt32 packSize; 17 | UInt32 unpackSize; 18 | unsigned state; 19 | Byte control; 20 | Bool needInitDic; 21 | Bool needInitState; 22 | Bool needInitProp; 23 | } CLzma2Dec; 24 | 25 | #define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) 26 | #define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); 27 | #define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); 28 | 29 | SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); 30 | SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); 31 | void Lzma2Dec_Init(CLzma2Dec *p); 32 | 33 | 34 | /* 35 | finishMode: 36 | It has meaning only if the decoding reaches output limit (*destLen or dicLimit). 37 | LZMA_FINISH_ANY - use smallest number of input bytes 38 | LZMA_FINISH_END - read EndOfStream marker after decoding 39 | 40 | Returns: 41 | SZ_OK 42 | status: 43 | LZMA_STATUS_FINISHED_WITH_MARK 44 | LZMA_STATUS_NOT_FINISHED 45 | LZMA_STATUS_NEEDS_MORE_INPUT 46 | SZ_ERROR_DATA - Data error 47 | */ 48 | 49 | SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, 50 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 51 | 52 | SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, 53 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 54 | 55 | 56 | /* ---------- One Call Interface ---------- */ 57 | 58 | /* 59 | finishMode: 60 | It has meaning only if the decoding reaches output limit (*destLen). 61 | LZMA_FINISH_ANY - use smallest number of input bytes 62 | LZMA_FINISH_END - read EndOfStream marker after decoding 63 | 64 | Returns: 65 | SZ_OK 66 | status: 67 | LZMA_STATUS_FINISHED_WITH_MARK 68 | LZMA_STATUS_NOT_FINISHED 69 | SZ_ERROR_DATA - Data error 70 | SZ_ERROR_MEM - Memory allocation error 71 | SZ_ERROR_UNSUPPORTED - Unsupported properties 72 | SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). 73 | */ 74 | 75 | SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, 76 | Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); 77 | 78 | EXTERN_C_END 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /tzf_dsound/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // USER IMPLEMENTATION 3 | // This file contains compile-time options for ImGui. 4 | // Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO(). 5 | //----------------------------------------------------------------------------- 6 | 7 | #pragma once 8 | 9 | //---- Define assertion handler. Defaults to calling assert(). 10 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 11 | 12 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. 13 | //#define IMGUI_API __declspec( dllexport ) 14 | //#define IMGUI_API __declspec( dllimport ) 15 | 16 | //---- Include imgui_user.h at the end of imgui.h 17 | //#define IMGUI_INCLUDE_IMGUI_USER_H 18 | 19 | //---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions) 20 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS 21 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS 22 | 23 | //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty) 24 | //#define IMGUI_DISABLE_TEST_WINDOWS 25 | 26 | //---- Don't define obsolete functions names 27 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 28 | 29 | //---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends) 30 | //#define IMGUI_USE_BGRA_PACKED_COLOR 31 | 32 | //---- Implement STB libraries in a namespace to avoid conflicts 33 | //#define IMGUI_STB_NAMESPACE ImGuiStb 34 | 35 | //---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. 36 | /* 37 | #define IM_VEC2_CLASS_EXTRA \ 38 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 39 | operator MyVec2() const { return MyVec2(x,y); } 40 | 41 | #define IM_VEC4_CLASS_EXTRA \ 42 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 43 | operator MyVec4() const { return MyVec4(x,y,z,w); } 44 | */ 45 | 46 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 47 | //---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers. 48 | /* 49 | namespace ImGui 50 | { 51 | void Value(const char* prefix, const MyMatrix44& v, const char* float_format = NULL); 52 | } 53 | */ 54 | 55 | -------------------------------------------------------------------------------- /tzf_dsound/scanner.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | 23 | #include "scanner.h" 24 | 25 | #include 26 | 27 | uintptr_t 28 | TZF_GetBaseAddr (void) 29 | { 30 | static uintptr_t base = (uintptr_t)GetModuleHandle (nullptr); 31 | 32 | return base; 33 | } 34 | 35 | void* 36 | TZF_Scan (uint8_t* pattern, size_t len, uint8_t* mask) 37 | { 38 | uint8_t* base_addr = (uint8_t *)GetModuleHandle (nullptr); 39 | 40 | MEMORY_BASIC_INFORMATION mem_info; 41 | VirtualQuery (base_addr, &mem_info, sizeof mem_info); 42 | 43 | IMAGE_DOS_HEADER* pDOS = 44 | (IMAGE_DOS_HEADER *)mem_info.AllocationBase; 45 | IMAGE_NT_HEADERS* pNT = 46 | (IMAGE_NT_HEADERS *)((uintptr_t)(pDOS + pDOS->e_lfanew)); 47 | 48 | uint8_t* end_addr = base_addr + pNT->OptionalHeader.SizeOfImage; 49 | 50 | uint8_t* begin = (uint8_t *)base_addr; 51 | uint8_t* it = begin; 52 | int idx = 0; 53 | 54 | while (it < end_addr) 55 | { 56 | VirtualQuery (it, &mem_info, sizeof mem_info); 57 | 58 | uint8_t* next_rgn = (uint8_t *)mem_info.BaseAddress + mem_info.RegionSize; 59 | 60 | if (mem_info.Type != MEM_IMAGE || mem_info.State != MEM_COMMIT || mem_info.Protect & PAGE_NOACCESS) { 61 | it = next_rgn; 62 | idx = 0; 63 | begin = it; 64 | continue; 65 | } 66 | 67 | while (it < next_rgn) { 68 | uint8_t* scan_addr = it; 69 | 70 | bool match = (*scan_addr == pattern [idx]); 71 | 72 | // For portions we do not care about... treat them 73 | // as matching. 74 | if (mask != nullptr && (! mask [idx])) 75 | match = true; 76 | 77 | if (match) { 78 | if (++idx == len) 79 | return (void *)begin; 80 | 81 | ++it; 82 | } 83 | 84 | else { 85 | // No match?! 86 | if (it > end_addr - len) 87 | break; 88 | 89 | 90 | 91 | it = ++begin; 92 | idx = 0; 93 | } 94 | } 95 | } 96 | 97 | return nullptr; 98 | } -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/LzFindMt.h: -------------------------------------------------------------------------------- 1 | /* LzFindMt.h -- multithreaded Match finder for LZ algorithms 2 | 2015-05-03 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_FIND_MT_H 5 | #define __LZ_FIND_MT_H 6 | 7 | #include "LzFind.h" 8 | #include "Threads.h" 9 | 10 | EXTERN_C_BEGIN 11 | 12 | #define kMtHashBlockSize (1 << 13) 13 | #define kMtHashNumBlocks (1 << 3) 14 | #define kMtHashNumBlocksMask (kMtHashNumBlocks - 1) 15 | 16 | #define kMtBtBlockSize (1 << 14) 17 | #define kMtBtNumBlocks (1 << 6) 18 | #define kMtBtNumBlocksMask (kMtBtNumBlocks - 1) 19 | 20 | typedef struct _CMtSync 21 | { 22 | Bool wasCreated; 23 | Bool needStart; 24 | Bool exit; 25 | Bool stopWriting; 26 | 27 | CThread thread; 28 | CAutoResetEvent canStart; 29 | CAutoResetEvent wasStarted; 30 | CAutoResetEvent wasStopped; 31 | CSemaphore freeSemaphore; 32 | CSemaphore filledSemaphore; 33 | Bool csWasInitialized; 34 | Bool csWasEntered; 35 | CCriticalSection cs; 36 | UInt32 numProcessedBlocks; 37 | } CMtSync; 38 | 39 | typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances); 40 | 41 | /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */ 42 | #define kMtCacheLineDummy 128 43 | 44 | typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos, 45 | UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc); 46 | 47 | typedef struct _CMatchFinderMt 48 | { 49 | /* LZ */ 50 | const Byte *pointerToCurPos; 51 | UInt32 *btBuf; 52 | UInt32 btBufPos; 53 | UInt32 btBufPosLimit; 54 | UInt32 lzPos; 55 | UInt32 btNumAvailBytes; 56 | 57 | UInt32 *hash; 58 | UInt32 fixedHashSize; 59 | UInt32 historySize; 60 | const UInt32 *crc; 61 | 62 | Mf_Mix_Matches MixMatchesFunc; 63 | 64 | /* LZ + BT */ 65 | CMtSync btSync; 66 | Byte btDummy[kMtCacheLineDummy]; 67 | 68 | /* BT */ 69 | UInt32 *hashBuf; 70 | UInt32 hashBufPos; 71 | UInt32 hashBufPosLimit; 72 | UInt32 hashNumAvail; 73 | 74 | CLzRef *son; 75 | UInt32 matchMaxLen; 76 | UInt32 numHashBytes; 77 | UInt32 pos; 78 | const Byte *buffer; 79 | UInt32 cyclicBufferPos; 80 | UInt32 cyclicBufferSize; /* it must be historySize + 1 */ 81 | UInt32 cutValue; 82 | 83 | /* BT + Hash */ 84 | CMtSync hashSync; 85 | /* Byte hashDummy[kMtCacheLineDummy]; */ 86 | 87 | /* Hash */ 88 | Mf_GetHeads GetHeadsFunc; 89 | CMatchFinder *MatchFinder; 90 | } CMatchFinderMt; 91 | 92 | void MatchFinderMt_Construct(CMatchFinderMt *p); 93 | void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc); 94 | SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, 95 | UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc); 96 | void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable); 97 | void MatchFinderMt_ReleaseStream(CMatchFinderMt *p); 98 | 99 | EXTERN_C_END 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Threads.c: -------------------------------------------------------------------------------- 1 | /* Threads.c -- multithreading library 2 | 2014-09-21 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #ifndef UNDER_CE 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | static WRes GetError() 13 | { 14 | DWORD res = GetLastError(); 15 | return (res) ? (WRes)(res) : 1; 16 | } 17 | 18 | WRes HandleToWRes(HANDLE h) { return (h != 0) ? 0 : GetError(); } 19 | WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); } 20 | 21 | WRes HandlePtr_Close(HANDLE *p) 22 | { 23 | if (*p != NULL) 24 | if (!CloseHandle(*p)) 25 | return GetError(); 26 | *p = NULL; 27 | return 0; 28 | } 29 | 30 | WRes Handle_WaitObject(HANDLE h) { return (WRes)WaitForSingleObject(h, INFINITE); } 31 | 32 | WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) 33 | { 34 | /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ 35 | 36 | #ifdef UNDER_CE 37 | 38 | DWORD threadId; 39 | *p = CreateThread(0, 0, func, param, 0, &threadId); 40 | 41 | #else 42 | 43 | unsigned threadId; 44 | *p = (HANDLE)_beginthreadex(NULL, 0, func, param, 0, &threadId); 45 | 46 | #endif 47 | 48 | /* maybe we must use errno here, but probably GetLastError() is also OK. */ 49 | return HandleToWRes(*p); 50 | } 51 | 52 | WRes Event_Create(CEvent *p, BOOL manualReset, int signaled) 53 | { 54 | *p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL); 55 | return HandleToWRes(*p); 56 | } 57 | 58 | WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(*p)); } 59 | WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(*p)); } 60 | 61 | WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) { return Event_Create(p, TRUE, signaled); } 62 | WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) { return Event_Create(p, FALSE, signaled); } 63 | WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) { return ManualResetEvent_Create(p, 0); } 64 | WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); } 65 | 66 | 67 | WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) 68 | { 69 | *p = CreateSemaphore(NULL, (LONG)initCount, (LONG)maxCount, NULL); 70 | return HandleToWRes(*p); 71 | } 72 | 73 | static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount) 74 | { return BOOLToWRes(ReleaseSemaphore(*p, releaseCount, previousCount)); } 75 | WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num) 76 | { return Semaphore_Release(p, (LONG)num, NULL); } 77 | WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); } 78 | 79 | WRes CriticalSection_Init(CCriticalSection *p) 80 | { 81 | /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */ 82 | #ifdef _MSC_VER 83 | __try 84 | #endif 85 | { 86 | InitializeCriticalSection(p); 87 | /* InitializeCriticalSectionAndSpinCount(p, 0); */ 88 | } 89 | #ifdef _MSC_VER 90 | __except (EXCEPTION_EXECUTE_HANDLER) { return 1; } 91 | #endif 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /tzf_dsound/log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__LOG_H__ 23 | #define __TZF__LOG_H__ 24 | 25 | #include 26 | 27 | // {A4BF1773-CAAB-48F3-AD88-C2AB5C23BD6F} 28 | static const GUID IID_SK_Logger = 29 | { 0xa4bf1773, 0xcaab, 0x48f3, { 0xad, 0x88, 0xc2, 0xab, 0x5c, 0x23, 0xbd, 0x6f } }; 30 | 31 | interface iSK_Logger : public IUnknown 32 | { 33 | class AutoClose 34 | { 35 | friend interface iSK_Logger; 36 | public: 37 | ~AutoClose (void) 38 | { 39 | if (log_ != nullptr) 40 | log_->close (); 41 | 42 | log_ = nullptr; 43 | } 44 | 45 | protected: 46 | AutoClose (iSK_Logger* log) : log_ (log) { } 47 | 48 | private: 49 | iSK_Logger* log_; 50 | }; 51 | 52 | AutoClose auto_close (void) { 53 | return AutoClose (this); 54 | } 55 | 56 | iSK_Logger (void) { 57 | AddRef (); 58 | } 59 | 60 | virtual ~iSK_Logger (void) { 61 | Release (); 62 | } 63 | 64 | /*** IUnknown methods ***/ 65 | STDMETHOD ( QueryInterface)(THIS_ REFIID riid, void** ppvObj) = 0; 66 | STDMETHOD_ (ULONG, AddRef) (THIS) = 0; 67 | STDMETHOD_ (ULONG, Release) (THIS) = 0; 68 | 69 | STDMETHOD_ (bool, init)(THIS_ const wchar_t* const wszFilename, 70 | const wchar_t* const wszMode ) = 0; 71 | STDMETHOD_ (void, close)(THIS) = 0; 72 | 73 | STDMETHOD_ (void, LogEx)(THIS_ bool _Timestamp, 74 | _In_z_ _Printf_format_string_ 75 | wchar_t const* const _Format, 76 | ... ) = 0; 77 | STDMETHOD_ (void, Log) (THIS_ _In_z_ _Printf_format_string_ 78 | wchar_t const* const _Format, 79 | ... ) = 0; 80 | STDMETHOD_ (void, Log) (THIS_ _In_z_ _Printf_format_string_ 81 | char const* const _Format, 82 | ... ) = 0; 83 | }; 84 | 85 | extern iSK_Logger* dll_log; 86 | 87 | iSK_Logger* 88 | TZF_CreateLog (const wchar_t* const wszName); 89 | 90 | #endif /* __TZF__LOG_H__ */ 91 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Lzma86Enc.c: -------------------------------------------------------------------------------- 1 | /* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder 2 | 2016-05-16 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #define SZE_OUT_OVERFLOW SZE_DATA_ERROR 15 | 16 | int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, 17 | int level, UInt32 dictSize, int filterMode) 18 | { 19 | size_t outSize2 = *destLen; 20 | Byte *filteredStream; 21 | Bool useFilter; 22 | int mainResult = SZ_ERROR_OUTPUT_EOF; 23 | CLzmaEncProps props; 24 | LzmaEncProps_Init(&props); 25 | props.level = level; 26 | props.dictSize = dictSize; 27 | 28 | *destLen = 0; 29 | if (outSize2 < LZMA86_HEADER_SIZE) 30 | return SZ_ERROR_OUTPUT_EOF; 31 | 32 | { 33 | int i; 34 | UInt64 t = srcLen; 35 | for (i = 0; i < 8; i++, t >>= 8) 36 | dest[LZMA86_SIZE_OFFSET + i] = (Byte)t; 37 | } 38 | 39 | filteredStream = 0; 40 | useFilter = (filterMode != SZ_FILTER_NO); 41 | if (useFilter) 42 | { 43 | if (srcLen != 0) 44 | { 45 | filteredStream = (Byte *)MyAlloc(srcLen); 46 | if (filteredStream == 0) 47 | return SZ_ERROR_MEM; 48 | memcpy(filteredStream, src, srcLen); 49 | } 50 | { 51 | UInt32 x86State; 52 | x86_Convert_Init(x86State); 53 | x86_Convert(filteredStream, srcLen, 0, &x86State, 1); 54 | } 55 | } 56 | 57 | { 58 | size_t minSize = 0; 59 | Bool bestIsFiltered = False; 60 | 61 | /* passes for SZ_FILTER_AUTO: 62 | 0 - BCJ + LZMA 63 | 1 - LZMA 64 | 2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better. 65 | */ 66 | int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1; 67 | 68 | int i; 69 | for (i = 0; i < numPasses; i++) 70 | { 71 | size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE; 72 | size_t outPropsSize = 5; 73 | SRes curRes; 74 | Bool curModeIsFiltered = (numPasses > 1 && i == numPasses - 1); 75 | if (curModeIsFiltered && !bestIsFiltered) 76 | break; 77 | if (useFilter && i == 0) 78 | curModeIsFiltered = True; 79 | 80 | curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed, 81 | curModeIsFiltered ? filteredStream : src, srcLen, 82 | &props, dest + 1, &outPropsSize, 0, 83 | NULL, &g_Alloc, &g_Alloc); 84 | 85 | if (curRes != SZ_ERROR_OUTPUT_EOF) 86 | { 87 | if (curRes != SZ_OK) 88 | { 89 | mainResult = curRes; 90 | break; 91 | } 92 | if (outSizeProcessed <= minSize || mainResult != SZ_OK) 93 | { 94 | minSize = outSizeProcessed; 95 | bestIsFiltered = curModeIsFiltered; 96 | mainResult = SZ_OK; 97 | } 98 | } 99 | } 100 | dest[0] = (Byte)(bestIsFiltered ? 1 : 0); 101 | *destLen = LZMA86_HEADER_SIZE + minSize; 102 | } 103 | if (useFilter) 104 | MyFree(filteredStream); 105 | return mainResult; 106 | } 107 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Sort.c: -------------------------------------------------------------------------------- 1 | /* Sort.c -- Sort functions 2 | 2014-04-05 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #define HeapSortDown(p, k, size, temp) \ 9 | { for (;;) { \ 10 | size_t s = (k << 1); \ 11 | if (s > size) break; \ 12 | if (s < size && p[s + 1] > p[s]) s++; \ 13 | if (temp >= p[s]) break; \ 14 | p[k] = p[s]; k = s; \ 15 | } p[k] = temp; } 16 | 17 | void HeapSort(UInt32 *p, size_t size) 18 | { 19 | if (size <= 1) 20 | return; 21 | p--; 22 | { 23 | size_t i = size / 2; 24 | do 25 | { 26 | UInt32 temp = p[i]; 27 | size_t k = i; 28 | HeapSortDown(p, k, size, temp) 29 | } 30 | while (--i != 0); 31 | } 32 | /* 33 | do 34 | { 35 | size_t k = 1; 36 | UInt32 temp = p[size]; 37 | p[size--] = p[1]; 38 | HeapSortDown(p, k, size, temp) 39 | } 40 | while (size > 1); 41 | */ 42 | while (size > 3) 43 | { 44 | UInt32 temp = p[size]; 45 | size_t k = (p[3] > p[2]) ? 3 : 2; 46 | p[size--] = p[1]; 47 | p[1] = p[k]; 48 | HeapSortDown(p, k, size, temp) 49 | } 50 | { 51 | UInt32 temp = p[size]; 52 | p[size] = p[1]; 53 | if (size > 2 && p[2] < temp) 54 | { 55 | p[1] = p[2]; 56 | p[2] = temp; 57 | } 58 | else 59 | p[1] = temp; 60 | } 61 | } 62 | 63 | void HeapSort64(UInt64 *p, size_t size) 64 | { 65 | if (size <= 1) 66 | return; 67 | p--; 68 | { 69 | size_t i = size / 2; 70 | do 71 | { 72 | UInt64 temp = p[i]; 73 | size_t k = i; 74 | HeapSortDown(p, k, size, temp) 75 | } 76 | while (--i != 0); 77 | } 78 | /* 79 | do 80 | { 81 | size_t k = 1; 82 | UInt64 temp = p[size]; 83 | p[size--] = p[1]; 84 | HeapSortDown(p, k, size, temp) 85 | } 86 | while (size > 1); 87 | */ 88 | while (size > 3) 89 | { 90 | UInt64 temp = p[size]; 91 | size_t k = (p[3] > p[2]) ? 3 : 2; 92 | p[size--] = p[1]; 93 | p[1] = p[k]; 94 | HeapSortDown(p, k, size, temp) 95 | } 96 | { 97 | UInt64 temp = p[size]; 98 | p[size] = p[1]; 99 | if (size > 2 && p[2] < temp) 100 | { 101 | p[1] = p[2]; 102 | p[2] = temp; 103 | } 104 | else 105 | p[1] = temp; 106 | } 107 | } 108 | 109 | /* 110 | #define HeapSortRefDown(p, vals, n, size, temp) \ 111 | { size_t k = n; UInt32 val = vals[temp]; for (;;) { \ 112 | size_t s = (k << 1); \ 113 | if (s > size) break; \ 114 | if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \ 115 | if (val >= vals[p[s]]) break; \ 116 | p[k] = p[s]; k = s; \ 117 | } p[k] = temp; } 118 | 119 | void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size) 120 | { 121 | if (size <= 1) 122 | return; 123 | p--; 124 | { 125 | size_t i = size / 2; 126 | do 127 | { 128 | UInt32 temp = p[i]; 129 | HeapSortRefDown(p, vals, i, size, temp); 130 | } 131 | while (--i != 0); 132 | } 133 | do 134 | { 135 | UInt32 temp = p[size]; 136 | p[size--] = p[1]; 137 | HeapSortRefDown(p, vals, 1, size, temp); 138 | } 139 | while (size > 1); 140 | } 141 | */ 142 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/LzmaEnc.h: -------------------------------------------------------------------------------- 1 | /* LzmaEnc.h -- LZMA Encoder 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA_ENC_H 5 | #define __LZMA_ENC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define LZMA_PROPS_SIZE 5 12 | 13 | typedef struct _CLzmaEncProps 14 | { 15 | int level; /* 0 <= level <= 9 */ 16 | UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version 17 | (1 << 12) <= dictSize <= (1 << 30) for 64-bit version 18 | default = (1 << 24) */ 19 | UInt64 reduceSize; /* estimated size of data that will be compressed. default = 0xFFFFFFFF. 20 | Encoder uses this value to reduce dictionary size */ 21 | int lc; /* 0 <= lc <= 8, default = 3 */ 22 | int lp; /* 0 <= lp <= 4, default = 0 */ 23 | int pb; /* 0 <= pb <= 4, default = 2 */ 24 | int algo; /* 0 - fast, 1 - normal, default = 1 */ 25 | int fb; /* 5 <= fb <= 273, default = 32 */ 26 | int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ 27 | int numHashBytes; /* 2, 3 or 4, default = 4 */ 28 | UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ 29 | unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ 30 | int numThreads; /* 1 or 2, default = 2 */ 31 | } CLzmaEncProps; 32 | 33 | void LzmaEncProps_Init(CLzmaEncProps *p); 34 | void LzmaEncProps_Normalize(CLzmaEncProps *p); 35 | UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); 36 | 37 | 38 | /* ---------- CLzmaEncHandle Interface ---------- */ 39 | 40 | /* LzmaEnc_* functions can return the following exit codes: 41 | Returns: 42 | SZ_OK - OK 43 | SZ_ERROR_MEM - Memory allocation error 44 | SZ_ERROR_PARAM - Incorrect paramater in props 45 | SZ_ERROR_WRITE - Write callback error. 46 | SZ_ERROR_PROGRESS - some break from progress callback 47 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 48 | */ 49 | 50 | typedef void * CLzmaEncHandle; 51 | 52 | CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); 53 | void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); 54 | SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); 55 | SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); 56 | SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, 57 | ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 58 | SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 59 | int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 60 | 61 | /* ---------- One Call Interface ---------- */ 62 | 63 | /* LzmaEncode 64 | Return code: 65 | SZ_OK - OK 66 | SZ_ERROR_MEM - Memory allocation error 67 | SZ_ERROR_PARAM - Incorrect paramater 68 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 69 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 70 | */ 71 | 72 | SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 73 | const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 74 | ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 75 | 76 | EXTERN_C_END 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /tzf_dsound/framerate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__FRAMERATE_H__ 23 | #define __TZF__FRAMERATE_H__ 24 | 25 | #include 26 | #include 27 | 28 | #include "command.h" 29 | 30 | namespace tzf 31 | { 32 | namespace FrameRateFix 33 | { 34 | void Init (void); 35 | void Shutdown (void); 36 | 37 | 38 | // Called whenever the engine finishes a frame 39 | void RenderTick (void); 40 | 41 | 42 | // Determine the appropriate value for TickScale 43 | long CalcTickScale (double elapsed_ms); 44 | 45 | 46 | float GetTargetFrametime (void); 47 | 48 | // 49 | // At key points during the game, we need to disable the code that 50 | // cuts timing in half. These places will be wrapped by calls to 51 | // these. 52 | // 53 | void Begin30FPSEvent (void); 54 | void End30FPSEvent (void); 55 | 56 | void SetFPS (int fps); 57 | 58 | class CommandProcessor : public SK_IVariableListener { 59 | public: 60 | CommandProcessor (void); 61 | 62 | virtual bool OnVarChange (SK_IVariable* var, void* val = NULL); 63 | 64 | static CommandProcessor* getInstance (void) 65 | { 66 | if (pCommProc == NULL) 67 | pCommProc = new CommandProcessor (); 68 | 69 | return pCommProc; 70 | } 71 | 72 | protected: 73 | SK_IVariable* tick_scale_; 74 | 75 | private: 76 | static CommandProcessor* pCommProc; 77 | }; 78 | 79 | 80 | // True if the game is running in fullscreen 81 | extern bool fullscreen; 82 | 83 | // True if the game is being framerate limited by the DRIVER 84 | extern bool driver_limit_setup; 85 | 86 | // True if the executable has been modified (at run-time) to allow 60 FPS 87 | extern bool variable_speed_installed; 88 | 89 | // This is actually setup in the SK DLL that loads this one 90 | extern uint32_t target_fps; 91 | 92 | // Store the original unmodifed game instructions 93 | extern uint8_t old_speed_reset_code2 [7]; 94 | extern uint8_t old_limiter_instruction [6]; 95 | 96 | // Cache the game's tick scale for timing -- this can be changed without 97 | // our knowledge, so this is more or less a hint rather than a rule 98 | extern int32_t tick_scale; 99 | 100 | // Prevent mult-threaded shenanigans 101 | extern CRITICAL_SECTION alter_speed_cs; 102 | 103 | // Hold references to these DLLs 104 | extern HMODULE bink_dll; 105 | extern HMODULE kernel32_dll; 106 | } 107 | } 108 | 109 | #endif /* __TZF__FRAMERATE_H__ */ -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Lzma86.h: -------------------------------------------------------------------------------- 1 | /* Lzma86.h -- LZMA + x86 (BCJ) Filter 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA86_H 5 | #define __LZMA86_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define LZMA86_SIZE_OFFSET (1 + 5) 12 | #define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8) 13 | 14 | /* 15 | It's an example for LZMA + x86 Filter use. 16 | You can use .lzma86 extension, if you write that stream to file. 17 | .lzma86 header adds one additional byte to standard .lzma header. 18 | .lzma86 header (14 bytes): 19 | Offset Size Description 20 | 0 1 = 0 - no filter, pure LZMA 21 | = 1 - x86 filter + LZMA 22 | 1 1 lc, lp and pb in encoded form 23 | 2 4 dictSize (little endian) 24 | 6 8 uncompressed size (little endian) 25 | 26 | 27 | Lzma86_Encode 28 | ------------- 29 | level - compression level: 0 <= level <= 9, the default value for "level" is 5. 30 | 31 | dictSize - The dictionary size in bytes. The maximum value is 32 | 128 MB = (1 << 27) bytes for 32-bit version 33 | 1 GB = (1 << 30) bytes for 64-bit version 34 | The default value is 16 MB = (1 << 24) bytes, for level = 5. 35 | It's recommended to use the dictionary that is larger than 4 KB and 36 | that can be calculated as (1 << N) or (3 << N) sizes. 37 | For better compression ratio dictSize must be >= inSize. 38 | 39 | filterMode: 40 | SZ_FILTER_NO - no Filter 41 | SZ_FILTER_YES - x86 Filter 42 | SZ_FILTER_AUTO - it tries both alternatives to select best. 43 | Encoder will use 2 or 3 passes: 44 | 2 passes when FILTER_NO provides better compression. 45 | 3 passes when FILTER_YES provides better compression. 46 | 47 | Lzma86Encode allocates Data with MyAlloc functions. 48 | RAM Requirements for compressing: 49 | RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize 50 | filterMode FilterBlockSize 51 | SZ_FILTER_NO 0 52 | SZ_FILTER_YES inSize 53 | SZ_FILTER_AUTO inSize 54 | 55 | 56 | Return code: 57 | SZ_OK - OK 58 | SZ_ERROR_MEM - Memory allocation error 59 | SZ_ERROR_PARAM - Incorrect paramater 60 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 61 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 62 | */ 63 | 64 | enum ESzFilterMode 65 | { 66 | SZ_FILTER_NO, 67 | SZ_FILTER_YES, 68 | SZ_FILTER_AUTO 69 | }; 70 | 71 | SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, 72 | int level, UInt32 dictSize, int filterMode); 73 | 74 | 75 | /* 76 | Lzma86_GetUnpackSize: 77 | In: 78 | src - input data 79 | srcLen - input data size 80 | Out: 81 | unpackSize - size of uncompressed stream 82 | Return code: 83 | SZ_OK - OK 84 | SZ_ERROR_INPUT_EOF - Error in headers 85 | */ 86 | 87 | SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize); 88 | 89 | /* 90 | Lzma86_Decode: 91 | In: 92 | dest - output data 93 | destLen - output data size 94 | src - input data 95 | srcLen - input data size 96 | Out: 97 | destLen - processed output size 98 | srcLen - processed input size 99 | Return code: 100 | SZ_OK - OK 101 | SZ_ERROR_DATA - Data error 102 | SZ_ERROR_MEM - Memory allocation error 103 | SZ_ERROR_UNSUPPORTED - unsupported file 104 | SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer 105 | */ 106 | 107 | SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen); 108 | 109 | EXTERN_C_END 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/7zCrc.c: -------------------------------------------------------------------------------- 1 | /* 7zCrc.c -- CRC32 init 2 | 2015-03-10 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #define kCrcPoly 0xEDB88320 10 | 11 | #ifdef MY_CPU_LE 12 | #define CRC_NUM_TABLES 8 13 | #else 14 | #define CRC_NUM_TABLES 9 15 | 16 | #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) 17 | 18 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table); 19 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table); 20 | #endif 21 | 22 | #ifndef MY_CPU_BE 23 | UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); 24 | UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); 25 | #endif 26 | 27 | typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table); 28 | 29 | CRC_FUNC g_CrcUpdateT4; 30 | CRC_FUNC g_CrcUpdateT8; 31 | CRC_FUNC g_CrcUpdate; 32 | 33 | UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; 34 | 35 | UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) 36 | { 37 | return g_CrcUpdate(v, data, size, g_CrcTable); 38 | } 39 | 40 | UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) 41 | { 42 | return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; 43 | } 44 | 45 | #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 46 | 47 | UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table) 48 | { 49 | const Byte *p = (const Byte *)data; 50 | const Byte *pEnd = p + size; 51 | for (; p != pEnd; p++) 52 | v = CRC_UPDATE_BYTE_2(v, *p); 53 | return v; 54 | } 55 | 56 | void MY_FAST_CALL CrcGenerateTable() 57 | { 58 | UInt32 i; 59 | for (i = 0; i < 256; i++) 60 | { 61 | UInt32 r = i; 62 | unsigned j; 63 | for (j = 0; j < 8; j++) 64 | r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); 65 | g_CrcTable[i] = r; 66 | } 67 | for (; i < 256 * CRC_NUM_TABLES; i++) 68 | { 69 | UInt32 r = g_CrcTable[i - 256]; 70 | g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); 71 | } 72 | 73 | #if CRC_NUM_TABLES < 4 74 | 75 | g_CrcUpdate = CrcUpdateT1; 76 | 77 | #else 78 | 79 | #ifdef MY_CPU_LE 80 | 81 | g_CrcUpdateT4 = CrcUpdateT4; 82 | g_CrcUpdate = CrcUpdateT4; 83 | 84 | #if CRC_NUM_TABLES >= 8 85 | g_CrcUpdateT8 = CrcUpdateT8; 86 | 87 | #ifdef MY_CPU_X86_OR_AMD64 88 | if (!CPU_Is_InOrder()) 89 | g_CrcUpdate = CrcUpdateT8; 90 | #endif 91 | #endif 92 | 93 | #else 94 | { 95 | #ifndef MY_CPU_BE 96 | UInt32 k = 0x01020304; 97 | const Byte *p = (const Byte *)&k; 98 | if (p[0] == 4 && p[1] == 3) 99 | { 100 | g_CrcUpdateT4 = CrcUpdateT4; 101 | g_CrcUpdate = CrcUpdateT4; 102 | #if CRC_NUM_TABLES >= 8 103 | g_CrcUpdateT8 = CrcUpdateT8; 104 | // g_CrcUpdate = CrcUpdateT8; 105 | #endif 106 | } 107 | else if (p[0] != 1 || p[1] != 2) 108 | g_CrcUpdate = CrcUpdateT1; 109 | else 110 | #endif 111 | { 112 | for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--) 113 | { 114 | UInt32 x = g_CrcTable[i - 256]; 115 | g_CrcTable[i] = CRC_UINT32_SWAP(x); 116 | } 117 | g_CrcUpdateT4 = CrcUpdateT1_BeT4; 118 | g_CrcUpdate = CrcUpdateT1_BeT4; 119 | #if CRC_NUM_TABLES >= 8 120 | g_CrcUpdateT8 = CrcUpdateT1_BeT8; 121 | // g_CrcUpdate = CrcUpdateT1_BeT8; 122 | #endif 123 | } 124 | } 125 | #endif 126 | 127 | #endif 128 | } 129 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Alloc.c: -------------------------------------------------------------------------------- 1 | /* Alloc.c -- Memory allocation functions 2 | 2015-02-21 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #ifdef _WIN32 7 | #include 8 | #endif 9 | #include 10 | 11 | #include 12 | 13 | /* #define _SZ_ALLOC_DEBUG */ 14 | 15 | /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ 16 | #ifdef _SZ_ALLOC_DEBUG 17 | #include 18 | int g_allocCount = 0; 19 | int g_allocCountMid = 0; 20 | int g_allocCountBig = 0; 21 | #endif 22 | 23 | void *MyAlloc(size_t size) 24 | { 25 | if (size == 0) 26 | return 0; 27 | #ifdef _SZ_ALLOC_DEBUG 28 | { 29 | void *p = malloc(size); 30 | fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p); 31 | return p; 32 | } 33 | #else 34 | return malloc(size); 35 | #endif 36 | } 37 | 38 | void MyFree(void *address) 39 | { 40 | #ifdef _SZ_ALLOC_DEBUG 41 | if (address != 0) 42 | fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address); 43 | #endif 44 | free(address); 45 | } 46 | 47 | #ifdef _WIN32 48 | 49 | void *MidAlloc(size_t size) 50 | { 51 | if (size == 0) 52 | return 0; 53 | #ifdef _SZ_ALLOC_DEBUG 54 | fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++); 55 | #endif 56 | return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); 57 | } 58 | 59 | void MidFree(void *address) 60 | { 61 | #ifdef _SZ_ALLOC_DEBUG 62 | if (address != 0) 63 | fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid); 64 | #endif 65 | if (address == 0) 66 | return; 67 | VirtualFree(address, 0, MEM_RELEASE); 68 | } 69 | 70 | #ifndef MEM_LARGE_PAGES 71 | #undef _7ZIP_LARGE_PAGES 72 | #endif 73 | 74 | #ifdef _7ZIP_LARGE_PAGES 75 | SIZE_T g_LargePageSize = 0; 76 | typedef SIZE_T (WINAPI *GetLargePageMinimumP)(); 77 | #endif 78 | 79 | void SetLargePageSize() 80 | { 81 | #ifdef _7ZIP_LARGE_PAGES 82 | SIZE_T size = 0; 83 | GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP) 84 | GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum"); 85 | if (largePageMinimum == 0) 86 | return; 87 | size = largePageMinimum(); 88 | if (size == 0 || (size & (size - 1)) != 0) 89 | return; 90 | g_LargePageSize = size; 91 | #endif 92 | } 93 | 94 | 95 | void *BigAlloc(size_t size) 96 | { 97 | if (size == 0) 98 | return 0; 99 | #ifdef _SZ_ALLOC_DEBUG 100 | fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++); 101 | #endif 102 | 103 | #ifdef _7ZIP_LARGE_PAGES 104 | if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18)) 105 | { 106 | void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)), 107 | MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE); 108 | if (res != 0) 109 | return res; 110 | } 111 | #endif 112 | return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); 113 | } 114 | 115 | void BigFree(void *address) 116 | { 117 | #ifdef _SZ_ALLOC_DEBUG 118 | if (address != 0) 119 | fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig); 120 | #endif 121 | 122 | if (address == 0) 123 | return; 124 | VirtualFree(address, 0, MEM_RELEASE); 125 | } 126 | 127 | #endif 128 | 129 | 130 | static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); } 131 | static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); } 132 | ISzAlloc g_Alloc = { SzAlloc, SzFree }; 133 | 134 | static void *SzBigAlloc(void *p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); } 135 | static void SzBigFree(void *p, void *address) { UNUSED_VAR(p); BigFree(address); } 136 | ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree }; 137 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Bra.c: -------------------------------------------------------------------------------- 1 | /* Bra.c -- Converters for RISC code 2 | 2010-04-16 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 9 | { 10 | SizeT i; 11 | if (size < 4) 12 | return 0; 13 | size -= 4; 14 | ip += 8; 15 | for (i = 0; i <= size; i += 4) 16 | { 17 | if (data[i + 3] == 0xEB) 18 | { 19 | UInt32 dest; 20 | UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]); 21 | src <<= 2; 22 | if (encoding) 23 | dest = ip + (UInt32)i + src; 24 | else 25 | dest = src - (ip + (UInt32)i); 26 | dest >>= 2; 27 | data[i + 2] = (Byte)(dest >> 16); 28 | data[i + 1] = (Byte)(dest >> 8); 29 | data[i + 0] = (Byte)dest; 30 | } 31 | } 32 | return i; 33 | } 34 | 35 | SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 36 | { 37 | SizeT i; 38 | if (size < 4) 39 | return 0; 40 | size -= 4; 41 | ip += 4; 42 | for (i = 0; i <= size; i += 2) 43 | { 44 | if ((data[i + 1] & 0xF8) == 0xF0 && 45 | (data[i + 3] & 0xF8) == 0xF8) 46 | { 47 | UInt32 dest; 48 | UInt32 src = 49 | (((UInt32)data[i + 1] & 0x7) << 19) | 50 | ((UInt32)data[i + 0] << 11) | 51 | (((UInt32)data[i + 3] & 0x7) << 8) | 52 | (data[i + 2]); 53 | 54 | src <<= 1; 55 | if (encoding) 56 | dest = ip + (UInt32)i + src; 57 | else 58 | dest = src - (ip + (UInt32)i); 59 | dest >>= 1; 60 | 61 | data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7)); 62 | data[i + 0] = (Byte)(dest >> 11); 63 | data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7)); 64 | data[i + 2] = (Byte)dest; 65 | i += 2; 66 | } 67 | } 68 | return i; 69 | } 70 | 71 | SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 72 | { 73 | SizeT i; 74 | if (size < 4) 75 | return 0; 76 | size -= 4; 77 | for (i = 0; i <= size; i += 4) 78 | { 79 | if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) 80 | { 81 | UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) | 82 | ((UInt32)data[i + 1] << 16) | 83 | ((UInt32)data[i + 2] << 8) | 84 | ((UInt32)data[i + 3] & (~3)); 85 | 86 | UInt32 dest; 87 | if (encoding) 88 | dest = ip + (UInt32)i + src; 89 | else 90 | dest = src - (ip + (UInt32)i); 91 | data[i + 0] = (Byte)(0x48 | ((dest >> 24) & 0x3)); 92 | data[i + 1] = (Byte)(dest >> 16); 93 | data[i + 2] = (Byte)(dest >> 8); 94 | data[i + 3] &= 0x3; 95 | data[i + 3] |= dest; 96 | } 97 | } 98 | return i; 99 | } 100 | 101 | SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 102 | { 103 | UInt32 i; 104 | if (size < 4) 105 | return 0; 106 | size -= 4; 107 | for (i = 0; i <= size; i += 4) 108 | { 109 | if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || 110 | (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) 111 | { 112 | UInt32 src = 113 | ((UInt32)data[i + 0] << 24) | 114 | ((UInt32)data[i + 1] << 16) | 115 | ((UInt32)data[i + 2] << 8) | 116 | ((UInt32)data[i + 3]); 117 | UInt32 dest; 118 | 119 | src <<= 2; 120 | if (encoding) 121 | dest = ip + i + src; 122 | else 123 | dest = src - (ip + i); 124 | dest >>= 2; 125 | 126 | dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; 127 | 128 | data[i + 0] = (Byte)(dest >> 24); 129 | data[i + 1] = (Byte)(dest >> 16); 130 | data[i + 2] = (Byte)(dest >> 8); 131 | data[i + 3] = (Byte)dest; 132 | } 133 | } 134 | return i; 135 | } 136 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/7zCrcOpt.c: -------------------------------------------------------------------------------- 1 | /* 7zCrcOpt.c -- CRC32 calculation 2 | 2015-03-01 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | #include 6 | 7 | #ifndef MY_CPU_BE 8 | 9 | #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 10 | 11 | UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) 12 | { 13 | const Byte *p = (const Byte *)data; 14 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 15 | v = CRC_UPDATE_BYTE_2(v, *p); 16 | for (; size >= 4; size -= 4, p += 4) 17 | { 18 | v ^= *(const UInt32 *)p; 19 | v = 20 | table[0x300 + ((v ) & 0xFF)] 21 | ^ table[0x200 + ((v >> 8) & 0xFF)] 22 | ^ table[0x100 + ((v >> 16) & 0xFF)] 23 | ^ table[0x000 + ((v >> 24))]; 24 | } 25 | for (; size > 0; size--, p++) 26 | v = CRC_UPDATE_BYTE_2(v, *p); 27 | return v; 28 | } 29 | 30 | UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table) 31 | { 32 | const Byte *p = (const Byte *)data; 33 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) 34 | v = CRC_UPDATE_BYTE_2(v, *p); 35 | for (; size >= 8; size -= 8, p += 8) 36 | { 37 | UInt32 d; 38 | v ^= *(const UInt32 *)p; 39 | v = 40 | table[0x700 + ((v ) & 0xFF)] 41 | ^ table[0x600 + ((v >> 8) & 0xFF)] 42 | ^ table[0x500 + ((v >> 16) & 0xFF)] 43 | ^ table[0x400 + ((v >> 24))]; 44 | d = *((const UInt32 *)p + 1); 45 | v ^= 46 | table[0x300 + ((d ) & 0xFF)] 47 | ^ table[0x200 + ((d >> 8) & 0xFF)] 48 | ^ table[0x100 + ((d >> 16) & 0xFF)] 49 | ^ table[0x000 + ((d >> 24))]; 50 | } 51 | for (; size > 0; size--, p++) 52 | v = CRC_UPDATE_BYTE_2(v, *p); 53 | return v; 54 | } 55 | 56 | #endif 57 | 58 | 59 | #ifndef MY_CPU_LE 60 | 61 | #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) 62 | 63 | #define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(((crc) >> 24) ^ (b))] ^ ((crc) << 8)) 64 | 65 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table) 66 | { 67 | const Byte *p = (const Byte *)data; 68 | table += 0x100; 69 | v = CRC_UINT32_SWAP(v); 70 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 71 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 72 | for (; size >= 4; size -= 4, p += 4) 73 | { 74 | v ^= *(const UInt32 *)p; 75 | v = 76 | table[0x000 + ((v ) & 0xFF)] 77 | ^ table[0x100 + ((v >> 8) & 0xFF)] 78 | ^ table[0x200 + ((v >> 16) & 0xFF)] 79 | ^ table[0x300 + ((v >> 24))]; 80 | } 81 | for (; size > 0; size--, p++) 82 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 83 | return CRC_UINT32_SWAP(v); 84 | } 85 | 86 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table) 87 | { 88 | const Byte *p = (const Byte *)data; 89 | table += 0x100; 90 | v = CRC_UINT32_SWAP(v); 91 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) 92 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 93 | for (; size >= 8; size -= 8, p += 8) 94 | { 95 | UInt32 d; 96 | v ^= *(const UInt32 *)p; 97 | v = 98 | table[0x400 + ((v ) & 0xFF)] 99 | ^ table[0x500 + ((v >> 8) & 0xFF)] 100 | ^ table[0x600 + ((v >> 16) & 0xFF)] 101 | ^ table[0x700 + ((v >> 24))]; 102 | d = *((const UInt32 *)p + 1); 103 | v ^= 104 | table[0x000 + ((d ) & 0xFF)] 105 | ^ table[0x100 + ((d >> 8) & 0xFF)] 106 | ^ table[0x200 + ((d >> 16) & 0xFF)] 107 | ^ table[0x300 + ((d >> 24))]; 108 | } 109 | for (; size > 0; size--, p++) 110 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 111 | return CRC_UINT32_SWAP(v); 112 | } 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Bcj2.h: -------------------------------------------------------------------------------- 1 | /* Bcj2.h -- BCJ2 Converter for x86 code 2 | 2014-11-10 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __BCJ2_H 5 | #define __BCJ2_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define BCJ2_NUM_STREAMS 4 12 | 13 | enum 14 | { 15 | BCJ2_STREAM_MAIN, 16 | BCJ2_STREAM_CALL, 17 | BCJ2_STREAM_JUMP, 18 | BCJ2_STREAM_RC 19 | }; 20 | 21 | enum 22 | { 23 | BCJ2_DEC_STATE_ORIG_0 = BCJ2_NUM_STREAMS, 24 | BCJ2_DEC_STATE_ORIG_1, 25 | BCJ2_DEC_STATE_ORIG_2, 26 | BCJ2_DEC_STATE_ORIG_3, 27 | 28 | BCJ2_DEC_STATE_ORIG, 29 | BCJ2_DEC_STATE_OK 30 | }; 31 | 32 | enum 33 | { 34 | BCJ2_ENC_STATE_ORIG = BCJ2_NUM_STREAMS, 35 | BCJ2_ENC_STATE_OK 36 | }; 37 | 38 | 39 | #define BCJ2_IS_32BIT_STREAM(s) ((s) == BCJ2_STREAM_CALL || (s) == BCJ2_STREAM_JUMP) 40 | 41 | /* 42 | CBcj2Dec / CBcj2Enc 43 | bufs sizes: 44 | BUF_SIZE(n) = lims[n] - bufs[n] 45 | bufs sizes for BCJ2_STREAM_CALL and BCJ2_STREAM_JUMP must be mutliply of 4: 46 | (BUF_SIZE(BCJ2_STREAM_CALL) & 3) == 0 47 | (BUF_SIZE(BCJ2_STREAM_JUMP) & 3) == 0 48 | */ 49 | 50 | /* 51 | CBcj2Dec: 52 | dest is allowed to overlap with bufs[BCJ2_STREAM_MAIN], with the following conditions: 53 | bufs[BCJ2_STREAM_MAIN] >= dest && 54 | bufs[BCJ2_STREAM_MAIN] - dest >= tempReserv + 55 | BUF_SIZE(BCJ2_STREAM_CALL) + 56 | BUF_SIZE(BCJ2_STREAM_JUMP) 57 | tempReserv = 0 : for first call of Bcj2Dec_Decode 58 | tempReserv = 4 : for any other calls of Bcj2Dec_Decode 59 | overlap with offset = 1 is not allowed 60 | */ 61 | 62 | typedef struct 63 | { 64 | const Byte *bufs[BCJ2_NUM_STREAMS]; 65 | const Byte *lims[BCJ2_NUM_STREAMS]; 66 | Byte *dest; 67 | const Byte *destLim; 68 | 69 | unsigned state; /* BCJ2_STREAM_MAIN has more priority than BCJ2_STATE_ORIG */ 70 | 71 | UInt32 ip; 72 | Byte temp[4]; 73 | UInt32 range; 74 | UInt32 code; 75 | UInt16 probs[2 + 256]; 76 | } CBcj2Dec; 77 | 78 | void Bcj2Dec_Init(CBcj2Dec *p); 79 | 80 | /* Returns: SZ_OK or SZ_ERROR_DATA */ 81 | SRes Bcj2Dec_Decode(CBcj2Dec *p); 82 | 83 | #define Bcj2Dec_IsFinished(_p_) ((_p_)->code == 0) 84 | 85 | 86 | 87 | typedef enum 88 | { 89 | BCJ2_ENC_FINISH_MODE_CONTINUE, 90 | BCJ2_ENC_FINISH_MODE_END_BLOCK, 91 | BCJ2_ENC_FINISH_MODE_END_STREAM 92 | } EBcj2Enc_FinishMode; 93 | 94 | typedef struct 95 | { 96 | Byte *bufs[BCJ2_NUM_STREAMS]; 97 | const Byte *lims[BCJ2_NUM_STREAMS]; 98 | const Byte *src; 99 | const Byte *srcLim; 100 | 101 | unsigned state; 102 | EBcj2Enc_FinishMode finishMode; 103 | 104 | Byte prevByte; 105 | 106 | Byte cache; 107 | UInt32 range; 108 | UInt64 low; 109 | UInt64 cacheSize; 110 | 111 | UInt32 ip; 112 | 113 | /* 32-bit ralative offset in JUMP/CALL commands is 114 | - (mod 4 GB) in 32-bit mode 115 | - signed Int32 in 64-bit mode 116 | We use (mod 4 GB) check for fileSize. 117 | Use fileSize up to 2 GB, if you want to support 32-bit and 64-bit code conversion. */ 118 | UInt32 fileIp; 119 | UInt32 fileSize; /* (fileSize <= ((UInt32)1 << 31)), 0 means no_limit */ 120 | UInt32 relatLimit; /* (relatLimit <= ((UInt32)1 << 31)), 0 means desable_conversion */ 121 | 122 | UInt32 tempTarget; 123 | unsigned tempPos; 124 | Byte temp[4 * 2]; 125 | 126 | unsigned flushPos; 127 | 128 | UInt16 probs[2 + 256]; 129 | } CBcj2Enc; 130 | 131 | void Bcj2Enc_Init(CBcj2Enc *p); 132 | void Bcj2Enc_Encode(CBcj2Enc *p); 133 | 134 | #define Bcj2Enc_Get_InputData_Size(p) ((SizeT)((p)->srcLim - (p)->src) + (p)->tempPos) 135 | #define Bcj2Enc_IsFinished(p) ((p)->flushPos == 5) 136 | 137 | 138 | #define BCJ2_RELAT_LIMIT_NUM_BITS 26 139 | #define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS) 140 | 141 | /* limit for CBcj2Enc::fileSize variable */ 142 | #define BCJ2_FileSize_MAX ((UInt32)1 << 31) 143 | 144 | EXTERN_C_END 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/LzFind.h: -------------------------------------------------------------------------------- 1 | /* LzFind.h -- Match finder for LZ algorithms 2 | 2015-10-15 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_FIND_H 5 | #define __LZ_FIND_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef UInt32 CLzRef; 12 | 13 | typedef struct _CMatchFinder 14 | { 15 | Byte *buffer; 16 | UInt32 pos; 17 | UInt32 posLimit; 18 | UInt32 streamPos; 19 | UInt32 lenLimit; 20 | 21 | UInt32 cyclicBufferPos; 22 | UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ 23 | 24 | Byte streamEndWasReached; 25 | Byte btMode; 26 | Byte bigHash; 27 | Byte directInput; 28 | 29 | UInt32 matchMaxLen; 30 | CLzRef *hash; 31 | CLzRef *son; 32 | UInt32 hashMask; 33 | UInt32 cutValue; 34 | 35 | Byte *bufferBase; 36 | ISeqInStream *stream; 37 | 38 | UInt32 blockSize; 39 | UInt32 keepSizeBefore; 40 | UInt32 keepSizeAfter; 41 | 42 | UInt32 numHashBytes; 43 | size_t directInputRem; 44 | UInt32 historySize; 45 | UInt32 fixedHashSize; 46 | UInt32 hashSizeSum; 47 | SRes result; 48 | UInt32 crc[256]; 49 | size_t numRefs; 50 | } CMatchFinder; 51 | 52 | #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) 53 | 54 | #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) 55 | 56 | #define Inline_MatchFinder_IsFinishedOK(p) \ 57 | ((p)->streamEndWasReached \ 58 | && (p)->streamPos == (p)->pos \ 59 | && (!(p)->directInput || (p)->directInputRem == 0)) 60 | 61 | int MatchFinder_NeedMove(CMatchFinder *p); 62 | Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); 63 | void MatchFinder_MoveBlock(CMatchFinder *p); 64 | void MatchFinder_ReadIfRequired(CMatchFinder *p); 65 | 66 | void MatchFinder_Construct(CMatchFinder *p); 67 | 68 | /* Conditions: 69 | historySize <= 3 GB 70 | keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB 71 | */ 72 | int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, 73 | UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, 74 | ISzAlloc *alloc); 75 | void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc); 76 | void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); 77 | void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); 78 | 79 | UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, 80 | UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, 81 | UInt32 *distances, UInt32 maxLen); 82 | 83 | /* 84 | Conditions: 85 | Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. 86 | Mf_GetPointerToCurrentPos_Func's result must be used only before any other function 87 | */ 88 | 89 | typedef void (*Mf_Init_Func)(void *object); 90 | typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); 91 | typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); 92 | typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); 93 | typedef void (*Mf_Skip_Func)(void *object, UInt32); 94 | 95 | typedef struct _IMatchFinder 96 | { 97 | Mf_Init_Func Init; 98 | Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; 99 | Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; 100 | Mf_GetMatches_Func GetMatches; 101 | Mf_Skip_Func Skip; 102 | } IMatchFinder; 103 | 104 | void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); 105 | 106 | void MatchFinder_Init_2(CMatchFinder *p, int readData); 107 | void MatchFinder_Init(CMatchFinder *p); 108 | 109 | UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); 110 | UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); 111 | 112 | void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); 113 | void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); 114 | 115 | EXTERN_C_END 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /tzf_dsound/ini.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__INI_H__ 23 | #define __TZF__INI_H__ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | // {B526D074-2F4D-4BAE-B6EC-11CB3779B199} 32 | static const GUID IID_SK_INISection = 33 | { 0xb526d074, 0x2f4d, 0x4bae, { 0xb6, 0xec, 0x11, 0xcb, 0x37, 0x79, 0xb1, 0x99 } }; 34 | 35 | interface iSK_INISection : public IUnknown 36 | { 37 | public: 38 | iSK_INISection (void) { 39 | AddRef (); 40 | } 41 | 42 | iSK_INISection (const wchar_t* section_name) { 43 | AddRef (); 44 | } 45 | 46 | ~iSK_INISection (void) { 47 | Release (); 48 | } 49 | 50 | /*** IUnknown methods ***/ 51 | STDMETHOD ( QueryInterface)(THIS_ REFIID riid, void** ppvObj) = 0; 52 | STDMETHOD_ (ULONG, AddRef) (THIS) = 0; 53 | STDMETHOD_ (ULONG, Release) (THIS) = 0; 54 | 55 | STDMETHOD_ (std::wstring&, get_value) (const wchar_t* key) = 0; 56 | STDMETHOD_ (void, set_name) (const wchar_t* name) = 0; 57 | STDMETHOD_ (bool, contains_key) (const wchar_t* key) = 0; 58 | STDMETHOD_ (void, add_key_value)(const wchar_t* key, const wchar_t* value) = 0; 59 | STDMETHOD_ (bool, remove_key) (const wchar_t* key) = 0; 60 | }; 61 | 62 | // {DD2B1E00-6C14-4659-8B45-FCEF1BC2C724} 63 | static const GUID IID_SK_INI = 64 | { 0xdd2b1e00, 0x6c14, 0x4659, { 0x8b, 0x45, 0xfc, 0xef, 0x1b, 0xc2, 0xc7, 0x24 } }; 65 | 66 | interface iSK_INI : public IUnknown 67 | { 68 | typedef const std::map _TSectionMap; 69 | 70 | iSK_INI (const wchar_t* filename) { 71 | AddRef (); 72 | }; 73 | 74 | virtual ~iSK_INI (void) { 75 | Release (); 76 | } 77 | 78 | /*** IUnknown methods ***/ 79 | STDMETHOD ( QueryInterface)(THIS_ REFIID riid, void** ppvObj) = 0; 80 | STDMETHOD_ (ULONG, AddRef) (THIS) = 0; 81 | STDMETHOD_ (ULONG, Release) (THIS) = 0; 82 | 83 | STDMETHOD_ (void, parse) (THIS) = 0; 84 | STDMETHOD_ (void, import) (THIS_ const wchar_t* import_data) = 0; 85 | STDMETHOD_ (void, write) (THIS_ const wchar_t* fname) = 0; 86 | 87 | STDMETHOD_ (_TSectionMap&, get_sections) (THIS) = 0; 88 | STDMETHOD_ (iSK_INISection&, get_section) (const wchar_t* section) = 0; 89 | STDMETHOD_ (bool, contains_section)(const wchar_t* section) = 0; 90 | STDMETHOD_ (bool, remove_section) (const wchar_t* section) = 0; 91 | 92 | STDMETHOD_ (iSK_INISection&, get_section_f) ( THIS_ _In_z_ _Printf_format_string_ 93 | wchar_t const* const _Format, 94 | ... ) = 0; 95 | }; 96 | 97 | iSK_INI* 98 | TZF_CreateINI (const wchar_t* const wszName); 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | /tzf_dsound.VC.VC.opendb 198 | /tzf_dsound.VC.db 199 | -------------------------------------------------------------------------------- /tzf_dsound/hook.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__HOOK_H__ 23 | #define __TZF__HOOK_H__ 24 | 25 | 26 | template 27 | _T 28 | TZF_ImportFunctionFromSpecialK ( const char* szName, 29 | _T fallback_fn ) 30 | { 31 | extern HMODULE hInjectorDLL; 32 | 33 | _T ret = 34 | reinterpret_cast <_T> ( 35 | GetProcAddress ( hInjectorDLL, 36 | szName ) 37 | ); 38 | 39 | return (ret == nullptr) ? fallback_fn : 40 | ret; 41 | } 42 | 43 | 44 | // MinHook Error Codes. 45 | typedef enum MH_STATUS 46 | { 47 | // Unknown error. Should not be returned. 48 | MH_UNKNOWN = -1, 49 | 50 | // Successful. 51 | MH_OK = 0, 52 | 53 | // MinHook is already initialized. 54 | MH_ERROR_ALREADY_INITIALIZED, 55 | 56 | // MinHook is not initialized yet, or already uninitialized. 57 | MH_ERROR_NOT_INITIALIZED, 58 | 59 | // The hook for the specified target function is already created. 60 | MH_ERROR_ALREADY_CREATED, 61 | 62 | // The hook for the specified target function is not created yet. 63 | MH_ERROR_NOT_CREATED, 64 | 65 | // The hook for the specified target function is already enabled. 66 | MH_ERROR_ENABLED, 67 | 68 | // The hook for the specified target function is not enabled yet, or already 69 | // disabled. 70 | MH_ERROR_DISABLED, 71 | 72 | // The specified pointer is invalid. It points the address of non-allocated 73 | // and/or non-executable region. 74 | MH_ERROR_NOT_EXECUTABLE, 75 | 76 | // The specified target function cannot be hooked. 77 | MH_ERROR_UNSUPPORTED_FUNCTION, 78 | 79 | // Failed to allocate memory. 80 | MH_ERROR_MEMORY_ALLOC, 81 | 82 | // Failed to change the memory protection. 83 | MH_ERROR_MEMORY_PROTECT, 84 | 85 | // The specified module is not loaded. 86 | MH_ERROR_MODULE_NOT_FOUND, 87 | 88 | // The specified function is not found. 89 | MH_ERROR_FUNCTION_NOT_FOUND 90 | } 91 | MH_STATUS; 92 | 93 | typedef const char* LPCSTR; 94 | typedef const wchar_t* LPCWSTR; 95 | typedef void* LPVOID; 96 | 97 | MH_STATUS 98 | __stdcall 99 | TZF_CreateFuncHook ( LPCWSTR pwszFuncName, 100 | LPVOID pTarget, 101 | LPVOID pDetour, 102 | LPVOID *ppOriginal ); 103 | 104 | MH_STATUS 105 | __stdcall 106 | TZF_CreateDLLHook ( LPCWSTR pwszModule, LPCSTR pszProcName, 107 | LPVOID pDetour, LPVOID *ppOriginal, 108 | LPVOID* ppFuncAddr = nullptr ); 109 | 110 | MH_STATUS 111 | __stdcall 112 | TZF_CreateDLLHook2 ( LPCWSTR pwszModule, LPCSTR pszProcName, 113 | LPVOID pDetour, LPVOID *ppOriginal, 114 | LPVOID* ppFuncAddr = nullptr ); 115 | 116 | MH_STATUS 117 | __stdcall 118 | TZF_EnableHook (LPVOID pTarget); 119 | 120 | MH_STATUS 121 | __stdcall 122 | TZF_DisableHook (LPVOID pTarget); 123 | 124 | MH_STATUS 125 | __stdcall 126 | TZF_RemoveHook (LPVOID pTarget); 127 | 128 | MH_STATUS 129 | __stdcall 130 | TZF_ApplyQueuedHooks (void); 131 | 132 | MH_STATUS 133 | __stdcall 134 | TZF_Init_MinHook (void); 135 | 136 | MH_STATUS 137 | __stdcall 138 | TZF_UnInit_MinHook (void); 139 | 140 | #endif __TZF__HOOK_H__ -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/Ppmd7.h: -------------------------------------------------------------------------------- 1 | /* Ppmd7.h -- PPMdH compression codec 2 | 2016-05-21 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | /* This code supports virtual RangeDecoder and includes the implementation 6 | of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H. 7 | If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */ 8 | 9 | #ifndef __PPMD7_H 10 | #define __PPMD7_H 11 | 12 | #include "Ppmd.h" 13 | 14 | EXTERN_C_BEGIN 15 | 16 | #define PPMD7_MIN_ORDER 2 17 | #define PPMD7_MAX_ORDER 64 18 | 19 | #define PPMD7_MIN_MEM_SIZE (1 << 11) 20 | #define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3) 21 | 22 | struct CPpmd7_Context_; 23 | 24 | typedef 25 | #ifdef PPMD_32BIT 26 | struct CPpmd7_Context_ * 27 | #else 28 | UInt32 29 | #endif 30 | CPpmd7_Context_Ref; 31 | 32 | typedef struct CPpmd7_Context_ 33 | { 34 | UInt16 NumStats; 35 | UInt16 SummFreq; 36 | CPpmd_State_Ref Stats; 37 | CPpmd7_Context_Ref Suffix; 38 | } CPpmd7_Context; 39 | 40 | #define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq) 41 | 42 | typedef struct 43 | { 44 | CPpmd7_Context *MinContext, *MaxContext; 45 | CPpmd_State *FoundState; 46 | unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag; 47 | Int32 RunLength, InitRL; /* must be 32-bit at least */ 48 | 49 | UInt32 Size; 50 | UInt32 GlueCount; 51 | Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; 52 | UInt32 AlignOffset; 53 | 54 | Byte Indx2Units[PPMD_NUM_INDEXES]; 55 | Byte Units2Indx[128]; 56 | CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; 57 | Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256]; 58 | CPpmd_See DummySee, See[25][16]; 59 | UInt16 BinSumm[128][64]; 60 | } CPpmd7; 61 | 62 | void Ppmd7_Construct(CPpmd7 *p); 63 | Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc); 64 | void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc); 65 | void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder); 66 | #define Ppmd7_WasAllocated(p) ((p)->Base != NULL) 67 | 68 | 69 | /* ---------- Internal Functions ---------- */ 70 | 71 | extern const Byte PPMD7_kExpEscape[16]; 72 | 73 | #ifdef PPMD_32BIT 74 | #define Ppmd7_GetPtr(p, ptr) (ptr) 75 | #define Ppmd7_GetContext(p, ptr) (ptr) 76 | #define Ppmd7_GetStats(p, ctx) ((ctx)->Stats) 77 | #else 78 | #define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs))) 79 | #define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs))) 80 | #define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats))) 81 | #endif 82 | 83 | void Ppmd7_Update1(CPpmd7 *p); 84 | void Ppmd7_Update1_0(CPpmd7 *p); 85 | void Ppmd7_Update2(CPpmd7 *p); 86 | void Ppmd7_UpdateBin(CPpmd7 *p); 87 | 88 | #define Ppmd7_GetBinSumm(p) \ 89 | &p->BinSumm[(unsigned)Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \ 90 | p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \ 91 | (p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \ 92 | 2 * p->HB2Flag[(unsigned)Ppmd7Context_OneState(p->MinContext)->Symbol] + \ 93 | ((p->RunLength >> 26) & 0x20)] 94 | 95 | CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); 96 | 97 | 98 | /* ---------- Decode ---------- */ 99 | 100 | typedef struct 101 | { 102 | UInt32 (*GetThreshold)(void *p, UInt32 total); 103 | void (*Decode)(void *p, UInt32 start, UInt32 size); 104 | UInt32 (*DecodeBit)(void *p, UInt32 size0); 105 | } IPpmd7_RangeDec; 106 | 107 | typedef struct 108 | { 109 | IPpmd7_RangeDec p; 110 | UInt32 Range; 111 | UInt32 Code; 112 | IByteIn *Stream; 113 | } CPpmd7z_RangeDec; 114 | 115 | void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p); 116 | Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p); 117 | #define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0) 118 | 119 | int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc); 120 | 121 | 122 | /* ---------- Encode ---------- */ 123 | 124 | typedef struct 125 | { 126 | UInt64 Low; 127 | UInt32 Range; 128 | Byte Cache; 129 | UInt64 CacheSize; 130 | IByteOut *Stream; 131 | } CPpmd7z_RangeEnc; 132 | 133 | void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p); 134 | void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p); 135 | 136 | void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol); 137 | 138 | EXTERN_C_END 139 | 140 | #endif 141 | -------------------------------------------------------------------------------- /tzf_dsound/config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__CONFIG_H__ 23 | #define __TZF__CONFIG_H__ 24 | 25 | #include 26 | #include 27 | 28 | extern std::wstring TZF_VER_STR; 29 | extern std::wstring DEFAULT_BK2; 30 | 31 | struct tzf_config_t 32 | { 33 | struct { 34 | uint32_t sample_hz = 48000; 35 | uint32_t channels = 8; // OBSOLETE 36 | bool compatibility = false; 37 | bool enable_fix = true; 38 | } audio; 39 | 40 | struct { 41 | bool yield_processor = true; 42 | bool allow_fake_sleep = false; 43 | bool minimize_latency = false; 44 | DWORD speedresetcode_addr = 0x0046C0F9; //0x0046C529; 45 | DWORD speedresetcode2_addr = 0x0056EB41; //0x0056E441; 0x217B464 46 | DWORD speedresetcode3_addr = 0x0056E03F; //0x0056D93F; 47 | DWORD limiter_branch_addr = 0x00990F53; //0x00990873; 48 | bool disable_limiter = true; 49 | bool auto_adjust = false; 50 | int target = 60; 51 | int battle_target = 60; 52 | bool battle_adaptive = false; 53 | int cutscene_target = 30; 54 | } framerate; 55 | 56 | struct { 57 | bool capture = false; 58 | } file_io; 59 | 60 | struct { 61 | bool allow_broadcasts = false; 62 | } steam; 63 | 64 | struct { 65 | bool fix_priest = true; 66 | } lua; 67 | 68 | struct { 69 | float fovy = 0.785398f; 70 | float aspect_ratio = 1.777778f; 71 | DWORD aspect_addr = 0x00D56494;//0x00D52398; 72 | DWORD fovy_addr = 0x00D56498;//0x00D5239C; 73 | bool blackbar_videos = true; // OBSOLETE 74 | bool aspect_correction = true; 75 | int32_t shadow_rescale = -2; 76 | float postproc_ratio = 1.0f; 77 | bool clear_blackbars = true; 78 | int32_t env_shadow_rescale = 0; 79 | bool dump_shaders = false; 80 | bool auto_apply_changes = false; 81 | bool osd_disclaimer = true; 82 | } render; 83 | 84 | struct { 85 | bool dump = false; 86 | bool remaster = false; 87 | bool cache = true; 88 | int32_t max_cache_in_mib = 2048L; 89 | int32_t worker_threads = 6; 90 | bool show_loading_text = true; 91 | float lod_bias = 0.0f; 92 | std::wstring 93 | gamepad = L"Xbox360"; 94 | bool on_demand_dump = false; 95 | bool highlight_debug_tex = true; 96 | } textures; 97 | 98 | struct { 99 | struct { 100 | float scale = 1.0f; 101 | bool never_show_eula = false; 102 | } ui; 103 | } input; 104 | 105 | struct { 106 | bool visible = false; 107 | } control_panel; 108 | 109 | struct { 110 | std::wstring swap_keys = L""; 111 | } keyboard; 112 | 113 | struct { 114 | std::wstring 115 | version = TZF_VER_STR; 116 | std::wstring 117 | intro_video = DEFAULT_BK2; 118 | std::wstring 119 | injector = L"d3d9.dll"; 120 | } system; 121 | }; 122 | 123 | extern tzf_config_t config; 124 | 125 | bool TZF_LoadConfig (std::wstring name = L"tzfix"); 126 | void TZF_SaveConfig (std::wstring name = L"tzfix", 127 | bool close_config = false); 128 | 129 | #endif __TZF__CONFIG_H__ -------------------------------------------------------------------------------- /tzf_dsound/keyboard.cpp: -------------------------------------------------------------------------------- 1 | #include "keyboard.h" 2 | #include 3 | 4 | #include "hook.h" 5 | #include "config.h" 6 | 7 | extern "C" { 8 | typedef int (__cdecl *SDL_GetKeyFromScancode_pfn)(int scancode); 9 | SDL_GetKeyFromScancode_pfn SDL_GetKeyFromScancode_Original = nullptr; 10 | 11 | typedef uint8_t* (__cdecl *SDL_GetKeyboardState_pfn)(int* numkeys); 12 | SDL_GetKeyboardState_pfn SDL_GetKeyboardState_Original = nullptr; 13 | 14 | const uint8_t* 15 | __cdecl 16 | SDL_GetKeyboardState_Detour (int *numkeys) 17 | { 18 | int num_keys; 19 | 20 | uint8_t* out = SDL_GetKeyboardState_Original (&num_keys); 21 | 22 | if (numkeys != nullptr) 23 | *numkeys = num_keys; 24 | 25 | static uint8_t keys [512]; 26 | memcpy (keys, out, sizeof (uint8_t) * num_keys); 27 | 28 | std::vector >::iterator it = 29 | tzf::KeyboardFix::swapped_keys.begin (); 30 | 31 | while (it != tzf::KeyboardFix::swapped_keys.end ()) { 32 | keys [it->first] = out [it->second]; 33 | keys [it->second] = out [it->first]; 34 | ++it; 35 | } 36 | 37 | return keys; 38 | } 39 | 40 | int 41 | __cdecl 42 | SDL_GetKeyFromScancode_Detour (int scancode) 43 | { 44 | if (tzf::KeyboardFix::remapped_scancodes.find (scancode) == 45 | tzf::KeyboardFix::remapped_scancodes.end ()) { 46 | return SDL_GetKeyFromScancode_Original (scancode); 47 | } else { 48 | std::vector >::iterator it = 49 | tzf::KeyboardFix::swapped_keys.begin (); 50 | 51 | while (it != tzf::KeyboardFix::swapped_keys.end ()) { 52 | if (it->first == scancode) 53 | return SDL_GetKeyFromScancode_Original (it->second); 54 | else if (it->second == scancode) 55 | return SDL_GetKeyFromScancode_Original (it->first); 56 | ++it; 57 | } 58 | } 59 | 60 | // This should never happen, but ... just in case. 61 | return 0; 62 | } 63 | } 64 | 65 | 66 | #include "log.h" 67 | 68 | void 69 | tzf::KeyboardFix::Init (void) 70 | { 71 | // Don't even hook this stuff if no keyboard remapping is requested. 72 | if (config.keyboard.swap_keys.empty ()) 73 | return; 74 | 75 | wchar_t* pairs = _wcsdup (config.keyboard.swap_keys.c_str ()); 76 | wchar_t* orig = pairs; 77 | 78 | size_t len = wcslen (pairs); 79 | size_t remaining = len; 80 | 81 | TZF_CreateDLLHook2 ( L"SDL2.dll", "SDL_GetKeyFromScancode", 82 | SDL_GetKeyFromScancode_Detour, 83 | (LPVOID *)&SDL_GetKeyFromScancode_Original ); 84 | 85 | TZF_CreateDLLHook2 ( L"SDL2.dll", "SDL_GetKeyboardState", 86 | SDL_GetKeyboardState_Detour, 87 | (LPVOID *)&SDL_GetKeyboardState_Original ); 88 | 89 | // Parse the swap pairs 90 | while (remaining > 0 && remaining <= len) { 91 | wchar_t* wszSwapPair = pairs; 92 | 93 | size_t pair_len = wcscspn (pairs, L","); 94 | 95 | remaining -= (pair_len + 1); 96 | pairs += (pair_len); 97 | 98 | *(pairs++) = L'\0'; 99 | 100 | size_t sep = wcscspn (wszSwapPair, L"-"); 101 | 102 | *(wszSwapPair + sep) = L'\0'; 103 | 104 | wchar_t* wszSwapFirst = wszSwapPair; 105 | int16_t first = _wtoi (wszSwapFirst); 106 | 107 | wchar_t* wszSwapSecond = (wszSwapPair + sep + 1); 108 | int16_t second = _wtoi (wszSwapSecond); 109 | 110 | if (remapped_scancodes.find (first) == remapped_scancodes.end () && 111 | remapped_scancodes.find (second) == remapped_scancodes.end ()) { 112 | remapped_scancodes.insert (first); 113 | remapped_scancodes.insert (second); 114 | 115 | swapped_keys.push_back (std::pair (first, second)); 116 | 117 | dll_log->Log (L"[ Keyboard ] # SDL Scancode Swap: (%i <-> %i)", first, second); 118 | } else { 119 | // Do not allow multiple remapping 120 | dll_log->Log ( L"[ Keyboard ] @ SDL Scancode Remapped Multiple Times! -- (%i <-> %i)", 121 | first, 122 | second ); 123 | } 124 | } 125 | 126 | // Free the copied string 127 | free (orig); 128 | } 129 | 130 | void 131 | tzf::KeyboardFix::Shutdown (void) 132 | { 133 | } 134 | 135 | std::set tzf::KeyboardFix::remapped_scancodes; 136 | std::vector > tzf::KeyboardFix::swapped_keys; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TZF 2 | Tales of Zestiria "Fix" - Community Patch 3 | 4 | Copyright (c) 2015-2016 5 | 6 | Andon "Kaldaien" Coleman, 7 | Niklas "DrDaxxy" Kielblock, 8 | Peter "Durante" Thoman 9 | 10 | All Rights Reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions 14 | are met: 15 | 16 | 1. Redistributions of source code must retain the above copyright 17 | notice, this list of conditions and the following disclaimer. 18 | 2. Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 26 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | 35 | Portions Copyright (c) 2009-2015 Tsuda Kageyu 36 | --- 37 | 38 | MinHook - The Minimalistic API Hooking Library for x64/x86 39 | Copyright (C) 2009-2015 Tsuda Kageyu. 40 | All rights reserved. 41 | 42 | Redistribution and use in source and binary forms, with or without 43 | modification, are permitted provided that the following conditions 44 | are met: 45 | 46 | 1. Redistributions of source code must retain the above copyright 47 | notice, this list of conditions and the following disclaimer. 48 | 2. Redistributions in binary form must reproduce the above copyright 49 | notice, this list of conditions and the following disclaimer in the 50 | documentation and/or other materials provided with the distribution. 51 | 52 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 53 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 54 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 55 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 56 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 57 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 58 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 59 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 60 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 61 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 62 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 63 | 64 | ================================================================================ 65 | Portions of this software are Copyright (c) 2008-2009, Vyacheslav Patkov. 66 | ================================================================================ 67 | Hacker Disassembler Engine 32 C 68 | Copyright (c) 2008-2009, Vyacheslav Patkov. 69 | All rights reserved. 70 | 71 | Redistribution and use in source and binary forms, with or without 72 | modification, are permitted provided that the following conditions 73 | are met: 74 | 75 | 1. Redistributions of source code must retain the above copyright 76 | notice, this list of conditions and the following disclaimer. 77 | 2. Redistributions in binary form must reproduce the above copyright 78 | notice, this list of conditions and the following disclaimer in the 79 | documentation and/or other materials provided with the distribution. 80 | 81 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 82 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 83 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 84 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 85 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 86 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 87 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 88 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 89 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 90 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 91 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 92 | -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/LzmaLib.h: -------------------------------------------------------------------------------- 1 | /* LzmaLib.h -- LZMA library interface 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA_LIB_H 5 | #define __LZMA_LIB_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define MY_STDAPI int MY_STD_CALL 12 | 13 | #define LZMA_PROPS_SIZE 5 14 | 15 | /* 16 | RAM requirements for LZMA: 17 | for compression: (dictSize * 11.5 + 6 MB) + state_size 18 | for decompression: dictSize + state_size 19 | state_size = (4 + (1.5 << (lc + lp))) KB 20 | by default (lc=3, lp=0), state_size = 16 KB. 21 | 22 | LZMA properties (5 bytes) format 23 | Offset Size Description 24 | 0 1 lc, lp and pb in encoded form. 25 | 1 4 dictSize (little endian). 26 | */ 27 | 28 | /* 29 | LzmaCompress 30 | ------------ 31 | 32 | outPropsSize - 33 | In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. 34 | Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. 35 | 36 | LZMA Encoder will use defult values for any parameter, if it is 37 | -1 for any from: level, loc, lp, pb, fb, numThreads 38 | 0 for dictSize 39 | 40 | level - compression level: 0 <= level <= 9; 41 | 42 | level dictSize algo fb 43 | 0: 16 KB 0 32 44 | 1: 64 KB 0 32 45 | 2: 256 KB 0 32 46 | 3: 1 MB 0 32 47 | 4: 4 MB 0 32 48 | 5: 16 MB 1 32 49 | 6: 32 MB 1 32 50 | 7+: 64 MB 1 64 51 | 52 | The default value for "level" is 5. 53 | 54 | algo = 0 means fast method 55 | algo = 1 means normal method 56 | 57 | dictSize - The dictionary size in bytes. The maximum value is 58 | 128 MB = (1 << 27) bytes for 32-bit version 59 | 1 GB = (1 << 30) bytes for 64-bit version 60 | The default value is 16 MB = (1 << 24) bytes. 61 | It's recommended to use the dictionary that is larger than 4 KB and 62 | that can be calculated as (1 << N) or (3 << N) sizes. 63 | 64 | lc - The number of literal context bits (high bits of previous literal). 65 | It can be in the range from 0 to 8. The default value is 3. 66 | Sometimes lc=4 gives the gain for big files. 67 | 68 | lp - The number of literal pos bits (low bits of current position for literals). 69 | It can be in the range from 0 to 4. The default value is 0. 70 | The lp switch is intended for periodical data when the period is equal to 2^lp. 71 | For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's 72 | better to set lc=0, if you change lp switch. 73 | 74 | pb - The number of pos bits (low bits of current position). 75 | It can be in the range from 0 to 4. The default value is 2. 76 | The pb switch is intended for periodical data when the period is equal 2^pb. 77 | 78 | fb - Word size (the number of fast bytes). 79 | It can be in the range from 5 to 273. The default value is 32. 80 | Usually, a big number gives a little bit better compression ratio and 81 | slower compression process. 82 | 83 | numThreads - The number of thereads. 1 or 2. The default value is 2. 84 | Fast mode (algo = 0) can use only 1 thread. 85 | 86 | Out: 87 | destLen - processed output size 88 | Returns: 89 | SZ_OK - OK 90 | SZ_ERROR_MEM - Memory allocation error 91 | SZ_ERROR_PARAM - Incorrect paramater 92 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 93 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 94 | */ 95 | 96 | MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, 97 | unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ 98 | int level, /* 0 <= level <= 9, default = 5 */ 99 | unsigned dictSize, /* default = (1 << 24) */ 100 | int lc, /* 0 <= lc <= 8, default = 3 */ 101 | int lp, /* 0 <= lp <= 4, default = 0 */ 102 | int pb, /* 0 <= pb <= 4, default = 2 */ 103 | int fb, /* 5 <= fb <= 273, default = 32 */ 104 | int numThreads /* 1 or 2, default = 2 */ 105 | ); 106 | 107 | /* 108 | LzmaUncompress 109 | -------------- 110 | In: 111 | dest - output data 112 | destLen - output data size 113 | src - input data 114 | srcLen - input data size 115 | Out: 116 | destLen - processed output size 117 | srcLen - processed input size 118 | Returns: 119 | SZ_OK - OK 120 | SZ_ERROR_DATA - Data error 121 | SZ_ERROR_MEM - Memory allocation arror 122 | SZ_ERROR_UNSUPPORTED - Unsupported properties 123 | SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src) 124 | */ 125 | 126 | MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen, 127 | const unsigned char *props, size_t propsSize); 128 | 129 | EXTERN_C_END 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/7zStream.c: -------------------------------------------------------------------------------- 1 | /* 7zStream.c -- 7z Stream functions 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType) 11 | { 12 | while (size != 0) 13 | { 14 | size_t processed = size; 15 | RINOK(stream->Read(stream, buf, &processed)); 16 | if (processed == 0) 17 | return errorType; 18 | buf = (void *)((Byte *)buf + processed); 19 | size -= processed; 20 | } 21 | return SZ_OK; 22 | } 23 | 24 | SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) 25 | { 26 | return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); 27 | } 28 | 29 | SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf) 30 | { 31 | size_t processed = 1; 32 | RINOK(stream->Read(stream, buf, &processed)); 33 | return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; 34 | } 35 | 36 | SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset) 37 | { 38 | Int64 t = offset; 39 | return stream->Seek(stream, &t, SZ_SEEK_SET); 40 | } 41 | 42 | SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) 43 | { 44 | const void *lookBuf; 45 | if (*size == 0) 46 | return SZ_OK; 47 | RINOK(stream->Look(stream, &lookBuf, size)); 48 | memcpy(buf, lookBuf, *size); 49 | return stream->Skip(stream, *size); 50 | } 51 | 52 | SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType) 53 | { 54 | while (size != 0) 55 | { 56 | size_t processed = size; 57 | RINOK(stream->Read(stream, buf, &processed)); 58 | if (processed == 0) 59 | return errorType; 60 | buf = (void *)((Byte *)buf + processed); 61 | size -= processed; 62 | } 63 | return SZ_OK; 64 | } 65 | 66 | SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) 67 | { 68 | return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); 69 | } 70 | 71 | static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) 72 | { 73 | SRes res = SZ_OK; 74 | CLookToRead *p = (CLookToRead *)pp; 75 | size_t size2 = p->size - p->pos; 76 | if (size2 == 0 && *size > 0) 77 | { 78 | p->pos = 0; 79 | size2 = LookToRead_BUF_SIZE; 80 | res = p->realStream->Read(p->realStream, p->buf, &size2); 81 | p->size = size2; 82 | } 83 | if (size2 < *size) 84 | *size = size2; 85 | *buf = p->buf + p->pos; 86 | return res; 87 | } 88 | 89 | static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) 90 | { 91 | SRes res = SZ_OK; 92 | CLookToRead *p = (CLookToRead *)pp; 93 | size_t size2 = p->size - p->pos; 94 | if (size2 == 0 && *size > 0) 95 | { 96 | p->pos = 0; 97 | if (*size > LookToRead_BUF_SIZE) 98 | *size = LookToRead_BUF_SIZE; 99 | res = p->realStream->Read(p->realStream, p->buf, size); 100 | size2 = p->size = *size; 101 | } 102 | if (size2 < *size) 103 | *size = size2; 104 | *buf = p->buf + p->pos; 105 | return res; 106 | } 107 | 108 | static SRes LookToRead_Skip(void *pp, size_t offset) 109 | { 110 | CLookToRead *p = (CLookToRead *)pp; 111 | p->pos += offset; 112 | return SZ_OK; 113 | } 114 | 115 | static SRes LookToRead_Read(void *pp, void *buf, size_t *size) 116 | { 117 | CLookToRead *p = (CLookToRead *)pp; 118 | size_t rem = p->size - p->pos; 119 | if (rem == 0) 120 | return p->realStream->Read(p->realStream, buf, size); 121 | if (rem > *size) 122 | rem = *size; 123 | memcpy(buf, p->buf + p->pos, rem); 124 | p->pos += rem; 125 | *size = rem; 126 | return SZ_OK; 127 | } 128 | 129 | static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin) 130 | { 131 | CLookToRead *p = (CLookToRead *)pp; 132 | p->pos = p->size = 0; 133 | return p->realStream->Seek(p->realStream, pos, origin); 134 | } 135 | 136 | void LookToRead_CreateVTable(CLookToRead *p, int lookahead) 137 | { 138 | p->s.Look = lookahead ? 139 | LookToRead_Look_Lookahead : 140 | LookToRead_Look_Exact; 141 | p->s.Skip = LookToRead_Skip; 142 | p->s.Read = LookToRead_Read; 143 | p->s.Seek = LookToRead_Seek; 144 | p->realStream = NULL; 145 | p->pos = 0; 146 | } 147 | 148 | void LookToRead_Init(CLookToRead *p) 149 | { 150 | p->pos = p->size = 0; 151 | } 152 | 153 | static SRes SecToLook_Read(void *pp, void *buf, size_t *size) 154 | { 155 | CSecToLook *p = (CSecToLook *)pp; 156 | return LookInStream_LookRead(p->realStream, buf, size); 157 | } 158 | 159 | void SecToLook_CreateVTable(CSecToLook *p) 160 | { 161 | p->realStream = NULL; 162 | p->s.Read = SecToLook_Read; 163 | } 164 | 165 | static SRes SecToRead_Read(void *pp, void *buf, size_t *size) 166 | { 167 | CSecToRead *p = (CSecToRead *)pp; 168 | return p->realStream->Read(p->realStream, buf, size); 169 | } 170 | 171 | void SecToRead_CreateVTable (CSecToRead *p) 172 | { 173 | p->s.Read = SecToRead_Read; 174 | p->realStream = NULL; 175 | } 176 | -------------------------------------------------------------------------------- /tzf_dsound/steam.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | 23 | #include 24 | 25 | #include "steam.h" 26 | #include "log.h" 27 | #include "config.h" 28 | #include "hook.h" 29 | 30 | #include 31 | 32 | HMODULE tzf::SteamFix::steam_dll = 0; 33 | 34 | typedef uint32_t AppId_t; 35 | 36 | class ISteamVideo 37 | { 38 | public: 39 | 40 | // Get a URL suitable for streaming the given Video app ID's video 41 | virtual void GetVideoURL( AppId_t unVideoAppID ) = 0; 42 | 43 | // returns true if user is uploading a live broadcast 44 | virtual bool IsBroadcasting( int *pnNumViewers ) = 0; 45 | }; 46 | 47 | enum { k_iClientVideoCallbacks = 4600 }; 48 | 49 | #define k_iClientVideo_BroadcastUploadStart (k_iClientVideoCallbacks + 4) 50 | 51 | class SteamVideoFake : public ISteamVideo { 52 | public: 53 | SteamVideoFake (ISteamVideo* real) : real_ (real) { }; 54 | 55 | // Get a URL suitable for streaming the given Video app ID's video 56 | virtual void GetVideoURL( AppId_t unVideoAppID ) { 57 | return real_->GetVideoURL (unVideoAppID); 58 | } 59 | 60 | // returns true if user is uploading a live broadcast 61 | virtual bool IsBroadcasting( int *pnNumViewers ) { 62 | *pnNumViewers = 0; 63 | return false; 64 | } 65 | 66 | protected: 67 | private: 68 | ISteamVideo* real_; 69 | }; 70 | 71 | SteamVideoFake* faker = nullptr; 72 | 73 | #define S_CALLTYPE __cdecl 74 | 75 | typedef ISteamVideo* (S_CALLTYPE *SteamVideo_t)(void); 76 | 77 | LPVOID SteamVideo = nullptr; 78 | SteamVideo_t SteamVideo_Original = nullptr; 79 | 80 | ISteamVideo* 81 | S_CALLTYPE 82 | SteamVideo_Detour (void) 83 | { 84 | ISteamVideo* pVideo = SteamVideo_Original (); 85 | 86 | int x; 87 | 88 | // Recent changes to SteamAPI store a non-zero value in the int* passed to 89 | // IsBroadcasting (...) even if the return is false. (4/17/17) 90 | // 91 | if (pVideo != nullptr /*&& pVideo->IsBroadcasting (&x) == true*/) { 92 | if (faker != nullptr) { 93 | delete faker; 94 | } 95 | 96 | faker = new SteamVideoFake (pVideo); 97 | 98 | return faker; 99 | } 100 | 101 | return pVideo; 102 | } 103 | 104 | 105 | void 106 | tzf::SteamFix::Init (void) 107 | { 108 | CommandProcessor* comm_proc = CommandProcessor::getInstance (); 109 | 110 | if (! config.steam.allow_broadcasts) 111 | return; 112 | 113 | steam_dll = LoadLibrary (L"steam_api.dll"); 114 | 115 | TZF_CreateDLLHook ( L"steam_api.dll", "SteamVideo", 116 | SteamVideo_Detour, 117 | (LPVOID *)&SteamVideo_Original, 118 | (LPVOID *)&SteamVideo ); 119 | 120 | TZF_EnableHook (SteamVideo); 121 | } 122 | 123 | void 124 | tzf::SteamFix::Shutdown (void) 125 | { 126 | if (! config.steam.allow_broadcasts) 127 | return; 128 | 129 | //TZF_RemoveHook (SteamVideo); 130 | 131 | FreeLibrary (steam_dll); 132 | } 133 | 134 | void 135 | tzf::SteamFix::SetOverlayState (bool active) 136 | { 137 | // Avoid duplicating a SK feature 138 | static HMODULE hD3D9 = GetModuleHandle (config.system.injector.c_str ()); 139 | 140 | typedef void (__stdcall *SK_SteamAPI_SetOverlayState_pfn)(bool); 141 | static SK_SteamAPI_SetOverlayState_pfn SK_SteamAPI_SetOverlayState = 142 | (SK_SteamAPI_SetOverlayState_pfn)GetProcAddress ( hD3D9, 143 | "SK_SteamAPI_SetOverlayState" ); 144 | 145 | SK_SteamAPI_SetOverlayState (active); 146 | } 147 | 148 | 149 | 150 | 151 | tzf::SteamFix::CommandProcessor::CommandProcessor (void) 152 | { 153 | SK_ICommandProcessor& command = 154 | *SK_GetCommandProcessor (); 155 | 156 | allow_broadcasts_ = TZF_CreateVar (SK_IVariable::Boolean, &config.steam.allow_broadcasts, this); 157 | 158 | command.AddVariable ("AllowBroadcasts", allow_broadcasts_); 159 | } 160 | 161 | bool 162 | tzf::SteamFix::CommandProcessor::OnVarChange (SK_IVariable* var, void* val) 163 | { 164 | if (var == allow_broadcasts_) { 165 | if (*(bool *)val == true) { 166 | config.steam.allow_broadcasts = true; 167 | SteamFix::Init (); 168 | } 169 | 170 | if (*(bool *)val == false) { 171 | SteamFix::Shutdown (); 172 | config.steam.allow_broadcasts = false; 173 | } 174 | } 175 | return true; 176 | } 177 | 178 | 179 | tzf::SteamFix::CommandProcessor* tzf::SteamFix::CommandProcessor::pCommProc; -------------------------------------------------------------------------------- /tzf_dsound/lzma/CpuArch.c: -------------------------------------------------------------------------------- 1 | /* CpuArch.c -- CPU specific code 2 | 2016-02-25: Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #ifdef MY_CPU_X86_OR_AMD64 9 | 10 | #if (defined(_MSC_VER) && !defined(MY_CPU_AMD64)) || defined(__GNUC__) 11 | #define USE_ASM 12 | #endif 13 | 14 | #if !defined(USE_ASM) && _MSC_VER >= 1500 15 | #include 16 | #endif 17 | 18 | #if defined(USE_ASM) && !defined(MY_CPU_AMD64) 19 | static UInt32 CheckFlag(UInt32 flag) 20 | { 21 | #ifdef _MSC_VER 22 | __asm pushfd; 23 | __asm pop EAX; 24 | __asm mov EDX, EAX; 25 | __asm xor EAX, flag; 26 | __asm push EAX; 27 | __asm popfd; 28 | __asm pushfd; 29 | __asm pop EAX; 30 | __asm xor EAX, EDX; 31 | __asm push EDX; 32 | __asm popfd; 33 | __asm and flag, EAX; 34 | #else 35 | __asm__ __volatile__ ( 36 | "pushf\n\t" 37 | "pop %%EAX\n\t" 38 | "movl %%EAX,%%EDX\n\t" 39 | "xorl %0,%%EAX\n\t" 40 | "push %%EAX\n\t" 41 | "popf\n\t" 42 | "pushf\n\t" 43 | "pop %%EAX\n\t" 44 | "xorl %%EDX,%%EAX\n\t" 45 | "push %%EDX\n\t" 46 | "popf\n\t" 47 | "andl %%EAX, %0\n\t": 48 | "=c" (flag) : "c" (flag) : 49 | "%eax", "%edx"); 50 | #endif 51 | return flag; 52 | } 53 | #define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False; 54 | #else 55 | #define CHECK_CPUID_IS_SUPPORTED 56 | #endif 57 | 58 | void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) 59 | { 60 | #ifdef USE_ASM 61 | 62 | #ifdef _MSC_VER 63 | 64 | UInt32 a2, b2, c2, d2; 65 | __asm xor EBX, EBX; 66 | __asm xor ECX, ECX; 67 | __asm xor EDX, EDX; 68 | __asm mov EAX, function; 69 | __asm cpuid; 70 | __asm mov a2, EAX; 71 | __asm mov b2, EBX; 72 | __asm mov c2, ECX; 73 | __asm mov d2, EDX; 74 | 75 | *a = a2; 76 | *b = b2; 77 | *c = c2; 78 | *d = d2; 79 | 80 | #else 81 | 82 | __asm__ __volatile__ ( 83 | #if defined(MY_CPU_AMD64) && defined(__PIC__) 84 | "mov %%rbx, %%rdi;" 85 | "cpuid;" 86 | "xchg %%rbx, %%rdi;" 87 | : "=a" (*a) , 88 | "=D" (*b) , 89 | #elif defined(MY_CPU_X86) && defined(__PIC__) 90 | "mov %%ebx, %%edi;" 91 | "cpuid;" 92 | "xchgl %%ebx, %%edi;" 93 | : "=a" (*a) , 94 | "=D" (*b) , 95 | #else 96 | "cpuid" 97 | : "=a" (*a) , 98 | "=b" (*b) , 99 | #endif 100 | "=c" (*c) , 101 | "=d" (*d) 102 | : "0" (function)) ; 103 | 104 | #endif 105 | 106 | #else 107 | 108 | int CPUInfo[4]; 109 | __cpuid(CPUInfo, function); 110 | *a = CPUInfo[0]; 111 | *b = CPUInfo[1]; 112 | *c = CPUInfo[2]; 113 | *d = CPUInfo[3]; 114 | 115 | #endif 116 | } 117 | 118 | Bool x86cpuid_CheckAndRead(Cx86cpuid *p) 119 | { 120 | CHECK_CPUID_IS_SUPPORTED 121 | MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]); 122 | MyCPUID(1, &p->ver, &p->b, &p->c, &p->d); 123 | return True; 124 | } 125 | 126 | static const UInt32 kVendors[][3] = 127 | { 128 | { 0x756E6547, 0x49656E69, 0x6C65746E}, 129 | { 0x68747541, 0x69746E65, 0x444D4163}, 130 | { 0x746E6543, 0x48727561, 0x736C7561} 131 | }; 132 | 133 | int x86cpuid_GetFirm(const Cx86cpuid *p) 134 | { 135 | unsigned i; 136 | for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++) 137 | { 138 | const UInt32 *v = kVendors[i]; 139 | if (v[0] == p->vendor[0] && 140 | v[1] == p->vendor[1] && 141 | v[2] == p->vendor[2]) 142 | return (int)i; 143 | } 144 | return -1; 145 | } 146 | 147 | Bool CPU_Is_InOrder() 148 | { 149 | Cx86cpuid p; 150 | int firm; 151 | UInt32 family, model; 152 | if (!x86cpuid_CheckAndRead(&p)) 153 | return True; 154 | 155 | family = x86cpuid_GetFamily(p.ver); 156 | model = x86cpuid_GetModel(p.ver); 157 | 158 | firm = x86cpuid_GetFirm(&p); 159 | 160 | switch (firm) 161 | { 162 | case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && ( 163 | /* In-Order Atom CPU */ 164 | model == 0x1C /* 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 */ 165 | || model == 0x26 /* 45 nm, Z6xx */ 166 | || model == 0x27 /* 32 nm, Z2460 */ 167 | || model == 0x35 /* 32 nm, Z2760 */ 168 | || model == 0x36 /* 32 nm, N2xxx, D2xxx */ 169 | ))); 170 | case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA))); 171 | case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF)); 172 | } 173 | return True; 174 | } 175 | 176 | #if !defined(MY_CPU_AMD64) && defined(_WIN32) 177 | #include 178 | static Bool CPU_Sys_Is_SSE_Supported() 179 | { 180 | OSVERSIONINFO vi; 181 | vi.dwOSVersionInfoSize = sizeof(vi); 182 | if (!GetVersionEx(&vi)) 183 | return False; 184 | return (vi.dwMajorVersion >= 5); 185 | } 186 | #define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False; 187 | #else 188 | #define CHECK_SYS_SSE_SUPPORT 189 | #endif 190 | 191 | Bool CPU_Is_Aes_Supported() 192 | { 193 | Cx86cpuid p; 194 | CHECK_SYS_SSE_SUPPORT 195 | if (!x86cpuid_CheckAndRead(&p)) 196 | return False; 197 | return (p.c >> 25) & 1; 198 | } 199 | 200 | #endif 201 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Ppmd7Enc.c: -------------------------------------------------------------------------------- 1 | /* Ppmd7Enc.c -- PPMdH Encoder 2 | 2015-09-28 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | #include 6 | 7 | #include 8 | 9 | #define kTopValue (1 << 24) 10 | 11 | void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p) 12 | { 13 | p->Low = 0; 14 | p->Range = 0xFFFFFFFF; 15 | p->Cache = 0; 16 | p->CacheSize = 1; 17 | } 18 | 19 | static void RangeEnc_ShiftLow(CPpmd7z_RangeEnc *p) 20 | { 21 | if ((UInt32)p->Low < (UInt32)0xFF000000 || (unsigned)(p->Low >> 32) != 0) 22 | { 23 | Byte temp = p->Cache; 24 | do 25 | { 26 | p->Stream->Write(p->Stream, (Byte)(temp + (Byte)(p->Low >> 32))); 27 | temp = 0xFF; 28 | } 29 | while (--p->CacheSize != 0); 30 | p->Cache = (Byte)((UInt32)p->Low >> 24); 31 | } 32 | p->CacheSize++; 33 | p->Low = (UInt32)p->Low << 8; 34 | } 35 | 36 | static void RangeEnc_Encode(CPpmd7z_RangeEnc *p, UInt32 start, UInt32 size, UInt32 total) 37 | { 38 | p->Low += start * (p->Range /= total); 39 | p->Range *= size; 40 | while (p->Range < kTopValue) 41 | { 42 | p->Range <<= 8; 43 | RangeEnc_ShiftLow(p); 44 | } 45 | } 46 | 47 | static void RangeEnc_EncodeBit_0(CPpmd7z_RangeEnc *p, UInt32 size0) 48 | { 49 | p->Range = (p->Range >> 14) * size0; 50 | while (p->Range < kTopValue) 51 | { 52 | p->Range <<= 8; 53 | RangeEnc_ShiftLow(p); 54 | } 55 | } 56 | 57 | static void RangeEnc_EncodeBit_1(CPpmd7z_RangeEnc *p, UInt32 size0) 58 | { 59 | UInt32 newBound = (p->Range >> 14) * size0; 60 | p->Low += newBound; 61 | p->Range -= newBound; 62 | while (p->Range < kTopValue) 63 | { 64 | p->Range <<= 8; 65 | RangeEnc_ShiftLow(p); 66 | } 67 | } 68 | 69 | void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p) 70 | { 71 | unsigned i; 72 | for (i = 0; i < 5; i++) 73 | RangeEnc_ShiftLow(p); 74 | } 75 | 76 | 77 | #define MASK(sym) ((signed char *)charMask)[sym] 78 | 79 | void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol) 80 | { 81 | size_t charMask[256 / sizeof(size_t)]; 82 | if (p->MinContext->NumStats != 1) 83 | { 84 | CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext); 85 | UInt32 sum; 86 | unsigned i; 87 | if (s->Symbol == symbol) 88 | { 89 | RangeEnc_Encode(rc, 0, s->Freq, p->MinContext->SummFreq); 90 | p->FoundState = s; 91 | Ppmd7_Update1_0(p); 92 | return; 93 | } 94 | p->PrevSuccess = 0; 95 | sum = s->Freq; 96 | i = p->MinContext->NumStats - 1; 97 | do 98 | { 99 | if ((++s)->Symbol == symbol) 100 | { 101 | RangeEnc_Encode(rc, sum, s->Freq, p->MinContext->SummFreq); 102 | p->FoundState = s; 103 | Ppmd7_Update1(p); 104 | return; 105 | } 106 | sum += s->Freq; 107 | } 108 | while (--i); 109 | 110 | p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]; 111 | PPMD_SetAllBitsIn256Bytes(charMask); 112 | MASK(s->Symbol) = 0; 113 | i = p->MinContext->NumStats - 1; 114 | do { MASK((--s)->Symbol) = 0; } while (--i); 115 | RangeEnc_Encode(rc, sum, p->MinContext->SummFreq - sum, p->MinContext->SummFreq); 116 | } 117 | else 118 | { 119 | UInt16 *prob = Ppmd7_GetBinSumm(p); 120 | CPpmd_State *s = Ppmd7Context_OneState(p->MinContext); 121 | if (s->Symbol == symbol) 122 | { 123 | RangeEnc_EncodeBit_0(rc, *prob); 124 | *prob = (UInt16)PPMD_UPDATE_PROB_0(*prob); 125 | p->FoundState = s; 126 | Ppmd7_UpdateBin(p); 127 | return; 128 | } 129 | else 130 | { 131 | RangeEnc_EncodeBit_1(rc, *prob); 132 | *prob = (UInt16)PPMD_UPDATE_PROB_1(*prob); 133 | p->InitEsc = PPMD7_kExpEscape[*prob >> 10]; 134 | PPMD_SetAllBitsIn256Bytes(charMask); 135 | MASK(s->Symbol) = 0; 136 | p->PrevSuccess = 0; 137 | } 138 | } 139 | for (;;) 140 | { 141 | UInt32 escFreq; 142 | CPpmd_See *see; 143 | CPpmd_State *s; 144 | UInt32 sum; 145 | unsigned i, numMasked = p->MinContext->NumStats; 146 | do 147 | { 148 | p->OrderFall++; 149 | if (!p->MinContext->Suffix) 150 | return; /* EndMarker (symbol = -1) */ 151 | p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix); 152 | } 153 | while (p->MinContext->NumStats == numMasked); 154 | 155 | see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq); 156 | s = Ppmd7_GetStats(p, p->MinContext); 157 | sum = 0; 158 | i = p->MinContext->NumStats; 159 | do 160 | { 161 | int cur = s->Symbol; 162 | if (cur == symbol) 163 | { 164 | UInt32 low = sum; 165 | CPpmd_State *s1 = s; 166 | do 167 | { 168 | sum += (s->Freq & (int)(MASK(s->Symbol))); 169 | s++; 170 | } 171 | while (--i); 172 | RangeEnc_Encode(rc, low, s1->Freq, sum + escFreq); 173 | Ppmd_See_Update(see); 174 | p->FoundState = s1; 175 | Ppmd7_Update2(p); 176 | return; 177 | } 178 | sum += (s->Freq & (int)(MASK(cur))); 179 | MASK(cur) = 0; 180 | s++; 181 | } 182 | while (--i); 183 | 184 | RangeEnc_Encode(rc, sum, escFreq, sum + escFreq); 185 | see->Summ = (UInt16)(see->Summ + sum + escFreq); 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/AesOpt.c: -------------------------------------------------------------------------------- 1 | /* AesOpt.c -- Intel's AES 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #ifdef MY_CPU_X86_OR_AMD64 9 | #if _MSC_VER >= 1500 10 | #define USE_INTEL_AES 11 | #endif 12 | #endif 13 | 14 | #ifdef USE_INTEL_AES 15 | 16 | #include 17 | 18 | void MY_FAST_CALL AesCbc_Encode_Intel(__m128i *p, __m128i *data, size_t numBlocks) 19 | { 20 | __m128i m = *p; 21 | for (; numBlocks != 0; numBlocks--, data++) 22 | { 23 | UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1; 24 | const __m128i *w = p + 3; 25 | m = _mm_xor_si128(m, *data); 26 | m = _mm_xor_si128(m, p[2]); 27 | do 28 | { 29 | m = _mm_aesenc_si128(m, w[0]); 30 | m = _mm_aesenc_si128(m, w[1]); 31 | w += 2; 32 | } 33 | while (--numRounds2 != 0); 34 | m = _mm_aesenc_si128(m, w[0]); 35 | m = _mm_aesenclast_si128(m, w[1]); 36 | *data = m; 37 | } 38 | *p = m; 39 | } 40 | 41 | #define NUM_WAYS 3 42 | 43 | #define AES_OP_W(op, n) { \ 44 | const __m128i t = w[n]; \ 45 | m0 = op(m0, t); \ 46 | m1 = op(m1, t); \ 47 | m2 = op(m2, t); \ 48 | } 49 | 50 | #define AES_DEC(n) AES_OP_W(_mm_aesdec_si128, n) 51 | #define AES_DEC_LAST(n) AES_OP_W(_mm_aesdeclast_si128, n) 52 | #define AES_ENC(n) AES_OP_W(_mm_aesenc_si128, n) 53 | #define AES_ENC_LAST(n) AES_OP_W(_mm_aesenclast_si128, n) 54 | 55 | void MY_FAST_CALL AesCbc_Decode_Intel(__m128i *p, __m128i *data, size_t numBlocks) 56 | { 57 | __m128i iv = *p; 58 | for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS) 59 | { 60 | UInt32 numRounds2 = *(const UInt32 *)(p + 1); 61 | const __m128i *w = p + numRounds2 * 2; 62 | __m128i m0, m1, m2; 63 | { 64 | const __m128i t = w[2]; 65 | m0 = _mm_xor_si128(t, data[0]); 66 | m1 = _mm_xor_si128(t, data[1]); 67 | m2 = _mm_xor_si128(t, data[2]); 68 | } 69 | numRounds2--; 70 | do 71 | { 72 | AES_DEC(1) 73 | AES_DEC(0) 74 | w -= 2; 75 | } 76 | while (--numRounds2 != 0); 77 | AES_DEC(1) 78 | AES_DEC_LAST(0) 79 | 80 | { 81 | __m128i t; 82 | t = _mm_xor_si128(m0, iv); iv = data[0]; data[0] = t; 83 | t = _mm_xor_si128(m1, iv); iv = data[1]; data[1] = t; 84 | t = _mm_xor_si128(m2, iv); iv = data[2]; data[2] = t; 85 | } 86 | } 87 | for (; numBlocks != 0; numBlocks--, data++) 88 | { 89 | UInt32 numRounds2 = *(const UInt32 *)(p + 1); 90 | const __m128i *w = p + numRounds2 * 2; 91 | __m128i m = _mm_xor_si128(w[2], *data); 92 | numRounds2--; 93 | do 94 | { 95 | m = _mm_aesdec_si128(m, w[1]); 96 | m = _mm_aesdec_si128(m, w[0]); 97 | w -= 2; 98 | } 99 | while (--numRounds2 != 0); 100 | m = _mm_aesdec_si128(m, w[1]); 101 | m = _mm_aesdeclast_si128(m, w[0]); 102 | 103 | m = _mm_xor_si128(m, iv); 104 | iv = *data; 105 | *data = m; 106 | } 107 | *p = iv; 108 | } 109 | 110 | void MY_FAST_CALL AesCtr_Code_Intel(__m128i *p, __m128i *data, size_t numBlocks) 111 | { 112 | __m128i ctr = *p; 113 | __m128i one; 114 | one.m128i_u64[0] = 1; 115 | one.m128i_u64[1] = 0; 116 | for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS) 117 | { 118 | UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1; 119 | const __m128i *w = p; 120 | __m128i m0, m1, m2; 121 | { 122 | const __m128i t = w[2]; 123 | ctr = _mm_add_epi64(ctr, one); m0 = _mm_xor_si128(ctr, t); 124 | ctr = _mm_add_epi64(ctr, one); m1 = _mm_xor_si128(ctr, t); 125 | ctr = _mm_add_epi64(ctr, one); m2 = _mm_xor_si128(ctr, t); 126 | } 127 | w += 3; 128 | do 129 | { 130 | AES_ENC(0) 131 | AES_ENC(1) 132 | w += 2; 133 | } 134 | while (--numRounds2 != 0); 135 | AES_ENC(0) 136 | AES_ENC_LAST(1) 137 | data[0] = _mm_xor_si128(data[0], m0); 138 | data[1] = _mm_xor_si128(data[1], m1); 139 | data[2] = _mm_xor_si128(data[2], m2); 140 | } 141 | for (; numBlocks != 0; numBlocks--, data++) 142 | { 143 | UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1; 144 | const __m128i *w = p; 145 | __m128i m; 146 | ctr = _mm_add_epi64(ctr, one); 147 | m = _mm_xor_si128(ctr, p[2]); 148 | w += 3; 149 | do 150 | { 151 | m = _mm_aesenc_si128(m, w[0]); 152 | m = _mm_aesenc_si128(m, w[1]); 153 | w += 2; 154 | } 155 | while (--numRounds2 != 0); 156 | m = _mm_aesenc_si128(m, w[0]); 157 | m = _mm_aesenclast_si128(m, w[1]); 158 | *data = _mm_xor_si128(*data, m); 159 | } 160 | *p = ctr; 161 | } 162 | 163 | #else 164 | 165 | void MY_FAST_CALL AesCbc_Encode(UInt32 *ivAes, Byte *data, size_t numBlocks); 166 | void MY_FAST_CALL AesCbc_Decode(UInt32 *ivAes, Byte *data, size_t numBlocks); 167 | void MY_FAST_CALL AesCtr_Code(UInt32 *ivAes, Byte *data, size_t numBlocks); 168 | 169 | void MY_FAST_CALL AesCbc_Encode_Intel(UInt32 *p, Byte *data, size_t numBlocks) 170 | { 171 | AesCbc_Encode(p, data, numBlocks); 172 | } 173 | 174 | void MY_FAST_CALL AesCbc_Decode_Intel(UInt32 *p, Byte *data, size_t numBlocks) 175 | { 176 | AesCbc_Decode(p, data, numBlocks); 177 | } 178 | 179 | void MY_FAST_CALL AesCtr_Code_Intel(UInt32 *p, Byte *data, size_t numBlocks) 180 | { 181 | AesCtr_Code(p, data, numBlocks); 182 | } 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /tzf_dsound/command.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | 23 | #ifndef __EPSILON_TESTBED__COMMAND_H__ 24 | #define __EPSILON_TESTBED__COMMAND_H__ 25 | 26 | #include 27 | 28 | # include 29 | 30 | #include // tolower (...) 31 | 32 | interface SK_IVariable; 33 | interface SK_ICommand; 34 | 35 | interface SK_ICommandResult 36 | { 37 | SK_ICommandResult ( const char* word, 38 | const char* arguments = "", 39 | const char* result = "", 40 | int status = false, 41 | const SK_IVariable* var = NULL, 42 | const SK_ICommand* cmd = NULL ) : word_ (word), 43 | args_ (arguments), 44 | result_ (result) { 45 | var_ = var; 46 | cmd_ = cmd; 47 | status_ = status; 48 | } 49 | 50 | const char* getWord (void) const { return word_.c_str (); } 51 | const char* getArgs (void) const { return args_.c_str (); } 52 | const char* getResult (void) const { return result_.c_str (); } 53 | 54 | const SK_IVariable* getVariable (void) const { return var_; } 55 | const SK_ICommand* getCommand (void) const { return cmd_; } 56 | 57 | int getStatus (void) const { return status_; } 58 | 59 | protected: 60 | 61 | private: 62 | const SK_IVariable* var_; 63 | const SK_ICommand* cmd_; 64 | std::string word_; 65 | std::string args_; 66 | std::string result_; 67 | int status_; 68 | }; 69 | 70 | interface SK_ICommand 71 | { 72 | virtual SK_ICommandResult execute (const char* szArgs) = 0; 73 | 74 | virtual const char* getHelp (void) { return "No Help Available"; } 75 | 76 | virtual int getNumArgs (void) { return 0; } 77 | virtual int getNumOptionalArgs (void) { return 0; } 78 | virtual int getNumRequiredArgs (void) { 79 | return getNumArgs () - getNumOptionalArgs (); 80 | } 81 | }; 82 | 83 | interface SK_IVariable 84 | { 85 | friend interface SK_IVariableListener; 86 | 87 | enum VariableType { 88 | Float, 89 | Double, 90 | Boolean, 91 | Byte, 92 | Short, 93 | Int, 94 | LongInt, 95 | String, 96 | 97 | NUM_VAR_TYPES_, 98 | 99 | Unknown 100 | } VariableTypes; 101 | 102 | virtual VariableType getType (void) const = 0; 103 | virtual void getValueString ( _Out_opt_ char* szOut, 104 | _Inout_ uint32_t* dwLen ) const = 0; 105 | virtual void* getValuePointer (void) const = 0; 106 | 107 | protected: 108 | VariableType type_; 109 | }; 110 | 111 | interface SK_IVariableListener 112 | { 113 | virtual bool OnVarChange (SK_IVariable* var, void* val = NULL) = 0; 114 | }; 115 | 116 | interface SK_ICommandProcessor 117 | { 118 | SK_ICommandProcessor (void); 119 | 120 | virtual ~SK_ICommandProcessor (void) 121 | { 122 | } 123 | 124 | virtual SK_ICommand* FindCommand (const char* szCommand) const; 125 | 126 | virtual const SK_ICommand* AddCommand ( const char* szCommand, 127 | SK_ICommand* pCommand ); 128 | virtual bool RemoveCommand ( const char* szCommand ); 129 | 130 | 131 | virtual const SK_IVariable* FindVariable (const char* szVariable) const; 132 | 133 | virtual const SK_IVariable* AddVariable ( const char* szVariable, 134 | SK_IVariable* pVariable ); 135 | virtual bool RemoveVariable ( const char* szVariable ); 136 | 137 | 138 | virtual SK_ICommandResult ProcessCommandLine (const char* szCommandLine); 139 | virtual SK_ICommandResult ProcessCommandFormatted (const char* szCommandFormat, ...); 140 | }; 141 | 142 | typedef SK_ICommandProcessor* (__stdcall *SK_GetCommandProcessor_pfn)(void); 143 | extern SK_GetCommandProcessor_pfn SK_GetCommandProcessor; 144 | 145 | SK_IVariable* 146 | TZF_CreateVar ( SK_IVariable::VariableType type, 147 | void* var, 148 | SK_IVariableListener *pListener = nullptr ); 149 | 150 | #endif /* __EPSILON_TESTBED__COMMAND_H */ 151 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Ppmd7Dec.c: -------------------------------------------------------------------------------- 1 | /* Ppmd7Dec.c -- PPMdH Decoder 2 | 2010-03-12 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | #include 6 | 7 | #include 8 | 9 | #define kTopValue (1 << 24) 10 | 11 | Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p) 12 | { 13 | unsigned i; 14 | p->Code = 0; 15 | p->Range = 0xFFFFFFFF; 16 | if (p->Stream->Read((void *)p->Stream) != 0) 17 | return False; 18 | for (i = 0; i < 4; i++) 19 | p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream); 20 | return (p->Code < 0xFFFFFFFF); 21 | } 22 | 23 | static UInt32 Range_GetThreshold(void *pp, UInt32 total) 24 | { 25 | CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp; 26 | return (p->Code) / (p->Range /= total); 27 | } 28 | 29 | static void Range_Normalize(CPpmd7z_RangeDec *p) 30 | { 31 | if (p->Range < kTopValue) 32 | { 33 | p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream); 34 | p->Range <<= 8; 35 | if (p->Range < kTopValue) 36 | { 37 | p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream); 38 | p->Range <<= 8; 39 | } 40 | } 41 | } 42 | 43 | static void Range_Decode(void *pp, UInt32 start, UInt32 size) 44 | { 45 | CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp; 46 | p->Code -= start * p->Range; 47 | p->Range *= size; 48 | Range_Normalize(p); 49 | } 50 | 51 | static UInt32 Range_DecodeBit(void *pp, UInt32 size0) 52 | { 53 | CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp; 54 | UInt32 newBound = (p->Range >> 14) * size0; 55 | UInt32 symbol; 56 | if (p->Code < newBound) 57 | { 58 | symbol = 0; 59 | p->Range = newBound; 60 | } 61 | else 62 | { 63 | symbol = 1; 64 | p->Code -= newBound; 65 | p->Range -= newBound; 66 | } 67 | Range_Normalize(p); 68 | return symbol; 69 | } 70 | 71 | void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p) 72 | { 73 | p->p.GetThreshold = Range_GetThreshold; 74 | p->p.Decode = Range_Decode; 75 | p->p.DecodeBit = Range_DecodeBit; 76 | } 77 | 78 | 79 | #define MASK(sym) ((signed char *)charMask)[sym] 80 | 81 | int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc) 82 | { 83 | size_t charMask[256 / sizeof(size_t)]; 84 | if (p->MinContext->NumStats != 1) 85 | { 86 | CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext); 87 | unsigned i; 88 | UInt32 count, hiCnt; 89 | if ((count = rc->GetThreshold(rc, p->MinContext->SummFreq)) < (hiCnt = s->Freq)) 90 | { 91 | Byte symbol; 92 | rc->Decode(rc, 0, s->Freq); 93 | p->FoundState = s; 94 | symbol = s->Symbol; 95 | Ppmd7_Update1_0(p); 96 | return symbol; 97 | } 98 | p->PrevSuccess = 0; 99 | i = p->MinContext->NumStats - 1; 100 | do 101 | { 102 | if ((hiCnt += (++s)->Freq) > count) 103 | { 104 | Byte symbol; 105 | rc->Decode(rc, hiCnt - s->Freq, s->Freq); 106 | p->FoundState = s; 107 | symbol = s->Symbol; 108 | Ppmd7_Update1(p); 109 | return symbol; 110 | } 111 | } 112 | while (--i); 113 | if (count >= p->MinContext->SummFreq) 114 | return -2; 115 | p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]; 116 | rc->Decode(rc, hiCnt, p->MinContext->SummFreq - hiCnt); 117 | PPMD_SetAllBitsIn256Bytes(charMask); 118 | MASK(s->Symbol) = 0; 119 | i = p->MinContext->NumStats - 1; 120 | do { MASK((--s)->Symbol) = 0; } while (--i); 121 | } 122 | else 123 | { 124 | UInt16 *prob = Ppmd7_GetBinSumm(p); 125 | if (rc->DecodeBit(rc, *prob) == 0) 126 | { 127 | Byte symbol; 128 | *prob = (UInt16)PPMD_UPDATE_PROB_0(*prob); 129 | symbol = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol; 130 | Ppmd7_UpdateBin(p); 131 | return symbol; 132 | } 133 | *prob = (UInt16)PPMD_UPDATE_PROB_1(*prob); 134 | p->InitEsc = PPMD7_kExpEscape[*prob >> 10]; 135 | PPMD_SetAllBitsIn256Bytes(charMask); 136 | MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0; 137 | p->PrevSuccess = 0; 138 | } 139 | for (;;) 140 | { 141 | CPpmd_State *ps[256], *s; 142 | UInt32 freqSum, count, hiCnt; 143 | CPpmd_See *see; 144 | unsigned i, num, numMasked = p->MinContext->NumStats; 145 | do 146 | { 147 | p->OrderFall++; 148 | if (!p->MinContext->Suffix) 149 | return -1; 150 | p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix); 151 | } 152 | while (p->MinContext->NumStats == numMasked); 153 | hiCnt = 0; 154 | s = Ppmd7_GetStats(p, p->MinContext); 155 | i = 0; 156 | num = p->MinContext->NumStats - numMasked; 157 | do 158 | { 159 | int k = (int)(MASK(s->Symbol)); 160 | hiCnt += (s->Freq & k); 161 | ps[i] = s++; 162 | i -= k; 163 | } 164 | while (i != num); 165 | 166 | see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum); 167 | freqSum += hiCnt; 168 | count = rc->GetThreshold(rc, freqSum); 169 | 170 | if (count < hiCnt) 171 | { 172 | Byte symbol; 173 | CPpmd_State **pps = ps; 174 | for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++); 175 | s = *pps; 176 | rc->Decode(rc, hiCnt - s->Freq, s->Freq); 177 | Ppmd_See_Update(see); 178 | p->FoundState = s; 179 | symbol = s->Symbol; 180 | Ppmd7_Update2(p); 181 | return symbol; 182 | } 183 | if (count >= freqSum) 184 | return -2; 185 | rc->Decode(rc, hiCnt, freqSum - hiCnt); 186 | see->Summ = (UInt16)(see->Summ + freqSum); 187 | do { MASK(ps[--i]->Symbol) = 0; } while (i != 0); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /tzf_dsound/compatibility.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | 23 | #include 24 | 25 | #include "hook.h" 26 | #include "log.h" 27 | 28 | typedef HMODULE (WINAPI *LoadLibraryA_pfn)(LPCSTR lpFileName); 29 | typedef HMODULE (WINAPI *LoadLibraryW_pfn)(LPCWSTR lpFileName); 30 | 31 | LoadLibraryA_pfn LoadLibraryA_Original = nullptr; 32 | LoadLibraryW_pfn LoadLibraryW_Original = nullptr; 33 | 34 | typedef HMODULE (WINAPI *LoadLibraryExA_pfn) 35 | ( _In_ LPCSTR lpFileName, 36 | _Reserved_ HANDLE hFile, 37 | _In_ DWORD dwFlags 38 | ); 39 | 40 | typedef HMODULE (WINAPI *LoadLibraryExW_pfn) 41 | ( _In_ LPCWSTR lpFileName, 42 | _Reserved_ HANDLE hFile, 43 | _In_ DWORD dwFlags 44 | ); 45 | 46 | LoadLibraryExA_pfn LoadLibraryExA_Original = nullptr; 47 | LoadLibraryExW_pfn LoadLibraryExW_Original = nullptr; 48 | 49 | extern HMODULE hModSelf; 50 | 51 | #include 52 | #pragma comment (lib, "Shlwapi.lib") 53 | 54 | BOOL 55 | BlacklistLibraryW (LPCWSTR lpFileName) 56 | { 57 | #if 0 58 | if (StrStrIW (lpFileName, L"ltc_help32") || 59 | StrStrIW (lpFileName, L"ltc_game32")) { 60 | dll_log->Log (L"[Black List] Preventing Raptr's overlay, evil little thing must die!"); 61 | return TRUE; 62 | } 63 | 64 | if (StrStrIW (lpFileName, L"PlayClaw")) { 65 | dll_log->Log (L"[Black List] Incompatible software: PlayClaw disabled"); 66 | return TRUE; 67 | } 68 | #endif 69 | 70 | return FALSE; 71 | } 72 | 73 | BOOL 74 | BlacklistLibraryA (LPCSTR lpFileName) 75 | { 76 | wchar_t wszWideLibName [MAX_PATH]; 77 | 78 | MultiByteToWideChar (CP_OEMCP, 0x00, lpFileName, -1, wszWideLibName, MAX_PATH); 79 | 80 | return BlacklistLibraryW (wszWideLibName); 81 | } 82 | 83 | HMODULE 84 | WINAPI 85 | LoadLibraryA_Detour (LPCSTR lpFileName) 86 | { 87 | if (lpFileName == nullptr) 88 | return NULL; 89 | 90 | HMODULE hModEarly = GetModuleHandleA (lpFileName); 91 | 92 | if (hModEarly == NULL && BlacklistLibraryA (lpFileName)) 93 | return NULL; 94 | 95 | HMODULE hMod = LoadLibraryA_Original (lpFileName); 96 | 97 | if (hModEarly != hMod) 98 | dll_log->Log (L"[DLL Loader] Game loaded '%#64hs' ", lpFileName); 99 | 100 | return hMod; 101 | } 102 | 103 | HMODULE 104 | WINAPI 105 | LoadLibraryW_Detour (LPCWSTR lpFileName) 106 | { 107 | if (lpFileName == nullptr) 108 | return NULL; 109 | 110 | HMODULE hModEarly = GetModuleHandleW (lpFileName); 111 | 112 | if (hModEarly == NULL && BlacklistLibraryW (lpFileName)) 113 | return NULL; 114 | 115 | HMODULE hMod = LoadLibraryW_Original (lpFileName); 116 | 117 | if (hModEarly != hMod) 118 | dll_log->Log (L"[DLL Loader] Game loaded '%#64s' ", lpFileName); 119 | 120 | return hMod; 121 | } 122 | 123 | HMODULE 124 | WINAPI 125 | LoadLibraryExA_Detour ( 126 | _In_ LPCSTR lpFileName, 127 | _Reserved_ HANDLE hFile, 128 | _In_ DWORD dwFlags ) 129 | { 130 | if (lpFileName == nullptr) 131 | return NULL; 132 | 133 | HMODULE hModEarly = GetModuleHandleA (lpFileName); 134 | 135 | if (hModEarly == NULL && BlacklistLibraryA (lpFileName)) 136 | return NULL; 137 | 138 | HMODULE hMod = LoadLibraryExA_Original (lpFileName, hFile, dwFlags); 139 | 140 | if (hModEarly != hMod && (! ((dwFlags & LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE) || 141 | (dwFlags & LOAD_LIBRARY_AS_IMAGE_RESOURCE)))) 142 | dll_log->Log (L"[DLL Loader] Game loaded '%#64hs' ", lpFileName); 143 | 144 | return hMod; 145 | } 146 | 147 | HMODULE 148 | WINAPI 149 | LoadLibraryExW_Detour ( 150 | _In_ LPCWSTR lpFileName, 151 | _Reserved_ HANDLE hFile, 152 | _In_ DWORD dwFlags ) 153 | { 154 | if (lpFileName == nullptr) 155 | return NULL; 156 | 157 | HMODULE hModEarly = GetModuleHandleW (lpFileName); 158 | 159 | if (hModEarly == NULL && BlacklistLibraryW (lpFileName)) 160 | return NULL; 161 | 162 | HMODULE hMod = LoadLibraryExW_Original (lpFileName, hFile, dwFlags); 163 | 164 | if (hModEarly != hMod && (! ((dwFlags & LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE) || 165 | (dwFlags & LOAD_LIBRARY_AS_IMAGE_RESOURCE)))) 166 | dll_log->Log (L"[DLL Loader] Game loaded '%#64s' ", lpFileName); 167 | 168 | return hMod; 169 | } 170 | 171 | void 172 | TZF_InitCompatBlacklist (void) 173 | { 174 | TZF_CreateDLLHook ( L"kernel32.dll", "LoadLibraryA", 175 | LoadLibraryA_Detour, 176 | (LPVOID*)&LoadLibraryA_Original ); 177 | 178 | TZF_CreateDLLHook ( L"kernel32.dll", "LoadLibraryW", 179 | LoadLibraryW_Detour, 180 | (LPVOID*)&LoadLibraryW_Original ); 181 | 182 | TZF_CreateDLLHook ( L"kernel32.dll", "LoadLibraryExA", 183 | LoadLibraryExA_Detour, 184 | (LPVOID*)&LoadLibraryExA_Original ); 185 | 186 | TZF_CreateDLLHook ( L"kernel32.dll", "LoadLibraryExW", 187 | LoadLibraryExW_Detour, 188 | (LPVOID*)&LoadLibraryExW_Original ); 189 | } -------------------------------------------------------------------------------- /tzf_dsound/include/lzma/7z.h: -------------------------------------------------------------------------------- 1 | /* 7z.h -- 7z interface 2 | 2015-11-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_H 5 | #define __7Z_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define k7zStartHeaderSize 0x20 12 | #define k7zSignatureSize 6 13 | 14 | extern const Byte k7zSignature[k7zSignatureSize]; 15 | 16 | typedef struct 17 | { 18 | const Byte *Data; 19 | size_t Size; 20 | } CSzData; 21 | 22 | /* CSzCoderInfo & CSzFolder support only default methods */ 23 | 24 | typedef struct 25 | { 26 | size_t PropsOffset; 27 | UInt32 MethodID; 28 | Byte NumStreams; 29 | Byte PropsSize; 30 | } CSzCoderInfo; 31 | 32 | typedef struct 33 | { 34 | UInt32 InIndex; 35 | UInt32 OutIndex; 36 | } CSzBond; 37 | 38 | #define SZ_NUM_CODERS_IN_FOLDER_MAX 4 39 | #define SZ_NUM_BONDS_IN_FOLDER_MAX 3 40 | #define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4 41 | 42 | typedef struct 43 | { 44 | UInt32 NumCoders; 45 | UInt32 NumBonds; 46 | UInt32 NumPackStreams; 47 | UInt32 UnpackStream; 48 | UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; 49 | CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX]; 50 | CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX]; 51 | } CSzFolder; 52 | 53 | 54 | SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd); 55 | 56 | typedef struct 57 | { 58 | UInt32 Low; 59 | UInt32 High; 60 | } CNtfsFileTime; 61 | 62 | typedef struct 63 | { 64 | Byte *Defs; /* MSB 0 bit numbering */ 65 | UInt32 *Vals; 66 | } CSzBitUi32s; 67 | 68 | typedef struct 69 | { 70 | Byte *Defs; /* MSB 0 bit numbering */ 71 | // UInt64 *Vals; 72 | CNtfsFileTime *Vals; 73 | } CSzBitUi64s; 74 | 75 | #define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) 76 | 77 | #define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) 78 | 79 | typedef struct 80 | { 81 | UInt32 NumPackStreams; 82 | UInt32 NumFolders; 83 | 84 | UInt64 *PackPositions; // NumPackStreams + 1 85 | CSzBitUi32s FolderCRCs; // NumFolders 86 | 87 | size_t *FoCodersOffsets; // NumFolders + 1 88 | UInt32 *FoStartPackStreamIndex; // NumFolders + 1 89 | UInt32 *FoToCoderUnpackSizes; // NumFolders + 1 90 | Byte *FoToMainUnpackSizeIndex; // NumFolders 91 | UInt64 *CoderUnpackSizes; // for all coders in all folders 92 | 93 | Byte *CodersData; 94 | } CSzAr; 95 | 96 | UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex); 97 | 98 | SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, 99 | ILookInStream *stream, UInt64 startPos, 100 | Byte *outBuffer, size_t outSize, 101 | ISzAlloc *allocMain); 102 | 103 | typedef struct 104 | { 105 | CSzAr db; 106 | 107 | UInt64 startPosAfterHeader; 108 | UInt64 dataPos; 109 | 110 | UInt32 NumFiles; 111 | 112 | UInt64 *UnpackPositions; // NumFiles + 1 113 | // Byte *IsEmptyFiles; 114 | Byte *IsDirs; 115 | CSzBitUi32s CRCs; 116 | 117 | CSzBitUi32s Attribs; 118 | // CSzBitUi32s Parents; 119 | CSzBitUi64s MTime; 120 | CSzBitUi64s CTime; 121 | 122 | UInt32 *FolderToFile; // NumFolders + 1 123 | UInt32 *FileToFolder; // NumFiles 124 | 125 | size_t *FileNameOffsets; /* in 2-byte steps */ 126 | Byte *FileNames; /* UTF-16-LE */ 127 | } CSzArEx; 128 | 129 | #define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i)) 130 | 131 | #define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i]) 132 | 133 | void SzArEx_Init(CSzArEx *p); 134 | void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc); 135 | UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder); 136 | int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize); 137 | 138 | /* 139 | if dest == NULL, the return value specifies the required size of the buffer, 140 | in 16-bit characters, including the null-terminating character. 141 | if dest != NULL, the return value specifies the number of 16-bit characters that 142 | are written to the dest, including the null-terminating character. */ 143 | 144 | size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); 145 | 146 | /* 147 | size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex); 148 | UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest); 149 | */ 150 | 151 | 152 | 153 | /* 154 | SzArEx_Extract extracts file from archive 155 | 156 | *outBuffer must be 0 before first call for each new archive. 157 | 158 | Extracting cache: 159 | If you need to decompress more than one file, you can send 160 | these values from previous call: 161 | *blockIndex, 162 | *outBuffer, 163 | *outBufferSize 164 | You can consider "*outBuffer" as cache of solid block. If your archive is solid, 165 | it will increase decompression speed. 166 | 167 | If you use external function, you can declare these 3 cache variables 168 | (blockIndex, outBuffer, outBufferSize) as static in that external function. 169 | 170 | Free *outBuffer and set *outBuffer to 0, if you want to flush cache. 171 | */ 172 | 173 | SRes SzArEx_Extract( 174 | const CSzArEx *db, 175 | ILookInStream *inStream, 176 | UInt32 fileIndex, /* index of file */ 177 | UInt32 *blockIndex, /* index of solid block */ 178 | Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ 179 | size_t *outBufferSize, /* buffer size for output buffer */ 180 | size_t *offset, /* offset of stream for required file in *outBuffer */ 181 | size_t *outSizeProcessed, /* size of file in *outBuffer */ 182 | ISzAlloc *allocMain, 183 | ISzAlloc *allocTemp); 184 | 185 | 186 | /* 187 | SzArEx_Open Errors: 188 | SZ_ERROR_NO_ARCHIVE 189 | SZ_ERROR_ARCHIVE 190 | SZ_ERROR_UNSUPPORTED 191 | SZ_ERROR_MEM 192 | SZ_ERROR_CRC 193 | SZ_ERROR_INPUT_EOF 194 | SZ_ERROR_FAIL 195 | */ 196 | 197 | SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, 198 | ISzAlloc *allocMain, ISzAlloc *allocTemp); 199 | 200 | EXTERN_C_END 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /tzf_dsound/parameter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of Tales of Zestiria "Fix". 3 | * 4 | * Tales of Zestiria "Fix" is free software : you can redistribute it 5 | * and/or modify it under the terms of the GNU General Public License 6 | * as published by The Free Software Foundation, either version 3 of 7 | * the License, or (at your option) any later version. 8 | * 9 | * Tales of Zestiria "Fix" is distributed in the hope that it will be 10 | * useful, 11 | * 12 | * But WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Tales of Zestiria "Fix". 18 | * 19 | * If not, see . 20 | * 21 | **/ 22 | #ifndef __TZF__PARAMETER_H__ 23 | #define __TZF__PARAMETER_H__ 24 | 25 | #include "ini.h" 26 | 27 | #include 28 | #include 29 | 30 | namespace tzf 31 | { 32 | class iParameter 33 | { 34 | public: 35 | iParameter (void) { 36 | ini = nullptr; 37 | } 38 | 39 | virtual std::wstring get_value_str (void) = 0; 40 | virtual void set_value_str (std::wstring str) = 0; 41 | 42 | // Read value from INI 43 | bool load (void) 44 | { 45 | if (ini != nullptr) { 46 | iSK_INISection& section = ini->get_section (ini_section.c_str ()); 47 | 48 | if (section.contains_key (ini_key.c_str ())) { 49 | set_value_str (section.get_value (ini_key.c_str ())); 50 | return true; 51 | } 52 | } 53 | 54 | return false; 55 | } 56 | 57 | // Store value in INI and/or XML 58 | bool store (void) 59 | { 60 | bool ret = false; 61 | 62 | if (ini != nullptr) { 63 | iSK_INISection& section = ini->get_section (ini_section.c_str ()); 64 | 65 | // If this operation actually creates a section, we need to make sure 66 | // that section has a name! 67 | section.set_name (ini_section.c_str ()); 68 | 69 | if (section.contains_key (ini_key.c_str ())) { 70 | section.get_value (ini_key.c_str ()) = get_value_str ().c_str (); 71 | ret = true; 72 | } 73 | 74 | // Add this key/value if it doesn't already exist. 75 | else { 76 | section.add_key_value (ini_key.c_str (), get_value_str ().c_str ()); 77 | ret = true;// +1; 78 | } 79 | } 80 | 81 | return ret; 82 | } 83 | 84 | void register_to_ini (iSK_INI* file, std::wstring section, std::wstring key) 85 | { 86 | ini = file; 87 | ini_section = section; 88 | ini_key = key; 89 | } 90 | 91 | protected: 92 | private: 93 | iSK_INI* ini; 94 | std::wstring ini_section; 95 | std::wstring ini_key; 96 | }; 97 | 98 | template 99 | class Parameter : public iParameter { 100 | public: 101 | virtual std::wstring get_value_str (void) = 0; 102 | virtual _T get_value (void) = 0; 103 | 104 | virtual void set_value (_T val) = 0; 105 | virtual void set_value_str (std::wstring str) = 0; 106 | 107 | virtual void store (_T val) = 0; 108 | virtual void store_str (std::wstring str) = 0; 109 | 110 | virtual bool load (_T& ref) = 0; 111 | 112 | protected: 113 | _T value; 114 | }; 115 | 116 | class ParameterInt : public Parameter 117 | { 118 | public: 119 | std::wstring get_value_str (void); 120 | int get_value (void); 121 | 122 | void set_value (int val); 123 | void set_value_str (std::wstring str); 124 | 125 | void store (int val); 126 | void store_str (std::wstring str); 127 | 128 | bool load (int& ref); 129 | 130 | protected: 131 | int value; 132 | }; 133 | 134 | class ParameterInt64 : public Parameter 135 | { 136 | public: 137 | std::wstring get_value_str (void); 138 | int64_t get_value (void); 139 | 140 | void set_value (int64_t val); 141 | void set_value_str (std::wstring str); 142 | 143 | void store (int64_t val); 144 | void store_str (std::wstring str); 145 | 146 | bool load (int64_t& ref); 147 | 148 | protected: 149 | int64_t value; 150 | }; 151 | 152 | class ParameterBool : public Parameter 153 | { 154 | public: 155 | std::wstring get_value_str (void); 156 | bool get_value (void); 157 | 158 | void set_value (bool val); 159 | void set_value_str (std::wstring str); 160 | 161 | void store (bool val); 162 | void store_str (std::wstring str); 163 | 164 | bool load (bool& ref); 165 | 166 | enum boolean_term_t { 167 | TrueFalse = 0, 168 | OnOff = 1, 169 | YesNo = 2, 170 | ZeroNonZero = 3 171 | }; 172 | 173 | protected: 174 | bool value; 175 | boolean_term_t type = TrueFalse; 176 | }; 177 | 178 | class ParameterFloat : public Parameter 179 | { 180 | public: 181 | std::wstring get_value_str (void); 182 | float get_value (void); 183 | 184 | void set_value (float val); 185 | void set_value_str (std::wstring str); 186 | 187 | void store (float val); 188 | void store_str (std::wstring str); 189 | 190 | bool load (float& ref); 191 | 192 | protected: 193 | float value; 194 | }; 195 | 196 | class ParameterStringW : public Parameter 197 | { 198 | public: 199 | std::wstring get_value_str (void); 200 | std::wstring get_value (void); 201 | 202 | void set_value (std::wstring str); 203 | void set_value_str (std::wstring str); 204 | 205 | void store (std::wstring val); 206 | void store_str (std::wstring str); 207 | 208 | bool load (std::wstring& ref); 209 | 210 | 211 | protected: 212 | std::wstring value; 213 | }; 214 | 215 | class ParameterFactory { 216 | public: 217 | template iParameter* create_parameter (const wchar_t* name); 218 | protected: 219 | private: 220 | std::vector params; 221 | }; 222 | } 223 | 224 | #endif /* __TZF__PARAMETER_H__ */ 225 | -------------------------------------------------------------------------------- /tzf_dsound/lzma/Sha256.c: -------------------------------------------------------------------------------- 1 | /* Crypto/Sha256.c -- SHA-256 Hash 2 | 2015-11-14 : Igor Pavlov : Public domain 3 | This code is based on public domain code from Wei Dai's Crypto++ library. */ 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | /* define it for speed optimization */ 14 | #ifndef _SFX 15 | #define _SHA256_UNROLL 16 | #define _SHA256_UNROLL2 17 | #endif 18 | 19 | /* #define _SHA256_UNROLL2 */ 20 | 21 | void Sha256_Init(CSha256 *p) 22 | { 23 | p->state[0] = 0x6a09e667; 24 | p->state[1] = 0xbb67ae85; 25 | p->state[2] = 0x3c6ef372; 26 | p->state[3] = 0xa54ff53a; 27 | p->state[4] = 0x510e527f; 28 | p->state[5] = 0x9b05688c; 29 | p->state[6] = 0x1f83d9ab; 30 | p->state[7] = 0x5be0cd19; 31 | p->count = 0; 32 | } 33 | 34 | #define S0(x) (rotrFixed(x, 2) ^ rotrFixed(x,13) ^ rotrFixed(x, 22)) 35 | #define S1(x) (rotrFixed(x, 6) ^ rotrFixed(x,11) ^ rotrFixed(x, 25)) 36 | #define s0(x) (rotrFixed(x, 7) ^ rotrFixed(x,18) ^ (x >> 3)) 37 | #define s1(x) (rotrFixed(x,17) ^ rotrFixed(x,19) ^ (x >> 10)) 38 | 39 | #define blk0(i) (W[i]) 40 | #define blk2(i) (W[i] += s1(W[((i)-2)&15]) + W[((i)-7)&15] + s0(W[((i)-15)&15])) 41 | 42 | #define Ch(x,y,z) (z^(x&(y^z))) 43 | #define Maj(x,y,z) ((x&y)|(z&(x|y))) 44 | 45 | #ifdef _SHA256_UNROLL2 46 | 47 | #define R(a,b,c,d,e,f,g,h, i) \ 48 | h += S1(e) + Ch(e,f,g) + K[(i)+(j)] + (j ? blk2(i) : blk0(i)); \ 49 | d += h; \ 50 | h += S0(a) + Maj(a, b, c) 51 | 52 | #define RX_8(i) \ 53 | R(a,b,c,d,e,f,g,h, i); \ 54 | R(h,a,b,c,d,e,f,g, i+1); \ 55 | R(g,h,a,b,c,d,e,f, i+2); \ 56 | R(f,g,h,a,b,c,d,e, i+3); \ 57 | R(e,f,g,h,a,b,c,d, i+4); \ 58 | R(d,e,f,g,h,a,b,c, i+5); \ 59 | R(c,d,e,f,g,h,a,b, i+6); \ 60 | R(b,c,d,e,f,g,h,a, i+7) 61 | 62 | #define RX_16 RX_8(0); RX_8(8); 63 | 64 | #else 65 | 66 | #define a(i) T[(0-(i))&7] 67 | #define b(i) T[(1-(i))&7] 68 | #define c(i) T[(2-(i))&7] 69 | #define d(i) T[(3-(i))&7] 70 | #define e(i) T[(4-(i))&7] 71 | #define f(i) T[(5-(i))&7] 72 | #define g(i) T[(6-(i))&7] 73 | #define h(i) T[(7-(i))&7] 74 | 75 | #define R(i) \ 76 | h(i) += S1(e(i)) + Ch(e(i),f(i),g(i)) + K[(i)+(j)] + (j ? blk2(i) : blk0(i)); \ 77 | d(i) += h(i); \ 78 | h(i) += S0(a(i)) + Maj(a(i), b(i), c(i)) \ 79 | 80 | #ifdef _SHA256_UNROLL 81 | 82 | #define RX_8(i) R(i+0); R(i+1); R(i+2); R(i+3); R(i+4); R(i+5); R(i+6); R(i+7); 83 | #define RX_16 RX_8(0); RX_8(8); 84 | 85 | #else 86 | 87 | #define RX_16 unsigned i; for (i = 0; i < 16; i++) { R(i); } 88 | 89 | #endif 90 | 91 | #endif 92 | 93 | static const UInt32 K[64] = { 94 | 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 95 | 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 96 | 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 97 | 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 98 | 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 99 | 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 100 | 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 101 | 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 102 | 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 103 | 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 104 | 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 105 | 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 106 | 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 107 | 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 108 | 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 109 | 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 110 | }; 111 | 112 | static void Sha256_WriteByteBlock(CSha256 *p) 113 | { 114 | UInt32 W[16]; 115 | unsigned j; 116 | UInt32 *state; 117 | 118 | #ifdef _SHA256_UNROLL2 119 | UInt32 a,b,c,d,e,f,g,h; 120 | #else 121 | UInt32 T[8]; 122 | #endif 123 | 124 | for (j = 0; j < 16; j += 4) 125 | { 126 | const Byte *ccc = p->buffer + j * 4; 127 | W[j ] = GetBe32(ccc); 128 | W[j + 1] = GetBe32(ccc + 4); 129 | W[j + 2] = GetBe32(ccc + 8); 130 | W[j + 3] = GetBe32(ccc + 12); 131 | } 132 | 133 | state = p->state; 134 | 135 | #ifdef _SHA256_UNROLL2 136 | a = state[0]; 137 | b = state[1]; 138 | c = state[2]; 139 | d = state[3]; 140 | e = state[4]; 141 | f = state[5]; 142 | g = state[6]; 143 | h = state[7]; 144 | #else 145 | for (j = 0; j < 8; j++) 146 | T[j] = state[j]; 147 | #endif 148 | 149 | for (j = 0; j < 64; j += 16) 150 | { 151 | RX_16 152 | } 153 | 154 | #ifdef _SHA256_UNROLL2 155 | state[0] += a; 156 | state[1] += b; 157 | state[2] += c; 158 | state[3] += d; 159 | state[4] += e; 160 | state[5] += f; 161 | state[6] += g; 162 | state[7] += h; 163 | #else 164 | for (j = 0; j < 8; j++) 165 | state[j] += T[j]; 166 | #endif 167 | 168 | /* Wipe variables */ 169 | /* memset(W, 0, sizeof(W)); */ 170 | /* memset(T, 0, sizeof(T)); */ 171 | } 172 | 173 | #undef S0 174 | #undef S1 175 | #undef s0 176 | #undef s1 177 | 178 | void Sha256_Update(CSha256 *p, const Byte *data, size_t size) 179 | { 180 | if (size == 0) 181 | return; 182 | 183 | { 184 | unsigned pos = (unsigned)p->count & 0x3F; 185 | unsigned num; 186 | 187 | p->count += size; 188 | 189 | num = 64 - pos; 190 | if (num > size) 191 | { 192 | memcpy(p->buffer + pos, data, size); 193 | return; 194 | } 195 | 196 | size -= num; 197 | memcpy(p->buffer + pos, data, num); 198 | data += num; 199 | } 200 | 201 | for (;;) 202 | { 203 | Sha256_WriteByteBlock(p); 204 | if (size < 64) 205 | break; 206 | size -= 64; 207 | memcpy(p->buffer, data, 64); 208 | data += 64; 209 | } 210 | 211 | if (size != 0) 212 | memcpy(p->buffer, data, size); 213 | } 214 | 215 | void Sha256_Final(CSha256 *p, Byte *digest) 216 | { 217 | unsigned pos = (unsigned)p->count & 0x3F; 218 | unsigned i; 219 | 220 | p->buffer[pos++] = 0x80; 221 | 222 | while (pos != (64 - 8)) 223 | { 224 | pos &= 0x3F; 225 | if (pos == 0) 226 | Sha256_WriteByteBlock(p); 227 | p->buffer[pos++] = 0; 228 | } 229 | 230 | { 231 | UInt64 numBits = (p->count << 3); 232 | SetBe32(p->buffer + 64 - 8, (UInt32)(numBits >> 32)); 233 | SetBe32(p->buffer + 64 - 4, (UInt32)(numBits)); 234 | } 235 | 236 | Sha256_WriteByteBlock(p); 237 | 238 | for (i = 0; i < 8; i += 2) 239 | { 240 | UInt32 v0 = p->state[i]; 241 | UInt32 v1 = p->state[i + 1]; 242 | SetBe32(digest , v0); 243 | SetBe32(digest + 4, v1); 244 | digest += 8; 245 | } 246 | 247 | Sha256_Init(p); 248 | } 249 | --------------------------------------------------------------------------------