diff --git a/CMakeLists.txt b/CMakeLists.txt index 562ba32..e47c1fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ endif() # VCPKG source directory set(PROJECT_VCPKG_DIRECTORY "C:/vcpkg") # Includes directory -set(PROJECT_INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/inc") +set(PROJECT_INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/includes") # CMAKE_TOOLCHAIN_FILE include("${PROJECT_VCPKG_DIRECTORY}/scripts/buildsystems/vcpkg.cmake") @@ -21,8 +21,7 @@ project ("xna") # Include sub-projects. include_directories(${PROJECT_INCLUDES_DIR}) -add_subdirectory ("framework") - +add_subdirectory ("sources") add_subdirectory ("samples") diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt deleted file mode 100644 index 0c82e8a..0000000 --- a/framework/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -# CMakeList.txt : CMake project for xna, include source and define -# project specific logic here. -# - -# Add source to this project's executable. -add_library (Xn65 STATIC -"csharp/stream.cpp" -"csharp/binary.cpp" -"csharp/type.cpp" -"game/component.cpp" -"game/servicecontainer.cpp" -"content/manager.cpp" -"content/reader.cpp" -"content/lzx/decoder.cpp" -"content/typereadermanager.cpp" -"common/color.cpp" -"common/collision.cpp" -"common/gjk.cpp" -"common/numerics.cpp" -"common/packedvalue.cpp" -"platform-dx/window.cpp" -"platform-dx/device.cpp" -"platform-dx/adapter.cpp" -"platform-dx/swapchain.cpp" -"platform-dx/rendertarget.cpp" -"platform-dx/texture.cpp" -"platform-dx/blendstate.cpp" -"platform-dx/game.cpp" -"platform-dx/gdevicemanager.cpp" -"platform-dx/rasterizerstate.cpp" -"platform-dx/samplerstate.cpp" -"platform-dx/sprite.cpp" -"platform-dx/depthstencilstate.cpp" -"platform-dx/keyboard.cpp" -"platform-dx/mouse.cpp" -"platform-dx/gamepad.cpp" -"platform-dx/soundeffect.cpp" -"platform-dx/displaymode.cpp" -"platform-dx/init.cpp" -"platform-dx/audioengine.cpp" -"graphics/gresource.cpp" -"platform-dx/effect.cpp" - "exception.cpp" "platform-dx/screen.cpp" ) - -if (CMAKE_VERSION VERSION_GREATER 3.12) - set_property(TARGET Xn65 PROPERTY CXX_STANDARD 20) -endif() - -# TODO: Add tests and install targets if needed. - -find_package(directxtk CONFIG REQUIRED) - -target_link_libraries( - Xn65 D3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib Microsoft::DirectXTK dxguid.lib - #"${PROJECT_INCLUDES_DIR}/libmspack/mspack.lib" - #"${PROJECT_INCLUDES_DIR}/effects11/Effects11.lib" -) diff --git a/inc/effects11/Effects11.lib b/inc/effects11/Effects11.lib deleted file mode 100644 index 030886a..0000000 Binary files a/inc/effects11/Effects11.lib and /dev/null differ diff --git a/inc/effects11/d3dx11effect.h b/inc/effects11/d3dx11effect.h deleted file mode 100644 index 6207b81..0000000 --- a/inc/effects11/d3dx11effect.h +++ /dev/null @@ -1,1212 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: D3DX11Effect.h -// -// Direct3D 11 Effect Types & APIs Header -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/p/?LinkId=271568 -//-------------------------------------------------------------------------------------- - -#pragma once - -#define D3DX11_EFFECTS_VERSION 1129 - -#if defined(_XBOX_ONE) && defined(_TITLE) -#include -#define NO_D3D11_DEBUG_NAME -#else -#include -#include -#endif - -#pragma comment( lib, "d3dcompiler.lib" ) -#pragma comment( lib, "dxguid.lib" ) - -#include - -////////////////////////////////////////////////////////////////////////////// -// File contents: -// -// 1) Stateblock enums, structs, interfaces, flat APIs -// 2) Effect enums, structs, interfaces, flat APIs -////////////////////////////////////////////////////////////////////////////// - -#ifndef D3DX11_BYTES_FROM_BITS -#define D3DX11_BYTES_FROM_BITS(x) (((x) + 7) / 8) -#endif // D3DX11_BYTES_FROM_BITS - -#ifndef D3DERR_INVALIDCALL -#define D3DERR_INVALIDCALL MAKE_HRESULT( 1, 0x876, 2156 ) -#endif - -struct D3DX11_STATE_BLOCK_MASK -{ - uint8_t VS; - uint8_t VSSamplers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - uint8_t VSShaderResources[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - uint8_t VSConstantBuffers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)]; - uint8_t VSInterfaces[D3DX11_BYTES_FROM_BITS(D3D11_SHADER_MAX_INTERFACES)]; - - uint8_t HS; - uint8_t HSSamplers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - uint8_t HSShaderResources[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - uint8_t HSConstantBuffers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)]; - uint8_t HSInterfaces[D3DX11_BYTES_FROM_BITS(D3D11_SHADER_MAX_INTERFACES)]; - - uint8_t DS; - uint8_t DSSamplers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - uint8_t DSShaderResources[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - uint8_t DSConstantBuffers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)]; - uint8_t DSInterfaces[D3DX11_BYTES_FROM_BITS(D3D11_SHADER_MAX_INTERFACES)]; - - uint8_t GS; - uint8_t GSSamplers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - uint8_t GSShaderResources[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - uint8_t GSConstantBuffers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)]; - uint8_t GSInterfaces[D3DX11_BYTES_FROM_BITS(D3D11_SHADER_MAX_INTERFACES)]; - - uint8_t PS; - uint8_t PSSamplers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - uint8_t PSShaderResources[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - uint8_t PSConstantBuffers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)]; - uint8_t PSInterfaces[D3DX11_BYTES_FROM_BITS(D3D11_SHADER_MAX_INTERFACES)]; - uint8_t PSUnorderedAccessViews; - - uint8_t CS; - uint8_t CSSamplers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT)]; - uint8_t CSShaderResources[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)]; - uint8_t CSConstantBuffers[D3DX11_BYTES_FROM_BITS(D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)]; - uint8_t CSInterfaces[D3DX11_BYTES_FROM_BITS(D3D11_SHADER_MAX_INTERFACES)]; - uint8_t CSUnorderedAccessViews; - - uint8_t IAVertexBuffers[D3DX11_BYTES_FROM_BITS(D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT)]; - uint8_t IAIndexBuffer; - uint8_t IAInputLayout; - uint8_t IAPrimitiveTopology; - - uint8_t OMRenderTargets; - uint8_t OMDepthStencilState; - uint8_t OMBlendState; - - uint8_t RSViewports; - uint8_t RSScissorRects; - uint8_t RSRasterizerState; - - uint8_t SOBuffers; - - uint8_t Predication; -}; - -//---------------------------------------------------------------------------- -// D3DX11_EFFECT flags: -// ------------------------------------- -// -// These flags are passed in when creating an effect, and affect -// the runtime effect behavior: -// -// (Currently none) -// -// -// These flags are set by the effect runtime: -// -// D3DX11_EFFECT_OPTIMIZED -// This effect has been optimized. Reflection functions that rely on -// names/semantics/strings should fail. This is set when Optimize() is -// called, but CEffect::IsOptimized() should be used to test for this. -// -// D3DX11_EFFECT_CLONE -// This effect is a clone of another effect. Single CBs will never be -// updated when internal variable values are changed. -// This flag is not set when the D3DX11_EFFECT_CLONE_FORCE_NONSINGLE flag -// is used in cloning. -// -//---------------------------------------------------------------------------- - -#define D3DX11_EFFECT_OPTIMIZED (1 << 21) -#define D3DX11_EFFECT_CLONE (1 << 22) - -// Mask of valid D3DCOMPILE_EFFECT flags for D3DX11CreateEffect* -#define D3DX11_EFFECT_RUNTIME_VALID_FLAGS (0) - -//---------------------------------------------------------------------------- -// D3DX11_EFFECT_VARIABLE flags: -// ---------------------------- -// -// These flags describe an effect variable (global or annotation), -// and are returned in D3DX11_EFFECT_VARIABLE_DESC::Flags. -// -// D3DX11_EFFECT_VARIABLE_ANNOTATION -// Indicates that this is an annotation on a technique, pass, or global -// variable. Otherwise, this is a global variable. Annotations cannot -// be shared. -// -// D3DX11_EFFECT_VARIABLE_EXPLICIT_BIND_POINT -// Indicates that the variable has been explicitly bound using the -// register keyword. -//---------------------------------------------------------------------------- - -#define D3DX11_EFFECT_VARIABLE_ANNOTATION (1 << 1) -#define D3DX11_EFFECT_VARIABLE_EXPLICIT_BIND_POINT (1 << 2) - -//---------------------------------------------------------------------------- -// D3DX11_EFFECT_CLONE flags: -// ---------------------------- -// -// These flags modify the effect cloning process and are passed into Clone. -// -// D3DX11_EFFECT_CLONE_FORCE_NONSINGLE -// Ignore all "single" qualifiers on cbuffers. All cbuffers will have their -// own ID3D11Buffer's created in the cloned effect. -//---------------------------------------------------------------------------- - -#define D3DX11_EFFECT_CLONE_FORCE_NONSINGLE (1 << 0) - - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectType ////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX11_EFFECT_TYPE_DESC: -// -// Retrieved by ID3DX11EffectType::GetDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_EFFECT_TYPE_DESC -{ - LPCSTR TypeName; // Name of the type - // (e.g. "float4" or "MyStruct") - - D3D_SHADER_VARIABLE_CLASS Class; // (e.g. scalar, vector, object, etc.) - D3D_SHADER_VARIABLE_TYPE Type; // (e.g. float, texture, vertexshader, etc.) - - uint32_t Elements; // Number of elements in this type - // (0 if not an array) - uint32_t Members; // Number of members - // (0 if not a structure) - uint32_t Rows; // Number of rows in this type - // (0 if not a numeric primitive) - uint32_t Columns; // Number of columns in this type - // (0 if not a numeric primitive) - - uint32_t PackedSize; // Number of bytes required to represent - // this data type, when tightly packed - uint32_t UnpackedSize; // Number of bytes occupied by this data - // type, when laid out in a constant buffer - uint32_t Stride; // Number of bytes to seek between elements, - // when laid out in a constant buffer -}; - -typedef interface ID3DX11EffectType ID3DX11EffectType; -typedef interface ID3DX11EffectType *LPD3D11EFFECTTYPE; - -// {4250D721-D5E5-491F-B62B-587C43186285} -DEFINE_GUID(IID_ID3DX11EffectType, - 0x4250d721, 0xd5e5, 0x491f, 0xb6, 0x2b, 0x58, 0x7c, 0x43, 0x18, 0x62, 0x85); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectType - -DECLARE_INTERFACE_(ID3DX11EffectType, IUnknown) -{ - // IUnknown - - // ID3DX11EffectType - STDMETHOD_(bool, IsValid)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ _Out_ D3DX11_EFFECT_TYPE_DESC *pDesc) PURE; - STDMETHOD_(ID3DX11EffectType*, GetMemberTypeByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectType*, GetMemberTypeByName)(THIS_ _In_z_ LPCSTR Name) PURE; - STDMETHOD_(ID3DX11EffectType*, GetMemberTypeBySemantic)(THIS_ _In_z_ LPCSTR Semantic) PURE; - STDMETHOD_(LPCSTR, GetMemberName)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(LPCSTR, GetMemberSemantic)(THIS_ _In_ uint32_t Index) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectVariable ////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX11_EFFECT_VARIABLE_DESC: -// -// Retrieved by ID3DX11EffectVariable::GetDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_EFFECT_VARIABLE_DESC -{ - LPCSTR Name; // Name of this variable, annotation, - // or structure member - LPCSTR Semantic; // Semantic string of this variable - // or structure member (nullptr for - // annotations or if not present) - - uint32_t Flags; // D3DX11_EFFECT_VARIABLE_* flags - uint32_t Annotations; // Number of annotations on this variable - // (always 0 for annotations) - - uint32_t BufferOffset; // Offset into containing cbuffer or tbuffer - // (always 0 for annotations or variables - // not in constant buffers) - - uint32_t ExplicitBindPoint; // Used if the variable has been explicitly bound - // using the register keyword. Check Flags for - // D3DX11_EFFECT_VARIABLE_EXPLICIT_BIND_POINT; -}; - -typedef interface ID3DX11EffectVariable ID3DX11EffectVariable; -typedef interface ID3DX11EffectVariable *LPD3D11EFFECTVARIABLE; - -// {036A777D-B56E-4B25-B313-CC3DDAB71873} -DEFINE_GUID(IID_ID3DX11EffectVariable, - 0x036a777d, 0xb56e, 0x4b25, 0xb3, 0x13, 0xcc, 0x3d, 0xda, 0xb7, 0x18, 0x73); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectVariable - -// Forward defines -typedef interface ID3DX11EffectScalarVariable ID3DX11EffectScalarVariable; -typedef interface ID3DX11EffectVectorVariable ID3DX11EffectVectorVariable; -typedef interface ID3DX11EffectMatrixVariable ID3DX11EffectMatrixVariable; -typedef interface ID3DX11EffectStringVariable ID3DX11EffectStringVariable; -typedef interface ID3DX11EffectClassInstanceVariable ID3DX11EffectClassInstanceVariable; -typedef interface ID3DX11EffectInterfaceVariable ID3DX11EffectInterfaceVariable; -typedef interface ID3DX11EffectShaderResourceVariable ID3DX11EffectShaderResourceVariable; -typedef interface ID3DX11EffectUnorderedAccessViewVariable ID3DX11EffectUnorderedAccessViewVariable; -typedef interface ID3DX11EffectRenderTargetViewVariable ID3DX11EffectRenderTargetViewVariable; -typedef interface ID3DX11EffectDepthStencilViewVariable ID3DX11EffectDepthStencilViewVariable; -typedef interface ID3DX11EffectConstantBuffer ID3DX11EffectConstantBuffer; -typedef interface ID3DX11EffectShaderVariable ID3DX11EffectShaderVariable; -typedef interface ID3DX11EffectBlendVariable ID3DX11EffectBlendVariable; -typedef interface ID3DX11EffectDepthStencilVariable ID3DX11EffectDepthStencilVariable; -typedef interface ID3DX11EffectRasterizerVariable ID3DX11EffectRasterizerVariable; -typedef interface ID3DX11EffectSamplerVariable ID3DX11EffectSamplerVariable; - -DECLARE_INTERFACE_(ID3DX11EffectVariable, IUnknown) -{ - // IUnknown - - // ID3DX11EffectVariable - STDMETHOD_(bool, IsValid)(THIS) PURE; - STDMETHOD_(ID3DX11EffectType*, GetType)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ _Out_ D3DX11_EFFECT_VARIABLE_DESC *pDesc) PURE; - - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD_(ID3DX11EffectVariable*, GetMemberByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetMemberByName)(THIS_ _In_z_ LPCSTR Name) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetMemberBySemantic)(THIS_ _In_z_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3DX11EffectVariable*, GetElement)(THIS_ _In_ uint32_t Index) PURE; - - STDMETHOD_(ID3DX11EffectConstantBuffer*, GetParentConstantBuffer)(THIS) PURE; - - STDMETHOD_(ID3DX11EffectScalarVariable*, AsScalar)(THIS) PURE; - STDMETHOD_(ID3DX11EffectVectorVariable*, AsVector)(THIS) PURE; - STDMETHOD_(ID3DX11EffectMatrixVariable*, AsMatrix)(THIS) PURE; - STDMETHOD_(ID3DX11EffectStringVariable*, AsString)(THIS) PURE; - STDMETHOD_(ID3DX11EffectClassInstanceVariable*, AsClassInstance)(THIS) PURE; - STDMETHOD_(ID3DX11EffectInterfaceVariable*, AsInterface)(THIS) PURE; - STDMETHOD_(ID3DX11EffectShaderResourceVariable*, AsShaderResource)(THIS) PURE; - STDMETHOD_(ID3DX11EffectUnorderedAccessViewVariable*, AsUnorderedAccessView)(THIS) PURE; - STDMETHOD_(ID3DX11EffectRenderTargetViewVariable*, AsRenderTargetView)(THIS) PURE; - STDMETHOD_(ID3DX11EffectDepthStencilViewVariable*, AsDepthStencilView)(THIS) PURE; - STDMETHOD_(ID3DX11EffectConstantBuffer*, AsConstantBuffer)(THIS) PURE; - STDMETHOD_(ID3DX11EffectShaderVariable*, AsShader)(THIS) PURE; - STDMETHOD_(ID3DX11EffectBlendVariable*, AsBlend)(THIS) PURE; - STDMETHOD_(ID3DX11EffectDepthStencilVariable*, AsDepthStencil)(THIS) PURE; - STDMETHOD_(ID3DX11EffectRasterizerVariable*, AsRasterizer)(THIS) PURE; - STDMETHOD_(ID3DX11EffectSamplerVariable*, AsSampler)(THIS) PURE; - - STDMETHOD(SetRawValue)(THIS_ _In_reads_bytes_(ByteCount) const void *pData, _In_ uint32_t ByteOffset, _In_ uint32_t ByteCount) PURE; - STDMETHOD(GetRawValue)(THIS_ _Out_writes_bytes_(ByteCount) void *pData, _In_ uint32_t ByteOffset, _In_ uint32_t ByteCount) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectScalarVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectScalarVariable ID3DX11EffectScalarVariable; -typedef interface ID3DX11EffectScalarVariable *LPD3D11EFFECTSCALARVARIABLE; - -// {921EF2E5-A65D-4E92-9FC6-4E9CC09A4ADE} -DEFINE_GUID(IID_ID3DX11EffectScalarVariable, - 0x921ef2e5, 0xa65d, 0x4e92, 0x9f, 0xc6, 0x4e, 0x9c, 0xc0, 0x9a, 0x4a, 0xde); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectScalarVariable - -DECLARE_INTERFACE_(ID3DX11EffectScalarVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectScalarVariable - STDMETHOD(SetFloat)(THIS_ _In_ const float Value) PURE; - STDMETHOD(GetFloat)(THIS_ _Out_ float *pValue) PURE; - - STDMETHOD(SetFloatArray)(THIS_ _In_reads_(Count) const float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetFloatArray)(THIS_ _Out_writes_(Count) float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - - STDMETHOD(SetInt)(THIS_ _In_ const int Value) PURE; - STDMETHOD(GetInt)(THIS_ _Out_ int *pValue) PURE; - - STDMETHOD(SetIntArray)(THIS_ _In_reads_(Count) const int *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetIntArray)(THIS_ _Out_writes_(Count) int *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - - STDMETHOD(SetBool)(THIS_ _In_ const bool Value) PURE; - STDMETHOD(GetBool)(THIS_ _Out_ bool *pValue) PURE; - - STDMETHOD(SetBoolArray)(THIS_ _In_reads_(Count) const bool *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetBoolArray)(THIS_ _Out_writes_(Count) bool *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectVectorVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectVectorVariable ID3DX11EffectVectorVariable; -typedef interface ID3DX11EffectVectorVariable *LPD3D11EFFECTVECTORVARIABLE; - -// {5E785D4A-D87B-48D8-B6E6-0F8CA7E7467A} -DEFINE_GUID(IID_ID3DX11EffectVectorVariable, - 0x5e785d4a, 0xd87b, 0x48d8, 0xb6, 0xe6, 0x0f, 0x8c, 0xa7, 0xe7, 0x46, 0x7a); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectVectorVariable - -DECLARE_INTERFACE_(ID3DX11EffectVectorVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectVectorVariable - STDMETHOD(SetBoolVector) (THIS_ _In_reads_(4) const bool *pData) PURE; - STDMETHOD(SetIntVector) (THIS_ _In_reads_(4) const int *pData) PURE; - STDMETHOD(SetFloatVector)(THIS_ _In_reads_(4) const float *pData) PURE; - - STDMETHOD(GetBoolVector) (THIS_ _Out_writes_(4) bool *pData) PURE; - STDMETHOD(GetIntVector) (THIS_ _Out_writes_(4) int *pData) PURE; - STDMETHOD(GetFloatVector)(THIS_ _Out_writes_(4) float *pData) PURE; - - STDMETHOD(SetBoolVectorArray) (THIS_ _In_reads_(Count*4) const bool *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(SetIntVectorArray) (THIS_ _In_reads_(Count*4) const int *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(SetFloatVectorArray)(THIS_ _In_reads_(Count*4) const float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - - STDMETHOD(GetBoolVectorArray) (THIS_ _Out_writes_(Count*4) bool *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetIntVectorArray) (THIS_ _Out_writes_(Count*4) int *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetFloatVectorArray)(THIS_ _Out_writes_(Count*4) float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectMatrixVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectMatrixVariable ID3DX11EffectMatrixVariable; -typedef interface ID3DX11EffectMatrixVariable *LPD3D11EFFECTMATRIXVARIABLE; - -// {E1096CF4-C027-419A-8D86-D29173DC803E} -DEFINE_GUID(IID_ID3DX11EffectMatrixVariable, - 0xe1096cf4, 0xc027, 0x419a, 0x8d, 0x86, 0xd2, 0x91, 0x73, 0xdc, 0x80, 0x3e); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectMatrixVariable - -DECLARE_INTERFACE_(ID3DX11EffectMatrixVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectMatrixVariable - STDMETHOD(SetMatrix)(THIS_ _In_reads_(16) const float *pData) PURE; - STDMETHOD(GetMatrix)(THIS_ _Out_writes_(16) float *pData) PURE; - - STDMETHOD(SetMatrixArray)(THIS_ _In_reads_(Count*16) const float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetMatrixArray)(THIS_ _Out_writes_(Count*16) float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - - STDMETHOD(SetMatrixPointerArray)(_In_reads_(Count*16) const float **ppData, uint32_t Offset, uint32_t Count) PURE; - STDMETHOD(GetMatrixPointerArray)(_Out_writes_(Count*16) float **ppData, uint32_t Offset, uint32_t Count) PURE; - - STDMETHOD(SetMatrixTranspose)(THIS_ _In_reads_(16) const float *pData) PURE; - STDMETHOD(GetMatrixTranspose)(THIS_ _Out_writes_(16) float *pData) PURE; - - STDMETHOD(SetMatrixTransposeArray)(THIS_ _In_reads_(Count*16) const float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetMatrixTransposeArray)(THIS_ _Out_writes_(Count*16) float *pData, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - - STDMETHOD(SetMatrixTransposePointerArray)(_In_reads_(Count*16) const float **ppData, uint32_t Offset, uint32_t Count) PURE; - STDMETHOD(GetMatrixTransposePointerArray)(_Out_writes_(Count*16) float **ppData, uint32_t Offset, uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectStringVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectStringVariable ID3DX11EffectStringVariable; -typedef interface ID3DX11EffectStringVariable *LPD3D11EFFECTSTRINGVARIABLE; - -// {F355C818-01BE-4653-A7CC-60FFFEDDC76D} -DEFINE_GUID(IID_ID3DX11EffectStringVariable, - 0xf355c818, 0x01be, 0x4653, 0xa7, 0xcc, 0x60, 0xff, 0xfe, 0xdd, 0xc7, 0x6d); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectStringVariable - -DECLARE_INTERFACE_(ID3DX11EffectStringVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectStringVariable - STDMETHOD(GetString)(THIS_ _Outptr_result_z_ LPCSTR *ppString) PURE; - STDMETHOD(GetStringArray)(THIS_ _Out_writes_(Count) LPCSTR *ppStrings, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectClassInstanceVariable //////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectClassInstanceVariable ID3DX11EffectClassInstanceVariable; -typedef interface ID3DX11EffectClassInstanceVariable *LPD3D11EFFECTCLASSINSTANCEVARIABLE; - -// {926A8053-2A39-4DB4-9BDE-CF649ADEBDC1} -DEFINE_GUID(IID_ID3DX11EffectClassInstanceVariable, - 0x926a8053, 0x2a39, 0x4db4, 0x9b, 0xde, 0xcf, 0x64, 0x9a, 0xde, 0xbd, 0xc1); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectClassInstanceVariable - -DECLARE_INTERFACE_(ID3DX11EffectClassInstanceVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectClassInstanceVariable - STDMETHOD(GetClassInstance)(_Outptr_ ID3D11ClassInstance** ppClassInstance) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectInterfaceVariable //////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectInterfaceVariable ID3DX11EffectInterfaceVariable; -typedef interface ID3DX11EffectInterfaceVariable *LPD3D11EFFECTINTERFACEVARIABLE; - -// {516C8CD8-1C80-40A4-B19B-0688792F11A5} -DEFINE_GUID(IID_ID3DX11EffectInterfaceVariable, - 0x516c8cd8, 0x1c80, 0x40a4, 0xb1, 0x9b, 0x06, 0x88, 0x79, 0x2f, 0x11, 0xa5); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectInterfaceVariable - -DECLARE_INTERFACE_(ID3DX11EffectInterfaceVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectInterfaceVariable - STDMETHOD(SetClassInstance)(_In_ ID3DX11EffectClassInstanceVariable *pEffectClassInstance) PURE; - STDMETHOD(GetClassInstance)(_Outptr_ ID3DX11EffectClassInstanceVariable **ppEffectClassInstance) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectShaderResourceVariable //////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectShaderResourceVariable ID3DX11EffectShaderResourceVariable; -typedef interface ID3DX11EffectShaderResourceVariable *LPD3D11EFFECTSHADERRESOURCEVARIABLE; - -// {350DB233-BBE0-485C-9BFE-C0026B844F89} -DEFINE_GUID(IID_ID3DX11EffectShaderResourceVariable, - 0x350db233, 0xbbe0, 0x485c, 0x9b, 0xfe, 0xc0, 0x02, 0x6b, 0x84, 0x4f, 0x89); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectShaderResourceVariable - -DECLARE_INTERFACE_(ID3DX11EffectShaderResourceVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectShaderResourceVariable - STDMETHOD(SetResource)(THIS_ _In_ ID3D11ShaderResourceView *pResource) PURE; - STDMETHOD(GetResource)(THIS_ _Outptr_ ID3D11ShaderResourceView **ppResource) PURE; - - STDMETHOD(SetResourceArray)(THIS_ _In_reads_(Count) ID3D11ShaderResourceView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetResourceArray)(THIS_ _Out_writes_(Count) ID3D11ShaderResourceView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectUnorderedAccessViewVariable //////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectUnorderedAccessViewVariable ID3DX11EffectUnorderedAccessViewVariable; -typedef interface ID3DX11EffectUnorderedAccessViewVariable *LPD3D11EFFECTUNORDEREDACCESSVIEWVARIABLE; - -// {79B4AC8C-870A-47D2-B05A-8BD5CC3EE6C9} -DEFINE_GUID(IID_ID3DX11EffectUnorderedAccessViewVariable, - 0x79b4ac8c, 0x870a, 0x47d2, 0xb0, 0x5a, 0x8b, 0xd5, 0xcc, 0x3e, 0xe6, 0xc9); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectUnorderedAccessViewVariable - -DECLARE_INTERFACE_(ID3DX11EffectUnorderedAccessViewVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectUnorderedAccessViewVariable - STDMETHOD(SetUnorderedAccessView)(THIS_ _In_ ID3D11UnorderedAccessView *pResource) PURE; - STDMETHOD(GetUnorderedAccessView)(THIS_ _Outptr_ ID3D11UnorderedAccessView **ppResource) PURE; - - STDMETHOD(SetUnorderedAccessViewArray)(THIS_ _In_reads_(Count) ID3D11UnorderedAccessView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetUnorderedAccessViewArray)(THIS_ _Out_writes_(Count) ID3D11UnorderedAccessView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectRenderTargetViewVariable ////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectRenderTargetViewVariable ID3DX11EffectRenderTargetViewVariable; -typedef interface ID3DX11EffectRenderTargetViewVariable *LPD3D11EFFECTRENDERTARGETVIEWVARIABLE; - -// {D5066909-F40C-43F8-9DB5-057C2A208552} -DEFINE_GUID(IID_ID3DX11EffectRenderTargetViewVariable, - 0xd5066909, 0xf40c, 0x43f8, 0x9d, 0xb5, 0x05, 0x7c, 0x2a, 0x20, 0x85, 0x52); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectRenderTargetViewVariable - -DECLARE_INTERFACE_(ID3DX11EffectRenderTargetViewVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectRenderTargetViewVariable - STDMETHOD(SetRenderTarget)(THIS_ _In_ ID3D11RenderTargetView *pResource) PURE; - STDMETHOD(GetRenderTarget)(THIS_ _Outptr_ ID3D11RenderTargetView **ppResource) PURE; - - STDMETHOD(SetRenderTargetArray)(THIS_ _In_reads_(Count) ID3D11RenderTargetView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetRenderTargetArray)(THIS_ _Out_writes_(Count) ID3D11RenderTargetView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectDepthStencilViewVariable ////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectDepthStencilViewVariable ID3DX11EffectDepthStencilViewVariable; -typedef interface ID3DX11EffectDepthStencilViewVariable *LPD3D11EFFECTDEPTHSTENCILVIEWVARIABLE; - -// {33C648AC-2E9E-4A2E-9CD6-DE31ACC5B347} -DEFINE_GUID(IID_ID3DX11EffectDepthStencilViewVariable, - 0x33c648ac, 0x2e9e, 0x4a2e, 0x9c, 0xd6, 0xde, 0x31, 0xac, 0xc5, 0xb3, 0x47); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectDepthStencilViewVariable - -DECLARE_INTERFACE_(ID3DX11EffectDepthStencilViewVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectDepthStencilViewVariable - STDMETHOD(SetDepthStencil)(THIS_ _In_ ID3D11DepthStencilView *pResource) PURE; - STDMETHOD(GetDepthStencil)(THIS_ _Outptr_ ID3D11DepthStencilView **ppResource) PURE; - - STDMETHOD(SetDepthStencilArray)(THIS_ _In_reads_(Count) ID3D11DepthStencilView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; - STDMETHOD(GetDepthStencilArray)(THIS_ _Out_writes_(Count) ID3D11DepthStencilView **ppResources, _In_ uint32_t Offset, _In_ uint32_t Count) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectConstantBuffer //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectConstantBuffer ID3DX11EffectConstantBuffer; -typedef interface ID3DX11EffectConstantBuffer *LPD3D11EFFECTCONSTANTBUFFER; - -// {2CB6C733-82D2-4000-B3DA-6219D9A99BF2} -DEFINE_GUID(IID_ID3DX11EffectConstantBuffer, - 0x2cb6c733, 0x82d2, 0x4000, 0xb3, 0xda, 0x62, 0x19, 0xd9, 0xa9, 0x9b, 0xf2); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectConstantBuffer - -DECLARE_INTERFACE_(ID3DX11EffectConstantBuffer, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectConstantBuffer - STDMETHOD(SetConstantBuffer)(THIS_ _In_ ID3D11Buffer *pConstantBuffer) PURE; - STDMETHOD(UndoSetConstantBuffer)(THIS) PURE; - STDMETHOD(GetConstantBuffer)(THIS_ _Outptr_ ID3D11Buffer **ppConstantBuffer) PURE; - - STDMETHOD(SetTextureBuffer)(THIS_ _In_ ID3D11ShaderResourceView *pTextureBuffer) PURE; - STDMETHOD(UndoSetTextureBuffer)(THIS) PURE; - STDMETHOD(GetTextureBuffer)(THIS_ _Outptr_ ID3D11ShaderResourceView **ppTextureBuffer) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectShaderVariable //////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX11_EFFECT_SHADER_DESC: -// -// Retrieved by ID3DX11EffectShaderVariable::GetShaderDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_EFFECT_SHADER_DESC -{ - const uint8_t *pInputSignature; // Passed into CreateInputLayout, - // valid on VS and GS only - - bool IsInline; // Is this an anonymous shader variable - // resulting from an inline shader assignment? - - - // -- The following fields are not valid after Optimize() -- - const uint8_t *pBytecode; // Shader bytecode - uint32_t BytecodeLength; - - LPCSTR SODecls[D3D11_SO_STREAM_COUNT]; // Stream out declaration string (for GS with SO) - uint32_t RasterizedStream; - - uint32_t NumInputSignatureEntries; // Number of entries in the input signature - uint32_t NumOutputSignatureEntries; // Number of entries in the output signature - uint32_t NumPatchConstantSignatureEntries; // Number of entries in the patch constant signature -}; - - -typedef interface ID3DX11EffectShaderVariable ID3DX11EffectShaderVariable; -typedef interface ID3DX11EffectShaderVariable *LPD3D11EFFECTSHADERVARIABLE; - -// {7508B344-020A-4EC7-9118-62CDD36C88D7} -DEFINE_GUID(IID_ID3DX11EffectShaderVariable, - 0x7508b344, 0x020a, 0x4ec7, 0x91, 0x18, 0x62, 0xcd, 0xd3, 0x6c, 0x88, 0xd7); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectShaderVariable - -DECLARE_INTERFACE_(ID3DX11EffectShaderVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectShaderVariable - STDMETHOD(GetShaderDesc)(THIS_ _In_ uint32_t ShaderIndex, _Out_ D3DX11_EFFECT_SHADER_DESC *pDesc) PURE; - - STDMETHOD(GetVertexShader)(THIS_ _In_ uint32_t ShaderIndex, _Outptr_ ID3D11VertexShader **ppVS) PURE; - STDMETHOD(GetGeometryShader)(THIS_ _In_ uint32_t ShaderIndex, _Outptr_ ID3D11GeometryShader **ppGS) PURE; - STDMETHOD(GetPixelShader)(THIS_ _In_ uint32_t ShaderIndex, _Outptr_ ID3D11PixelShader **ppPS) PURE; - STDMETHOD(GetHullShader)(THIS_ _In_ uint32_t ShaderIndex, _Outptr_ ID3D11HullShader **ppHS) PURE; - STDMETHOD(GetDomainShader)(THIS_ _In_ uint32_t ShaderIndex, _Outptr_ ID3D11DomainShader **ppDS) PURE; - STDMETHOD(GetComputeShader)(THIS_ _In_ uint32_t ShaderIndex, _Outptr_ ID3D11ComputeShader **ppCS) PURE; - - STDMETHOD(GetInputSignatureElementDesc)(THIS_ _In_ uint32_t ShaderIndex, _In_ uint32_t Element, _Out_ D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - STDMETHOD(GetOutputSignatureElementDesc)(THIS_ _In_ uint32_t ShaderIndex, _In_ uint32_t Element, _Out_ D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE; - STDMETHOD(GetPatchConstantSignatureElementDesc)(THIS_ _In_ uint32_t ShaderIndex, _In_ uint32_t Element, _Out_ D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectBlendVariable ///////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectBlendVariable ID3DX11EffectBlendVariable; -typedef interface ID3DX11EffectBlendVariable *LPD3D11EFFECTBLENDVARIABLE; - -// {D664F4D7-3B81-4805-B277-C1DF58C39F53} -DEFINE_GUID(IID_ID3DX11EffectBlendVariable, - 0xd664f4d7, 0x3b81, 0x4805, 0xb2, 0x77, 0xc1, 0xdf, 0x58, 0xc3, 0x9f, 0x53); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectBlendVariable - -DECLARE_INTERFACE_(ID3DX11EffectBlendVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectBlendVariable - STDMETHOD(GetBlendState)(THIS_ _In_ uint32_t Index, _Outptr_ ID3D11BlendState **ppState) PURE; - STDMETHOD(SetBlendState)(THIS_ _In_ uint32_t Index, _In_ ID3D11BlendState *pState) PURE; - STDMETHOD(UndoSetBlendState)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD(GetBackingStore)(THIS_ _In_ uint32_t Index, _Out_ D3D11_BLEND_DESC *pDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectDepthStencilVariable ////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectDepthStencilVariable ID3DX11EffectDepthStencilVariable; -typedef interface ID3DX11EffectDepthStencilVariable *LPD3D11EFFECTDEPTHSTENCILVARIABLE; - -// {69B5751B-61A5-48E5-BD41-D93988111563} -DEFINE_GUID(IID_ID3DX11EffectDepthStencilVariable, - 0x69b5751b, 0x61a5, 0x48e5, 0xbd, 0x41, 0xd9, 0x39, 0x88, 0x11, 0x15, 0x63); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectDepthStencilVariable - -DECLARE_INTERFACE_(ID3DX11EffectDepthStencilVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectDepthStencilVariable - STDMETHOD(GetDepthStencilState)(THIS_ _In_ uint32_t Index, _Outptr_ ID3D11DepthStencilState **ppState) PURE; - STDMETHOD(SetDepthStencilState)(THIS_ _In_ uint32_t Index, _In_ ID3D11DepthStencilState *pState) PURE; - STDMETHOD(UndoSetDepthStencilState)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD(GetBackingStore)(THIS_ _In_ uint32_t Index, _Out_ D3D11_DEPTH_STENCIL_DESC *pDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectRasterizerVariable //////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectRasterizerVariable ID3DX11EffectRasterizerVariable; -typedef interface ID3DX11EffectRasterizerVariable *LPD3D11EFFECTRASTERIZERVARIABLE; - -// {53A262F6-5F74-4151-A132-E3DD19A62C9D} -DEFINE_GUID(IID_ID3DX11EffectRasterizerVariable, - 0x53a262f6, 0x5f74, 0x4151, 0xa1, 0x32, 0xe3, 0xdd, 0x19, 0xa6, 0x2c, 0x9d); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectRasterizerVariable - -DECLARE_INTERFACE_(ID3DX11EffectRasterizerVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectRasterizerVariable - STDMETHOD(GetRasterizerState)(THIS_ _In_ uint32_t Index, _Outptr_ ID3D11RasterizerState **ppState) PURE; - STDMETHOD(SetRasterizerState)(THIS_ _In_ uint32_t Index, _In_ ID3D11RasterizerState *pState) PURE; - STDMETHOD(UndoSetRasterizerState)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD(GetBackingStore)(THIS_ _In_ uint32_t Index, _Out_ D3D11_RASTERIZER_DESC *pDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectSamplerVariable /////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DX11EffectSamplerVariable ID3DX11EffectSamplerVariable; -typedef interface ID3DX11EffectSamplerVariable *LPD3D11EFFECTSAMPLERVARIABLE; - -// {C6402E55-1095-4D95-8931-F92660513DD9} -DEFINE_GUID(IID_ID3DX11EffectSamplerVariable, - 0xc6402e55, 0x1095, 0x4d95, 0x89, 0x31, 0xf9, 0x26, 0x60, 0x51, 0x3d, 0xd9); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectSamplerVariable - -DECLARE_INTERFACE_(ID3DX11EffectSamplerVariable, ID3DX11EffectVariable) -{ - // IUnknown - // ID3DX11EffectVariable - - // ID3DX11EffectSamplerVariable - STDMETHOD(GetSampler)(THIS_ _In_ uint32_t Index, _Outptr_ ID3D11SamplerState **ppSampler) PURE; - STDMETHOD(SetSampler)(THIS_ _In_ uint32_t Index, _In_ ID3D11SamplerState *pSampler) PURE; - STDMETHOD(UndoSetSampler)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD(GetBackingStore)(THIS_ _In_ uint32_t Index, _Out_ D3D11_SAMPLER_DESC *pDesc) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectPass ////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX11_PASS_DESC: -// -// Retrieved by ID3DX11EffectPass::GetDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_PASS_DESC -{ - LPCSTR Name; // Name of this pass (nullptr if not anonymous) - uint32_t Annotations; // Number of annotations on this pass - - uint8_t *pIAInputSignature; // Signature from VS or GS (if there is no VS) - // or nullptr if neither exists - size_t IAInputSignatureSize; // Singature size in bytes - - uint32_t StencilRef; // Specified in SetDepthStencilState() - uint32_t SampleMask; // Specified in SetBlendState() - FLOAT BlendFactor[4]; // Specified in SetBlendState() -}; - -//---------------------------------------------------------------------------- -// D3DX11_PASS_SHADER_DESC: -// -// Retrieved by ID3DX11EffectPass::Get**ShaderDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_PASS_SHADER_DESC -{ - ID3DX11EffectShaderVariable *pShaderVariable; // The variable that this shader came from. - // If this is an inline shader assignment, - // the returned interface will be an - // anonymous shader variable, which is - // not retrievable any other way. It's - // name in the variable description will - // be "$Anonymous". - // If there is no assignment of this type in - // the pass block, pShaderVariable != nullptr, - // but pShaderVariable->IsValid() == false. - - uint32_t ShaderIndex; // The element of pShaderVariable (if an array) - // or 0 if not applicable -}; - -typedef interface ID3DX11EffectPass ID3DX11EffectPass; -typedef interface ID3DX11EffectPass *LPD3D11EFFECTPASS; - -// {3437CEC4-4AC1-4D87-8916-F4BD5A41380C} -DEFINE_GUID(IID_ID3DX11EffectPass, - 0x3437cec4, 0x4ac1, 0x4d87, 0x89, 0x16, 0xf4, 0xbd, 0x5a, 0x41, 0x38, 0x0c); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectPass - -DECLARE_INTERFACE_(ID3DX11EffectPass, IUnknown) -{ - // IUnknown - - // ID3DX11EffectPass - STDMETHOD_(bool, IsValid)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ _Out_ D3DX11_PASS_DESC *pDesc) PURE; - - STDMETHOD(GetVertexShaderDesc)(THIS_ _Out_ D3DX11_PASS_SHADER_DESC *pDesc) PURE; - STDMETHOD(GetGeometryShaderDesc)(THIS_ _Out_ D3DX11_PASS_SHADER_DESC *pDesc) PURE; - STDMETHOD(GetPixelShaderDesc)(THIS_ _Out_ D3DX11_PASS_SHADER_DESC *pDesc) PURE; - STDMETHOD(GetHullShaderDesc)(THIS_ _Out_ D3DX11_PASS_SHADER_DESC *pDesc) PURE; - STDMETHOD(GetDomainShaderDesc)(THIS_ _Out_ D3DX11_PASS_SHADER_DESC *pDesc) PURE; - STDMETHOD(GetComputeShaderDesc)(THIS_ _Out_ D3DX11_PASS_SHADER_DESC *pDesc) PURE; - - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD(Apply)(THIS_ _In_ uint32_t Flags, _In_ ID3D11DeviceContext* pContext) PURE; - - STDMETHOD(ComputeStateBlockMask)(THIS_ _Inout_ D3DX11_STATE_BLOCK_MASK *pStateBlockMask) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectTechnique ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX11_TECHNIQUE_DESC: -// -// Retrieved by ID3DX11EffectTechnique::GetDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_TECHNIQUE_DESC -{ - LPCSTR Name; // Name of this technique (nullptr if not anonymous) - uint32_t Passes; // Number of passes contained within - uint32_t Annotations; // Number of annotations on this technique -}; - -typedef interface ID3DX11EffectTechnique ID3DX11EffectTechnique; -typedef interface ID3DX11EffectTechnique *LPD3D11EFFECTTECHNIQUE; - -// {51198831-1F1D-4F47-BD76-41CB0835B1DE} -DEFINE_GUID(IID_ID3DX11EffectTechnique, - 0x51198831, 0x1f1d, 0x4f47, 0xbd, 0x76, 0x41, 0xcb, 0x08, 0x35, 0xb1, 0xde); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectTechnique - -DECLARE_INTERFACE_(ID3DX11EffectTechnique, IUnknown) -{ - // IUnknown - - // ID3DX11EffectTechnique - STDMETHOD_(bool, IsValid)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ _Out_ D3DX11_TECHNIQUE_DESC *pDesc) PURE; - - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD_(ID3DX11EffectPass*, GetPassByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectPass*, GetPassByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD(ComputeStateBlockMask)(THIS_ _Inout_ D3DX11_STATE_BLOCK_MASK *pStateBlockMask) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11EffectTechnique ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX11_GROUP_DESC: -// -// Retrieved by ID3DX11EffectTechnique::GetDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_GROUP_DESC -{ - LPCSTR Name; // Name of this group (only nullptr if global) - uint32_t Techniques; // Number of techniques contained within - uint32_t Annotations; // Number of annotations on this group -}; - -typedef interface ID3DX11EffectGroup ID3DX11EffectGroup; -typedef interface ID3DX11EffectGroup *LPD3D11EFFECTGROUP; - -// {03074acf-97de-485f-b201-cb775264afd6} -DEFINE_GUID(IID_ID3DX11EffectGroup, - 0x03074acf, 0x97de, 0x485f, 0xb2, 0x01, 0xcb, 0x77, 0x52, 0x64, 0xaf, 0xd6); - -#undef INTERFACE -#define INTERFACE ID3DX11EffectGroup - -DECLARE_INTERFACE_(ID3DX11EffectGroup, IUnknown) -{ - // IUnknown - - // ID3DX11EffectGroup - STDMETHOD_(bool, IsValid)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ _Out_ D3DX11_GROUP_DESC *pDesc) PURE; - - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetAnnotationByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD_(ID3DX11EffectTechnique*, GetTechniqueByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectTechnique*, GetTechniqueByName)(THIS_ _In_z_ LPCSTR Name) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// ID3DX11Effect ////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DX11_EFFECT_DESC: -// -// Retrieved by ID3DX11Effect::GetDesc() -//---------------------------------------------------------------------------- - -struct D3DX11_EFFECT_DESC -{ - uint32_t ConstantBuffers; // Number of constant buffers in this effect - uint32_t GlobalVariables; // Number of global variables in this effect - uint32_t InterfaceVariables; // Number of global interfaces in this effect - uint32_t Techniques; // Number of techniques in this effect - uint32_t Groups; // Number of groups in this effect -}; - -typedef interface ID3DX11Effect ID3DX11Effect; -typedef interface ID3DX11Effect *LPD3D11EFFECT; - -// {FA61CA24-E4BA-4262-9DB8-B132E8CAE319} -DEFINE_GUID(IID_ID3DX11Effect, - 0xfa61ca24, 0xe4ba, 0x4262, 0x9d, 0xb8, 0xb1, 0x32, 0xe8, 0xca, 0xe3, 0x19); - -#undef INTERFACE -#define INTERFACE ID3DX11Effect - -DECLARE_INTERFACE_(ID3DX11Effect, IUnknown) -{ - // IUnknown - - // ID3DX11Effect - STDMETHOD_(bool, IsValid)(THIS) PURE; - - STDMETHOD(GetDevice)(THIS_ _Outptr_ ID3D11Device** ppDevice) PURE; - - STDMETHOD(GetDesc)(THIS_ _Out_ D3DX11_EFFECT_DESC *pDesc) PURE; - - STDMETHOD_(ID3DX11EffectConstantBuffer*, GetConstantBufferByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectConstantBuffer*, GetConstantBufferByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD_(ID3DX11EffectVariable*, GetVariableByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetVariableByName)(THIS_ _In_z_ LPCSTR Name) PURE; - STDMETHOD_(ID3DX11EffectVariable*, GetVariableBySemantic)(THIS_ _In_z_ LPCSTR Semantic) PURE; - - STDMETHOD_(ID3DX11EffectGroup*, GetGroupByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectGroup*, GetGroupByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD_(ID3DX11EffectTechnique*, GetTechniqueByIndex)(THIS_ _In_ uint32_t Index) PURE; - STDMETHOD_(ID3DX11EffectTechnique*, GetTechniqueByName)(THIS_ _In_z_ LPCSTR Name) PURE; - - STDMETHOD_(ID3D11ClassLinkage*, GetClassLinkage)(THIS) PURE; - - STDMETHOD(CloneEffect)(THIS_ _In_ uint32_t Flags, _Outptr_ ID3DX11Effect** ppClonedEffect ) PURE; - STDMETHOD(Optimize)(THIS) PURE; - STDMETHOD_(bool, IsOptimized)(THIS) PURE; -}; - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//---------------------------------------------------------------------------- -// D3DX11CreateEffectFromMemory -// -// Creates an effect instance from a compiled effect in memory -// -// Parameters: -// -// [in] -// -// pData -// Blob of compiled effect data -// DataLength -// Length of the data blob -// FXFlags -// Flags pertaining to Effect creation -// pDevice -// Pointer to the D3D11 device on which to create Effect resources -// srcName [optional] -// ASCII string to use for debug object naming -// -// [out] -// -// ppEffect -// Address of the newly created Effect interface -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3DX11CreateEffectFromMemory( _In_reads_bytes_(DataLength) LPCVOID pData, - _In_ SIZE_T DataLength, - _In_ UINT FXFlags, - _In_ ID3D11Device *pDevice, - _Outptr_ ID3DX11Effect **ppEffect, - _In_opt_z_ LPCSTR srcName = nullptr ); - -//---------------------------------------------------------------------------- -// D3DX11CreateEffectFromFile -// -// Creates an effect instance from a compiled effect data file -// -// Parameters: -// -// [in] -// -// pFileName -// Compiled effect file -// FXFlags -// Flags pertaining to Effect creation -// pDevice -// Pointer to the D3D11 device on which to create Effect resources -// -// [out] -// -// ppEffect -// Address of the newly created Effect interface -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI D3DX11CreateEffectFromFile( _In_z_ LPCWSTR pFileName, - _In_ UINT FXFlags, - _In_ ID3D11Device *pDevice, - _Outptr_ ID3DX11Effect **ppEffect ); - -//---------------------------------------------------------------------------- -// D3DX11CompileEffectFromMemory -// -// Complies an effect shader source file in memory and then creates an effect instance -// -// Parameters: -// -// [in] -// -// pData -// Pointer to FX shader as an ASCII string -// DataLength -// Length of the FX shader ASCII string -// srcName [optional] -// ASCII string to use for debug object naming -// pDefines [optional] -// A NULL-terminated array of shader macros -// pInclude [optional] -// A pointer to an include interface -// HLSLFlags -// HLSL compile options (see D3DCOMPILE flags) -// FXFlags -// Flags pertaining to Effect compilation (see D3DCOMPILE_EFFECT flags) -// pDevice -// Pointer to the D3D11 device on which to create Effect resources -// -// [out] -// -// ppEffect -// Address of the newly created Effect interface -// -//---------------------------------------------------------------------------- - -HRESULT D3DX11CompileEffectFromMemory( _In_reads_bytes_(DataLength) LPCVOID pData, - _In_ SIZE_T DataLength, - _In_opt_z_ LPCSTR srcName, - _In_opt_ const D3D_SHADER_MACRO *pDefines, - _In_opt_ ID3DInclude *pInclude, - _In_ UINT HLSLFlags, - _In_ UINT FXFlags, - _In_ ID3D11Device *pDevice, - _Out_ ID3DX11Effect **ppEffect, - _Outptr_opt_result_maybenull_ ID3DBlob **ppErrors ); - -//---------------------------------------------------------------------------- -// D3DX11CompileEffectFromFile -// -// Complies an effect shader source file and then creates an effect instance -// -// Parameters: -// -// [in] -// -// pFileName -// FX shader source file -// pDefines [optional] -// A NULL-terminated array of shader macros -// pInclude [optional] -// A pointer to an include interface -// HLSLFlags -// HLSL compile options (see D3DCOMPILE flags) -// FXFlags -// Flags pertaining to Effect compilation (see D3DCOMPILE_EFFECT flags) -// pDevice -// Pointer to the D3D11 device on which to create Effect resources -// -// [out] -// -// ppEffect -// Address of the newly created Effect interface -// -//---------------------------------------------------------------------------- - -HRESULT D3DX11CompileEffectFromFile( _In_z_ LPCWSTR pFileName, - _In_opt_ const D3D_SHADER_MACRO *pDefines, - _In_opt_ ID3DInclude *pInclude, - _In_ UINT HLSLFlags, - _In_ UINT FXFlags, - _In_ ID3D11Device *pDevice, - _Out_ ID3DX11Effect **ppEffect, - _Outptr_opt_result_maybenull_ ID3DBlob **ppErrors ); - - -//---------------------------------------------------------------------------- -// D3DX11DebugMute -// -// Controls the output of diagnostic information in DEBUG builds. No effect -// in RELEASE builds. -// -// Returns the previous state so you can do temporary suppression like: -// -// bool oldmute = D3DX11DebugMute(true); -// ... -// D3DX11DebugMute(oldmute); -// -//---------------------------------------------------------------------------- - -bool D3DX11DebugMute(bool mute); - -#ifdef __cplusplus -} -#endif //__cplusplus diff --git a/inc/libmspack/lzx.h b/inc/libmspack/lzx.h deleted file mode 100644 index 9c1358d..0000000 --- a/inc/libmspack/lzx.h +++ /dev/null @@ -1,222 +0,0 @@ -/* This file is part of libmspack. - * (C) 2003-2013 Stuart Caie. - * - * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted - * by Microsoft Corporation. - * - * libmspack is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License (LGPL) version 2.1 - * - * For further details, see the file COPYING.LIB distributed with libmspack - */ - -#include - -#ifndef MSPACK_LZX_H -#define MSPACK_LZX_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* LZX compression / decompression definitions */ - -/* some constants defined by the LZX specification */ -#define LZX_MIN_MATCH (2) -#define LZX_MAX_MATCH (257) -#define LZX_NUM_CHARS (256) -#define LZX_BLOCKTYPE_INVALID (0) /* also blocktypes 4-7 invalid */ -#define LZX_BLOCKTYPE_VERBATIM (1) -#define LZX_BLOCKTYPE_ALIGNED (2) -#define LZX_BLOCKTYPE_UNCOMPRESSED (3) -#define LZX_PRETREE_NUM_ELEMENTS (20) -#define LZX_ALIGNED_NUM_ELEMENTS (8) /* aligned offset tree #elements */ -#define LZX_NUM_PRIMARY_LENGTHS (7) /* this one missing from spec! */ -#define LZX_NUM_SECONDARY_LENGTHS (249) /* length tree #elements */ - -/* LZX huffman defines: tweak tablebits as desired */ -#define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS) -#define LZX_PRETREE_TABLEBITS (6) -#define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 290*8) -#define LZX_MAINTREE_TABLEBITS (12) -#define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1) -#define LZX_LENGTH_TABLEBITS (12) -#define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS) -#define LZX_ALIGNED_TABLEBITS (7) -#define LZX_LENTABLE_SAFETY (64) /* table decoding overruns are allowed */ - -#define LZX_FRAME_SIZE (32768) /* the size of a frame in LZX */ - -struct lzxd_stream { - struct mspack_system *sys; /* I/O routines */ - struct mspack_file *input; /* input file handle */ - struct mspack_file *output; /* output file handle */ - - off_t offset; /* number of bytes actually output */ - off_t length; /* overall decompressed length of stream */ - - unsigned char *window; /* decoding window */ - unsigned int window_size; /* window size */ - unsigned int ref_data_size; /* LZX DELTA reference data size */ - unsigned int num_offsets; /* number of match_offset entries in table */ - unsigned int window_posn; /* decompression offset within window */ - unsigned int frame_posn; /* current frame offset within in window */ - unsigned int frame; /* the number of 32kb frames processed */ - unsigned int reset_interval; /* which frame do we reset the compressor? */ - - unsigned int R0, R1, R2; /* for the LRU offset system */ - unsigned int block_length; /* uncompressed length of this LZX block */ - unsigned int block_remaining; /* uncompressed bytes still left to decode */ - - signed int intel_filesize; /* magic header value used for transform */ - - unsigned char intel_started; /* has intel E8 decoding started? */ - unsigned char block_type; /* type of the current block */ - unsigned char header_read; /* have we started decoding at all yet? */ - unsigned char input_end; /* have we reached the end of input? */ - unsigned char is_delta; /* does stream follow LZX DELTA spec? */ - - int error; - - /* I/O buffering */ - unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end; - unsigned int bit_buffer, bits_left, inbuf_size; - - /* huffman code lengths */ - unsigned char PRETREE_len [LZX_PRETREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - unsigned char MAINTREE_len [LZX_MAINTREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - unsigned char LENGTH_len [LZX_LENGTH_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - unsigned char ALIGNED_len [LZX_ALIGNED_MAXSYMBOLS + LZX_LENTABLE_SAFETY]; - - /* huffman decoding tables */ - unsigned short PRETREE_table [(1 << LZX_PRETREE_TABLEBITS) + - (LZX_PRETREE_MAXSYMBOLS * 2)]; - unsigned short MAINTREE_table[(1 << LZX_MAINTREE_TABLEBITS) + - (LZX_MAINTREE_MAXSYMBOLS * 2)]; - unsigned short LENGTH_table [(1 << LZX_LENGTH_TABLEBITS) + - (LZX_LENGTH_MAXSYMBOLS * 2)]; - unsigned short ALIGNED_table [(1 << LZX_ALIGNED_TABLEBITS) + - (LZX_ALIGNED_MAXSYMBOLS * 2)]; - unsigned char LENGTH_empty; - - /* this is used purely for doing the intel E8 transform */ - unsigned char e8_buf[LZX_FRAME_SIZE]; -}; - -/** - * Allocates and initialises LZX decompression state for decoding an LZX - * stream. - * - * This routine uses system->alloc() to allocate memory. If memory - * allocation fails, or the parameters to this function are invalid, - * NULL is returned. - * - * @param system an mspack_system structure used to read from - * the input stream and write to the output - * stream, also to allocate and free memory. - * @param input an input stream with the LZX data. - * @param output an output stream to write the decoded data to. - * @param window_bits the size of the decoding window, which must be - * between 15 and 21 inclusive for regular LZX - * data, or between 17 and 25 inclusive for - * LZX DELTA data. - * @param reset_interval the interval at which the LZX bitstream is - * reset, in multiples of LZX frames (32678 - * bytes), e.g. a value of 2 indicates the input - * stream resets after every 65536 output bytes. - * A value of 0 indicates that the bitstream never - * resets, such as in CAB LZX streams. - * @param input_buffer_size the number of bytes to use as an input - * bitstream buffer. - * @param output_length the length in bytes of the entirely - * decompressed output stream, if known in - * advance. It is used to correctly perform the - * Intel E8 transformation, which must stop 6 - * bytes before the very end of the - * decompressed stream. It is not otherwise used - * or adhered to. If the full decompressed - * length is known in advance, set it here. - * If it is NOT known, use the value 0, and call - * lzxd_set_output_length() once it is - * known. If never set, 4 of the final 6 bytes - * of the output stream may be incorrect. - * @param is_delta should be zero for all regular LZX data, - * non-zero for LZX DELTA encoded data. - * @return a pointer to an initialised lzxd_stream structure, or NULL if - * there was not enough memory or parameters to the function were wrong. - */ -extern struct lzxd_stream *lzxd_init(struct mspack_system *system, - struct mspack_file *input, - struct mspack_file *output, - int window_bits, - int reset_interval, - int input_buffer_size, - off_t output_length, - char is_delta); - -/* see description of output_length in lzxd_init() */ -extern void lzxd_set_output_length(struct lzxd_stream *lzx, - off_t output_length); - -/** - * Reads LZX DELTA reference data into the window and allows - * lzxd_decompress() to reference it. - * - * Call this before the first call to lzxd_decompress(). - - * @param lzx the LZX stream to apply this reference data to - * @param system an mspack_system implementation to use with the - * input param. Only read() will be called. - * @param input an input file handle to read reference data using - * system->read(). - * @param length the length of the reference data. Cannot be longer - * than the LZX window size. - * @return an error code, or MSPACK_ERR_OK if successful - */ -extern int lzxd_set_reference_data(struct lzxd_stream *lzx, - struct mspack_system *system, - struct mspack_file *input, - unsigned int length); - -/** - * Decompresses entire or partial LZX streams. - * - * The number of bytes of data that should be decompressed is given as the - * out_bytes parameter. If more bytes are decoded than are needed, they - * will be kept over for a later invocation. - * - * The output bytes will be passed to the system->write() function given in - * lzxd_init(), using the output file handle given in lzxd_init(). More than - * one call may be made to system->write(). - - * Input bytes will be read in as necessary using the system->read() - * function given in lzxd_init(), using the input file handle given in - * lzxd_init(). This will continue until system->read() returns 0 bytes, - * or an error. Errors will be passed out of the function as - * MSPACK_ERR_READ errors. Input streams should convey an "end of input - * stream" by refusing to supply all the bytes that LZX asks for when they - * reach the end of the stream, rather than return an error code. - * - * If any error code other than MSPACK_ERR_OK is returned, the stream - * should be considered unusable and lzxd_decompress() should not be - * called again on this stream. - * - * @param lzx LZX decompression state, as allocated by lzxd_init(). - * @param out_bytes the number of bytes of data to decompress. - * @return an error code, or MSPACK_ERR_OK if successful - */ -extern int lzxd_decompress(struct lzxd_stream *lzx, off_t out_bytes); - -/** - * Frees all state associated with an LZX data stream. This will call - * system->free() using the system pointer given in lzxd_init(). - * - * @param lzx LZX decompression state to free. - */ -void lzxd_free(struct lzxd_stream *lzx); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/inc/libmspack/mspack.h b/inc/libmspack/mspack.h deleted file mode 100644 index 3e99624..0000000 --- a/inc/libmspack/mspack.h +++ /dev/null @@ -1,2385 +0,0 @@ -/* libmspack -- a library for working with Microsoft compression formats. - * (C) 2003-2019 Stuart Caie - * - * libmspack is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License (LGPL) version 2.1 - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/** \mainpage - * - * \section intro Introduction - * - * libmspack is a library which provides compressors and decompressors, - * archivers and dearchivers for Microsoft compression formats. - * - * \section formats Formats supported - * - * The following file formats are supported: - * - SZDD files, which use LZSS compression - * - KWAJ files, which use LZSS, LZSS+Huffman or deflate compression - * - .HLP (MS Help) files, which use LZSS compression - * - .CAB (MS Cabinet) files, which use deflate, LZX or Quantum compression - * - .CHM (HTML Help) files, which use LZX compression - * - .LIT (MS EBook) files, which use LZX compression and DES encryption - * - .LZX (Exchange Offline Addressbook) files, which use LZX compression - * - * To determine the capabilities of the library, and the binary - * compatibility version of any particular compressor or decompressor, use - * the mspack_version() function. The UNIX library interface version is - * defined as the highest-versioned library component. - * - * \section starting Getting started - * - * The macro MSPACK_SYS_SELFTEST() should be used to ensure the library can - * be used. In particular, it checks if the caller is using 32-bit file I/O - * when the library is compiled for 64-bit file I/O and vice versa. - * - * If compiled normally, the library includes basic file I/O and memory - * management functionality using the standard C library. This can be - * customised and replaced entirely by creating a mspack_system structure. - * - * A compressor or decompressor for the required format must be - * instantiated before it can be used. Each construction function takes - * one parameter, which is either a pointer to a custom mspack_system - * structure, or NULL to use the default. The instantiation returned, if - * not NULL, contains function pointers (methods) to work with the given - * file format. - * - * For compression: - * - mspack_create_cab_compressor() creates a mscab_compressor - * - mspack_create_chm_compressor() creates a mschm_compressor - * - mspack_create_lit_compressor() creates a mslit_compressor - * - mspack_create_hlp_compressor() creates a mshlp_compressor - * - mspack_create_szdd_compressor() creates a msszdd_compressor - * - mspack_create_kwaj_compressor() creates a mskwaj_compressor - * - mspack_create_oab_compressor() creates a msoab_compressor - * - * For decompression: - * - mspack_create_cab_decompressor() creates a mscab_decompressor - * - mspack_create_chm_decompressor() creates a mschm_decompressor - * - mspack_create_lit_decompressor() creates a mslit_decompressor - * - mspack_create_hlp_decompressor() creates a mshlp_decompressor - * - mspack_create_szdd_decompressor() creates a msszdd_decompressor - * - mspack_create_kwaj_decompressor() creates a mskwaj_decompressor - * - mspack_create_oab_decompressor() creates a msoab_decompressor - * - * Once finished working with a format, each kind of - * compressor/decompressor has its own specific destructor: - * - mspack_destroy_cab_compressor() - * - mspack_destroy_cab_decompressor() - * - mspack_destroy_chm_compressor() - * - mspack_destroy_chm_decompressor() - * - mspack_destroy_lit_compressor() - * - mspack_destroy_lit_decompressor() - * - mspack_destroy_hlp_compressor() - * - mspack_destroy_hlp_decompressor() - * - mspack_destroy_szdd_compressor() - * - mspack_destroy_szdd_decompressor() - * - mspack_destroy_kwaj_compressor() - * - mspack_destroy_kwaj_decompressor() - * - mspack_destroy_oab_compressor() - * - mspack_destroy_oab_decompressor() - * - * Destroying a compressor or decompressor does not destroy any objects, - * structures or handles that have been created using that compressor or - * decompressor. Ensure that everything created or opened is destroyed or - * closed before compressor/decompressor is itself destroyed. - * - * \section errors Error codes - * - * All compressors and decompressors use the same set of error codes. Most - * methods return an error code directly. For methods which do not - * return error codes directly, the error code can be obtained with the - * last_error() method. - * - * - #MSPACK_ERR_OK is used to indicate success. This error code is defined - * as zero, all other code are non-zero. - * - #MSPACK_ERR_ARGS indicates that a method was called with inappropriate - * arguments. - * - #MSPACK_ERR_OPEN indicates that mspack_system::open() failed. - * - #MSPACK_ERR_READ indicates that mspack_system::read() failed. - * - #MSPACK_ERR_WRITE indicates that mspack_system::write() failed. - * - #MSPACK_ERR_SEEK indicates that mspack_system::seek() failed. - * - #MSPACK_ERR_NOMEMORY indicates that mspack_system::alloc() failed. - * - #MSPACK_ERR_SIGNATURE indicates that the file being read does not - * have the correct "signature". It is probably not a valid file for - * whatever format is being read. - * - #MSPACK_ERR_DATAFORMAT indicates that the file being used or read - * is corrupt. - * - #MSPACK_ERR_CHECKSUM indicates that a data checksum has failed. - * - #MSPACK_ERR_CRUNCH indicates an error occured during compression. - * - #MSPACK_ERR_DECRUNCH indicates an error occured during decompression. - * - * \section threading Multi-threading - * - * libmspack methods are reentrant and multithreading-safe when each - * thread has its own compressor or decompressor. - - * You should not call multiple methods simultaneously on a single - * compressor or decompressor instance. - * - * If this may happen, you can either use one compressor or - * decompressor per thread, or you can use your preferred lock, - * semaphore or mutex library to ensure no more than one method on a - * compressor/decompressor is called simultaneously. libmspack will - * not do this locking for you. - * - * Example of incorrect behaviour: - * - thread 1 calls mspack_create_cab_decompressor() - * - thread 1 calls open() - * - thread 1 calls extract() for one file - * - thread 2 simultaneously calls extract() for another file - * - * Correct behaviour: - * - thread 1 calls mspack_create_cab_decompressor() - * - thread 2 calls mspack_create_cab_decompressor() - * - thread 1 calls its own open() / extract() - * - thread 2 simultaneously calls its own open() / extract() - * - * Also correct behaviour: - * - thread 1 calls mspack_create_cab_decompressor() - * - thread 1 locks a mutex for with the decompressor before - * calling any methods on it, and unlocks the mutex after each - * method returns. - * - thread 1 can share the results of open() with thread 2, and both - * can call extract(), provided they both guard against simultaneous - * use of extract(), and any other methods, with the mutex - */ - -#ifndef LIB_MSPACK_H -#define LIB_MSPACK_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * System self-test function, to ensure both library and calling program - * can use one another. - * - * A result of MSPACK_ERR_OK means the library and caller are - * compatible. Any other result indicates that the library and caller are - * not compatible and should not be used. In particular, a value of - * MSPACK_ERR_SEEK means the library and caller use different off_t - * datatypes. - * - * It should be used like so: - * - * @code - * int selftest_result; - * MSPACK_SYS_SELFTEST(selftest_result); - * if (selftest_result != MSPACK_ERR_OK) { - * fprintf(stderr, "incompatible with this build of libmspack\n"); - * exit(0); - * } - * @endcode - * - * @param result an int variable to store the result of the self-test - */ -#define MSPACK_SYS_SELFTEST(result) do { \ - (result) = mspack_sys_selftest_internal(sizeof(off_t)); \ -} while (0) - -/** Part of the MSPACK_SYS_SELFTEST() macro, must not be used directly. */ -extern int mspack_sys_selftest_internal(int); - -/** - * Enquire about the binary compatibility version of a specific interface in - * the library. Currently, the following interfaces are defined: - * - * - #MSPACK_VER_LIBRARY: the overall library - * - #MSPACK_VER_SYSTEM: the mspack_system interface - * - #MSPACK_VER_MSCABD: the mscab_decompressor interface - * - #MSPACK_VER_MSCABC: the mscab_compressor interface - * - #MSPACK_VER_MSCHMD: the mschm_decompressor interface - * - #MSPACK_VER_MSCHMC: the mschm_compressor interface - * - #MSPACK_VER_MSLITD: the mslit_decompressor interface - * - #MSPACK_VER_MSLITC: the mslit_compressor interface - * - #MSPACK_VER_MSHLPD: the mshlp_decompressor interface - * - #MSPACK_VER_MSHLPC: the mshlp_compressor interface - * - #MSPACK_VER_MSSZDDD: the msszdd_decompressor interface - * - #MSPACK_VER_MSSZDDC: the msszdd_compressor interface - * - #MSPACK_VER_MSKWAJD: the mskwaj_decompressor interface - * - #MSPACK_VER_MSKWAJC: the mskwaj_compressor interface - * - #MSPACK_VER_MSOABD: the msoab_decompressor interface - * - #MSPACK_VER_MSOABC: the msoab_compressor interface - * - * The result of the function should be interpreted as follows: - * - -1: this interface is completely unknown to the library - * - 0: this interface is known, but non-functioning - * - 1: this interface has all basic functionality - * - 2, 3, ...: this interface has additional functionality, clearly marked - * in the documentation as "version 2", "version 3" and so on. - * - * @param entity the interface to request current version of - * @return the version of the requested interface - */ -extern int mspack_version(int entity); - -/** Pass to mspack_version() to get the overall library version */ -#define MSPACK_VER_LIBRARY (0) -/** Pass to mspack_version() to get the mspack_system version */ -#define MSPACK_VER_SYSTEM (1) -/** Pass to mspack_version() to get the mscab_decompressor version */ -#define MSPACK_VER_MSCABD (2) -/** Pass to mspack_version() to get the mscab_compressor version */ -#define MSPACK_VER_MSCABC (3) -/** Pass to mspack_version() to get the mschm_decompressor version */ -#define MSPACK_VER_MSCHMD (4) -/** Pass to mspack_version() to get the mschm_compressor version */ -#define MSPACK_VER_MSCHMC (5) -/** Pass to mspack_version() to get the mslit_decompressor version */ -#define MSPACK_VER_MSLITD (6) -/** Pass to mspack_version() to get the mslit_compressor version */ -#define MSPACK_VER_MSLITC (7) -/** Pass to mspack_version() to get the mshlp_decompressor version */ -#define MSPACK_VER_MSHLPD (8) -/** Pass to mspack_version() to get the mshlp_compressor version */ -#define MSPACK_VER_MSHLPC (9) -/** Pass to mspack_version() to get the msszdd_decompressor version */ -#define MSPACK_VER_MSSZDDD (10) -/** Pass to mspack_version() to get the msszdd_compressor version */ -#define MSPACK_VER_MSSZDDC (11) -/** Pass to mspack_version() to get the mskwaj_decompressor version */ -#define MSPACK_VER_MSKWAJD (12) -/** Pass to mspack_version() to get the mskwaj_compressor version */ -#define MSPACK_VER_MSKWAJC (13) -/** Pass to mspack_version() to get the msoab_decompressor version */ -#define MSPACK_VER_MSOABD (14) -/** Pass to mspack_version() to get the msoab_compressor version */ -#define MSPACK_VER_MSOABC (15) - -/* --- file I/O abstraction ------------------------------------------------ */ - -/** - * A structure which abstracts file I/O and memory management. - * - * The library always uses the mspack_system structure for interaction - * with the file system and to allocate, free and copy all memory. It also - * uses it to send literal messages to the library user. - * - * When the library is compiled normally, passing NULL to a compressor or - * decompressor constructor will result in a default mspack_system being - * used, where all methods are implemented with the standard C library. - * However, all constructors support being given a custom created - * mspack_system structure, with the library user's own methods. This - * allows for more abstract interaction, such as reading and writing files - * directly to memory, or from a network socket or pipe. - * - * Implementors of an mspack_system structure should read all - * documentation entries for every structure member, and write methods - * which conform to those standards. - */ -struct mspack_system { - /** - * Opens a file for reading, writing, appending or updating. - * - * @param self a self-referential pointer to the mspack_system - * structure whose open() method is being called. If - * this pointer is required by close(), read(), write(), - * seek() or tell(), it should be stored in the result - * structure at this time. - * @param filename the file to be opened. It is passed directly from the - * library caller without being modified, so it is up to - * the caller what this parameter actually represents. - * @param mode one of #MSPACK_SYS_OPEN_READ (open an existing file - * for reading), #MSPACK_SYS_OPEN_WRITE (open a new file - * for writing), #MSPACK_SYS_OPEN_UPDATE (open an existing - * file for reading/writing from the start of the file) or - * #MSPACK_SYS_OPEN_APPEND (open an existing file for - * reading/writing from the end of the file) - * @return a pointer to a mspack_file structure. This structure officially - * contains no members, its true contents are up to the - * mspack_system implementor. It should contain whatever is needed - * for other mspack_system methods to operate. Returning the NULL - * pointer indicates an error condition. - * @see close(), read(), write(), seek(), tell(), message() - */ - struct mspack_file * (*open)(struct mspack_system *self, - const char *filename, - int mode); - - /** - * Closes a previously opened file. If any memory was allocated for this - * particular file handle, it should be freed at this time. - * - * @param file the file to close - * @see open() - */ - void (*close)(struct mspack_file *file); - - /** - * Reads a given number of bytes from an open file. - * - * @param file the file to read from - * @param buffer the location where the read bytes should be stored - * @param bytes the number of bytes to read from the file. - * @return the number of bytes successfully read (this can be less than - * the number requested), zero to mark the end of file, or less - * than zero to indicate an error. The library does not "retry" - * reads and assumes short reads are due to EOF, so you should - * avoid returning short reads because of transient errors. - * @see open(), write() - */ - int (*read)(struct mspack_file *file, - void *buffer, - int bytes); - - /** - * Writes a given number of bytes to an open file. - * - * @param file the file to write to - * @param buffer the location where the written bytes should be read from - * @param bytes the number of bytes to write to the file. - * @return the number of bytes successfully written, this can be less - * than the number requested. Zero or less can indicate an error - * where no bytes at all could be written. All cases where less - * bytes were written than requested are considered by the library - * to be an error. - * @see open(), read() - */ - int (*write)(struct mspack_file *file, - void *buffer, - int bytes); - - /** - * Seeks to a specific file offset within an open file. - * - * Sometimes the library needs to know the length of a file. It does - * this by seeking to the end of the file with seek(file, 0, - * MSPACK_SYS_SEEK_END), then calling tell(). Implementations may want - * to make a special case for this. - * - * Due to the potentially varying 32/64 bit datatype off_t on some - * architectures, the #MSPACK_SYS_SELFTEST macro MUST be used before - * using the library. If not, the error caused by the library passing an - * inappropriate stackframe to seek() is subtle and hard to trace. - * - * @param file the file to be seeked - * @param offset an offset to seek, measured in bytes - * @param mode one of #MSPACK_SYS_SEEK_START (the offset should be - * measured from the start of the file), #MSPACK_SYS_SEEK_CUR - * (the offset should be measured from the current file offset) - * or #MSPACK_SYS_SEEK_END (the offset should be measured from - * the end of the file) - * @return zero for success, non-zero for an error - * @see open(), tell() - */ - int (*seek)(struct mspack_file *file, - off_t offset, - int mode); - - /** - * Returns the current file position (in bytes) of the given file. - * - * @param file the file whose file position is wanted - * @return the current file position of the file - * @see open(), seek() - */ - off_t (*tell)(struct mspack_file *file); - - /** - * Used to send messages from the library to the user. - * - * Occasionally, the library generates warnings or other messages in - * plain english to inform the human user. These are informational only - * and can be ignored if not wanted. - * - * @param file may be a file handle returned from open() if this message - * pertains to a specific open file, or NULL if not related to - * a specific file. - * @param format a printf() style format string. It does NOT include a - * trailing newline. - * @see open() - */ - void (*message)(struct mspack_file *file, - const char *format, - ...); - - /** - * Allocates memory. - * - * @param self a self-referential pointer to the mspack_system - * structure whose alloc() method is being called. - * @param bytes the number of bytes to allocate - * @result a pointer to the requested number of bytes, or NULL if - * not enough memory is available - * @see free() - */ - void * (*alloc)(struct mspack_system *self, - size_t bytes); - - /** - * Frees memory. - * - * @param ptr the memory to be freed. NULL is accepted and ignored. - * @see alloc() - */ - void (*free)(void *ptr); - - /** - * Copies from one region of memory to another. - * - * The regions of memory are guaranteed not to overlap, are usually less - * than 256 bytes, and may not be aligned. Please note that the source - * parameter comes before the destination parameter, unlike the standard - * C function memcpy(). - * - * @param src the region of memory to copy from - * @param dest the region of memory to copy to - * @param bytes the size of the memory region, in bytes - */ - void (*copy)(void *src, - void *dest, - size_t bytes); - - /** - * A null pointer to mark the end of mspack_system. It must equal NULL. - * - * Should the mspack_system structure extend in the future, this NULL - * will be seen, rather than have an invalid method pointer called. - */ - void *null_ptr; -}; - -/** mspack_system::open() mode: open existing file for reading. */ -#define MSPACK_SYS_OPEN_READ (0) -/** mspack_system::open() mode: open new file for writing */ -#define MSPACK_SYS_OPEN_WRITE (1) -/** mspack_system::open() mode: open existing file for writing */ -#define MSPACK_SYS_OPEN_UPDATE (2) -/** mspack_system::open() mode: open existing file for writing */ -#define MSPACK_SYS_OPEN_APPEND (3) - -/** mspack_system::seek() mode: seek relative to start of file */ -#define MSPACK_SYS_SEEK_START (0) -/** mspack_system::seek() mode: seek relative to current offset */ -#define MSPACK_SYS_SEEK_CUR (1) -/** mspack_system::seek() mode: seek relative to end of file */ -#define MSPACK_SYS_SEEK_END (2) - -/** - * A structure which represents an open file handle. The contents of this - * structure are determined by the implementation of the - * mspack_system::open() method. - */ -struct mspack_file { - int dummy; -}; - -/* --- error codes --------------------------------------------------------- */ - -/** Error code: no error */ -#define MSPACK_ERR_OK (0) -/** Error code: bad arguments to method */ -#define MSPACK_ERR_ARGS (1) -/** Error code: error opening file */ -#define MSPACK_ERR_OPEN (2) -/** Error code: error reading file */ -#define MSPACK_ERR_READ (3) -/** Error code: error writing file */ -#define MSPACK_ERR_WRITE (4) -/** Error code: seek error */ -#define MSPACK_ERR_SEEK (5) -/** Error code: out of memory */ -#define MSPACK_ERR_NOMEMORY (6) -/** Error code: bad "magic id" in file */ -#define MSPACK_ERR_SIGNATURE (7) -/** Error code: bad or corrupt file format */ -#define MSPACK_ERR_DATAFORMAT (8) -/** Error code: bad checksum or CRC */ -#define MSPACK_ERR_CHECKSUM (9) -/** Error code: error during compression */ -#define MSPACK_ERR_CRUNCH (10) -/** Error code: error during decompression */ -#define MSPACK_ERR_DECRUNCH (11) - -/* --- functions available in library -------------------------------------- */ - -/** Creates a new CAB compressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mscab_compressor or NULL - */ -extern struct mscab_compressor * - mspack_create_cab_compressor(struct mspack_system *sys); - -/** Creates a new CAB decompressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mscab_decompressor or NULL - */ -extern struct mscab_decompressor * - mspack_create_cab_decompressor(struct mspack_system *sys); - -/** Destroys an existing CAB compressor. - * @param self the #mscab_compressor to destroy - */ -extern void mspack_destroy_cab_compressor(struct mscab_compressor *self); - -/** Destroys an existing CAB decompressor. - * @param self the #mscab_decompressor to destroy - */ -extern void mspack_destroy_cab_decompressor(struct mscab_decompressor *self); - - -/** Creates a new CHM compressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mschm_compressor or NULL - */ -extern struct mschm_compressor * - mspack_create_chm_compressor(struct mspack_system *sys); - -/** Creates a new CHM decompressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mschm_decompressor or NULL - */ -extern struct mschm_decompressor * - mspack_create_chm_decompressor(struct mspack_system *sys); - -/** Destroys an existing CHM compressor. - * @param self the #mschm_compressor to destroy - */ -extern void mspack_destroy_chm_compressor(struct mschm_compressor *self); - -/** Destroys an existing CHM decompressor. - * @param self the #mschm_decompressor to destroy - */ -extern void mspack_destroy_chm_decompressor(struct mschm_decompressor *self); - - -/** Creates a new LIT compressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mslit_compressor or NULL - */ -extern struct mslit_compressor * - mspack_create_lit_compressor(struct mspack_system *sys); - -/** Creates a new LIT decompressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mslit_decompressor or NULL - */ -extern struct mslit_decompressor * - mspack_create_lit_decompressor(struct mspack_system *sys); - -/** Destroys an existing LIT compressor. - * @param self the #mslit_compressor to destroy - */ -extern void mspack_destroy_lit_compressor(struct mslit_compressor *self); - -/** Destroys an existing LIT decompressor. - * @param self the #mslit_decompressor to destroy - */ -extern void mspack_destroy_lit_decompressor(struct mslit_decompressor *self); - - -/** Creates a new HLP compressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mshlp_compressor or NULL - */ -extern struct mshlp_compressor * - mspack_create_hlp_compressor(struct mspack_system *sys); - -/** Creates a new HLP decompressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mshlp_decompressor or NULL - */ -extern struct mshlp_decompressor * - mspack_create_hlp_decompressor(struct mspack_system *sys); - -/** Destroys an existing hlp compressor. - * @param self the #mshlp_compressor to destroy - */ -extern void mspack_destroy_hlp_compressor(struct mshlp_compressor *self); - -/** Destroys an existing hlp decompressor. - * @param self the #mshlp_decompressor to destroy - */ -extern void mspack_destroy_hlp_decompressor(struct mshlp_decompressor *self); - - -/** Creates a new SZDD compressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #msszdd_compressor or NULL - */ -extern struct msszdd_compressor * - mspack_create_szdd_compressor(struct mspack_system *sys); - -/** Creates a new SZDD decompressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #msszdd_decompressor or NULL - */ -extern struct msszdd_decompressor * - mspack_create_szdd_decompressor(struct mspack_system *sys); - -/** Destroys an existing SZDD compressor. - * @param self the #msszdd_compressor to destroy - */ -extern void mspack_destroy_szdd_compressor(struct msszdd_compressor *self); - -/** Destroys an existing SZDD decompressor. - * @param self the #msszdd_decompressor to destroy - */ -extern void mspack_destroy_szdd_decompressor(struct msszdd_decompressor *self); - - -/** Creates a new KWAJ compressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mskwaj_compressor or NULL - */ -extern struct mskwaj_compressor * - mspack_create_kwaj_compressor(struct mspack_system *sys); - -/** Creates a new KWAJ decompressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #mskwaj_decompressor or NULL - */ -extern struct mskwaj_decompressor * - mspack_create_kwaj_decompressor(struct mspack_system *sys); - -/** Destroys an existing KWAJ compressor. - * @param self the #mskwaj_compressor to destroy - */ -extern void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *self); - -/** Destroys an existing KWAJ decompressor. - * @param self the #mskwaj_decompressor to destroy - */ -extern void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *self); - - -/** Creates a new OAB compressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #msoab_compressor or NULL - */ -extern struct msoab_compressor * - mspack_create_oab_compressor(struct mspack_system *sys); - -/** Creates a new OAB decompressor. - * @param sys a custom mspack_system structure, or NULL to use the default - * @return a #msoab_decompressor or NULL - */ -extern struct msoab_decompressor * - mspack_create_oab_decompressor(struct mspack_system *sys); - -/** Destroys an existing OAB compressor. - * @param self the #msoab_compressor to destroy - */ -extern void mspack_destroy_oab_compressor(struct msoab_compressor *self); - -/** Destroys an existing OAB decompressor. - * @param self the #msoab_decompressor to destroy - */ -extern void mspack_destroy_oab_decompressor(struct msoab_decompressor *self); - - -/* --- support for .CAB (MS Cabinet) file format --------------------------- */ - -/** - * A structure which represents a single cabinet file. - * - * All fields are READ ONLY. - * - * If this cabinet is part of a merged cabinet set, the #files and #folders - * fields are common to all cabinets in the set, and will be identical. - * - * @see mscab_decompressor::open(), mscab_decompressor::close(), - * mscab_decompressor::search() - */ -struct mscabd_cabinet { - /** - * The next cabinet in a chained list, if this cabinet was opened with - * mscab_decompressor::search(). May be NULL to mark the end of the - * list. - */ - struct mscabd_cabinet *next; - - /** - * The filename of the cabinet. More correctly, the filename of the - * physical file that the cabinet resides in. This is given by the - * library user and may be in any format. - */ - const char *filename; - - /** The file offset of cabinet within the physical file it resides in. */ - off_t base_offset; - - /** The length of the cabinet file in bytes. */ - unsigned int length; - - /** The previous cabinet in a cabinet set, or NULL. */ - struct mscabd_cabinet *prevcab; - - /** The next cabinet in a cabinet set, or NULL. */ - struct mscabd_cabinet *nextcab; - - /** The filename of the previous cabinet in a cabinet set, or NULL. */ - char *prevname; - - /** The filename of the next cabinet in a cabinet set, or NULL. */ - char *nextname; - - /** The name of the disk containing the previous cabinet in a cabinet - * set, or NULL. - */ - char *previnfo; - - /** The name of the disk containing the next cabinet in a cabinet set, - * or NULL. - */ - char *nextinfo; - - /** A list of all files in the cabinet or cabinet set. */ - struct mscabd_file *files; - - /** A list of all folders in the cabinet or cabinet set. */ - struct mscabd_folder *folders; - - /** - * The set ID of the cabinet. All cabinets in the same set should have - * the same set ID. - */ - unsigned short set_id; - - /** - * The index number of the cabinet within the set. Numbering should - * start from 0 for the first cabinet in the set, and increment by 1 for - * each following cabinet. - */ - unsigned short set_index; - - /** - * The number of bytes reserved in the header area of the cabinet. - * - * If this is non-zero and flags has MSCAB_HDR_RESV set, this data can - * be read by the calling application. It is of the given length, - * located at offset (base_offset + MSCAB_HDR_RESV_OFFSET) in the - * cabinet file. - * - * @see flags - */ - unsigned short header_resv; - - /** - * Header flags. - * - * - MSCAB_HDR_PREVCAB indicates the cabinet is part of a cabinet set, and - * has a predecessor cabinet. - * - MSCAB_HDR_NEXTCAB indicates the cabinet is part of a cabinet set, and - * has a successor cabinet. - * - MSCAB_HDR_RESV indicates the cabinet has reserved header space. - * - * @see prevname, previnfo, nextname, nextinfo, header_resv - */ - int flags; -}; - -/** Offset from start of cabinet to the reserved header data (if present). */ -#define MSCAB_HDR_RESV_OFFSET (0x28) - -/** Cabinet header flag: cabinet has a predecessor */ -#define MSCAB_HDR_PREVCAB (0x01) -/** Cabinet header flag: cabinet has a successor */ -#define MSCAB_HDR_NEXTCAB (0x02) -/** Cabinet header flag: cabinet has reserved header space */ -#define MSCAB_HDR_RESV (0x04) - -/** - * A structure which represents a single folder in a cabinet or cabinet set. - * - * All fields are READ ONLY. - * - * A folder is a single compressed stream of data. When uncompressed, it - * holds the data of one or more files. A folder may be split across more - * than one cabinet. - */ -struct mscabd_folder { - /** - * A pointer to the next folder in this cabinet or cabinet set, or NULL - * if this is the final folder. - */ - struct mscabd_folder *next; - - /** - * The compression format used by this folder. - * - * The macro MSCABD_COMP_METHOD() should be used on this field to get - * the algorithm used. The macro MSCABD_COMP_LEVEL() should be used to get - * the "compression level". - * - * @see MSCABD_COMP_METHOD(), MSCABD_COMP_LEVEL() - */ - int comp_type; - - /** - * The total number of data blocks used by this folder. This includes - * data blocks present in other files, if this folder spans more than - * one cabinet. - */ - unsigned int num_blocks; -}; - -/** - * Returns the compression method used by a folder. - * - * @param comp_type a mscabd_folder::comp_type value - * @return one of #MSCAB_COMP_NONE, #MSCAB_COMP_MSZIP, #MSCAB_COMP_QUANTUM - * or #MSCAB_COMP_LZX - */ -#define MSCABD_COMP_METHOD(comp_type) ((comp_type) & 0x0F) -/** - * Returns the compression level used by a folder. - * - * @param comp_type a mscabd_folder::comp_type value - * @return the compression level. This is only defined by LZX and Quantum - * compression - */ -#define MSCABD_COMP_LEVEL(comp_type) (((comp_type) >> 8) & 0x1F) - -/** Compression mode: no compression. */ -#define MSCAB_COMP_NONE (0) -/** Compression mode: MSZIP (deflate) compression. */ -#define MSCAB_COMP_MSZIP (1) -/** Compression mode: Quantum compression */ -#define MSCAB_COMP_QUANTUM (2) -/** Compression mode: LZX compression */ -#define MSCAB_COMP_LZX (3) - -/** - * A structure which represents a single file in a cabinet or cabinet set. - * - * All fields are READ ONLY. - */ -struct mscabd_file { - /** - * The next file in the cabinet or cabinet set, or NULL if this is the - * final file. - */ - struct mscabd_file *next; - - /** - * The filename of the file. - * - * A null terminated string of up to 255 bytes in length, it may be in - * either ISO-8859-1 or UTF8 format, depending on the file attributes. - * - * @see attribs - */ - char *filename; - - /** The uncompressed length of the file, in bytes. */ - unsigned int length; - - /** - * File attributes. - * - * The following attributes are defined: - * - #MSCAB_ATTRIB_RDONLY indicates the file is write protected. - * - #MSCAB_ATTRIB_HIDDEN indicates the file is hidden. - * - #MSCAB_ATTRIB_SYSTEM indicates the file is a operating system file. - * - #MSCAB_ATTRIB_ARCH indicates the file is "archived". - * - #MSCAB_ATTRIB_EXEC indicates the file is an executable program. - * - #MSCAB_ATTRIB_UTF_NAME indicates the filename is in UTF8 format rather - * than ISO-8859-1. - */ - int attribs; - - /** File's last modified time, hour field. */ - char time_h; - /** File's last modified time, minute field. */ - char time_m; - /** File's last modified time, second field. */ - char time_s; - - /** File's last modified date, day field. */ - char date_d; - /** File's last modified date, month field. */ - char date_m; - /** File's last modified date, year field. */ - int date_y; - - /** A pointer to the folder that contains this file. */ - struct mscabd_folder *folder; - - /** The uncompressed offset of this file in its folder. */ - unsigned int offset; -}; - -/** mscabd_file::attribs attribute: file is read-only. */ -#define MSCAB_ATTRIB_RDONLY (0x01) -/** mscabd_file::attribs attribute: file is hidden. */ -#define MSCAB_ATTRIB_HIDDEN (0x02) -/** mscabd_file::attribs attribute: file is an operating system file. */ -#define MSCAB_ATTRIB_SYSTEM (0x04) -/** mscabd_file::attribs attribute: file is "archived". */ -#define MSCAB_ATTRIB_ARCH (0x20) -/** mscabd_file::attribs attribute: file is an executable program. */ -#define MSCAB_ATTRIB_EXEC (0x40) -/** mscabd_file::attribs attribute: filename is UTF8, not ISO-8859-1. */ -#define MSCAB_ATTRIB_UTF_NAME (0x80) - -/** mscab_decompressor::set_param() parameter: search buffer size. */ -#define MSCABD_PARAM_SEARCHBUF (0) -/** mscab_decompressor::set_param() parameter: repair MS-ZIP streams? */ -#define MSCABD_PARAM_FIXMSZIP (1) -/** mscab_decompressor::set_param() parameter: size of decompression buffer */ -#define MSCABD_PARAM_DECOMPBUF (2) -/** mscab_decompressor::set_param() parameter: salvage data from bad cabinets? - * If enabled, open() will skip file with bad folder indices or filenames - * rather than reject the whole cabinet, and extract() will limit rather than - * reject files with invalid offsets and lengths, and bad data block checksums - * will be ignored. Available only in CAB decoder version 2 and above. - */ -#define MSCABD_PARAM_SALVAGE (3) - -/** TODO */ -struct mscab_compressor { - int dummy; -}; - -/** - * A decompressor for .CAB (Microsoft Cabinet) files - * - * All fields are READ ONLY. - * - * @see mspack_create_cab_decompressor(), mspack_destroy_cab_decompressor() - */ -struct mscab_decompressor { - /** - * Opens a cabinet file and reads its contents. - * - * If the file opened is a valid cabinet file, all headers will be read - * and a mscabd_cabinet structure will be returned, with a full list of - * folders and files. - * - * In the case of an error occuring, NULL is returned and the error code - * is available from last_error(). - * - * The filename pointer should be considered "in use" until close() is - * called on the cabinet. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @param filename the filename of the cabinet file. This is passed - * directly to mspack_system::open(). - * @return a pointer to a mscabd_cabinet structure, or NULL on failure - * @see close(), search(), last_error() - */ - struct mscabd_cabinet * (*open) (struct mscab_decompressor *self, - const char *filename); - - /** - * Closes a previously opened cabinet or cabinet set. - * - * This closes a cabinet, all cabinets associated with it via the - * mscabd_cabinet::next, mscabd_cabinet::prevcab and - * mscabd_cabinet::nextcab pointers, and all folders and files. All - * memory used by these entities is freed. - * - * The cabinet pointer is now invalid and cannot be used again. All - * mscabd_folder and mscabd_file pointers from that cabinet or cabinet - * set are also now invalid, and cannot be used again. - * - * If the cabinet pointer given was created using search(), it MUST be - * the cabinet pointer returned by search() and not one of the later - * cabinet pointers further along the mscabd_cabinet::next chain. - - * If extra cabinets have been added using append() or prepend(), these - * will all be freed, even if the cabinet pointer given is not the first - * cabinet in the set. Do NOT close() more than one cabinet in the set. - * - * The mscabd_cabinet::filename is not freed by the library, as it is - * not allocated by the library. The caller should free this itself if - * necessary, before it is lost forever. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @param cab the cabinet to close - * @see open(), search(), append(), prepend() - */ - void (*close)(struct mscab_decompressor *self, - struct mscabd_cabinet *cab); - - /** - * Searches a regular file for embedded cabinets. - * - * This opens a normal file with the given filename and will search the - * entire file for embedded cabinet files - * - * If any cabinets are found, the equivalent of open() is called on each - * potential cabinet file at the offset it was found. All successfully - * open()ed cabinets are kept in a list. - * - * The first cabinet found will be returned directly as the result of - * this method. Any further cabinets found will be chained in a list - * using the mscabd_cabinet::next field. - * - * In the case of an error occuring anywhere other than the simulated - * open(), NULL is returned and the error code is available from - * last_error(). - * - * If no error occurs, but no cabinets can be found in the file, NULL is - * returned and last_error() returns MSPACK_ERR_OK. - * - * The filename pointer should be considered in use until close() is - * called on the cabinet. - * - * close() should only be called on the result of search(), not on any - * subsequent cabinets in the mscabd_cabinet::next chain. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @param filename the filename of the file to search for cabinets. This - * is passed directly to mspack_system::open(). - * @return a pointer to a mscabd_cabinet structure, or NULL - * @see close(), open(), last_error() - */ - struct mscabd_cabinet * (*search) (struct mscab_decompressor *self, - const char *filename); - - /** - * Appends one mscabd_cabinet to another, forming or extending a cabinet - * set. - * - * This will attempt to append one cabinet to another such that - * (cab->nextcab == nextcab) && (nextcab->prevcab == cab) and - * any folders split between the two cabinets are merged. - * - * The cabinets MUST be part of a cabinet set -- a cabinet set is a - * cabinet that spans more than one physical cabinet file on disk -- and - * must be appropriately matched. - * - * It can be determined if a cabinet has further parts to load by - * examining the mscabd_cabinet::flags field: - * - * - if (flags & MSCAB_HDR_PREVCAB) is non-zero, there is a - * predecessor cabinet to open() and prepend(). Its MS-DOS - * case-insensitive filename is mscabd_cabinet::prevname - * - if (flags & MSCAB_HDR_NEXTCAB) is non-zero, there is a - * successor cabinet to open() and append(). Its MS-DOS case-insensitive - * filename is mscabd_cabinet::nextname - * - * If the cabinets do not match, an error code will be returned. Neither - * cabinet has been altered, and both should be closed seperately. - * - * Files and folders in a cabinet set are a single entity. All cabinets - * in a set use the same file list, which is updated as cabinets in the - * set are added. All pointers to mscabd_folder and mscabd_file - * structures in either cabinet must be discarded and re-obtained after - * merging. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @param cab the cabinet which will be appended to, - * predecessor of nextcab - * @param nextcab the cabinet which will be appended, - * successor of cab - * @return an error code, or MSPACK_ERR_OK if successful - * @see prepend(), open(), close() - */ - int (*append) (struct mscab_decompressor *self, - struct mscabd_cabinet *cab, - struct mscabd_cabinet *nextcab); - - /** - * Prepends one mscabd_cabinet to another, forming or extending a - * cabinet set. - * - * This will attempt to prepend one cabinet to another, such that - * (cab->prevcab == prevcab) && (prevcab->nextcab == cab). In - * all other respects, it is identical to append(). See append() for the - * full documentation. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @param cab the cabinet which will be prepended to, - * successor of prevcab - * @param prevcab the cabinet which will be prepended, - * predecessor of cab - * @return an error code, or MSPACK_ERR_OK if successful - * @see append(), open(), close() - */ - int (*prepend) (struct mscab_decompressor *self, - struct mscabd_cabinet *cab, - struct mscabd_cabinet *prevcab); - - /** - * Extracts a file from a cabinet or cabinet set. - * - * This extracts a compressed file in a cabinet and writes it to the given - * filename. - * - * The MS-DOS filename of the file, mscabd_file::filename, is NOT USED - * by extract(). The caller must examine this MS-DOS filename, copy and - * change it as necessary, create directories as necessary, and provide - * the correct filename as a parameter, which will be passed unchanged - * to the decompressor's mspack_system::open() - * - * If the file belongs to a split folder in a multi-part cabinet set, - * and not enough parts of the cabinet set have been loaded and appended - * or prepended, an error will be returned immediately. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @param file the file to be decompressed - * @param filename the filename of the file being written to - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*extract)(struct mscab_decompressor *self, - struct mscabd_file *file, - const char *filename); - - /** - * Sets a CAB decompression engine parameter. - * - * The following parameters are defined: - * - #MSCABD_PARAM_SEARCHBUF: How many bytes should be allocated as a - * buffer when using search()? The minimum value is 4. The default - * value is 32768. - * - #MSCABD_PARAM_FIXMSZIP: If non-zero, extract() will ignore bad - * checksums and recover from decompression errors in MS-ZIP - * compressed folders. The default value is 0 (don't recover). - * - #MSCABD_PARAM_DECOMPBUF: How many bytes should be used as an input - * bit buffer by decompressors? The minimum value is 4. The default - * value is 4096. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @param param the parameter to set - * @param value the value to set the parameter to - * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there - * is a problem with either parameter or value. - * @see search(), extract() - */ - int (*set_param)(struct mscab_decompressor *self, - int param, - int value); - - /** - * Returns the error code set by the most recently called method. - * - * This is useful for open() and search(), which do not return an error - * code directly. - * - * @param self a self-referential pointer to the mscab_decompressor - * instance being called - * @return the most recent error code - * @see open(), search() - */ - int (*last_error)(struct mscab_decompressor *self); -}; - -/* --- support for .CHM (HTMLHelp) file format ----------------------------- */ - -/** - * A structure which represents a file to be placed in a CHM helpfile. - * - * A contiguous array of these structures should be passed to - * mschm_compressor::generate(). The array list is terminated with an - * entry whose mschmc_file::section field is set to #MSCHMC_ENDLIST, the - * other fields in this entry are ignored. - */ -struct mschmc_file { - /** One of #MSCHMC_ENDLIST, #MSCHMC_UNCOMP or #MSCHMC_MSCOMP. */ - int section; - - /** The filename of the source file that will be added to the CHM. This - * is passed directly to mspack_system::open(). */ - const char *filename; - - /** The full path and filename of the file within the CHM helpfile, a - * UTF-1 encoded null-terminated string. */ - char *chm_filename; - - /** The length of the file, in bytes. This will be adhered to strictly - * and a read error will be issued if this many bytes cannot be read - * from the real file at CHM generation time. */ - off_t length; -}; - -/** - * A structure which represents a section of a CHM helpfile. - * - * All fields are READ ONLY. - * - * Not used directly, but used as a generic base type for - * mschmd_sec_uncompressed and mschmd_sec_mscompressed. - */ -struct mschmd_section { - /** A pointer to the CHM helpfile that contains this section. */ - struct mschmd_header *chm; - - /** - * The section ID. Either 0 for the uncompressed section - * mschmd_sec_uncompressed, or 1 for the LZX compressed section - * mschmd_sec_mscompressed. No other section IDs are known. - */ - unsigned int id; -}; - -/** - * A structure which represents the uncompressed section of a CHM helpfile. - * - * All fields are READ ONLY. - */ -struct mschmd_sec_uncompressed { - /** Generic section data. */ - struct mschmd_section base; - - /** The file offset of where this section begins in the CHM helpfile. */ - off_t offset; -}; - -/** - * A structure which represents the LZX compressed section of a CHM helpfile. - * - * All fields are READ ONLY. - */ -struct mschmd_sec_mscompressed { - /** Generic section data. */ - struct mschmd_section base; - - /** A pointer to the meta-file which represents all LZX compressed data. */ - struct mschmd_file *content; - - /** A pointer to the file which contains the LZX control data. */ - struct mschmd_file *control; - - /** A pointer to the file which contains the LZX reset table. */ - struct mschmd_file *rtable; - - /** A pointer to the file which contains the LZX span information. - * Available only in CHM decoder version 2 and above. - */ - struct mschmd_file *spaninfo; -}; - -/** - * A structure which represents a CHM helpfile. - * - * All fields are READ ONLY. - */ -struct mschmd_header { - /** The version of the CHM file format used in this file. */ - unsigned int version; - - /** - * The "timestamp" of the CHM helpfile. - * - * It is the lower 32 bits of a 64-bit value representing the number of - * centiseconds since 1601-01-01 00:00:00 UTC, plus 42. It is not useful - * as a timestamp, but it is useful as a semi-unique ID. - */ - unsigned int timestamp; - - /** - * The default Language and Country ID (LCID) of the user who ran the - * HTMLHelp Compiler. This is not the language of the CHM file itself. - */ - unsigned int language; - - /** - * The filename of the CHM helpfile. This is given by the library user - * and may be in any format. - */ - const char *filename; - - /** The length of the CHM helpfile, in bytes. */ - off_t length; - - /** A list of all non-system files in the CHM helpfile. */ - struct mschmd_file *files; - - /** - * A list of all system files in the CHM helpfile. - * - * System files are files which begin with "::". They are meta-files - * generated by the CHM creation process. - */ - struct mschmd_file *sysfiles; - - /** The section 0 (uncompressed) data in this CHM helpfile. */ - struct mschmd_sec_uncompressed sec0; - - /** The section 1 (MSCompressed) data in this CHM helpfile. */ - struct mschmd_sec_mscompressed sec1; - - /** The file offset of the first PMGL/PMGI directory chunk. */ - off_t dir_offset; - - /** The number of PMGL/PMGI directory chunks in this CHM helpfile. */ - unsigned int num_chunks; - - /** The size of each PMGL/PMGI chunk, in bytes. */ - unsigned int chunk_size; - - /** The "density" of the quick-reference section in PMGL/PMGI chunks. */ - unsigned int density; - - /** The depth of the index tree. - * - * - if 1, there are no PMGI chunks, only PMGL chunks. - * - if 2, there is 1 PMGI chunk. All chunk indices point to PMGL chunks. - * - if 3, the root PMGI chunk points to secondary PMGI chunks, which in - * turn point to PMGL chunks. - * - and so on... - */ - unsigned int depth; - - /** - * The number of the root PMGI chunk. - * - * If there is no index in the CHM helpfile, this will be 0xFFFFFFFF. - */ - unsigned int index_root; - - /** - * The number of the first PMGL chunk. Usually zero. - * Available only in CHM decoder version 2 and above. - */ - unsigned int first_pmgl; - - /** - * The number of the last PMGL chunk. Usually num_chunks-1. - * Available only in CHM decoder version 2 and above. - */ - unsigned int last_pmgl; - - /** - * A cache of loaded chunks, filled in by mschm_decoder::fast_find(). - * Available only in CHM decoder version 2 and above. - */ - unsigned char **chunk_cache; -}; - -/** - * A structure which represents a file stored in a CHM helpfile. - * - * All fields are READ ONLY. - */ -struct mschmd_file { - /** - * A pointer to the next file in the list, or NULL if this is the final - * file. - */ - struct mschmd_file *next; - - /** - * A pointer to the section that this file is located in. Indirectly, - * it also points to the CHM helpfile the file is located in. - */ - struct mschmd_section *section; - - /** The offset within the section data that this file is located at. */ - off_t offset; - - /** The length of this file, in bytes */ - off_t length; - - /** The filename of this file -- a null terminated string in UTF-8. */ - char *filename; -}; - -/** mschmc_file::section value: end of CHM file list */ -#define MSCHMC_ENDLIST (0) -/** mschmc_file::section value: this file is in the Uncompressed section */ -#define MSCHMC_UNCOMP (1) -/** mschmc_file::section value: this file is in the MSCompressed section */ -#define MSCHMC_MSCOMP (2) - -/** mschm_compressor::set_param() parameter: "timestamp" header */ -#define MSCHMC_PARAM_TIMESTAMP (0) -/** mschm_compressor::set_param() parameter: "language" header */ -#define MSCHMC_PARAM_LANGUAGE (1) -/** mschm_compressor::set_param() parameter: LZX window size */ -#define MSCHMC_PARAM_LZXWINDOW (2) -/** mschm_compressor::set_param() parameter: intra-chunk quickref density */ -#define MSCHMC_PARAM_DENSITY (3) -/** mschm_compressor::set_param() parameter: whether to create indices */ -#define MSCHMC_PARAM_INDEX (4) - -/** - * A compressor for .CHM (Microsoft HTMLHelp) files. - * - * All fields are READ ONLY. - * - * @see mspack_create_chm_compressor(), mspack_destroy_chm_compressor() - */ -struct mschm_compressor { - /** - * Generates a CHM help file. - * - * The help file will contain up to two sections, an Uncompressed - * section and potentially an MSCompressed (LZX compressed) - * section. - * - * While the contents listing of a CHM file is always in lexical order, - * the file list passed in will be taken as the correct order for files - * within the sections. It is in your interest to place similar files - * together for better compression. - * - * There are two modes of generation, to use a temporary file or not to - * use one. See use_temporary_file() for the behaviour of generate() in - * these two different modes. - * - * @param self a self-referential pointer to the mschm_compressor - * instance being called - * @param file_list an array of mschmc_file structures, terminated - * with an entry whose mschmc_file::section field is - * #MSCHMC_ENDLIST. The order of the list is - * preserved within each section. The length of any - * mschmc_file::chm_filename string cannot exceed - * roughly 4096 bytes. Each source file must be able - * to supply as many bytes as given in the - * mschmc_file::length field. - * @param output_file the file to write the generated CHM helpfile to. - * This is passed directly to mspack_system::open() - * @return an error code, or MSPACK_ERR_OK if successful - * @see use_temporary_file() set_param() - */ - int (*generate)(struct mschm_compressor *self, - struct mschmc_file file_list[], - const char *output_file); - - /** - * Specifies whether a temporary file is used during CHM generation. - * - * The CHM file format includes data about the compressed section (such - * as its overall size) that is stored in the output CHM file prior to - * the compressed section itself. This unavoidably requires that the - * compressed section has to be generated, before these details can be - * set. There are several ways this can be handled. Firstly, the - * compressed section could be generated entirely in memory before - * writing any of the output CHM file. This approach is not used in - * libmspack, as the compressed section can exceed the addressable - * memory space on most architectures. - * - * libmspack has two options, either to write these unknowable sections - * with blank data, generate the compressed section, then re-open the - * output file for update once the compressed section has been - * completed, or to write the compressed section to a temporary file, - * then write the entire output file at once, performing a simple - * file-to-file copy for the compressed section. - * - * The simple solution of buffering the entire compressed section in - * memory can still be used, if desired. As the temporary file's - * filename is passed directly to mspack_system::open(), it is possible - * for a custom mspack_system implementation to hold this file in memory, - * without writing to a disk. - * - * If a temporary file is set, generate() performs the following - * sequence of events: the temporary file is opened for writing, the - * compression algorithm writes to the temporary file, the temporary - * file is closed. Then the output file is opened for writing and the - * temporary file is re-opened for reading. The output file is written - * and the temporary file is read from. Both files are then closed. The - * temporary file itself is not deleted. If that is desired, the - * temporary file should be deleted after the completion of generate(), - * if it exists. - * - * If a temporary file is set not to be used, generate() performs the - * following sequence of events: the output file is opened for writing, - * then it is written and closed. The output file is then re-opened for - * update, the appropriate sections are seek()ed to and re-written, then - * the output file is closed. - * - * @param self a self-referential pointer to the - * mschm_compressor instance being called - * @param use_temp_file non-zero if the temporary file should be used, - * zero if the temporary file should not be used. - * @param temp_file a file to temporarily write compressed data to, - * before opening it for reading and copying the - * contents to the output file. This is passed - * directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - * @see generate() - */ - int (*use_temporary_file)(struct mschm_compressor *self, - int use_temp_file, - const char *temp_file); - /** - * Sets a CHM compression engine parameter. - * - * The following parameters are defined: - - * - #MSCHMC_PARAM_TIMESTAMP: Sets the "timestamp" of the CHM file - * generated. This is not a timestamp, see mschmd_header::timestamp - * for a description. If this timestamp is 0, generate() will use its - * own algorithm for making a unique ID, based on the lengths and - * names of files in the CHM itself. Defaults to 0, any value between - * 0 and (2^32)-1 is valid. - * - #MSCHMC_PARAM_LANGUAGE: Sets the "language" of the CHM file - * generated. This is not the language used in the CHM file, but the - * language setting of the user who ran the HTMLHelp compiler. It - * defaults to 0x0409. The valid range is between 0x0000 and 0x7F7F. - * - #MSCHMC_PARAM_LZXWINDOW: Sets the size of the LZX history window, - * which is also the interval at which the compressed data stream can be - * randomly accessed. The value is not a size in bytes, but a power of - * two. The default value is 16 (which makes the window 2^16 bytes, or - * 64 kilobytes), the valid range is from 15 (32 kilobytes) to 21 (2 - * megabytes). - * - #MSCHMC_PARAM_DENSITY: Sets the "density" of quick reference - * entries stored at the end of directory listing chunk. Each chunk is - * 4096 bytes in size, and contains as many file entries as there is - * room for. At the other end of the chunk, a list of "quick reference" - * pointers is included. The offset of every 'N'th file entry is given a - * quick reference, where N = (2^density) + 1. The default density is - * 2. The smallest density is 0 (N=2), the maximum is 10 (N=1025). As - * each file entry requires at least 5 bytes, the maximum number of - * entries in a single chunk is roughly 800, so the maximum value 10 - * can be used to indicate there are no quickrefs at all. - * - #MSCHMC_PARAM_INDEX: Sets whether or not to include quick lookup - * index chunk(s), in addition to normal directory listing chunks. A - * value of zero means no index chunks will be created, a non-zero value - * means index chunks will be created. The default is zero, "don't - * create an index". - * - * @param self a self-referential pointer to the mschm_compressor - * instance being called - * @param param the parameter to set - * @param value the value to set the parameter to - * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there - * is a problem with either parameter or value. - * @see generate() - */ - int (*set_param)(struct mschm_compressor *self, - int param, - int value); - - /** - * Returns the error code set by the most recently called method. - * - * @param self a self-referential pointer to the mschm_compressor - * instance being called - * @return the most recent error code - * @see set_param(), generate() - */ - int (*last_error)(struct mschm_compressor *self); -}; - -/** - * A decompressor for .CHM (Microsoft HTMLHelp) files - * - * All fields are READ ONLY. - * - * @see mspack_create_chm_decompressor(), mspack_destroy_chm_decompressor() - */ -struct mschm_decompressor { - /** - * Opens a CHM helpfile and reads its contents. - * - * If the file opened is a valid CHM helpfile, all headers will be read - * and a mschmd_header structure will be returned, with a full list of - * files. - * - * In the case of an error occuring, NULL is returned and the error code - * is available from last_error(). - * - * The filename pointer should be considered "in use" until close() is - * called on the CHM helpfile. - * - * @param self a self-referential pointer to the mschm_decompressor - * instance being called - * @param filename the filename of the CHM helpfile. This is passed - * directly to mspack_system::open(). - * @return a pointer to a mschmd_header structure, or NULL on failure - * @see close() - */ - struct mschmd_header *(*open)(struct mschm_decompressor *self, - const char *filename); - - /** - * Closes a previously opened CHM helpfile. - * - * This closes a CHM helpfile, frees the mschmd_header and all - * mschmd_file structures associated with it (if any). This works on - * both helpfiles opened with open() and helpfiles opened with - * fast_open(). - * - * The CHM header pointer is now invalid and cannot be used again. All - * mschmd_file pointers referencing that CHM are also now invalid, and - * cannot be used again. - * - * @param self a self-referential pointer to the mschm_decompressor - * instance being called - * @param chm the CHM helpfile to close - * @see open(), fast_open() - */ - void (*close)(struct mschm_decompressor *self, - struct mschmd_header *chm); - - /** - * Extracts a file from a CHM helpfile. - * - * This extracts a file from a CHM helpfile and writes it to the given - * filename. The filename of the file, mscabd_file::filename, is not - * used by extract(), but can be used by the caller as a guide for - * constructing an appropriate filename. - * - * This method works both with files found in the mschmd_header::files - * and mschmd_header::sysfiles list and mschmd_file structures generated - * on the fly by fast_find(). - * - * @param self a self-referential pointer to the mschm_decompressor - * instance being called - * @param file the file to be decompressed - * @param filename the filename of the file being written to - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*extract)(struct mschm_decompressor *self, - struct mschmd_file *file, - const char *filename); - - /** - * Returns the error code set by the most recently called method. - * - * This is useful for open() and fast_open(), which do not return an - * error code directly. - * - * @param self a self-referential pointer to the mschm_decompressor - * instance being called - * @return the most recent error code - * @see open(), extract() - */ - int (*last_error)(struct mschm_decompressor *self); - - /** - * Opens a CHM helpfile quickly. - * - * If the file opened is a valid CHM helpfile, only essential headers - * will be read. A mschmd_header structure will be still be returned, as - * with open(), but the mschmd_header::files field will be NULL. No - * files details will be automatically read. The fast_find() method - * must be used to obtain file details. - * - * In the case of an error occuring, NULL is returned and the error code - * is available from last_error(). - * - * The filename pointer should be considered "in use" until close() is - * called on the CHM helpfile. - * - * @param self a self-referential pointer to the mschm_decompressor - * instance being called - * @param filename the filename of the CHM helpfile. This is passed - * directly to mspack_system::open(). - * @return a pointer to a mschmd_header structure, or NULL on failure - * @see open(), close(), fast_find(), extract() - */ - struct mschmd_header *(*fast_open)(struct mschm_decompressor *self, - const char *filename); - - /** - * Finds file details quickly. - * - * Instead of reading all CHM helpfile headers and building a list of - * files, fast_open() and fast_find() are intended for finding file - * details only when they are needed. The CHM file format includes an - * on-disk file index to allow this. - * - * Given a case-sensitive filename, fast_find() will search the on-disk - * index for that file. - * - * If the file was found, the caller-provided mschmd_file structure will - * be filled out like so: - * - section: the correct value for the found file - * - offset: the correct value for the found file - * - length: the correct value for the found file - * - all other structure elements: NULL or 0 - * - * If the file was not found, MSPACK_ERR_OK will still be returned as the - * result, but the caller-provided structure will be filled out like so: - * - section: NULL - * - offset: 0 - * - length: 0 - * - all other structure elements: NULL or 0 - * - * This method is intended to be used in conjunction with CHM helpfiles - * opened with fast_open(), but it also works with helpfiles opened - * using the regular open(). - * - * @param self a self-referential pointer to the mschm_decompressor - * instance being called - * @param chm the CHM helpfile to search for the file - * @param filename the filename of the file to search for - * @param f_ptr a pointer to a caller-provded mschmd_file structure - * @param f_size sizeof(struct mschmd_file) - * @return an error code, or MSPACK_ERR_OK if successful - * @see open(), close(), fast_find(), extract() - */ - int (*fast_find)(struct mschm_decompressor *self, - struct mschmd_header *chm, - const char *filename, - struct mschmd_file *f_ptr, - int f_size); -}; - -/* --- support for .LIT (EBook) file format -------------------------------- */ - -/** TODO */ -struct mslit_compressor { - int dummy; -}; - -/** TODO */ -struct mslit_decompressor { - int dummy; -}; - - -/* --- support for .HLP (MS Help) file format ------------------------------ */ - -/** TODO */ -struct mshlp_compressor { - int dummy; -}; - -/** TODO */ -struct mshlp_decompressor { - int dummy; -}; - - -/* --- support for SZDD file format ---------------------------------------- */ - -/** msszdd_compressor::set_param() parameter: the missing character */ -#define MSSZDDC_PARAM_MISSINGCHAR (0) - -/** msszddd_header::format value - a regular SZDD file */ -#define MSSZDD_FMT_NORMAL (0) - -/** msszddd_header::format value - a special QBasic SZDD file */ -#define MSSZDD_FMT_QBASIC (1) - -/** - * A structure which represents an SZDD compressed file. - * - * All fields are READ ONLY. - */ -struct msszddd_header { - /** The file format; either #MSSZDD_FMT_NORMAL or #MSSZDD_FMT_QBASIC */ - int format; - - /** The amount of data in the SZDD file once uncompressed. */ - off_t length; - - /** - * The last character in the filename, traditionally replaced with an - * underscore to show the file is compressed. The null character is used - * to show that this character has not been stored (e.g. because the - * filename is not known). Generally, only characters that may appear in - * an MS-DOS filename (except ".") are valid. - */ - char missing_char; -}; - -/** - * A compressor for the SZDD file format. - * - * All fields are READ ONLY. - * - * @see mspack_create_szdd_compressor(), mspack_destroy_szdd_compressor() - */ -struct msszdd_compressor { - /** - * Reads an input file and creates a compressed output file in the - * SZDD compressed file format. The SZDD compression format is quick - * but gives poor compression. It is possible for the compressed output - * file to be larger than the input file. - * - * Conventionally, SZDD compressed files have the final character in - * their filename replaced with an underscore, to show they are - * compressed. The missing character is stored in the compressed file - * itself. This is due to the restricted filename conventions of MS-DOS, - * most operating systems, such as UNIX, simply append another file - * extension to the existing filename. As mspack does not deal with - * filenames, this is left up to you. If you wish to set the missing - * character stored in the file header, use set_param() with the - * #MSSZDDC_PARAM_MISSINGCHAR parameter. - * - * "Stream" compression (where the length of the input data is not - * known) is not possible. The length of the input data is stored in the - * header of the SZDD file and must therefore be known before any data - * is compressed. Due to technical limitations of the file format, the - * maximum size of uncompressed file that will be accepted is 2147483647 - * bytes. - * - * @param self a self-referential pointer to the msszdd_compressor - * instance being called - * @param input the name of the file to compressed. This is passed - * passed directly to mspack_system::open() - * @param output the name of the file to write compressed data to. - * This is passed directly to mspack_system::open(). - * @param length the length of the uncompressed file, or -1 to indicate - * that this should be determined automatically by using - * mspack_system::seek() on the input file. - * @return an error code, or MSPACK_ERR_OK if successful - * @see set_param() - */ - int (*compress)(struct msszdd_compressor *self, - const char *input, - const char *output, - off_t length); - - /** - * Sets an SZDD compression engine parameter. - * - * The following parameters are defined: - - * - #MSSZDDC_PARAM_CHARACTER: the "missing character", the last character - * in the uncompressed file's filename, which is traditionally replaced - * with an underscore to show the file is compressed. Traditionally, - * this can only be a character that is a valid part of an MS-DOS, - * filename, but libmspack permits any character between 0x00 and 0xFF - * to be stored. 0x00 is the default, and it represents "no character - * stored". - * - * @param self a self-referential pointer to the msszdd_compressor - * instance being called - * @param param the parameter to set - * @param value the value to set the parameter to - * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there - * is a problem with either parameter or value. - * @see compress() - */ - int (*set_param)(struct msszdd_compressor *self, - int param, - int value); - - /** - * Returns the error code set by the most recently called method. - * - * @param self a self-referential pointer to the msszdd_compressor - * instance being called - * @return the most recent error code - * @see compress() - */ - int (*last_error)(struct mschm_decompressor *self); -}; - -/** - * A decompressor for SZDD compressed files. - * - * All fields are READ ONLY. - * - * @see mspack_create_szdd_decompressor(), mspack_destroy_szdd_decompressor() - */ -struct msszdd_decompressor { - /** - * Opens a SZDD file and reads the header. - * - * If the file opened is a valid SZDD file, all headers will be read and - * a msszddd_header structure will be returned. - * - * In the case of an error occuring, NULL is returned and the error code - * is available from last_error(). - * - * The filename pointer should be considered "in use" until close() is - * called on the SZDD file. - * - * @param self a self-referential pointer to the msszdd_decompressor - * instance being called - * @param filename the filename of the SZDD compressed file. This is - * passed directly to mspack_system::open(). - * @return a pointer to a msszddd_header structure, or NULL on failure - * @see close() - */ - struct msszddd_header *(*open)(struct msszdd_decompressor *self, - const char *filename); - - /** - * Closes a previously opened SZDD file. - * - * This closes a SZDD file and frees the msszddd_header associated with - * it. - * - * The SZDD header pointer is now invalid and cannot be used again. - * - * @param self a self-referential pointer to the msszdd_decompressor - * instance being called - * @param szdd the SZDD file to close - * @see open() - */ - void (*close)(struct msszdd_decompressor *self, - struct msszddd_header *szdd); - - /** - * Extracts the compressed data from a SZDD file. - * - * This decompresses the compressed SZDD data stream and writes it to - * an output file. - * - * @param self a self-referential pointer to the msszdd_decompressor - * instance being called - * @param szdd the SZDD file to extract data from - * @param filename the filename to write the decompressed data to. This - * is passed directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*extract)(struct msszdd_decompressor *self, - struct msszddd_header *szdd, - const char *filename); - - /** - * Decompresses an SZDD file to an output file in one step. - * - * This opens an SZDD file as input, reads the header, then decompresses - * the compressed data immediately to an output file, finally closing - * both the input and output file. It is more convenient to use than - * open() then extract() then close(), if you do not need to know the - * SZDD output size or missing character. - * - * @param self a self-referential pointer to the msszdd_decompressor - * instance being called - * @param input the filename of the input SZDD file. This is passed - * directly to mspack_system::open(). - * @param output the filename to write the decompressed data to. This - * is passed directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*decompress)(struct msszdd_decompressor *self, - const char *input, - const char *output); - - /** - * Returns the error code set by the most recently called method. - * - * This is useful for open() which does not return an - * error code directly. - * - * @param self a self-referential pointer to the msszdd_decompressor - * instance being called - * @return the most recent error code - * @see open(), extract(), decompress() - */ - int (*last_error)(struct msszdd_decompressor *self); -}; - -/* --- support for KWAJ file format ---------------------------------------- */ - -/** mskwaj_compressor::set_param() parameter: compression type */ -#define MSKWAJC_PARAM_COMP_TYPE (0) - -/** mskwaj_compressor::set_param() parameter: include the length of the - * uncompressed file in the header? - */ -#define MSKWAJC_PARAM_INCLUDE_LENGTH (1) - -/** KWAJ compression type: no compression. */ -#define MSKWAJ_COMP_NONE (0) -/** KWAJ compression type: no compression, 0xFF XOR "encryption". */ -#define MSKWAJ_COMP_XOR (1) -/** KWAJ compression type: LZSS (same method as SZDD) */ -#define MSKWAJ_COMP_SZDD (2) -/** KWAJ compression type: LZ+Huffman compression */ -#define MSKWAJ_COMP_LZH (3) -/** KWAJ compression type: MSZIP */ -#define MSKWAJ_COMP_MSZIP (4) - -/** KWAJ optional header flag: decompressed file length is included */ -#define MSKWAJ_HDR_HASLENGTH (0x01) - -/** KWAJ optional header flag: unknown 2-byte structure is included */ -#define MSKWAJ_HDR_HASUNKNOWN1 (0x02) - -/** KWAJ optional header flag: unknown multi-sized structure is included */ -#define MSKWAJ_HDR_HASUNKNOWN2 (0x04) - -/** KWAJ optional header flag: file name (no extension) is included */ -#define MSKWAJ_HDR_HASFILENAME (0x08) - -/** KWAJ optional header flag: file extension is included */ -#define MSKWAJ_HDR_HASFILEEXT (0x10) - -/** KWAJ optional header flag: extra text is included */ -#define MSKWAJ_HDR_HASEXTRATEXT (0x20) - -/** - * A structure which represents an KWAJ compressed file. - * - * All fields are READ ONLY. - */ -struct mskwajd_header { - /** The compression type; should be one of #MSKWAJ_COMP_NONE, - * #MSKWAJ_COMP_XOR, #MSKWAJ_COMP_SZDD or #MSKWAJ_COMP_LZH - */ - unsigned short comp_type; - - /** The offset in the file where the compressed data stream begins */ - off_t data_offset; - - /** Flags indicating which optional headers were included. */ - int headers; - - /** The amount of uncompressed data in the file, or 0 if not present. */ - off_t length; - - /** output filename, or NULL if not present */ - char *filename; - - /** extra uncompressed data (usually text) in the header. - * This data can contain nulls so use extra_length to get the size. - */ - char *extra; - - /** length of extra uncompressed data in the header */ - unsigned short extra_length; -}; - -/** - * A compressor for the KWAJ file format. - * - * All fields are READ ONLY. - * - * @see mspack_create_kwaj_compressor(), mspack_destroy_kwaj_compressor() - */ -struct mskwaj_compressor { - /** - * Reads an input file and creates a compressed output file in the - * KWAJ compressed file format. The KWAJ compression format is quick - * but gives poor compression. It is possible for the compressed output - * file to be larger than the input file. - * - * @param self a self-referential pointer to the mskwaj_compressor - * instance being called - * @param input the name of the file to compressed. This is passed - * passed directly to mspack_system::open() - * @param output the name of the file to write compressed data to. - * This is passed directly to mspack_system::open(). - * @param length the length of the uncompressed file, or -1 to indicate - * that this should be determined automatically by using - * mspack_system::seek() on the input file. - * @return an error code, or MSPACK_ERR_OK if successful - * @see set_param() - */ - int (*compress)(struct mskwaj_compressor *self, - const char *input, - const char *output, - off_t length); - - /** - * Sets an KWAJ compression engine parameter. - * - * The following parameters are defined: - * - * - #MSKWAJC_PARAM_COMP_TYPE: the compression method to use. Must - * be one of #MSKWAJC_COMP_NONE, #MSKWAJC_COMP_XOR, #MSKWAJ_COMP_SZDD - * or #MSKWAJ_COMP_LZH. The default is #MSKWAJ_COMP_LZH. - * - * - #MSKWAJC_PARAM_INCLUDE_LENGTH: a boolean; should the compressed - * output file should include the uncompressed length of the input - * file in the header? This adds 4 bytes to the size of the output - * file. A value of zero says "no", non-zero says "yes". The default - * is "no". - * - * @param self a self-referential pointer to the mskwaj_compressor - * instance being called - * @param param the parameter to set - * @param value the value to set the parameter to - * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there - * is a problem with either parameter or value. - * @see generate() - */ - int (*set_param)(struct mskwaj_compressor *self, - int param, - int value); - - - /** - * Sets the original filename of the file before compression, - * which will be stored in the header of the output file. - * - * The filename should be a null-terminated string, it must be an - * MS-DOS "8.3" type filename (up to 8 bytes for the filename, then - * optionally a "." and up to 3 bytes for a filename extension). - * - * If NULL is passed as the filename, no filename is included in the - * header. This is the default. - * - * @param self a self-referential pointer to the mskwaj_compressor - * instance being called - * @param filename the original filename to use - * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if the - * filename is too long - */ - int (*set_filename)(struct mskwaj_compressor *self, - const char *filename); - - /** - * Sets arbitrary data that will be stored in the header of the - * output file, uncompressed. It can be up to roughly 64 kilobytes, - * as the overall size of the header must not exceed 65535 bytes. - * The data can contain null bytes if desired. - * - * If NULL is passed as the data pointer, or zero is passed as the - * length, no extra data is included in the header. This is the - * default. - * - * @param self a self-referential pointer to the mskwaj_compressor - * instance being called - * @param data a pointer to the data to be stored in the header - * @param bytes the length of the data in bytes - * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS extra data - * is too long - */ - int (*set_extra_data)(struct mskwaj_compressor *self, - void *data, - size_t bytes); - - /** - * Returns the error code set by the most recently called method. - * - * @param self a self-referential pointer to the mskwaj_compressor - * instance being called - * @return the most recent error code - * @see compress() - */ - int (*last_error)(struct mschm_decompressor *self); -}; - -/** - * A decompressor for KWAJ compressed files. - * - * All fields are READ ONLY. - * - * @see mspack_create_kwaj_decompressor(), mspack_destroy_kwaj_decompressor() - */ -struct mskwaj_decompressor { - /** - * Opens a KWAJ file and reads the header. - * - * If the file opened is a valid KWAJ file, all headers will be read and - * a mskwajd_header structure will be returned. - * - * In the case of an error occuring, NULL is returned and the error code - * is available from last_error(). - * - * The filename pointer should be considered "in use" until close() is - * called on the KWAJ file. - * - * @param self a self-referential pointer to the mskwaj_decompressor - * instance being called - * @param filename the filename of the KWAJ compressed file. This is - * passed directly to mspack_system::open(). - * @return a pointer to a mskwajd_header structure, or NULL on failure - * @see close() - */ - struct mskwajd_header *(*open)(struct mskwaj_decompressor *self, - const char *filename); - - /** - * Closes a previously opened KWAJ file. - * - * This closes a KWAJ file and frees the mskwajd_header associated - * with it. The KWAJ header pointer is now invalid and cannot be - * used again. - * - * @param self a self-referential pointer to the mskwaj_decompressor - * instance being called - * @param kwaj the KWAJ file to close - * @see open() - */ - void (*close)(struct mskwaj_decompressor *self, - struct mskwajd_header *kwaj); - - /** - * Extracts the compressed data from a KWAJ file. - * - * This decompresses the compressed KWAJ data stream and writes it to - * an output file. - * - * @param self a self-referential pointer to the mskwaj_decompressor - * instance being called - * @param kwaj the KWAJ file to extract data from - * @param filename the filename to write the decompressed data to. This - * is passed directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*extract)(struct mskwaj_decompressor *self, - struct mskwajd_header *kwaj, - const char *filename); - - /** - * Decompresses an KWAJ file to an output file in one step. - * - * This opens an KWAJ file as input, reads the header, then decompresses - * the compressed data immediately to an output file, finally closing - * both the input and output file. It is more convenient to use than - * open() then extract() then close(), if you do not need to know the - * KWAJ output size or output filename. - * - * @param self a self-referential pointer to the mskwaj_decompressor - * instance being called - * @param input the filename of the input KWAJ file. This is passed - * directly to mspack_system::open(). - * @param output the filename to write the decompressed data to. This - * is passed directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*decompress)(struct mskwaj_decompressor *self, - const char *input, - const char *output); - - /** - * Returns the error code set by the most recently called method. - * - * This is useful for open() which does not return an - * error code directly. - * - * @param self a self-referential pointer to the mskwaj_decompressor - * instance being called - * @return the most recent error code - * @see open(), search() - */ - int (*last_error)(struct mskwaj_decompressor *self); -}; - -/* --- support for .LZX (Offline Address Book) file format ----------------- */ - -/** - * A compressor for the Offline Address Book (OAB) format. - * - * All fields are READ ONLY. - * - * @see mspack_create_oab_compressor(), mspack_destroy_oab_compressor() - */ -struct msoab_compressor { - /** - * Compress a full OAB file. - * - * The input file will be read and the compressed contents written to the - * output file. - * - * @param self a self-referential pointer to the msoab_decompressor - * instance being called - * @param input the filename of the input file. This is passed - * directly to mspack_system::open(). - * @param output the filename of the output file. This is passed - * directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*compress) (struct msoab_compressor *self, - const char *input, - const char *output); - - /** - * Generate a compressed incremental OAB patch file. - * - * The two uncompressed files "input" and "base" will be read, and an - * incremental patch to generate "input" from "base" will be written to - * the output file. - * - * @param self a self-referential pointer to the msoab_compressor - * instance being called - * @param input the filename of the input file containing the new - * version of its contents. This is passed directly - * to mspack_system::open(). - * @param base the filename of the original base file containing - * the old version of its contents, against which the - * incremental patch shall generated. This is passed - * directly to mspack_system::open(). - * @param output the filename of the output file. This is passed - * directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*compress_incremental) (struct msoab_compressor *self, - const char *input, - const char *base, - const char *output); -}; - -/** - * A decompressor for .LZX (Offline Address Book) files - * - * All fields are READ ONLY. - * - * @see mspack_create_oab_decompressor(), mspack_destroy_oab_decompressor() - */ -struct msoab_decompressor { - /** - * Decompresses a full Offline Address Book file. - * - * If the input file is a valid compressed Offline Address Book file, - * it will be read and the decompressed contents will be written to - * the output file. - * - * @param self a self-referential pointer to the msoab_decompressor - * instance being called - * @param input the filename of the input file. This is passed - * directly to mspack_system::open(). - * @param output the filename of the output file. This is passed - * directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*decompress) (struct msoab_decompressor *self, - const char *input, - const char *output); - - /** - * Decompresses an Offline Address Book with an incremental patch file. - * - * This requires both a full UNCOMPRESSED Offline Address Book file to - * act as the "base", and a compressed incremental patch file as input. - * If the input file is valid, it will be decompressed with reference to - * the base file, and the decompressed contents will be written to the - * output file. - * - * There is no way to tell what the right base file is for the given - * incremental patch, but if you get it wrong, this will usually result - * in incorrect data being decompressed, which will then fail a checksum - * test. - * - * @param self a self-referential pointer to the msoab_decompressor - * instance being called - * @param input the filename of the input file. This is passed - * directly to mspack_system::open(). - * @param base the filename of the base file to which the - * incremental patch shall be applied. This is passed - * directly to mspack_system::open(). - * @param output the filename of the output file. This is passed - * directly to mspack_system::open(). - * @return an error code, or MSPACK_ERR_OK if successful - */ - int (*decompress_incremental) (struct msoab_decompressor *self, - const char *input, - const char *base, - const char *output); - - /** - * Sets an OAB decompression engine parameter. Available only in OAB - * decompressor version 2 and above. - * - * - #MSOABD_PARAM_DECOMPBUF: How many bytes should be used as an input - * buffer by decompressors? The minimum value is 16. The default value - * is 4096. - * - * @param self a self-referential pointer to the msoab_decompressor - * instance being called - * @param param the parameter to set - * @param value the value to set the parameter to - * @return MSPACK_ERR_OK if all is OK, or MSPACK_ERR_ARGS if there - * is a problem with either parameter or value. - */ - int (*set_param)(struct msoab_decompressor *self, - int param, - int value); - -}; - -/** msoab_decompressor::set_param() parameter: size of decompression buffer */ -#define MSOABD_PARAM_DECOMPBUF (0) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/inc/libmspack/mspack.lib b/inc/libmspack/mspack.lib deleted file mode 100644 index ba15006..0000000 Binary files a/inc/libmspack/mspack.lib and /dev/null differ diff --git a/inc/xna/xna-dx.hpp b/inc/xna/xna-dx.hpp deleted file mode 100644 index 0493488..0000000 --- a/inc/xna/xna-dx.hpp +++ /dev/null @@ -1,885 +0,0 @@ -#ifndef XNA_XNADX_HPP -#define XNA_XNADX_HPP - -#define NOMINMAX - -//---------------- DX INCLUDES ----------------// - -//DirectX -#if defined(_XBOX_ONE) && defined(_TITLE) -#include -#define NO_D3D11_DEBUG_NAME -#endif -#include "dxgi.h" -#include "d3d11.h" -#include -#include -#include -#include -#include -#include -#include -#include -//DirectXTK -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//Windows -#include -#include -#include -#include -#include - -//---------------- USINGS ----------------// - -template -using comptr = Microsoft::WRL::ComPtr; - -//---------------- INCLUDES ----------------// - -#include "xna.hpp" - -//---------------- CLASSES ----------------// - -namespace xna { - //---------------- HELPERS ----------------// - - struct DxHelpers { - static constexpr RECT RectangleToDx(Rectangle const& value) { - RECT rect{}; - rect.top = value.Top(); - rect.left = value.Left(); - rect.right = value.Right(); - rect.bottom = value.Bottom(); - - return rect; - } - - static constexpr D3D11_VIEWPORT ViewportToDx(Viewport const& value) { - D3D11_VIEWPORT _view{}; - _view.TopLeftX = value.X; - _view.TopLeftY = value.Y; - _view.Width = value.Width; - _view.Height = value.Height; - _view.MinDepth = value.MinDetph; - _view.MaxDepth = value.MaxDepth; - - return _view; - } - - static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) { - DirectX::XMVECTOR v{}; - - v.m128_f32[0] = value.X; - v.m128_f32[1] = value.Y; - - return v; - } - - static constexpr DirectX::XMVECTOR VectorToDx(Vector3 const& value) { - DirectX::XMVECTOR v{}; - - v.m128_f32[0] = value.X; - v.m128_f32[1] = value.Y; - v.m128_f32[2] = value.Z; - - return v; - } - - static constexpr DirectX::XMFLOAT3 Vector3ToDx(Vector3 const& value) { - DirectX::XMFLOAT3 v{}; - - v.x = value.X; - v.y = value.Y; - v.z = value.Z; - - return v; - } - - static constexpr DirectX::XMVECTOR VectorToDx(Vector4 const& value) { - DirectX::XMVECTOR v{}; - - v.m128_f32[0] = value.X; - v.m128_f32[1] = value.Y; - v.m128_f32[2] = value.Z; - v.m128_f32[3] = value.W; - - return v; - } - - static constexpr DirectX::XMMATRIX MatrixToDx(Matrix const& value) { - auto m = DirectX::XMMATRIX( - value.M11, - value.M12, - value.M13, - value.M14, - value.M21, - value.M22, - value.M23, - value.M24, - value.M31, - value.M32, - value.M33, - value.M34, - value.M41, - value.M42, - value.M43, - value.M44 - ); - - return m; - } - - static constexpr DirectX::SpriteSortMode SpriteSortToDx(SpriteSortMode value) { - return static_cast(static_cast(value)); - } - - static constexpr DXGI_FORMAT SurfaceFormatToDx(SurfaceFormat format) - { - switch (format) - { - case SurfaceFormat::Color://21 - return DXGI_FORMAT_R8G8B8A8_UNORM; - case SurfaceFormat::Bgr565: //23 - return DXGI_FORMAT_B5G6R5_UNORM; - case SurfaceFormat::Bgra5551://25 - return DXGI_FORMAT_B5G5R5A1_UNORM; - case SurfaceFormat::Bgra4444://26 - return DXGI_FORMAT_B4G4R4A4_UNORM; - case SurfaceFormat::Dxt1://827611204 - return DXGI_FORMAT_BC1_UNORM; - case SurfaceFormat::Dxt3://861165636 - return DXGI_FORMAT_BC2_UNORM; - case SurfaceFormat::Dxt5://894720068 - return DXGI_FORMAT_BC3_UNORM; - case SurfaceFormat::NormalizedByte2://60 - return DXGI_FORMAT_R8G8_SNORM; - case SurfaceFormat::NormalizedByte4://63 - return DXGI_FORMAT_R8G8B8A8_SNORM; - case SurfaceFormat::Rgba1010102://31 - return DXGI_FORMAT_R10G10B10A2_UNORM; - case SurfaceFormat::Rg32://34 - return DXGI_FORMAT_R16G16_UNORM; - case SurfaceFormat::Rgba64://36 - return DXGI_FORMAT_R16G16B16A16_UNORM; - case SurfaceFormat::Alpha8://28 - return DXGI_FORMAT_A8_UNORM; - case SurfaceFormat::Single://114 - return DXGI_FORMAT_R32_FLOAT; - case SurfaceFormat::Vector2://115 - return DXGI_FORMAT_R32G32_FLOAT; - case SurfaceFormat::Vector4://116 - return DXGI_FORMAT_R32G32B32A32_FLOAT; - case SurfaceFormat::HalfSingle://111 - return DXGI_FORMAT_R16_FLOAT; - case SurfaceFormat::HalfVector2://112 - return DXGI_FORMAT_R16G16_FLOAT; - case SurfaceFormat::HalfVector4://113 - return DXGI_FORMAT_R16G16B16A16_FLOAT; - case SurfaceFormat::HdrBlendable://113 - return DXGI_FORMAT_R16G16B16A16_FLOAT; - default://0 - return DXGI_FORMAT_UNKNOWN; - } - } - - static constexpr SurfaceFormat SurfaceFormatToXna(DXGI_FORMAT format) { - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - return SurfaceFormat::Color; - case DXGI_FORMAT_B5G6R5_UNORM: - return SurfaceFormat::Bgr565; - case DXGI_FORMAT_B5G5R5A1_UNORM: - return SurfaceFormat::Bgra5551; - case DXGI_FORMAT_B4G4R4A4_UNORM: - return SurfaceFormat::Bgra4444; - case DXGI_FORMAT_BC2_UNORM: - return SurfaceFormat::Dxt3; - case DXGI_FORMAT_BC3_UNORM: - return SurfaceFormat::Dxt5; - case DXGI_FORMAT_R8G8_SNORM: - return SurfaceFormat::NormalizedByte2; - case DXGI_FORMAT_R8G8B8A8_SNORM: - return SurfaceFormat::NormalizedByte4; - case DXGI_FORMAT_R10G10B10A2_UNORM: - return SurfaceFormat::Rgba1010102; - case DXGI_FORMAT_R16G16_UNORM: - return SurfaceFormat::Rg32; - case DXGI_FORMAT_R16G16B16A16_UNORM: - return SurfaceFormat::Rgba64; - case DXGI_FORMAT_A8_UNORM: - return SurfaceFormat::Alpha8; - case DXGI_FORMAT_R32_FLOAT: - return SurfaceFormat::Single; - case DXGI_FORMAT_R32G32_FLOAT: - return SurfaceFormat::Vector2; - case DXGI_FORMAT_R32G32B32A32_FLOAT: - return SurfaceFormat::Vector4; - case DXGI_FORMAT_R16_FLOAT: - return SurfaceFormat::HalfSingle; - case DXGI_FORMAT_R16G16_FLOAT: - return SurfaceFormat::HalfVector2; - case DXGI_FORMAT_R16G16B16A16_FLOAT: - return SurfaceFormat::HalfVector4; - default: - return SurfaceFormat::Unknown; - } - } - - static constexpr Blend BlendToXna(D3D11_BLEND blend) { - switch (blend) { - case D3D11_BLEND_ZERO: - return Blend::Zero; - case D3D11_BLEND_ONE: - return Blend::One; - case D3D11_BLEND_SRC_COLOR: - return Blend::SourceColor; - case D3D11_BLEND_INV_SRC_COLOR: - return Blend::InverseSourceColor; - case D3D11_BLEND_SRC_ALPHA: - return Blend::SourceAlpha; - case D3D11_BLEND_INV_SRC_ALPHA: - return Blend::InverseSourceAlpha; - case D3D11_BLEND_DEST_ALPHA: - return Blend::DestinationAlpha; - case D3D11_BLEND_INV_DEST_ALPHA: - return Blend::InverseDestinationAlpha; - case D3D11_BLEND_DEST_COLOR: - return Blend::DestinationColor; - case D3D11_BLEND_INV_DEST_COLOR: - return Blend::InverseDestinationColor; - case D3D11_BLEND_SRC_ALPHA_SAT: - return Blend::SourceAlphaSaturation; - case D3D11_BLEND_BLEND_FACTOR: - return Blend::BlendFactor; - case D3D11_BLEND_INV_BLEND_FACTOR: - return Blend::InverseBlendFactor; - case D3D11_BLEND_SRC1_COLOR: - return Blend::Source1Color; - case D3D11_BLEND_INV_SRC1_COLOR: - return Blend::InverseSource1Color; - case D3D11_BLEND_SRC1_ALPHA: - return Blend::Source1Alpha; - case D3D11_BLEND_INV_SRC1_ALPHA: - return Blend::InverseSource1Alpha; - default: - return Blend::Zero; - } - } - - static constexpr D3D11_BLEND BlendToDx(Blend blend) { - switch (blend) - { - case xna::Blend::Zero: - return D3D11_BLEND_ZERO; - case xna::Blend::One: - return D3D11_BLEND_ONE; - case xna::Blend::SourceColor: - return D3D11_BLEND_SRC_COLOR; - case xna::Blend::InverseSourceColor: - return D3D11_BLEND_INV_SRC_COLOR; - case xna::Blend::SourceAlpha: - return D3D11_BLEND_SRC_ALPHA; - case xna::Blend::InverseSourceAlpha: - return D3D11_BLEND_INV_SRC_ALPHA; - case xna::Blend::DestinationAlpha: - return D3D11_BLEND_DEST_ALPHA; - case xna::Blend::InverseDestinationAlpha: - return D3D11_BLEND_INV_DEST_ALPHA; - case xna::Blend::DestinationColor: - return D3D11_BLEND_DEST_COLOR; - case xna::Blend::InverseDestinationColor: - return D3D11_BLEND_INV_DEST_COLOR; - case xna::Blend::SourceAlphaSaturation: - return D3D11_BLEND_SRC_ALPHA_SAT; - case xna::Blend::BlendFactor: - return D3D11_BLEND_BLEND_FACTOR; - case xna::Blend::InverseBlendFactor: - return D3D11_BLEND_INV_BLEND_FACTOR; - case xna::Blend::Source1Color: - return D3D11_BLEND_SRC1_COLOR; - case xna::Blend::InverseSource1Color: - return D3D11_BLEND_INV_SRC1_COLOR; - case xna::Blend::Source1Alpha: - return D3D11_BLEND_SRC1_ALPHA; - case xna::Blend::InverseSource1Alpha: - return D3D11_BLEND_INV_SRC1_ALPHA; - default: - return D3D11_BLEND_ZERO; - } - } - - static constexpr D3D11_BLEND_OP BlendOperationToDx(BlendOperation op) { - return static_cast(static_cast(op) + 1); - } - - static constexpr BlendOperation BlendOperationToXna(D3D11_BLEND_OP op) { - return static_cast(static_cast(op) - 1); - } - - static constexpr D3D11_COLOR_WRITE_ENABLE ColorWriteChannelsToDx(ColorWriteChannels colorWrite) { - switch (colorWrite) - { - case xna::ColorWriteChannels::Red: - return D3D11_COLOR_WRITE_ENABLE_RED; - case xna::ColorWriteChannels::Green: - return D3D11_COLOR_WRITE_ENABLE_GREEN; - case xna::ColorWriteChannels::Blue: - return D3D11_COLOR_WRITE_ENABLE_BLUE; - case xna::ColorWriteChannels::Alpha: - return D3D11_COLOR_WRITE_ENABLE_ALPHA; - case xna::ColorWriteChannels::All: - return D3D11_COLOR_WRITE_ENABLE_ALL; - default: - return D3D11_COLOR_WRITE_ENABLE_ALL; - } - } - - static constexpr D3D11_TEXTURE_ADDRESS_MODE TextureAddresModeToDx(TextureAddressMode value) { - return static_cast(static_cast(value) + 1); - } - - static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) { - return static_cast(value - 1); - } - - }; - - struct PlatformInit { - static void Init() { - InitRegisteredTypes(); - InitActivadors(); - } - - static void InitRegisteredTypes(); - static void InitActivadors(); - - private: - template - static void insertRegisteredReader(String const& readerName) { - const auto reader = typeof(); - //Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader }); - Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader }); - Type::NameOfRegisteredTypes.insert({ "Microsoft.Xna.Framework.Content." + readerName, reader }); - } - - template - static void insertRegisteredReader(String const& readerName, String const& microsoftNameFullName) { - const auto reader = typeof(); - //Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader }); - Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader }); - Type::NameOfRegisteredTypes.insert({ microsoftNameFullName, reader }); - } - - template - static void insertActivadorReader() { - ContentTypeReaderActivador::SetActivador(typeof(), []() -> sptr { - auto obj = snew(); - return reinterpret_pointer_cast(obj); - }); - } - }; - - // Helper class for animation and simulation timing. - class StepTimer - { - public: - StepTimer() noexcept(false) : - m_elapsedTicks(0), - m_totalTicks(0), - m_leftOverTicks(0), - m_frameCount(0), - m_framesPerSecond(0), - m_framesThisSecond(0), - m_qpcSecondCounter(0), - m_isFixedTimeStep(false), - m_targetElapsedTicks(TicksPerSecond / 60) - { - if (!QueryPerformanceFrequency(&m_qpcFrequency)) - { - throw std::exception(); - } - - if (!QueryPerformanceCounter(&m_qpcLastTime)) - { - throw std::exception(); - } - - // Initialize max delta to 1/10 of a second. - m_qpcMaxDelta = static_cast(m_qpcFrequency.QuadPart / 10); - } - - // Get elapsed time since the previous Update call. - uint64_t GetElapsedTicks() const noexcept { return m_elapsedTicks; } - double GetElapsedSeconds() const noexcept { return TicksToSeconds(m_elapsedTicks); } - - // Get total time since the start of the program. - uint64_t GetTotalTicks() const noexcept { return m_totalTicks; } - double GetTotalSeconds() const noexcept { return TicksToSeconds(m_totalTicks); } - - // Get total number of updates since start of the program. - uint32_t GetFrameCount() const noexcept { return m_frameCount; } - - // Get the current framerate. - uint32_t GetFramesPerSecond() const noexcept { return m_framesPerSecond; } - - // Set whether to use fixed or variable timestep mode. - void SetFixedTimeStep(bool isFixedTimestep) noexcept { m_isFixedTimeStep = isFixedTimestep; } - - // Set how often to call Update when in fixed timestep mode. - void SetTargetElapsedTicks(uint64_t targetElapsed) noexcept { m_targetElapsedTicks = targetElapsed; } - void SetTargetElapsedSeconds(double targetElapsed) noexcept { m_targetElapsedTicks = SecondsToTicks(targetElapsed); } - - // Integer format represents time using 10,000,000 ticks per second. - static constexpr uint64_t TicksPerSecond = 10000000; - - static constexpr double TicksToSeconds(uint64_t ticks) noexcept { return static_cast(ticks) / TicksPerSecond; } - static constexpr uint64_t SecondsToTicks(double seconds) noexcept { return static_cast(seconds * TicksPerSecond); } - - // After an intentional timing discontinuity (for instance a blocking IO operation) - // call this to avoid having the fixed timestep logic attempt a set of catch-up - // Update calls. - - void ResetElapsedTime() - { - if (!QueryPerformanceCounter(&m_qpcLastTime)) - { - throw std::exception(); - } - - m_leftOverTicks = 0; - m_framesPerSecond = 0; - m_framesThisSecond = 0; - m_qpcSecondCounter = 0; - } - - // Update timer state, calling the specified Update function the appropriate number of times. - template - void Tick(const TUpdate& update) - { - // Query the current time. - LARGE_INTEGER currentTime; - - if (!QueryPerformanceCounter(¤tTime)) - { - throw std::exception(); - } - - uint64_t timeDelta = static_cast(currentTime.QuadPart - m_qpcLastTime.QuadPart); - - m_qpcLastTime = currentTime; - m_qpcSecondCounter += timeDelta; - - // Clamp excessively large time deltas (e.g. after paused in the debugger). - if (timeDelta > m_qpcMaxDelta) - { - timeDelta = m_qpcMaxDelta; - } - - // Convert QPC units into a canonical tick format. This cannot overflow due to the previous clamp. - timeDelta *= TicksPerSecond; - timeDelta /= static_cast(m_qpcFrequency.QuadPart); - - const uint32_t lastFrameCount = m_frameCount; - - if (m_isFixedTimeStep) - { - // Fixed timestep update logic - - // If the app is running very close to the target elapsed time (within 1/4 of a millisecond) just clamp - // the clock to exactly match the target value. This prevents tiny and irrelevant errors - // from accumulating over time. Without this clamping, a game that requested a 60 fps - // fixed update, running with vsync enabled on a 59.94 NTSC display, would eventually - // accumulate enough tiny errors that it would drop a frame. It is better to just round - // small deviations down to zero to leave things running smoothly. - - if (static_cast(std::abs(static_cast(timeDelta - m_targetElapsedTicks))) < TicksPerSecond / 4000) - { - timeDelta = m_targetElapsedTicks; - } - - m_leftOverTicks += timeDelta; - - while (m_leftOverTicks >= m_targetElapsedTicks) - { - m_elapsedTicks = m_targetElapsedTicks; - m_totalTicks += m_targetElapsedTicks; - m_leftOverTicks -= m_targetElapsedTicks; - m_frameCount++; - - update(); - } - } - else - { - // Variable timestep update logic. - m_elapsedTicks = timeDelta; - m_totalTicks += timeDelta; - m_leftOverTicks = 0; - m_frameCount++; - - update(); - } - - // Track the current framerate. - if (m_frameCount != lastFrameCount) - { - m_framesThisSecond++; - } - - if (m_qpcSecondCounter >= static_cast(m_qpcFrequency.QuadPart)) - { - m_framesPerSecond = m_framesThisSecond; - m_framesThisSecond = 0; - m_qpcSecondCounter %= static_cast(m_qpcFrequency.QuadPart); - } - } - - private: - // Source timing data uses QPC units. - LARGE_INTEGER m_qpcFrequency; - LARGE_INTEGER m_qpcLastTime; - uint64_t m_qpcMaxDelta; - - // Derived timing data uses a canonical tick format. - uint64_t m_elapsedTicks; - uint64_t m_totalTicks; - uint64_t m_leftOverTicks; - - // Members for tracking the framerate. - uint32_t m_frameCount; - uint32_t m_framesPerSecond; - uint32_t m_framesThisSecond; - uint64_t m_qpcSecondCounter; - - // Members for configuring fixed timestep mode. - bool m_isFixedTimeStep; - uint64_t m_targetElapsedTicks; - }; - - //---------------- IMPLEMENTATIONS ----------------// - - struct SpriteFont::PlatformImplementation { - uptr dxSpriteFont{ nullptr }; - }; - - struct SpriteBatch::PlatformImplementation { - sptr dxSpriteBatch = nullptr; - comptr dxInputLayout = nullptr; - sptr dxEffectBuffer = nullptr; - }; - - struct GraphicsAdapter::PlatformImplementation { - comptr dxAdapter = nullptr; - comptr dxFactory = nullptr; - }; - - struct BlendRenderTarget { - bool Enabled{ true }; - Blend Source{ Blend::SourceAlpha }; - Blend Destination{ Blend::InverseSourceAlpha }; - BlendOperation Operation{ BlendOperation::Add }; - Blend SourceAlpha{ Blend::One }; - Blend DestinationAlpha{ Blend::Zero }; - BlendOperation OperationAlpha{ BlendOperation::Add }; - ColorWriteChannels WriteMask{ ColorWriteChannels::All }; - - constexpr BlendRenderTarget() = default; - }; - - struct BlendState::PlatformImplementation { - comptr dxBlendState = nullptr; - D3D11_BLEND_DESC dxDescription{}; - float blendFactor[4]{ 1.0F, 1.0F, 1.0F, 1.0F }; - UINT sampleMask{ 0xffffffff }; - }; - - struct DepthStencilState::PlatformImplementation { - comptr dxDepthStencil = nullptr; - D3D11_DEPTH_STENCIL_DESC dxDescription{}; - }; - - struct GamePad::PlatformImplementation { - uptr _dxGamePad = unew(); - - void Suspend() const { - if (_dxGamePad) - _dxGamePad->Suspend(); - } - - void Resume() const { - if (_dxGamePad) - _dxGamePad->Resume(); - } - }; - - struct Keyboard::PlatformImplementation { - PlatformImplementation() { - _dxKeyboard = unew(); - } - - uptr _dxKeyboard = nullptr; - - inline void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const { - if (_dxKeyboard) - _dxKeyboard->ProcessMessage(message, wParam, lParam); - } - }; - - struct Mouse::PlatformImplementation { - PlatformImplementation() { - _dxMouse = unew(); - } - - inline void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const { - if (_dxMouse) - _dxMouse->ProcessMessage(message, wParam, lParam); - } - - uptr _dxMouse = nullptr; - }; - - struct RasterizerState::PlatformImplementation { - comptr dxRasterizerState = nullptr; - D3D11_RASTERIZER_DESC dxDescription{}; - }; - - struct SamplerState::PlatformImplementation { - comptr _samplerState = nullptr; - D3D11_SAMPLER_DESC _description{}; - }; - - struct SwapChain::PlatformImplementation { - comptr dxSwapChain{ nullptr }; - DXGI_SWAP_CHAIN_DESC1 dxDescription{}; - DXGI_SWAP_CHAIN_FULLSCREEN_DESC dxFullScreenDescription{}; - - bool GetBackBuffer(comptr& texture2D) const { - if (!dxSwapChain) - return false; - - const auto hr = dxSwapChain->GetBuffer(0, __uuidof(texture2D), (void**)texture2D.GetAddressOf()); - - return !FAILED(hr); - } - }; - - struct Texture2D::PlatformImplementation { - comptr dxTexture2D{ nullptr }; - comptr dxShaderResource{ nullptr }; - D3D11_SUBRESOURCE_DATA dxSubResource{}; - D3D11_TEXTURE2D_DESC dxDescription{}; - D3D11_SHADER_RESOURCE_VIEW_DESC dxShaderDescription{}; - }; - - struct RenderTarget2D::PlatformImplementation { - comptr _renderTargetView = nullptr; - D3D11_RENDER_TARGET_VIEW_DESC _renderTargetDesc{}; - }; - - enum class GameWindowMode : UINT { - Fullscreen = WS_POPUP | WS_VISIBLE, - Windowed = WS_OVERLAPPED | WS_SYSMENU | WS_VISIBLE, - Borderless = WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE, - }; - - struct GameWindow::PlatformImplementation { - public: - PlatformImplementation(GameWindow* gameWindow): gameWindow(gameWindow){} - - constexpr void Mode(GameWindowMode mode) { - _windowStyle = static_cast(mode); - } - - constexpr GameWindowMode Mode() const { - return static_cast(_windowStyle); - } - - void Position(int width, int height, bool update = true); - void Size(int width, int height, bool update = true); - - inline HINSTANCE HInstance() const { - return _hInstance; - } - - inline HWND WindowHandle() const { - return _windowHandle; - } - - constexpr int Width() const { - return _windowWidth; - } - - constexpr int Height() const { - return _windowHeight; - } - - inline void Icon(unsigned int icon) { - _windowIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(icon)); - } - - inline void Icon(HICON icon) { - _windowIcon = icon; - } - - inline void Cursor(unsigned int cursor) { - _windowCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(cursor)); - } - - inline void Cursor(HCURSOR cursor) { - _windowCursor = cursor; - } - - constexpr float CenterX() const { - return _windowCenterX; - } - - constexpr float CenterY() const { - return _windowCenterY; - } - - inline void CursorVisibility(bool visible) const { - ShowCursor(visible); - } - - inline void Close() const { - PostMessage(_windowHandle, WM_DESTROY, 0, 0); - } - - constexpr COLORREF Color() const { - return _windowColor; - } - - constexpr void Color(COLORREF color) { - _windowColor = color; - } - - constexpr void Color(BYTE r, BYTE g, BYTE b) { - _windowColor = RGB(r, g, b); - } - - bool Create(); - bool Update(); - - static LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - private: - friend class GameWindow; - GameWindow* gameWindow = nullptr; - - HINSTANCE _hInstance{ nullptr }; - HWND _windowHandle{ nullptr }; - int _windowWidth{ 800 }; - int _windowHeight{ 480 }; - HICON _windowIcon{ nullptr }; - HCURSOR _windowCursor{ nullptr }; - COLORREF _windowColor{ RGB(0,0,0) }; - String _windowTitle{ "Xna++ Game Development" }; - DWORD _windowStyle{ 0 }; - int _windowPosX{ 0 }; - int _windowPosY{ 0 }; - float _windowCenterX{ 0 }; - float _windowCenterY{ 0 }; - - inline void setPosition() { - _windowPosX = GetSystemMetrics(SM_CXSCREEN) / 2 - _windowWidth / 2; - _windowPosY = GetSystemMetrics(SM_CYSCREEN) / 2 - _windowHeight / 2; - } - - inline void setCenter() { - _windowCenterX = _windowWidth / 2.0f; - _windowCenterY = _windowHeight / 2.0f; - } - }; - - struct AudioEngine::PlatformImplementation { - PlatformImplementation() { - _dxAudioEngine = unew( -#ifdef _DEBUG - DirectX::AudioEngine_Debug -#endif - ); - } - - ~PlatformImplementation() { - if (_dxAudioEngine) { - _dxAudioEngine->Suspend(); - } - } - - uptr _dxAudioEngine = nullptr; - }; - - struct GraphicsDevice::PlatformImplementation { - comptr _device = nullptr; - comptr _context = nullptr; - comptr _factory = nullptr; - - sptr _swapChain = nullptr; - sptr _renderTarget2D = nullptr; - intptr_t windowHandle{ 0 }; - - D3D_FEATURE_LEVEL featureLevels[7] = - { - D3D_FEATURE_LEVEL_11_1, - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - D3D_FEATURE_LEVEL_9_3, - D3D_FEATURE_LEVEL_9_2, - D3D_FEATURE_LEVEL_9_1, - }; - - D3D_FEATURE_LEVEL currentFeatureLevel{ D3D_FEATURE_LEVEL_11_1 }; - - private: - friend class GraphicsDevice; - float _backgroundColor[4] = { 0, 0, 0, 0 }; - UINT vSyncValue = 1; - }; - - struct Game::PlatformImplementation { - private: - friend class Game; - - xna::StepTimer _stepTimer{}; - }; - - struct SoundEffectInstance::PlatformImplementation { - uptr _dxInstance = nullptr; - }; - - struct SoundEffect::PlatformImplementation { - uptr _dxSoundEffect = nullptr; - }; - - struct Effect::PlatformImplementation { - sptr dxEffect = nullptr; - }; - - struct BasicEffect::PlatformImplementation { - sptr dxBasicEffect = nullptr; - }; -} -#endif \ No newline at end of file diff --git a/includes/xna-dx/framework.hpp b/includes/xna-dx/framework.hpp new file mode 100644 index 0000000..022224c --- /dev/null +++ b/includes/xna-dx/framework.hpp @@ -0,0 +1,4 @@ +#include "steptimer.hpp" +#include "init.hpp" +#include "implementations.hpp" +#include "helpers.hpp" \ No newline at end of file diff --git a/includes/xna-dx/headers.hpp b/includes/xna-dx/headers.hpp new file mode 100644 index 0000000..baaaebd --- /dev/null +++ b/includes/xna-dx/headers.hpp @@ -0,0 +1,61 @@ +#ifndef XNA_DX_HEADERS_HPP +#define XNA_DX_HEADERS_HPP + +#define NOMINMAX + +//---------------- DX INCLUDES ----------------// + +//DirectX +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#define NO_D3D11_DEBUG_NAME +#endif +#include "dxgi.h" +#include "d3d11.h" +#include +#include +#include +#include +#include +#include +#include +#include +//DirectXTK +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//Windows +#include +#include +#include +#include +#include + +//Xna + +#include "xna/framework.hpp" + +//---------------- USINGS ----------------// + +template +using comptr = Microsoft::WRL::ComPtr; + +#endif \ No newline at end of file diff --git a/includes/xna-dx/helpers.hpp b/includes/xna-dx/helpers.hpp new file mode 100644 index 0000000..a96573c --- /dev/null +++ b/includes/xna-dx/helpers.hpp @@ -0,0 +1,311 @@ +#ifndef XNA_DX_HELPERS_HPP +#define XNA_DX_HELPERS_HPP + +#include "headers.hpp" + +namespace xna { + struct DxHelpers { + static constexpr RECT RectangleToDx(Rectangle const& value) { + RECT rect{}; + rect.top = value.Top(); + rect.left = value.Left(); + rect.right = value.Right(); + rect.bottom = value.Bottom(); + + return rect; + } + + static constexpr D3D11_VIEWPORT ViewportToDx(Viewport const& value) { + D3D11_VIEWPORT _view{}; + _view.TopLeftX = value.X; + _view.TopLeftY = value.Y; + _view.Width = value.Width; + _view.Height = value.Height; + _view.MinDepth = value.MinDetph; + _view.MaxDepth = value.MaxDepth; + + return _view; + } + + static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) { + DirectX::XMVECTOR v{}; + + v.m128_f32[0] = value.X; + v.m128_f32[1] = value.Y; + + return v; + } + + static constexpr DirectX::XMVECTOR VectorToDx(Vector3 const& value) { + DirectX::XMVECTOR v{}; + + v.m128_f32[0] = value.X; + v.m128_f32[1] = value.Y; + v.m128_f32[2] = value.Z; + + return v; + } + + static constexpr DirectX::XMFLOAT3 Vector3ToDx(Vector3 const& value) { + DirectX::XMFLOAT3 v{}; + + v.x = value.X; + v.y = value.Y; + v.z = value.Z; + + return v; + } + + static constexpr DirectX::XMVECTOR VectorToDx(Vector4 const& value) { + DirectX::XMVECTOR v{}; + + v.m128_f32[0] = value.X; + v.m128_f32[1] = value.Y; + v.m128_f32[2] = value.Z; + v.m128_f32[3] = value.W; + + return v; + } + + static constexpr DirectX::XMMATRIX MatrixToDx(Matrix const& value) { + auto m = DirectX::XMMATRIX( + value.M11, + value.M12, + value.M13, + value.M14, + value.M21, + value.M22, + value.M23, + value.M24, + value.M31, + value.M32, + value.M33, + value.M34, + value.M41, + value.M42, + value.M43, + value.M44 + ); + + return m; + } + + static constexpr DirectX::SpriteSortMode SpriteSortToDx(SpriteSortMode value) { + return static_cast(static_cast(value)); + } + + static constexpr DXGI_FORMAT SurfaceFormatToDx(SurfaceFormat format) + { + switch (format) + { + case SurfaceFormat::Color://21 + return DXGI_FORMAT_R8G8B8A8_UNORM; + case SurfaceFormat::Bgr565: //23 + return DXGI_FORMAT_B5G6R5_UNORM; + case SurfaceFormat::Bgra5551://25 + return DXGI_FORMAT_B5G5R5A1_UNORM; + case SurfaceFormat::Bgra4444://26 + return DXGI_FORMAT_B4G4R4A4_UNORM; + case SurfaceFormat::Dxt1://827611204 + return DXGI_FORMAT_BC1_UNORM; + case SurfaceFormat::Dxt3://861165636 + return DXGI_FORMAT_BC2_UNORM; + case SurfaceFormat::Dxt5://894720068 + return DXGI_FORMAT_BC3_UNORM; + case SurfaceFormat::NormalizedByte2://60 + return DXGI_FORMAT_R8G8_SNORM; + case SurfaceFormat::NormalizedByte4://63 + return DXGI_FORMAT_R8G8B8A8_SNORM; + case SurfaceFormat::Rgba1010102://31 + return DXGI_FORMAT_R10G10B10A2_UNORM; + case SurfaceFormat::Rg32://34 + return DXGI_FORMAT_R16G16_UNORM; + case SurfaceFormat::Rgba64://36 + return DXGI_FORMAT_R16G16B16A16_UNORM; + case SurfaceFormat::Alpha8://28 + return DXGI_FORMAT_A8_UNORM; + case SurfaceFormat::Single://114 + return DXGI_FORMAT_R32_FLOAT; + case SurfaceFormat::Vector2://115 + return DXGI_FORMAT_R32G32_FLOAT; + case SurfaceFormat::Vector4://116 + return DXGI_FORMAT_R32G32B32A32_FLOAT; + case SurfaceFormat::HalfSingle://111 + return DXGI_FORMAT_R16_FLOAT; + case SurfaceFormat::HalfVector2://112 + return DXGI_FORMAT_R16G16_FLOAT; + case SurfaceFormat::HalfVector4://113 + return DXGI_FORMAT_R16G16B16A16_FLOAT; + case SurfaceFormat::HdrBlendable://113 + return DXGI_FORMAT_R16G16B16A16_FLOAT; + default://0 + return DXGI_FORMAT_UNKNOWN; + } + } + + static constexpr SurfaceFormat SurfaceFormatToXna(DXGI_FORMAT format) { + switch (format) + { + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_B8G8R8A8_UNORM: + return SurfaceFormat::Color; + case DXGI_FORMAT_B5G6R5_UNORM: + return SurfaceFormat::Bgr565; + case DXGI_FORMAT_B5G5R5A1_UNORM: + return SurfaceFormat::Bgra5551; + case DXGI_FORMAT_B4G4R4A4_UNORM: + return SurfaceFormat::Bgra4444; + case DXGI_FORMAT_BC2_UNORM: + return SurfaceFormat::Dxt3; + case DXGI_FORMAT_BC3_UNORM: + return SurfaceFormat::Dxt5; + case DXGI_FORMAT_R8G8_SNORM: + return SurfaceFormat::NormalizedByte2; + case DXGI_FORMAT_R8G8B8A8_SNORM: + return SurfaceFormat::NormalizedByte4; + case DXGI_FORMAT_R10G10B10A2_UNORM: + return SurfaceFormat::Rgba1010102; + case DXGI_FORMAT_R16G16_UNORM: + return SurfaceFormat::Rg32; + case DXGI_FORMAT_R16G16B16A16_UNORM: + return SurfaceFormat::Rgba64; + case DXGI_FORMAT_A8_UNORM: + return SurfaceFormat::Alpha8; + case DXGI_FORMAT_R32_FLOAT: + return SurfaceFormat::Single; + case DXGI_FORMAT_R32G32_FLOAT: + return SurfaceFormat::Vector2; + case DXGI_FORMAT_R32G32B32A32_FLOAT: + return SurfaceFormat::Vector4; + case DXGI_FORMAT_R16_FLOAT: + return SurfaceFormat::HalfSingle; + case DXGI_FORMAT_R16G16_FLOAT: + return SurfaceFormat::HalfVector2; + case DXGI_FORMAT_R16G16B16A16_FLOAT: + return SurfaceFormat::HalfVector4; + default: + return SurfaceFormat::Unknown; + } + } + + static constexpr Blend BlendToXna(D3D11_BLEND blend) { + switch (blend) { + case D3D11_BLEND_ZERO: + return Blend::Zero; + case D3D11_BLEND_ONE: + return Blend::One; + case D3D11_BLEND_SRC_COLOR: + return Blend::SourceColor; + case D3D11_BLEND_INV_SRC_COLOR: + return Blend::InverseSourceColor; + case D3D11_BLEND_SRC_ALPHA: + return Blend::SourceAlpha; + case D3D11_BLEND_INV_SRC_ALPHA: + return Blend::InverseSourceAlpha; + case D3D11_BLEND_DEST_ALPHA: + return Blend::DestinationAlpha; + case D3D11_BLEND_INV_DEST_ALPHA: + return Blend::InverseDestinationAlpha; + case D3D11_BLEND_DEST_COLOR: + return Blend::DestinationColor; + case D3D11_BLEND_INV_DEST_COLOR: + return Blend::InverseDestinationColor; + case D3D11_BLEND_SRC_ALPHA_SAT: + return Blend::SourceAlphaSaturation; + case D3D11_BLEND_BLEND_FACTOR: + return Blend::BlendFactor; + case D3D11_BLEND_INV_BLEND_FACTOR: + return Blend::InverseBlendFactor; + case D3D11_BLEND_SRC1_COLOR: + return Blend::Source1Color; + case D3D11_BLEND_INV_SRC1_COLOR: + return Blend::InverseSource1Color; + case D3D11_BLEND_SRC1_ALPHA: + return Blend::Source1Alpha; + case D3D11_BLEND_INV_SRC1_ALPHA: + return Blend::InverseSource1Alpha; + default: + return Blend::Zero; + } + } + + static constexpr D3D11_BLEND BlendToDx(Blend blend) { + switch (blend) + { + case xna::Blend::Zero: + return D3D11_BLEND_ZERO; + case xna::Blend::One: + return D3D11_BLEND_ONE; + case xna::Blend::SourceColor: + return D3D11_BLEND_SRC_COLOR; + case xna::Blend::InverseSourceColor: + return D3D11_BLEND_INV_SRC_COLOR; + case xna::Blend::SourceAlpha: + return D3D11_BLEND_SRC_ALPHA; + case xna::Blend::InverseSourceAlpha: + return D3D11_BLEND_INV_SRC_ALPHA; + case xna::Blend::DestinationAlpha: + return D3D11_BLEND_DEST_ALPHA; + case xna::Blend::InverseDestinationAlpha: + return D3D11_BLEND_INV_DEST_ALPHA; + case xna::Blend::DestinationColor: + return D3D11_BLEND_DEST_COLOR; + case xna::Blend::InverseDestinationColor: + return D3D11_BLEND_INV_DEST_COLOR; + case xna::Blend::SourceAlphaSaturation: + return D3D11_BLEND_SRC_ALPHA_SAT; + case xna::Blend::BlendFactor: + return D3D11_BLEND_BLEND_FACTOR; + case xna::Blend::InverseBlendFactor: + return D3D11_BLEND_INV_BLEND_FACTOR; + case xna::Blend::Source1Color: + return D3D11_BLEND_SRC1_COLOR; + case xna::Blend::InverseSource1Color: + return D3D11_BLEND_INV_SRC1_COLOR; + case xna::Blend::Source1Alpha: + return D3D11_BLEND_SRC1_ALPHA; + case xna::Blend::InverseSource1Alpha: + return D3D11_BLEND_INV_SRC1_ALPHA; + default: + return D3D11_BLEND_ZERO; + } + } + + static constexpr D3D11_BLEND_OP BlendOperationToDx(BlendOperation op) { + return static_cast(static_cast(op) + 1); + } + + static constexpr BlendOperation BlendOperationToXna(D3D11_BLEND_OP op) { + return static_cast(static_cast(op) - 1); + } + + static constexpr D3D11_COLOR_WRITE_ENABLE ColorWriteChannelsToDx(ColorWriteChannels colorWrite) { + switch (colorWrite) + { + case xna::ColorWriteChannels::Red: + return D3D11_COLOR_WRITE_ENABLE_RED; + case xna::ColorWriteChannels::Green: + return D3D11_COLOR_WRITE_ENABLE_GREEN; + case xna::ColorWriteChannels::Blue: + return D3D11_COLOR_WRITE_ENABLE_BLUE; + case xna::ColorWriteChannels::Alpha: + return D3D11_COLOR_WRITE_ENABLE_ALPHA; + case xna::ColorWriteChannels::All: + return D3D11_COLOR_WRITE_ENABLE_ALL; + default: + return D3D11_COLOR_WRITE_ENABLE_ALL; + } + } + + static constexpr D3D11_TEXTURE_ADDRESS_MODE TextureAddresModeToDx(TextureAddressMode value) { + return static_cast(static_cast(value) + 1); + } + + static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) { + return static_cast(value - 1); + } + + }; +} + +#endif \ No newline at end of file diff --git a/includes/xna-dx/implementations.hpp b/includes/xna-dx/implementations.hpp new file mode 100644 index 0000000..0927318 --- /dev/null +++ b/includes/xna-dx/implementations.hpp @@ -0,0 +1,310 @@ +#ifndef XNA_DX_IMPLEMENTATIONS_HPP +#define XNA_DX_IMPLEMENTATIONS_HPP + +#include "headers.hpp" + +namespace xna { + struct SpriteFont::PlatformImplementation { + uptr dxSpriteFont{ nullptr }; + }; + + struct SpriteBatch::PlatformImplementation { + sptr dxSpriteBatch = nullptr; + comptr dxInputLayout = nullptr; + sptr dxEffectBuffer = nullptr; + }; + + struct GraphicsAdapter::PlatformImplementation { + comptr dxAdapter = nullptr; + comptr dxFactory = nullptr; + }; + + struct BlendRenderTarget { + bool Enabled{ true }; + Blend Source{ Blend::SourceAlpha }; + Blend Destination{ Blend::InverseSourceAlpha }; + BlendOperation Operation{ BlendOperation::Add }; + Blend SourceAlpha{ Blend::One }; + Blend DestinationAlpha{ Blend::Zero }; + BlendOperation OperationAlpha{ BlendOperation::Add }; + ColorWriteChannels WriteMask{ ColorWriteChannels::All }; + + constexpr BlendRenderTarget() = default; + }; + + struct BlendState::PlatformImplementation { + comptr dxBlendState = nullptr; + D3D11_BLEND_DESC dxDescription{}; + float blendFactor[4]{ 1.0F, 1.0F, 1.0F, 1.0F }; + UINT sampleMask{ 0xffffffff }; + }; + + struct DepthStencilState::PlatformImplementation { + comptr dxDepthStencil = nullptr; + D3D11_DEPTH_STENCIL_DESC dxDescription{}; + }; + + struct GamePad::PlatformImplementation { + uptr _dxGamePad = unew(); + + void Suspend() const { + if (_dxGamePad) + _dxGamePad->Suspend(); + } + + void Resume() const { + if (_dxGamePad) + _dxGamePad->Resume(); + } + }; + + struct Keyboard::PlatformImplementation { + PlatformImplementation() { + _dxKeyboard = unew(); + } + + uptr _dxKeyboard = nullptr; + + inline void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const { + if (_dxKeyboard) + _dxKeyboard->ProcessMessage(message, wParam, lParam); + } + }; + + struct Mouse::PlatformImplementation { + PlatformImplementation() { + _dxMouse = unew(); + } + + inline void ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) const { + if (_dxMouse) + _dxMouse->ProcessMessage(message, wParam, lParam); + } + + uptr _dxMouse = nullptr; + }; + + struct RasterizerState::PlatformImplementation { + comptr dxRasterizerState = nullptr; + D3D11_RASTERIZER_DESC dxDescription{}; + }; + + struct SamplerState::PlatformImplementation { + comptr _samplerState = nullptr; + D3D11_SAMPLER_DESC _description{}; + }; + + struct SwapChain::PlatformImplementation { + comptr dxSwapChain{ nullptr }; + DXGI_SWAP_CHAIN_DESC1 dxDescription{}; + DXGI_SWAP_CHAIN_FULLSCREEN_DESC dxFullScreenDescription{}; + + bool GetBackBuffer(comptr& texture2D) const { + if (!dxSwapChain) + return false; + + const auto hr = dxSwapChain->GetBuffer(0, __uuidof(texture2D), (void**)texture2D.GetAddressOf()); + + return !FAILED(hr); + } + }; + + struct Texture2D::PlatformImplementation { + comptr dxTexture2D{ nullptr }; + comptr dxShaderResource{ nullptr }; + D3D11_SUBRESOURCE_DATA dxSubResource{}; + D3D11_TEXTURE2D_DESC dxDescription{}; + D3D11_SHADER_RESOURCE_VIEW_DESC dxShaderDescription{}; + }; + + struct RenderTarget2D::PlatformImplementation { + comptr _renderTargetView = nullptr; + D3D11_RENDER_TARGET_VIEW_DESC _renderTargetDesc{}; + }; + + enum class GameWindowMode : UINT { + Fullscreen = WS_POPUP | WS_VISIBLE, + Windowed = WS_OVERLAPPED | WS_SYSMENU | WS_VISIBLE, + Borderless = WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE, + }; + + struct GameWindow::PlatformImplementation { + public: + PlatformImplementation(GameWindow* gameWindow) : gameWindow(gameWindow) {} + + constexpr void Mode(GameWindowMode mode) { + _windowStyle = static_cast(mode); + } + + constexpr GameWindowMode Mode() const { + return static_cast(_windowStyle); + } + + void Position(int width, int height, bool update = true); + void Size(int width, int height, bool update = true); + + inline HINSTANCE HInstance() const { + return _hInstance; + } + + inline HWND WindowHandle() const { + return _windowHandle; + } + + constexpr int Width() const { + return _windowWidth; + } + + constexpr int Height() const { + return _windowHeight; + } + + inline void Icon(unsigned int icon) { + _windowIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(icon)); + } + + inline void Icon(HICON icon) { + _windowIcon = icon; + } + + inline void Cursor(unsigned int cursor) { + _windowCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(cursor)); + } + + inline void Cursor(HCURSOR cursor) { + _windowCursor = cursor; + } + + constexpr float CenterX() const { + return _windowCenterX; + } + + constexpr float CenterY() const { + return _windowCenterY; + } + + inline void CursorVisibility(bool visible) const { + ShowCursor(visible); + } + + inline void Close() const { + PostMessage(_windowHandle, WM_DESTROY, 0, 0); + } + + constexpr COLORREF Color() const { + return _windowColor; + } + + constexpr void Color(COLORREF color) { + _windowColor = color; + } + + constexpr void Color(BYTE r, BYTE g, BYTE b) { + _windowColor = RGB(r, g, b); + } + + bool Create(); + bool Update(); + + static LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + + private: + friend class GameWindow; + GameWindow* gameWindow = nullptr; + + HINSTANCE _hInstance{ nullptr }; + HWND _windowHandle{ nullptr }; + int _windowWidth{ 800 }; + int _windowHeight{ 480 }; + HICON _windowIcon{ nullptr }; + HCURSOR _windowCursor{ nullptr }; + COLORREF _windowColor{ RGB(0,0,0) }; + String _windowTitle{ "Xna++ Game Development" }; + DWORD _windowStyle{ 0 }; + int _windowPosX{ 0 }; + int _windowPosY{ 0 }; + float _windowCenterX{ 0 }; + float _windowCenterY{ 0 }; + + inline void setPosition() { + _windowPosX = GetSystemMetrics(SM_CXSCREEN) / 2 - _windowWidth / 2; + _windowPosY = GetSystemMetrics(SM_CYSCREEN) / 2 - _windowHeight / 2; + } + + inline void setCenter() { + _windowCenterX = _windowWidth / 2.0f; + _windowCenterY = _windowHeight / 2.0f; + } + }; + + struct AudioEngine::PlatformImplementation { + PlatformImplementation() { + _dxAudioEngine = unew( +#ifdef _DEBUG + DirectX::AudioEngine_Debug +#endif + ); + } + + ~PlatformImplementation() { + if (_dxAudioEngine) { + _dxAudioEngine->Suspend(); + } + } + + uptr _dxAudioEngine = nullptr; + }; + + struct GraphicsDevice::PlatformImplementation { + comptr _device = nullptr; + comptr _context = nullptr; + comptr _factory = nullptr; + + sptr _swapChain = nullptr; + sptr _renderTarget2D = nullptr; + intptr_t windowHandle{ 0 }; + + D3D_FEATURE_LEVEL featureLevels[7] = + { + D3D_FEATURE_LEVEL_11_1, + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_3, + D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1, + }; + + D3D_FEATURE_LEVEL currentFeatureLevel{ D3D_FEATURE_LEVEL_11_1 }; + + private: + friend class GraphicsDevice; + float _backgroundColor[4] = { 0, 0, 0, 0 }; + UINT vSyncValue = 1; + }; + + struct Game::PlatformImplementation { + private: + friend class Game; + + xna::StepTimer _stepTimer{}; + }; + + struct SoundEffectInstance::PlatformImplementation { + uptr _dxInstance = nullptr; + }; + + struct SoundEffect::PlatformImplementation { + uptr _dxSoundEffect = nullptr; + }; + + struct Effect::PlatformImplementation { + sptr dxEffect = nullptr; + }; + + struct BasicEffect::PlatformImplementation { + sptr dxBasicEffect = nullptr; + }; +} + +#endif \ No newline at end of file diff --git a/includes/xna-dx/init.hpp b/includes/xna-dx/init.hpp new file mode 100644 index 0000000..265848a --- /dev/null +++ b/includes/xna-dx/init.hpp @@ -0,0 +1,43 @@ +#ifndef XNA_DX_INIT_HPP +#define XNA_DX_INIT_HPP + +#include "headers.hpp" + +namespace xna { + struct PlatformInit { + static void Init() { + InitRegisteredTypes(); + InitActivadors(); + } + + static void InitRegisteredTypes(); + static void InitActivadors(); + + private: + template + static void insertRegisteredReader(String const& readerName) { + const auto reader = typeof(); + //Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader }); + Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader }); + Type::NameOfRegisteredTypes.insert({ "Microsoft.Xna.Framework.Content." + readerName, reader }); + } + + template + static void insertRegisteredReader(String const& readerName, String const& microsoftNameFullName) { + const auto reader = typeof(); + //Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader }); + Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader }); + Type::NameOfRegisteredTypes.insert({ microsoftNameFullName, reader }); + } + + template + static void insertActivadorReader() { + ContentTypeReaderActivador::SetActivador(typeof(), []() -> sptr { + auto obj = snew(); + return reinterpret_pointer_cast(obj); + }); + } + }; +} + +#endif \ No newline at end of file diff --git a/includes/xna-dx/steptimer.hpp b/includes/xna-dx/steptimer.hpp new file mode 100644 index 0000000..7ce6746 --- /dev/null +++ b/includes/xna-dx/steptimer.hpp @@ -0,0 +1,185 @@ +#ifndef XNA_DX_STEPTIMER_HPP +#define XNA_DX_STEPTIMER_HPP + +#include "headers.hpp" + +namespace xna { + // Helper class for animation and simulation timing. + class StepTimer + { + public: + StepTimer() noexcept(false) : + m_elapsedTicks(0), + m_totalTicks(0), + m_leftOverTicks(0), + m_frameCount(0), + m_framesPerSecond(0), + m_framesThisSecond(0), + m_qpcSecondCounter(0), + m_isFixedTimeStep(false), + m_targetElapsedTicks(TicksPerSecond / 60) + { + if (!QueryPerformanceFrequency(&m_qpcFrequency)) + { + throw std::exception(); + } + + if (!QueryPerformanceCounter(&m_qpcLastTime)) + { + throw std::exception(); + } + + // Initialize max delta to 1/10 of a second. + m_qpcMaxDelta = static_cast(m_qpcFrequency.QuadPart / 10); + } + + // Get elapsed time since the previous Update call. + uint64_t GetElapsedTicks() const noexcept { return m_elapsedTicks; } + double GetElapsedSeconds() const noexcept { return TicksToSeconds(m_elapsedTicks); } + + // Get total time since the start of the program. + uint64_t GetTotalTicks() const noexcept { return m_totalTicks; } + double GetTotalSeconds() const noexcept { return TicksToSeconds(m_totalTicks); } + + // Get total number of updates since start of the program. + uint32_t GetFrameCount() const noexcept { return m_frameCount; } + + // Get the current framerate. + uint32_t GetFramesPerSecond() const noexcept { return m_framesPerSecond; } + + // Set whether to use fixed or variable timestep mode. + void SetFixedTimeStep(bool isFixedTimestep) noexcept { m_isFixedTimeStep = isFixedTimestep; } + + // Set how often to call Update when in fixed timestep mode. + void SetTargetElapsedTicks(uint64_t targetElapsed) noexcept { m_targetElapsedTicks = targetElapsed; } + void SetTargetElapsedSeconds(double targetElapsed) noexcept { m_targetElapsedTicks = SecondsToTicks(targetElapsed); } + + // Integer format represents time using 10,000,000 ticks per second. + static constexpr uint64_t TicksPerSecond = 10000000; + + static constexpr double TicksToSeconds(uint64_t ticks) noexcept { return static_cast(ticks) / TicksPerSecond; } + static constexpr uint64_t SecondsToTicks(double seconds) noexcept { return static_cast(seconds * TicksPerSecond); } + + // After an intentional timing discontinuity (for instance a blocking IO operation) + // call this to avoid having the fixed timestep logic attempt a set of catch-up + // Update calls. + + void ResetElapsedTime() + { + if (!QueryPerformanceCounter(&m_qpcLastTime)) + { + throw std::exception(); + } + + m_leftOverTicks = 0; + m_framesPerSecond = 0; + m_framesThisSecond = 0; + m_qpcSecondCounter = 0; + } + + // Update timer state, calling the specified Update function the appropriate number of times. + template + void Tick(const TUpdate& update) + { + // Query the current time. + LARGE_INTEGER currentTime; + + if (!QueryPerformanceCounter(¤tTime)) + { + throw std::exception(); + } + + uint64_t timeDelta = static_cast(currentTime.QuadPart - m_qpcLastTime.QuadPart); + + m_qpcLastTime = currentTime; + m_qpcSecondCounter += timeDelta; + + // Clamp excessively large time deltas (e.g. after paused in the debugger). + if (timeDelta > m_qpcMaxDelta) + { + timeDelta = m_qpcMaxDelta; + } + + // Convert QPC units into a canonical tick format. This cannot overflow due to the previous clamp. + timeDelta *= TicksPerSecond; + timeDelta /= static_cast(m_qpcFrequency.QuadPart); + + const uint32_t lastFrameCount = m_frameCount; + + if (m_isFixedTimeStep) + { + // Fixed timestep update logic + + // If the app is running very close to the target elapsed time (within 1/4 of a millisecond) just clamp + // the clock to exactly match the target value. This prevents tiny and irrelevant errors + // from accumulating over time. Without this clamping, a game that requested a 60 fps + // fixed update, running with vsync enabled on a 59.94 NTSC display, would eventually + // accumulate enough tiny errors that it would drop a frame. It is better to just round + // small deviations down to zero to leave things running smoothly. + + if (static_cast(std::abs(static_cast(timeDelta - m_targetElapsedTicks))) < TicksPerSecond / 4000) + { + timeDelta = m_targetElapsedTicks; + } + + m_leftOverTicks += timeDelta; + + while (m_leftOverTicks >= m_targetElapsedTicks) + { + m_elapsedTicks = m_targetElapsedTicks; + m_totalTicks += m_targetElapsedTicks; + m_leftOverTicks -= m_targetElapsedTicks; + m_frameCount++; + + update(); + } + } + else + { + // Variable timestep update logic. + m_elapsedTicks = timeDelta; + m_totalTicks += timeDelta; + m_leftOverTicks = 0; + m_frameCount++; + + update(); + } + + // Track the current framerate. + if (m_frameCount != lastFrameCount) + { + m_framesThisSecond++; + } + + if (m_qpcSecondCounter >= static_cast(m_qpcFrequency.QuadPart)) + { + m_framesPerSecond = m_framesThisSecond; + m_framesThisSecond = 0; + m_qpcSecondCounter %= static_cast(m_qpcFrequency.QuadPart); + } + } + + private: + // Source timing data uses QPC units. + LARGE_INTEGER m_qpcFrequency; + LARGE_INTEGER m_qpcLastTime; + uint64_t m_qpcMaxDelta; + + // Derived timing data uses a canonical tick format. + uint64_t m_elapsedTicks; + uint64_t m_totalTicks; + uint64_t m_leftOverTicks; + + // Members for tracking the framerate. + uint32_t m_frameCount; + uint32_t m_framesPerSecond; + uint32_t m_framesThisSecond; + uint64_t m_qpcSecondCounter; + + // Members for configuring fixed timestep mode. + bool m_isFixedTimeStep; + uint64_t m_targetElapsedTicks; + }; +} + +#endif \ No newline at end of file diff --git a/inc/xna/audio/audioengine.hpp b/includes/xna/audio/audioengine.hpp similarity index 100% rename from inc/xna/audio/audioengine.hpp rename to includes/xna/audio/audioengine.hpp diff --git a/inc/xna/audio/soundeffect.hpp b/includes/xna/audio/soundeffect.hpp similarity index 100% rename from inc/xna/audio/soundeffect.hpp rename to includes/xna/audio/soundeffect.hpp diff --git a/inc/xna/common/collision.hpp b/includes/xna/common/collision.hpp similarity index 100% rename from inc/xna/common/collision.hpp rename to includes/xna/common/collision.hpp diff --git a/inc/xna/common/color.hpp b/includes/xna/common/color.hpp similarity index 100% rename from inc/xna/common/color.hpp rename to includes/xna/common/color.hpp diff --git a/inc/xna/common/curve.hpp b/includes/xna/common/curve.hpp similarity index 100% rename from inc/xna/common/curve.hpp rename to includes/xna/common/curve.hpp diff --git a/inc/xna/common/math.hpp b/includes/xna/common/math.hpp similarity index 100% rename from inc/xna/common/math.hpp rename to includes/xna/common/math.hpp diff --git a/inc/xna/common/numerics.hpp b/includes/xna/common/numerics.hpp similarity index 100% rename from inc/xna/common/numerics.hpp rename to includes/xna/common/numerics.hpp diff --git a/inc/xna/common/packedvalue.hpp b/includes/xna/common/packedvalue.hpp similarity index 100% rename from inc/xna/common/packedvalue.hpp rename to includes/xna/common/packedvalue.hpp diff --git a/inc/xna/content/lzx/decoder.hpp b/includes/xna/content/lzx/decoder.hpp similarity index 100% rename from inc/xna/content/lzx/decoder.hpp rename to includes/xna/content/lzx/decoder.hpp diff --git a/inc/xna/content/manager.hpp b/includes/xna/content/manager.hpp similarity index 100% rename from inc/xna/content/manager.hpp rename to includes/xna/content/manager.hpp diff --git a/inc/xna/content/reader.hpp b/includes/xna/content/reader.hpp similarity index 100% rename from inc/xna/content/reader.hpp rename to includes/xna/content/reader.hpp diff --git a/inc/xna/content/readers/audio.hpp b/includes/xna/content/readers/audio.hpp similarity index 100% rename from inc/xna/content/readers/audio.hpp rename to includes/xna/content/readers/audio.hpp diff --git a/inc/xna/content/readers/default.hpp b/includes/xna/content/readers/default.hpp similarity index 100% rename from inc/xna/content/readers/default.hpp rename to includes/xna/content/readers/default.hpp diff --git a/inc/xna/content/readers/graphics.hpp b/includes/xna/content/readers/graphics.hpp similarity index 100% rename from inc/xna/content/readers/graphics.hpp rename to includes/xna/content/readers/graphics.hpp diff --git a/inc/xna/content/typereadermanager.hpp b/includes/xna/content/typereadermanager.hpp similarity index 100% rename from inc/xna/content/typereadermanager.hpp rename to includes/xna/content/typereadermanager.hpp diff --git a/inc/xna/csharp/binary.hpp b/includes/xna/csharp/binary.hpp similarity index 100% rename from inc/xna/csharp/binary.hpp rename to includes/xna/csharp/binary.hpp diff --git a/inc/xna/csharp/buffer.hpp b/includes/xna/csharp/buffer.hpp similarity index 100% rename from inc/xna/csharp/buffer.hpp rename to includes/xna/csharp/buffer.hpp diff --git a/inc/xna/csharp/eventhandler.hpp b/includes/xna/csharp/eventhandler.hpp similarity index 100% rename from inc/xna/csharp/eventhandler.hpp rename to includes/xna/csharp/eventhandler.hpp diff --git a/inc/xna/csharp/screen.hpp b/includes/xna/csharp/screen.hpp similarity index 100% rename from inc/xna/csharp/screen.hpp rename to includes/xna/csharp/screen.hpp diff --git a/inc/xna/csharp/service.hpp b/includes/xna/csharp/service.hpp similarity index 100% rename from inc/xna/csharp/service.hpp rename to includes/xna/csharp/service.hpp diff --git a/inc/xna/csharp/stream.hpp b/includes/xna/csharp/stream.hpp similarity index 100% rename from inc/xna/csharp/stream.hpp rename to includes/xna/csharp/stream.hpp diff --git a/inc/xna/csharp/timespan.hpp b/includes/xna/csharp/timespan.hpp similarity index 100% rename from inc/xna/csharp/timespan.hpp rename to includes/xna/csharp/timespan.hpp diff --git a/inc/xna/csharp/type.hpp b/includes/xna/csharp/type.hpp similarity index 100% rename from inc/xna/csharp/type.hpp rename to includes/xna/csharp/type.hpp diff --git a/inc/xna/default.hpp b/includes/xna/default.hpp similarity index 100% rename from inc/xna/default.hpp rename to includes/xna/default.hpp diff --git a/inc/xna/enumerations.hpp b/includes/xna/enumerations.hpp similarity index 100% rename from inc/xna/enumerations.hpp rename to includes/xna/enumerations.hpp diff --git a/inc/xna/exception.hpp b/includes/xna/exception.hpp similarity index 100% rename from inc/xna/exception.hpp rename to includes/xna/exception.hpp diff --git a/inc/xna/xna.hpp b/includes/xna/framework.hpp similarity index 100% rename from inc/xna/xna.hpp rename to includes/xna/framework.hpp diff --git a/inc/xna/game/component.hpp b/includes/xna/game/component.hpp similarity index 100% rename from inc/xna/game/component.hpp rename to includes/xna/game/component.hpp diff --git a/inc/xna/game/game.hpp b/includes/xna/game/game.hpp similarity index 100% rename from inc/xna/game/game.hpp rename to includes/xna/game/game.hpp diff --git a/inc/xna/game/gdeviceinfo.hpp b/includes/xna/game/gdeviceinfo.hpp similarity index 100% rename from inc/xna/game/gdeviceinfo.hpp rename to includes/xna/game/gdeviceinfo.hpp diff --git a/inc/xna/game/gdevicemanager.hpp b/includes/xna/game/gdevicemanager.hpp similarity index 100% rename from inc/xna/game/gdevicemanager.hpp rename to includes/xna/game/gdevicemanager.hpp diff --git a/inc/xna/game/servicecontainer.hpp b/includes/xna/game/servicecontainer.hpp similarity index 100% rename from inc/xna/game/servicecontainer.hpp rename to includes/xna/game/servicecontainer.hpp diff --git a/inc/xna/game/time.hpp b/includes/xna/game/time.hpp similarity index 100% rename from inc/xna/game/time.hpp rename to includes/xna/game/time.hpp diff --git a/inc/xna/game/window.hpp b/includes/xna/game/window.hpp similarity index 100% rename from inc/xna/game/window.hpp rename to includes/xna/game/window.hpp diff --git a/inc/xna/graphics/adapter.hpp b/includes/xna/graphics/adapter.hpp similarity index 100% rename from inc/xna/graphics/adapter.hpp rename to includes/xna/graphics/adapter.hpp diff --git a/inc/xna/graphics/blendstate.hpp b/includes/xna/graphics/blendstate.hpp similarity index 100% rename from inc/xna/graphics/blendstate.hpp rename to includes/xna/graphics/blendstate.hpp diff --git a/inc/xna/graphics/depthstencilstate.hpp b/includes/xna/graphics/depthstencilstate.hpp similarity index 100% rename from inc/xna/graphics/depthstencilstate.hpp rename to includes/xna/graphics/depthstencilstate.hpp diff --git a/inc/xna/graphics/device.hpp b/includes/xna/graphics/device.hpp similarity index 100% rename from inc/xna/graphics/device.hpp rename to includes/xna/graphics/device.hpp diff --git a/inc/xna/graphics/displaymode.hpp b/includes/xna/graphics/displaymode.hpp similarity index 100% rename from inc/xna/graphics/displaymode.hpp rename to includes/xna/graphics/displaymode.hpp diff --git a/inc/xna/graphics/effect.hpp b/includes/xna/graphics/effect.hpp similarity index 100% rename from inc/xna/graphics/effect.hpp rename to includes/xna/graphics/effect.hpp diff --git a/inc/xna/graphics/gresource.hpp b/includes/xna/graphics/gresource.hpp similarity index 100% rename from inc/xna/graphics/gresource.hpp rename to includes/xna/graphics/gresource.hpp diff --git a/inc/xna/graphics/presentparams.hpp b/includes/xna/graphics/presentparams.hpp similarity index 100% rename from inc/xna/graphics/presentparams.hpp rename to includes/xna/graphics/presentparams.hpp diff --git a/inc/xna/graphics/rasterizerstate.hpp b/includes/xna/graphics/rasterizerstate.hpp similarity index 100% rename from inc/xna/graphics/rasterizerstate.hpp rename to includes/xna/graphics/rasterizerstate.hpp diff --git a/inc/xna/graphics/rendertarget.hpp b/includes/xna/graphics/rendertarget.hpp similarity index 100% rename from inc/xna/graphics/rendertarget.hpp rename to includes/xna/graphics/rendertarget.hpp diff --git a/inc/xna/graphics/samplerstate.hpp b/includes/xna/graphics/samplerstate.hpp similarity index 100% rename from inc/xna/graphics/samplerstate.hpp rename to includes/xna/graphics/samplerstate.hpp diff --git a/inc/xna/graphics/sprite.hpp b/includes/xna/graphics/sprite.hpp similarity index 100% rename from inc/xna/graphics/sprite.hpp rename to includes/xna/graphics/sprite.hpp diff --git a/inc/xna/graphics/swapchain.hpp b/includes/xna/graphics/swapchain.hpp similarity index 100% rename from inc/xna/graphics/swapchain.hpp rename to includes/xna/graphics/swapchain.hpp diff --git a/inc/xna/graphics/texture.hpp b/includes/xna/graphics/texture.hpp similarity index 100% rename from inc/xna/graphics/texture.hpp rename to includes/xna/graphics/texture.hpp diff --git a/inc/xna/graphics/vertexposition.hpp b/includes/xna/graphics/vertexposition.hpp similarity index 100% rename from inc/xna/graphics/vertexposition.hpp rename to includes/xna/graphics/vertexposition.hpp diff --git a/inc/xna/graphics/viewport.hpp b/includes/xna/graphics/viewport.hpp similarity index 100% rename from inc/xna/graphics/viewport.hpp rename to includes/xna/graphics/viewport.hpp diff --git a/inc/xna/helpers.hpp b/includes/xna/helpers.hpp similarity index 100% rename from inc/xna/helpers.hpp rename to includes/xna/helpers.hpp diff --git a/inc/xna/input/gamepad.hpp b/includes/xna/input/gamepad.hpp similarity index 100% rename from inc/xna/input/gamepad.hpp rename to includes/xna/input/gamepad.hpp diff --git a/inc/xna/input/input-enums.hpp b/includes/xna/input/input-enums.hpp similarity index 100% rename from inc/xna/input/input-enums.hpp rename to includes/xna/input/input-enums.hpp diff --git a/inc/xna/input/keyboard.hpp b/includes/xna/input/keyboard.hpp similarity index 100% rename from inc/xna/input/keyboard.hpp rename to includes/xna/input/keyboard.hpp diff --git a/inc/xna/input/mouse.hpp b/includes/xna/input/mouse.hpp similarity index 100% rename from inc/xna/input/mouse.hpp rename to includes/xna/input/mouse.hpp diff --git a/samples/01_blank/CMakeLists.txt b/samples/01_blank/CMakeLists.txt index bba069c..9ecdeb3 100644 --- a/samples/01_blank/CMakeLists.txt +++ b/samples/01_blank/CMakeLists.txt @@ -10,4 +10,4 @@ if (CMAKE_VERSION VERSION_GREATER 3.12) endif() # TODO: Add tests and install targets if needed. -target_link_libraries(BlankApp Xn65) +target_link_libraries(BlankApp Xn65DX) diff --git a/samples/01_blank/xna.cpp b/samples/01_blank/xna.cpp index cc68a70..6141a87 100644 --- a/samples/01_blank/xna.cpp +++ b/samples/01_blank/xna.cpp @@ -1,8 +1,7 @@ // xna.cpp : Defines the entry point for the application. // -#include "xna/xna.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" using namespace std; using namespace xna; diff --git a/samples/02_PlatfformerStarterKit/CMakeLists.txt b/samples/02_PlatfformerStarterKit/CMakeLists.txt index 29b791e..d145299 100644 --- a/samples/02_PlatfformerStarterKit/CMakeLists.txt +++ b/samples/02_PlatfformerStarterKit/CMakeLists.txt @@ -11,5 +11,5 @@ endif() # TODO: Add tests and install targets if needed. target_link_libraries( - PlatformApp Xn65 + PlatformApp Xn65DX ) \ No newline at end of file diff --git a/samples/02_PlatfformerStarterKit/extensions.hpp b/samples/02_PlatfformerStarterKit/extensions.hpp index d578bd4..789b478 100644 --- a/samples/02_PlatfformerStarterKit/extensions.hpp +++ b/samples/02_PlatfformerStarterKit/extensions.hpp @@ -1,7 +1,7 @@ #ifndef PLATFORMSTARTERKIT_EXTENSIONS_HPP #define PLATFORMSTARTERKIT_EXTENSIONS_HPP -#include "xna/xna.hpp" +#include "headers.hpp" namespace PlatformerStarterKit { struct RectangleExtensions { diff --git a/samples/02_PlatfformerStarterKit/headers.hpp b/samples/02_PlatfformerStarterKit/headers.hpp index ca5e858..5f42ac2 100644 --- a/samples/02_PlatfformerStarterKit/headers.hpp +++ b/samples/02_PlatfformerStarterKit/headers.hpp @@ -1 +1 @@ -#include "xna/xna-dx.hpp" \ No newline at end of file +#include "xna-dx/framework.hpp" \ No newline at end of file diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 45257e9..24ef843 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -4,4 +4,4 @@ # Add source to this project's executable. add_subdirectory ("01_blank") -add_subdirectory ("02_PlatfformerStarterKit") +#add_subdirectory ("02_PlatfformerStarterKit") diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt new file mode 100644 index 0000000..b5a1cce --- /dev/null +++ b/sources/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory ("framework") +add_subdirectory ("framework-dx") diff --git a/sources/framework-dx/CMakeLists.txt b/sources/framework-dx/CMakeLists.txt new file mode 100644 index 0000000..56bd965 --- /dev/null +++ b/sources/framework-dx/CMakeLists.txt @@ -0,0 +1,37 @@ +# CMakeList.txt : CMake project for xna, include source and define +# project specific logic here. +# + +# Add source to this project's executable. +add_library (Xn65DX STATIC +"window.cpp" +"device.cpp" +"adapter.cpp" +"swapchain.cpp" +"rendertarget.cpp" +"texture.cpp" +"blendstate.cpp" +"game.cpp" +"gdevicemanager.cpp" +"rasterizerstate.cpp" +"samplerstate.cpp" +"sprite.cpp" +"depthstencilstate.cpp" +"keyboard.cpp" +"mouse.cpp" +"gamepad.cpp" +"soundeffect.cpp" +"init.cpp" +"audioengine.cpp" +"effect.cpp" +"screen.cpp") + +if (CMAKE_VERSION VERSION_GREATER 3.12) + set_property(TARGET Xn65DX PROPERTY CXX_STANDARD 20) +endif() + +find_package(directxtk CONFIG REQUIRED) + +target_link_libraries( + Xn65DX Xn65 D3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib Microsoft::DirectXTK dxguid.lib +) diff --git a/framework/platform-dx/adapter.cpp b/sources/framework-dx/adapter.cpp similarity index 99% rename from framework/platform-dx/adapter.cpp rename to sources/framework-dx/adapter.cpp index e522a20..b3d53d5 100644 --- a/framework/platform-dx/adapter.cpp +++ b/sources/framework-dx/adapter.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { static void setOutputVars(comptr const& adapter, String& deviceName, intptr_t& monitorHandle); diff --git a/framework/platform-dx/audioengine.cpp b/sources/framework-dx/audioengine.cpp similarity index 97% rename from framework/platform-dx/audioengine.cpp rename to sources/framework-dx/audioengine.cpp index 56f8226..4e4fbe9 100644 --- a/framework/platform-dx/audioengine.cpp +++ b/sources/framework-dx/audioengine.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { void AudioEngine::Initialize() { diff --git a/framework/platform-dx/blendstate.cpp b/sources/framework-dx/blendstate.cpp similarity index 99% rename from framework/platform-dx/blendstate.cpp rename to sources/framework-dx/blendstate.cpp index 6ee8ebe..30e38cb 100644 --- a/framework/platform-dx/blendstate.cpp +++ b/sources/framework-dx/blendstate.cpp @@ -1,6 +1,6 @@ #include "xna/graphics/blendstate.hpp" #include "xna/graphics/gresource.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { BlendState::BlendState() : BlendState(nullptr) {} diff --git a/framework/platform-dx/depthstencilstate.cpp b/sources/framework-dx/depthstencilstate.cpp similarity index 99% rename from framework/platform-dx/depthstencilstate.cpp rename to sources/framework-dx/depthstencilstate.cpp index dcbf545..8b86328 100644 --- a/framework/platform-dx/depthstencilstate.cpp +++ b/sources/framework-dx/depthstencilstate.cpp @@ -1,5 +1,5 @@ #include "xna/graphics/depthstencilstate.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { static D3D11_DEPTH_STENCIL_DESC defaultDesc() { diff --git a/framework/platform-dx/device.cpp b/sources/framework-dx/device.cpp similarity index 99% rename from framework/platform-dx/device.cpp rename to sources/framework-dx/device.cpp index 018dca0..bb1cbd0 100644 --- a/framework/platform-dx/device.cpp +++ b/sources/framework-dx/device.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { static void reset(GraphicsDevice::PlatformImplementation& impl); diff --git a/framework/platform-dx/effect.cpp b/sources/framework-dx/effect.cpp similarity index 99% rename from framework/platform-dx/effect.cpp rename to sources/framework-dx/effect.cpp index e67ed90..742e53e 100644 --- a/framework/platform-dx/effect.cpp +++ b/sources/framework-dx/effect.cpp @@ -1,5 +1,5 @@ #include "xna/graphics/effect.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" #include "xna/common/math.hpp" using DxBasicEffect = DirectX::BasicEffect; diff --git a/framework/platform-dx/game.cpp b/sources/framework-dx/game.cpp similarity index 99% rename from framework/platform-dx/game.cpp rename to sources/framework-dx/game.cpp index a52595a..80295bf 100644 --- a/framework/platform-dx/game.cpp +++ b/sources/framework-dx/game.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { Game::Game() { diff --git a/framework/platform-dx/gamepad.cpp b/sources/framework-dx/gamepad.cpp similarity index 99% rename from framework/platform-dx/gamepad.cpp rename to sources/framework-dx/gamepad.cpp index ec22f4e..d1f7d3f 100644 --- a/framework/platform-dx/gamepad.cpp +++ b/sources/framework-dx/gamepad.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" #include "xna/input/gamepad.hpp" namespace xna { diff --git a/framework/platform-dx/gdevicemanager.cpp b/sources/framework-dx/gdevicemanager.cpp similarity index 99% rename from framework/platform-dx/gdevicemanager.cpp rename to sources/framework-dx/gdevicemanager.cpp index bfdacdf..bd24b07 100644 --- a/framework/platform-dx/gdevicemanager.cpp +++ b/sources/framework-dx/gdevicemanager.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { static bool IsWindowOnAdapter(intptr_t windowHandle, GraphicsAdapter const& adapter); diff --git a/framework/platform-dx/init.cpp b/sources/framework-dx/init.cpp similarity index 99% rename from framework/platform-dx/init.cpp rename to sources/framework-dx/init.cpp index 7f69ee8..bf058b2 100644 --- a/framework/platform-dx/init.cpp +++ b/sources/framework-dx/init.cpp @@ -3,7 +3,7 @@ #include "xna/content/readers/audio.hpp" #include "xna/content/typereadermanager.hpp" #include "xna/content/readers/default.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { void Platform::Init() { diff --git a/framework/platform-dx/keyboard.cpp b/sources/framework-dx/keyboard.cpp similarity index 92% rename from framework/platform-dx/keyboard.cpp rename to sources/framework-dx/keyboard.cpp index 9cf2892..febe06d 100644 --- a/framework/platform-dx/keyboard.cpp +++ b/sources/framework-dx/keyboard.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { KeyboardState Keyboard::GetState() { diff --git a/framework/platform-dx/mouse.cpp b/sources/framework-dx/mouse.cpp similarity index 96% rename from framework/platform-dx/mouse.cpp rename to sources/framework-dx/mouse.cpp index d3f4171..8a2f454 100644 --- a/framework/platform-dx/mouse.cpp +++ b/sources/framework-dx/mouse.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { MouseState Mouse::GetState() { diff --git a/framework/platform-dx/rasterizerstate.cpp b/sources/framework-dx/rasterizerstate.cpp similarity index 99% rename from framework/platform-dx/rasterizerstate.cpp rename to sources/framework-dx/rasterizerstate.cpp index 777963f..0823ad7 100644 --- a/framework/platform-dx/rasterizerstate.cpp +++ b/sources/framework-dx/rasterizerstate.cpp @@ -1,5 +1,5 @@ #include "xna/graphics/rasterizerstate.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { diff --git a/framework/platform-dx/rendertarget.cpp b/sources/framework-dx/rendertarget.cpp similarity index 97% rename from framework/platform-dx/rendertarget.cpp rename to sources/framework-dx/rendertarget.cpp index 08a83ca..2f50f40 100644 --- a/framework/platform-dx/rendertarget.cpp +++ b/sources/framework-dx/rendertarget.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { RenderTarget2D::RenderTarget2D() : Texture2D(nullptr) { diff --git a/framework/platform-dx/samplerstate.cpp b/sources/framework-dx/samplerstate.cpp similarity index 99% rename from framework/platform-dx/samplerstate.cpp rename to sources/framework-dx/samplerstate.cpp index 5209173..6f5ed96 100644 --- a/framework/platform-dx/samplerstate.cpp +++ b/sources/framework-dx/samplerstate.cpp @@ -1,6 +1,6 @@ #include "xna/graphics/samplerstate.hpp" #include "xna/graphics/samplerstate.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { SamplerState::SamplerState() : SamplerState(nullptr){} diff --git a/framework/platform-dx/screen.cpp b/sources/framework-dx/screen.cpp similarity index 98% rename from framework/platform-dx/screen.cpp rename to sources/framework-dx/screen.cpp index 1af1482..0c03019 100644 --- a/framework/platform-dx/screen.cpp +++ b/sources/framework-dx/screen.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { diff --git a/framework/platform-dx/soundeffect.cpp b/sources/framework-dx/soundeffect.cpp similarity index 99% rename from framework/platform-dx/soundeffect.cpp rename to sources/framework-dx/soundeffect.cpp index 82c19e6..5da1386 100644 --- a/framework/platform-dx/soundeffect.cpp +++ b/sources/framework-dx/soundeffect.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" #include "xna/csharp/stream.hpp" using DxSoundEffect = DirectX::SoundEffect; diff --git a/framework/platform-dx/sprite.cpp b/sources/framework-dx/sprite.cpp similarity index 99% rename from framework/platform-dx/sprite.cpp rename to sources/framework-dx/sprite.cpp index 866eb37..6bc352d 100644 --- a/framework/platform-dx/sprite.cpp +++ b/sources/framework-dx/sprite.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" #include using DxSpriteBatch = DirectX::SpriteBatch; diff --git a/framework/platform-dx/swapchain.cpp b/sources/framework-dx/swapchain.cpp similarity index 99% rename from framework/platform-dx/swapchain.cpp rename to sources/framework-dx/swapchain.cpp index 04e6ebe..8da6314 100644 --- a/framework/platform-dx/swapchain.cpp +++ b/sources/framework-dx/swapchain.cpp @@ -1,6 +1,6 @@ #include "xna/graphics/adapter.hpp" #include "xna/graphics/swapchain.hpp" -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" #include "xna/graphics/device.hpp" namespace xna { diff --git a/framework/platform-dx/texture.cpp b/sources/framework-dx/texture.cpp similarity index 99% rename from framework/platform-dx/texture.cpp rename to sources/framework-dx/texture.cpp index a4955d1..8ae2d93 100644 --- a/framework/platform-dx/texture.cpp +++ b/sources/framework-dx/texture.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { static void setDefaultTexture2DDesc(Texture2D::PlatformImplementation& impl); diff --git a/framework/platform-dx/window.cpp b/sources/framework-dx/window.cpp similarity index 99% rename from framework/platform-dx/window.cpp rename to sources/framework-dx/window.cpp index 3f54760..01d5589 100644 --- a/framework/platform-dx/window.cpp +++ b/sources/framework-dx/window.cpp @@ -1,4 +1,4 @@ -#include "xna/xna-dx.hpp" +#include "xna-dx/framework.hpp" namespace xna { GameWindow::GameWindow() { diff --git a/sources/framework/CMakeLists.txt b/sources/framework/CMakeLists.txt new file mode 100644 index 0000000..82f9a8b --- /dev/null +++ b/sources/framework/CMakeLists.txt @@ -0,0 +1,27 @@ +# CMakeList.txt : CMake project for xna, include source and define +# project specific logic here. +# + +# Add source to this project's executable. +add_library (Xn65 STATIC +"csharp/stream.cpp" +"csharp/binary.cpp" +"csharp/type.cpp" +"game/component.cpp" +"game/servicecontainer.cpp" +"content/manager.cpp" +"content/reader.cpp" +"content/lzx/decoder.cpp" +"content/typereadermanager.cpp" +"common/color.cpp" +"common/collision.cpp" +"common/gjk.cpp" +"common/numerics.cpp" +"common/packedvalue.cpp" +"graphics/gresource.cpp" +"graphics/displaymode" +"exception.cpp") + +if (CMAKE_VERSION VERSION_GREATER 3.12) + set_property(TARGET Xn65 PROPERTY CXX_STANDARD 20) +endif() diff --git a/framework/common/collision.cpp b/sources/framework/common/collision.cpp similarity index 100% rename from framework/common/collision.cpp rename to sources/framework/common/collision.cpp diff --git a/framework/common/color.cpp b/sources/framework/common/color.cpp similarity index 100% rename from framework/common/color.cpp rename to sources/framework/common/color.cpp diff --git a/framework/common/gjk.cpp b/sources/framework/common/gjk.cpp similarity index 100% rename from framework/common/gjk.cpp rename to sources/framework/common/gjk.cpp diff --git a/framework/common/numerics.cpp b/sources/framework/common/numerics.cpp similarity index 100% rename from framework/common/numerics.cpp rename to sources/framework/common/numerics.cpp diff --git a/framework/common/packedvalue.cpp b/sources/framework/common/packedvalue.cpp similarity index 100% rename from framework/common/packedvalue.cpp rename to sources/framework/common/packedvalue.cpp diff --git a/framework/content/lzx/decoder.cpp b/sources/framework/content/lzx/decoder.cpp similarity index 56% rename from framework/content/lzx/decoder.cpp rename to sources/framework/content/lzx/decoder.cpp index 81ad46a..650e57c 100644 --- a/framework/content/lzx/decoder.cpp +++ b/sources/framework/content/lzx/decoder.cpp @@ -1,6 +1,6 @@ #include "xna/content/lzx/decoder.hpp" -#include "libmspack/mspack.h" -#include "libmspack/lzx.h" +//#include "libmspack/mspack.h" +//#include "libmspack/lzx.h" namespace xna { LzxDecoder::LzxDecoder(int window) { @@ -11,35 +11,35 @@ namespace xna { } int LzxDecoder::Decompress(Stream* inData, int inLen, Stream* outData, int outLen) { - mspack_file* input = nullptr; + /*mspack_file* input = nullptr; mspack_file* output = nullptr; auto lzxstream = lzxd_init( - //struct mspack_system* system, + struct mspack_system* system, nullptr, - //struct mspack_file* input, + struct mspack_file* input, input + inData->Position(), - //struct mspack_file* output, + struct mspack_file* output, output + outData->Position(), - //int window_bits, + int window_bits, window_bits, - //int reset_interval, + int reset_interval, 0, - //int input_buffer_size, + int input_buffer_size, inLen, - //off_t output_length, + off_t output_length, outLen, - //char is_delta + char is_delta 0 ); auto result = lzxd_decompress( - //struct lzxd_stream* lzx, + struct lzxd_stream* lzx, lzxstream, - //off_t out_bytes + off_t out_bytes 0 - ); + );*/ - return result; + return 0; } } \ No newline at end of file diff --git a/framework/content/manager.cpp b/sources/framework/content/manager.cpp similarity index 100% rename from framework/content/manager.cpp rename to sources/framework/content/manager.cpp diff --git a/framework/content/reader.cpp b/sources/framework/content/reader.cpp similarity index 100% rename from framework/content/reader.cpp rename to sources/framework/content/reader.cpp diff --git a/framework/content/typereadermanager.cpp b/sources/framework/content/typereadermanager.cpp similarity index 100% rename from framework/content/typereadermanager.cpp rename to sources/framework/content/typereadermanager.cpp diff --git a/framework/csharp/binary.cpp b/sources/framework/csharp/binary.cpp similarity index 100% rename from framework/csharp/binary.cpp rename to sources/framework/csharp/binary.cpp diff --git a/framework/csharp/stream.cpp b/sources/framework/csharp/stream.cpp similarity index 100% rename from framework/csharp/stream.cpp rename to sources/framework/csharp/stream.cpp diff --git a/framework/csharp/type.cpp b/sources/framework/csharp/type.cpp similarity index 100% rename from framework/csharp/type.cpp rename to sources/framework/csharp/type.cpp diff --git a/framework/exception.cpp b/sources/framework/exception.cpp similarity index 100% rename from framework/exception.cpp rename to sources/framework/exception.cpp diff --git a/framework/game/component.cpp b/sources/framework/game/component.cpp similarity index 100% rename from framework/game/component.cpp rename to sources/framework/game/component.cpp diff --git a/framework/game/servicecontainer.cpp b/sources/framework/game/servicecontainer.cpp similarity index 100% rename from framework/game/servicecontainer.cpp rename to sources/framework/game/servicecontainer.cpp diff --git a/framework/platform-dx/displaymode.cpp b/sources/framework/graphics/displaymode.cpp similarity index 97% rename from framework/platform-dx/displaymode.cpp rename to sources/framework/graphics/displaymode.cpp index 80a56c4..300dba3 100644 --- a/framework/platform-dx/displaymode.cpp +++ b/sources/framework/graphics/displaymode.cpp @@ -1,4 +1,3 @@ -#include "xna/xna-dx.hpp" #include "xna/graphics/displaymode.hpp" namespace xna { diff --git a/framework/graphics/gresource.cpp b/sources/framework/graphics/gresource.cpp similarity index 100% rename from framework/graphics/gresource.cpp rename to sources/framework/graphics/gresource.cpp