From 9fdeeaef8d6208ec40d178a6f575c58a34031ded Mon Sep 17 00:00:00 2001 From: Stephan Vedder Date: Fri, 11 Apr 2025 11:30:52 +0200 Subject: [PATCH 1/2] [CMAKE][CORE] Move compression library to core --- Core/Libraries/CMakeLists.txt | 2 +- Core/Libraries/Include/Lib/BaseTypeCore.h | 144 ++ .../Source/Compression/CMakeLists.txt | 15 +- .../Source/Compression/Compression.h | 2 +- .../Source/Compression/CompressionManager.cpp | 0 .../Source/Compression/EAC/btreeabout.cpp | 0 .../Source/Compression/EAC/btreecodex.h | 0 .../Source/Compression/EAC/btreedecode.cpp | 0 .../Source/Compression/EAC/btreeencode.cpp | 0 .../Libraries/Source/Compression/EAC/codex.h | 0 .../Libraries/Source/Compression/EAC/gimex.h | 0 .../Source/Compression/EAC/huffabout.cpp | 0 .../Source/Compression/EAC/huffcodex.h | 0 .../Source/Compression/EAC/huffdecode.cpp | 0 .../Source/Compression/EAC/huffencode.cpp | 0 .../Source/Compression/EAC/refabout.cpp | 0 .../Source/Compression/EAC/refcodex.h | 0 .../Source/Compression/EAC/refdecode.cpp | 0 .../Source/Compression/EAC/refencode.cpp | 0 .../Compression/LZHCompress/NoxCompress.cpp | 2 +- .../Compression/LZHCompress/NoxCompress.h | 0 Generals/Code/CMakeLists.txt | 4 +- Generals/Code/GameEngine/CMakeLists.txt | 4 +- Generals/Code/GameEngineDevice/CMakeLists.txt | 5 +- Generals/Code/Libraries/CMakeLists.txt | 4 +- .../Code/Libraries/Include/Lib/BaseType.h | 105 +- .../Source/Compression/CMakeLists.txt | 39 - .../Source/Compression/Compression.h | 71 - .../Source/Compression/CompressionManager.cpp | 509 ------- .../Source/Compression/EAC/btreeabout.cpp | 105 -- .../Source/Compression/EAC/btreecodex.h | 62 - .../Source/Compression/EAC/btreedecode.cpp | 165 --- .../Source/Compression/EAC/btreeencode.cpp | 710 ---------- .../Libraries/Source/Compression/EAC/codex.h | 123 -- .../Libraries/Source/Compression/EAC/gimex.h | 497 ------- .../Source/Compression/EAC/huffabout.cpp | 88 -- .../Source/Compression/EAC/huffcodex.h | 74 - .../Source/Compression/EAC/huffdecode.cpp | 570 -------- .../Source/Compression/EAC/huffencode.cpp | 1227 ----------------- .../Source/Compression/EAC/refabout.cpp | 105 -- .../Source/Compression/EAC/refcodex.h | 74 - .../Source/Compression/EAC/refdecode.cpp | 186 --- .../Source/Compression/EAC/refencode.cpp | 264 ---- .../Compression/LZHCompress/NoxCompress.cpp | 297 ---- .../Compression/LZHCompress/NoxCompress.h | 40 - Generals/Code/Main/CMakeLists.txt | 2 +- Generals/Code/Tools/Compress/CMakeLists.txt | 4 +- GeneralsMD/Code/CMakeLists.txt | 4 +- GeneralsMD/Code/GameEngine/CMakeLists.txt | 2 +- GeneralsMD/Code/Libraries/CMakeLists.txt | 2 - .../Code/Libraries/Include/Lib/BaseType.h | 110 +- GeneralsMD/Code/Tools/Compress/CMakeLists.txt | 2 +- 52 files changed, 173 insertions(+), 5446 deletions(-) create mode 100644 Core/Libraries/Include/Lib/BaseTypeCore.h rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/CMakeLists.txt (56%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/Compression.h (98%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/CompressionManager.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/btreeabout.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/btreecodex.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/btreedecode.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/btreeencode.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/codex.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/gimex.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/huffabout.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/huffcodex.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/huffdecode.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/huffencode.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/refabout.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/refcodex.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/refdecode.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/EAC/refencode.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp (99%) rename {GeneralsMD/Code => Core}/Libraries/Source/Compression/LZHCompress/NoxCompress.h (100%) delete mode 100644 Generals/Code/Libraries/Source/Compression/CMakeLists.txt delete mode 100644 Generals/Code/Libraries/Source/Compression/Compression.h delete mode 100644 Generals/Code/Libraries/Source/Compression/CompressionManager.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/btreeabout.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/btreecodex.h delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/btreedecode.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/btreeencode.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/codex.h delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/gimex.h delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/huffabout.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/huffcodex.h delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/huffdecode.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/huffencode.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/refabout.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/refcodex.h delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/refdecode.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/EAC/refencode.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp delete mode 100644 Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.h diff --git a/Core/Libraries/CMakeLists.txt b/Core/Libraries/CMakeLists.txt index 9640a7ac161..e7df7a0eca3 100644 --- a/Core/Libraries/CMakeLists.txt +++ b/Core/Libraries/CMakeLists.txt @@ -9,4 +9,4 @@ add_subdirectory(Source/EABrowserDispatch) add_subdirectory(Source/EABrowserEngine) -#add_subdirectory(Source/Compression) +add_subdirectory(Source/Compression) diff --git a/Core/Libraries/Include/Lib/BaseTypeCore.h b/Core/Libraries/Include/Lib/BaseTypeCore.h new file mode 100644 index 00000000000..193271d9bc5 --- /dev/null +++ b/Core/Libraries/Include/Lib/BaseTypeCore.h @@ -0,0 +1,144 @@ +/* +** Copyright 2025 Electronic Arts Inc. +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** 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 General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +// FILE: BaseTypeCore.h /////////////////////////////////////////////////////////// +// +// Project: RTS3 +// +// Basic types and constants +// Author: Michael S. Booth, January 1995, September 2000 +// TheSuperHackers @compile feliwir 11/04/2025 Move common BaseType.h code to BaseTypeCore.h +// +/////////////////////////////////////////////////////////////////////////////// + +// tell the compiler to only load this file once +#pragma once + + +#ifndef _BASE_TYPE_CORE_H_ +#define _BASE_TYPE_CORE_H_ + +#include +#include +// TheSuperHackers @compile feliwir 07/04/2025 Adds utility macros for cross-platform compatibility +#include + +/* +** Turn off some unneeded warnings. +** Within the windows headers themselves, Microsoft has disabled the warnings 4290, 4514, +** 4069, 4200, 4237, 4103, 4001, 4035, 4164. Makes you wonder, eh? +*/ + +// "unreferenced inline function has been removed" Yea, so what? +#pragma warning(disable : 4514) + +// Unreferenced local function removed. +#pragma warning(disable : 4505) + +// 'unreferenced formal parameter' +#pragma warning(disable : 4100) + +// 'identifier was truncated to '255' characters in the browser information': +// Tempates create LLLOOONNNGGG identifiers! +#pragma warning(disable : 4786) + +// 'function selected for automatic inline expansion'. Cool, but since we're treating +// warnings as errors, don't warn me about this! +#pragma warning(disable : 4711) + +#if 0 +// 'assignment within condition expression'. actually a pretty useful warning, +// but way too much existing code violates it. +//#pragma warning(disable : 4706) +#else +// actually, it turned out not to be too bad, so this is now ENABLED. (srj) +#pragma warning(error : 4706) +#endif + +// 'conditional expression is constant'. used lots in debug builds. +#pragma warning(disable : 4127) + +// 'nonstandard extension used : nameless struct/union'. MS headers violate this... +#pragma warning(disable : 4201) + +// 'unreachable code'. STL violates this... +#pragma warning(disable : 4702) + +// 'local variable is initialized but not referenced'. good thing to know about... +#pragma warning(error : 4189) + +// 'unreferenced local variable'. good thing to know about... +#pragma warning(error : 4101) + +#ifndef PI +#define PI 3.14159265359f +#define TWO_PI 6.28318530718f +#endif + +#ifndef NULL +//#define NULL ((void *)0) +#define NULL 0 // C++ doesn't like casting void *'s into other pointers +#endif + +// MSVC math.h defines overloaded functions with this name... +//#ifndef abs +//#define abs(x) (((x) < 0) ? -(x) : (x)) +//#endif + +#ifndef min +#define min(x,y) (((x)<(y)) ? (x) : (y)) +#endif + +#ifndef max +#define max(x,y) (((x)>(y)) ? (x) : (y)) +#endif + +#ifndef TRUE +#define TRUE true +#endif + +#ifndef FALSE +#define FALSE false +#endif + +// Elements in an array +#ifndef ELEMENTS_OF +#define ELEMENTS_OF( x ) ( sizeof( x ) / sizeof( x[0] ) ) +#endif + +//-------------------------------------------------------------------- +// Fundamental type definitions +//-------------------------------------------------------------------- +typedef float Real; // 4 bytes +typedef int Int; // 4 bytes +typedef unsigned int UnsignedInt; // 4 bytes +typedef unsigned short UnsignedShort; // 2 bytes +typedef short Short; // 2 bytes +typedef unsigned char UnsignedByte; // 1 byte USED TO BE "Byte" +typedef char Byte; // 1 byte USED TO BE "SignedByte" +typedef char Char; // 1 byte of text +typedef bool Bool; // +// note, the types below should use "long long", but MSVC doesn't support it yet +#ifdef _MSC_VER +typedef __int64 Int64; // 8 bytes +typedef unsigned __int64 UnsignedInt64; // 8 bytes +#else +typedef long long Int64; // 8 bytes +typedef unsigned long long UnsignedInt64; // 8 bytes +#endif + +#endif // _BASE_TYPE_CORE_H_ \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/Compression/CMakeLists.txt b/Core/Libraries/Source/Compression/CMakeLists.txt similarity index 56% rename from GeneralsMD/Code/Libraries/Source/Compression/CMakeLists.txt rename to Core/Libraries/Source/Compression/CMakeLists.txt index 784c4b83e5c..086bb9a1397 100644 --- a/GeneralsMD/Code/Libraries/Source/Compression/CMakeLists.txt +++ b/Core/Libraries/Source/Compression/CMakeLists.txt @@ -19,21 +19,22 @@ set(COMPRESSION_SRC Compression.h ) -add_library(z_compression STATIC) -set_target_properties(z_compression PROPERTIES OUTPUT_NAME compression) +add_library(core_compression STATIC) +set_target_properties(core_compression PROPERTIES OUTPUT_NAME compression) -target_sources(z_compression PRIVATE ${COMPRESSION_SRC}) +target_sources(core_compression PRIVATE ${COMPRESSION_SRC}) -target_include_directories(z_compression INTERFACE +target_include_directories(core_compression INTERFACE . ) -target_link_libraries(z_compression PRIVATE +target_link_libraries(core_compression PRIVATE core_config - zi_always + core_utility + corei_libraries_include ) -target_link_libraries(z_compression PUBLIC +target_link_libraries(core_compression PUBLIC liblzhl libzlib ) diff --git a/GeneralsMD/Code/Libraries/Source/Compression/Compression.h b/Core/Libraries/Source/Compression/Compression.h similarity index 98% rename from GeneralsMD/Code/Libraries/Source/Compression/Compression.h rename to Core/Libraries/Source/Compression/Compression.h index 4d967c8fcc9..f74b2d6301a 100644 --- a/GeneralsMD/Code/Libraries/Source/Compression/Compression.h +++ b/Core/Libraries/Source/Compression/Compression.h @@ -25,7 +25,7 @@ #ifndef __COMPRESSION_H__ #define __COMPRESSION_H__ -#include "Lib/BaseType.h" +#include "Lib/BaseTypeCore.h" enum CompressionType { diff --git a/GeneralsMD/Code/Libraries/Source/Compression/CompressionManager.cpp b/Core/Libraries/Source/Compression/CompressionManager.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/CompressionManager.cpp rename to Core/Libraries/Source/Compression/CompressionManager.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/btreeabout.cpp b/Core/Libraries/Source/Compression/EAC/btreeabout.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/btreeabout.cpp rename to Core/Libraries/Source/Compression/EAC/btreeabout.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/btreecodex.h b/Core/Libraries/Source/Compression/EAC/btreecodex.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/btreecodex.h rename to Core/Libraries/Source/Compression/EAC/btreecodex.h diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/btreedecode.cpp b/Core/Libraries/Source/Compression/EAC/btreedecode.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/btreedecode.cpp rename to Core/Libraries/Source/Compression/EAC/btreedecode.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/btreeencode.cpp b/Core/Libraries/Source/Compression/EAC/btreeencode.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/btreeencode.cpp rename to Core/Libraries/Source/Compression/EAC/btreeencode.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/codex.h b/Core/Libraries/Source/Compression/EAC/codex.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/codex.h rename to Core/Libraries/Source/Compression/EAC/codex.h diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/gimex.h b/Core/Libraries/Source/Compression/EAC/gimex.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/gimex.h rename to Core/Libraries/Source/Compression/EAC/gimex.h diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/huffabout.cpp b/Core/Libraries/Source/Compression/EAC/huffabout.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/huffabout.cpp rename to Core/Libraries/Source/Compression/EAC/huffabout.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/huffcodex.h b/Core/Libraries/Source/Compression/EAC/huffcodex.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/huffcodex.h rename to Core/Libraries/Source/Compression/EAC/huffcodex.h diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/huffdecode.cpp b/Core/Libraries/Source/Compression/EAC/huffdecode.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/huffdecode.cpp rename to Core/Libraries/Source/Compression/EAC/huffdecode.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/huffencode.cpp b/Core/Libraries/Source/Compression/EAC/huffencode.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/huffencode.cpp rename to Core/Libraries/Source/Compression/EAC/huffencode.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/refabout.cpp b/Core/Libraries/Source/Compression/EAC/refabout.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/refabout.cpp rename to Core/Libraries/Source/Compression/EAC/refabout.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/refcodex.h b/Core/Libraries/Source/Compression/EAC/refcodex.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/refcodex.h rename to Core/Libraries/Source/Compression/EAC/refcodex.h diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/refdecode.cpp b/Core/Libraries/Source/Compression/EAC/refdecode.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/refdecode.cpp rename to Core/Libraries/Source/Compression/EAC/refdecode.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/EAC/refencode.cpp b/Core/Libraries/Source/Compression/EAC/refencode.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/EAC/refencode.cpp rename to Core/Libraries/Source/Compression/EAC/refencode.cpp diff --git a/GeneralsMD/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp similarity index 99% rename from GeneralsMD/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp rename to Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp index 05f8ae05c33..36360865a6f 100644 --- a/GeneralsMD/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp +++ b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp @@ -22,7 +22,7 @@ #include #include -#include "Lib/BaseType.h" +#include "Lib/BaseTypeCore.h" #include "NoxCompress.h" #include "CompLibHeader/lzhl.h" diff --git a/GeneralsMD/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.h b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.h rename to Core/Libraries/Source/Compression/LZHCompress/NoxCompress.h diff --git a/Generals/Code/CMakeLists.txt b/Generals/Code/CMakeLists.txt index 4c3fe4da43b..a5c30b90cc8 100644 --- a/Generals/Code/CMakeLists.txt +++ b/Generals/Code/CMakeLists.txt @@ -24,8 +24,10 @@ target_include_directories(gi_libraries_source_wwvegas_wwmath INTERFACE "Librari target_include_directories(gi_libraries_source_wwvegas_wwsaveload INTERFACE "Libraries/Source/WWVegas/WWSaveLoad") target_include_directories(gi_main INTERFACE "Main") target_link_libraries(gi_always INTERFACE - gi_libraries_include core_utility + gi_libraries_include + # Must stay below so headers from game are included first + corei_libraries_include ) # Contains internal libraries diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index f9e4b226173..2db4f80a741 100644 --- a/Generals/Code/GameEngine/CMakeLists.txt +++ b/Generals/Code/GameEngine/CMakeLists.txt @@ -1084,13 +1084,13 @@ target_include_directories(g_gameengine PRIVATE ) target_link_libraries(g_gameengine PRIVATE - gi_libraries_include + gi_always ) target_link_libraries(g_gameengine PUBLIC d3d8lib core_browserdispatch - g_compression + core_compression g_wwvegas core_config core_utility diff --git a/Generals/Code/GameEngineDevice/CMakeLists.txt b/Generals/Code/GameEngineDevice/CMakeLists.txt index f054aa9ce1a..626197d0654 100644 --- a/Generals/Code/GameEngineDevice/CMakeLists.txt +++ b/Generals/Code/GameEngineDevice/CMakeLists.txt @@ -192,9 +192,8 @@ target_include_directories(g_gameenginedevice PUBLIC ) target_link_libraries(g_gameenginedevice PRIVATE - gi_libraries_include - gi_main - gi_always + gi_always + gi_main ) target_link_libraries(g_gameenginedevice PUBLIC diff --git a/Generals/Code/Libraries/CMakeLists.txt b/Generals/Code/Libraries/CMakeLists.txt index 406ad87198d..ae105f614de 100644 --- a/Generals/Code/Libraries/CMakeLists.txt +++ b/Generals/Code/Libraries/CMakeLists.txt @@ -1,4 +1,2 @@ # WW common libraries decended from earliest C&C games -add_subdirectory(Source/WWVegas) - -add_subdirectory(Source/Compression) +add_subdirectory(Source/WWVegas) \ No newline at end of file diff --git a/Generals/Code/Libraries/Include/Lib/BaseType.h b/Generals/Code/Libraries/Include/Lib/BaseType.h index 0eab9098478..ea94cf2fc37 100644 --- a/Generals/Code/Libraries/Include/Lib/BaseType.h +++ b/Generals/Code/Libraries/Include/Lib/BaseType.h @@ -32,110 +32,7 @@ #ifndef _BASE_TYPE_H_ #define _BASE_TYPE_H_ -#include -#include -// TheSuperHackers @compile feliwir 07/04/2025 Adds utility macros for cross-platform compatibility -#include - -/* -** Turn off some unneeded warnings. -** Within the windows headers themselves, Microsoft has disabled the warnings 4290, 4514, -** 4069, 4200, 4237, 4103, 4001, 4035, 4164. Makes you wonder, eh? -*/ - -// "unreferenced inline function has been removed" Yea, so what? -#pragma warning(disable : 4514) - -// Unreferenced local function removed. -#pragma warning(disable : 4505) - -// 'unreferenced formal parameter' -#pragma warning(disable : 4100) - -// 'identifier was truncated to '255' characters in the browser information': -// Tempates create LLLOOONNNGGG identifiers! -#pragma warning(disable : 4786) - -// 'function selected for automatic inline expansion'. Cool, but since we're treating -// warnings as errors, don't warn me about this! -#pragma warning(disable : 4711) - -#if 0 -// 'assignment within condition expression'. actually a pretty useful warning, -// but way too much existing code violates it. -//#pragma warning(disable : 4706) -#else -// actually, it turned out not to be too bad, so this is now ENABLED. (srj) -#pragma warning(error : 4706) -#endif - -// 'conditional expression is constant'. used lots in debug builds. -#pragma warning(disable : 4127) - -// 'nonstandard extension used : nameless struct/union'. MS headers violate this... -#pragma warning(disable : 4201) - -// 'unreachable code'. STL violates this... -#pragma warning(disable : 4702) - -// 'local variable is initialized but not referenced'. good thing to know about... -#pragma warning(error : 4189) - -// 'unreferenced local variable'. good thing to know about... -#pragma warning(error : 4101) - -#ifndef PI -#define PI 3.14159265359f -#define TWO_PI 6.28318530718f -#endif - -#ifndef NULL -//#define NULL ((void *)0) -#define NULL 0 // C++ doesn't like casting void *'s into other pointers -#endif - -// MSVC math.h defines overloaded functions with this name... -//#ifndef abs -//#define abs(x) (((x) < 0) ? -(x) : (x)) -//#endif - -#ifndef min -#define min(x,y) (((x)<(y)) ? (x) : (y)) -#endif - -#ifndef max -#define max(x,y) (((x)>(y)) ? (x) : (y)) -#endif - -#ifndef TRUE -#define TRUE true -#endif - -#ifndef FALSE -#define FALSE false -#endif - -//-------------------------------------------------------------------- -// Fundamental type definitions -//-------------------------------------------------------------------- -typedef float Real; // 4 bytes -typedef int Int; // 4 bytes -typedef unsigned int UnsignedInt; // 4 bytes -typedef unsigned short UnsignedShort; // 2 bytes -typedef short Short; // 2 bytes -typedef unsigned char UnsignedByte; // 1 byte USED TO BE "Byte" -typedef char Byte; // 1 byte USED TO BE "SignedByte" -typedef char Char; // 1 byte of text -typedef bool Bool; // -// note, the types below should use "long long", but MSVC doesn't support it yet -#ifdef _MSC_VER -typedef __int64 Int64; // 8 bytes -typedef unsigned __int64 UnsignedInt64; // 8 bytes -#else -typedef long long Int64; // 8 bytes -typedef unsigned long long UnsignedInt64; // 8 bytes -#endif - +#include "Lib/BaseTypeCore.h" #include "Lib/trig.h" //----------------------------------------------------------------------------- diff --git a/Generals/Code/Libraries/Source/Compression/CMakeLists.txt b/Generals/Code/Libraries/Source/Compression/CMakeLists.txt deleted file mode 100644 index 3cc3acb85f8..00000000000 --- a/Generals/Code/Libraries/Source/Compression/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -set(COMPRESSION_SRC - "EAC/btreeabout.cpp" - "EAC/btreedecode.cpp" - "EAC/btreeencode.cpp" - "EAC/huffabout.cpp" - "EAC/huffdecode.cpp" - "EAC/huffencode.cpp" - "EAC/refabout.cpp" - "EAC/refdecode.cpp" - "EAC/refencode.cpp" - "EAC/btreecodex.h" - "EAC/codex.h" - "EAC/gimex.h" - "EAC/huffcodex.h" - "EAC/refcodex.h" - "LZHCompress/NoxCompress.cpp" - "LZHCompress/NoxCompress.h" - "CompressionManager.cpp" - "Compression.h" -) - -add_library(g_compression STATIC) -set_target_properties(g_compression PROPERTIES OUTPUT_NAME compression) - -target_sources(g_compression PRIVATE ${COMPRESSION_SRC}) - -target_include_directories(g_compression INTERFACE - . -) - -target_link_libraries(g_compression PRIVATE - gi_always - core_config -) - -target_link_libraries(g_compression PUBLIC - liblzhl - libzlib -) diff --git a/Generals/Code/Libraries/Source/Compression/Compression.h b/Generals/Code/Libraries/Source/Compression/Compression.h deleted file mode 100644 index c4b6218a307..00000000000 --- a/Generals/Code/Libraries/Source/Compression/Compression.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: Compression.h /////////////////////////////////////////////////////// -// Author: Matthew D. Campbell -////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#ifndef __COMPRESSION_H__ -#define __COMPRESSION_H__ - -#include "Lib/BaseType.h" - -enum CompressionType -{ - COMPRESSION_MIN = 0, - COMPRESSION_NONE = COMPRESSION_MIN, - COMPRESSION_REFPACK, - COMPRESSION_MAX = COMPRESSION_REFPACK, - COMPRESSION_NOXLZH, - COMPRESSION_ZLIB1, - COMPRESSION_ZLIB2, - COMPRESSION_ZLIB3, - COMPRESSION_ZLIB4, - COMPRESSION_ZLIB5, - COMPRESSION_ZLIB6, - COMPRESSION_ZLIB7, - COMPRESSION_ZLIB8, - COMPRESSION_ZLIB9, - COMPRESSION_BTREE, - COMPRESSION_HUFF, -}; - -class CompressionManager -{ -public: - - static Bool isDataCompressed( const void *mem, Int len ); - static CompressionType getCompressionType( const void *mem, Int len ); - - static Int getMaxCompressedSize( Int uncompressedLen, CompressionType compType ); - static Int getUncompressedSize( const void *mem, Int len ); - - static Int compressData( CompressionType compType, void *src, Int srcLen, void *dest, Int destLen ); // 0 on error - static Int decompressData( void *src, Int srcLen, void *dest, Int destLen ); // 0 on error - - static const char *getCompressionNameByType( CompressionType compType ); - - // For perf timers, so we can have separate ones for compression/decompression - static const char *getDecompressionNameByType( CompressionType compType ); - - static CompressionType getPreferredCompression( void ); -}; - -#endif // __COMPRESSION_H__ diff --git a/Generals/Code/Libraries/Source/Compression/CompressionManager.cpp b/Generals/Code/Libraries/Source/Compression/CompressionManager.cpp deleted file mode 100644 index c65bbc653eb..00000000000 --- a/Generals/Code/Libraries/Source/Compression/CompressionManager.cpp +++ /dev/null @@ -1,509 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: Compression.cpp ///////////////////////////////////////////////////// -// Author: Matthew D. Campbell -// LZH wrapper taken from Nox, originally from Jeff Brown -////////////////////////////////////////////////////////////////////////////// - -#include "Compression.h" -#include "LZHCompress/NoxCompress.h" -extern "C" { -#include "ZLib/zlib.h" -} -#include "EAC/codex.h" -#include "EAC/btreecodex.h" -#include "EAC/huffcodex.h" -#include "EAC/refcodex.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma message("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -#define DEBUG_LOG(x) {} - -const char *CompressionManager::getCompressionNameByType( CompressionType compType ) -{ - static const char *s_compressionNames[COMPRESSION_MAX+1] = { - "No compression", - "RefPack", - /* - "LZHL", - "ZLib 1 (fast)", - "ZLib 2", - "ZLib 3", - "ZLib 4", - "ZLib 5 (default)", - "ZLib 6", - "ZLib 7", - "ZLib 8", - "ZLib 9 (slow)", - "BTree", - "Huff", - */ - }; - return s_compressionNames[compType]; -} - -// For perf timers, so we can have separate ones for compression/decompression -const char *CompressionManager::getDecompressionNameByType( CompressionType compType ) -{ - static const char *s_decompressionNames[COMPRESSION_MAX+1] = { - "d_None", - "d_RefPack", - /* - "d_NoxLZW", - "d_ZLib1", - "d_ZLib2", - "d_ZLib3", - "d_ZLib4", - "d_ZLib5", - "d_ZLib6", - "d_ZLib7", - "d_ZLib8", - "d_ZLib9", - "d_BTree", - "d_Huff", - */ - }; - return s_decompressionNames[compType]; -} - -// --------------------------------------------------------------------------------------- - -Bool CompressionManager::isDataCompressed( const void *mem, Int len ) -{ - CompressionType t = getCompressionType(mem, len); - return t != COMPRESSION_NONE; -} - -CompressionType CompressionManager::getPreferredCompression( void ) -{ - return COMPRESSION_REFPACK; -} - - -CompressionType CompressionManager::getCompressionType( const void *mem, Int len ) -{ - if (len < 8) - return COMPRESSION_NONE; - - if ( memcmp( mem, "NOX\0", 4 ) == 0 ) - return COMPRESSION_NOXLZH; - - if ( memcmp( mem, "ZL1\0", 4 ) == 0 ) - return COMPRESSION_ZLIB1; - if ( memcmp( mem, "ZL2\0", 4 ) == 0 ) - return COMPRESSION_ZLIB2; - if ( memcmp( mem, "ZL3\0", 4 ) == 0 ) - return COMPRESSION_ZLIB3; - if ( memcmp( mem, "ZL4\0", 4 ) == 0 ) - return COMPRESSION_ZLIB4; - if ( memcmp( mem, "ZL5\0", 4 ) == 0 ) - return COMPRESSION_ZLIB5; - if ( memcmp( mem, "ZL6\0", 4 ) == 0 ) - return COMPRESSION_ZLIB6; - if ( memcmp( mem, "ZL7\0", 4 ) == 0 ) - return COMPRESSION_ZLIB7; - if ( memcmp( mem, "ZL8\0", 4 ) == 0 ) - return COMPRESSION_ZLIB8; - if ( memcmp( mem, "ZL9\0", 4 ) == 0 ) - return COMPRESSION_ZLIB9; - if ( memcmp( mem, "EAB\0", 4 ) == 0 ) - return COMPRESSION_BTREE; - if ( memcmp( mem, "EAH\0", 4 ) == 0 ) - return COMPRESSION_HUFF; - if ( memcmp( mem, "EAR\0", 4 ) == 0 ) - return COMPRESSION_REFPACK; - - return COMPRESSION_NONE; -} - -Int CompressionManager::getMaxCompressedSize( Int uncompressedLen, CompressionType compType ) -{ - switch (compType) - { - case COMPRESSION_NOXLZH: - return CalcNewSize(uncompressedLen) + 8; - - case COMPRESSION_BTREE: // guessing here - case COMPRESSION_HUFF: // guessing here - case COMPRESSION_REFPACK: // guessing here - return uncompressedLen + 8; - - case COMPRESSION_ZLIB1: - case COMPRESSION_ZLIB2: - case COMPRESSION_ZLIB3: - case COMPRESSION_ZLIB4: - case COMPRESSION_ZLIB5: - case COMPRESSION_ZLIB6: - case COMPRESSION_ZLIB7: - case COMPRESSION_ZLIB8: - case COMPRESSION_ZLIB9: - return (Int)(ceil(uncompressedLen * 1.1 + 12 + 8)); - } - - return 0; -} - -Int CompressionManager::getUncompressedSize( const void *mem, Int len ) -{ - if (len < 8) - return len; - - CompressionType compType = getCompressionType( mem, len ); - switch (compType) - { - case COMPRESSION_NOXLZH: - case COMPRESSION_ZLIB1: - case COMPRESSION_ZLIB2: - case COMPRESSION_ZLIB3: - case COMPRESSION_ZLIB4: - case COMPRESSION_ZLIB5: - case COMPRESSION_ZLIB6: - case COMPRESSION_ZLIB7: - case COMPRESSION_ZLIB8: - case COMPRESSION_ZLIB9: - case COMPRESSION_BTREE: - case COMPRESSION_HUFF: - case COMPRESSION_REFPACK: - return *(Int *)(((UnsignedByte *)mem)+4); - } - - return len; -} - -Int CompressionManager::compressData( CompressionType compType, void *srcVoid, Int srcLen, void *destVoid, Int destLen ) -{ - if (destLen < 8) - return 0; - - destLen -= 8; - - UnsignedByte *src = (UnsignedByte *)srcVoid; - UnsignedByte *dest = (UnsignedByte *)destVoid; - - if (compType == COMPRESSION_BTREE) - { - memcpy(dest, "EAB\0", 4); - *(Int *)(dest+4) = 0; - Int ret = BTREE_encode(dest+8, src, srcLen); - if (ret) - { - *(Int *)(dest+4) = srcLen; - return ret + 8; - } - else - return 0; - } - if (compType == COMPRESSION_HUFF) - { - memcpy(dest, "EAH\0", 4); - *(Int *)(dest+4) = 0; - Int ret = HUFF_encode(dest+8, src, srcLen); - if (ret) - { - *(Int *)(dest+4) = srcLen; - return ret + 8; - } - else - return 0; - } - if (compType == COMPRESSION_REFPACK) - { - memcpy(dest, "EAR\0", 4); - *(Int *)(dest+4) = 0; - Int ret = REF_encode(dest+8, src, srcLen); - if (ret) - { - *(Int *)(dest+4) = srcLen; - return ret + 8; - } - else - return 0; - } - - if (compType == COMPRESSION_NOXLZH) - { - memcpy(dest, "NOX\0", 4); - *(Int *)(dest+4) = 0; - Bool ret = CompressMemory(src, srcLen, dest+8, destLen); - if (ret) - { - *(Int *)(dest+4) = srcLen; - return destLen + 8; - } - else - return 0; - } - - if (compType >= COMPRESSION_ZLIB1 && compType <= COMPRESSION_ZLIB9) - { - Int level = compType - COMPRESSION_ZLIB1 + 1; // 1-9 - memcpy(dest, "ZL0\0", 4); - dest[2] = '0' + level; - *(Int *)(dest+4) = 0; - - unsigned long outLen = destLen; - Int err = z_compress2( dest+8, &outLen, src, srcLen, level ); - - if (err == Z_OK || err == Z_STREAM_END) - { - *(Int *)(dest+4) = srcLen; - return outLen + 8; - } - else - { - DEBUG_LOG(("ZLib compression error (level is %d, src len is %d) %d\n", level, srcLen, err)); - return 0; - } - } - - return 0; -} - -Int CompressionManager::decompressData( void *srcVoid, Int srcLen, void *destVoid, Int destLen ) -{ - if (srcLen < 8) - return 0; - - UnsignedByte *src = (UnsignedByte *)srcVoid; - UnsignedByte *dest = (UnsignedByte *)destVoid; - - CompressionType compType = getCompressionType(src, srcLen); - - if (compType == COMPRESSION_BTREE) - { - Int slen = srcLen - 8; - Int ret = BTREE_decode(dest, src+8, &slen); - if (ret) - return ret; - else - return 0; - } - if (compType == COMPRESSION_HUFF) - { - Int slen = srcLen - 8; - Int ret = HUFF_decode(dest, src+8, &slen); - if (ret) - return ret; - else - return 0; - } - if (compType == COMPRESSION_REFPACK) - { - Int slen = srcLen - 8; - Int ret = REF_decode(dest, src+8, &slen); - if (ret) - return ret; - else - return 0; - } - - if (compType == COMPRESSION_NOXLZH) - { - Bool ret = DecompressMemory(src+8, srcLen-8, dest, destLen); - if (ret) - return destLen; - else - return 0; - } - - if (compType >= COMPRESSION_ZLIB1 && compType <= COMPRESSION_ZLIB9) - { -#ifdef DEBUG_LOGGING - Int level = compType - COMPRESSION_ZLIB1 + 1; // 1-9 -#endif - - unsigned long outLen = destLen; - Int err = z_uncompress(dest, &outLen, src+8, srcLen-8); - if (err == Z_OK || err == Z_STREAM_END) - { - return outLen; - } - else - { - DEBUG_LOG(("ZLib decompression error (src is level %d, %d bytes long) %d\n", level, srcLen, err)); - return 0; - } - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////// -///// Performance Testing /////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef TEST_COMPRESSION - -#include "GameClient/MapUtil.h" -#include "Common/FileSystem.h" -#include "Common/file.h" - -#include "Common/PerfTimer.h" -enum { NUM_TIMES = 10 }; - -struct CompData -{ -public: - Int origSize; - Int compressedSize[COMPRESSION_MAX+1]; -}; - -void DoCompressTest( void ) -{ - - Int i; - - PerfGather *s_compressGathers[COMPRESSION_MAX+1]; - PerfGather *s_decompressGathers[COMPRESSION_MAX+1]; - for (i = 0; i < COMPRESSION_MAX+1; ++i) - { - s_compressGathers[i] = new PerfGather(CompressionManager::getCompressionNameByType((CompressionType)i)); - s_decompressGathers[i] = new PerfGather(CompressionManager::getDecompressionNameByType((CompressionType)i)); - } - - std::map s_sizes; - - std::map::const_iterator it = TheMapCache->begin(); - while (it != TheMapCache->end()) - { - //if (it->second.m_isOfficial) - //{ - //++it; - //continue; - //} - //static Int count = 0; - //if (count++ > 2) - //break; - File *f = TheFileSystem->openFile(it->first.str()); - if (f) - { - DEBUG_LOG(("***************************\nTesting '%s'\n\n", it->first.str())); - Int origSize = f->size(); - UnsignedByte *buf = (UnsignedByte *)f->readEntireAndClose(); - UnsignedByte *uncompressedBuf = NEW UnsignedByte[origSize]; - - CompData d = s_sizes[it->first]; - d.origSize = origSize; - d.compressedSize[COMPRESSION_NONE] = origSize; - - for (i=COMPRESSION_MIN; i<=COMPRESSION_MAX; ++i) - { - DEBUG_LOG(("=================================================\n")); - DEBUG_LOG(("Compression Test %d\n", i)); - - Int maxCompressedSize = CompressionManager::getMaxCompressedSize( origSize, (CompressionType)i ); - DEBUG_LOG(("Orig size is %d, max compressed size is %d bytes\n", origSize, maxCompressedSize)); - - UnsignedByte *compressedBuf = NEW UnsignedByte[maxCompressedSize]; - memset(compressedBuf, 0, maxCompressedSize); - memset(uncompressedBuf, 0, origSize); - - Int compressedLen, decompressedLen; - - for (Int j=0; j < NUM_TIMES; ++j) - { - s_compressGathers[i]->startTimer(); - compressedLen = CompressionManager::compressData((CompressionType)i, buf, origSize, compressedBuf, maxCompressedSize); - s_compressGathers[i]->stopTimer(); - s_decompressGathers[i]->startTimer(); - decompressedLen = CompressionManager::decompressData(compressedBuf, compressedLen, uncompressedBuf, origSize); - s_decompressGathers[i]->stopTimer(); - } - d.compressedSize[i] = compressedLen; - DEBUG_LOG(("Compressed len is %d (%g%% of original size)\n", compressedLen, (double)compressedLen/(double)origSize*100.0)); - DEBUG_ASSERTCRASH(compressedLen, ("Failed to compress\n")); - DEBUG_LOG(("Decompressed len is %d (%g%% of original size)\n", decompressedLen, (double)decompressedLen/(double)origSize*100.0)); - - DEBUG_ASSERTCRASH(decompressedLen == origSize, ("orig size does not match compressed+uncompressed output\n")); - if (decompressedLen == origSize) - { - Int ret = memcmp(buf, uncompressedBuf, origSize); - if (ret != 0) - { - DEBUG_CRASH(("orig buffer does not match compressed+uncompressed output - ret was %d\n", ret)); - } - } - - delete compressedBuf; - compressedBuf = NULL; - } - - DEBUG_LOG(("d = %d -> %d\n", d.origSize, d.compressedSize[i])); - s_sizes[it->first] = d; - DEBUG_LOG(("s_sizes[%s] = %d -> %d\n", it->first.str(), s_sizes[it->first].origSize, s_sizes[it->first].compressedSize[i])); - - delete[] buf; - buf = NULL; - - delete[] uncompressedBuf; - uncompressedBuf = NULL; - } - - ++it; - } - - for (i=COMPRESSION_MIN; i<=COMPRESSION_MAX; ++i) - { - Real maxCompression = 1000.0f; - Real minCompression = 0.0f; - Int totalUncompressedBytes = 0; - Int totalCompressedBytes = 0; - for (std::map::iterator cd = s_sizes.begin(); cd != s_sizes.end(); ++cd) - { - CompData d = cd->second; - - Real ratio = d.compressedSize[i]/(Real)d.origSize; - maxCompression = min(maxCompression, ratio); - minCompression = max(minCompression, ratio); - - totalUncompressedBytes += d.origSize; - totalCompressedBytes += d.compressedSize[i]; - } - DEBUG_LOG(("***************************************************\n")); - DEBUG_LOG(("Compression method %s:\n", CompressionManager::getCompressionNameByType((CompressionType)i))); - DEBUG_LOG(("%d bytes compressed to %d (%g%%)\n", totalUncompressedBytes, totalCompressedBytes, - totalCompressedBytes/(Real)totalUncompressedBytes*100.0f)); - DEBUG_LOG(("Min ratio: %g%%, Max ratio: %g%%\n", - minCompression*100.0f, maxCompression*100.0f)); - DEBUG_LOG(("\n")); - } - - PerfGather::dumpAll(10000); - //PerfGather::displayGraph(TheGameLogic->getFrame()); - PerfGather::resetAll(); - CopyFile( "AAAPerfStats.csv", "AAACompressPerfStats.csv", FALSE ); - - for (i = 0; i < COMPRESSION_MAX+1; ++i) - { - delete s_compressGathers[i]; - s_compressGathers[i] = NULL; - - delete s_decompressGathers[i]; - s_decompressGathers[i] = NULL; - } - -} - -#endif // TEST_COMPRESSION diff --git a/Generals/Code/Libraries/Source/Compression/EAC/btreeabout.cpp b/Generals/Code/Libraries/Source/Compression/EAC/btreeabout.cpp deleted file mode 100644 index b7ee5fdba17..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/btreeabout.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -/* ABSTRACT */ -/*------------------------------------------------------------------*/ -/* */ -/* BTree - Binary Tree Codex */ -/* */ -/* by FrANK G. Barchard, EAC */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Version Date SE History: */ -/* ------- ---- -- -------- */ -/* 1.00 950108 FB BTree codex based on hufftree and ref codex */ -/* 1.01 970117 FB encode check index before going off array */ -/* 1.02 020716 FB allocate percentage more buffer for large files*/ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Module Notes: */ -/* ------------- */ -/* Reentrant */ -/* Files: btrread.c btrwrite.c btrcodex.h */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Format Notes: */ -/* ------------- */ -/* BTree is an EA proprietary compression scheme by Frank Barchard. */ -/* Each byte is either a raw byte (leaf) or node that points to */ -/* 2 other nodes. Each node is either a simple byte or 2 nodes. */ -/* The stream is simple bytes and uses bytes for nodes that werent */ -/* used in the original file. */ -/* */ -/* BTREE (fb6) header format: */ -/* -------------------------- */ -/* */ -/* offset bytes notes */ -/* id 0 2 id is 46fb */ -/* ulen 2 3 total unpacked len */ -/* ilen* 2/5 3 unpacked len for this file */ -/* clue 5/8 1 */ -/* nodes 6/9 1 number of nodes */ -/* { */ -/* node 7/10+3n 1 */ -/* left 8/11+3n 1 */ -/* right 9/12+3n 1 */ -/* } */ -/* */ -/* [packed data] */ -/* [explicitely packed last byte] */ -/* */ -/* * present if composite packed */ -/* */ -/*------------------------------------------------------------------*/ -/* END ABSTRACT */ - -#include -#include "codex.h" -#include "btreecodex.h" - -/****************************************************************/ -/* Information Functions */ -/****************************************************************/ - -CODEXABOUT *GCALL BTREE_about(void) -{ - CODEXABOUT* info; - - info = (CODEXABOUT*) galloc(sizeof(CODEXABOUT)); - if (info) - { - memset(info, 0, sizeof(CODEXABOUT)); - - info->signature = QMAKEID('B','T','R','E'); - info->size = sizeof(CODEXABOUT); - info->version = 200; /* codex version number (200) */ - info->decode = 1; /* supports decoding */ - info->encode = 1; /* supports encoding */ - info->size32 = 0; /* supports 32 bit size field */ - strcpy(info->versionstr, "1.02"); /* version # */ - strcpy(info->shorttypestr, "btr"); /* type */ - strcpy(info->longtypestr, "BTree"); /* longtype */ - } - return(info); -} - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/btreecodex.h b/Generals/Code/Libraries/Source/Compression/EAC/btreecodex.h deleted file mode 100644 index 1c54ad911f1..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/btreecodex.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */ - -#ifndef __BTRCODEX -#define __BTRCODEX 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __CODEX_H -#error "Include codex.h before btreecodex.h" -#endif - -/****************************************************************/ -/* BTR Codex */ -/****************************************************************/ - -/* Information Functions */ - -CODEXABOUT *GCALL BTREE_about(void); -bool GCALL BTREE_is(const void *compresseddata); - -/* Decode Functions */ - -int GCALL BTREE_size(const void *compresseddata); -#ifdef __cplusplus -int GCALL BTREE_decode(void *dest, const void *compresseddata, int *compressedsize=0); -#else -int GCALL BTREE_decode(void *dest, const void *compresseddata, int *compressedsize); -#endif - -/* Encode Functions */ - -#ifdef __cplusplus -int GCALL BTREE_encode(void *compresseddata, const void *source, int sourcesize, int *opts=0); -#else -int GCALL BTREE_encode(void *compresseddata, const void *source, int sourcesize, int *opts); -#endif - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/btreedecode.cpp b/Generals/Code/Libraries/Source/Compression/EAC/btreedecode.cpp deleted file mode 100644 index 1cae60cebb3..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/btreedecode.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -#ifndef __BTRREAD -#define __BTRREAD 1 - -#include -#include "codex.h" -#include "btreecodex.h" - -/****************************************************************/ -/* Internal Functions */ -/****************************************************************/ - -struct BTreeDecodeContext -{ - signed char cluetbl[256]; - unsigned char left[256]; - unsigned char right[256]; - unsigned char *d; -}; - -static void BTREE_chase(struct BTreeDecodeContext *DC, unsigned char node) -{ - if (DC->cluetbl[node]) - { - BTREE_chase(DC,DC->left[node]); - BTREE_chase(DC,DC->right[node]); - return; - } - *DC->d++ = node; -} - -static int BTREE_decompress(unsigned char *packbuf,unsigned char *unpackbuf) -{ - int node; - int i; - int nodes; - int clue; - int ulen; - unsigned char *s; - signed char c; - unsigned int type; - struct BTreeDecodeContext DC; - - s = packbuf; - DC.d = unpackbuf; - ulen = 0L; - - if (s) - { - type = ggetm(s,2); - s += 2; - - /* (skip nothing for 0x46fb) */ - if (type==0x47fb) /* skip ulen */ - s += 3; - - ulen = ggetm(s,3); - s += 3; - - for (i=0;i<256;++i) /* 0 means a code is a leaf */ - DC.cluetbl[i] = 0; - - clue = *s++; - DC.cluetbl[clue] = 1; /* mark clue as special */ - - nodes = *s++; - for (i=0;i. -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -#ifndef __BTRWRITE -#define __BTRWRITE 1 - -#include -#include "codex.h" -#include "btreecodex.h" - -/****************************************************************/ -/* Internal Functions */ -/****************************************************************/ - -#define BTREEWORD short -#define BTREECODES 256 -#define BTREEBIGNUM 32000 -#define BTREESLOPAGE 16384 - -struct BTREEMemStruct -{ - char *ptr; - int len; -}; - -struct BTreeEncodeContext -{ - unsigned int packbits; - unsigned int workpattern; - unsigned char *bufptr; - unsigned int ulen; - unsigned int masks[17]; - unsigned char clueq[BTREECODES]; - unsigned char right[BTREECODES]; - unsigned char join[BTREECODES]; - unsigned int plen; - unsigned char *bufbase; - unsigned char *bufend; - unsigned char *buffer; - unsigned char *buf1; - unsigned char *buf2; -}; - -static void BTREE_writebits(struct BTreeEncodeContext *EC, - struct BTREEMemStruct *dest, - unsigned int bitpattern, - unsigned int len) -{ - if (len > 16) - { - BTREE_writebits(EC,dest,(unsigned int) (bitpattern>>16), len-16); - BTREE_writebits(EC,dest,(unsigned int) bitpattern, 16); - } - else - { - EC->packbits += len; - EC->workpattern += (bitpattern & EC->masks[len]) << (24-EC->packbits); - while (EC->packbits > 7) - { - *(dest->ptr+dest->len) = (unsigned char) (EC->workpattern >> 16); - ++dest->len; - - EC->workpattern = EC->workpattern << 8; - EC->packbits -= 8; - ++EC->plen; - } - } -} - - -static void BTREE_adjcount(unsigned char *s, unsigned char *bend, BTREEWORD *count) -{ - -#ifdef __WATCOMC__ - - union - { - unsigned char b[4]; - int w; - } i; - - #define COUNTADJ(j) i.b[1] = i.b[0]; i.b[0] = *(s+j); ++count[i.w]; - - i.w = 0; - i.b[0] = (unsigned BTREEWORD) *s++; - -#else - - unsigned BTREEWORD i; - - #define COUNTADJ(j) i = (BTREEWORD)(((i<<8) | *(s+j))); ++*(count+(int)i); - - i = (unsigned BTREEWORD) *s++; - -#endif - - bend -= 16; - - if (sbufbase; - if (s==EC->buf1) - { - d = EC->buf2; - } - else - { - d = EC->buf1; - } - EC->bufbase = d; - bend = EC->bufend; - - *bend = (unsigned char) clue; - while (s<=bend) - { - while (!cluep[(unsigned int) (*d++ = *s++)]) - ; - - i = (unsigned int) *(s-1); - - if (cluep[i]==1) - { if (*s==rightp[i]) - { *(d-1) = joinp[i]; - ++s; - } - } - else - { if (cluep[i]==3) - { *(d-1) = (unsigned char) clue; - *d++ = *(s-1); - } - else - *d++ = *s++; - } - } - EC->bufend = d-2; -} - - -/* find 48 most common nodes */ - -static unsigned int BTREE_findbest(BTREEWORD *countptr, - unsigned char *tryq, - unsigned int *bestn, - unsigned int *bestval, - int ratio) -{ - unsigned int i; - unsigned int i1; - unsigned int i2; - unsigned int bestsize; - - unsigned int i3; - unsigned int l; - - bestsize = 1; - i = 3; - l = 0; - for (i2=0;i2<256;++i2) - { - if (tryq[i2]) - { for (i1=0;i1<256;++i1) - { - if (*countptr++>(BTREEWORD)i) - { - if (tryq[i1]) - { i = *(countptr-1); - i3=bestsize; - while (bestval[i3-1]ulen*3/2+(int)BTREESLOPAGE; - buf2size = EC->ulen*3/2+(int)BTREESLOPAGE; - - treebuf = (unsigned char *) galloc(treebufsize); - if (!treebuf) - return; /* failure Insufficient memory for work buffer */ - - EC->buf1 = (unsigned char *) galloc(buf1size); - if (!EC->buf1) - return; /* failure Insufficient memory for work buffer */ - - EC->buf2 = (unsigned char *) galloc(buf2size); - if (!EC->buf2) - return; /* failure Insufficient memory for work buffer */ - - memcpy(EC->buf1, EC->buffer, EC->ulen); /* copy to scratch buffer */ - - EC->buffer = EC->buf1; - EC->bufptr = EC->buf1+EC->ulen; - - EC->bufbase = EC->buffer; - EC->bufend = EC->bufptr; - - count = (BTREEWORD *) treebuf; - - if (quick) ratio = quick; - else ratio = 2; - -/*** count file ***/ - - for (i=0; ibufptr; - ptr1 = EC->buffer; - while (ptr1clueq[i] = 0; - -/* get a clue byte (forced) */ - - for(i=0; i3) - tryq[i] = 1; - else - tryq[i] = 0; - } - -/* don't use 0 for clue or node (so that [clue][0] is reserved for EOF) */ - - count2[0] = BTREEBIGNUM; /* don't use for clue or node */ - -/* asciiz btree suppress packing of 0..31 */ - - if (zerosuppress) - { - for (i=0; i<32; ++i) - { - count2[i] = BTREEBIGNUM; /* don't use for nodes */ - tryq[i] = 0; /* don't try to pack */ - freeq[i] = 0; /* don't try to pack */ - } - } - - -/* sort codes with least used codes first */ -/* primary key is count, secondary key is higher code */ - -/* registers vars usage - i - code - i1 - done flag/swap temp -*/ - - for (i=0;isortptr[i-1]))) - { - i1 = sortptr[i]; - sortptr[i] = sortptr[i-1]; - sortptr[i-1] = i1; - i1 = 1; - } - } - } - - freeptr = 0; - i = sortptr[freeptr++]; - clue = (unsigned char) i; - freeq[i] = 0; - tryq[i] = 0; - EC->clueq[i] = 3; - - if (count2[i]) - BTREE_joinnodes(EC,EC->clueq, EC->right, EC->join, clue); - - EC->clueq[i] = 2; - -/* init best array */ - - bestval[0] = (unsigned int) -1; - - -/* count file (pass 2) */ - - bt_size = 0; - domore = passes; - while (domore) - { - -/* clear count array */ - - BTREE_clearcount(tryq,count); - -/* do an adjacency count */ - - ptr1 = EC->bufbase; - bend = EC->bufend; - - BTREE_adjcount(ptr1, bend, count); - -/* find most common nodes */ - - bestsize = BTREE_findbest(count,tryq,bestn,bestval,ratio); - -/* decide which nodes should be joined to what */ - - domore = 0; - if (bestsize>1) - { - tcost = tsave = 0; - i = i1 = domore = 1; - while (domore) - { - leftnode = (bestn[i]>>8)&255; - rightnode = bestn[i]&255; - - if ((tryq[leftnode]==1) && (tryq[rightnode]==1)) - { - domore = 0; - while ((freeptrclueq[joinnode] = 3; - - freeq[leftnode] = 0; - tryq[leftnode] = 2; - EC->clueq[leftnode] = 1; - EC->right[leftnode] = (unsigned char) rightnode; - EC->join[leftnode] = (unsigned char) joinnode; - - freeq[rightnode] = 0; - tryq[rightnode] = 2; - - bt_node[bt_size] = joinnode; - bt_left[bt_size] = leftnode; - bt_right[bt_size] = rightnode; - ++bt_size; - - if (i1<=multimax) - domore = 1; - } - } - } - - ++i; - if (i>=bestsize) - domore = 0; - } - - bestsize = i1; - - if (bestsize>1) - { - /* multijoin nodes */ - - BTREE_joinnodes(EC,EC->clueq, EC->right, EC->join, clue); - - /* restore clue table */ - - for(i=1;i>8)&255; - joinnode = bestjoin[i]; - EC->clueq[leftnode] = EC->clueq[joinnode] = 0; - } - - domore = --passes; - } - - } - - } - EC->bufptr = EC->bufend; - -/* write header */ - - BTREE_writebits(EC,dest,(unsigned int) clue, 8); /* clue byte */ - BTREE_writebits(EC,dest,(unsigned int) bt_size, 8); /* tree size */ - - for (i=0; iplen; - -/*** write packed file ***/ - - ptr1 = EC->bufbase; - bend = EC->bufend; - - while (ptr1buf2); - gfree(EC->buf1); - gfree(treebuf); -} - -static int BTREE_compressfile(struct BTreeEncodeContext *EC, - struct BTREEMemStruct *infile, - struct BTREEMemStruct *outfile, - int ulen, - int zerosuppress) -{ - unsigned int i; - - unsigned int passes; - unsigned int multimax; - int flen; - -/* set defaults */ - - EC->packbits = 0; - - EC->workpattern = 0L; - passes = 256; - multimax = 32; - EC->masks[0] = 0; - for (i=1;i<17;++i) - EC->masks[i] = (EC->masks[i-1] << 1) + 1; - -/* read in a source file */ - - EC->buffer = (unsigned char *) (infile->ptr); - flen = infile->len; - - EC->ulen = flen; - EC->bufptr = EC->buffer + flen; - -/* pack a file */ - - outfile->ptr = outfile->ptr; - outfile->len = 0L; - - EC->packbits = 0; - EC->workpattern = 0L; - EC->plen = 0L; - -/* write standard header stuff (type/signature/ulen/adjust) */ - - /* simple fb6 header */ - - if (ulen==infile->len) - { - BTREE_writebits(EC,outfile,(unsigned int) 0x46fb, 16); - BTREE_writebits(EC,outfile,(unsigned int) infile->len, 24); - } - - /* composite fb6 header */ - - else - { - BTREE_writebits(EC,outfile,(unsigned int) 0x47fb, 16); - BTREE_writebits(EC,outfile,(unsigned int) ulen, 24); - BTREE_writebits(EC,outfile,(unsigned int) infile->len, 24); - } - - BTREE_treepack(EC,outfile,passes, multimax, 0, zerosuppress); - - return(outfile->len); -} - - - -/****************************************************************/ -/* Encode Function */ -/****************************************************************/ - -int GCALL BTREE_encode(void *compresseddata, const void *source, int sourcesize, int *opts) -{ - int plen; - struct BTREEMemStruct infile; - struct BTREEMemStruct outfile; - struct BTreeEncodeContext EC; - int opt=0; - if (opts) - opt = opts[0]; - - infile.ptr = (char *)source; - infile.len = sourcesize; - outfile.ptr = (char *)compresseddata; - outfile.len = sourcesize; - - plen = BTREE_compressfile(&EC,&infile, &outfile, sourcesize, opt); - - return(plen); -} - -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/codex.h b/Generals/Code/Libraries/Source/Compression/EAC/codex.h deleted file mode 100644 index 8e2dbdcc9c4..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/codex.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */ - -/*------------------------------------------------------------------*/ -/* */ -/* Compression Decompression Exchange(CODEX) v2.00 */ -/* */ -/* by FrANK G. Barchard, EAC */ -/* */ -/* Header Module - Oct 15, 2001 */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Version Date SE History */ -/* ------- ------ -- ------- */ -/* 1.00 990824 FB codex API seperated from huff tool */ -/* 1.01 010427 FB fb6 32 bit size header */ -/* 1.02 011011 FB c++ defaults */ -/* 2.00 011015 FB bool, dest/source, new about struct,no QPUBLIC */ -/* */ -/*------------------------------------------------------------------*/ - -#ifndef __CODEX_H -#define __CODEX_H 1 - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define CODEX_VERSION 200 - -/****************************************************************/ -/* Data Types */ -/****************************************************************/ - -/* Info structure describing bitmaps */ - -typedef struct -{ - int signature; /* signature of codex ie 'tga ' (optional) */ - int size; /* size of CODEXABOUT structure */ - int version; /* version number of CODEXABOUT structure (200) */ - - unsigned int decode :1; /* supports decoding */ - unsigned int encode :1; /* supports encoding */ - unsigned int size32 :1; /* support 32 bit size field */ - unsigned int pad :29; - - char versionstr[8]; /* version number of codex module ie 1.00 */ - char shorttypestr[8]; /* 3 or 4 character type string ie ref */ - char longtypestr[16]; /* full name of data format ie Refpack */ -} CODEXABOUT; - -#define QMAKEID(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d)) - -#if !defined(GCALL) -#if defined(_MSC_VER) && !defined(_XBOX) -#define GCALL __stdcall -#else -#define GCALL -#endif -#endif - - -typedef struct QFUNCTIONS -{ - CODEXABOUT * (GCALL * CODEX_about)(void); - bool (GCALL * CODEX_is)(const void *compressed); - int (GCALL * CODEX_size)(const void *compressed); - int (GCALL * CODEX_decode)(void *dest, const void *source, int *sourcesizeptr); - int (GCALL * CODEX_encode)(void *dest, const void *source, int sourcesize, int *opts); -} QFUNCTIONS; - -extern struct QFUNCTIONS qfunctions[]; - -/****************************************************************/ -/* Codex Module Example Prototypes */ -/****************************************************************/ - -#include "gimex.h" /* for memory IO */ - -/* Information Functions */ - -CODEXABOUT *GCALL CODEX_about(void); -bool GCALL CODEX_is(const void *source); -int GCALL CODEX_size(const void *source); - -/* Decode/Encode Functions */ - -#ifdef __cplusplus -int GCALL CODEX_decode(void *dest, const void *source, int *sourcesizeptr=0); -int GCALL CODEX_encode(void *dest, const void *source, int sourcesize, int *opts=0); -#else -int GCALL CODEX_decode(void *dest, const void *source, int *sourcesizeptr); -int GCALL CODEX_encode(void *dest, const void *source, int sourcesize, int *opts); -#endif - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/gimex.h b/Generals/Code/Libraries/Source/Compression/EAC/gimex.h deleted file mode 100644 index b53b45c38cc..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/gimex.h +++ /dev/null @@ -1,497 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* Copyright (C) Electronic Arts Canada Inc. 1994-2002. All rights reserved. */ - -/* ABSTRACT -gimex.h - Primary header file for the GIMEX API. -@ */ - -/*------------------------------------------------------------------*/ -/* */ -/* Graphics IMport EXport API v3.46 */ -/* */ -/* by Frank Barchard, EAC */ -/* */ -/* Header Module - Dec 05, 2002 */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Version Date SE History */ -/* ------- ------ -- ------- */ -/* 3.01 ------ FB gref void * */ -/* 3.02 ------ FB const GIMEX_write */ -/* 3.10 ------ FB 16 bpp import */ -/* 3.11 ------ FB gbitmap->image void * */ -/* 3.12 ------ FB about importstream, exportstream, maxredbits et*/ -/* 3.13 ------ FB about->movie */ -/* 3.14 ------ FB GFUNCTIONS table declared */ -/* 3.15 ------ FB about->mipmap */ -/* 3.16 ------ FB about->font */ -/* 3.17 ------ FB linux use intel ordered ARGB */ -/* 3.20 ------ FB 64 bit file system (GPOS), removed ARGB16 */ -/* 3.21 ------ FB 64 bit backwards compatibility with 32 */ -/* 3.22 ------ FB 32 bit file implementation for efficiency */ -/* 3.23 ------ FB bitfield warning removed */ -/* 3.24 010426 FB GIMEX_read/write take void * prototyped here */ -/* 3.25 010427 FB about width/height max,align and obsolete */ -/* 3.26 010501 FB INT64 for gcc 2.95.3 on ps2 use long */ -/* 3.27 010504 FB removed _ARGB_T - use ARGB. add GC reference */ -/* 3.30 010614 LC update for 330 release */ -/* 3.31 010628 FB GIMEX_COMMENT_SIZE 1024 */ -/* 3.32 011009 FB about->file64 for 64 bit file sizes */ -/* 3.40 011022 FB bool returns, ggetm inline, 512 GIMEX_FRAME... */ -/* 3.41 020225 FB metalbin 240 on ps2 */ -/* 3.44 020307 FB bumped for next release. no api change */ -/* 3.45 020927 FB geti 3 bounds safe/purify */ -/* 3.46 021205 FB about firstextension */ -/* */ -/*------------------------------------------------------------------*/ - -#ifndef __GIMEX_H -#define __GIMEX_H 1 - -#if defined(_MSC_VER) -#pragma once -#pragma warning(disable : 4100) -/* warning C4100: unreferenced parameter */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define GIMEX_VERSION 346 -#define GIMEX_PATCH 0 - -/****************************************************************************/ -/* Data Types */ -/****************************************************************************/ - -/* ARGB structure used for palettes/pixels */ - -// experimental float channel - -#ifdef GIMEXFLOAT -typedef float GCHANNEL; -#else -typedef unsigned char GCHANNEL; -#endif - -#ifndef ARGB -#define ARGB ARGB -#if defined(_MSC_VER) || defined(__i386__) - - typedef struct - { - GCHANNEL b,g,r,a; - } ARGB; - -#elif defined(__R5900) || defined(SGI) /* PS2 */ - - typedef struct - { - GCHANNEL r,g,b,a; - } ARGB; - -#else /* GameCube/Mac */ - - typedef struct - { - GCHANNEL a,r,g,b; - } ARGB; -#endif -#endif - -#if !defined(GPOS) -#if defined(_MSC_VER) -typedef __int64 GPOS; -#elif defined(__R5900) -typedef long GPOS; -#else -typedef long long GPOS; -#endif -#endif - -/* Info structure describing bitmaps */ - -#define GIMEX_FRAMENAME_SIZE 512 -#define GIMEX_COMMENT_SIZE 1024 -#define GIMEX_COLOURTBL_SIZE 256 -#define GIMEX_HOTSPOTTBL_SIZE 1024 -#define GIMEX_HOTSPOTTBL_VALUES 2 - -typedef struct -{ - int signature; /* signature of gimex ie 'tga ' (optional) */ - int size; /* size of GINFO structure */ - int version; /* version number of GINFO structure (300) */ - int framenum; /* current frame */ - int width; /* width of bitmap in pixels */ - int height; /* height of bitmap in pixels */ - int bpp; /* bits per pixel (8, 16 or 32) */ - int originalbpp; /* bits per pixel in original image (1 to 32) */ - int startcolour; /* first colour in palette */ - int numcolours; /* number of colours in original indexed palette */ - ARGB colourtbl[GIMEX_COLOURTBL_SIZE]; /* 8 bit palette */ - int subtype; /* internal format sub-type 0-default */ - int packed; /* type of packing on original image. 0 none, 1 run, n other */ - int quality; /* quality of lossy packing 0..100 */ - int framesize; /* size of frame in bytes */ - int alphabits; /* number of bits in alpha channel */ - int redbits; /* number of bits in red channel */ - int greenbits; /* number of bits in green channel */ - int bluebits; /* number of bits in blue channel */ - int centerx; /* center point relative to upper left corner */ - int centery; - int defaultx; /* default coordinate point */ - int defaulty; - int numhotspots; /* number of hot spots defined */ - char framename[GIMEX_FRAMENAME_SIZE]; /* null terminated name of frame/image */ - char comment[GIMEX_COMMENT_SIZE]; /* null terminated multiline user comment */ - int hotspottbl[GIMEX_HOTSPOTTBL_SIZE][GIMEX_HOTSPOTTBL_VALUES];/* up to 256 hot spots, XY pairs relative to upperleft */ - float dpi; /* dots per inch ie 72.0 */ - float fps; /* frame per second (one over duration). 15.0 is typical */ - int reserved[3]; /* reserved for future use - set to zero */ -} GINFO; - -typedef struct GSTREAM GSTREAM; /* handle used for file functions */ - -typedef struct -{ - int signature; /* signature of gimex ie '.tga' (optional) */ - int size; /* size of GINSTANCE structure */ - int frames; /* Number of frames in file */ - int framenum; /* current frame (optional) */ - GSTREAM *gstream; /* stream pointer for file */ - void *gref; /* gimex reference to additional memory used by module (optional) */ -} GINSTANCE; - -/* Info structure describing bitmaps */ - -#define MAXMACTYPES 8 -#define MAXEXTENSIONS 8 - -#define GIMEX_EXTENSION_SIZE 8 -#define GIMEX_AUTHORSTR_SIZE 32 -#define GIMEX_VERSIONSTR_SIZE 8 -#define GIMEX_SHORTTYPESTR_SIZE 8 -#define GIMEX_WORDTYPESTR_SIZE 16 -#define GIMEX_LONGTYPESTR_SIZE 32 - -typedef struct -{ - int signature; /* signature of gimex ie 'tga ' (optional) */ - int size; /* size of GABOUT structure */ - int version; /* version number of GABOUT structure (200) */ - unsigned int canimport :1; /* supports importing */ - unsigned int canexport :1; /* supports exporting */ - unsigned int importpacked :2; /* max import packed field 0..3 */ - unsigned int exportpacked :2; /* max export packed field 0..3 */ - unsigned int import8 :1; /* supports importing 8 bit indexed */ - unsigned int export8 :1; /* supports exporting 8 bit indexed */ - unsigned int import32 :1; /* supports importing 32 bit direct rgb */ - unsigned int export32 :1; /* supports exporting 32 bit direct rgb */ - unsigned int multiframe :1; /* supports multiple frames */ - unsigned int multifile :1; /* format requires additional files or resource fork */ - unsigned int multisize :1; /* supports different size per frame */ - unsigned int framebuffer :1; /* module requires memory to buffer entire frame */ - unsigned int external :1; /* uses external resources */ - unsigned int usesfile :1; /* module is file based vs ads/printer/generator */ - unsigned int globalpalette :1; /* limited to a single palette per file */ - unsigned int greyscale :1; /* use maxcolours for number of levels */ - unsigned int startcolour :1; /* supports start colour */ - unsigned int dotsubtype :1; /* subtype based on extension */ - unsigned int resizable :1; /* read will respect ginfo width & height */ - unsigned int reserved2 :1; /* reserved for future use */ - unsigned int reserved3 :1; /* reserved for future use */ - unsigned int importstream :1; /* supports open with GIMEX_NOFRAMECOUNT */ - unsigned int exportstream :1; /* will ignore frame count on export */ - unsigned int movie :1; /* this is a movie format (as opposed to mipmaps, fonts or multipage) */ - unsigned int mipmap :1; /* mipmaps are supported and will constrain sizes */ - unsigned int font :1; /* this is a font format */ - unsigned int obsolete :1; /* this format is obsolete */ - unsigned int file64 :1; /* this format supports 64 bit file sizes */ - unsigned int firstextension:1; /* use first extension when assigning default name */ - unsigned int pad :1; /* pad bitfield to 32 bit boundary for inter compiler compatibility */ - int maxcolours; /* only use in 8 bit, 0 if module does not care */ - int maxframename; /* maximum characters in ginfo framename */ - int defaultquality; /* default pack quality */ - int mactype[MAXMACTYPES]; /* mac file system types used */ - char extensions[MAXEXTENSIONS][GIMEX_EXTENSION_SIZE]; /* null terminated extensions with '.' */ - char authorstr[GIMEX_AUTHORSTR_SIZE]; /* name of gimex module author */ - char versionstr[GIMEX_VERSIONSTR_SIZE]; /* version number of gimex module ie 1.00 */ - char shorttypestr[GIMEX_SHORTTYPESTR_SIZE]; /* 3 or 4 character type string ie TGA */ - char wordtypestr[GIMEX_WORDTYPESTR_SIZE]; /* single word type string ie Targa */ - char longtypestr[GIMEX_LONGTYPESTR_SIZE]; /* full name of data format ie True Vision Targa */ - unsigned int maxalphabits:8; /* maximum supported number of bits in alpha channel */ - unsigned int maxredbits :8; /* maximum supported number of bits in red channel */ - unsigned int maxgreenbits:8; /* maximum supported number of bits in green channel */ - unsigned int maxbluebits :8; /* maximum supported number of bits in blue channel */ - unsigned int maxwidth; /* maximum width in pixels */ - unsigned int maxheight; /* maximum height in pixels */ - unsigned int alignwidth; /* width must be multiple of this in pixels */ - unsigned int alignheight; /* height must be multiple of this in pixels */ - unsigned int pad2[4]; -} GABOUT; - -/* Bitmap structure (optional) */ - -typedef struct -{ - GINFO *ginfo; - void *image; - int rowbytes; -} GBITMAP; - -#ifndef GMAKEID -#define GMAKEID(a,b,c,d) (((int)(a)<<24)|((int)(b)<<16)|((int)(c)<<8)|(int)(d)) -#endif - -#ifndef gmin -#define gmin(a,b) ((a)<(b)?(a):(b)) -#endif - -#ifndef gmax -#define gmax(a,b) ((a)>(b)?(a):(b)) -#endif - -#if !defined(GCALL) -#if defined(_MSC_VER) && !defined(_XBOX) -#define GCALL __stdcall -#else -#define GCALL -#endif -#endif - - -#if !defined(__cplusplus) && !defined(bool) -#define bool bool -typedef enum{ False=0x0, True=0x1}bool; -#endif - -typedef struct GFUNCTIONS -{ - GABOUT * (GCALL * GIMEX_about)(void); - int (GCALL * GIMEX_is)(GSTREAM *g); - int (GCALL * GIMEX_open)(GINSTANCE **gx, GSTREAM *g, const char *pathname,bool framecountflag); - GINFO * (GCALL * GIMEX_info)(GINSTANCE *gx, int framenum); - int (GCALL * GIMEX_read)(GINSTANCE *gx, GINFO *ginfo, char *dest, int rowbytes); - int (GCALL * GIMEX_close)(GINSTANCE *gx); - int (GCALL * GIMEX_wopen)(GINSTANCE **gx, GSTREAM *g, const char *pathname, int numframes); - int (GCALL * GIMEX_write)(GINSTANCE *gx, const GINFO *ginfo, char *source, int rowbytes); - int (GCALL * GIMEX_wclose)(GINSTANCE *gx); -} GFUNCTIONS; - -extern struct GFUNCTIONS gfunctions[]; - -/****************************************************************************/ -/* Gimex Module Example Prototypes */ -/****************************************************************************/ - -/* valid values to be passed to framecountflag parameter for the GIMEX_open function */ -#ifdef __cplusplus -#define GIMEX_FRAMECOUNT true -#define GIMEX_NOFRAMECOUNT false -#else -#define GIMEX_FRAMECOUNT 0x1 -#define GIMEX_NOFRAMECOUNT 0x0 -#endif -/* Information Functions */ - -GABOUT *GCALL GIMEX_about(void); -int GCALL GIMEX_is(GSTREAM *g); - -/* Import Functions */ - -#ifdef __cplusplus -int GCALL GIMEX_open(GINSTANCE **gx, GSTREAM *g, const char *pathname, bool framecountflag=GIMEX_FRAMECOUNT); -#else -int GCALL GIMEX_open(GINSTANCE **gx, GSTREAM *g, const char *pathname, bool framecountflag); -#endif -GINFO * GCALL GIMEX_info(GINSTANCE *gx, int framenum); -bool GCALL GIMEX_read(GINSTANCE *gx, const GINFO *ginfo, void *dest, int rowbytes); -bool GCALL GIMEX_close(GINSTANCE *gx); - -/* Example Export Functions */ - -bool GCALL GIMEX_wopen(GINSTANCE **gx, GSTREAM *g, const char *pathname, int numframes); -bool GCALL GIMEX_write(GINSTANCE *gx, const GINFO *ginfo, const void *source, int rowbytes); -bool GCALL GIMEX_wclose(GINSTANCE *gx); - -/****************************************************************************/ -/* Application Module Prototypes */ -/****************************************************************************/ - -/* File Stream Functions */ - -GSTREAM * GCALL gopen(const char *pathname); -GSTREAM * GCALL gwopen(const char *pathname); -bool GCALL gclose(GSTREAM *g); -int GCALL gread(GSTREAM *g, void *buf, int size); -int GCALL gwrite(GSTREAM *g, const void *buf, int size); -bool GCALL gseek(GSTREAM *g, GPOS offset); -GPOS GCALL glen(GSTREAM *g); -GPOS GCALL gtell(GSTREAM *g); - -/* Memory Functions */ - -#if !defined(galloc) -#include -#define galloc malloc -//void * GCALL galloc(int size); -#endif -//bool GCALL gfree(void *memptr); -#define gfree free - -#ifdef __cplusplus -} -#endif - -/****************************************************************************/ -/* Inline C++ (cross platform) */ -/****************************************************************************/ - -#ifdef _MSC_VER -#pragma warning(disable: 4514) // unreferenced inline function has been removed -#endif - -/* get motorola memory */ -static __inline unsigned int ggetm(const void *src, int bytes) -{ - if (bytes==1) - return (unsigned int) *(const unsigned char *) src; -#if defined(__APPLE__) || (defined(__MWERKS__) && defined(__PPCGEKKO__)) - else if (bytes==2) - return (unsigned int) *(const unsigned short *) src; - else if (bytes==4) - return (unsigned int) *(const unsigned int *) src; -#else - else if (bytes==2) - return (((unsigned int) *(const unsigned char *) src)<<8) | (((unsigned int) *((const unsigned char *) src+1))); - else if (bytes==4) - return (((unsigned int) *(const unsigned char *) src)<<24) | (((unsigned int) *((const unsigned char *) src+1))<<16) | (((unsigned int) *((const unsigned char *) src+2))<<8) | (((unsigned int) *((const unsigned char *) src+3))); -#endif - else if (bytes==3) - return (((unsigned int) *(const unsigned char *) src)<<16) | (((unsigned int) *((const unsigned char *) src+1))<<8) | (((unsigned int) *((const unsigned char *) src+2))); - return 0; -} - -/* get intel memory */ - -static __inline unsigned int ggeti(const void *src, int bytes) -{ - if (bytes==1) - return (unsigned int) *(const unsigned char *) src; -#if defined(_MSC_VER) || defined(__i386__) - else if (bytes==2) - return (unsigned int) *(const unsigned short *) src; - else if (bytes==4) - return (unsigned int) *(const unsigned int *) src; -#else - else if (bytes==2) - return (((unsigned int) *((const unsigned char *) src+1))<<8) | (((unsigned int) *(const unsigned char *) src+0)); - else if (bytes==4) - return (((unsigned int) *((const unsigned char *) src+3))<<24) | (((unsigned int) *((const unsigned char *) src+2))<<16) | (((unsigned int) *((const unsigned char *) src+1))<<8) | (((unsigned int) *(const unsigned char *) src+0)); -#endif - else if (bytes==3) - return (((unsigned int) *((const unsigned char *) src+2))<<16) | (((unsigned int) *((const unsigned char *) src+1))<<8) | (((unsigned int) *(const unsigned char *) src+0)); - return 0; -} - -/* put motorolla memory */ - -static __inline void gputm(void *dst, unsigned int data, int bytes) -{ - if (bytes==1) - { - ((unsigned char *) dst)[0] = (unsigned char) data; - } -#if defined(__APPLE__) || (defined(__MWERKS__) && defined(__PPCGEKKO__)) - else if (bytes==2) - { - ((unsigned short *) dst)[0] = (unsigned short) data; - } - else if (bytes==4) - { - ((unsigned int *) dst)[0] = (unsigned int) data; - } -#else - else if (bytes==2) - { - ((unsigned char *) dst)[0] = (unsigned char) (data>>8); - ((unsigned char *) dst)[1] = (unsigned char) data; - } - else if (bytes==4) - { - ((unsigned char *) dst)[0] = (unsigned char) (data>>24); - ((unsigned char *) dst)[1] = (unsigned char) (data>>16); - ((unsigned char *) dst)[2] = (unsigned char) (data>>8); - ((unsigned char *) dst)[3] = (unsigned char) data; - } -#endif - else if (bytes==3) - { - ((unsigned char *) dst)[0] = (unsigned char) (data>>16); - ((unsigned char *) dst)[1] = (unsigned char) (data>>8); - ((unsigned char *) dst)[2] = (unsigned char) data; - } -} - -/* put intel memory */ - -static __inline void gputi(void *dst, unsigned int data, int bytes) -{ - if (bytes==1) - { - ((unsigned char *) dst)[0] = (unsigned char) data; - } -#if defined(_MSC_VER) || defined(__i386__) - else if (bytes==2) - { - ((unsigned short *) dst)[0] = (unsigned short) data; - } - else if (bytes==4) - { - ((unsigned int *) dst)[0] = (unsigned int) data; - } -#else - else if (bytes==2) - { - ((unsigned char *) dst)[0] = (unsigned char) data; - ((unsigned char *) dst)[1] = (unsigned char) (data>>8); - } - else if (bytes==4) - { - ((unsigned char *) dst)[0] = (unsigned char) data; - ((unsigned char *) dst)[1] = (unsigned char) (data>>8); - ((unsigned char *) dst)[2] = (unsigned char) (data>>16); - ((unsigned char *) dst)[3] = (unsigned char) (data>>24); - } -#endif - else if (bytes==3) - { - ((unsigned char *) dst)[0] = (unsigned char) data; - ((unsigned char *) dst)[1] = (unsigned char) (data>>8); - ((unsigned char *) dst)[2] = (unsigned char) (data>>16); - } -} - -#endif /* __GIMEX_H */ - -/* END ABSTRACT */ diff --git a/Generals/Code/Libraries/Source/Compression/EAC/huffabout.cpp b/Generals/Code/Libraries/Source/Compression/EAC/huffabout.cpp deleted file mode 100644 index 5baa3eb0373..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/huffabout.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -/* ABSTRACT */ -/*------------------------------------------------------------------*/ -/* */ -/* Huffman - Huffman with Runlength Codex */ -/* */ -/* by FrANK G. Barchard, EAC */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Version Date SE History: */ -/* ------- ---- -- -------- */ -/* 1.00 950108 FB based on huff and ref codex */ -/* 1.01 950316 FB delta huff and delta delta huff */ -/* 1.02 950317 FB quick table version (used in wing3) */ -/* 1.03 950626 FB allocate context instead of on stack */ -/* 1.04 010608 ID forgot to undelta big size buffer fix */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Module Notes: */ -/* ------------- */ -/* Reentrant */ -/* Files: hufread.c hufwrite.c hufcodex.h */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Format Notes: */ -/* ------------- */ -/* *30fb fb6 huff 6.1 EOF only huff */ -/* *31fb fb6 huff 6.1 ' ' ' composite */ -/* *32fb fb6 huff 6.1 EOF only speed */ -/* *33fb fb6 huff 6.1 ' ' ' composite */ -/* *34fb fb6 huff 6.1 EOF only acceleration */ -/* *35fb fb6 huff 6.1 ' ' ' composite */ -/* */ -/*------------------------------------------------------------------*/ -/* END ABSTRACT */ - -#include -#include "codex.h" -#include "huffcodex.h" - -/****************************************************************/ -/* Information Functions */ -/****************************************************************/ - -CODEXABOUT *GCALL HUFF_about(void) -{ - CODEXABOUT *info; - - info = (CODEXABOUT *) galloc(sizeof(CODEXABOUT)); - if (info) - { - memset(info, 0, sizeof(CODEXABOUT)); - - info->signature = QMAKEID('H','U','F','F'); - info->size = sizeof(CODEXABOUT); - info->version = 200; /* codex version number (200) */ - info->decode = 1; /* supports decoding */ - info->encode = 1; /* supports encoding */ - info->size32 = 0; /* supports 32 bit size field */ - strcpy(info->versionstr, "1.04"); /* version # */ - strcpy(info->shorttypestr, "huff"); /* type */ - strcpy(info->longtypestr, "Huffman"); /* longtype */ - } - return(info); -} - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/huffcodex.h b/Generals/Code/Libraries/Source/Compression/EAC/huffcodex.h deleted file mode 100644 index 17670286247..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/huffcodex.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */ - -#ifndef __HUFCODEX -#define __HUFCODEX 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __CODEX_H -#error "Include codex.h before huffcodex.h" -#endif - -/****************************************************************/ -/* HUF Codex */ -/****************************************************************/ - -/* Information Functions */ - -CODEXABOUT *GCALL HUFF_about(void); -bool GCALL HUFF_is(const void *compresseddata); - -/* Decode Functions */ - -int GCALL HUFF_size(const void *compresseddata); -#ifdef __cplusplus -int GCALL HUFF_decode(void *dest, const void *compresseddata, int *compressedsize=0); -#else -int GCALL HUFF_decode(void *dest, const void *compresseddata, int *compressedsize); -#endif - -/* Encode Functions */ - -#ifdef __cplusplus -int GCALL HUFF_encode(void *compresseddata, const void *source, int sourcesize, int *opts=0); -#else -int GCALL HUFF_encode(void *compresseddata, const void *source, int sourcesize, int *opts); -#endif - -/****************************************************************/ -/* Internal */ -/****************************************************************/ - -#ifndef qmin -#define qmin(a,b) ((a)<(b)?(a):(b)) -#endif - -#ifndef qmax -#define qmax(a,b) ((a)>(b)?(a):(b)) -#endif - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/huffdecode.cpp b/Generals/Code/Libraries/Source/Compression/EAC/huffdecode.cpp deleted file mode 100644 index fa81d445906..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/huffdecode.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -#ifndef __HUFREAD -#define __HUFREAD 1 - -#include -#include "codex.h" -#include "huffcodex.h" - -#if defined(_MSC_VER) -#pragma warning(push,1) -#endif - -/****************************************************************/ -/* Internal Functions */ -/****************************************************************/ - -struct HuffDecodeContext -{ - unsigned char *s; - int bitsleft; - unsigned int bits; -}; - -/****************************************************************/ -/* Huffman Unpacker */ -/****************************************************************/ - -static int ZERO=0; - -#define GET16BITS() \ - bitsunshifted = qs[0] | (bitsunshifted << 8);\ - bitsunshifted = qs[1] | (bitsunshifted << 8);\ - qs += 2; - - -#define SQgetbits(v,n)\ - if (n) \ - { \ - v = bits >> (32-(n));\ - bits <<= (n);\ - bitsleft -= (n);\ - } \ -\ - if (bitsleft<0)\ - {\ - GET16BITS() \ -\ - bits = bitsunshifted<<(-bitsleft);\ - bitsleft += 16;\ - } - - -#define SQgetnum(v) \ - if ((int)bits<0)\ - {\ - SQgetbits(v,3);\ - v -= 4;\ - }\ - else\ - {\ - int n;\ - unsigned int v1;\ -\ - if (bits>>16)\ - {\ - n=2;\ - do\ - {\ - bits <<= 1; \ - ++n;\ - }\ - while ((int)bits>=0);\ - bits <<= 1;\ - bitsleft -= (n-1);\ - SQgetbits(v,ZERO);\ - }\ - else\ - {\ - n=2;\ - do\ - {\ - ++n;\ - SQgetbits(v,1);\ - }\ - while (!v);\ - }\ - if (n>16)\ - {\ - SQgetbits(v,n-16);\ - SQgetbits(v1,16);\ - v = (v1|(v<<16))+(1<=9) - break; - numbitentries = 1<<(8-bits); - - while (bitnum--) - { - nextcode = *codeptr++; - nextlen = bits; - if (nextcode==clue) - { - cluelen = bits; - nextlen = 96; /* will force out of main loop */ - } - for (i=0; i>24]; - GET16BITS(); - bits = bitsunshifted<<(16-bitsleft); - -/* quick 8 decode */ - -nextloop: - numbits = quicklenptr[bits>>24]; - bitsleft -= numbits; - - if (bitsleft>=0) - { - do - { - *qd++ = quickcodeptr[bits>>24]; - bits <<= numbits; - - numbits = quicklenptr[bits>>24]; - bitsleft -= numbits; - if (bitsleft<0) break; - *qd++ = quickcodeptr[bits>>24]; - bits <<= numbits; - - numbits = quicklenptr[bits>>24]; - bitsleft -= numbits; - if (bitsleft<0) break; - *qd++ = quickcodeptr[bits>>24]; - bits <<= numbits; - - numbits = quicklenptr[bits>>24]; - bitsleft -= numbits; - if (bitsleft<0) break; - *qd++ = quickcodeptr[bits>>24]; - bits <<= numbits; - - numbits = quicklenptr[bits>>24]; - bitsleft -= numbits; - - } while (bitsleft>=0); - } - bitsleft += 16; - - } while (bitsleft>=0); /* would fetching 16 bits do it? */ - - bitsleft = bitsleft-16+numbits; /* back to normal */ - -/****************************************************************/ -/* 16 bit decoder */ -/****************************************************************/ - - { - unsigned char code; - - - if (numbits!=96) - { - cmp = (unsigned int) (bits>>16); /* 16 bit left justified compare */ - - numbits = 8; - do - { - ++numbits; - } - while (cmp>=cmptbl[numbits]); - } - else - numbits = cluelen; - - - cmp = bits >> (32-(numbits)); - bits <<= (numbits); - bitsleft -= (numbits); - - code = codetbl[cmp-deltatbl[numbits]]; /* the code */ - - if (code!=clue && bitsleft>=0) - { - *qd++ = code; - goto nextloop; - } - - if (bitsleft<0) - { - GET16BITS(); - bits = bitsunshifted<<-bitsleft; - bitsleft += 16; - } - - if (code!=clue) - { - *qd++ = code; - goto nextloop; - } - - /* handle clue */ - - { - int runlen=0; - unsigned char *d=qd; - unsigned char *dest; - - SQgetnum(runlen); - if (runlen) /* runlength sequence */ - { - dest = d+runlen; - code = *(d-1); - do - { - *d++ = code; - } while (d. -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -#ifndef __HUFWRITE -#define __HUFWRITE 1 - -#include -#include "codex.h" -#include "huffcodex.h" - -/****************************************************************/ -/* Internal Functions */ -/****************************************************************/ - -struct HUFFMemStruct -{ - char *ptr; - int len; -}; - -#define HUFFBIGNUM 32000 -#define HUFFTREESIZE 520 -#define HUFFCODES 256 -#define HUFFMAXBITS 16 -#define HUFFREPTBL 252 - -struct HuffEncodeContext -{ - char qleapcode[HUFFCODES]; - unsigned int count[768]; - unsigned int bitnum[HUFFMAXBITS+1]; - unsigned int repbits[HUFFREPTBL]; - unsigned int repbase[HUFFREPTBL]; - unsigned int tree_left[HUFFTREESIZE]; - unsigned int tree_right[HUFFTREESIZE]; - unsigned int bitsarray[HUFFCODES]; - unsigned int patternarray[HUFFCODES]; - unsigned int masks[17]; - unsigned int packbits; - unsigned int workpattern; - unsigned char *buffer; - unsigned char *bufptr; - int flen; - unsigned int csum; - unsigned int mostbits; - unsigned int codes; - unsigned int chainused; - unsigned int clue; - unsigned int dclue; - unsigned int clues; - unsigned int dclues; - int mindelta; - int maxdelta; - unsigned int plen; - unsigned int ulen; - unsigned int sortptr[HUFFCODES]; -}; - -static void HUFF_deltabytes(const void *source,void *dest,int len) -{ - const unsigned char *s = (const unsigned char *) source; - unsigned char *d = (unsigned char *) dest; - unsigned char c; - unsigned char c1; - const unsigned char *send; - - c = '\0'; - send = s+len; - while (s 16) - { - HUFF_writebits(EC,dest,(unsigned int) (bitpattern>>16), len-16); - HUFF_writebits(EC,dest,(unsigned int) bitpattern, 16); - } - else - { - EC->packbits += len; - EC->workpattern += (bitpattern & EC->masks[len]) << (24-EC->packbits); - while (EC->packbits > 7) - { - *(dest->ptr+dest->len) = (unsigned char) (EC->workpattern >> 16); - ++dest->len; - - EC->workpattern = EC->workpattern << 8; - EC->packbits -= 8; - ++EC->plen; - } - } -} - -static void HUFF_treechase(struct HuffEncodeContext *EC, - unsigned int node, - unsigned int bits) -{ - if (node < HUFFCODES) - EC->bitsarray[node] = bits; - else - { HUFF_treechase(EC,EC->tree_left[node], bits+1); - HUFF_treechase(EC,EC->tree_right[node], bits+1); - } -} - -static void HUFF_maketree(struct HuffEncodeContext *EC) -{ - unsigned int i, i1; - unsigned int ptr1; - unsigned int val1, val2; - - unsigned int ptr2, nodes; - - unsigned int list_count[HUFFCODES+2]; - unsigned int list_ptr[HUFFCODES+2]; - -/* initialize tree */ - -/* registers vars usage - i - code - i1 - code index (number of unjoined codes) - i2 - - i3 - -*/ - - nodes = HUFFCODES; - i1 = 0; - list_count[i1++] = 0L; - for (i=0; ibitsarray[i] = 99; - if (EC->count[i]) - { list_count[i1] = (unsigned int) EC->count[i]; - list_ptr[i1++] = i; - } - } - EC->codes = i1-1; - -/* make tree */ - -/* registers vars usage - i - code index/temp - i1 - number of unjoined codes - i2 - - i3 - -*/ - - if (i1>2) - { - while (i1>2) - { - /* get 2 smallest node counts */ - - i = i1; - val1 = list_count[--i]; /* initialize 2 values */ - ptr1 = i; - val2 = list_count[--i]; - ptr2 = i; - if (val1 < val2) - { val2 = val1; - ptr2 = ptr1; - val1 = list_count[i]; - ptr1 = i; - } - - while (i) - { --i; - while (list_count[i] > val1) - --i; - - if (i) - { val1 = list_count[i]; - ptr1 = i; - if (val1 <= val2) - { val1 = val2; - ptr1 = ptr2; - val2 = list_count[i]; - ptr2 = i; - } - } - } - - EC->tree_left[nodes] = list_ptr[ptr1]; - EC->tree_right[nodes] = list_ptr[ptr2]; - list_count[ptr1] = val1 + val2; - list_ptr[ptr1] = nodes; - list_count[ptr2] = list_count[--i1]; - list_ptr[ptr2] = list_ptr[i1]; - ++nodes; - } - - /* traverse tree */ - - HUFF_treechase(EC,nodes-1, 0); - } - else - { - /* traverse tree */ - - HUFF_treechase(EC,list_ptr[EC->codes], 1); - } -} - -static int HUFF_minrep(struct HuffEncodeContext *EC, - unsigned int remaining, - unsigned int r) -{ - int min, min1, use, newremaining; - - if (r) - { min = HUFF_minrep(EC,remaining, r-1); - if (EC->count[EC->clue+r]) - { use = remaining/r; - newremaining = remaining-(use*r); - min1 = HUFF_minrep(EC,newremaining, r-1)+EC->bitsarray[EC->clue+r]*use; - if (min1bitsarray[EC->clue]+3+EC->repbits[remaining]*2; - } - } - return(min); -} - -static void HUFF_writenum(struct HuffEncodeContext *EC, - struct HUFFMemStruct *dest, - unsigned int num) -{ - unsigned int dphuf; - unsigned int dbase; - - if (numrepbits[(unsigned int) num]; - dbase = (unsigned int) EC->repbase[(unsigned int) num]; - } - else - { if (num<508L) - { dphuf = 6; - dbase = 252L; - } - else if (num<1020L) - { dphuf = 7; - dbase = 508L; - } - else if (num<2044L) - { dphuf = 8; - dbase = 1020L; - } - else if (num<4092L) - { dphuf = 9; - dbase = 2044L; - } - else if (num<8188L) - { dphuf = 10; - dbase = 4092L; - } - else if (num<16380L) - { dphuf = 11; - dbase = 8188L; - } - else if (num<32764L) - { dphuf = 12; - dbase = 16380L; - } - else if (num<65532L) - { dphuf = 13; - dbase = 32764L; - } - else if (num<131068L) - { dphuf = 14; - dbase = 65532L; - } - else if (num<262140L) - { dphuf = 15; - dbase = 131068L; - } - else if (num<524288L) - { dphuf = 16; - dbase = 262140L; - } - else if (num<1048576L) - { dphuf = 17; - dbase = 524288L; - } - else - { dphuf = 18; - dbase = 1048576L; - } - } - HUFF_writebits(EC,dest,(unsigned int) 0x00000001, dphuf+1); - HUFF_writebits(EC,dest,(unsigned int) (num - dbase), dphuf+2); -} - -/* write explicite byte ([clue] 0gn [0] [byte]) */ - -static void HUFF_writeexp(struct HuffEncodeContext *EC, - struct HUFFMemStruct *dest, - unsigned int code) -{ - HUFF_writebits(EC,dest,EC->patternarray[EC->clue], EC->bitsarray[EC->clue]); - HUFF_writenum(EC,dest,0L); - HUFF_writebits(EC,dest,(unsigned int) code, 9); -} - -static void HUFF_writecode(struct HuffEncodeContext *EC, - struct HUFFMemStruct *dest, - unsigned int code) -{ - if (code==EC->clue) - HUFF_writeexp(EC,dest,code); - else - HUFF_writebits(EC,dest,EC->patternarray[code], EC->bitsarray[code]); -} - -static void HUFF_init(struct HuffEncodeContext *EC) -{ - unsigned int i; - -/* precalculate repeat field lengths */ - -/* registers vars usage - i - num - i1 - - i2 - - i3 - -*/ - - i = 0; - while (i<4) - { EC->repbits[i] = 0; - EC->repbase[i++] = 0L; - } - while (i<12) - { EC->repbits[i] = 1; - EC->repbase[i++] = 4L; - } - while (i<28) - { EC->repbits[i] = 2; - EC->repbase[i++] = 12L; - } - while (i<60) - { EC->repbits[i] = 3; - EC->repbase[i++] = 28L; - } - while (i<124) - { EC->repbits[i] = 4; - EC->repbase[i++] = 60L; - } - while (i<252) - { EC->repbits[i] = 5; - EC->repbase[i++] = 124L; - } -} - - -static void HUFF_analysis(struct HuffEncodeContext *EC, - unsigned int opt, - unsigned int chainsaw) -{ - unsigned char *bptr1; - unsigned char *bptr2; - unsigned int i; - unsigned int i1; - unsigned int i2=0; - unsigned int i3; - - unsigned int thres=0; - int di; - unsigned int pattern; - unsigned int rep1; - unsigned int repn; - unsigned int ncode; - unsigned int irep; - unsigned int remaining; - - unsigned int count2[HUFFCODES]; - unsigned int dcount[HUFFCODES]; - -/* count file (pass 1) */ - -/* registers vars usage - i - current byte - i1 - previous byte - i2 - rep - i3 - checksum -*/ - - for (i=0; i<768; ++i) - EC->count[i] = 0; - - bptr1 = EC->buffer; - i1 = 256; - i3 = 0; - while (bptr1bufptr) - { i = (unsigned int) *bptr1++; - i3 = i3 + i; - if (i == i1) - { - i2 = 0; - bptr2 = bptr1+30000; - if (bptr2>(EC->bufptr)) - bptr2 = EC->bufptr; - - while ((i == i1) && (bptr1 < bptr2)) - { ++i2; - i = (unsigned int) *bptr1++; - i3 = i3 + i; - } - - if (i2 < 255) - ++EC->count[512+i2]; - else - ++EC->count[512]; - } - ++EC->count[i]; - ++EC->count[((i+256-i1)&255)+256]; - i1 = i; - } - EC->csum = i3; - if (!EC->count[512]) - ++EC->count[512]; - -/* find clue bytes */ - -/* registers vars usage - i - code - i1 - cluebyte - i2 - clues - i3 - best forced clue -*/ - - EC->clues = 0; - EC->dclues = 0; - i3 = 0; - for (i=0;icount[i]count[i3]) - i3 = i; - while (!EC->count[i] && (i<256)) - { ++i2; - ++i; - } - if (i2 >= EC->dclues) - { EC->dclue = i1; - EC->dclues = i2; - if (EC->dclues >= EC->clues) - { EC->dclue = EC->clue; - EC->dclues = EC->clues; - EC->clue = i1; - EC->clues = i2; - } - } - } - -/* force a clue byte */ - - if (opt & 32) - { if (!EC->clues) - { EC->clues = 1; - EC->clue = i3; - } - } - -/* disable & split clue bytes */ - - if ((~opt) & 2) - { if (EC->clues>1) - EC->clues = 1; - if ((~opt) & 1) - EC->clues = 0; - } - if ((~opt) & 4) - EC->dclues = 0; - else - { if (EC->dclues > 10) - { i1 = EC->clue; - i2 = EC->clues; - EC->clue = EC->dclue; - EC->clues = EC->dclues; - EC->dclue = i1; - EC->dclues = i2; - } - - if ((EC->clues*4) < EC->dclues) - { EC->clues = EC->dclues/4; - EC->dclues = EC->dclues-EC->clues; - EC->clue = EC->dclue+EC->dclues; - } - } - - -/* copy delta clue bytes */ - - if (EC->dclues) - { - EC->mindelta = -((int)EC->dclues/2); - EC->maxdelta = EC->dclues+EC->mindelta; - thres = (int) (EC->ulen/25); - - for (i=1;i<=(unsigned int)EC->maxdelta;++i) - if (EC->count[256+i] > thres) - EC->count[EC->dclue+(i-1)*2] = EC->count[256+i]; - for (i=1;i<=(unsigned int)(-EC->mindelta);++i) - if (EC->count[512-i] > thres) - EC->count[EC->dclue+(i-1)*2+1] = EC->count[512-i]; - -/* adjust delta clues */ - - for (i=0, i2=0;idclues;++i) - if (EC->count[EC->dclue+i]) - i2 = i; - di = EC->dclues-i2-1; - EC->dclues -= di; - if (EC->clue == (EC->dclue+EC->dclues+di)) - { EC->clue -= di; - EC->clues += di; - } - EC->mindelta = -((int)EC->dclues/2); - EC->maxdelta = EC->dclues+EC->mindelta; - } - -/* copy rep clue bytes */ - - if (EC->clues) - { - for (i=0;iclues;++i) - EC->count[EC->clue+i] = EC->count[512+i]; - } - -/* make a first approximation tree */ - - HUFF_maketree(EC); - - - -/* remove implied rep clues */ - -/* registers vars usage - i - clues - i1 - minrep - i2 - - i3 - -*/ - - if (EC->clues>1) - { - for (i=1; iclues; ++i) - { i1 = i-1; - if (i1>8) - i1 = 8; - if (EC->count[EC->clue+i]) - { i1 = HUFF_minrep(EC,i,i1); - if ((i1 <= EC->bitsarray[EC->clue+i]) - || (EC->count[EC->clue+i]*(i1-EC->bitsarray[EC->clue+i])<(i/2))) - { EC->count[EC->clue+i] = 0; - } - } - } - } - -/* count file (pass 2) */ - -/* registers vars usage - i - current byte - i1 - previous byte - i2 - rep - i3 - rep2 -*/ - - for (i=0; icount[i]; - dcount[i] = 0; - EC->count[i] = 0; - EC->count[256+i] = 0; - EC->count[512+i] = 0; - } - - i = 1; - i1 = 256; - bptr1 = EC->buffer; - while (bptr1bufptr) - { i = (unsigned int) *bptr1++; - if (i == i1) - { - i2 = 0; - bptr2 = bptr1+30000; - if (bptr2>(EC->bufptr)) - bptr2 = EC->bufptr; - - while ((i == i1) && (bptr1 < bptr2)) - { i = (unsigned int) *bptr1++; - ++i2; - } - - repn = HUFFBIGNUM; - irep = HUFFBIGNUM; - ncode = i2*EC->bitsarray[i1]; - if (EC->clues) - { - if (count2[EC->clue]) - { repn = 20; - if (i2 < HUFFREPTBL) - repn = EC->bitsarray[EC->clue]+3+EC->repbits[i2]*2; - } - if (EC->clues>1) - { - remaining = i2; - irep = 0; - i3=EC->clues-1; - while (i3) - { if (count2[EC->clue+i3]) - { rep1 = remaining/i3; - irep = irep+rep1*EC->bitsarray[EC->clue+i3]; - remaining = remaining-rep1*i3; - } - --i3; - } - if (remaining) - irep=HUFFBIGNUM; - } - } - - if ((ncode<=repn) && (ncode<=irep)) - EC->count[i1] += i2; - else - { if (repn < irep) - ++EC->count[EC->clue]; - else - { - remaining = i2; - irep = 0; - i3=EC->clues-1; - while (i3) - { if (count2[EC->clue+i3]) - { rep1 = remaining/i3; - irep = irep+rep1*EC->bitsarray[EC->clue+i3]; - remaining = remaining-rep1*i3; - EC->count[EC->clue+i3] += rep1; - } - --i3; - } - } - } - } - if (EC->dclues) - { i3 = 0; - di = i-i1; - if (di <= EC->maxdelta) - { if (di >= EC->mindelta) - { di = (i-i1-1)*2+EC->dclue; - if (idclue+1; - if (count2[di]>thres) - { if (count2[i]<4) - ++i3; - if (EC->bitsarray[di] < EC->bitsarray[i]) - ++i3; - if (EC->bitsarray[di] == EC->bitsarray[i]) - if (EC->count[di] > EC->count[i]) - ++i3; - } - } - } - if (i3) - ++EC->count[di]; - else - ++EC->count[i]; - } - else - ++EC->count[i]; - i1 = i; - } - -/* force a clue byte */ - - if (opt & 32) - ++EC->count[EC->clue]; - -/* make a second approximation tree */ - - HUFF_maketree(EC); - -/* chainsaw IV branch clipping algorithm */ - -/* - maintains perfect tree - - - find intest code - - find intest branch thats shorter than maximum bits - - graft one branch to the shorter branch - - shorten the other code by 1 -*/ - -/* registers vars usage - i - code - i1 - codes lengths - i2 - int code1 ptr - i3 - int code2 ptr -*/ - - EC->chainused = 0; - i1 = 99; - while (i1>chainsaw) - { i1 = 0; - for (i=0; icount[i]) - { if (EC->bitsarray[i]>=i1) - { i3 = i2; - i2 = i; - i1 = EC->bitsarray[i]; - } - } - } - - if (i1>chainsaw) - { - i1 = 0; - while (i1count[i1]) - { - if (EC->bitsarray[i1]count[i]) - { - if ((EC->bitsarray[i]bitsarray[i]>EC->bitsarray[i1])) - i1 = i; - } - } - - i = EC->bitsarray[i1]+1; /* graft to short code */ - EC->bitsarray[i1] = i; - EC->bitsarray[i2] = i; - EC->bitsarray[i3] = EC->bitsarray[i3]-1;/* shorten other code by 1 */ - - EC->chainused = chainsaw; - i1 = 99; - } - } - -/* if huffman inhibited make all codes 8 bits */ - -/* registers vars usage - i - code - i1 - 8 - i2 - - i3 - -*/ - - if ((~opt) & 8) - { - i1 = 8; - for (i=0; ibitsarray[i] = i1; - } - -/* count bitnums */ - -/* registers vars usage - i - code/bits - i1 - - i2 - - i3 - -*/ - - for (i=0; i<=HUFFMAXBITS; ++i) - EC->bitnum[i] = 0; - for (i=0; ibitsarray[i]<=HUFFMAXBITS) - ++EC->bitnum[EC->bitsarray[i]]; - } - -/* sort codes */ - -/* registers vars usage - i - next sorted ptr - i1 - code - i2 - bits - i3 - EC->mostbits -*/ - - i=0; - i3=0; - for (i2=1; i2<=HUFFMAXBITS; ++i2) - { if (EC->bitnum[i2]) - { for (i1=0; i1bitsarray[i1] == i2) - EC->sortptr[i++] = i1; - i3 = i2; - } - } - EC->mostbits = i3; - -/* assign bit patterns */ - -/* registers vars usage - i - code index - i1 - code - i2 - bits - i3 - -*/ - - pattern = 0L; - i2 = 0; - for (i=0; icodes; ++i) - { i1 = EC->sortptr[i]; - while (i2 < EC->bitsarray[i1]) - { ++i2; - pattern = pattern << 1; - } - EC->patternarray[i1] = pattern; - ++pattern; - } -} - - -static void HUFF_pack(struct HuffEncodeContext *EC, - struct HUFFMemStruct *dest, - unsigned int opt) -{ - unsigned char *bptr1; - unsigned char *bptr2; - unsigned int i; - unsigned int i1; - unsigned int i2; - unsigned int i3; - int uptype; - unsigned int hlen, ibits, rladjust; - int di, firstcode, firstbits; - unsigned int rep1, repn, ncode, irep, remaining,curpc; - -/* write header */ - - curpc = 0L; - - uptype = 38; - rladjust = 1; - if (uptype==38) - { - if (uptype==34) - { - HUFF_writenum(EC,dest,(unsigned int) EC->ulen); - - ibits = 0; - if ((opt & 16) && (!EC->chainused)) - ibits = 1; - - i = 0; /* write options field */ - if (EC->clues) - i = 1; - if (ibits) - i += 2; - if (EC->dclues) - i += 4; - HUFF_writenum(EC,dest,(unsigned int) i); - - if (EC->clues) - { HUFF_writenum(EC,dest,(unsigned int) EC->clue); - HUFF_writenum(EC,dest,(unsigned int) EC->clues); - } - if (EC->dclues) - { HUFF_writenum(EC,dest,(unsigned int) EC->dclue); - HUFF_writenum(EC,dest,(unsigned int) EC->dclues); - } - - if (!ibits) - HUFF_writenum(EC,dest,(unsigned int) EC->mostbits); - } - else - { - HUFF_writebits(EC,dest,(unsigned int) EC->clue, 8); /* clue */ - rladjust = 0; - } - - for (i=1; i <= EC->mostbits; ++i) - HUFF_writenum(EC,dest,(unsigned int) EC->bitnum[i]); - - for (i=0; iqleapcode[i] = 0; - - i = 0; - i2 = 255; - firstbits = 0; - firstcode = -1; - while (icodes) - { - i1 = EC->sortptr[i]; -#if 0 - if (EC->bitsarray[i1]!=firstbits) - { - i2 = firstcode; - firstcode = i1; - firstbits = EC->bitsarray[i2]; - } -#endif - -/* calculate leapfrog delta */ - - di = -1; - do - { - i2 = (i2+1)&255; - if (!EC->qleapcode[i2]) - ++di; - } while (i1!=i2); - EC->qleapcode[i2] = 1; - HUFF_writenum(EC,dest,(unsigned int) di); - ++i; - } - } - hlen = EC->plen+1; - - if (!EC->clues) - EC->clue = HUFFBIGNUM; - -/* write packed file */ - -/* registers vars usage - i - current byte - i1 - previous byte - i2 - rep - i3 - rep2 -*/ - - i = 1; - i1 = 256; - bptr1 = EC->buffer; - while (bptr1bufptr) - { i = (unsigned int) *bptr1++; - - if (i == i1) - { - i2 = 0; - bptr2 = bptr1+30000; - if (bptr2>(EC->bufptr)) - bptr2 = EC->bufptr; - - while ((i == i1) && (bptr1 < bptr2)) - { i = (unsigned int) *bptr1++; - ++i2; - } - - repn = HUFFBIGNUM; - irep = HUFFBIGNUM; - ncode = i2*EC->bitsarray[i1]; - if (EC->clues) - { - if (EC->count[EC->clue]) - { repn = 20; - if (i2 < HUFFREPTBL) - repn = EC->bitsarray[EC->clue]+3+EC->repbits[i2]*2; - } - if (EC->clues>1) - { - remaining = i2; - irep = 0; - i3=EC->clues-1; - while (i3) - { if (EC->count[EC->clue+i3]) - { rep1 = remaining/i3; - irep = irep+rep1*EC->bitsarray[EC->clue+i3]; - remaining = remaining-rep1*i3; - } - --i3; - } - if (remaining) - irep = HUFFBIGNUM; - } - } - - if ((ncode<=repn) && (ncode<=irep)) - { - while (i2--) - HUFF_writecode(EC,dest,i1); - } - else - { if (repn < irep) - { - HUFF_writebits(EC,dest,EC->patternarray[EC->clue], EC->bitsarray[EC->clue]); - HUFF_writenum(EC,dest,(unsigned int) (i2-rladjust)); - } - else - { - remaining = i2; - irep = 0; - i3=EC->clues-1; - while (i3) - { if (EC->count[EC->clue+i3]) - { rep1 = remaining/i3; - irep = irep+rep1*EC->bitsarray[EC->clue+i3]; - remaining = remaining-rep1*i3; - while (rep1--) - HUFF_writecode(EC,dest,EC->clue+i3); - } - --i3; - } - } - } - } - i3 = 0; - if (EC->dclues) - { - di = i-i1; - if ((di <= EC->maxdelta) && (di >= EC->mindelta)) - { di = (i-i1-1)*2+EC->dclue; - if (idclue+1; - if (EC->bitsarray[di] < EC->bitsarray[i]) - { HUFF_writebits(EC,dest,EC->patternarray[di], EC->bitsarray[di]); - ++i3; - } - } - } - i1 = i; - if (!i3) - HUFF_writecode(EC,dest,i); - - if (((int) bptr1- (int) EC->buffer) >= (int)(EC->plen+curpc)) - curpc = (int) bptr1 - (int) EC->buffer - EC->plen; - } - - /* write EOF ([clue] 0gn [10]) */ - - HUFF_writebits(EC,dest,EC->patternarray[EC->clue], EC->bitsarray[EC->clue]); - HUFF_writenum(EC,dest,0L); - HUFF_writebits(EC,dest,(unsigned int) 2, 2); - - /* flush bits */ - - HUFF_writebits(EC,dest,(unsigned int) 0,7); - - curpc += 2; -} - -static int HUFF_packfile(struct HuffEncodeContext *EC, - struct HUFFMemStruct *infile, - struct HUFFMemStruct *outfile, - int ulen, - int deltaed) -{ - unsigned int i; - unsigned int uptype=0; - unsigned int chainsaw; - unsigned int opt; - -/* set defaults */ - - EC->packbits = 0; - EC->workpattern = 0L; - chainsaw = 15; - EC->masks[0] = 0; - for (i=1;i<17;++i) - EC->masks[i] = (EC->masks[i-1] << 1) + 1; - -/* initialize huffman vars */ - - HUFF_init(EC); - -/* read in a source file */ - - EC->buffer = (unsigned char *) (infile->ptr); - EC->flen = infile->len; - - EC->ulen = EC->flen; - EC->bufptr = EC->buffer + EC->flen; - -/* pack a file */ - - outfile->ptr = outfile->ptr; - outfile->len = 0L; - - EC->packbits = 0; - EC->workpattern = 0L; - EC->plen = 0L; - - opt = 57 | 49; - - HUFF_analysis(EC,opt, chainsaw); - -/* write standard header stuff (type/signature/ulen/adjust) */ - - if (ulen>0xffffff) // 32 bit header required - { - /* simple fb6 header */ - - if (ulen==infile->len) - { - if (deltaed==0) uptype = 0xb0fb; - else if (deltaed==1) uptype = 0xb2fb; - else if (deltaed==2) uptype = 0xb4fb; - HUFF_writebits(EC,outfile,(unsigned int) uptype, 16); - HUFF_writebits(EC,outfile,(unsigned int) infile->len, 32); - } - - /* composite fb4 header */ - - else - { - if (deltaed==0) uptype = 0xb1fb; - else if (deltaed==1) uptype = 0xb3fb; - else if (deltaed==2) uptype = 0xb5fb; - HUFF_writebits(EC,outfile,(unsigned int) uptype, 16); - HUFF_writebits(EC,outfile,(unsigned int) ulen, 32); - HUFF_writebits(EC,outfile,(unsigned int) infile->len, 32); - } - } - else - { - /* simple fb6 header */ - - - if (ulen==infile->len) - { - if (deltaed==0) uptype = 0x30fb; - else if (deltaed==1) uptype = 0x32fb; - else if (deltaed==2) uptype = 0x34fb; - HUFF_writebits(EC,outfile,(unsigned int) uptype, 16); - HUFF_writebits(EC,outfile,(unsigned int) infile->len, 24); - } - - /* composite fb4 header */ - - else - { - if (deltaed==0) uptype = 0x31fb; - else if (deltaed==1) uptype = 0x33fb; - else if (deltaed==2) uptype = 0x35fb; - HUFF_writebits(EC,outfile,(unsigned int) uptype, 16); - HUFF_writebits(EC,outfile,(unsigned int) ulen, 24); - HUFF_writebits(EC,outfile,(unsigned int) infile->len, 24); - } - } - - HUFF_pack(EC,outfile, opt); - - return(outfile->len); -} - - -/****************************************************************/ -/* Encode Function */ -/****************************************************************/ - -int GCALL HUFF_encode(void *compresseddata, const void *source, int sourcesize, int *opts) -{ - int plen=0; - struct HUFFMemStruct infile; - struct HUFFMemStruct outfile; - struct HuffEncodeContext *EC=0; - void *deltabuf=0; - int opt=0; - if (opts) - opt = opts[0]; - - EC = (struct HuffEncodeContext *)galloc(sizeof(struct HuffEncodeContext)); - if (EC) - { - switch (opt) - { - default: - case 0: - infile.ptr = (char *)source; - break; - - case 1: - deltabuf = galloc(sourcesize); - HUFF_deltabytes(source,deltabuf,sourcesize); - infile.ptr = (char *) deltabuf; - break; - - case 2: - deltabuf = galloc(sourcesize); - HUFF_deltabytes(source,deltabuf,sourcesize); - HUFF_deltabytes(deltabuf,deltabuf,sourcesize); - infile.ptr = (char *) deltabuf; - break; - } - - infile.len = sourcesize; - outfile.ptr = (char *)compresseddata; - outfile.len = sourcesize; - - plen = HUFF_packfile(EC,&infile, &outfile, sourcesize, opt); - - if (deltabuf) gfree(deltabuf); - gfree(EC); - } - return(plen); -} - -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/refabout.cpp b/Generals/Code/Libraries/Source/Compression/EAC/refabout.cpp deleted file mode 100644 index c04fa3f7076..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/refabout.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -/* ABSTRACT */ -/*------------------------------------------------------------------*/ -/* */ -/* RefPack - Backward Reference Codex */ -/* */ -/* by FrANK G. Barchard, EAC */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Version Date SE History: */ -/* ------- ---- -- -------- */ -/* 0.10 941010 FB First codex prototype module */ -/* 0.90 941019 FB #includable */ -/* 1.00 950108 FB frozen API at 1.00 */ -/* 1.01 010426 FB 32 size field */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Module Notes: */ -/* ------------- */ -/* used hash table and link table for speed */ -/* Reentrant */ -/* Files: refread.c refwrite.c refcodex.h (refmatch.asm pc) */ -/* */ -/*------------------------------------------------------------------*/ -/* */ -/* Format Notes: */ -/* ------------- */ -/* refpack is a sliding window (131k) lzss method, with byte */ -/* oriented coding. */ -/* */ -/* huff fb6 style header: */ -/* *10fb fb6 refpack 1.0 reference pack */ -/* *90fb fb6 refpack 1.01 32 bit reference pack */ -/* */ -/* */ -/* header: */ -/* [10fb] [totalunpacksize] [nextunpacksize] */ -/* 2 3 3 */ -/* [90fb] [totalunpacksize] [nextunpacksize] */ -/* 2 4 4 */ -/* */ -/* */ -/* */ -/* format is: */ -/* ---------- */ -/* 0ffnnndd_ffffffff short ref, f=0..1023,n=3..10,d=0..3 */ -/* 10nnnnnn_ddffffff_ffffffff int ref, f=0..16384,n=4..67,d=0..3 */ -/* 110fnndd_f.._f.._nnnnnnnn very int,f=0..131071,n=5..1028,d=0..3*/ -/* 111ddddd literal, d=4..112 */ -/* 111111dd eof, d=0..3 */ -/* */ -/*------------------------------------------------------------------*/ -/* END ABSTRACT */ - -#include -#include "codex.h" -#include "refcodex.h" - -/****************************************************************/ -/* Information Functions */ -/****************************************************************/ - -CODEXABOUT *GCALL REF_about(void) -{ - CODEXABOUT *info; - - info = (CODEXABOUT *) galloc(sizeof(CODEXABOUT)); - if (info) - { - memset(info, 0, sizeof(CODEXABOUT)); - - info->signature = QMAKEID(0,'R','E','F'); - info->size = sizeof(CODEXABOUT); - info->version = 200; /* codex version number (200) */ - info->decode = 1; /* supports decoding */ - info->encode = 1; /* supports encoding */ - info->size32 = 1; /* supports 32 bit size field */ - strcpy(info->versionstr, "1.01"); /* version # */ - strcpy(info->shorttypestr, "ref"); /* type */ - strcpy(info->longtypestr, "Refpack"); /* longtype */ - } - return(info); -} - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/refcodex.h b/Generals/Code/Libraries/Source/Compression/EAC/refcodex.h deleted file mode 100644 index ce590195956..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/refcodex.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */ - -#ifndef __REFCODEX -#define __REFCODEX 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __CODEX_H -#error "Include codex.h before refcodex.h" -#endif - -/****************************************************************/ -/* REF Codex */ -/****************************************************************/ - -/* Information Functions */ - -CODEXABOUT *GCALL REF_about(void); -bool GCALL REF_is(const void *compresseddata); - -/* Decode Functions */ - -int GCALL REF_size(const void *compresseddata); -#ifdef __cplusplus -int GCALL REF_decode(void *dest, const void *compresseddata, int *compressedsize=0); -#else -int GCALL REF_decode(void *dest, const void *compresseddata, int *compressedsize); -#endif - -/* Encode Functions */ - -#ifdef __cplusplus -int GCALL REF_encode(void *compresseddata, const void *source, int sourcesize, int *opts=0); -#else -int GCALL REF_encode(void *compresseddata, const void *source, int sourcesize, int *opts); -#endif - -/****************************************************************/ -/* Internal */ -/****************************************************************/ - -#ifndef qmin -#define qmin(a,b) ((a)<(b)?(a):(b)) -#endif - -#ifndef qmax -#define qmax(a,b) ((a)>(b)?(a):(b)) -#endif - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/refdecode.cpp b/Generals/Code/Libraries/Source/Compression/EAC/refdecode.cpp deleted file mode 100644 index 68b7e77c242..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/refdecode.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -#ifndef __REFREAD -#define __REFREAD 1 - -#include -#include "codex.h" -#include "refcodex.h" - -/****************************************************************/ -/* Information Functions */ -/****************************************************************/ - -/* check for reasonable header: */ -/* 10fb header */ - -bool GCALL REF_is(const void *compresseddata) -{ - bool ok=false; - int packtype=ggetm(compresseddata,2); - - if (packtype==0x10fb - || packtype==0x11fb - || packtype==0x90fb - || packtype==0x91fb) - ok = true; - - return(ok); -} - - -/****************************************************************/ -/* Decode Functions */ -/****************************************************************/ - -int GCALL REF_size(const void *compresseddata) -{ - int len=0; - int packtype=ggetm(compresseddata,2); - int ssize=(packtype&0x8000)?4:3; - - if (packtype&0x100) /* 11fb */ - { - len = ggetm((char *)compresseddata+2+ssize,ssize); - } - else /* 10fb */ - { - len = ggetm((char *)compresseddata+2,ssize); - } - - return(len); -} - - -int GCALL REF_decode(void *dest, const void *compresseddata, int *compressedsize) -{ - unsigned char *s; - unsigned char *ref; - unsigned char *d; - unsigned char first; - unsigned char second; - unsigned char third; - unsigned char forth; - unsigned int run; - unsigned int type; - int ulen; - - s = (unsigned char *) compresseddata; - d = (unsigned char *) dest; - ulen = 0L; - - if (s) - { - type = *s++; - type = (type<<8) + *s++; - - if (type&0x8000) /* 4 byte size field */ - { - if (type&0x100) /* skip ulen */ - s += 4; - - ulen = *s++; - ulen = (ulen<<8) + *s++; - ulen = (ulen<<8) + *s++; - ulen = (ulen<<8) + *s++; - } - else - { - if (type&0x100) /* skip ulen */ - s += 3; - - ulen = *s++; - ulen = (ulen<<8) + *s++; - ulen = (ulen<<8) + *s++; - } - - for (;;) - { - first = *s++; - if (!(first&0x80)) /* short form */ - { - second = *s++; - run = first&3; - while (run--) - *d++ = *s++; - ref = d-1 - (((first&0x60)<<3) + second); - run = ((first&0x1c)>>2)+3-1; - do - { - *d++ = *ref++; - } while (run--); - continue; - } - if (!(first&0x40)) /* int form */ - { - second = *s++; - third = *s++; - run = second>>6; - while (run--) - *d++ = *s++; - - ref = d-1 - (((second&0x3f)<<8) + third); - - run = (first&0x3f)+4-1; - do - { - *d++ = *ref++; - } while (run--); - continue; - } - if (!(first&0x20)) /* very int form */ - { - second = *s++; - third = *s++; - forth = *s++; - run = first&3; - while (run--) - *d++ = *s++; - - ref = d-1 - (((first&0x10)>>4<<16) + (second<<8) + third); - - run = ((first&0x0c)>>2<<8) + forth + 5-1; - do - { - *d++ = *ref++; - } while (run--); - continue; - } - run = ((first&0x1f)<<2)+4; /* literal */ - if (run<=112) - { - while (run--) - *d++ = *s++; - continue; - } - run = first&3; /* eof (+0..3 literal) */ - while (run--) - *d++ = *s++; - break; - } - } - if (compressedsize) - *compressedsize = (int)((char *)s-(char *)compresseddata); - return(ulen); -} - -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/EAC/refencode.cpp b/Generals/Code/Libraries/Source/Compression/EAC/refencode.cpp deleted file mode 100644 index a72679061e0..00000000000 --- a/Generals/Code/Libraries/Source/Compression/EAC/refencode.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. - -#ifndef __REFWRITE -#define __REFWRITE 1 - -#include -#include "codex.h" -#include "refcodex.h" - -/****************************************************************/ -/* Internal Functions */ -/****************************************************************/ - -static unsigned int matchlen(unsigned char *s,unsigned char *d, unsigned int maxmatch) -{ - unsigned int current; - - for (current=0; current (unsigned int)131071) - maxback = 131071; - - hashtbl = (int *) galloc(65536L*sizeof(int)); - if (!hashtbl) - return(0); - link = (int *) galloc(131072L*sizeof(int)); - if (!link) - return(0); - - memset(hashtbl,-1,65536L*sizeof(int)); - - len -= 4; - while (len>=0) - { - boffset = 0; - blen = 2; - bcost = 2; -// ccost = 0; - mlen = qmin(len,1028); - tptr=cptr-1; - hash = HASH(cptr); - hoffset = hashtbl[hash]; - minhoffset = qmax(cptr-from-131071,0); - - - if (hoffset>=minhoffset) - { - do - { - tptr = from+hoffset; - if (cptr[blen]==tptr[blen]) - { - tlen = matchlen(cptr,tptr,mlen); - if (tlen > blen) - { - toffset = (cptr-1)-tptr; - if (toffset<1024 && tlen<=10) /* two byte int form */ - tcost = 2; - else if (toffset<16384 && tlen<=67) /* three byte int form */ - tcost = 3; - else /* four byte very int form */ - tcost = 4; - - if (tlen-tcost+4 > blen-bcost+4) - { - blen = tlen; - bcost = tcost; - boffset = toffset; - if (blen>=1028) break; - } - } - } - } while ((hoffset = link[hoffset&131071]) >= minhoffset); - } - -// ccost = 0; -// if ((run<4) && ((run+blen)>=4)) -// ccost = 1; // extra packet cost to switch out of literal into reference - -// if (bcost>blen || (blen<=2 && bcost==blen && !ccost) || (len<4)) - if (bcost>=blen || len<4) - { - hoffset = (cptr-from); - link[hoffset&131071] = hashtbl[hash]; - hashtbl[hash] = hoffset; - - ++run; - ++cptr; - --len; - } - else - { - while (run>3) /* literal block of data */ - { - tlen = qmin(112,run&~3); - run -= tlen; - *to++ = (unsigned char) (0xe0+(tlen>>2)-1); - memcpy(to,rptr,tlen); - rptr += tlen; - to += tlen; - ++countliterals; - } - if (bcost==2) /* two byte int form */ - { - *to++ = (unsigned char) (((boffset>>8)<<5) + ((blen-3)<<2) + run); - *to++ = (unsigned char) boffset; - ++countshort; - } - else if (bcost==3) /* three byte int form */ - { - *to++ = (unsigned char) (0x80 + (blen-4)); - *to++ = (unsigned char) ((run<<6) + (boffset>>8)); - *to++ = (unsigned char) boffset; - ++countint; - } - else /* four byte very int form */ - { - *to++ = (unsigned char) (0xc0 + ((boffset>>16)<<4) + (((blen-5)>>8)<<2) + run); - *to++ = (unsigned char) (boffset>>8); - *to++ = (unsigned char) (boffset); - *to++ = (unsigned char) (blen-5); - ++countvint; - } - if (run) - { - memcpy(to, rptr, run); - to += run; - run = 0; - } - - if (quick) - { - hoffset = (cptr-from); - link[hoffset&131071] = hashtbl[hash]; - hashtbl[hash] = hoffset; - cptr += blen; - } - else - { - for (i=0; i < (int)blen; ++i) - { - hash = HASH(cptr); - hoffset = (cptr-from); - link[hoffset&131071] = hashtbl[hash]; - hashtbl[hash] = hoffset; - ++cptr; - } - } - - rptr = cptr; - len -= blen; - } - } - len += 4; - run += len; - while (run>3) /* no match at end, use literal */ - { - tlen = qmin(112,run&~3); - run -= tlen; - *to++ = (unsigned char) (0xe0+(tlen>>2)-1); - memcpy(to,rptr,tlen); - rptr += tlen; - to += tlen; - } - - *to++ = (unsigned char) (0xfc+run); /* end of stream command + 0..3 literal */ - if (run) - { - memcpy(to,rptr,run); - to += run; - } - - gfree(link); - gfree(hashtbl); - return(to-dest); -} - - -/****************************************************************/ -/* Encode Function */ -/****************************************************************/ - -int GCALL REF_encode(void *compresseddata, const void *source, int sourcesize, int *opts) -{ - int maxback=131072; - int quick=0; - int plen; - int hlen; - - - /* simple fb6 header */ - - if (sourcesize>0xffffff) // 32 bit header required - { - gputm(compresseddata, (unsigned int) 0x90fb, 2); - gputm((char *)compresseddata+2, (unsigned int) sourcesize, 4); - hlen = 6L; - } - else - { - gputm(compresseddata, (unsigned int) 0x10fb, 2); - gputm((char *)compresseddata+2, (unsigned int) sourcesize, 3); - hlen = 5L; - } - plen = hlen+refcompress((unsigned char *)source, sourcesize, (unsigned char *)compresseddata+hlen, maxback, quick); - return(plen); -} - -#endif - diff --git a/Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp b/Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp deleted file mode 100644 index 120cad13f0d..00000000000 --- a/Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// compress.c -// Compress interface for packets and files -// Author: Jeff Brown, January 1999 - -#include -#include -#include "Lib/BaseType.h" -#include "NoxCompress.h" -#include "CompLibHeader/lzhl.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma message("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -#define BLOCKSIZE 500000 -#define NoxRead fread -#define DbgMalloc malloc -#define DbgFree free -#define DEBUG_LOG(x) {} - -Bool DecompressFile (char *infile, char *outfile) -{ - UnsignedInt rawSize = 0, compressedSize = 0; - FILE *inFilePtr = NULL; - FILE *outFilePtr= NULL; - char *inBlock = NULL; - char *outBlock = NULL; - LZHL_DHANDLE decompress; - Int ok = 0; - UnsignedInt srcSz, dstSz; - - // Parameter checking - - if (( infile == NULL ) || ( outfile == NULL )) - return FALSE; - - inFilePtr = fopen( infile, "rb" ); - if ( inFilePtr ) - { - // Allocate the appropriate amount of memory - // Get compressed size of file. - fseek( inFilePtr, 0, SEEK_END ); - compressedSize = ftell( inFilePtr ); - fseek( inFilePtr, 0, SEEK_SET ); - - compressedSize -= sizeof(UnsignedInt); - - // Get uncompressed size. Don't worry about endian, - // this is always INTEL baby! - NoxRead(&rawSize, 1, sizeof(UnsignedInt), inFilePtr); - - // This is ick, but allocate a BIIIIG chunk o' memory x 2 - inBlock = (char *) DbgMalloc( compressedSize ); - outBlock= (char *) DbgMalloc( rawSize ); - - if (( inBlock == NULL ) || ( outBlock == NULL )) - return FALSE; - - // Read in a big chunk o file - NoxRead(inBlock, 1, compressedSize, inFilePtr); - - fclose(inFilePtr); - - // Decompress - srcSz = compressedSize; - dstSz = rawSize; - - // Just Do it! - decompress = LZHLCreateDecompressor(); - - for (;;) - { - ok = LZHLDecompress( decompress, outBlock + rawSize - dstSz, &dstSz, - inBlock + compressedSize - srcSz, &srcSz); - - if ( !ok ) - break; - - if (srcSz <= 0) - break; - } - - DEBUG_LOG(("Decompressed %s to %s, output size = %d\n", infile, outfile, rawSize)); - - LZHLDestroyDecompressor(decompress); - outFilePtr = fopen(outfile, "wb"); - if (outFilePtr) - { - fwrite (outBlock, rawSize, 1, outFilePtr); - fclose(outFilePtr); - } - else - return FALSE; - - // Clean up this mess - DbgFree(inBlock); - DbgFree(outBlock); - return TRUE; - - } // End of if fileptr - - return FALSE; -} - - -Bool CompressFile (char *infile, char *outfile) -{ - UnsignedInt rawSize = 0; - UnsignedInt compressedSize = 0, compressed = 0, i = 0; - FILE *inFilePtr = NULL; - FILE *outFilePtr= NULL; - char *inBlock = NULL; - char *outBlock = NULL; - LZHL_CHANDLE compressor; - UnsignedInt blocklen; - - // Parameter checking - - if (( infile == NULL ) || ( outfile == NULL )) - return FALSE; - - // Allocate the appropriate amount of memory - inFilePtr = fopen( infile, "rb" ); - if ( inFilePtr ) - { - // Get size of file. - fseek( inFilePtr, 0, SEEK_END ); - rawSize = ftell( inFilePtr ); - fseek( inFilePtr, 0, SEEK_SET ); - - // This is ick, but allocate a BIIIIG chunk o' memory x 2 - inBlock = (char *) DbgMalloc(rawSize); - outBlock= (char *) DbgMalloc( LZHLCompressorCalcMaxBuf( rawSize )); - - if (( inBlock == NULL ) || ( outBlock == NULL )) - return FALSE; - - // Read in a big chunk o file - NoxRead(inBlock, 1, rawSize, inFilePtr); - - fclose(inFilePtr); - - // Compress - compressor = LZHLCreateCompressor(); - for ( i = 0; i < rawSize; i += BLOCKSIZE ) - { - blocklen = min((UnsignedInt)BLOCKSIZE, rawSize - i); - compressed = LZHLCompress(compressor, outBlock + compressedSize, inBlock + i, blocklen); - compressedSize += compressed; - } - - LZHLDestroyCompressor(compressor); - - outFilePtr = fopen(outfile, "wb"); - if (outFilePtr) - { - // write out the uncompressed size first. - fwrite(&rawSize, sizeof(UnsignedInt), 1, outFilePtr); - fwrite(outBlock, compressedSize, 1, outFilePtr); - fclose(outFilePtr); - } - else - return FALSE; - - // Clean up - DbgFree(inBlock); - DbgFree(outBlock); - return TRUE; - } - - return FALSE; -} - -Bool CompressPacket (char *inPacket, char *outPacket) -{ - // Parameter checking - - if (( inPacket == NULL ) || ( outPacket == NULL )) - return FALSE; - - return TRUE; -} - - -Bool DecompressPacket (char *inPacket, char *outPacket) -{ - // Parameter checking - - if (( inPacket == NULL ) || ( outPacket == NULL )) - return FALSE; - return TRUE; -} - - -UnsignedInt CalcNewSize (UnsignedInt rawSize) -{ - return LZHLCompressorCalcMaxBuf(rawSize); -} - -Bool DecompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& outSize) -{ - UnsignedByte *inBuffer = (UnsignedByte *)inBufferVoid; - UnsignedByte *outBuffer = (UnsignedByte *)outBufferVoid; - UnsignedInt rawSize = 0, compressedSize = 0; - LZHL_DHANDLE decompress; - Int ok = 0; - UnsignedInt srcSz, dstSz; - - // Parameter checking - - if (( inBuffer == NULL ) || ( outBuffer == NULL ) || ( inSize < 4 ) || ( outSize == 0 )) - return FALSE; - - // Get compressed size of file. - compressedSize = inSize; - - // Get uncompressed size. - rawSize = outSize; - - // Decompress - srcSz = compressedSize; - dstSz = rawSize; - - // Just Do it! - decompress = LZHLCreateDecompressor(); - - for (;;) - { - ok = LZHLDecompress( decompress, outBuffer + rawSize - dstSz, &dstSz, - inBuffer + compressedSize - srcSz, &srcSz); - - if ( !ok ) - break; - - if (srcSz <= 0) - break; - } - - LZHLDestroyDecompressor(decompress); - - outSize = rawSize; - - return TRUE; - -} - -Bool CompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& outSize) -{ - UnsignedByte *inBuffer = (UnsignedByte *)inBufferVoid; - UnsignedByte *outBuffer = (UnsignedByte *)outBufferVoid; - UnsignedInt rawSize = 0; - UnsignedInt compressedSize = 0, compressed = 0, i = 0; - LZHL_CHANDLE compressor; - UnsignedInt blocklen; - - // Parameter checking - - if (( inBuffer == NULL ) || ( outBuffer == NULL ) || ( inSize < 4 ) || ( outSize == 0 )) - return FALSE; - - rawSize = inSize; - - // Compress - compressor = LZHLCreateCompressor(); - for ( i = 0; i < rawSize; i += BLOCKSIZE ) - { - blocklen = min((UnsignedInt)BLOCKSIZE, rawSize - i); - compressed = LZHLCompress(compressor, outBuffer + compressedSize, inBuffer + i, blocklen); - compressedSize += compressed; - } - - LZHLDestroyCompressor(compressor); - - outSize = compressedSize; - - return TRUE; -} diff --git a/Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.h b/Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.h deleted file mode 100644 index e1b520b3ed2..00000000000 --- a/Generals/Code/Libraries/Source/Compression/LZHCompress/NoxCompress.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// compress.h -// Compress/Decompression header. -// Author: Jeff Brown, January 1999 - - -#ifndef __compress_h -#define __compress_h - -#define MAP_EXTENSION ".map" -#define LZH_EXTENSION ".nxz" -#define RUL_EXTENSION ".rul" - -Bool DecompressFile (char *infile, char *outfile); -Bool CompressFile (char *infile, char *outfile); -Bool CompressPacket (char *inPacket, char *outPacket); -Bool DecompressPacket (char *inPacket, char *outPacket); -UnsignedInt CalcNewSize (UnsignedInt rawSize); - -Bool DecompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& outSize); -Bool CompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& outSize); - -#endif // __compress_h \ No newline at end of file diff --git a/Generals/Code/Main/CMakeLists.txt b/Generals/Code/Main/CMakeLists.txt index 27a507a32a4..e2a6294fe38 100644 --- a/Generals/Code/Main/CMakeLists.txt +++ b/Generals/Code/Main/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries(g_generals PRIVATE dxguid g_gameengine g_gameenginedevice - gi_libraries_include + gi_always imm32 milesstub safedisc diff --git a/Generals/Code/Tools/Compress/CMakeLists.txt b/Generals/Code/Tools/Compress/CMakeLists.txt index daeb5a85de7..37cd8abf531 100644 --- a/Generals/Code/Tools/Compress/CMakeLists.txt +++ b/Generals/Code/Tools/Compress/CMakeLists.txt @@ -8,9 +8,9 @@ set_target_properties(g_compress PROPERTIES OUTPUT_NAME compress) target_sources(g_compress PRIVATE ${COMRPESS_SRC}) target_link_libraries(g_compress PRIVATE - g_compression - gi_always + core_compression core_config + gi_always ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") diff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txt index 3c4cf70dd0f..a487b0f0247 100644 --- a/GeneralsMD/Code/CMakeLists.txt +++ b/GeneralsMD/Code/CMakeLists.txt @@ -24,8 +24,10 @@ target_include_directories(zi_libraries_source_wwvegas_wwmath INTERFACE "Librari target_include_directories(zi_libraries_source_wwvegas_wwsaveload INTERFACE "Libraries/Source/WWVegas/WWSaveLoad") target_include_directories(zi_main INTERFACE "Main") target_link_libraries(zi_always INTERFACE - zi_libraries_include core_utility + zi_libraries_include + # Must stay below so headers from game are included first + corei_libraries_include ) # Contains internal libraries diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index fbe326eb430..a7da3f3648c 100644 --- a/GeneralsMD/Code/GameEngine/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngine/CMakeLists.txt @@ -1176,7 +1176,7 @@ target_link_libraries(z_gameengine PUBLIC core_utility stlport core_browserdispatch - z_compression + core_compression z_wwvegas ) diff --git a/GeneralsMD/Code/Libraries/CMakeLists.txt b/GeneralsMD/Code/Libraries/CMakeLists.txt index 13c6c4a34e6..175b35d827e 100644 --- a/GeneralsMD/Code/Libraries/CMakeLists.txt +++ b/GeneralsMD/Code/Libraries/CMakeLists.txt @@ -6,5 +6,3 @@ add_subdirectory(Source/profile) # debugging library add_subdirectory(Source/debug) - -add_subdirectory(Source/Compression) diff --git a/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h b/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h index f982c71eba8..d48c7141157 100644 --- a/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h +++ b/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h @@ -32,115 +32,7 @@ #ifndef _BASE_TYPE_H_ #define _BASE_TYPE_H_ -#include -#include -// TheSuperHackers @compile feliwir 07/04/2025 Adds utility macros for cross-platform compatibility -#include - -/* -** Turn off some unneeded warnings. -** Within the windows headers themselves, Microsoft has disabled the warnings 4290, 4514, -** 4069, 4200, 4237, 4103, 4001, 4035, 4164. Makes you wonder, eh? -*/ - -// "unreferenced inline function has been removed" Yea, so what? -#pragma warning(disable : 4514) - -// Unreferenced local function removed. -#pragma warning(disable : 4505) - -// 'unreferenced formal parameter' -#pragma warning(disable : 4100) - -// 'identifier was truncated to '255' characters in the browser information': -// Tempates create LLLOOONNNGGG identifiers! -#pragma warning(disable : 4786) - -// 'function selected for automatic inline expansion'. Cool, but since we're treating -// warnings as errors, don't warn me about this! -#pragma warning(disable : 4711) - -#if 0 -// 'assignment within condition expression'. actually a pretty useful warning, -// but way too much existing code violates it. -//#pragma warning(disable : 4706) -#else -// actually, it turned out not to be too bad, so this is now ENABLED. (srj) -#pragma warning(error : 4706) -#endif - -// 'conditional expression is constant'. used lots in debug builds. -#pragma warning(disable : 4127) - -// 'nonstandard extension used : nameless struct/union'. MS headers violate this... -#pragma warning(disable : 4201) - -// 'unreachable code'. STL violates this... -#pragma warning(disable : 4702) - -// 'local variable is initialized but not referenced'. good thing to know about... -#pragma warning(error : 4189) - -// 'unreferenced local variable'. good thing to know about... -#pragma warning(error : 4101) - -#ifndef PI -#define PI 3.14159265359f -#define TWO_PI 6.28318530718f -#endif - -#ifndef NULL -//#define NULL ((void *)0) -#define NULL 0 // C++ doesn't like casting void *'s into other pointers -#endif - -// MSVC math.h defines overloaded functions with this name... -//#ifndef abs -//#define abs(x) (((x) < 0) ? -(x) : (x)) -//#endif - -#ifndef min -#define min(x,y) (((x)<(y)) ? (x) : (y)) -#endif - -#ifndef max -#define max(x,y) (((x)>(y)) ? (x) : (y)) -#endif - -#ifndef TRUE -#define TRUE true -#endif - -#ifndef FALSE -#define FALSE false -#endif - -// Elements in an array -#ifndef ELEMENTS_OF -#define ELEMENTS_OF( x ) ( sizeof( x ) / sizeof( x[0] ) ) -#endif - -//-------------------------------------------------------------------- -// Fundamental type definitions -//-------------------------------------------------------------------- -typedef float Real; // 4 bytes -typedef int Int; // 4 bytes -typedef unsigned int UnsignedInt; // 4 bytes -typedef unsigned short UnsignedShort; // 2 bytes -typedef short Short; // 2 bytes -typedef unsigned char UnsignedByte; // 1 byte USED TO BE "Byte" -typedef char Byte; // 1 byte USED TO BE "SignedByte" -typedef char Char; // 1 byte of text -typedef bool Bool; // -// note, the types below should use "long long", but MSVC doesn't support it yet -#ifdef _MSC_VER -typedef __int64 Int64; // 8 bytes -typedef unsigned __int64 UnsignedInt64; // 8 bytes -#else -typedef long long Int64; // 8 bytes -typedef unsigned long long UnsignedInt64; // 8 bytes -#endif - +#include "Lib/BaseTypeCore.h" #include "Lib/trig.h" //----------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/Tools/Compress/CMakeLists.txt b/GeneralsMD/Code/Tools/Compress/CMakeLists.txt index 7b20ca186df..098b5e827a3 100644 --- a/GeneralsMD/Code/Tools/Compress/CMakeLists.txt +++ b/GeneralsMD/Code/Tools/Compress/CMakeLists.txt @@ -9,7 +9,7 @@ target_sources(z_compress PRIVATE ${COMRPESS_SRC}) target_link_libraries(z_compress PRIVATE core_config - z_compression + core_compression zi_always ) From d8499d3b4ec4c992a13f3d4188ed11f81a8efd80 Mon Sep 17 00:00:00 2001 From: Stephan Vedder Date: Fri, 11 Apr 2025 11:43:48 +0200 Subject: [PATCH 2/2] [CMAKE][CORE] Move compress tool to core --- Core/CMakeLists.txt | 2 +- Core/Tools/CMakeLists.txt | 11 ++ Core/Tools/Compress/CMakeLists.txt | 21 +++ .../Code => Core}/Tools/Compress/Compress.cpp | 2 +- Generals/Code/Tools/CMakeLists.txt | 1 - Generals/Code/Tools/Compress/CMakeLists.txt | 21 --- Generals/Code/Tools/Compress/Compress.cpp | 137 ------------------ GeneralsMD/Code/Tools/CMakeLists.txt | 1 - GeneralsMD/Code/Tools/Compress/CMakeLists.txt | 21 --- 9 files changed, 34 insertions(+), 183 deletions(-) create mode 100644 Core/Tools/CMakeLists.txt create mode 100644 Core/Tools/Compress/CMakeLists.txt rename {GeneralsMD/Code => Core}/Tools/Compress/Compress.cpp (99%) delete mode 100644 Generals/Code/Tools/Compress/CMakeLists.txt delete mode 100644 Generals/Code/Tools/Compress/Compress.cpp delete mode 100644 GeneralsMD/Code/Tools/Compress/CMakeLists.txt diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index a89c07e8c62..616d80d7ccc 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -22,5 +22,5 @@ add_subdirectory(Libraries) # add_subdirectory(GameEngineDevice) if (RTS_BUILD_CORE_TOOLS OR RTS_BUILD_CORE_EXTRAS) - # add_subdirectory(Tools) + add_subdirectory(Tools) endif() \ No newline at end of file diff --git a/Core/Tools/CMakeLists.txt b/Core/Tools/CMakeLists.txt new file mode 100644 index 00000000000..cb47b91e401 --- /dev/null +++ b/Core/Tools/CMakeLists.txt @@ -0,0 +1,11 @@ +# Build tools + +# Build useful tool binaries. +if(RTS_BUILD_CORE_TOOLS) + # TODO: add subdirectory... +endif() + +# Build less useful tool/test binaries. +if(RTS_BUILD_CORE_EXTRAS) + add_subdirectory(Compress) +endif() diff --git a/Core/Tools/Compress/CMakeLists.txt b/Core/Tools/Compress/CMakeLists.txt new file mode 100644 index 00000000000..7c6b6c86e61 --- /dev/null +++ b/Core/Tools/Compress/CMakeLists.txt @@ -0,0 +1,21 @@ +set(COMRPESS_SRC + "Compress.cpp" +) + +add_executable(core_compress WIN32) +set_target_properties(core_compress PROPERTIES OUTPUT_NAME compress) + +target_sources(core_compress PRIVATE ${COMRPESS_SRC}) + +target_link_libraries(core_compress PRIVATE + core_config + core_compression + zi_always +) + +if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") + if(IS_VS6_BUILD) + target_compile_definitions(core_compress PRIVATE vsnprintf=_vsnprintf) + endif() + target_link_options(core_compress PRIVATE /subsystem:console) +endif() diff --git a/GeneralsMD/Code/Tools/Compress/Compress.cpp b/Core/Tools/Compress/Compress.cpp similarity index 99% rename from GeneralsMD/Code/Tools/Compress/Compress.cpp rename to Core/Tools/Compress/Compress.cpp index b770fd14cf8..7fcf1ccdd3f 100644 --- a/GeneralsMD/Code/Tools/Compress/Compress.cpp +++ b/Core/Tools/Compress/Compress.cpp @@ -18,7 +18,7 @@ #include #include -#include "Lib/BaseType.h" +#include "Lib/BaseTypeCore.h" #include "Compression.h" diff --git a/Generals/Code/Tools/CMakeLists.txt b/Generals/Code/Tools/CMakeLists.txt index 62635cf1dce..77983a2ec42 100644 --- a/Generals/Code/Tools/CMakeLists.txt +++ b/Generals/Code/Tools/CMakeLists.txt @@ -15,7 +15,6 @@ if(RTS_BUILD_GENERALS_EXTRAS) add_subdirectory(Autorun) add_subdirectory(Babylon) add_subdirectory(buildVersionUpdate) - add_subdirectory(Compress) add_subdirectory(CRCDiff) add_subdirectory(Launcher) add_subdirectory(mangler) diff --git a/Generals/Code/Tools/Compress/CMakeLists.txt b/Generals/Code/Tools/Compress/CMakeLists.txt deleted file mode 100644 index 37cd8abf531..00000000000 --- a/Generals/Code/Tools/Compress/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set(COMRPESS_SRC - "Compress.cpp" -) - -add_executable(g_compress WIN32) -set_target_properties(g_compress PROPERTIES OUTPUT_NAME compress) - -target_sources(g_compress PRIVATE ${COMRPESS_SRC}) - -target_link_libraries(g_compress PRIVATE - core_compression - core_config - gi_always -) - -if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - if(IS_VS6_BUILD) - target_compile_definitions(g_compress PRIVATE vsnprintf=_vsnprintf) - endif() - target_link_options(g_compress PRIVATE /subsystem:console) -endif() diff --git a/Generals/Code/Tools/Compress/Compress.cpp b/Generals/Code/Tools/Compress/Compress.cpp deleted file mode 100644 index 288f3fd2cbe..00000000000 --- a/Generals/Code/Tools/Compress/Compress.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include -#include -#include "Lib/BaseType.h" -#include "Compression.h" - - -// TheSuperHackers @todo Streamline and simplify the logging approach for tools -#define DEBUG_LOG(x) printf x - - -void dumpHelp(const char *exe) -{ - DEBUG_LOG(("Usage:\n To print the compression type of an existing file: %s -in infile\n", exe)); - DEBUG_LOG((" To compress a file: %s -in infile -out outfile <-type compressionmode>\n\n", exe)); - DEBUG_LOG(("Compression modes:\n")); - for (int i=COMPRESSION_MIN; i<=COMPRESSION_MAX; ++i) - { - DEBUG_LOG((" %s\n", CompressionManager::getCompressionNameByType((CompressionType)i))); - } -} - -void main(int argc, char **argv) -{ - std::string inFile = ""; - std::string outFile = ""; - CompressionType compressType = CompressionManager::getPreferredCompression(); - - for (int i=1; i