├── DRM ├── DRM.rc ├── Repack.h ├── Game.h ├── PlatformSetup.h ├── File.h ├── Main.cpp ├── DRM.h ├── DRM.vcxproj.filters ├── Repack.cpp ├── FileExtensions.h ├── File.cpp └── DRM.cpp ├── CDRM ├── CDRM.rc ├── resource.h ├── Game.h ├── PlatformSetup.h ├── File.h ├── CDRM.h ├── Main.cpp ├── CDRM.vcxproj.filters └── File.cpp ├── External └── zlib │ ├── contrib │ ├── README.contrib │ ├── masmx64 │ │ ├── bld_ml64.bat │ │ ├── readme.txt │ │ └── inffas8664.c │ ├── masmx86 │ │ ├── bld_ml32.bat │ │ └── readme.txt │ ├── minizip │ │ ├── MiniZip64_Changes.txt │ │ ├── minizip.pc.in │ │ ├── Makefile │ │ ├── mztools.h │ │ ├── configure.ac │ │ ├── iowin32.h │ │ ├── make_vms.com │ │ ├── Makefile.am │ │ ├── minizip.1 │ │ ├── miniunzip.1 │ │ ├── MiniZip64_info.txt │ │ ├── crypt.h │ │ └── ioapi.h │ └── vstudio │ │ ├── vc10 │ │ ├── miniunz.vcxproj.filters │ │ ├── minizip.vcxproj.filters │ │ ├── testzlibdll.vcxproj.filters │ │ ├── zlib.rc │ │ ├── testzlib.vcxproj.filters │ │ ├── zlibstat.vcxproj.filters │ │ ├── zlibvc.vcxproj.filters │ │ └── zlibvc.def │ │ ├── vc9 │ │ ├── zlib.rc │ │ └── zlibvc.def │ │ ├── vc11 │ │ ├── zlib.rc │ │ └── zlibvc.def │ │ └── readme.txt │ ├── inffast.h │ ├── gzclose.c │ ├── zlib.map │ ├── uncompr.c │ ├── compress.c │ ├── inftrees.h │ ├── treebuild.xml │ ├── README │ ├── adler32.c │ ├── inffixed.h │ ├── inflate.h │ ├── gzguts.h │ └── zutil.h ├── .gitignore ├── WAVE2WAV ├── RIFF.h ├── File.h ├── Main.cpp ├── WAVE2WAV.vcxproj.filters ├── File.cpp ├── RIFF.cpp └── WAVE2WAV.vcxproj ├── License.txt ├── README.md └── PCD2DDS ├── DDS.h ├── File.h ├── Main.cpp ├── PCD2DDS.vcxproj.filters ├── PCD.h ├── File.cpp ├── DDS.cpp ├── PCD.cpp └── PCD2DDS.vcxproj /DRM/DRM.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gh0stBlade/cdcEngineTools/HEAD/DRM/DRM.rc -------------------------------------------------------------------------------- /CDRM/CDRM.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gh0stBlade/cdcEngineTools/HEAD/CDRM/CDRM.rc -------------------------------------------------------------------------------- /CDRM/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gh0stBlade/cdcEngineTools/HEAD/CDRM/resource.h -------------------------------------------------------------------------------- /External/zlib/contrib/README.contrib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gh0stBlade/cdcEngineTools/HEAD/External/zlib/contrib/README.contrib -------------------------------------------------------------------------------- /External/zlib/contrib/masmx64/bld_ml64.bat: -------------------------------------------------------------------------------- 1 | ml64.exe /Flinffasx64 /c /Zi inffasx64.asm 2 | ml64.exe /Flgvmat64 /c /Zi gvmat64.asm 3 | -------------------------------------------------------------------------------- /External/zlib/contrib/masmx86/bld_ml32.bat: -------------------------------------------------------------------------------- 1 | ml /coff /Zi /c /Flmatch686.lst match686.asm 2 | ml /coff /Zi /c /Flinffas32.lst inffas32.asm 3 | -------------------------------------------------------------------------------- /DRM/Repack.h: -------------------------------------------------------------------------------- 1 | #ifndef REPACK_H 2 | #define REPACK_H 3 | 4 | void RepackSections(const char* sectionListPath, const char* basePath); 5 | 6 | #endif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Obj/* 2 | Builds/* 3 | Libs/* 4 | External/* 5 | *.sdf 6 | *.txt 7 | *.opendb 8 | *.db 9 | *.lastbuildstate 10 | *.idb 11 | *.tlog 12 | *.res -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/MiniZip64_Changes.txt: -------------------------------------------------------------------------------- 1 | 2 | MiniZip 1.1 was derrived from MiniZip at version 1.01f 3 | 4 | Change in 1.0 (Okt 2009) 5 | - **TODO - Add history** 6 | 7 | -------------------------------------------------------------------------------- /CDRM/Game.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_H 2 | #define GAME_H 3 | 4 | #if TR7 5 | #define GAME_NAME "Tomb Raider: Legend" 6 | #elif TR8 7 | #define GAME_NAME "Tomb Raider: Underworld" 8 | #elif TRAS 9 | #define GAME_NAME "Tomb Raider: Ascension" 10 | #endif 11 | 12 | #endif -------------------------------------------------------------------------------- /WAVE2WAV/RIFF.h: -------------------------------------------------------------------------------- 1 | #ifndef RIFF_H 2 | #define RIFF_H 3 | 4 | #define SECTION_MAGIC (0x54434553) 5 | #define RIFF_MAGIC (0x46464952) 6 | #define WAVE_SECTION_TYPE (6) 7 | 8 | void ConvertWAVEToWAV(const char* filePath); 9 | void ConvertWAVToWAVE(const char* filePath); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/minizip.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@/minizip 5 | 6 | Name: minizip 7 | Description: Minizip zip file manipulation library 8 | Requires: 9 | Version: @PACKAGE_VERSION@ 10 | Libs: -L${libdir} -lminizip 11 | Libs.private: -lz 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /DRM/Game.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_H 2 | #define GAME_H 3 | 4 | #if TR7 5 | #define GAME_NAME "Tomb Raider: Legend" 6 | #elif TRAE 7 | #define GAME_NAME "Tomb Raider: Anniversary" 8 | #elif TR8 9 | #define GAME_NAME "Tomb Raider: Underworld" 10 | #elif TRAS 11 | #define GAME_NAME "Tomb Raider: Ascension" 12 | #else 13 | #error "Unsupported Game!" 14 | #endif 15 | #endif -------------------------------------------------------------------------------- /External/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/Makefile: -------------------------------------------------------------------------------- 1 | CC=cc 2 | CFLAGS=-O -I../.. 3 | 4 | UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a 5 | ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a 6 | 7 | .c.o: 8 | $(CC) -c $(CFLAGS) $*.c 9 | 10 | all: miniunz minizip 11 | 12 | miniunz: $(UNZ_OBJS) 13 | $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) 14 | 15 | minizip: $(ZIP_OBJS) 16 | $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) 17 | 18 | test: miniunz minizip 19 | ./minizip test readme.txt 20 | ./miniunz -l test.zip 21 | mv readme.txt readme.old 22 | ./miniunz test.zip 23 | 24 | clean: 25 | /bin/rm -f *.o *~ minizip miniunz 26 | -------------------------------------------------------------------------------- /External/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /CDRM/PlatformSetup.h: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_H 2 | #define PLATFORM_H 3 | 4 | #if TR8 || TRAS 5 | #if PC 6 | #define PLATFORM_FULL_NAME "PC" 7 | #define PLATFORM_CONFIG_NAME "PC-W" 8 | #define ENDIAN_BIG (0) 9 | #elif PS2 10 | #define PLATFORM_FULL_NAME "PS2" 11 | #define PLATFORM_CONFIG_NAME "PS2-W" 12 | #define ENDIAN_BIG (0) 13 | #elif WII 14 | #define PLATFORM_FULL_NAME "WII" 15 | #define PLATFORM_CONFIG_NAME "WII-W" 16 | #define ENDIAN_BIG (0) 17 | #elif XENON 18 | #define PLATFORM_FULL_NAME "XENON" 19 | #define PLATFORM_CONFIG_NAME "XENON-W" 20 | #define ENDIAN_BIG (1) 21 | #elif PS3 22 | #define PLATFORM_FULL_NAME "PS3" 23 | #define PLATFORM_CONFIG_NAME "PS3-W" 24 | #define ENDIAN_BIG (1) 25 | #else 26 | #error "Unsupported Platform!" 27 | #endif 28 | #else 29 | #error "Unsupported Game!" 30 | #endif 31 | 32 | #endif -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | [DRM/CDRM] Tomb Raider: Legend/Anniversary/Underworld DRM/CDRM Unpacker 2 | Copyright (C) Gh0stBlade 2015 - gh0stblade@live[dot]co.uk 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cdcEngineTools 2 | Tools for Tomb Raider games running on CDCEngine by Crystal Dynamics 3 | 4 | Compile Requirements: 5 | 6 | 1. Visual Studio 2013. 7 | 8 | Usage Requirements: 9 | 10 | 1. Visual C++ 2013 Redistributable. 11 | 12 | Tool Usage: 13 | 14 | 1. If the game is Tomb Raider: Legend or Tomb Raider: Anniversary skip to step 4. 15 | 2. Tomb Raider: Underworld DRM files are usually compressed. You must navigate to the correct folder i.e if TR8 and PC (TR8 PC-W). 16 | 3. Drag and drop the DRM file onto CDRM.EXE which will decompress the CDRM's compressed blocks. 17 | 4. Finally, to extract the DRM you must drag and drop the DRM file onto DRM.EXE. 18 | 19 | Note: It is important that the correct GAME and PLATFORM assets are passed to the correct tool otherwise unforeseen issues may occur! 20 | 21 | Disclaimer: I am not responsible for any damage these tools may incur. 22 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/mztools.h: -------------------------------------------------------------------------------- 1 | /* 2 | Additional tools for Minizip 3 | Code: Xavier Roche '2004 4 | License: Same as ZLIB (www.gzip.org) 5 | */ 6 | 7 | #ifndef _zip_tools_H 8 | #define _zip_tools_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef _ZLIB_H 15 | #include "zlib.h" 16 | #endif 17 | 18 | #include "unzip.h" 19 | 20 | /* Repair a ZIP file (missing central directory) 21 | file: file to recover 22 | fileOut: output file after recovery 23 | fileOutTmp: temporary file name used for recovery 24 | */ 25 | extern int ZEXPORT unzRepair(const char* file, 26 | const char* fileOut, 27 | const char* fileOutTmp, 28 | uLong* nRecovered, 29 | uLong* bytesRecovered); 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_INIT([minizip], [1.2.8], [bugzilla.redhat.com]) 5 | AC_CONFIG_SRCDIR([minizip.c]) 6 | AM_INIT_AUTOMAKE([foreign]) 7 | LT_INIT 8 | 9 | AC_MSG_CHECKING([whether to build example programs]) 10 | AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs])) 11 | AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes]) 12 | if test "$enable_demos" = yes 13 | then 14 | AC_MSG_RESULT([yes]) 15 | else 16 | AC_MSG_RESULT([no]) 17 | fi 18 | 19 | case "${host}" in 20 | *-mingw* | mingw*) 21 | WIN32="yes" 22 | ;; 23 | *) 24 | ;; 25 | esac 26 | AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) 27 | 28 | 29 | AC_SUBST([HAVE_UNISTD_H], [0]) 30 | AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], []) 31 | AC_CONFIG_FILES([Makefile minizip.pc]) 32 | AC_OUTPUT 33 | -------------------------------------------------------------------------------- /DRM/PlatformSetup.h: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_H 2 | #define PLATFORM_H 3 | 4 | #if PC 5 | #define PLATFORM_FULL_NAME "PC" 6 | #define PLATFORM_CONFIG_NAME "PC-W" 7 | #define ENDIAN_BIG (0) 8 | #elif PS2 9 | #define PLATFORM_FULL_NAME "PS2" 10 | #define PLATFORM_CONFIG_NAME "PS2-W" 11 | #define ENDIAN_BIG (0) 12 | #elif PSP 13 | #define PLATFORM_FULL_NAME "PSP" 14 | #define PLATFORM_CONFIG_NAME "PSP-W" 15 | #define ENDIAN_BIG (0) 16 | #elif WII 17 | #define PLATFORM_FULL_NAME "WII" 18 | #define PLATFORM_CONFIG_NAME "WII-W" 19 | #define ENDIAN_BIG (0) 20 | #elif XENON 21 | #define PLATFORM_FULL_NAME "XENON" 22 | #define PLATFORM_CONFIG_NAME "XENON-W" 23 | #define ENDIAN_BIG (1) 24 | #elif PS3 25 | #define PLATFORM_FULL_NAME "PS3" 26 | #define PLATFORM_CONFIG_NAME "PS3-W" 27 | #define ENDIAN_BIG (1) 28 | #elif NGC 29 | #define PLATFORM_FULL_NAME "NGC" 30 | #define PLATFORM_CONFIG_NAME "NGC-W" 31 | #define ENDIAN_BIG (1) 32 | #else 33 | #error "Unsupported Platform!" 34 | #endif 35 | 36 | #endif -------------------------------------------------------------------------------- /PCD2DDS/DDS.h: -------------------------------------------------------------------------------- 1 | #ifndef DDS_H 2 | #define DDS_H 3 | 4 | #include 5 | 6 | #define SECTION_MAGIC (0x54434553) 7 | #define PCD_MAGIC (0x39444350) 8 | #define DDS_MAGIC (0x20534444) 9 | #define TEXTURE_SECTION_TYPE (5) 10 | 11 | /*enum DDSFormat 12 | { 13 | DXT1 = 0x31545844, 14 | DXT3 = 0x33545844, 15 | DTX5 = 0x35545844 16 | };*/ 17 | 18 | #pragma pack(push, 1) 19 | struct DDSHeader 20 | { 21 | unsigned int m_magic; 22 | unsigned int m_size; 23 | unsigned int m_flags; 24 | unsigned int m_height; 25 | 26 | unsigned int m_width; 27 | unsigned int m_pitchOrLinearSize; 28 | unsigned int m_dummy; 29 | unsigned int m_depth; 30 | unsigned int m_mipCount; 31 | 32 | unsigned int m_reserved[12]; 33 | unsigned int m_format; 34 | }; 35 | 36 | #pragma pack(pop) 37 | 38 | void ConvertDDSToPCD(const char* filePath); 39 | void WritePCDDS(const char* resultFileName, std::ifstream& ifs); 40 | void WritePCTarga(const char* resultFileName, std::ifstream& ifs); 41 | 42 | #endif -------------------------------------------------------------------------------- /External/zlib/contrib/masmx86/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Summary 3 | ------- 4 | This directory contains ASM implementations of the functions 5 | longest_match() and inflate_fast(). 6 | 7 | 8 | Use instructions 9 | ---------------- 10 | Assemble using MASM, and copy the object files into the zlib source 11 | directory, then run the appropriate makefile, as suggested below. You can 12 | donwload MASM from here: 13 | 14 | http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64 15 | 16 | You can also get objects files here: 17 | 18 | http://www.winimage.com/zLibDll/zlib124_masm_obj.zip 19 | 20 | Build instructions 21 | ------------------ 22 | * With Microsoft C and MASM: 23 | nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" 24 | 25 | * With Borland C and TASM: 26 | make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" OBJPA="+match686c.obj+match686.obj+inffas32.obj" 27 | 28 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/iowin32.h: -------------------------------------------------------------------------------- 1 | /* iowin32.h -- IO base function header for compress/uncompress .zip 2 | Version 1.1, February 14h, 2010 3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 4 | 5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 6 | 7 | Modifications for Zip64 support 8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 9 | 10 | For more info read MiniZip_info.txt 11 | 12 | */ 13 | 14 | #include 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 22 | void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); 23 | void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); 24 | void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /CDRM/File.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_H 2 | #define FILE_H 3 | 4 | #include "PlatformSetup.h" 5 | 6 | #include 7 | #include 8 | 9 | unsigned int ReverseUInt(unsigned int uiInput); 10 | int ReverseInt(int iInput); 11 | unsigned short ReverseUShort(unsigned short usInput); 12 | short ReverseShort(short sInput); 13 | 14 | char ReadByte(std::ifstream& ifs); 15 | unsigned char ReadUByte(std::ifstream& ifs); 16 | short ReadShort(std::ifstream& ifs); 17 | unsigned short ReadUShort(std::ifstream& ifs); 18 | int ReadInt(std::ifstream& ifs); 19 | unsigned int ReadUInt(std::ifstream& ifs); 20 | 21 | void WriteByte(std::ofstream& ofs, char input); 22 | void WriteUByte(std::ofstream& ofs, unsigned char input); 23 | void WriteShort(std::ofstream& ofs, short input); 24 | void WriteUShort(std::ofstream& ofs, unsigned short input); 25 | void WriteInt(std::ofstream& ofs, int input); 26 | void WriteUInt(std::ofstream& ofs, unsigned int input); 27 | 28 | unsigned int GetFileType(const char* szFilePath); 29 | 30 | #endif -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {048af943-022b-4db6-beeb-a54c34774ee2} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {c1d600d2-888f-4aea-b73e-8b0dd9befa0c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {0844199a-966b-4f19-81db-1e0125e141b9} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {c0419b40-bf50-40da-b153-ff74215b79de} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {bb87b070-735b-478e-92ce-7383abb2f36c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {f46ab6a6-548f-43cb-ae96-681abb5bd5db} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {fa61a89f-93fc-4c89-b29e-36224b7592f4} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {d4b85da0-2ba2-4934-b57f-e2584e3848ee} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {e573e075-00bd-4a7d-bd67-a8cc9bfc5aca} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/make_vms.com: -------------------------------------------------------------------------------- 1 | $ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig 2 | $ open/write zdef vmsdefs.h 3 | $ copy sys$input: zdef 4 | $ deck 5 | #define unix 6 | #define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from 7 | #define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator 8 | #define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord 9 | #define Write_EndOfCentralDirectoryRecord Write_EoDRecord 10 | $ eod 11 | $ close zdef 12 | $ copy vmsdefs.h,ioapi.h_orig ioapi.h 13 | $ cc/include=[--]/prefix=all ioapi.c 14 | $ cc/include=[--]/prefix=all miniunz.c 15 | $ cc/include=[--]/prefix=all unzip.c 16 | $ cc/include=[--]/prefix=all minizip.c 17 | $ cc/include=[--]/prefix=all zip.c 18 | $ link miniunz,unzip,ioapi,[--]libz.olb/lib 19 | $ link minizip,zip,ioapi,[--]libz.olb/lib 20 | $ mcr []minizip test minizip_info.txt 21 | $ mcr []miniunz -l test.zip 22 | $ rename minizip_info.txt; minizip_info.txt_old 23 | $ mcr []miniunz test.zip 24 | $ delete test.zip;* 25 | $exit 26 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libminizip.la 2 | 3 | if COND_DEMOS 4 | bin_PROGRAMS = miniunzip minizip 5 | endif 6 | 7 | zlib_top_srcdir = $(top_srcdir)/../.. 8 | zlib_top_builddir = $(top_builddir)/../.. 9 | 10 | AM_CPPFLAGS = -I$(zlib_top_srcdir) 11 | AM_LDFLAGS = -L$(zlib_top_builddir) 12 | 13 | if WIN32 14 | iowin32_src = iowin32.c 15 | iowin32_h = iowin32.h 16 | endif 17 | 18 | libminizip_la_SOURCES = \ 19 | ioapi.c \ 20 | mztools.c \ 21 | unzip.c \ 22 | zip.c \ 23 | ${iowin32_src} 24 | 25 | libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz 26 | 27 | minizip_includedir = $(includedir)/minizip 28 | minizip_include_HEADERS = \ 29 | crypt.h \ 30 | ioapi.h \ 31 | mztools.h \ 32 | unzip.h \ 33 | zip.h \ 34 | ${iowin32_h} 35 | 36 | pkgconfigdir = $(libdir)/pkgconfig 37 | pkgconfig_DATA = minizip.pc 38 | 39 | EXTRA_PROGRAMS = miniunzip minizip 40 | 41 | miniunzip_SOURCES = miniunz.c 42 | miniunzip_LDADD = libminizip.la 43 | 44 | minizip_SOURCES = minizip.c 45 | minizip_LDADD = libminizip.la -lz 46 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc9/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1,2,8,0 6 | PRODUCTVERSION 1,2,8,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.8\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1,2,8,0 6 | PRODUCTVERSION 1,2,8,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.8\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc11/zlib.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IDR_VERSION1 1 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 5 | FILEVERSION 1,2,8,0 6 | PRODUCTVERSION 1,2,8,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 // not used 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "040904E4" 16 | //language ID = U.S. English, char set = Windows, Multilingual 17 | 18 | BEGIN 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 20 | VALUE "FileVersion", "1.2.8\0" 21 | VALUE "InternalName", "zlib\0" 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" 23 | VALUE "ProductName", "ZLib.DLL\0" 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 25 | VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0409, 1252 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /DRM/File.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_H 2 | #define FILE_H 3 | 4 | #include 5 | #include 6 | 7 | unsigned int getFileMagic(const char* filePath); 8 | 9 | unsigned int ReverseUInt(unsigned int uiInput); 10 | int ReverseInt(int iInput); 11 | unsigned short ReverseUShort(unsigned short usInput); 12 | short ReverseShort(short sInput); 13 | 14 | char ReadByte(std::ifstream& ifs); 15 | unsigned char ReadUByte(std::ifstream& ifs); 16 | short ReadShort(std::ifstream& ifs); 17 | unsigned short ReadUShort(std::ifstream& ifs); 18 | int ReadInt(std::ifstream& ifs); 19 | unsigned int ReadUInt(std::ifstream& ifs); 20 | 21 | void WriteByte(std::ofstream& ofs, char input); 22 | void WriteUByte(std::ofstream& ofs, unsigned char input); 23 | void WriteShort(std::ofstream& ofs, short input); 24 | void WriteUShort(std::ofstream& ofs, unsigned short input); 25 | void WriteInt(std::ofstream& ofs, int input); 26 | void WriteUInt(std::ofstream& ofs, unsigned int input); 27 | 28 | void CreateDirectories(std::string str); 29 | bool IsDirectory(const char* filePath); 30 | bool DoesFileExist(const char* filePath); 31 | 32 | #endif -------------------------------------------------------------------------------- /PCD2DDS/File.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_H 2 | #define FILE_H 3 | 4 | #include 5 | #include 6 | 7 | unsigned int getFileMagic(const char* filePath); 8 | 9 | unsigned int ReverseUInt(unsigned int uiInput); 10 | int ReverseInt(int iInput); 11 | unsigned short ReverseUShort(unsigned short usInput); 12 | short ReverseShort(short sInput); 13 | 14 | char ReadByte(std::ifstream& ifs); 15 | unsigned char ReadUByte(std::ifstream& ifs); 16 | short ReadShort(std::ifstream& ifs); 17 | unsigned short ReadUShort(std::ifstream& ifs); 18 | int ReadInt(std::ifstream& ifs); 19 | unsigned int ReadUInt(std::ifstream& ifs); 20 | 21 | void WriteByte(std::ofstream& ofs, char input); 22 | void WriteUByte(std::ofstream& ofs, unsigned char input); 23 | void WriteShort(std::ofstream& ofs, short input); 24 | void WriteUShort(std::ofstream& ofs, unsigned short input); 25 | void WriteInt(std::ofstream& ofs, int input); 26 | void WriteUInt(std::ofstream& ofs, unsigned int input); 27 | 28 | void CreateDirectories(std::string str); 29 | bool IsDirectory(const char* filePath); 30 | bool DoesFileExist(const char* filePath); 31 | 32 | #endif -------------------------------------------------------------------------------- /WAVE2WAV/File.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_H 2 | #define FILE_H 3 | 4 | #include 5 | #include 6 | 7 | unsigned int getFileMagic(const char* filePath); 8 | 9 | unsigned int ReverseUInt(unsigned int uiInput); 10 | int ReverseInt(int iInput); 11 | unsigned short ReverseUShort(unsigned short usInput); 12 | short ReverseShort(short sInput); 13 | 14 | char ReadByte(std::ifstream& ifs); 15 | unsigned char ReadUByte(std::ifstream& ifs); 16 | short ReadShort(std::ifstream& ifs); 17 | unsigned short ReadUShort(std::ifstream& ifs); 18 | int ReadInt(std::ifstream& ifs); 19 | unsigned int ReadUInt(std::ifstream& ifs); 20 | 21 | void WriteByte(std::ofstream& ofs, char input); 22 | void WriteUByte(std::ofstream& ofs, unsigned char input); 23 | void WriteShort(std::ofstream& ofs, short input); 24 | void WriteUShort(std::ofstream& ofs, unsigned short input); 25 | void WriteInt(std::ofstream& ofs, int input); 26 | void WriteUInt(std::ofstream& ofs, unsigned int input); 27 | 28 | void CreateDirectories(std::string str); 29 | bool IsDirectory(const char* filePath); 30 | bool DoesFileExist(const char* filePath); 31 | 32 | #endif -------------------------------------------------------------------------------- /External/zlib/contrib/masmx64/readme.txt: -------------------------------------------------------------------------------- 1 | Summary 2 | ------- 3 | This directory contains ASM implementations of the functions 4 | longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t), 5 | for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits. 6 | 7 | gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits 8 | assembly optimized version from Jean-loup Gailly original longest_match function 9 | 10 | inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing 11 | original function from Mark Adler 12 | 13 | Use instructions 14 | ---------------- 15 | Assemble the .asm files using MASM and put the object files into the zlib source 16 | directory. You can also get object files here: 17 | 18 | http://www.winimage.com/zLibDll/zlib124_masm_obj.zip 19 | 20 | define ASMV and ASMINF in your project. Include inffas8664.c in your source tree, 21 | and inffasx64.obj and gvmat64.obj as object to link. 22 | 23 | 24 | Build instructions 25 | ------------------ 26 | run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe) 27 | 28 | ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK 29 | 30 | You can get Windows 2003 server DDK with ml64 and cl for AMD64 from 31 | http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) 32 | -------------------------------------------------------------------------------- /WAVE2WAV/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "RIFF.h" 5 | #include "File.h" 6 | 7 | void PrintToolInfo(); 8 | void PrintToolUsage(); 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | //Print the tool info on-screen. 13 | PrintToolInfo(); 14 | 15 | //If there are args to process. 16 | if (argc == 2) 17 | { 18 | unsigned int fileMagic = getFileMagic(argv[1]); 19 | 20 | switch (fileMagic) 21 | { 22 | case SECTION_MAGIC: 23 | ConvertWAVEToWAV(argv[1]); 24 | break; 25 | case RIFF_MAGIC: 26 | ConvertWAVToWAVE(argv[1]); 27 | break; 28 | } 29 | } 30 | else 31 | { 32 | std::cout << "Fatal Error: Insufficient amount of args!" << std::endl; 33 | PrintToolUsage(); 34 | } 35 | 36 | return 0; 37 | } 38 | 39 | const char* GAME_NAME = "Tomb Raider: Legend"; 40 | const char* PLATFORM_FULL_NAME = "PC"; 41 | 42 | void PrintToolInfo() 43 | { 44 | #if DEBUG 45 | std::cout << "PCD2DDS v1.0 (DEBUG) for " << GAME_NAME << std::endl; 46 | #else 47 | std::cout << "PCD2DDS v1.0 for " << GAME_NAME << std::endl; 48 | #endif 49 | //std::cout << "Platform: " << PLATFORM_FULL_NAME << " (" << PLATFORM_CONFIG_NAME << ")" << std::endl; 50 | std::cout << "Built: " << (__DATE__ ", " __TIME__) << std::endl; 51 | std::cout << "By Gh0stBlade" << std::endl; 52 | } 53 | 54 | void PrintToolUsage() 55 | { 56 | std::cout << "PCD2DDS.exe [input.pcd/.dds]" << std::endl; 57 | system("pause"); 58 | } -------------------------------------------------------------------------------- /WAVE2WAV/WAVE2WAV.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /CDRM/CDRM.h: -------------------------------------------------------------------------------- 1 | #ifndef CDRM_H 2 | #define CDRM_H 3 | 4 | //Includes 5 | #include 6 | #include 7 | #include 8 | 9 | //Constants 10 | const unsigned int CDRM_MAGIC = 0x4D524443; 11 | const unsigned int CDRM_MAGIC_ENDIAN_BIG = 0x4344524D; 12 | const unsigned int CDRM_MAX_COMPRESSED_BLOCKS = 16777215; 13 | 14 | //Platform specific constants 15 | #if (PC || XENON || PS3) 16 | const unsigned int CDRM_MAX_BLOCK_SIZE = 262144; 17 | const unsigned short CDRM_FILE_ALIGNMENT = 15; 18 | #elif (WII) 19 | const unsigned int CDRM_MAX_BLOCK_SIZE = 131072; 20 | const unsigned short CDRM_FILE_ALIGNMENT = 31; 21 | #else 22 | #error "Unsupported Platform!" 23 | #endif 24 | 25 | //Structs 26 | struct CDRMEntry 27 | { 28 | unsigned int m_compressedSize; 29 | unsigned int m_uncompressedSize; 30 | }; 31 | 32 | //Classes 33 | class CDRM 34 | { 35 | public: 36 | CDRM(); 37 | ~CDRM(); 38 | 39 | void Decompress(const char* filePath); 40 | void Compress(const char* filePath, unsigned int compressionMode); 41 | 42 | private: 43 | unsigned int m_magic; 44 | unsigned int m_numUnknownBlocks; 45 | unsigned int m_numCompressedBlocks; 46 | std::vector m_entries; 47 | }; 48 | 49 | 50 | //Enums 51 | enum CDRMFlags 52 | { 53 | NONE = 0, 54 | UNCOMPRESSED = 1, 55 | COMPRESSED = 2 56 | }; 57 | 58 | void CompressData(char* szUncompressedData, unsigned int uiUncompressedSize, std::string &strOutData); 59 | void DecompressData(char* &szCompressedData, unsigned int compressedSize, char* &szUnCompressedData, unsigned int uncompressedSize); 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /External/zlib/zlib.map: -------------------------------------------------------------------------------- 1 | ZLIB_1.2.0 { 2 | global: 3 | compressBound; 4 | deflateBound; 5 | inflateBack; 6 | inflateBackEnd; 7 | inflateBackInit_; 8 | inflateCopy; 9 | local: 10 | deflate_copyright; 11 | inflate_copyright; 12 | inflate_fast; 13 | inflate_table; 14 | zcalloc; 15 | zcfree; 16 | z_errmsg; 17 | gz_error; 18 | gz_intmax; 19 | _*; 20 | }; 21 | 22 | ZLIB_1.2.0.2 { 23 | gzclearerr; 24 | gzungetc; 25 | zlibCompileFlags; 26 | } ZLIB_1.2.0; 27 | 28 | ZLIB_1.2.0.8 { 29 | deflatePrime; 30 | } ZLIB_1.2.0.2; 31 | 32 | ZLIB_1.2.2 { 33 | adler32_combine; 34 | crc32_combine; 35 | deflateSetHeader; 36 | inflateGetHeader; 37 | } ZLIB_1.2.0.8; 38 | 39 | ZLIB_1.2.2.3 { 40 | deflateTune; 41 | gzdirect; 42 | } ZLIB_1.2.2; 43 | 44 | ZLIB_1.2.2.4 { 45 | inflatePrime; 46 | } ZLIB_1.2.2.3; 47 | 48 | ZLIB_1.2.3.3 { 49 | adler32_combine64; 50 | crc32_combine64; 51 | gzopen64; 52 | gzseek64; 53 | gztell64; 54 | inflateUndermine; 55 | } ZLIB_1.2.2.4; 56 | 57 | ZLIB_1.2.3.4 { 58 | inflateReset2; 59 | inflateMark; 60 | } ZLIB_1.2.3.3; 61 | 62 | ZLIB_1.2.3.5 { 63 | gzbuffer; 64 | gzoffset; 65 | gzoffset64; 66 | gzclose_r; 67 | gzclose_w; 68 | } ZLIB_1.2.3.4; 69 | 70 | ZLIB_1.2.5.1 { 71 | deflatePending; 72 | } ZLIB_1.2.3.5; 73 | 74 | ZLIB_1.2.5.2 { 75 | deflateResetKeep; 76 | gzgetc_; 77 | inflateResetKeep; 78 | } ZLIB_1.2.5.1; 79 | 80 | ZLIB_1.2.7.1 { 81 | inflateGetDictionary; 82 | gzvprintf; 83 | } ZLIB_1.2.5.2; 84 | -------------------------------------------------------------------------------- /DRM/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "DRM.h" 5 | #include "Game.h" 6 | #include "PlatformSetup.h" 7 | #include "File.h" 8 | #include "Repack.h" 9 | 10 | void PrintToolInfo(); 11 | void PrintToolUsage(); 12 | 13 | int main(int argc, char* argv[]) 14 | { 15 | //Print the tool info on-screen. 16 | PrintToolInfo(); 17 | 18 | //If there are args to process. 19 | if (argc == 2) 20 | { 21 | if (IsDirectory(argv[1])) 22 | { 23 | char buff[128]; 24 | sprintf_s(buff, "%s%s", argv[1], "\\sectionList.txt");//unsafe 25 | 26 | if (DoesFileExist(buff)) 27 | { 28 | RepackSections(buff, argv[1]); 29 | } 30 | else 31 | { 32 | std::cout << "Warning failed to locate section list!" << std::endl; 33 | system("Pause"); 34 | } 35 | } 36 | else 37 | { 38 | cDRM mDRM; 39 | mDRM.ExtractSections(argv[1]); 40 | } 41 | } 42 | else 43 | { 44 | std::cout << "Fatal Error: Insufficient amount of args!" << std::endl; 45 | PrintToolUsage(); 46 | } 47 | 48 | return 0; 49 | } 50 | 51 | void PrintToolInfo() 52 | { 53 | #if DEBUG 54 | std::cout << "DRM v1.2 (DEBUG) for " << GAME_NAME << std::endl; 55 | #else 56 | std::cout << "DRM v1.2 for " << GAME_NAME << std::endl; 57 | #endif 58 | std::cout << "Platform: " << PLATFORM_FULL_NAME << " (" << PLATFORM_CONFIG_NAME << ")" << std::endl; 59 | std::cout << "Built: " << (__DATE__ ", " __TIME__) << std::endl; 60 | std::cout << "By Gh0stBlade" << std::endl; 61 | } 62 | 63 | void PrintToolUsage() 64 | { 65 | std::cout << "DRM.exe [input.drm]" << std::endl; 66 | system("pause"); 67 | } -------------------------------------------------------------------------------- /PCD2DDS/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "PCD.h" 5 | #include "File.h" 6 | #include "DDS.h" 7 | 8 | void PrintToolInfo(); 9 | void PrintToolUsage(); 10 | 11 | int main(int argc, char* argv[]) 12 | { 13 | //Print the tool info on-screen. 14 | PrintToolInfo(); 15 | 16 | //If there are args to process. 17 | if (argc == 2) 18 | { 19 | unsigned int fileMagic = getFileMagic(argv[1]); 20 | 21 | #if PS3 22 | fileMagic = ReverseUInt(fileMagic); 23 | #endif 24 | switch (fileMagic) 25 | { 26 | case SECTION_MAGIC: 27 | ConvertPCDToDDS(argv[1]); 28 | break; 29 | case DDS_MAGIC: 30 | ConvertDDSToPCD(argv[1]); 31 | break; 32 | default: 33 | std::cout << "Failed to detect file type!" << std::endl; 34 | break; 35 | } 36 | } 37 | else 38 | { 39 | std::cout << "Fatal Error: Insufficient amount of args!" << std::endl; 40 | PrintToolUsage(); 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | const char* GAME_NAME = "Tomb Raider: Legend"; 47 | const char* PLATFORM_FULL_NAME = "PC"; 48 | 49 | void PrintToolInfo() 50 | { 51 | #if DEBUG 52 | std::cout << "PCD2DDS v1.0 (DEBUG) for " << GAME_NAME << std::endl; 53 | #else 54 | std::cout << "PCD2DDS v1.0 for " << GAME_NAME << std::endl; 55 | #endif 56 | //std::cout << "Platform: " << PLATFORM_FULL_NAME << " (" << PLATFORM_CONFIG_NAME << ")" << std::endl; 57 | std::cout << "Built: " << (__DATE__ ", " __TIME__) << std::endl; 58 | std::cout << "By Gh0stBlade" << std::endl; 59 | } 60 | 61 | void PrintToolUsage() 62 | { 63 | std::cout << "PCD2DDS.exe [input.pcd/.dds]" << std::endl; 64 | system("pause"); 65 | } -------------------------------------------------------------------------------- /CDRM/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "CDRM.h" 5 | #include "Game.h" 6 | #include "PlatformSetup.h" 7 | #include "File.h" 8 | 9 | void PrintToolInfo(); 10 | void PrintToolUsage(); 11 | 12 | int main(int argc, char* argv[]) 13 | { 14 | //Print the tool info on-screen. 15 | PrintToolInfo(); 16 | 17 | //If there are args to process. 18 | if (argc == 2) 19 | { 20 | //Get filetype and perform specific action 21 | switch (GetFileType(argv[1])) 22 | { 23 | case -1://Error occured 24 | return 0; 25 | case CDRM_MAGIC_ENDIAN_BIG: 26 | case CDRM_MAGIC: //"CDRM" 27 | { 28 | //Decompress the cdrm from input path 29 | CDRM mCDRM; 30 | mCDRM.Decompress(argv[1]); 31 | break; 32 | } 33 | default: 34 | { //Compress the drm from the input path 35 | CDRM mCDRM; 36 | mCDRM.Compress(argv[1], 2); 37 | break; 38 | } 39 | } 40 | 41 | 42 | } 43 | else 44 | { 45 | std::cout << "Fatal Error: Insufficient amount of args!" << std::endl; 46 | PrintToolUsage(); 47 | } 48 | 49 | return 0; 50 | } 51 | 52 | void PrintToolInfo() 53 | { 54 | #if DEBUG 55 | std::cout << "CDRM v1.1 (DEBUG) for " << GAME_NAME << std::endl; 56 | #else 57 | std::cout << "CDRM v1.1 for " << GAME_NAME << std::endl; 58 | #endif 59 | std::cout << "Platform: " << PLATFORM_FULL_NAME << " (" << PLATFORM_CONFIG_NAME << ")" << std::endl; 60 | std::cout << "Built: " << (__DATE__ ", " __TIME__) << std::endl; 61 | std::cout << "By Gh0stBlade" << std::endl; 62 | } 63 | 64 | void PrintToolUsage() 65 | { 66 | std::cout << "CDRM.exe [input.drm]" << std::endl; 67 | system("pause"); 68 | } -------------------------------------------------------------------------------- /PCD2DDS/PCD2DDS.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/minizip.1: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .TH minizip 1 "May 2, 2001" 3 | .\" Please adjust this date whenever revising the manpage. 4 | .\" 5 | .\" Some roff macros, for reference: 6 | .\" .nh disable hyphenation 7 | .\" .hy enable hyphenation 8 | .\" .ad l left justify 9 | .\" .ad b justify to both left and right margins 10 | .\" .nf disable filling 11 | .\" .fi enable filling 12 | .\" .br insert line break 13 | .\" .sp insert n+1 empty lines 14 | .\" for manpage-specific macros, see man(7) 15 | .SH NAME 16 | minizip - create ZIP archives 17 | .SH SYNOPSIS 18 | .B minizip 19 | .RI [ -o ] 20 | zipfile [ " files" ... ] 21 | .SH DESCRIPTION 22 | .B minizip 23 | is a simple tool which allows the creation of compressed file archives 24 | in the ZIP format used by the MS-DOS utility PKZIP. It was written as 25 | a demonstration of the 26 | .IR zlib (3) 27 | library and therefore lack many of the features of the 28 | .IR zip (1) 29 | program. 30 | .SH OPTIONS 31 | The first argument supplied is the name of the ZIP archive to create or 32 | .RI -o 33 | in which case it is ignored and the second argument treated as the 34 | name of the ZIP file. If the ZIP file already exists it will be 35 | overwritten. 36 | .PP 37 | Subsequent arguments specify a list of files to place in the ZIP 38 | archive. If none are specified then an empty archive will be created. 39 | .SH SEE ALSO 40 | .BR miniunzip (1), 41 | .BR zlib (3), 42 | .BR zip (1). 43 | .SH AUTHOR 44 | This program was written by Gilles Vollant. This manual page was 45 | written by Mark Brown . 46 | 47 | -------------------------------------------------------------------------------- /DRM/DRM.h: -------------------------------------------------------------------------------- 1 | #ifndef DRM_H 2 | #define DRM_H 3 | 4 | //Includes 5 | #include 6 | 7 | //Constants 8 | const unsigned int DRM_MAX_SECTIONS = 16777215; 9 | 10 | #define REPACK_MODE (0)//Must be on for PCD->DDS tool 11 | 12 | #if (TR7 || TRAE) 13 | #define DRM_VERSION (14) 14 | #elif TR8 15 | #define DRM_VERSION (19) 16 | #elif TRAS 17 | #define DRM_VERSION (21) 18 | #else 19 | #error "Unsupported Game!" 20 | #endif 21 | 22 | struct Section 23 | { 24 | unsigned int uiSize; 25 | unsigned char ucType; 26 | unsigned char ucUnk00; 27 | unsigned short usUnk01; 28 | unsigned int uiHeaderSize; 29 | unsigned int uiHash; 30 | unsigned int uiLang; 31 | }; 32 | 33 | //Classes 34 | class cDRM 35 | { 36 | 37 | public: 38 | cDRM(); 39 | ~cDRM(); 40 | 41 | void ExtractSections(char* szFilePath); 42 | 43 | private: 44 | char* m_filePath; 45 | unsigned int m_version; 46 | 47 | #if TR8 48 | unsigned int m_nameSize; 49 | unsigned int m_paddingSize; 50 | unsigned int m_unk00; 51 | unsigned int m_unk01; 52 | #elif TRAS 53 | unsigned int m_nameSize; 54 | unsigned int m_paddingSize; 55 | unsigned int m_unk00; 56 | unsigned int m_unk01; 57 | unsigned int m_unk02; 58 | #endif 59 | 60 | unsigned int m_numSections; 61 | 62 | std::vector
m_sections; 63 | }; 64 | 65 | //Enums 66 | enum SectionType 67 | { 68 | #if TR7 69 | GENERAL = 0, 70 | EMPTY = 1, 71 | ANIMATION = 2, 72 | PUSHBUFFER_WC = 3, 73 | PUSHBUFFER = 4, 74 | TEXTURE = 5, 75 | WAVE = 6, 76 | DTPDATA = 7, 77 | SCRIPT = 8, 78 | SHADERLIB = 9, 79 | NUM_SECTION_TYPES = 10 80 | 81 | #elif TR8 82 | GENERAL = 0, 83 | EMPTY = 1, 84 | ANIMATION = 2, 85 | PUSHBUFFER_WC = 3, 86 | PUSHBUFFER = 4, 87 | TEXTURE = 5, 88 | WAVE = 6, 89 | DTPDATA = 7, 90 | SCRIPT = 8, 91 | SHADERLIB = 9, 92 | MATERIAL = 10, 93 | OBJ = 11, 94 | MESH = 12, 95 | UNK13 = 13 96 | #endif 97 | 98 | }; 99 | 100 | #endif -------------------------------------------------------------------------------- /CDRM/CDRM.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | 49 | 50 | Resource Files 51 | 52 | 53 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/miniunzip.1: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .TH miniunzip 1 "Nov 7, 2001" 3 | .\" Please adjust this date whenever revising the manpage. 4 | .\" 5 | .\" Some roff macros, for reference: 6 | .\" .nh disable hyphenation 7 | .\" .hy enable hyphenation 8 | .\" .ad l left justify 9 | .\" .ad b justify to both left and right margins 10 | .\" .nf disable filling 11 | .\" .fi enable filling 12 | .\" .br insert line break 13 | .\" .sp insert n+1 empty lines 14 | .\" for manpage-specific macros, see man(7) 15 | .SH NAME 16 | miniunzip - uncompress and examine ZIP archives 17 | .SH SYNOPSIS 18 | .B miniunzip 19 | .RI [ -exvlo ] 20 | zipfile [ files_to_extract ] [-d tempdir] 21 | .SH DESCRIPTION 22 | .B minizip 23 | is a simple tool which allows the extraction of compressed file 24 | archives in the ZIP format used by the MS-DOS utility PKZIP. It was 25 | written as a demonstration of the 26 | .IR zlib (3) 27 | library and therefore lack many of the features of the 28 | .IR unzip (1) 29 | program. 30 | .SH OPTIONS 31 | A number of options are supported. With the exception of 32 | .BI \-d\ tempdir 33 | these must be supplied before any 34 | other arguments and are: 35 | .TP 36 | .BI \-l\ ,\ \-\-v 37 | List the files in the archive without extracting them. 38 | .TP 39 | .B \-o 40 | Overwrite files without prompting for confirmation. 41 | .TP 42 | .B \-x 43 | Extract files (default). 44 | .PP 45 | The 46 | .I zipfile 47 | argument is the name of the archive to process. The next argument can be used 48 | to specify a single file to extract from the archive. 49 | 50 | Lastly, the following option can be specified at the end of the command-line: 51 | .TP 52 | .BI \-d\ tempdir 53 | Extract the archive in the directory 54 | .I tempdir 55 | rather than the current directory. 56 | .SH SEE ALSO 57 | .BR minizip (1), 58 | .BR zlib (3), 59 | .BR unzip (1). 60 | .SH AUTHOR 61 | This program was written by Gilles Vollant. This manual page was 62 | written by Mark Brown . The -d tempdir option 63 | was added by Dirk Eddelbuettel . 64 | -------------------------------------------------------------------------------- /DRM/DRM.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | 55 | 56 | Resource Files 57 | 58 | 59 | -------------------------------------------------------------------------------- /External/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (z_const Bytef *)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {c1f6a2e3-5da5-4955-8653-310d3efe05a9} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {c2aaffdc-2c95-4d6f-8466-4bec5890af2c} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | {c274fe07-05f2-461c-964b-f6341e4e7eb5} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | -------------------------------------------------------------------------------- /PCD2DDS/PCD.h: -------------------------------------------------------------------------------- 1 | #ifndef PCD_H 2 | #define PCD_H 3 | 4 | #define SECTION_MAGIC (0x54434553) 5 | #define PCD_MAGIC (0x39444350) 6 | #define DDS_MAGIC (0x20534444) 7 | #define TEXTURE_SECTION_TYPE (5) 8 | 9 | #define PS3 0 10 | 11 | #define PS3T_MAGIC (0x50533354) 12 | 13 | #include 14 | 15 | namespace cdc 16 | { 17 | namespace PC 18 | { 19 | namespace Texture 20 | { 21 | enum kFormat 22 | { 23 | BPP_32 = 0x15, 24 | DXT1 = 0x31545844, 25 | DXT3 = 0x33545844, 26 | DXT5 = 0x35545844 27 | }; 28 | 29 | enum kFlags//Taken from TR7.pdb 30 | { 31 | FILTER_POINT = 0x0, 32 | FILTER_BILINEAR = 0x1, 33 | FILTER_TRILINEAR = 0x2, 34 | FILTER_ANISOTROPIC_1X = 0x3, 35 | FILTER_ANISOTROPIC_2X = 0x4, 36 | FILTER_ANISOTROPIC_4X = 0x6, 37 | FILTER_ANISOTROPIC_8X = 0xa, 38 | FILTER_ANISOTROPIC_16X = 0x12, 39 | FILTER_BEST = 0x100, 40 | FILTER_DEFAULT = 0x12, 41 | FILTER_INVALID = 0x200, 42 | }; 43 | 44 | #pragma pack(push, 1) 45 | struct Header 46 | { 47 | unsigned int m_magic; 48 | enum PCDFMT m_format; 49 | unsigned int m_textureDataSize; 50 | unsigned int m_paletteDataSize; 51 | unsigned short m_width; 52 | unsigned short m_height; 53 | unsigned char m_depth; 54 | unsigned char m_numMipMaps; 55 | unsigned short m_flags; 56 | }; 57 | #pragma pack(pop) 58 | 59 | void WriteDDS(const cdc::PC::Texture::Header& header, char* textureData, char* resultFileName); 60 | void WriteTarga(const cdc::PC::Texture::Header& header, char* textureData, char* resultFileName); 61 | } 62 | } 63 | 64 | namespace ps3 65 | { 66 | namespace Texture 67 | { 68 | enum kFormat 69 | { 70 | DXT1 = 0x86, 71 | //DXT3 = 0x33545844, 72 | DXT5 = 0x88 73 | }; 74 | 75 | #pragma pack(push, 1) 76 | struct Header 77 | { 78 | unsigned int m_magic; 79 | unsigned int m_textureDataSize; 80 | unsigned short m_unk00; 81 | unsigned short m_unk01; 82 | unsigned char m_format; 83 | unsigned char m_unk02; 84 | unsigned short m_unk03; 85 | 86 | unsigned int m_unk04; 87 | unsigned short m_width; 88 | unsigned short m_height; 89 | unsigned int m_unk05; 90 | unsigned int m_unk06; 91 | unsigned int m_unk07; 92 | }; 93 | #pragma pack(pop) 94 | 95 | unsigned int getFormat(unsigned int format); 96 | } 97 | } 98 | } 99 | 100 | void ConvertPCDToDDS(const char* filePath); 101 | 102 | #endif -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/readme.txt: -------------------------------------------------------------------------------- 1 | Building instructions for the DLL versions of Zlib 1.2.8 2 | ======================================================== 3 | 4 | This directory contains projects that build zlib and minizip using 5 | Microsoft Visual C++ 9.0/10.0. 6 | 7 | You don't need to build these projects yourself. You can download the 8 | binaries from: 9 | http://www.winimage.com/zLibDll 10 | 11 | More information can be found at this site. 12 | 13 | 14 | 15 | 16 | 17 | Build instructions for Visual Studio 2008 (32 bits or 64 bits) 18 | -------------------------------------------------------------- 19 | - Uncompress current zlib, including all contrib/* files 20 | - Compile assembly code (with Visual Studio Command Prompt) by running: 21 | bld_ml64.bat (in contrib\masmx64) 22 | bld_ml32.bat (in contrib\masmx86) 23 | - Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008 24 | - Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32" 25 | 26 | Build instructions for Visual Studio 2010 (32 bits or 64 bits) 27 | -------------------------------------------------------------- 28 | - Uncompress current zlib, including all contrib/* files 29 | - Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010 30 | 31 | Build instructions for Visual Studio 2012 (32 bits or 64 bits) 32 | -------------------------------------------------------------- 33 | - Uncompress current zlib, including all contrib/* files 34 | - Open contrib\vstudio\vc11\zlibvc.sln with Microsoft Visual C++ 2012 35 | 36 | 37 | Important 38 | --------- 39 | - To use zlibwapi.dll in your application, you must define the 40 | macro ZLIB_WINAPI when compiling your application's source files. 41 | 42 | 43 | Additional notes 44 | ---------------- 45 | - This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built 46 | by Gilles Vollant from the zlib 1.1.x sources, and distributed at 47 | http://www.winimage.com/zLibDll 48 | It uses the WINAPI calling convention for the exported functions, and 49 | includes the minizip functionality. If your application needs that 50 | particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. 51 | 52 | - The new DLL was renamed because there exist several incompatible 53 | versions of zlib.dll on the Internet. 54 | 55 | - There is also an official DLL build of zlib, named zlib1.dll. This one 56 | is exporting the functions using the CDECL convention. See the file 57 | win32\DLL_FAQ.txt found in this zlib distribution. 58 | 59 | - There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol 60 | has a slightly different effect. To avoid compatibility problems, do 61 | not define it here. 62 | 63 | 64 | Gilles Vollant 65 | info@winimage.com 66 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {174213f6-7f66-4ae8-a3a8-a1e0a1e6ffdd} 6 | 7 | 8 | 9 | 10 | Source Files 11 | 12 | 13 | Source Files 14 | 15 | 16 | Source Files 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | 68 | 69 | Source Files 70 | 71 | 72 | 73 | 74 | Source Files 75 | 76 | 77 | -------------------------------------------------------------------------------- /External/zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (z_const Bytef *)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 79 | (sourceLen >> 25) + 13; 80 | } 81 | -------------------------------------------------------------------------------- /DRM/Repack.cpp: -------------------------------------------------------------------------------- 1 | #include "Repack.h" 2 | 3 | #include "DRM.h" 4 | #include "File.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void RepackSections(const char* sectionListPath, const char* basePath) 12 | { 13 | 14 | std::string sectionFileName; 15 | int numSections = 0; 16 | std::ofstream ofs("Repacked.drm", std::ios::binary); 17 | 18 | WriteUInt(ofs, DRM_VERSION); 19 | WriteUInt(ofs, 0);//Placeholder 20 | 21 | //Read and write DRM headers 22 | std::ifstream sectionListFile(sectionListPath); 23 | while (std::getline(sectionListFile, sectionFileName)) 24 | { 25 | numSections++; 26 | 27 | std::stringstream sectionPath; 28 | sectionPath << basePath << "\\" << sectionFileName; 29 | 30 | std::ifstream ifs(sectionPath.str(), std::ios::binary); 31 | int sectHdr = ReadUInt(ifs);//Unused 32 | 33 | // 34 | std::string path(sectionPath.str()); 35 | std::string filename; 36 | 37 | size_t pos = path.find_last_of("\\"); 38 | if (pos != std::string::npos) 39 | { 40 | filename.assign(path.begin() + pos + 1, path.end()); 41 | pos = path.find_last_of("_"); 42 | filename.assign(path.begin() + pos + 1, path.end()); 43 | filename.erase(filename.find_first_of("."), std::string::npos); 44 | } 45 | else 46 | { 47 | filename = path; 48 | } 49 | 50 | unsigned int hash; 51 | sscanf(filename.c_str(), "%x", &hash); 52 | 53 | WriteUInt(ofs, ReadUInt(ifs)); 54 | WriteUByte(ofs, ReadUByte(ifs)); 55 | WriteUByte(ofs, ReadUByte(ifs)); 56 | WriteUShort(ofs, ReadUShort(ifs)); 57 | WriteUInt(ofs, ReadUInt(ifs)); 58 | unsigned int sectionHash = ReadUInt(ifs); 59 | if (sectionHash != hash) 60 | { 61 | std::cout << "Warning: Detected hash mis-match!" << std::endl; 62 | sectionHash = hash; 63 | } 64 | WriteUInt(ofs, sectionHash); 65 | 66 | WriteUInt(ofs, ReadUInt(ifs)); 67 | ifs.close(); 68 | } 69 | sectionListFile.close(); 70 | 71 | //Read and write section data 72 | std::ifstream sectionListFile2(sectionListPath); 73 | while (std::getline(sectionListFile2, sectionFileName)) 74 | { 75 | std::stringstream sectionPath; 76 | sectionPath << basePath << "\\" << sectionFileName; 77 | 78 | std::ifstream ifs(sectionPath.str(), std::ios::binary); 79 | 80 | //Get section data size 81 | ifs.seekg(0x0, SEEK_END); 82 | int dataSize = (ifs.tellg()); 83 | dataSize -= 0x18; 84 | ifs.seekg(0x18, SEEK_SET); 85 | 86 | char* sectionData = new char[dataSize]; 87 | ifs.read(sectionData, dataSize); 88 | ofs.write(sectionData, dataSize); 89 | delete[] sectionData; 90 | 91 | ifs.close(); 92 | } 93 | sectionListFile2.close(); 94 | 95 | 96 | //Write num files 97 | ofs.seekp(0x4, SEEK_SET); 98 | WriteUInt(ofs, numSections); 99 | 100 | ofs.flush(); 101 | ofs.close(); 102 | 103 | } -------------------------------------------------------------------------------- /DRM/FileExtensions.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEEXTENSIONS_H 2 | #define FILEEXTESNIONS_H 3 | 4 | #if (TR7 || TRAE) 5 | 6 | char* szExtensions[] 7 | { 8 | ".gnc", 9 | ".ept", 10 | ".ani", 11 | ".pbrwc", 12 | ".pbr", 13 | ".pcd", 14 | ".wave", 15 | ".dtp", 16 | ".script", 17 | ".shad", 18 | ".nst" 19 | }; 20 | #elif TR8 21 | #if PC 22 | char* szExtensions[] 23 | { 24 | ".gnc", 25 | ".unk01", 26 | ".ani", 27 | ".unk03", 28 | ".unk04", 29 | ".tr8pcd9", 30 | ".fsb", 31 | ".dtp", 32 | ".script", 33 | ".shad", 34 | ".matd", 35 | ".obj", 36 | ".tr8mesh", 37 | ".unk13" 38 | }; 39 | #elif XENON 40 | char* szExtensions[] 41 | { 42 | ".gnc", 43 | ".unk01", 44 | ".ani", 45 | ".unk03", 46 | ".unk04", 47 | ".tr8x360", 48 | ".fsb", 49 | ".dtp", 50 | ".script", 51 | ".shad", 52 | ".matd", 53 | ".obj", 54 | ".tr8mesh", 55 | ".unk13" 56 | }; 57 | #elif PS3 58 | char* szExtensions[] 59 | { 60 | ".gnc", 61 | ".unk01", 62 | ".ani", 63 | ".unk03", 64 | ".unk04", 65 | ".tr8ps3t", 66 | ".fsb", 67 | ".dtp", 68 | ".script", 69 | ".shad", 70 | ".matd", 71 | ".obj", 72 | ".tr8mesh", 73 | ".unk13" 74 | }; 75 | #elif WII 76 | char* szExtensions[] 77 | { 78 | ".gnc", 79 | ".unk01", 80 | ".ani", 81 | ".unk03", 82 | ".unk04", 83 | ".tr8sgl", 84 | ".fsb", 85 | ".dtp", 86 | ".script", 87 | ".shad", 88 | ".matd", 89 | ".obj", 90 | ".tr8mesh", 91 | ".unk13" 92 | }; 93 | #elif PS2 94 | char* szExtensions[] 95 | { 96 | ".gnc", 97 | ".unk01", 98 | ".ani", 99 | ".unk03", 100 | ".unk04", 101 | ".tr8sgl", 102 | ".fsb", 103 | ".dtp", 104 | ".script", 105 | ".shad", 106 | ".matd", 107 | ".obj", 108 | ".tr8mesh", 109 | ".unk13" 110 | }; 111 | #else 112 | #error "Unsupported Platform!" 113 | #endif 114 | #elif TRAS 115 | #if PC 116 | char* szExtensions[] 117 | { 118 | ".gnc", 119 | ".unk01", 120 | ".ani", 121 | ".unk03", 122 | ".unk04", 123 | ".tr8pcd9", 124 | ".fsb", 125 | ".dtp", 126 | ".script", 127 | ".shad", 128 | ".matd", 129 | ".obj", 130 | ".tr8mesh", 131 | ".unk13" 132 | }; 133 | #elif XENON 134 | char* szExtensions[] 135 | { 136 | ".gnc", 137 | ".unk01", 138 | ".ani", 139 | ".unk03", 140 | ".unk04", 141 | ".tr8x360", 142 | ".fsb", 143 | ".dtp", 144 | ".script", 145 | ".shad", 146 | ".matd", 147 | ".obj", 148 | ".trasmesh", 149 | ".unk13" 150 | }; 151 | #elif PS3 152 | char* szExtensions[] 153 | { 154 | ".gnc", 155 | ".unk01", 156 | ".ani", 157 | ".unk03", 158 | ".unk04", 159 | ".tr8ps3t", 160 | ".fsb", 161 | ".dtp", 162 | ".script", 163 | ".shad", 164 | ".matd", 165 | ".obj", 166 | ".tr8mesh", 167 | ".unk13" 168 | }; 169 | #error "Unsupported Platform!" 170 | #endif 171 | #else 172 | #error "Unsupported Game!" 173 | #endif 174 | 175 | #endif -------------------------------------------------------------------------------- /External/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/MiniZip64_info.txt: -------------------------------------------------------------------------------- 1 | MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson 2 | 3 | Introduction 4 | --------------------- 5 | MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html ) 6 | 7 | When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0. 8 | All possible work was done for compatibility. 9 | 10 | 11 | Background 12 | --------------------- 13 | When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 14 | support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ ) 15 | 16 | That was used as a starting point. And after that ZIP64 support was added to zip.c 17 | some refactoring and code cleanup was also done. 18 | 19 | 20 | Changed from MiniZip 1.0 to MiniZip 1.1 21 | --------------------------------------- 22 | * Added ZIP64 support for unzip ( by Even Rouault ) 23 | * Added ZIP64 support for zip ( by Mathias Svensson ) 24 | * Reverted some changed that Even Rouault did. 25 | * Bunch of patches received from Gulles Vollant that he received for MiniZip from various users. 26 | * Added unzip patch for BZIP Compression method (patch create by Daniel Borca) 27 | * Added BZIP Compress method for zip 28 | * Did some refactoring and code cleanup 29 | 30 | 31 | Credits 32 | 33 | Gilles Vollant - Original MiniZip author 34 | Even Rouault - ZIP64 unzip Support 35 | Daniel Borca - BZip Compression method support in unzip 36 | Mathias Svensson - ZIP64 zip support 37 | Mathias Svensson - BZip Compression method support in zip 38 | 39 | Resources 40 | 41 | ZipLayout http://result42.com/projects/ZipFileLayout 42 | Command line tool for Windows that shows the layout and information of the headers in a zip archive. 43 | Used when debugging and validating the creation of zip files using MiniZip64 44 | 45 | 46 | ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT 47 | Zip File specification 48 | 49 | 50 | Notes. 51 | * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined. 52 | 53 | License 54 | ---------------------------------------------------------- 55 | Condition of use and distribution are the same than zlib : 56 | 57 | This software is provided 'as-is', without any express or implied 58 | warranty. In no event will the authors be held liable for any damages 59 | arising from the use of this software. 60 | 61 | Permission is granted to anyone to use this software for any purpose, 62 | including commercial applications, and to alter it and redistribute it 63 | freely, subject to the following restrictions: 64 | 65 | 1. The origin of this software must not be misrepresented; you must not 66 | claim that you wrote the original software. If you use this software 67 | in a product, an acknowledgment in the product documentation would be 68 | appreciated but is not required. 69 | 2. Altered source versions must be plainly marked as such, and must not be 70 | misrepresented as being the original software. 71 | 3. This notice may not be removed or altered from any source distribution. 72 | 73 | ---------------------------------------------------------- 74 | 75 | -------------------------------------------------------------------------------- /CDRM/File.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "PlatformSetup.h" 6 | 7 | unsigned int ReverseUInt(unsigned int uiInput) 8 | { 9 | return (unsigned int)(((uiInput & 0xFFu) << 24) | ((uiInput & 0xFF00u) << 8) | ((uiInput & 0xFF0000u) >> 8) | ((uiInput & 0xFF000000u) >> 24)); 10 | } 11 | 12 | int ReverseInt(int iInput) 13 | { 14 | return (int)(((iInput & 0xFF) << 24) | ((iInput & 0xFF00u) << 8) | ((iInput & 0xFF0000u) >> 8) | ((iInput & 0xFF000000u) >> 24)); 15 | } 16 | 17 | unsigned short ReverseUShort(unsigned short usInput) 18 | { 19 | return (unsigned short)((usInput >> 8) | (usInput << 8)); 20 | } 21 | 22 | short ReverseShort(short sInput) 23 | { 24 | return (short)((sInput >> 8) | (sInput << 8)); 25 | } 26 | 27 | char ReadByte(std::ifstream& ifs) 28 | { 29 | char val; 30 | ifs.read((char*)&val, sizeof(char)); 31 | return val; 32 | } 33 | 34 | unsigned char ReadUByte(std::ifstream& ifs) 35 | { 36 | unsigned char val; 37 | ifs.read((char*)&val, sizeof(unsigned char)); 38 | return val; 39 | } 40 | 41 | short ReadShort(std::ifstream& ifs) 42 | { 43 | short val; 44 | ifs.read((char*)&val, sizeof(short)); 45 | #if ENDIAN_BIG 46 | val = ReverseShort(val); 47 | #endif 48 | return val; 49 | } 50 | 51 | unsigned short ReadUShort(std::ifstream& ifs) 52 | { 53 | unsigned short val; 54 | ifs.read((char*)&val, sizeof(unsigned short)); 55 | #if ENDIAN_BIG 56 | val = ReverseUShort(val); 57 | #endif 58 | return val; 59 | } 60 | 61 | int ReadInt(std::ifstream& ifs) 62 | { 63 | int val; 64 | ifs.read((char*)&val, sizeof(int)); 65 | #if ENDIAN_BIG 66 | val = ReverseInt(val); 67 | #endif 68 | return val; 69 | } 70 | 71 | unsigned int ReadUInt(std::ifstream& ifs) 72 | { 73 | unsigned int val; 74 | ifs.read((char*)&val, sizeof(unsigned int)); 75 | #if ENDIAN_BIG 76 | val = ReverseUInt(val); 77 | #endif 78 | return val; 79 | } 80 | 81 | void WriteByte(std::ofstream& ofs, char input) 82 | { 83 | char val = input; 84 | ofs.write(&val, sizeof(char)); 85 | } 86 | 87 | void WriteUByte(std::ofstream& ofs, unsigned char input) 88 | { 89 | unsigned char val = input; 90 | ofs.write((char*)&val, sizeof(unsigned char)); 91 | } 92 | 93 | void WriteShort(std::ofstream& ofs, short input) 94 | { 95 | short val = input; 96 | #if ENDIAN_BIG 97 | val = ReverseShort(val); 98 | #endif 99 | ofs.write((char*)&val, sizeof(short)); 100 | } 101 | 102 | void WriteUShort(std::ofstream& ofs, unsigned short input) 103 | { 104 | unsigned short val = input; 105 | #if ENDIAN_BIG 106 | val = ReverseUShort(val); 107 | #endif 108 | ofs.write((char*)&val, sizeof(unsigned short)); 109 | } 110 | 111 | void WriteInt(std::ofstream& ofs, int input) 112 | { 113 | int val = input; 114 | #if ENDIAN_BIG 115 | val = ReverseInt(val); 116 | #endif 117 | ofs.write((char*)&val, sizeof(int)); 118 | } 119 | 120 | void WriteUInt(std::ofstream& ofs, unsigned int input) 121 | { 122 | unsigned int val = input; 123 | #if ENDIAN_BIG 124 | val = ReverseUInt(val); 125 | #endif 126 | ofs.write((char*)&val, sizeof(unsigned int)); 127 | } 128 | 129 | unsigned int GetFileType(const char* szFilePath) 130 | { 131 | std::ifstream ifs(szFilePath, std::ios::binary); 132 | 133 | if (!ifs.good()) 134 | { 135 | std::cout << "Fatal Error: Failed to open file!" << std::endl; 136 | return -1; 137 | } 138 | 139 | unsigned int uiMagic = ReadUInt(ifs); 140 | ifs.close(); 141 | return uiMagic; 142 | } -------------------------------------------------------------------------------- /External/zlib/treebuild.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | zip compression library 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 117 | -------------------------------------------------------------------------------- /WAVE2WAV/File.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #include "File.h" 7 | 8 | unsigned int getFileMagic(const char* filePath) 9 | { 10 | std::ifstream ifs(filePath, std::ios::binary); 11 | unsigned int fileMagic = 0; 12 | 13 | if (ifs.good()) 14 | { 15 | ifs.read((char*)&fileMagic, sizeof(unsigned int)); 16 | return fileMagic; 17 | } 18 | 19 | return fileMagic; 20 | } 21 | 22 | unsigned int ReverseUInt(unsigned int uiInput) 23 | { 24 | return (unsigned int)(((uiInput & 0xFFu) << 24) | ((uiInput & 0xFF00u) << 8) | ((uiInput & 0xFF0000u) >> 8) | ((uiInput & 0xFF000000u) >> 24)); 25 | } 26 | 27 | int ReverseInt(int iInput) 28 | { 29 | return (int)(((iInput & 0xFF) << 24) | ((iInput & 0xFF00u) << 8) | ((iInput & 0xFF0000u) >> 8) | ((iInput & 0xFF000000u) >> 24)); 30 | } 31 | 32 | unsigned short ReverseUShort(unsigned short usInput) 33 | { 34 | return (unsigned short)((usInput >> 8) | (usInput << 8)); 35 | } 36 | 37 | short ReverseShort(short sInput) 38 | { 39 | return (short)((sInput >> 8) | (sInput << 8)); 40 | } 41 | 42 | char ReadByte(std::ifstream& ifs) 43 | { 44 | char val; 45 | ifs.read((char*)&val, sizeof(char)); 46 | return val; 47 | } 48 | 49 | unsigned char ReadUByte(std::ifstream& ifs) 50 | { 51 | unsigned char val; 52 | ifs.read((char*)&val, sizeof(unsigned char)); 53 | return val; 54 | } 55 | 56 | short ReadShort(std::ifstream& ifs) 57 | { 58 | short val; 59 | ifs.read((char*)&val, sizeof(short)); 60 | #if ENDIAN_BIG 61 | ReverseShort(val); 62 | #endif 63 | return val; 64 | } 65 | 66 | unsigned short ReadUShort(std::ifstream& ifs) 67 | { 68 | unsigned short val; 69 | ifs.read((char*)&val, sizeof(unsigned short)); 70 | #if ENDIAN_BIG 71 | ReverseUShort(val); 72 | #endif 73 | return val; 74 | } 75 | 76 | int ReadInt(std::ifstream& ifs) 77 | { 78 | int val; 79 | ifs.read((char*)&val, sizeof(int)); 80 | #if ENDIAN_BIG 81 | ReverseInt(val); 82 | #endif 83 | return val; 84 | } 85 | 86 | unsigned int ReadUInt(std::ifstream& ifs) 87 | { 88 | unsigned int val; 89 | ifs.read((char*)&val, sizeof(unsigned int)); 90 | #if ENDIAN_BIG 91 | ReverseUInt(val); 92 | #endif 93 | return val; 94 | } 95 | 96 | void WriteByte(std::ofstream& ofs, char input) 97 | { 98 | char val = input; 99 | ofs.write(&val, sizeof(char)); 100 | } 101 | 102 | void WriteUByte(std::ofstream& ofs, unsigned char input) 103 | { 104 | unsigned char val = input; 105 | ofs.write((char*)&val, sizeof(unsigned char)); 106 | } 107 | 108 | void WriteShort(std::ofstream& ofs, short input) 109 | { 110 | short val = input; 111 | #if ENDIAN_BIG 112 | ReverseShort(val); 113 | #endif 114 | ofs.write((char*)&val, sizeof(short)); 115 | } 116 | 117 | void WriteUShort(std::ofstream& ofs, unsigned short input) 118 | { 119 | unsigned short val = input; 120 | #if ENDIAN_BIG 121 | ReverseUShort(val); 122 | #endif 123 | ofs.write((char*)&val, sizeof(unsigned short)); 124 | } 125 | 126 | void WriteInt(std::ofstream& ofs, int input) 127 | { 128 | int val = input; 129 | #if ENDIAN_BIG 130 | ReverseInt(val); 131 | #endif 132 | ofs.write((char*)&val, sizeof(int)); 133 | } 134 | 135 | void WriteUInt(std::ofstream& ofs, unsigned int input) 136 | { 137 | unsigned int val = input; 138 | #if ENDIAN_BIG 139 | ReverseUInt(val); 140 | #endif 141 | ofs.write((char*)&val, sizeof(unsigned int)); 142 | } 143 | 144 | void CreateDirectories(std::string str) 145 | { 146 | 147 | } 148 | 149 | bool IsDirectory(const char* filePath) 150 | { 151 | int stringSize = strlen(filePath); 152 | 153 | if (stringSize > 0) 154 | { 155 | for (int i = stringSize; i > 0; i--) 156 | { 157 | if (filePath[i] == '.') 158 | { 159 | return false; 160 | } 161 | 162 | if (filePath[i] == '\\') 163 | { 164 | return true; 165 | } 166 | } 167 | } 168 | 169 | return false; 170 | } 171 | 172 | bool DoesFileExist(const char* filePath) 173 | { 174 | std::ifstream file(filePath); 175 | return file.good(); 176 | } 177 | -------------------------------------------------------------------------------- /PCD2DDS/File.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "File.h" 6 | 7 | #include "PCD.h" 8 | #define ENDIAN_BIG PS3 9 | 10 | unsigned int getFileMagic(const char* filePath) 11 | { 12 | std::ifstream ifs(filePath, std::ios::binary); 13 | unsigned int fileMagic = 0; 14 | 15 | if (ifs.good()) 16 | { 17 | ifs.read((char*)&fileMagic, sizeof(unsigned int)); 18 | return fileMagic; 19 | } 20 | 21 | return fileMagic; 22 | } 23 | 24 | unsigned int ReverseUInt(unsigned int uiInput) 25 | { 26 | return (unsigned int)(((uiInput & 0xFFu) << 24) | ((uiInput & 0xFF00u) << 8) | ((uiInput & 0xFF0000u) >> 8) | ((uiInput & 0xFF000000u) >> 24)); 27 | } 28 | 29 | int ReverseInt(int iInput) 30 | { 31 | return (int)(((iInput & 0xFF) << 24) | ((iInput & 0xFF00u) << 8) | ((iInput & 0xFF0000u) >> 8) | ((iInput & 0xFF000000u) >> 24)); 32 | } 33 | 34 | unsigned short ReverseUShort(unsigned short usInput) 35 | { 36 | return (unsigned short)((usInput >> 8) | (usInput << 8)); 37 | } 38 | 39 | short ReverseShort(short sInput) 40 | { 41 | return (short)((sInput >> 8) | (sInput << 8)); 42 | } 43 | 44 | char ReadByte(std::ifstream& ifs) 45 | { 46 | char val; 47 | ifs.read((char*)&val, sizeof(char)); 48 | return val; 49 | } 50 | 51 | unsigned char ReadUByte(std::ifstream& ifs) 52 | { 53 | unsigned char val; 54 | ifs.read((char*)&val, sizeof(unsigned char)); 55 | return val; 56 | } 57 | 58 | short ReadShort(std::ifstream& ifs) 59 | { 60 | short val; 61 | ifs.read((char*)&val, sizeof(short)); 62 | #if ENDIAN_BIG 63 | val = ReverseShort(val); 64 | #endif 65 | return val; 66 | } 67 | 68 | unsigned short ReadUShort(std::ifstream& ifs) 69 | { 70 | unsigned short val; 71 | ifs.read((char*)&val, sizeof(unsigned short)); 72 | #if ENDIAN_BIG 73 | val = ReverseUShort(val); 74 | #endif 75 | return val; 76 | } 77 | 78 | int ReadInt(std::ifstream& ifs) 79 | { 80 | int val; 81 | ifs.read((char*)&val, sizeof(int)); 82 | #if ENDIAN_BIG 83 | val = ReverseInt(val); 84 | #endif 85 | return val; 86 | } 87 | 88 | unsigned int ReadUInt(std::ifstream& ifs) 89 | { 90 | unsigned int val; 91 | ifs.read((char*)&val, sizeof(unsigned int)); 92 | #if ENDIAN_BIG 93 | val = ReverseUInt(val); 94 | #endif 95 | return val; 96 | } 97 | 98 | void WriteByte(std::ofstream& ofs, char input) 99 | { 100 | char val = input; 101 | ofs.write(&val, sizeof(char)); 102 | } 103 | 104 | void WriteUByte(std::ofstream& ofs, unsigned char input) 105 | { 106 | unsigned char val = input; 107 | ofs.write((char*)&val, sizeof(unsigned char)); 108 | } 109 | 110 | void WriteShort(std::ofstream& ofs, short input) 111 | { 112 | short val = input; 113 | #if ENDIAN_BIG 114 | ReverseShort(val); 115 | #endif 116 | ofs.write((char*)&val, sizeof(short)); 117 | } 118 | 119 | void WriteUShort(std::ofstream& ofs, unsigned short input) 120 | { 121 | unsigned short val = input; 122 | #if ENDIAN_BIG 123 | ReverseUShort(val); 124 | #endif 125 | ofs.write((char*)&val, sizeof(unsigned short)); 126 | } 127 | 128 | void WriteInt(std::ofstream& ofs, int input) 129 | { 130 | int val = input; 131 | #if ENDIAN_BIG 132 | ReverseInt(val); 133 | #endif 134 | ofs.write((char*)&val, sizeof(int)); 135 | } 136 | 137 | void WriteUInt(std::ofstream& ofs, unsigned int input) 138 | { 139 | unsigned int val = input; 140 | #if ENDIAN_BIG 141 | ReverseUInt(val); 142 | #endif 143 | ofs.write((char*)&val, sizeof(unsigned int)); 144 | } 145 | 146 | void CreateDirectories(std::string str) 147 | { 148 | 149 | } 150 | 151 | bool IsDirectory(const char* filePath) 152 | { 153 | int stringSize = strlen(filePath); 154 | 155 | if (stringSize > 0) 156 | { 157 | for (int i = stringSize; i > 0; i--) 158 | { 159 | if (filePath[i] == '.') 160 | { 161 | return false; 162 | } 163 | 164 | if (filePath[i] == '\\') 165 | { 166 | return true; 167 | } 168 | } 169 | } 170 | 171 | return false; 172 | } 173 | 174 | bool DoesFileExist(const char* filePath) 175 | { 176 | std::ifstream file(filePath); 177 | return file.good(); 178 | } 179 | -------------------------------------------------------------------------------- /DRM/File.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #include "File.h" 7 | #include "PlatformSetup.h" 8 | 9 | unsigned int getFileMagic(const char* filePath) 10 | { 11 | std::ifstream ifs(filePath, std::ios::binary); 12 | unsigned int fileMagic = 0; 13 | 14 | if (ifs.good()) 15 | { 16 | ifs.read((char*)&fileMagic, sizeof(unsigned int)); 17 | return fileMagic; 18 | } 19 | 20 | return fileMagic; 21 | } 22 | 23 | unsigned int ReverseUInt(unsigned int uiInput) 24 | { 25 | return (unsigned int)(((uiInput & 0xFFu) << 24) | ((uiInput & 0xFF00u) << 8) | ((uiInput & 0xFF0000u) >> 8) | ((uiInput & 0xFF000000u) >> 24)); 26 | } 27 | 28 | int ReverseInt(int iInput) 29 | { 30 | return (int)(((iInput & 0xFF) << 24) | ((iInput & 0xFF00u) << 8) | ((iInput & 0xFF0000u) >> 8) | ((iInput & 0xFF000000u) >> 24)); 31 | } 32 | 33 | unsigned short ReverseUShort(unsigned short usInput) 34 | { 35 | return (unsigned short)((usInput >> 8) | (usInput << 8)); 36 | } 37 | 38 | short ReverseShort(short sInput) 39 | { 40 | return (short)((sInput >> 8) | (sInput << 8)); 41 | } 42 | 43 | char ReadByte(std::ifstream& ifs) 44 | { 45 | char val; 46 | ifs.read((char*)&val, sizeof(char)); 47 | return val; 48 | } 49 | 50 | unsigned char ReadUByte(std::ifstream& ifs) 51 | { 52 | unsigned char val; 53 | ifs.read((char*)&val, sizeof(unsigned char)); 54 | return val; 55 | } 56 | 57 | short ReadShort(std::ifstream& ifs) 58 | { 59 | short val; 60 | ifs.read((char*)&val, sizeof(short)); 61 | #if ENDIAN_BIG 62 | val = ReverseShort(val); 63 | #endif 64 | return val; 65 | } 66 | 67 | unsigned short ReadUShort(std::ifstream& ifs) 68 | { 69 | unsigned short val; 70 | ifs.read((char*)&val, sizeof(unsigned short)); 71 | #if ENDIAN_BIG 72 | val = ReverseUShort(val); 73 | #endif 74 | return val; 75 | } 76 | 77 | int ReadInt(std::ifstream& ifs) 78 | { 79 | int val; 80 | ifs.read((char*)&val, sizeof(int)); 81 | #if ENDIAN_BIG 82 | val = ReverseInt(val); 83 | #endif 84 | return val; 85 | } 86 | 87 | unsigned int ReadUInt(std::ifstream& ifs) 88 | { 89 | unsigned int val; 90 | ifs.read((char*)&val, sizeof(unsigned int)); 91 | #if ENDIAN_BIG 92 | val = ReverseUInt(val); 93 | #endif 94 | return val; 95 | } 96 | 97 | void WriteByte(std::ofstream& ofs, char input) 98 | { 99 | char val = input; 100 | ofs.write(&val, sizeof(char)); 101 | } 102 | 103 | void WriteUByte(std::ofstream& ofs, unsigned char input) 104 | { 105 | unsigned char val = input; 106 | ofs.write((char*)&val, sizeof(unsigned char)); 107 | } 108 | 109 | void WriteShort(std::ofstream& ofs, short input) 110 | { 111 | short val = input; 112 | #if ENDIAN_BIG 113 | val = ReverseShort(val); 114 | #endif 115 | ofs.write((char*)&val, sizeof(short)); 116 | } 117 | 118 | void WriteUShort(std::ofstream& ofs, unsigned short input) 119 | { 120 | unsigned short val = input; 121 | #if ENDIAN_BIG 122 | val = ReverseUShort(val); 123 | #endif 124 | ofs.write((char*)&val, sizeof(unsigned short)); 125 | } 126 | 127 | void WriteInt(std::ofstream& ofs, int input) 128 | { 129 | int val = input; 130 | #if ENDIAN_BIG 131 | val = ReverseInt(val); 132 | #endif 133 | ofs.write((char*)&val, sizeof(int)); 134 | } 135 | 136 | void WriteUInt(std::ofstream& ofs, unsigned int input) 137 | { 138 | unsigned int val = input; 139 | #if ENDIAN_BIG 140 | val = ReverseUInt(val); 141 | #endif 142 | ofs.write((char*)&val, sizeof(unsigned int)); 143 | } 144 | 145 | void CreateDirectories(std::string str) 146 | { 147 | //Little fix for strings which accidentally don't end with \\. If not the last folder won't be created! 148 | if (str[str.size() - 1] != *"\\") str.append("\\"); 149 | 150 | int iPos = 1; 151 | while (iPos != 0) 152 | { 153 | iPos = str.find("\\", iPos) + 1; 154 | CreateDirectory(str.substr(0, iPos).c_str(), NULL); 155 | } 156 | } 157 | 158 | bool IsDirectory(const char* filePath) 159 | { 160 | int stringSize = strlen(filePath); 161 | 162 | if (stringSize > 0) 163 | { 164 | for (int i = stringSize; i > 0; i--) 165 | { 166 | if (filePath[i] == '.') 167 | { 168 | return false; 169 | } 170 | 171 | if (filePath[i] == '\\') 172 | { 173 | return true; 174 | } 175 | } 176 | } 177 | 178 | return false; 179 | } 180 | 181 | bool DoesFileExist(const char* filePath) 182 | { 183 | std::ifstream file(filePath); 184 | return file.good(); 185 | } 186 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {07934a85-8b61-443d-a0ee-b2eedb74f3cd} 6 | cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90 7 | 8 | 9 | {1d99675b-433d-4a21-9e50-ed4ab8b19762} 10 | h;hpp;hxx;hm;inl;fi;fd 11 | 12 | 13 | {431c0958-fa71-44d0-9084-2d19d100c0cc} 14 | ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | Source Files 68 | 69 | 70 | Source Files 71 | 72 | 73 | Source Files 74 | 75 | 76 | Source Files 77 | 78 | 79 | 80 | 81 | Source Files 82 | 83 | 84 | 85 | 86 | Source Files 87 | 88 | 89 | 90 | 91 | Header Files 92 | 93 | 94 | Header Files 95 | 96 | 97 | Header Files 98 | 99 | 100 | Header Files 101 | 102 | 103 | Header Files 104 | 105 | 106 | Header Files 107 | 108 | 109 | Header Files 110 | 111 | 112 | Header Files 113 | 114 | 115 | Header Files 116 | 117 | 118 | -------------------------------------------------------------------------------- /PCD2DDS/DDS.cpp: -------------------------------------------------------------------------------- 1 | #include "DDS.h" 2 | #include "File.h" 3 | 4 | #include 5 | #include 6 | 7 | void ConvertDDSToPCD(const char* filePath) 8 | { 9 | std::ifstream ifs(filePath, std::ios::binary); 10 | 11 | //If there was a failure to open the file we must exit 12 | if (!ifs.good()) 13 | { 14 | std::cout << "Error: failed to open the file!" << std::endl; 15 | ifs.close(); 16 | return; 17 | } 18 | 19 | unsigned int magic; 20 | ifs.read(reinterpret_cast(&magic), sizeof(unsigned int)); 21 | ifs.seekg(0, SEEK_SET); 22 | 23 | switch (magic) 24 | { 25 | case 0x00020000://Targa 26 | WritePCTarga(filePath, ifs); 27 | break; 28 | case DDS_MAGIC: 29 | WritePCDDS(filePath, ifs); 30 | break; 31 | default: 32 | std::cout << "Error: Unsupported texture format!" << std::endl; 33 | break; 34 | } 35 | 36 | ifs.close(); 37 | } 38 | 39 | void WritePCDDS(const char* resultFileName, std::ifstream& ifs) 40 | { 41 | int fileSize = 0; 42 | ifs.seekg(0, SEEK_END); 43 | fileSize = ifs.tellg(); 44 | ifs.seekg(0, SEEK_SET); 45 | 46 | DDSHeader ddsHeader; 47 | ifs.read(reinterpret_cast(&ddsHeader), sizeof(DDSHeader)); 48 | 49 | if (ddsHeader.m_magic != DDS_MAGIC) 50 | { 51 | std::cout << "Error: DDS magic mis-match!" << std::endl; 52 | ifs.close(); 53 | return; 54 | } 55 | 56 | char* textureData = new char[fileSize - 0x80]; 57 | ifs.seekg(0x80, SEEK_SET); 58 | ifs.read(textureData, fileSize - 0x80); 59 | ifs.close(); 60 | 61 | char nameBuff[128]; 62 | memset(nameBuff, 0, 128); 63 | sprintf_s(nameBuff, "%s%s", resultFileName, ".pcd"); 64 | 65 | std::ofstream ofs(nameBuff, std::ios::binary); 66 | 67 | // 68 | std::string path(resultFileName); 69 | std::string filename; 70 | 71 | size_t pos = path.find_last_of("\\"); 72 | if (pos != std::string::npos) 73 | { 74 | filename.assign(path.begin() + pos + 1, path.end()); 75 | pos = path.find_last_of("_"); 76 | filename.assign(path.begin() + pos + 1, path.end()); 77 | filename.erase(filename.find_first_of("."), std::string::npos); 78 | } 79 | else 80 | { 81 | filename = path; 82 | } 83 | 84 | unsigned int hash; 85 | sscanf(filename.c_str(), "%x", &hash); 86 | 87 | WriteUInt(ofs, SECTION_MAGIC); 88 | WriteUInt(ofs, ((fileSize - 0x80) + 0x18)); 89 | WriteUInt(ofs, (TEXTURE_SECTION_TYPE)); 90 | WriteUInt(ofs, 0); 91 | WriteUInt(ofs, hash); 92 | WriteUInt(ofs, 0xFFFFFFFF); 93 | 94 | WriteUInt(ofs, PCD_MAGIC); 95 | WriteUInt(ofs, ddsHeader.m_format); 96 | WriteUInt(ofs, (fileSize - 0x80)); 97 | WriteUInt(ofs, 0); 98 | WriteUShort(ofs, ddsHeader.m_width); 99 | WriteUShort(ofs, ddsHeader.m_height); 100 | WriteUByte(ofs, ddsHeader.m_depth); 101 | WriteUByte(ofs, ddsHeader.m_mipCount); 102 | WriteUShort(ofs, 3); 103 | 104 | ofs.write(textureData, (fileSize - 0x80)); 105 | 106 | delete [] textureData; 107 | } 108 | 109 | void WritePCTarga(const char* resultFileName, std::ifstream& ifs) 110 | { 111 | int fileSize = 0; 112 | ifs.seekg(0, SEEK_END); 113 | fileSize = ifs.tellg(); 114 | ifs.seekg(0, SEEK_SET); 115 | 116 | unsigned int magic; 117 | ifs.read(reinterpret_cast(&magic), sizeof(unsigned int)); 118 | 119 | if (magic != 0x00020000) 120 | { 121 | std::cout << "Error: Targa magic mis-match!" << std::endl; 122 | ifs.close(); 123 | return; 124 | } 125 | 126 | ifs.seekg(0xC, SEEK_SET); 127 | 128 | unsigned short width; 129 | unsigned short height; 130 | 131 | ifs.read(reinterpret_cast(&width), sizeof(unsigned short)); 132 | ifs.read(reinterpret_cast(&height), sizeof(unsigned short)); 133 | 134 | char* textureData = new char[width * height * 4]; 135 | ifs.seekg(0x12, SEEK_SET); 136 | ifs.read(textureData, width * height * 4); 137 | ifs.close(); 138 | 139 | char nameBuff[128]; 140 | memset(nameBuff, 0, 128); 141 | sprintf_s(nameBuff, "%s%s", resultFileName, ".pcd"); 142 | 143 | std::ofstream ofs(nameBuff, std::ios::binary); 144 | 145 | // 146 | std::string path(resultFileName); 147 | std::string filename; 148 | 149 | size_t pos = path.find_last_of("\\"); 150 | if (pos != std::string::npos) 151 | { 152 | filename.assign(path.begin() + pos + 1, path.end()); 153 | pos = path.find_last_of("_"); 154 | filename.assign(path.begin() + pos + 1, path.end()); 155 | filename.erase(filename.find_first_of("."), std::string::npos); 156 | } 157 | else 158 | { 159 | filename = path; 160 | } 161 | 162 | unsigned int hash; 163 | sscanf(filename.c_str(), "%x", &hash); 164 | 165 | WriteUInt(ofs, SECTION_MAGIC); 166 | WriteUInt(ofs, ((fileSize - 0x80) + 0x18)); 167 | WriteUInt(ofs, (TEXTURE_SECTION_TYPE)); 168 | WriteUInt(ofs, 0); 169 | WriteUInt(ofs, hash); 170 | WriteUInt(ofs, 0xFFFFFFFF); 171 | 172 | WriteUInt(ofs, PCD_MAGIC); 173 | WriteUInt(ofs, 0x15); 174 | WriteUInt(ofs, (fileSize - 0x80)); 175 | WriteUInt(ofs, 0); 176 | WriteUShort(ofs, width); 177 | WriteUShort(ofs, height); 178 | WriteUByte(ofs, 32); 179 | WriteUByte(ofs, 0); 180 | WriteUShort(ofs, 0); 181 | 182 | ofs.write(textureData, width * height * 4); 183 | 184 | delete [] textureData; 185 | } 186 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/crypt.h: -------------------------------------------------------------------------------- 1 | /* crypt.h -- base code for crypt/uncrypt ZIPfile 2 | 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | 8 | This code is a modified version of crypting code in Infozip distribution 9 | 10 | The encryption/decryption parts of this source code (as opposed to the 11 | non-echoing password parts) were originally written in Europe. The 12 | whole source package can be freely distributed, including from the USA. 13 | (Prior to January 2000, re-export from the US was a violation of US law.) 14 | 15 | This encryption code is a direct transcription of the algorithm from 16 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This 17 | file (appnote.txt) is distributed with the PKZIP program (even in the 18 | version without encryption capabilities). 19 | 20 | If you don't need crypting in your application, just define symbols 21 | NOCRYPT and NOUNCRYPT. 22 | 23 | This code support the "Traditional PKWARE Encryption". 24 | 25 | The new AES encryption added on Zip format by Winzip (see the page 26 | http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong 27 | Encryption is not supported. 28 | */ 29 | 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) 31 | 32 | /*********************************************************************** 33 | * Return the next byte in the pseudo-random sequence 34 | */ 35 | static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) 36 | { 37 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an 38 | * unpredictable manner on 16-bit systems; not a problem 39 | * with any known compiler so far, though */ 40 | 41 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; 42 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); 43 | } 44 | 45 | /*********************************************************************** 46 | * Update the encryption keys with the next byte of plain text 47 | */ 48 | static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) 49 | { 50 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); 51 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; 52 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; 53 | { 54 | register int keyshift = (int)((*(pkeys+1)) >> 24); 55 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); 56 | } 57 | return c; 58 | } 59 | 60 | 61 | /*********************************************************************** 62 | * Initialize the encryption keys and the random header according to 63 | * the given password. 64 | */ 65 | static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) 66 | { 67 | *(pkeys+0) = 305419896L; 68 | *(pkeys+1) = 591751049L; 69 | *(pkeys+2) = 878082192L; 70 | while (*passwd != '\0') { 71 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); 72 | passwd++; 73 | } 74 | } 75 | 76 | #define zdecode(pkeys,pcrc_32_tab,c) \ 77 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) 78 | 79 | #define zencode(pkeys,pcrc_32_tab,c,t) \ 80 | (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) 81 | 82 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED 83 | 84 | #define RAND_HEAD_LEN 12 85 | /* "last resort" source for second part of crypt seed pattern */ 86 | # ifndef ZCR_SEED2 87 | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ 88 | # endif 89 | 90 | static int crypthead(const char* passwd, /* password string */ 91 | unsigned char* buf, /* where to write header */ 92 | int bufSize, 93 | unsigned long* pkeys, 94 | const z_crc_t* pcrc_32_tab, 95 | unsigned long crcForCrypting) 96 | { 97 | int n; /* index in random header */ 98 | int t; /* temporary */ 99 | int c; /* random byte */ 100 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ 101 | static unsigned calls = 0; /* ensure different random header each time */ 102 | 103 | if (bufSize> 7) & 0xff; 118 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); 119 | } 120 | /* Encrypt random header (last two bytes is high word of crc) */ 121 | init_keys(passwd, pkeys, pcrc_32_tab); 122 | for (n = 0; n < RAND_HEAD_LEN-2; n++) 123 | { 124 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); 125 | } 126 | buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); 127 | buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); 128 | return n; 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /WAVE2WAV/RIFF.cpp: -------------------------------------------------------------------------------- 1 | #include "RIFF.h" 2 | #include "File.h" 3 | 4 | #include 5 | #include 6 | 7 | void ConvertWAVEToWAV(const char* filePath) 8 | { 9 | std::ifstream ifs(filePath, std::ios::binary); 10 | 11 | //If there was a failure to open the file we must exit 12 | if (!ifs.good()) 13 | { 14 | std::cout << "Error: failed to open the file!" << std::endl; 15 | ifs.close(); 16 | return; 17 | } 18 | 19 | //Check to see if file has valid section header 20 | unsigned int sectionMagic = ReadUInt(ifs); 21 | if (sectionMagic != SECTION_MAGIC) 22 | { 23 | std::cout << "Error: section magic mis-match!" << std::endl; 24 | ifs.close(); 25 | return; 26 | } 27 | 28 | unsigned int sectionSize = ReadUInt(ifs); 29 | if (sectionSize <= 0) 30 | { 31 | std::cout << "Error: section corrupt, size is <= 0!" << std::endl; 32 | ifs.close(); 33 | return; 34 | } 35 | 36 | unsigned char sectionType = ReadUByte(ifs); 37 | if (sectionType != WAVE_SECTION_TYPE) 38 | { 39 | std::cout << "Error: invalid section type!" << std::endl; 40 | ifs.close(); 41 | return; 42 | } 43 | 44 | //Now we've validated this is a valid section let's convert the data to wav 45 | ifs.seekg(24, SEEK_SET); 46 | 47 | unsigned int waveFrequency = ReadUInt(ifs); 48 | 49 | ifs.seekg(8, SEEK_CUR); 50 | 51 | unsigned int waveUnk00 = ReadUInt(ifs); 52 | 53 | char* waveData = new char[sectionSize - 16]; 54 | ifs.read((char*)waveData, (sectionSize - 16)); 55 | 56 | ifs.close(); 57 | 58 | //Write output wave file 59 | char nameBuff[128]; 60 | memset(nameBuff, 0, 128); 61 | sprintf_s(nameBuff, "%s%s", filePath, ".wav");///@FIXME filename needs extracting this is dangerous! 62 | 63 | std::ofstream ofs(nameBuff, std::ios::binary); 64 | //"RIFF" 65 | WriteUInt(ofs, RIFF_MAGIC); 66 | //Size 67 | WriteUInt(ofs, ((sectionSize-16) + 44)); 68 | //"WAVE" 69 | WriteUInt(ofs, 0x45564157); 70 | //"fmt " 71 | WriteUInt(ofs, 0x20746D66); 72 | //Sub chunk 73 | WriteUInt(ofs, 0x14); 74 | //Audio format 75 | WriteUShort(ofs, 0x11); 76 | //Num channels 77 | WriteUShort(ofs, 1); 78 | //Sample rate 79 | WriteUInt(ofs, waveFrequency); 80 | //Byte rate 81 | WriteUInt(ofs, 0x4DE2); 82 | //Block align 83 | WriteUShort(ofs, 36); 84 | //Bits per sample 85 | WriteUShort(ofs, 4); 86 | //? 87 | WriteUShort(ofs, 2); 88 | //? 89 | WriteUShort(ofs, 65); 90 | //"DATA" 91 | WriteUInt(ofs, 0x61746164); 92 | //? 93 | WriteUInt(ofs, 0xD530); 94 | //? 95 | WriteUInt(ofs, waveUnk00); 96 | 97 | ofs.write(waveData, (sectionSize - 16)); 98 | delete[] waveData; 99 | ofs.close(); 100 | 101 | } 102 | 103 | void ConvertWAVToWAVE(const char* filePath) 104 | { 105 | std::ifstream ifs(filePath, std::ios::binary); 106 | 107 | //If there was a failure to open the file we must exit 108 | if (!ifs.good()) 109 | { 110 | std::cout << "Error: failed to open the file!" << std::endl; 111 | ifs.close(); 112 | return; 113 | } 114 | 115 | unsigned int riffMagic = ReadUInt(ifs); 116 | if (riffMagic != RIFF_MAGIC) 117 | { 118 | std::cout << "Error: RIFF magic mis-match!" << std::endl; 119 | ifs.close(); 120 | return; 121 | } 122 | 123 | unsigned int riffSize = ReadUInt(ifs); 124 | if (riffMagic <= 0) 125 | { 126 | std::cout << "Error: RIFF size <= 0!" << std::endl; 127 | ifs.close(); 128 | return; 129 | } 130 | 131 | ifs.seekg(12, SEEK_CUR); 132 | 133 | unsigned short riffFormat = ReadUShort(ifs); 134 | if (riffFormat != 0x11) 135 | { 136 | std::cout << "Error: unsupported wave format! Got:" << riffFormat << "Expected: 18" << std::endl; 137 | ifs.close(); 138 | return; 139 | } 140 | 141 | ifs.seekg(2, SEEK_CUR); 142 | 143 | unsigned int riffSampleRate = ReadUInt(ifs); 144 | 145 | ifs.seekg(20, SEEK_CUR); 146 | 147 | unsigned int riffUnk00 = ReadUInt(ifs); 148 | 149 | char* waveData = new char[riffSize - 44]; 150 | ifs.read(waveData, (riffSize - 4)); 151 | 152 | ifs.close(); 153 | 154 | //Write section header 155 | char nameBuff[128]; 156 | memset(nameBuff, 0, 128); 157 | sprintf_s(nameBuff, "%s%s", filePath, ".wave"); 158 | 159 | std::ofstream ofs(nameBuff, std::ios::binary); 160 | 161 | if (!ofs.good()) 162 | { 163 | std::cout << "Error: Failed to open output file for writing!" << std::endl; 164 | ofs.close(); 165 | return; 166 | } 167 | 168 | // 169 | std::string path(filePath); 170 | std::string filename; 171 | 172 | size_t pos = path.find_last_of("\\"); 173 | if (pos != std::string::npos) 174 | { 175 | filename.assign(path.begin() + pos + 1, path.end()); 176 | pos = path.find_last_of("_"); 177 | filename.assign(path.begin() + pos + 1, path.end()); 178 | filename.erase(filename.find_first_of("."), std::string::npos); 179 | } 180 | else 181 | { 182 | filename = path; 183 | } 184 | 185 | unsigned int hash; 186 | sscanf(filename.c_str(), "%x", &hash); 187 | 188 | //"SECT" 189 | WriteUInt(ofs, 0x54434553); 190 | //File size of section data minus header 191 | WriteUInt(ofs, ((riffSize-44)+16)); 192 | WriteUByte(ofs, WAVE_SECTION_TYPE); 193 | ofs.seekp(3, SEEK_CUR);//Unsupported 194 | //Header size (nothing since this asset is not relocated) 195 | WriteUInt(ofs, 0); 196 | //Unique hash of section stored in filename 197 | WriteUInt(ofs, hash); 198 | //Lang/mask 199 | WriteUInt(ofs, 0xFFFFFFFF); 200 | 201 | //Wave section data 202 | WriteUInt(ofs, riffSampleRate); 203 | ofs.seekp(8, SEEK_CUR); 204 | WriteUInt(ofs, riffUnk00); 205 | ofs.write(waveData, (riffSize - 44)); 206 | 207 | ofs.flush(); 208 | ofs.close(); 209 | } -------------------------------------------------------------------------------- /External/zlib/README: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.8 is a general purpose data compression library. All the code is 4 | thread safe. The data format used by the zlib library is described by RFCs 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and 7 | rfc1952 (gzip format). 8 | 9 | All functions of the compression library are documented in the file zlib.h 10 | (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 11 | of the library is given in the file test/example.c which also tests that 12 | the library is working correctly. Another example is given in the file 13 | test/minigzip.c. The compression library itself is composed of all source 14 | files in the root directory. 15 | 16 | To compile all files and run the test program, follow the instructions given at 17 | the top of Makefile.in. In short "./configure; make test", and if that goes 18 | well, "make install" should work for most flavors of Unix. For Windows, use 19 | one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use 20 | make_vms.com. 21 | 22 | Questions about zlib should be sent to , or to Gilles Vollant 23 | for the Windows DLL version. The zlib home page is 24 | http://zlib.net/ . Before reporting a problem, please check this site to 25 | verify that you have the latest version of zlib; otherwise get the latest 26 | version and check whether the problem still exists or not. 27 | 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. 29 | 30 | Mark Nelson wrote an article about zlib for the Jan. 1997 31 | issue of Dr. Dobb's Journal; a copy of the article is available at 32 | http://marknelson.us/1997/01/01/zlib-engine/ . 33 | 34 | The changes made in version 1.2.8 are documented in the file ChangeLog. 35 | 36 | Unsupported third party contributions are provided in directory contrib/ . 37 | 38 | zlib is available in Java using the java.util.zip package, documented at 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . 40 | 41 | A Perl interface to zlib written by Paul Marquess is available 42 | at CPAN (Comprehensive Perl Archive Network) sites, including 43 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . 44 | 45 | A Python interface to zlib written by A.M. Kuchling is 46 | available in Python 1.5 and later versions, see 47 | http://docs.python.org/library/zlib.html . 48 | 49 | zlib is built into tcl: http://wiki.tcl.tk/4610 . 50 | 51 | An experimental package to read and write files in .zip format, written on top 52 | of zlib by Gilles Vollant , is available in the 53 | contrib/minizip directory of zlib. 54 | 55 | 56 | Notes for some targets: 57 | 58 | - For Windows DLL versions, please see win32/DLL_FAQ.txt 59 | 60 | - For 64-bit Irix, deflate.c must be compiled without any optimization. With 61 | -O, one libpng test fails. The test works in 32 bit mode (with the -n32 62 | compiler flag). The compiler bug has been reported to SGI. 63 | 64 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works 65 | when compiled with cc. 66 | 67 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is 68 | necessary to get gzprintf working correctly. This is done by configure. 69 | 70 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with 71 | other compilers. Use "make test" to check your compiler. 72 | 73 | - gzdopen is not supported on RISCOS or BEOS. 74 | 75 | - For PalmOs, see http://palmzlib.sourceforge.net/ 76 | 77 | 78 | Acknowledgments: 79 | 80 | The deflate format used by zlib was defined by Phil Katz. The deflate and 81 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 82 | people who reported problems and suggested various improvements in zlib; they 83 | are too numerous to cite here. 84 | 85 | Copyright notice: 86 | 87 | (C) 1995-2013 Jean-loup Gailly and Mark Adler 88 | 89 | This software is provided 'as-is', without any express or implied 90 | warranty. In no event will the authors be held liable for any damages 91 | arising from the use of this software. 92 | 93 | Permission is granted to anyone to use this software for any purpose, 94 | including commercial applications, and to alter it and redistribute it 95 | freely, subject to the following restrictions: 96 | 97 | 1. The origin of this software must not be misrepresented; you must not 98 | claim that you wrote the original software. If you use this software 99 | in a product, an acknowledgment in the product documentation would be 100 | appreciated but is not required. 101 | 2. Altered source versions must be plainly marked as such, and must not be 102 | misrepresented as being the original software. 103 | 3. This notice may not be removed or altered from any source distribution. 104 | 105 | Jean-loup Gailly Mark Adler 106 | jloup@gzip.org madler@alumni.caltech.edu 107 | 108 | If you use the zlib library in a product, we would appreciate *not* receiving 109 | lengthy legal documents to sign. The sources are provided for free but without 110 | warranty of any kind. The library has been entirely written by Jean-loup 111 | Gailly and Mark Adler; it does not include third-party code. 112 | 113 | If you redistribute modified sources, we would appreciate that you include in 114 | the file ChangeLog history information documenting your changes. Please read 115 | the FAQ for more information on the distribution of modified source versions. 116 | -------------------------------------------------------------------------------- /External/zlib/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2011 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #define local static 11 | 12 | local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); 13 | 14 | #define BASE 65521 /* largest prime smaller than 65536 */ 15 | #define NMAX 5552 16 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 17 | 18 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 19 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 20 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 21 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 22 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 23 | 24 | /* use NO_DIVIDE if your processor does not do division in hardware -- 25 | try it both ways to see which is faster */ 26 | #ifdef NO_DIVIDE 27 | /* note that this assumes BASE is 65521, where 65536 % 65521 == 15 28 | (thank you to John Reiser for pointing this out) */ 29 | # define CHOP(a) \ 30 | do { \ 31 | unsigned long tmp = a >> 16; \ 32 | a &= 0xffffUL; \ 33 | a += (tmp << 4) - tmp; \ 34 | } while (0) 35 | # define MOD28(a) \ 36 | do { \ 37 | CHOP(a); \ 38 | if (a >= BASE) a -= BASE; \ 39 | } while (0) 40 | # define MOD(a) \ 41 | do { \ 42 | CHOP(a); \ 43 | MOD28(a); \ 44 | } while (0) 45 | # define MOD63(a) \ 46 | do { /* this assumes a is not negative */ \ 47 | z_off64_t tmp = a >> 32; \ 48 | a &= 0xffffffffL; \ 49 | a += (tmp << 8) - (tmp << 5) + tmp; \ 50 | tmp = a >> 16; \ 51 | a &= 0xffffL; \ 52 | a += (tmp << 4) - tmp; \ 53 | tmp = a >> 16; \ 54 | a &= 0xffffL; \ 55 | a += (tmp << 4) - tmp; \ 56 | if (a >= BASE) a -= BASE; \ 57 | } while (0) 58 | #else 59 | # define MOD(a) a %= BASE 60 | # define MOD28(a) a %= BASE 61 | # define MOD63(a) a %= BASE 62 | #endif 63 | 64 | /* ========================================================================= */ 65 | uLong ZEXPORT adler32(adler, buf, len) 66 | uLong adler; 67 | const Bytef *buf; 68 | uInt len; 69 | { 70 | unsigned long sum2; 71 | unsigned n; 72 | 73 | /* split Adler-32 into component sums */ 74 | sum2 = (adler >> 16) & 0xffff; 75 | adler &= 0xffff; 76 | 77 | /* in case user likes doing a byte at a time, keep it fast */ 78 | if (len == 1) { 79 | adler += buf[0]; 80 | if (adler >= BASE) 81 | adler -= BASE; 82 | sum2 += adler; 83 | if (sum2 >= BASE) 84 | sum2 -= BASE; 85 | return adler | (sum2 << 16); 86 | } 87 | 88 | /* initial Adler-32 value (deferred check for len == 1 speed) */ 89 | if (buf == Z_NULL) 90 | return 1L; 91 | 92 | /* in case short lengths are provided, keep it somewhat fast */ 93 | if (len < 16) { 94 | while (len--) { 95 | adler += *buf++; 96 | sum2 += adler; 97 | } 98 | if (adler >= BASE) 99 | adler -= BASE; 100 | MOD28(sum2); /* only added so many BASE's */ 101 | return adler | (sum2 << 16); 102 | } 103 | 104 | /* do length NMAX blocks -- requires just one modulo operation */ 105 | while (len >= NMAX) { 106 | len -= NMAX; 107 | n = NMAX / 16; /* NMAX is divisible by 16 */ 108 | do { 109 | DO16(buf); /* 16 sums unrolled */ 110 | buf += 16; 111 | } while (--n); 112 | MOD(adler); 113 | MOD(sum2); 114 | } 115 | 116 | /* do remaining bytes (less than NMAX, still just one modulo) */ 117 | if (len) { /* avoid modulos if none remaining */ 118 | while (len >= 16) { 119 | len -= 16; 120 | DO16(buf); 121 | buf += 16; 122 | } 123 | while (len--) { 124 | adler += *buf++; 125 | sum2 += adler; 126 | } 127 | MOD(adler); 128 | MOD(sum2); 129 | } 130 | 131 | /* return recombined sums */ 132 | return adler | (sum2 << 16); 133 | } 134 | 135 | /* ========================================================================= */ 136 | local uLong adler32_combine_(adler1, adler2, len2) 137 | uLong adler1; 138 | uLong adler2; 139 | z_off64_t len2; 140 | { 141 | unsigned long sum1; 142 | unsigned long sum2; 143 | unsigned rem; 144 | 145 | /* for negative len, return invalid adler32 as a clue for debugging */ 146 | if (len2 < 0) 147 | return 0xffffffffUL; 148 | 149 | /* the derivation of this formula is left as an exercise for the reader */ 150 | MOD63(len2); /* assumes len2 >= 0 */ 151 | rem = (unsigned)len2; 152 | sum1 = adler1 & 0xffff; 153 | sum2 = rem * sum1; 154 | MOD(sum2); 155 | sum1 += (adler2 & 0xffff) + BASE - 1; 156 | sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 157 | if (sum1 >= BASE) sum1 -= BASE; 158 | if (sum1 >= BASE) sum1 -= BASE; 159 | if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); 160 | if (sum2 >= BASE) sum2 -= BASE; 161 | return sum1 | (sum2 << 16); 162 | } 163 | 164 | /* ========================================================================= */ 165 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) 166 | uLong adler1; 167 | uLong adler2; 168 | z_off_t len2; 169 | { 170 | return adler32_combine_(adler1, adler2, len2); 171 | } 172 | 173 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2) 174 | uLong adler1; 175 | uLong adler2; 176 | z_off64_t len2; 177 | { 178 | return adler32_combine_(adler1, adler2, len2); 179 | } 180 | -------------------------------------------------------------------------------- /External/zlib/inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. 6 | It is part of the implementation of this library and is 7 | subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, 12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, 13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, 14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, 15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, 16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, 17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, 18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, 19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, 20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, 21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, 22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, 23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, 24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, 25 | {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, 26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, 27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, 28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, 29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, 30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, 31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, 32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, 33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, 34 | {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, 35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, 36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, 37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, 38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, 39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, 40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, 41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, 42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, 43 | {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, 44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, 45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, 46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, 47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, 48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, 49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, 50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, 51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, 52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, 53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, 54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, 55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, 56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, 57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, 58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, 59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, 60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, 61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, 62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, 63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, 64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, 65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, 66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, 67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, 68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, 69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, 70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, 71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, 72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, 73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, 74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, 75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, 76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, 77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, 78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, 79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, 80 | {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, 81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, 82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, 83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, 84 | {0,9,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, 89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, 90 | {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, 91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, 92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, 93 | {22,5,193},{64,5,0} 94 | }; 95 | -------------------------------------------------------------------------------- /External/zlib/inflate.h: -------------------------------------------------------------------------------- 1 | /* inflate.h -- internal inflate state definition 2 | * Copyright (C) 1995-2009 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* define NO_GZIP when compiling if you want to disable gzip header and 12 | trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 13 | the crc code when it is not needed. For shared libraries, gzip decoding 14 | should be left enabled. */ 15 | #ifndef NO_GZIP 16 | # define GUNZIP 17 | #endif 18 | 19 | /* Possible inflate modes between inflate() calls */ 20 | typedef enum { 21 | HEAD, /* i: waiting for magic header */ 22 | FLAGS, /* i: waiting for method and flags (gzip) */ 23 | TIME, /* i: waiting for modification time (gzip) */ 24 | OS, /* i: waiting for extra flags and operating system (gzip) */ 25 | EXLEN, /* i: waiting for extra length (gzip) */ 26 | EXTRA, /* i: waiting for extra bytes (gzip) */ 27 | NAME, /* i: waiting for end of file name (gzip) */ 28 | COMMENT, /* i: waiting for end of comment (gzip) */ 29 | HCRC, /* i: waiting for header crc (gzip) */ 30 | DICTID, /* i: waiting for dictionary check value */ 31 | DICT, /* waiting for inflateSetDictionary() call */ 32 | TYPE, /* i: waiting for type bits, including last-flag bit */ 33 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ 34 | STORED, /* i: waiting for stored size (length and complement) */ 35 | COPY_, /* i/o: same as COPY below, but only first time in */ 36 | COPY, /* i/o: waiting for input or output to copy stored block */ 37 | TABLE, /* i: waiting for dynamic block table lengths */ 38 | LENLENS, /* i: waiting for code length code lengths */ 39 | CODELENS, /* i: waiting for length/lit and distance code lengths */ 40 | LEN_, /* i: same as LEN below, but only first time in */ 41 | LEN, /* i: waiting for length/lit/eob code */ 42 | LENEXT, /* i: waiting for length extra bits */ 43 | DIST, /* i: waiting for distance code */ 44 | DISTEXT, /* i: waiting for distance extra bits */ 45 | MATCH, /* o: waiting for output space to copy string */ 46 | LIT, /* o: waiting for output space to write literal */ 47 | CHECK, /* i: waiting for 32-bit check value */ 48 | LENGTH, /* i: waiting for 32-bit length (gzip) */ 49 | DONE, /* finished check, done -- remain here until reset */ 50 | BAD, /* got a data error -- remain here until reset */ 51 | MEM, /* got an inflate() memory error -- remain here until reset */ 52 | SYNC /* looking for synchronization bytes to restart inflate() */ 53 | } inflate_mode; 54 | 55 | /* 56 | State transitions between above modes - 57 | 58 | (most modes can go to BAD or MEM on error -- not shown for clarity) 59 | 60 | Process header: 61 | HEAD -> (gzip) or (zlib) or (raw) 62 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> 63 | HCRC -> TYPE 64 | (zlib) -> DICTID or TYPE 65 | DICTID -> DICT -> TYPE 66 | (raw) -> TYPEDO 67 | Read deflate blocks: 68 | TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK 69 | STORED -> COPY_ -> COPY -> TYPE 70 | TABLE -> LENLENS -> CODELENS -> LEN_ 71 | LEN_ -> LEN 72 | Read deflate codes in fixed or dynamic block: 73 | LEN -> LENEXT or LIT or TYPE 74 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 75 | LIT -> LEN 76 | Process trailer: 77 | CHECK -> LENGTH -> DONE 78 | */ 79 | 80 | /* state maintained between inflate() calls. Approximately 10K bytes. */ 81 | struct inflate_state { 82 | inflate_mode mode; /* current inflate mode */ 83 | int last; /* true if processing last block */ 84 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 85 | int havedict; /* true if dictionary provided */ 86 | int flags; /* gzip header method and flags (0 if zlib) */ 87 | unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 88 | unsigned long check; /* protected copy of check value */ 89 | unsigned long total; /* protected copy of output count */ 90 | gz_headerp head; /* where to save gzip header information */ 91 | /* sliding window */ 92 | unsigned wbits; /* log base 2 of requested window size */ 93 | unsigned wsize; /* window size or zero if not using window */ 94 | unsigned whave; /* valid bytes in the window */ 95 | unsigned wnext; /* window write index */ 96 | unsigned char FAR *window; /* allocated sliding window, if needed */ 97 | /* bit accumulator */ 98 | unsigned long hold; /* input bit accumulator */ 99 | unsigned bits; /* number of bits in "in" */ 100 | /* for string and stored block copying */ 101 | unsigned length; /* literal or length of data to copy */ 102 | unsigned offset; /* distance back to copy string from */ 103 | /* for table and code decoding */ 104 | unsigned extra; /* extra bits needed */ 105 | /* fixed and dynamic code tables */ 106 | code const FAR *lencode; /* starting table for length/literal codes */ 107 | code const FAR *distcode; /* starting table for distance codes */ 108 | unsigned lenbits; /* index bits for lencode */ 109 | unsigned distbits; /* index bits for distcode */ 110 | /* dynamic table building */ 111 | unsigned ncode; /* number of code length code lengths */ 112 | unsigned nlen; /* number of length code lengths */ 113 | unsigned ndist; /* number of distance code lengths */ 114 | unsigned have; /* number of code lengths in lens[] */ 115 | code FAR *next; /* next available space in codes[] */ 116 | unsigned short lens[320]; /* temporary storage for code lengths */ 117 | unsigned short work[288]; /* work area for code table building */ 118 | code codes[ENOUGH]; /* space for code tables */ 119 | int sane; /* if false, allow invalid distance too far */ 120 | int back; /* bits back of last unprocessed length/lit */ 121 | unsigned was; /* initial length of match */ 122 | }; 123 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc10/zlibvc.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; zlib data compression and ZIP file I/O library 3 | 4 | VERSION 1.2.8 5 | 6 | EXPORTS 7 | adler32 @1 8 | compress @2 9 | crc32 @3 10 | deflate @4 11 | deflateCopy @5 12 | deflateEnd @6 13 | deflateInit2_ @7 14 | deflateInit_ @8 15 | deflateParams @9 16 | deflateReset @10 17 | deflateSetDictionary @11 18 | gzclose @12 19 | gzdopen @13 20 | gzerror @14 21 | gzflush @15 22 | gzopen @16 23 | gzread @17 24 | gzwrite @18 25 | inflate @19 26 | inflateEnd @20 27 | inflateInit2_ @21 28 | inflateInit_ @22 29 | inflateReset @23 30 | inflateSetDictionary @24 31 | inflateSync @25 32 | uncompress @26 33 | zlibVersion @27 34 | gzprintf @28 35 | gzputc @29 36 | gzgetc @30 37 | gzseek @31 38 | gzrewind @32 39 | gztell @33 40 | gzeof @34 41 | gzsetparams @35 42 | zError @36 43 | inflateSyncPoint @37 44 | get_crc_table @38 45 | compress2 @39 46 | gzputs @40 47 | gzgets @41 48 | inflateCopy @42 49 | inflateBackInit_ @43 50 | inflateBack @44 51 | inflateBackEnd @45 52 | compressBound @46 53 | deflateBound @47 54 | gzclearerr @48 55 | gzungetc @49 56 | zlibCompileFlags @50 57 | deflatePrime @51 58 | deflatePending @52 59 | 60 | unzOpen @61 61 | unzClose @62 62 | unzGetGlobalInfo @63 63 | unzGetCurrentFileInfo @64 64 | unzGoToFirstFile @65 65 | unzGoToNextFile @66 66 | unzOpenCurrentFile @67 67 | unzReadCurrentFile @68 68 | unzOpenCurrentFile3 @69 69 | unztell @70 70 | unzeof @71 71 | unzCloseCurrentFile @72 72 | unzGetGlobalComment @73 73 | unzStringFileNameCompare @74 74 | unzLocateFile @75 75 | unzGetLocalExtrafield @76 76 | unzOpen2 @77 77 | unzOpenCurrentFile2 @78 78 | unzOpenCurrentFilePassword @79 79 | 80 | zipOpen @80 81 | zipOpenNewFileInZip @81 82 | zipWriteInFileInZip @82 83 | zipCloseFileInZip @83 84 | zipClose @84 85 | zipOpenNewFileInZip2 @86 86 | zipCloseFileInZipRaw @87 87 | zipOpen2 @88 88 | zipOpenNewFileInZip3 @89 89 | 90 | unzGetFilePos @100 91 | unzGoToFilePos @101 92 | 93 | fill_win32_filefunc @110 94 | 95 | ; zlibwapi v1.2.4 added: 96 | fill_win32_filefunc64 @111 97 | fill_win32_filefunc64A @112 98 | fill_win32_filefunc64W @113 99 | 100 | unzOpen64 @120 101 | unzOpen2_64 @121 102 | unzGetGlobalInfo64 @122 103 | unzGetCurrentFileInfo64 @124 104 | unzGetCurrentFileZStreamPos64 @125 105 | unztell64 @126 106 | unzGetFilePos64 @127 107 | unzGoToFilePos64 @128 108 | 109 | zipOpen64 @130 110 | zipOpen2_64 @131 111 | zipOpenNewFileInZip64 @132 112 | zipOpenNewFileInZip2_64 @133 113 | zipOpenNewFileInZip3_64 @134 114 | zipOpenNewFileInZip4_64 @135 115 | zipCloseFileInZipRaw64 @136 116 | 117 | ; zlib1 v1.2.4 added: 118 | adler32_combine @140 119 | crc32_combine @142 120 | deflateSetHeader @144 121 | deflateTune @145 122 | gzbuffer @146 123 | gzclose_r @147 124 | gzclose_w @148 125 | gzdirect @149 126 | gzoffset @150 127 | inflateGetHeader @156 128 | inflateMark @157 129 | inflatePrime @158 130 | inflateReset2 @159 131 | inflateUndermine @160 132 | 133 | ; zlib1 v1.2.6 added: 134 | gzgetc_ @161 135 | inflateResetKeep @163 136 | deflateResetKeep @164 137 | 138 | ; zlib1 v1.2.7 added: 139 | gzopen_w @165 140 | 141 | ; zlib1 v1.2.8 added: 142 | inflateGetDictionary @166 143 | gzvprintf @167 144 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc11/zlibvc.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; zlib data compression and ZIP file I/O library 3 | 4 | VERSION 1.2.8 5 | 6 | EXPORTS 7 | adler32 @1 8 | compress @2 9 | crc32 @3 10 | deflate @4 11 | deflateCopy @5 12 | deflateEnd @6 13 | deflateInit2_ @7 14 | deflateInit_ @8 15 | deflateParams @9 16 | deflateReset @10 17 | deflateSetDictionary @11 18 | gzclose @12 19 | gzdopen @13 20 | gzerror @14 21 | gzflush @15 22 | gzopen @16 23 | gzread @17 24 | gzwrite @18 25 | inflate @19 26 | inflateEnd @20 27 | inflateInit2_ @21 28 | inflateInit_ @22 29 | inflateReset @23 30 | inflateSetDictionary @24 31 | inflateSync @25 32 | uncompress @26 33 | zlibVersion @27 34 | gzprintf @28 35 | gzputc @29 36 | gzgetc @30 37 | gzseek @31 38 | gzrewind @32 39 | gztell @33 40 | gzeof @34 41 | gzsetparams @35 42 | zError @36 43 | inflateSyncPoint @37 44 | get_crc_table @38 45 | compress2 @39 46 | gzputs @40 47 | gzgets @41 48 | inflateCopy @42 49 | inflateBackInit_ @43 50 | inflateBack @44 51 | inflateBackEnd @45 52 | compressBound @46 53 | deflateBound @47 54 | gzclearerr @48 55 | gzungetc @49 56 | zlibCompileFlags @50 57 | deflatePrime @51 58 | deflatePending @52 59 | 60 | unzOpen @61 61 | unzClose @62 62 | unzGetGlobalInfo @63 63 | unzGetCurrentFileInfo @64 64 | unzGoToFirstFile @65 65 | unzGoToNextFile @66 66 | unzOpenCurrentFile @67 67 | unzReadCurrentFile @68 68 | unzOpenCurrentFile3 @69 69 | unztell @70 70 | unzeof @71 71 | unzCloseCurrentFile @72 72 | unzGetGlobalComment @73 73 | unzStringFileNameCompare @74 74 | unzLocateFile @75 75 | unzGetLocalExtrafield @76 76 | unzOpen2 @77 77 | unzOpenCurrentFile2 @78 78 | unzOpenCurrentFilePassword @79 79 | 80 | zipOpen @80 81 | zipOpenNewFileInZip @81 82 | zipWriteInFileInZip @82 83 | zipCloseFileInZip @83 84 | zipClose @84 85 | zipOpenNewFileInZip2 @86 86 | zipCloseFileInZipRaw @87 87 | zipOpen2 @88 88 | zipOpenNewFileInZip3 @89 89 | 90 | unzGetFilePos @100 91 | unzGoToFilePos @101 92 | 93 | fill_win32_filefunc @110 94 | 95 | ; zlibwapi v1.2.4 added: 96 | fill_win32_filefunc64 @111 97 | fill_win32_filefunc64A @112 98 | fill_win32_filefunc64W @113 99 | 100 | unzOpen64 @120 101 | unzOpen2_64 @121 102 | unzGetGlobalInfo64 @122 103 | unzGetCurrentFileInfo64 @124 104 | unzGetCurrentFileZStreamPos64 @125 105 | unztell64 @126 106 | unzGetFilePos64 @127 107 | unzGoToFilePos64 @128 108 | 109 | zipOpen64 @130 110 | zipOpen2_64 @131 111 | zipOpenNewFileInZip64 @132 112 | zipOpenNewFileInZip2_64 @133 113 | zipOpenNewFileInZip3_64 @134 114 | zipOpenNewFileInZip4_64 @135 115 | zipCloseFileInZipRaw64 @136 116 | 117 | ; zlib1 v1.2.4 added: 118 | adler32_combine @140 119 | crc32_combine @142 120 | deflateSetHeader @144 121 | deflateTune @145 122 | gzbuffer @146 123 | gzclose_r @147 124 | gzclose_w @148 125 | gzdirect @149 126 | gzoffset @150 127 | inflateGetHeader @156 128 | inflateMark @157 129 | inflatePrime @158 130 | inflateReset2 @159 131 | inflateUndermine @160 132 | 133 | ; zlib1 v1.2.6 added: 134 | gzgetc_ @161 135 | inflateResetKeep @163 136 | deflateResetKeep @164 137 | 138 | ; zlib1 v1.2.7 added: 139 | gzopen_w @165 140 | 141 | ; zlib1 v1.2.8 added: 142 | inflateGetDictionary @166 143 | gzvprintf @167 144 | -------------------------------------------------------------------------------- /External/zlib/contrib/vstudio/vc9/zlibvc.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; zlib data compression and ZIP file I/O library 3 | 4 | VERSION 1.2.8 5 | 6 | EXPORTS 7 | adler32 @1 8 | compress @2 9 | crc32 @3 10 | deflate @4 11 | deflateCopy @5 12 | deflateEnd @6 13 | deflateInit2_ @7 14 | deflateInit_ @8 15 | deflateParams @9 16 | deflateReset @10 17 | deflateSetDictionary @11 18 | gzclose @12 19 | gzdopen @13 20 | gzerror @14 21 | gzflush @15 22 | gzopen @16 23 | gzread @17 24 | gzwrite @18 25 | inflate @19 26 | inflateEnd @20 27 | inflateInit2_ @21 28 | inflateInit_ @22 29 | inflateReset @23 30 | inflateSetDictionary @24 31 | inflateSync @25 32 | uncompress @26 33 | zlibVersion @27 34 | gzprintf @28 35 | gzputc @29 36 | gzgetc @30 37 | gzseek @31 38 | gzrewind @32 39 | gztell @33 40 | gzeof @34 41 | gzsetparams @35 42 | zError @36 43 | inflateSyncPoint @37 44 | get_crc_table @38 45 | compress2 @39 46 | gzputs @40 47 | gzgets @41 48 | inflateCopy @42 49 | inflateBackInit_ @43 50 | inflateBack @44 51 | inflateBackEnd @45 52 | compressBound @46 53 | deflateBound @47 54 | gzclearerr @48 55 | gzungetc @49 56 | zlibCompileFlags @50 57 | deflatePrime @51 58 | deflatePending @52 59 | 60 | unzOpen @61 61 | unzClose @62 62 | unzGetGlobalInfo @63 63 | unzGetCurrentFileInfo @64 64 | unzGoToFirstFile @65 65 | unzGoToNextFile @66 66 | unzOpenCurrentFile @67 67 | unzReadCurrentFile @68 68 | unzOpenCurrentFile3 @69 69 | unztell @70 70 | unzeof @71 71 | unzCloseCurrentFile @72 72 | unzGetGlobalComment @73 73 | unzStringFileNameCompare @74 74 | unzLocateFile @75 75 | unzGetLocalExtrafield @76 76 | unzOpen2 @77 77 | unzOpenCurrentFile2 @78 78 | unzOpenCurrentFilePassword @79 79 | 80 | zipOpen @80 81 | zipOpenNewFileInZip @81 82 | zipWriteInFileInZip @82 83 | zipCloseFileInZip @83 84 | zipClose @84 85 | zipOpenNewFileInZip2 @86 86 | zipCloseFileInZipRaw @87 87 | zipOpen2 @88 88 | zipOpenNewFileInZip3 @89 89 | 90 | unzGetFilePos @100 91 | unzGoToFilePos @101 92 | 93 | fill_win32_filefunc @110 94 | 95 | ; zlibwapi v1.2.4 added: 96 | fill_win32_filefunc64 @111 97 | fill_win32_filefunc64A @112 98 | fill_win32_filefunc64W @113 99 | 100 | unzOpen64 @120 101 | unzOpen2_64 @121 102 | unzGetGlobalInfo64 @122 103 | unzGetCurrentFileInfo64 @124 104 | unzGetCurrentFileZStreamPos64 @125 105 | unztell64 @126 106 | unzGetFilePos64 @127 107 | unzGoToFilePos64 @128 108 | 109 | zipOpen64 @130 110 | zipOpen2_64 @131 111 | zipOpenNewFileInZip64 @132 112 | zipOpenNewFileInZip2_64 @133 113 | zipOpenNewFileInZip3_64 @134 114 | zipOpenNewFileInZip4_64 @135 115 | zipCloseFileInZipRaw64 @136 116 | 117 | ; zlib1 v1.2.4 added: 118 | adler32_combine @140 119 | crc32_combine @142 120 | deflateSetHeader @144 121 | deflateTune @145 122 | gzbuffer @146 123 | gzclose_r @147 124 | gzclose_w @148 125 | gzdirect @149 126 | gzoffset @150 127 | inflateGetHeader @156 128 | inflateMark @157 129 | inflatePrime @158 130 | inflateReset2 @159 131 | inflateUndermine @160 132 | 133 | ; zlib1 v1.2.6 added: 134 | gzgetc_ @161 135 | inflateResetKeep @163 136 | deflateResetKeep @164 137 | 138 | ; zlib1 v1.2.7 added: 139 | gzopen_w @165 140 | 141 | ; zlib1 v1.2.8 added: 142 | inflateGetDictionary @166 143 | gzvprintf @167 144 | -------------------------------------------------------------------------------- /External/zlib/gzguts.h: -------------------------------------------------------------------------------- 1 | /* gzguts.h -- zlib internal header definitions for gz* operations 2 | * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifdef _LARGEFILE64_SOURCE 7 | # ifndef _LARGEFILE_SOURCE 8 | # define _LARGEFILE_SOURCE 1 9 | # endif 10 | # ifdef _FILE_OFFSET_BITS 11 | # undef _FILE_OFFSET_BITS 12 | # endif 13 | #endif 14 | 15 | #ifdef HAVE_HIDDEN 16 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 17 | #else 18 | # define ZLIB_INTERNAL 19 | #endif 20 | 21 | #include 22 | #include "zlib.h" 23 | #ifdef STDC 24 | # include 25 | # include 26 | # include 27 | #endif 28 | #include 29 | 30 | #ifdef _WIN32 31 | # include 32 | #endif 33 | 34 | #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) 35 | # include 36 | #endif 37 | 38 | #ifdef WINAPI_FAMILY 39 | # define open _open 40 | # define read _read 41 | # define write _write 42 | # define close _close 43 | #endif 44 | 45 | #ifdef NO_DEFLATE /* for compatibility with old definition */ 46 | # define NO_GZCOMPRESS 47 | #endif 48 | 49 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 50 | # ifndef HAVE_VSNPRINTF 51 | # define HAVE_VSNPRINTF 52 | # endif 53 | #endif 54 | 55 | #if defined(__CYGWIN__) 56 | # ifndef HAVE_VSNPRINTF 57 | # define HAVE_VSNPRINTF 58 | # endif 59 | #endif 60 | 61 | #if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) 62 | # ifndef HAVE_VSNPRINTF 63 | # define HAVE_VSNPRINTF 64 | # endif 65 | #endif 66 | 67 | #ifndef HAVE_VSNPRINTF 68 | # ifdef MSDOS 69 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 70 | but for now we just assume it doesn't. */ 71 | # define NO_vsnprintf 72 | # endif 73 | # ifdef __TURBOC__ 74 | # define NO_vsnprintf 75 | # endif 76 | # ifdef WIN32 77 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 78 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) 79 | # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) 80 | # define vsnprintf _vsnprintf 81 | # endif 82 | # endif 83 | # endif 84 | # ifdef __SASC 85 | # define NO_vsnprintf 86 | # endif 87 | # ifdef VMS 88 | # define NO_vsnprintf 89 | # endif 90 | # ifdef __OS400__ 91 | # define NO_vsnprintf 92 | # endif 93 | # ifdef __MVS__ 94 | # define NO_vsnprintf 95 | # endif 96 | #endif 97 | 98 | /* unlike snprintf (which is required in C99, yet still not supported by 99 | Microsoft more than a decade later!), _snprintf does not guarantee null 100 | termination of the result -- however this is only used in gzlib.c where 101 | the result is assured to fit in the space provided */ 102 | #ifdef _MSC_VER 103 | # define snprintf _snprintf 104 | #endif 105 | 106 | #ifndef local 107 | # define local static 108 | #endif 109 | /* compile with -Dlocal if your debugger can't find static symbols */ 110 | 111 | /* gz* functions always use library allocation functions */ 112 | #ifndef STDC 113 | extern voidp malloc OF((uInt size)); 114 | extern void free OF((voidpf ptr)); 115 | #endif 116 | 117 | /* get errno and strerror definition */ 118 | #if defined UNDER_CE 119 | # include 120 | # define zstrerror() gz_strwinerror((DWORD)GetLastError()) 121 | #else 122 | # ifndef NO_STRERROR 123 | # include 124 | # define zstrerror() strerror(errno) 125 | # else 126 | # define zstrerror() "stdio error (consult errno)" 127 | # endif 128 | #endif 129 | 130 | /* provide prototypes for these when building zlib without LFS */ 131 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 132 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); 133 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); 134 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); 135 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); 136 | #endif 137 | 138 | /* default memLevel */ 139 | #if MAX_MEM_LEVEL >= 8 140 | # define DEF_MEM_LEVEL 8 141 | #else 142 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 143 | #endif 144 | 145 | /* default i/o buffer size -- double this for output when reading (this and 146 | twice this must be able to fit in an unsigned type) */ 147 | #define GZBUFSIZE 8192 148 | 149 | /* gzip modes, also provide a little integrity check on the passed structure */ 150 | #define GZ_NONE 0 151 | #define GZ_READ 7247 152 | #define GZ_WRITE 31153 153 | #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ 154 | 155 | /* values for gz_state how */ 156 | #define LOOK 0 /* look for a gzip header */ 157 | #define COPY 1 /* copy input directly */ 158 | #define GZIP 2 /* decompress a gzip stream */ 159 | 160 | /* internal gzip file state data structure */ 161 | typedef struct { 162 | /* exposed contents for gzgetc() macro */ 163 | struct gzFile_s x; /* "x" for exposed */ 164 | /* x.have: number of bytes available at x.next */ 165 | /* x.next: next output data to deliver or write */ 166 | /* x.pos: current position in uncompressed data */ 167 | /* used for both reading and writing */ 168 | int mode; /* see gzip modes above */ 169 | int fd; /* file descriptor */ 170 | char *path; /* path or fd for error messages */ 171 | unsigned size; /* buffer size, zero if not allocated yet */ 172 | unsigned want; /* requested buffer size, default is GZBUFSIZE */ 173 | unsigned char *in; /* input buffer */ 174 | unsigned char *out; /* output buffer (double-sized when reading) */ 175 | int direct; /* 0 if processing gzip, 1 if transparent */ 176 | /* just for reading */ 177 | int how; /* 0: get header, 1: copy, 2: decompress */ 178 | z_off64_t start; /* where the gzip data started, for rewinding */ 179 | int eof; /* true if end of input file reached */ 180 | int past; /* true if read requested past end */ 181 | /* just for writing */ 182 | int level; /* compression level */ 183 | int strategy; /* compression strategy */ 184 | /* seek request */ 185 | z_off64_t skip; /* amount to skip (already rewound if backwards) */ 186 | int seek; /* true if seek request pending */ 187 | /* error information */ 188 | int err; /* error code */ 189 | char *msg; /* error message */ 190 | /* zlib inflate or deflate stream */ 191 | z_stream strm; /* stream structure in-place (not a pointer) */ 192 | } gz_state; 193 | typedef gz_state FAR *gz_statep; 194 | 195 | /* shared functions */ 196 | void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); 197 | #if defined UNDER_CE 198 | char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); 199 | #endif 200 | 201 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t 202 | value -- needed when comparing unsigned to z_off64_t, which is signed 203 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ 204 | #ifdef INT_MAX 205 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) 206 | #else 207 | unsigned ZLIB_INTERNAL gz_intmax OF((void)); 208 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) 209 | #endif 210 | -------------------------------------------------------------------------------- /PCD2DDS/PCD.cpp: -------------------------------------------------------------------------------- 1 | #include "PCD.h" 2 | #include "File.h" 3 | 4 | #include 5 | #include 6 | 7 | void ConvertPCDToDDS(const char* filePath) 8 | { 9 | #if !PS3 10 | std::ifstream ifs(filePath, std::ios::binary); 11 | 12 | //If there was a failure to open the file we must exit 13 | if (!ifs.good()) 14 | { 15 | std::cout << "Error: failed to open the file!" << std::endl; 16 | ifs.close(); 17 | return; 18 | } 19 | 20 | //Check to see if file has valid section header 21 | unsigned int sectionMagic = ReadUInt(ifs); 22 | if (sectionMagic != SECTION_MAGIC) 23 | { 24 | std::cout << "Error: section magic mis-match!" << std::endl; 25 | ifs.close(); 26 | return; 27 | } 28 | 29 | unsigned int sectionSize = ReadUInt(ifs); 30 | if (sectionSize <= 0) 31 | { 32 | std::cout << "Error: section corrupt, size is <= 0!" << std::endl; 33 | ifs.close(); 34 | return; 35 | } 36 | 37 | unsigned char sectionType = ReadUByte(ifs); 38 | if (sectionType != TEXTURE_SECTION_TYPE) 39 | { 40 | std::cout << "Error: invalid section type!" << std::endl; 41 | ifs.close(); 42 | return; 43 | } 44 | 45 | //Skip past section header 46 | ifs.seekg(24, SEEK_SET); 47 | 48 | //Load texture data header 49 | cdc::PC::Texture::Header pcdHeader; 50 | ifs.read(reinterpret_cast(&pcdHeader), sizeof(cdc::PC::Texture::Header)); 51 | 52 | if (pcdHeader.m_magic != PCD_MAGIC) 53 | { 54 | std::cout << "Error PCD magic mis-match!" << std::endl; 55 | ifs.close(); 56 | return; 57 | } 58 | 59 | char* textureData = new char[pcdHeader.m_textureDataSize]; 60 | ifs.read(textureData, pcdHeader.m_textureDataSize); 61 | ifs.close(); 62 | 63 | char nameBuff[128]; 64 | memset(nameBuff, 0, 128); 65 | 66 | switch (pcdHeader.m_format) 67 | { 68 | case cdc::PC::Texture::kFormat::BPP_32: 69 | sprintf_s(nameBuff, "%s%s", filePath, ".tga"); 70 | WriteTarga(pcdHeader, textureData, &nameBuff[0]); 71 | break; 72 | case cdc::PC::Texture::kFormat::DXT1: 73 | case cdc::PC::Texture::kFormat::DXT3: 74 | case cdc::PC::Texture::kFormat::DXT5: 75 | sprintf_s(nameBuff, "%s%s", filePath, ".dds"); 76 | WriteDDS(pcdHeader, textureData, &nameBuff[0]); 77 | break; 78 | default: 79 | std::cout << "Error: Unsupported texture format!" << std::endl; 80 | break; 81 | } 82 | 83 | delete [] textureData; 84 | #else 85 | std::ifstream ifs(filePath, std::ios::binary); 86 | 87 | //If there was a failure to open the file we must exit 88 | if (!ifs.good()) 89 | { 90 | std::cout << "Error: failed to open the file!" << std::endl; 91 | ifs.close(); 92 | return; 93 | } 94 | 95 | //Check to see if file has valid section header 96 | unsigned int sectionMagic = ReadUInt(ifs); 97 | 98 | if (sectionMagic != SECTION_MAGIC) 99 | { 100 | std::cout << "Error: section magic mis-match!" << std::endl; 101 | ifs.close(); 102 | return; 103 | } 104 | 105 | unsigned int sectionSize = ReadUInt(ifs); 106 | if (sectionSize <= 0) 107 | { 108 | std::cout << "Error: section corrupt, size is <= 0!" << std::endl; 109 | ifs.close(); 110 | return; 111 | } 112 | 113 | unsigned char sectionType = ReadUByte(ifs); 114 | if (sectionType != TEXTURE_SECTION_TYPE) 115 | { 116 | std::cout << "Error: invalid section type!" << std::endl; 117 | ifs.close(); 118 | return; 119 | } 120 | 121 | //Skip past section header 122 | ifs.seekg(24, SEEK_SET); 123 | 124 | //Load texture data header 125 | cdc::ps3::Texture::Header ps3tHeader; 126 | ifs.read(reinterpret_cast(&ps3tHeader), sizeof(cdc::ps3::Texture::Header)); 127 | 128 | //Endian swap 129 | ps3tHeader.m_magic = ReverseUInt(ps3tHeader.m_magic); 130 | ps3tHeader.m_textureDataSize = ReverseUInt(ps3tHeader.m_textureDataSize); 131 | ps3tHeader.m_width = ReverseUShort(ps3tHeader.m_width); 132 | ps3tHeader.m_height = ReverseUShort(ps3tHeader.m_height); 133 | 134 | //Swap 135 | if (ps3tHeader.m_magic != PS3T_MAGIC) 136 | { 137 | std::cout << "Error PS3T magic mis-match!" << std::endl; 138 | ifs.close(); 139 | return; 140 | } 141 | 142 | char* textureData = new char[ps3tHeader.m_textureDataSize]; 143 | ifs.read(textureData, ps3tHeader.m_textureDataSize); 144 | ifs.close(); 145 | 146 | char nameBuff[128]; 147 | memset(nameBuff, 0, 128); 148 | sprintf_s(nameBuff, "%s%s", filePath, ".dds"); 149 | 150 | std::ofstream ofs(nameBuff, std::ios::binary); 151 | 152 | unsigned int ddsSize = 0x7C; 153 | unsigned int ddsFlags = 0x000A1007; 154 | unsigned int ddsPitchOrLinearSize = 0x00010000; 155 | unsigned int ddsDummy = 0; 156 | unsigned int ddsHeight = ps3tHeader.m_height; 157 | unsigned int ddsWidth = ps3tHeader.m_width; 158 | unsigned int ddsDepth = 0;//;ps3tHeader.m_depth; 159 | unsigned int ddsMipCount = 0;// ps3tHeader.m_numMipMaps; 160 | unsigned int ddsFormat = cdc::ps3::Texture::getFormat(ps3tHeader.m_format); 161 | unsigned int ddsUnk00 = 0x00401008; 162 | 163 | WriteUInt(ofs, DDS_MAGIC); 164 | WriteUInt(ofs, ddsSize); 165 | WriteUInt(ofs, ddsFlags); 166 | WriteUInt(ofs, ddsHeight); 167 | 168 | WriteUInt(ofs, ddsWidth); 169 | WriteUInt(ofs, ddsPitchOrLinearSize); 170 | WriteUInt(ofs, ddsDummy); 171 | WriteUInt(ofs, ddsDepth); 172 | 173 | WriteUInt(ofs, ddsMipCount); 174 | 175 | //Reserved 176 | ofs.seekp(12 * sizeof(unsigned int), SEEK_CUR); 177 | 178 | WriteUInt(ofs, ddsFormat); 179 | ofs.seekp(0x14, SEEK_CUR); 180 | WriteUInt(ofs, ddsUnk00); 181 | ofs.seekp(0x10, SEEK_CUR); 182 | 183 | ofs.write(textureData, ps3tHeader.m_textureDataSize); 184 | 185 | ofs.flush(); 186 | ofs.close(); 187 | delete[] textureData; 188 | #endif 189 | } 190 | 191 | unsigned int cdc::ps3::Texture::getFormat(unsigned int format) 192 | { 193 | switch (format) 194 | { 195 | case cdc::ps3::Texture::kFormat::DXT1: 196 | return 0x31545844; 197 | break; 198 | case cdc::ps3::Texture::kFormat::DXT5: 199 | return 0x35545844; 200 | default: 201 | assert(false); 202 | break; 203 | } 204 | 205 | return -1; 206 | } 207 | 208 | void cdc::PC::Texture::WriteDDS(const cdc::PC::Texture::Header& header, char* textureData, char* resultFileName) 209 | { 210 | if (textureData == nullptr) 211 | { 212 | std::cout << "Error: invalid texture data pointer passed to WriteDDS!" << std::endl; 213 | return; 214 | } 215 | 216 | std::ofstream ofs(resultFileName, std::ios::binary); 217 | 218 | WriteUInt(ofs, DDS_MAGIC); 219 | WriteUInt(ofs, 124); 220 | WriteUInt(ofs, 0x000A1007); 221 | WriteUInt(ofs, header.m_height); 222 | 223 | WriteUInt(ofs, header.m_width); 224 | WriteUInt(ofs, 0x00010000); 225 | WriteUInt(ofs, 0); 226 | WriteUInt(ofs, 0); 227 | 228 | WriteUInt(ofs, header.m_numMipMaps); 229 | 230 | //Reserved 231 | ofs.seekp(12 * sizeof(unsigned int), SEEK_CUR); 232 | 233 | WriteUInt(ofs, header.m_format); 234 | ofs.seekp(0x14, SEEK_CUR); 235 | WriteUInt(ofs, 0x00401008); 236 | ofs.seekp(0x10, SEEK_CUR); 237 | 238 | ofs.write(textureData, header.m_textureDataSize); 239 | 240 | ofs.flush(); 241 | ofs.close(); 242 | 243 | } 244 | 245 | void cdc::PC::Texture::WriteTarga(const cdc::PC::Texture::Header& header, char* textureData, char* resultFileName) 246 | { 247 | if (textureData == nullptr) 248 | { 249 | std::cout << "Error: invalid texture data pointer passed to WriteTarga!" << std::endl; 250 | return; 251 | } 252 | 253 | std::ofstream ofs(resultFileName, std::ios::binary); 254 | 255 | WriteUInt(ofs, 0x00020000); 256 | WriteUInt(ofs, 0); 257 | WriteUInt(ofs, 0); 258 | 259 | WriteUShort(ofs, header.m_width); 260 | WriteUShort(ofs, header.m_height); 261 | WriteUShort(ofs, 0x820); 262 | 263 | ofs.write(textureData, header.m_textureDataSize); 264 | 265 | ofs.flush(); 266 | ofs.close(); 267 | } 268 | -------------------------------------------------------------------------------- /WAVE2WAV/WAVE2WAV.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {394F39DC-CFE6-4378-A441-77E22C410DA9} 23 | Win32Proj 24 | WAVE2WAV 25 | 8.1 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | 87 | 88 | Level3 89 | Disabled 90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 91 | 92 | 93 | Console 94 | 95 | 96 | 97 | 98 | 99 | 100 | Level3 101 | Disabled 102 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 103 | 104 | 105 | Console 106 | 107 | 108 | 109 | 110 | Level3 111 | 112 | 113 | MaxSpeed 114 | true 115 | true 116 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 117 | 118 | 119 | Console 120 | true 121 | true 122 | 123 | 124 | 125 | 126 | Level3 127 | 128 | 129 | MaxSpeed 130 | true 131 | true 132 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 133 | 134 | 135 | Console 136 | true 137 | true 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /PCD2DDS/PCD2DDS.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {79E3710B-C706-45D3-8390-B35ABF240F92} 23 | Win32Proj 24 | PCD2DDS 25 | 8.1 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | 87 | 88 | Level3 89 | Disabled 90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 91 | 92 | 93 | Console 94 | 95 | 96 | 97 | 98 | 99 | 100 | Level3 101 | Disabled 102 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 103 | 104 | 105 | Console 106 | 107 | 108 | 109 | 110 | Level3 111 | 112 | 113 | MaxSpeed 114 | true 115 | true 116 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 117 | 118 | 119 | Console 120 | true 121 | true 122 | 123 | 124 | 125 | 126 | Level3 127 | 128 | 129 | MaxSpeed 130 | true 131 | true 132 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 133 | 134 | 135 | Console 136 | true 137 | true 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /DRM/DRM.cpp: -------------------------------------------------------------------------------- 1 | #include "DRM.h" 2 | #include "File.h" 3 | #include "FileExtensions.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | cDRM::cDRM() 13 | { 14 | this->m_version = 0; 15 | this->m_numSections = 0; 16 | if (this->m_sections.size() > 0) 17 | { 18 | this->m_sections.clear(); 19 | } 20 | } 21 | 22 | cDRM::~cDRM() 23 | { 24 | this->m_version = 0; 25 | this->m_numSections = 0; 26 | if (this->m_sections.size() > 0) 27 | { 28 | this->m_sections.clear(); 29 | } 30 | } 31 | 32 | void cDRM::ExtractSections(char* szFilePath) 33 | { 34 | //Store DRM input path 35 | this->m_filePath = szFilePath; 36 | 37 | //Initialise ifstream for reading in binary mode 38 | std::ifstream ifs(this->m_filePath, std::ios::binary); 39 | 40 | //If it's not good to go 41 | if (!ifs.good()) 42 | { 43 | std::cout << "Fatal Error: Failed to open file at path: " << this->m_filePath << std::endl; 44 | return; 45 | } 46 | 47 | //Read our DRM header into cDRM 48 | this->m_version = ReadUInt(ifs); 49 | if (this->m_version != DRM_VERSION) 50 | { 51 | std::cout << "Fatal Error: Version mis-match! expected: " << DRM_VERSION << " got: " << this->m_version << std::endl; 52 | return; 53 | } 54 | 55 | #if TR8 56 | this->m_nameSize = ReadUInt(ifs); 57 | this->m_paddingSize = ReadUInt(ifs); 58 | this->m_unk00 = ReadUInt(ifs); 59 | this->m_unk01 = ReadUInt(ifs); 60 | #elif TRAS 61 | this->m_nameSize = ReadUInt(ifs); 62 | this->m_paddingSize = ReadUInt(ifs); 63 | this->m_unk00 = ReadUInt(ifs); 64 | this->m_unk01 = ReadUInt(ifs); 65 | this->m_unk02 = ReadUInt(ifs); 66 | #endif 67 | 68 | this->m_numSections = ReadUInt(ifs); 69 | if (this->m_numSections > DRM_MAX_SECTIONS) 70 | { 71 | std::cout << "Fatal Error: Number of Sections: " << this->m_numSections << " exceeded the limit of: " << DRM_MAX_SECTIONS << "!" << std::endl; 72 | return; 73 | } 74 | 75 | //If not enough sections 76 | if (this->m_numSections <= 0) 77 | { 78 | std::cout << "Fatal Error: Number of Sections <= 0 !" << std::endl; 79 | return; 80 | } 81 | 82 | #if TRAS 83 | ifs.seekg(0x4, SEEK_CUR); 84 | #endif 85 | 86 | //Read all the section info into this 87 | for (int i = 0; i != this->m_numSections; i++) 88 | { 89 | this->m_sections.emplace_back(); 90 | Section* section = &this->m_sections[this->m_sections.size() - 1]; 91 | 92 | section->uiSize = ReadUInt(ifs); 93 | section->ucType = ReadUByte(ifs); 94 | section->ucUnk00 = ReadUByte(ifs); 95 | section->usUnk01 = ReadUShort(ifs); 96 | section->uiHeaderSize = ReadUInt(ifs); 97 | section->uiHash = ReadUInt(ifs); 98 | section->uiLang = ReadUInt(ifs); 99 | } 100 | 101 | #if TR8 || TRAS 102 | //Skip past names & padding info 103 | ifs.seekg(this->m_nameSize + this->m_paddingSize, SEEK_CUR); 104 | #endif 105 | 106 | std::string strOutPath = std::string(this->m_filePath); 107 | strOutPath = strOutPath.substr(0, strOutPath.find_last_of(".")) + "\\";; 108 | 109 | //Create Directories 110 | CreateDirectories(strOutPath); 111 | 112 | for (int i = 0; i != this->m_numSections; i++) 113 | { 114 | Section* section = &this->m_sections[i]; 115 | 116 | //Print extraction message to console 117 | std::cout << "Extracting Section: " << "[ " << (i + 1) << " / " << this->m_numSections << " ]" << std::endl; 118 | 119 | //Define output file path 120 | std::stringstream strOutPath2; 121 | strOutPath2 << strOutPath << i << "_" << std::hex << section->uiHash << szExtensions[section->ucType]; 122 | 123 | std::stringstream strOutPath3; 124 | strOutPath3 << strOutPath << "\\sectionList.txt"; 125 | 126 | //Skip header 127 | #if REPACK_MODE 128 | bool bRealSize = false;//Don't modify 129 | #else 130 | bool bRealSize = true; 131 | #endif 132 | 133 | if (bRealSize) 134 | { 135 | //Declare variables to store data 136 | char* szSectionData = new char[section->uiSize]; 137 | 138 | //Declare output file stream 139 | std::ofstream ofs(strOutPath2.str(), std::ios::binary); 140 | 141 | //Create output sectionList.txt 142 | std::ofstream ofs2(strOutPath3.str(), std::ios::app); 143 | 144 | ofs2 << i << "_" << std::hex << section->uiHash << szExtensions[section->ucType] << std::endl; 145 | 146 | //If not good to go 147 | if (!ofs.good()) 148 | { 149 | std::cout << "Fatal Error: Unknown error occured whilst initialising ofstream!" << std::endl; 150 | return; 151 | } 152 | 153 | //Skip header info 154 | #if TR7 || TRAE 155 | ifs.seekg(((section->uiHeaderSize >> 0x8) * 0x8), SEEK_CUR); 156 | #elif TR8 157 | ifs.seekg((section->uiHeaderSize >> 0x8), SEEK_CUR); 158 | #elif TRAS 159 | ifs.seekg((section->uiHeaderSize >> 0x8), SEEK_CUR); 160 | #else 161 | #error "Unsupported Game!" 162 | #endif 163 | //Read then write the section data 164 | ifs.read(szSectionData, section->uiSize); 165 | #if REPACK_MODE && (TR7 || TRAE) 166 | //Write section header 167 | WriteUInt(ofs, 0x54434553); 168 | WriteUInt(ofs, section->uiSize); 169 | WriteUByte(ofs, section->ucType); 170 | WriteUByte(ofs, section->ucUnk00); 171 | WriteUShort(ofs, section->usUnk01); 172 | WriteUInt(ofs, section->uiHeaderSize); 173 | WriteUInt(ofs, section->uiHash); 174 | WriteUInt(ofs, section->uiLang); 175 | #endif 176 | ofs.write(szSectionData, section->uiSize); 177 | 178 | //Flush and close ofstream 179 | ofs.flush(); 180 | ofs.close(); 181 | 182 | // 183 | ofs2.flush(); 184 | ofs2.close(); 185 | 186 | //delete allocated section data 187 | delete[] szSectionData; 188 | } 189 | else 190 | { 191 | //Declare char* to store section data 192 | #if TR7 || TRAE 193 | char* szSectionData = new char[section->uiSize + ((section->uiHeaderSize >> 0x8) * 0x8)]; 194 | #elif TR8 195 | char* szSectionData = new char[section->uiSize + (section->uiHeaderSize >> 0x8)]; 196 | #elif TRAS 197 | char* szSectionData = new char[section->uiSize + (section->uiHeaderSize >> 0x8)]; 198 | #endif 199 | 200 | //Declare output file stream 201 | std::ofstream ofs(strOutPath2.str(), std::ios::binary); 202 | 203 | //Create output sectionList.txt 204 | std::ofstream ofs2(strOutPath3.str(), std::ios::app); 205 | 206 | ofs2 << i << "_" << std::hex << section->uiHash << szExtensions[section->ucType] << std::endl; 207 | 208 | //If not good to go 209 | if (!ofs.good()) 210 | { 211 | std::cout << "Fatal Error: Unknown error occured whilst initialising ofstream!" << std::endl; 212 | return; 213 | } 214 | 215 | //Read then write the section data 216 | #if REPACK_MODE 217 | //Write section header 218 | WriteUInt(ofs, 0x54434553); 219 | WriteUInt(ofs, section->uiSize); 220 | WriteUByte(ofs, section->ucType); 221 | WriteUByte(ofs, section->ucUnk00); 222 | WriteUShort(ofs, section->usUnk01); 223 | WriteUInt(ofs, section->uiHeaderSize); 224 | WriteUInt(ofs, section->uiHash); 225 | WriteUInt(ofs, section->uiLang); 226 | #endif 227 | #if TR7 || TRAE 228 | ifs.read(szSectionData, section->uiSize + ((section->uiHeaderSize >> 0x8) * 0x8)); 229 | ofs.write(szSectionData, section->uiSize + ((section->uiHeaderSize >> 0x8) * 0x8)); 230 | #elif TR8 231 | ifs.read(szSectionData, section->uiSize + (section->uiHeaderSize >> 0x8)); 232 | ofs.write(szSectionData, section->uiSize + (section->uiHeaderSize >> 0x8)); 233 | #elif TRAS 234 | ifs.read(szSectionData, section->uiSize + (section->uiHeaderSize >> 0x8)); 235 | ofs.write(szSectionData, section->uiSize + (section->uiHeaderSize >> 0x8)); 236 | #endif 237 | //Flush and close ofstream 238 | ofs.flush(); 239 | ofs.close(); 240 | 241 | //Flush and close ofstream 242 | ofs2.flush(); 243 | ofs2.close(); 244 | 245 | //Delete allocated section data 246 | delete[] szSectionData; 247 | } 248 | } 249 | 250 | //Close ifstream 251 | ifs.close(); 252 | 253 | //Print success 254 | std::cout << "Successfully Extracted: " << "[ " << (this->m_numSections) << " ] " << " section(s)!" << std::endl; 255 | } -------------------------------------------------------------------------------- /External/zlib/zutil.h: -------------------------------------------------------------------------------- 1 | /* zutil.h -- internal interface and configuration of the compression library 2 | * Copyright (C) 1995-2013 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef ZUTIL_H 14 | #define ZUTIL_H 15 | 16 | #ifdef HAVE_HIDDEN 17 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 18 | #else 19 | # define ZLIB_INTERNAL 20 | #endif 21 | 22 | #include "zlib.h" 23 | 24 | #if defined(STDC) && !defined(Z_SOLO) 25 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 26 | # include 27 | # endif 28 | # include 29 | # include 30 | #endif 31 | 32 | #ifdef Z_SOLO 33 | typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ 34 | #endif 35 | 36 | #ifndef local 37 | # define local static 38 | #endif 39 | /* compile with -Dlocal if your debugger can't find static symbols */ 40 | 41 | typedef unsigned char uch; 42 | typedef uch FAR uchf; 43 | typedef unsigned short ush; 44 | typedef ush FAR ushf; 45 | typedef unsigned long ulg; 46 | 47 | extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 48 | /* (size given to avoid silly warnings with Visual C++) */ 49 | 50 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 51 | 52 | #define ERR_RETURN(strm,err) \ 53 | return (strm->msg = ERR_MSG(err), (err)) 54 | /* To be used only when the state is known to be valid */ 55 | 56 | /* common constants */ 57 | 58 | #ifndef DEF_WBITS 59 | # define DEF_WBITS MAX_WBITS 60 | #endif 61 | /* default windowBits for decompression. MAX_WBITS is for compression only */ 62 | 63 | #if MAX_MEM_LEVEL >= 8 64 | # define DEF_MEM_LEVEL 8 65 | #else 66 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 67 | #endif 68 | /* default memLevel */ 69 | 70 | #define STORED_BLOCK 0 71 | #define STATIC_TREES 1 72 | #define DYN_TREES 2 73 | /* The three kinds of block type */ 74 | 75 | #define MIN_MATCH 3 76 | #define MAX_MATCH 258 77 | /* The minimum and maximum match lengths */ 78 | 79 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 80 | 81 | /* target dependencies */ 82 | 83 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 84 | # define OS_CODE 0x00 85 | # ifndef Z_SOLO 86 | # if defined(__TURBOC__) || defined(__BORLANDC__) 87 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 88 | /* Allow compilation with ANSI keywords only enabled */ 89 | void _Cdecl farfree( void *block ); 90 | void *_Cdecl farmalloc( unsigned long nbytes ); 91 | # else 92 | # include 93 | # endif 94 | # else /* MSC or DJGPP */ 95 | # include 96 | # endif 97 | # endif 98 | #endif 99 | 100 | #ifdef AMIGA 101 | # define OS_CODE 0x01 102 | #endif 103 | 104 | #if defined(VAXC) || defined(VMS) 105 | # define OS_CODE 0x02 106 | # define F_OPEN(name, mode) \ 107 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 108 | #endif 109 | 110 | #if defined(ATARI) || defined(atarist) 111 | # define OS_CODE 0x05 112 | #endif 113 | 114 | #ifdef OS2 115 | # define OS_CODE 0x06 116 | # if defined(M_I86) && !defined(Z_SOLO) 117 | # include 118 | # endif 119 | #endif 120 | 121 | #if defined(MACOS) || defined(TARGET_OS_MAC) 122 | # define OS_CODE 0x07 123 | # ifndef Z_SOLO 124 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 125 | # include /* for fdopen */ 126 | # else 127 | # ifndef fdopen 128 | # define fdopen(fd,mode) NULL /* No fdopen() */ 129 | # endif 130 | # endif 131 | # endif 132 | #endif 133 | 134 | #ifdef TOPS20 135 | # define OS_CODE 0x0a 136 | #endif 137 | 138 | #ifdef WIN32 139 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 140 | # define OS_CODE 0x0b 141 | # endif 142 | #endif 143 | 144 | #ifdef __50SERIES /* Prime/PRIMOS */ 145 | # define OS_CODE 0x0f 146 | #endif 147 | 148 | #if defined(_BEOS_) || defined(RISCOS) 149 | # define fdopen(fd,mode) NULL /* No fdopen() */ 150 | #endif 151 | 152 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 153 | # if defined(_WIN32_WCE) 154 | # define fdopen(fd,mode) NULL /* No fdopen() */ 155 | # ifndef _PTRDIFF_T_DEFINED 156 | typedef int ptrdiff_t; 157 | # define _PTRDIFF_T_DEFINED 158 | # endif 159 | # else 160 | # define fdopen(fd,type) _fdopen(fd,type) 161 | # endif 162 | #endif 163 | 164 | #if defined(__BORLANDC__) && !defined(MSDOS) 165 | #pragma warn -8004 166 | #pragma warn -8008 167 | #pragma warn -8066 168 | #endif 169 | 170 | /* provide prototypes for these when building zlib without LFS */ 171 | #if !defined(_WIN32) && \ 172 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) 173 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 174 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 175 | #endif 176 | 177 | /* common defaults */ 178 | 179 | #ifndef OS_CODE 180 | # define OS_CODE 0x03 /* assume Unix */ 181 | #endif 182 | 183 | #ifndef F_OPEN 184 | # define F_OPEN(name, mode) fopen((name), (mode)) 185 | #endif 186 | 187 | /* functions */ 188 | 189 | #if defined(pyr) || defined(Z_SOLO) 190 | # define NO_MEMCPY 191 | #endif 192 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 193 | /* Use our own functions for small and medium model with MSC <= 5.0. 194 | * You may have to use the same strategy for Borland C (untested). 195 | * The __SC__ check is for Symantec. 196 | */ 197 | # define NO_MEMCPY 198 | #endif 199 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 200 | # define HAVE_MEMCPY 201 | #endif 202 | #ifdef HAVE_MEMCPY 203 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 204 | # define zmemcpy _fmemcpy 205 | # define zmemcmp _fmemcmp 206 | # define zmemzero(dest, len) _fmemset(dest, 0, len) 207 | # else 208 | # define zmemcpy memcpy 209 | # define zmemcmp memcmp 210 | # define zmemzero(dest, len) memset(dest, 0, len) 211 | # endif 212 | #else 213 | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 214 | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 215 | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 216 | #endif 217 | 218 | /* Diagnostic functions */ 219 | #ifdef DEBUG 220 | # include 221 | extern int ZLIB_INTERNAL z_verbose; 222 | extern void ZLIB_INTERNAL z_error OF((char *m)); 223 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 224 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} 225 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} 226 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 227 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 228 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 229 | #else 230 | # define Assert(cond,msg) 231 | # define Trace(x) 232 | # define Tracev(x) 233 | # define Tracevv(x) 234 | # define Tracec(c,x) 235 | # define Tracecv(c,x) 236 | #endif 237 | 238 | #ifndef Z_SOLO 239 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 240 | unsigned size)); 241 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 242 | #endif 243 | 244 | #define ZALLOC(strm, items, size) \ 245 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) 246 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 247 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 248 | 249 | /* Reverse the bytes in a 32-bit value */ 250 | #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ 251 | (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) 252 | 253 | #endif /* ZUTIL_H */ 254 | -------------------------------------------------------------------------------- /External/zlib/contrib/minizip/ioapi.h: -------------------------------------------------------------------------------- 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip 2 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 3 | 4 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 5 | 6 | Modifications for Zip64 support 7 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 8 | 9 | For more info read MiniZip_info.txt 10 | 11 | Changes 12 | 13 | Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) 14 | Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. 15 | More if/def section may be needed to support other platforms 16 | Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. 17 | (but you should use iowin32.c for windows instead) 18 | 19 | */ 20 | 21 | #ifndef _ZLIBIOAPI64_H 22 | #define _ZLIBIOAPI64_H 23 | 24 | #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) 25 | 26 | // Linux needs this to support file operation on files larger then 4+GB 27 | // But might need better if/def to select just the platforms that needs them. 28 | 29 | #ifndef __USE_FILE_OFFSET64 30 | #define __USE_FILE_OFFSET64 31 | #endif 32 | #ifndef __USE_LARGEFILE64 33 | #define __USE_LARGEFILE64 34 | #endif 35 | #ifndef _LARGEFILE64_SOURCE 36 | #define _LARGEFILE64_SOURCE 37 | #endif 38 | #ifndef _FILE_OFFSET_BIT 39 | #define _FILE_OFFSET_BIT 64 40 | #endif 41 | 42 | #endif 43 | 44 | #include 45 | #include 46 | #include "zlib.h" 47 | 48 | #if defined(USE_FILE32API) 49 | #define fopen64 fopen 50 | #define ftello64 ftell 51 | #define fseeko64 fseek 52 | #else 53 | #ifdef __FreeBSD__ 54 | #define fopen64 fopen 55 | #define ftello64 ftello 56 | #define fseeko64 fseeko 57 | #endif 58 | #ifdef _MSC_VER 59 | #define fopen64 fopen 60 | #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) 61 | #define ftello64 _ftelli64 62 | #define fseeko64 _fseeki64 63 | #else // old MSC 64 | #define ftello64 ftell 65 | #define fseeko64 fseek 66 | #endif 67 | #endif 68 | #endif 69 | 70 | /* 71 | #ifndef ZPOS64_T 72 | #ifdef _WIN32 73 | #define ZPOS64_T fpos_t 74 | #else 75 | #include 76 | #define ZPOS64_T uint64_t 77 | #endif 78 | #endif 79 | */ 80 | 81 | #ifdef HAVE_MINIZIP64_CONF_H 82 | #include "mz64conf.h" 83 | #endif 84 | 85 | /* a type choosen by DEFINE */ 86 | #ifdef HAVE_64BIT_INT_CUSTOM 87 | typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; 88 | #else 89 | #ifdef HAS_STDINT_H 90 | #include "stdint.h" 91 | typedef uint64_t ZPOS64_T; 92 | #else 93 | 94 | /* Maximum unsigned 32-bit value used as placeholder for zip64 */ 95 | #define MAXU32 0xffffffff 96 | 97 | #if defined(_MSC_VER) || defined(__BORLANDC__) 98 | typedef unsigned __int64 ZPOS64_T; 99 | #else 100 | typedef unsigned long long int ZPOS64_T; 101 | #endif 102 | #endif 103 | #endif 104 | 105 | 106 | 107 | #ifdef __cplusplus 108 | extern "C" { 109 | #endif 110 | 111 | 112 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 113 | #define ZLIB_FILEFUNC_SEEK_END (2) 114 | #define ZLIB_FILEFUNC_SEEK_SET (0) 115 | 116 | #define ZLIB_FILEFUNC_MODE_READ (1) 117 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 118 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 119 | 120 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 121 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 122 | 123 | 124 | #ifndef ZCALLBACK 125 | #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 126 | #define ZCALLBACK CALLBACK 127 | #else 128 | #define ZCALLBACK 129 | #endif 130 | #endif 131 | 132 | 133 | 134 | 135 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 136 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 137 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 138 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 139 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 140 | 141 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 142 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 143 | 144 | 145 | /* here is the "old" 32 bits structure structure */ 146 | typedef struct zlib_filefunc_def_s 147 | { 148 | open_file_func zopen_file; 149 | read_file_func zread_file; 150 | write_file_func zwrite_file; 151 | tell_file_func ztell_file; 152 | seek_file_func zseek_file; 153 | close_file_func zclose_file; 154 | testerror_file_func zerror_file; 155 | voidpf opaque; 156 | } zlib_filefunc_def; 157 | 158 | typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); 159 | typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); 160 | typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); 161 | 162 | typedef struct zlib_filefunc64_def_s 163 | { 164 | open64_file_func zopen64_file; 165 | read_file_func zread_file; 166 | write_file_func zwrite_file; 167 | tell64_file_func ztell64_file; 168 | seek64_file_func zseek64_file; 169 | close_file_func zclose_file; 170 | testerror_file_func zerror_file; 171 | voidpf opaque; 172 | } zlib_filefunc64_def; 173 | 174 | void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); 175 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 176 | 177 | /* now internal definition, only for zip.c and unzip.h */ 178 | typedef struct zlib_filefunc64_32_def_s 179 | { 180 | zlib_filefunc64_def zfile_func64; 181 | open_file_func zopen32_file; 182 | tell_file_func ztell32_file; 183 | seek_file_func zseek32_file; 184 | } zlib_filefunc64_32_def; 185 | 186 | 187 | #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 188 | #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 189 | //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) 190 | //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) 191 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) 192 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) 193 | 194 | voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); 195 | long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); 196 | ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); 197 | 198 | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); 199 | 200 | #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) 201 | #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) 202 | #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) 203 | 204 | #ifdef __cplusplus 205 | } 206 | #endif 207 | 208 | #endif 209 | -------------------------------------------------------------------------------- /External/zlib/contrib/masmx64/inffas8664.c: -------------------------------------------------------------------------------- 1 | /* inffas8664.c is a hand tuned assembler version of inffast.c - fast decoding 2 | * version for AMD64 on Windows using Microsoft C compiler 3 | * 4 | * Copyright (C) 1995-2003 Mark Adler 5 | * For conditions of distribution and use, see copyright notice in zlib.h 6 | * 7 | * Copyright (C) 2003 Chris Anderson 8 | * Please use the copyright conditions above. 9 | * 10 | * 2005 - Adaptation to Microsoft C Compiler for AMD64 by Gilles Vollant 11 | * 12 | * inffas8664.c call function inffas8664fnc in inffasx64.asm 13 | * inffasx64.asm is automatically convert from AMD64 portion of inffas86.c 14 | * 15 | * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also 16 | * slightly quicker on x86 systems because, instead of using rep movsb to copy 17 | * data, it uses rep movsw, which moves data in 2-byte chunks instead of single 18 | * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates 19 | * from http://fedora.linux.duke.edu/fc1_x86_64 20 | * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with 21 | * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version, 22 | * when decompressing mozilla-source-1.3.tar.gz. 23 | * 24 | * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from 25 | * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at 26 | * the moment. I have successfully compiled and tested this code with gcc2.96, 27 | * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S 28 | * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX 29 | * enabled. I will attempt to merge the MMX code into this version. Newer 30 | * versions of this and inffast.S can be found at 31 | * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ 32 | * 33 | */ 34 | 35 | #include 36 | #include "zutil.h" 37 | #include "inftrees.h" 38 | #include "inflate.h" 39 | #include "inffast.h" 40 | 41 | /* Mark Adler's comments from inffast.c: */ 42 | 43 | /* 44 | Decode literal, length, and distance codes and write out the resulting 45 | literal and match bytes until either not enough input or output is 46 | available, an end-of-block is encountered, or a data error is encountered. 47 | When large enough input and output buffers are supplied to inflate(), for 48 | example, a 16K input buffer and a 64K output buffer, more than 95% of the 49 | inflate execution time is spent in this routine. 50 | 51 | Entry assumptions: 52 | 53 | state->mode == LEN 54 | strm->avail_in >= 6 55 | strm->avail_out >= 258 56 | start >= strm->avail_out 57 | state->bits < 8 58 | 59 | On return, state->mode is one of: 60 | 61 | LEN -- ran out of enough output space or enough available input 62 | TYPE -- reached end of block code, inflate() to interpret next block 63 | BAD -- error in block data 64 | 65 | Notes: 66 | 67 | - The maximum input bits used by a length/distance pair is 15 bits for the 68 | length code, 5 bits for the length extra, 15 bits for the distance code, 69 | and 13 bits for the distance extra. This totals 48 bits, or six bytes. 70 | Therefore if strm->avail_in >= 6, then there is enough input to avoid 71 | checking for available input while decoding. 72 | 73 | - The maximum bytes that a single length/distance pair can output is 258 74 | bytes, which is the maximum length that can be coded. inflate_fast() 75 | requires strm->avail_out >= 258 for each loop to avoid checking for 76 | output space. 77 | */ 78 | 79 | 80 | 81 | typedef struct inffast_ar { 82 | /* 64 32 x86 x86_64 */ 83 | /* ar offset register */ 84 | /* 0 0 */ void *esp; /* esp save */ 85 | /* 8 4 */ void *ebp; /* ebp save */ 86 | /* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */ 87 | /* 24 12 */ unsigned char FAR *last; /* r9 while in < last */ 88 | /* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */ 89 | /* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */ 90 | /* 48 24 */ unsigned char FAR *end; /* r10 while out < end */ 91 | /* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */ 92 | /* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */ 93 | /* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */ 94 | /* 80 40 */ size_t /*unsigned long */hold; /* edx rdx local strm->hold */ 95 | /* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */ 96 | /* 92 48 */ unsigned wsize; /* window size */ 97 | /* 96 52 */ unsigned write; /* window write index */ 98 | /*100 56 */ unsigned lmask; /* r12 mask for lcode */ 99 | /*104 60 */ unsigned dmask; /* r13 mask for dcode */ 100 | /*108 64 */ unsigned len; /* r14 match length */ 101 | /*112 68 */ unsigned dist; /* r15 match distance */ 102 | /*116 72 */ unsigned status; /* set when state chng*/ 103 | } type_ar; 104 | #ifdef ASMINF 105 | 106 | void inflate_fast(strm, start) 107 | z_streamp strm; 108 | unsigned start; /* inflate()'s starting value for strm->avail_out */ 109 | { 110 | struct inflate_state FAR *state; 111 | type_ar ar; 112 | void inffas8664fnc(struct inffast_ar * par); 113 | 114 | 115 | 116 | #if (defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )) || (defined(_MSC_VER) && defined(_M_AMD64)) 117 | #define PAD_AVAIL_IN 6 118 | #define PAD_AVAIL_OUT 258 119 | #else 120 | #define PAD_AVAIL_IN 5 121 | #define PAD_AVAIL_OUT 257 122 | #endif 123 | 124 | /* copy state to local variables */ 125 | state = (struct inflate_state FAR *)strm->state; 126 | 127 | ar.in = strm->next_in; 128 | ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN); 129 | ar.out = strm->next_out; 130 | ar.beg = ar.out - (start - strm->avail_out); 131 | ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT); 132 | ar.wsize = state->wsize; 133 | ar.write = state->wnext; 134 | ar.window = state->window; 135 | ar.hold = state->hold; 136 | ar.bits = state->bits; 137 | ar.lcode = state->lencode; 138 | ar.dcode = state->distcode; 139 | ar.lmask = (1U << state->lenbits) - 1; 140 | ar.dmask = (1U << state->distbits) - 1; 141 | 142 | /* decode literals and length/distances until end-of-block or not enough 143 | input data or output space */ 144 | 145 | /* align in on 1/2 hold size boundary */ 146 | while (((size_t)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) { 147 | ar.hold += (unsigned long)*ar.in++ << ar.bits; 148 | ar.bits += 8; 149 | } 150 | 151 | inffas8664fnc(&ar); 152 | 153 | if (ar.status > 1) { 154 | if (ar.status == 2) 155 | strm->msg = "invalid literal/length code"; 156 | else if (ar.status == 3) 157 | strm->msg = "invalid distance code"; 158 | else 159 | strm->msg = "invalid distance too far back"; 160 | state->mode = BAD; 161 | } 162 | else if ( ar.status == 1 ) { 163 | state->mode = TYPE; 164 | } 165 | 166 | /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ 167 | ar.len = ar.bits >> 3; 168 | ar.in -= ar.len; 169 | ar.bits -= ar.len << 3; 170 | ar.hold &= (1U << ar.bits) - 1; 171 | 172 | /* update state and return */ 173 | strm->next_in = ar.in; 174 | strm->next_out = ar.out; 175 | strm->avail_in = (unsigned)(ar.in < ar.last ? 176 | PAD_AVAIL_IN + (ar.last - ar.in) : 177 | PAD_AVAIL_IN - (ar.in - ar.last)); 178 | strm->avail_out = (unsigned)(ar.out < ar.end ? 179 | PAD_AVAIL_OUT + (ar.end - ar.out) : 180 | PAD_AVAIL_OUT - (ar.out - ar.end)); 181 | state->hold = (unsigned long)ar.hold; 182 | state->bits = ar.bits; 183 | return; 184 | } 185 | 186 | #endif 187 | --------------------------------------------------------------------------------