Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,157 @@
# Microsoft Developer Studio Project File - Name="CMP" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=CMP - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Cmp.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Cmp.mak" CFG="CMP - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "CMP - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "CMP - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "CMP - Win32 Retail" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/CMP", PECAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
!IF "$(CFG)" == "CMP - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "x:\cpa\lib"
# PROP Intermediate_Dir "Tmp\Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G5 /W4 /WX /GX /O2 /I "x:\Cpa\Public" /I "x:\Cpa\Public\Cmp" /I "x:\CPA\TempGrp\CMP" /D "NDEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /FD /c
# SUBTRACT CPP /Fr /YX
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"x:\cpa\lib\CMPP5_vr.lib"
!ELSEIF "$(CFG)" == "CMP - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "x:\cpa\lib"
# PROP Intermediate_Dir "Tmp\Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G5 /MD /W4 /WX /GX /Z7 /Od /I "x:\Cpa\Public" /I "x:\Cpa\Public\Cmp" /I "x:\CPA\TempGrp\CMP" /D "_DEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /FD /c
# SUBTRACT CPP /Fr /YX
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"x:\cpa\lib\CMPP5_vd.lib"
!ELSEIF "$(CFG)" == "CMP - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "CMP___Wi"
# PROP BASE Intermediate_Dir "CMP___Wi"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "x:\cpa\lib"
# PROP Intermediate_Dir "tmp\retail"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /W4 /WX /GX /O2 /I "x:\Cpa\Public" /I "x:\Cpa\Public\Cmp" /I "x:\CPA\TempGrp\CMP" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "VISUAL" /FD /c
# SUBTRACT BASE CPP /Fr /YX
# ADD CPP /nologo /G5 /W4 /WX /GX /O2 /I "x:\Cpa\Public" /I "x:\Cpa\Public\Cmp" /I "x:\CPA\TempGrp\CMP" /D "NDEBUG" /D "VISUAL" /D "WIN32" /D "RETAIL" /FD /c
# SUBTRACT CPP /Fr /YX
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"x:\cpa\lib\CMPP5_vr.lib"
# ADD LIB32 /nologo /out:"x:\cpa\lib\CMPP5_vf.lib"
!ENDIF
# Begin Target
# Name "CMP - Win32 Release"
# Name "CMP - Win32 Debug"
# Name "CMP - Win32 Retail"
# Begin Group "Sources"
# PROP Default_Filter ".c"
# Begin Source File
SOURCE=.\PC\CMP_DIFF.c
# End Source File
# Begin Source File
SOURCE=.\PC\CMP_File.c
# End Source File
# Begin Source File
SOURCE=.\PC\CMP_LZSS.c
# End Source File
# Begin Source File
SOURCE=.\PC\CMP_Main.c
# End Source File
# End Group
# Begin Group "Includes"
# PROP Default_Filter ".h"
# Begin Source File
SOURCE=..\..\Public\CMP.h
# End Source File
# Begin Source File
SOURCE=.\PC\CMP_DIFF.h
# End Source File
# Begin Source File
SOURCE=.\PC\CMP_File.h
# End Source File
# Begin Source File
SOURCE=.\PC\CMP_LZSS.h
# End Source File
# Begin Source File
SOURCE=..\..\Public\CMP\CMP_Pub.h
# End Source File
# Begin Source File
SOURCE=.\Cmp_Ver.h
# End Source File
# Begin Source File
SOURCE=.\ErmCmp.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,311 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="CMP"
ProjectGUID="{943DE6C4-2627-4699-A05B-14A7DB6E7D72}"
SccProjectName="&quot;$/cpa/tempgrp/CMP&quot;, PECAAAAA"
SccAuxPath=""
SccLocalPath="."
SccProvider="MSSCCI:NXN alienbrain">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="x:\cpa\lib"
IntermediateDirectory=".\Tmp\Release"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OptimizeForProcessor="1"
AdditionalIncludeDirectories="x:\Cpa\Public,x:\Cpa\Public\Cmp,x:\CPA\TempGrp\CMP"
PreprocessorDefinitions="NDEBUG;VISUAL;WIN32;USE_PROFILER"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\Tmp\Release/CMP.pch"
AssemblerListingLocation=".\Tmp\Release/"
ObjectFile=".\Tmp\Release/"
ProgramDataBaseFileName=".\Tmp\Release/"
WarningLevel="4"
WarnAsError="TRUE"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="x:\cpa\lib\CMPP5_vr.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Retail|Win32"
OutputDirectory="x:\cpa\lib"
IntermediateDirectory=".\tmp\retail"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OptimizeForProcessor="1"
AdditionalIncludeDirectories="x:\Cpa\Public,x:\Cpa\Public\Cmp,x:\CPA\TempGrp\CMP"
PreprocessorDefinitions="NDEBUG;VISUAL;WIN32;RETAIL"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\tmp\retail/CMP.pch"
AssemblerListingLocation=".\tmp\retail/"
ObjectFile=".\tmp\retail/"
ProgramDataBaseFileName=".\tmp\retail/"
WarningLevel="4"
WarnAsError="TRUE"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="x:\cpa\lib\CMPP5_vf.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory="x:\cpa\libd"
IntermediateDirectory=".\Tmp\Debug"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
OptimizeForProcessor="1"
AdditionalIncludeDirectories="x:\Cpa\Public,x:\Cpa\Public\Cmp,x:\CPA\TempGrp\CMP"
PreprocessorDefinitions="_DEBUG;VISUAL;WIN32;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\Tmp\Debug/CMP.pch"
AssemblerListingLocation=".\Tmp\Debug/"
ObjectFile=".\Tmp\Debug/"
ProgramDataBaseFileName=".\Tmp\Debug/"
WarningLevel="4"
WarnAsError="TRUE"
SuppressStartupBanner="TRUE"
DebugInformationFormat="1"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="x:\cpa\libD\CMPP5_vd.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Sources"
Filter=".c">
<File
RelativePath="PC\CMP_DIFF.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="PC\CMP_File.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="PC\CMP_LZSS.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="PC\CMP_Main.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Includes"
Filter=".h">
<File
RelativePath="..\..\Public\CMP.h">
</File>
<File
RelativePath="PC\CMP_DIFF.h">
</File>
<File
RelativePath="PC\CMP_File.h">
</File>
<File
RelativePath="PC\CMP_LZSS.h">
</File>
<File
RelativePath="..\..\Public\CMP\CMP_Pub.h">
</File>
<File
RelativePath="Cmp_Ver.h">
</File>
<File
RelativePath="ErmCmp.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,35 @@
#if !defined(__CMP_CPA_H__)
#define __CMP_CPA_H__
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
/****************************************
* Here is the list of disabled WARNING *
****************************************/
#if defined(VISUAL)
#pragma warning(disable:4010) /** single-line comment contains line-continuation character **/
#pragma warning(disable:4032) /** formal parameter 1 has different type when promoted **/
#pragma warning(disable:4100) /** unreferenced formal parameter **/
#pragma warning(disable:4115) /** named type definition in parentheses **/
#pragma warning(disable:4127) /** conditional expression is constant **/
#pragma warning(disable:4201) /** nonstandard extension used : nameless struct/union **/
#pragma warning(disable:4214) /** nonstandard extension used : bit field types other than int **/
#pragma warning(disable:4310) /** cast truncates constant value **/
#pragma warning(disable:4514) /** unreferenced inline function has been removed **/
#pragma warning(disable:4702) /** unreachable code **/
#pragma warning(disable:4711) /** selected for automatic inline expansion **/
#endif /* VISUAL */
#define HieFriend
#include "ACP_Base.h"
#include "CPA_Expt.h"
#include "CPA_Std.h"
#include "MMG.h"
#include "ERM.h"
#endif /* __CMP_CPA_H__ */

View File

@@ -0,0 +1,5 @@
#if !defined(__CMP_Def_h__)
#define __CMP_Def_h__
#endif /* __CMP_Def_h__ */

View File

@@ -0,0 +1,9 @@
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
#define C_szCMPVersion "CMP V5.0.0" /* The format is XXX Va.b.c with Xxx is the Tag of the module */
#define C_szCMPFullName "Compress and expand" /* the complete and clear name of the module */
#define C_szCMPDate "Aug 06 1997" /* The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/

View File

@@ -0,0 +1,155 @@
#if !defined(__ErmCMP_h__)
#define __ErmCMP_h__
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
#include "CMP_Ver.h"
/***************************************/
/**** Error macros (using ACPerror) ****/
/***************************************/
#define M_CMPFatalError(ErrorNum) \
{ \
if (ErrorNum>E_uwCMPFatalErr&&ErrorNum<E_uwCMPStartOfWarning) \
{ \
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
Erm_M_UpdateLastError(CMP,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
} \
else \
{ \
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
Erm_M_UpdateLastError(CMP,C_ucErmDefaultChannel,E_uwCMPFatalErrorNotAFatalError,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
} \
}
#define M_CMPInformationError(ErrorNum) \
{ \
if (ErrorNum>E_uwCMPStartOfInformationWarning&&ErrorNum<E_uwCMPErrNumber) \
{ \
Erm_M_UpdateLastError(CMP,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,C_ucErmNoOpenInfoWindow,C_ucNeverStopForDebug, NULL);\
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
} \
else \
{ \
M_CMPFatalError(E_uwCMPInformationErrorIsNotAInformationError); \
} \
}
#define M_CMPWarningError(ErrorNum) \
{ \
if (ErrorNum>E_uwCMPStartOfWarning&&ErrorNum<E_uwCMPStartOfInformationWarning) \
{ \
Erm_M_UpdateLastError(CMP,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
} \
else \
{ \
M_CMPFatalError(E_uwCMPWarningErrorIsNotAWarningError); \
} \
}
#define __FATAL_ERR_INPUT__
#define __INFORMATION_ERR_INPUT__ /**** Treat as a level 1 warning ****/
#define __WARNING_ERR_INPUT__ /**** Treat as a level 2 warning ****/
enum e_uwCMPErrNumber
{
E_uwCMPFatalErr,
#if defined(__FATAL_ERR_INPUT__)
/**** Error's errors ****/
E_uwCMPFatalErrorNotAFatalError,
E_uwCMPInformationErrorIsNotAInformationError,
E_uwCMPWarningErrorIsNotAWarningError,
E_uwCMPCloseFileError,
E_uwCMPOutputBitError,
E_uwCMPOutputBitsError,
E_uwCMPInputBitError,
E_uwCMPInputBitsError,
E_uwCMPCheckSum,
E_uwCMPFileCorrupted,
#endif /*__FATAL_ERR_INPUT__*/
E_uwCMPStartOfWarning,
#if defined(__WARNING_ERR_INPUT__)
#endif /*__WARNING_ERR_INPUT__*/
E_uwCMPStartOfInformationWarning,
#if defined(__INFORMATION_ERR_INPUT__)
#endif /*__INFORMATION_ERR_INPUT__*/
E_uwCMPErrNumber,
};
/*------------------*/
/* Global Variables*/
/*------------------*/
#undef EXTERN
#undef extern
#undef LOCAL
#if !defined(D_CMP_Input_VariableDefine)
#define EXTERN extern /*external declaration*/
#define LOCAL /*replace by nothing : we have to declare*/
#else /* D_CMP_Input_VariableDefine */
#define EXTERN /*replace by nothing : we have to declare*/
#define LOCAL /*replace by nothing : we have to declare*/
#endif /* D_CMP_Input_VariableDefine */
EXTERN unsigned char g_ucCMPModuleId /* number of identification of the Game module*/
#if defined(D_CMP_Input_VariableDefine)
= C_ucModuleNotInitialized
#endif /* D_CMP_Input_VariableDefine */
;
#if defined(__ERROR_STRINGS__)
EXTERN CPA_EXPORT char * g_a_szCMPInformationModule []
#if defined(D_CMP_Input_VariableDefine) && !defined(CPA_WANTS_IMPORT)
= {C_szCMPVersion, C_szCMPFullName, C_szCMPDate}
#endif /* D_CMP_Input_VariableDefine && CPA_WANTS_IMPORT */
;
EXTERN char * g_szCMPModuleName /* Obliged syntax 'sz'+[Abbreviation of ModuleName]+'ModuleName'*/
#if defined(D_CMP_Input_VariableDefine)
= {"CMP"}
#endif /* D_CMP_Input_VariableDefine */
;
EXTERN tdstErrorMsg g_a_stCMPTabErr[] /* Obliged syntax 'a_sz'+[Abbreviation of ModuleName]+'TabErr'*/
#if defined(D_CMP_Input_VariableDefine)
=
{
#if defined(__FATAL_ERR_INPUT__)
/**** Error's errors ****/
E_uwCMPFatalErrorNotAFatalError,"M_CMPFatalError : try to raise a warning or an information",
E_uwCMPInformationErrorIsNotAInformationError,"M_CMPInformationError : try to raise a fatal or a warning",
E_uwCMPWarningErrorIsNotAWarningError,"M_CMPWarningError : try to raise a fatal or a information",
E_uwCMPCloseFileError,"Can not close the file",
E_uwCMPOutputBitError,"fn_vOutputBit : Error",
E_uwCMPOutputBitsError,"fn_vOutputBits : Error",
E_uwCMPInputBitError,"fn_lInputBit : Error",
E_uwCMPInputBitsError,"fn_ulInputBit : Error",
E_uwCMPCheckSum,"Bad CheckSum",
E_uwCMPFileCorrupted,"File corrupted",
#endif /*__FATAL_ERR_INPUT__*/
#ifdef __WARNING_ERR_INPUT__
#endif /*__WARNING_ERR_INPUT__*/
#ifdef __INFORMATION_ERR_INPUT__
#endif /*__INFORMATION_ERR_INPUT__*/
0xffff,"\0"/*fin*/
}
#endif /* D_CMP_Input_VariableDefine */
;
#endif /* __ERROR_STRINGS__ */
#undef EXTERN
#undef extern
#endif /* !__ErmCMP_h__ */

View File

@@ -0,0 +1,375 @@
#include "CMP_Pub.h"
#if defined(D_CMP_DIFF)
#include <stdio.h>
#include "CMP_CPA.h"
#include "ErmCmp.h"
#include "CMP_File.h"
/**************************************************************************/
#define D_CMP_DIFF_CODED
/**************************************************************************/
#define C_CMP_DIFF_BLOCK_FACTOR 1
#define C_CMP_DIFF_BLOCK_SIZE (C_CMP_DIFF_BLOCK_FACTOR<<3)
#define C_CMP_DIFF_NB_BLOCKS 256
/**************************************************************************/
char *CMP_DIFF_g_szCompressionName = "Differential method";
char CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS+1][C_CMP_DIFF_BLOCK_SIZE];
unsigned char CMP_DIFF_g_ucfinish=0;
/**************************************************************************/
/*#define D_CMP_DIFF_CODE_DEBUG*/
#define C_CMP_DIFF_INIT_CODE 0x53
#define C_CMP_DIFF_INIT_CODE1 0xB9
#define C_CMP_DIFF_INIT_CODE2 ((unsigned long) C_CMP_DIFF_INIT_CODE * 0x01010101 + 0x01020304)
unsigned char CMP_DIFF_g_ucCode=C_CMP_DIFF_INIT_CODE;
unsigned char CMP_DIFF_g_ucCheckSum;
long CMP_DIFF_g_lNbCodedBytes=0;
long CMP_DIFF_g_lNbBytes=0;
#if defined(D_CMP_DIFF_CODED)
/**************************************************************************/
unsigned char CMP_DIFF_fn_ucSwapCode(unsigned char code)
{
unsigned char i,newcode=0;
for (i=0;i<8;i++)
{
newcode |= (((code >> i) & 0x1) <<(7-i));
}
return newcode;
}
/**************************************************************************/
unsigned char CMP_DIFF_fn_ucGetCheckSum(FILE *input)
{
unsigned char chksum;
fread(&chksum,sizeof(chksum),1,input);
chksum ^= C_CMP_DIFF_INIT_CODE;
#ifdef D_CMP_DIFF_CODE_DEBUG
printf("get checksum = %d\n",(int) chksum);
#endif
return chksum;
}
/**************************************************************************/
void CMP_DIFF_fn_vSetCheckSum(unsigned char chksum,FILE *output)
{
fseek(output,0L,SEEK_SET);
#ifdef D_CMP_DIFF_CODE_DEBUG
printf("set checksum = %d\n",(int) chksum);
#endif
chksum ^= C_CMP_DIFF_INIT_CODE;
fwrite(&chksum,sizeof(chksum),1,output);
}
/**************************************************************************/
long CMP_DIFF_fn_lGetSize(FILE *input)
{
long size;
fread(&size,sizeof(size),1,input);
size ^= C_CMP_DIFF_INIT_CODE2;
#ifdef D_CMP_DIFF_CODE_DEBUG
printf("get size = %ld\n",(long) size);
#endif
return size;
}
/**************************************************************************/
void CMP_DIFF_fn_vSetSize(long size,FILE *output)
{
#ifdef D_CMP_DIFF_CODE_DEBUG
printf("set size = %ld\n",(long) size);
#endif
size ^= C_CMP_DIFF_INIT_CODE2;
fwrite(&size,sizeof(size),1,output);
}
/**************************************************************************/
long CMP_DIFF_fn_lUncodedGetc(FILE *input)
{
long dummy;
if ((dummy=getc(input))!=EOF) CMP_DIFF_g_lNbBytes++;
return dummy;
}
/**************************************************************************/
long CMP_DIFF_fn_lCodedPutc(int c,FILE *output)
{
long dummy;
dummy = c ^ ((int) ( CMP_DIFF_fn_ucSwapCode(CMP_DIFF_g_ucCode++) ^ C_CMP_DIFF_INIT_CODE1 ));
CMP_DIFF_g_ucCheckSum = (unsigned char)(CMP_DIFF_g_ucCheckSum + (unsigned char)c);
CMP_DIFF_g_lNbCodedBytes++;
dummy = putc(dummy,output);
#ifdef D_CMP_DIFF_CODE_DEBUG
printf("line %04d org %03d coded written %03d checksum %03d\n",(int) CMP_DIFF_g_lNbCodedBytes,(int) c,(int) dummy,(int) CMP_DIFF_g_ucCheckSum);
#endif
return dummy;
}
/**************************************************************************/
long CMP_DIFF_fn_lCodedGetc(FILE *input)
{
int dummy;
int c;
if ((dummy=c=getc(input))!=EOF)
{
dummy = c ^ ((int) ( CMP_DIFF_fn_ucSwapCode(CMP_DIFF_g_ucCode++) ^ C_CMP_DIFF_INIT_CODE1 ));
CMP_DIFF_g_ucCheckSum = (unsigned char)(CMP_DIFF_g_ucCheckSum - (unsigned char)dummy);
CMP_DIFF_g_lNbCodedBytes++;
#ifdef D_CMP_DIFF_CODE_DEBUG
printf("line %04d read %03d decoded fin %03d checksum %03d\n",(int) CMP_DIFF_g_lNbCodedBytes,(int) c,(int) dummy,(int) CMP_DIFF_g_ucCheckSum);
#endif
}
return dummy;
}
/**************************************************************************/
long CMP_DIFF_fn_lUncodedPutc(int c,FILE *output)
{
CMP_DIFF_g_lNbBytes--;
if (CMP_DIFF_g_lNbBytes<0) CMP_DIFF_g_ucfinish=1;
return putc(c,output);
}
/**************************************************************************/
#else /* D_CMP_DIFF_CODED */
/**************************************************************************/
long CMP_DIFF_fn_lUncodedGetc(FILE *input)
{
return getc(input);
}
/**************************************************************************/
long CMP_DIFF_fn_lUncodedPutc(int c,FILE *output)
{
return putc(c,output);
}
/**************************************************************************/
long CMP_DIFF_fn_lCodedGetc(FILE *input)
{
return getc(input);
}
/**************************************************************************/
long CMP_DIFF_fn_lCodedPutc(int c,FILE *output)
{
return putc(c,output);
}
/**************************************************************************/
#endif /* D_CMP_DIFF_CODED */
/**************************************************************************/
void CMP_DIFF_fn_vInitBuffer()
{
int i,j;
for(i=0;i<C_CMP_DIFF_NB_BLOCKS;i++)
{
for (j=0;j<C_CMP_DIFF_BLOCK_SIZE;j++)
{
CMP_DIFF_g_aa_cBuffer[i][j]=(char)i;
}
}
CMP_DIFF_g_lNbCodedBytes=CMP_DIFF_g_lNbBytes=0;
CMP_DIFF_g_ucfinish=0;
CMP_DIFF_g_ucCode=C_CMP_DIFF_INIT_CODE + 4;
}
/**************************************************************************/
void CMP_DIFF_fn_vCompressFile( FILE *input, FILE *output )
{
int i,j,currentsize;
int bestblock = 0;
int bestcount,matchcount;
int changeindex = 0,bitvalue;
CMP_DIFF_fn_vInitBuffer();
#if defined(D_CMP_DIFF_CODED)
CMP_DIFF_fn_vSetCheckSum(CMP_DIFF_g_ucCheckSum=0,output);
CMP_DIFF_fn_vSetSize(CMP_DIFF_g_lNbBytes=0,output);
#endif
while(!CMP_DIFF_g_ucfinish)
{
currentsize=C_CMP_DIFF_BLOCK_SIZE;
for(j=0;j<C_CMP_DIFF_BLOCK_SIZE;j++)
{
i=CMP_DIFF_fn_lUncodedGetc(input);
if (i==EOF)
{
currentsize=j;
break;
}
CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j]=(char)i;
}
if (currentsize==0)
{
CMP_DIFF_g_ucfinish=1;
}
else
{
bestcount=-1;
for(i=0;i<C_CMP_DIFF_NB_BLOCKS;i++)
{
matchcount=0;
for(j=0;j<currentsize;j++)
{
if (CMP_DIFF_g_aa_cBuffer[i][j]==CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j])
{
matchcount++;
}
}
if (matchcount>bestcount)
{
bestcount=matchcount;
bestblock=i;
if (bestcount==currentsize)
break;
}
}
CMP_DIFF_fn_lCodedPutc(bestblock,output);
for (i=0;i<C_CMP_DIFF_BLOCK_FACTOR;i++)
{
changeindex=0;
bitvalue=1;
for (j=i*8;j<i*8+8;j++)
{
if (j>=currentsize)
break;
if (CMP_DIFF_g_aa_cBuffer[bestblock][j] != CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j])
{
changeindex += bitvalue;
}
bitvalue *= 2;
}
CMP_DIFF_fn_lCodedPutc(changeindex,output);
for (j=i*8;j<i*8+8;j++)
{
if (changeindex % 2 == 1)
{
CMP_DIFF_fn_lCodedPutc(CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j],output);
}
changeindex /= 2;
}
if (currentsize<C_CMP_DIFF_BLOCK_SIZE)
{
CMP_DIFF_fn_lCodedPutc(currentsize,output);
CMP_DIFF_g_ucfinish=1;
}
else
{
for(j=0;j<C_CMP_DIFF_BLOCK_SIZE;j++)
{
CMP_DIFF_g_aa_cBuffer[bestblock][j]=CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j];
}
}
}
}
}
#ifdef D_CMP_DIFF_CODED
CMP_DIFF_fn_vSetCheckSum(CMP_DIFF_g_ucCheckSum,output);
CMP_DIFF_fn_vSetSize(CMP_DIFF_g_lNbBytes,output);
#endif
}
/**************************************************************************/
void CMP_DIFF_fn_vExpandFile( FILE *input, FILE *output )
{
int i,j;
int bestblock=-1;
int changeindex = 0;
CMP_DIFF_fn_vInitBuffer();
#ifdef D_CMP_DIFF_CODED
CMP_DIFF_g_ucCheckSum=CMP_DIFF_fn_ucGetCheckSum(input);
CMP_DIFF_g_lNbBytes=CMP_DIFF_fn_lGetSize(input);
#endif
while (!CMP_DIFF_g_ucfinish)
{
if (bestblock==-1)
{
bestblock=CMP_DIFF_fn_lCodedGetc(input);
if (bestblock==EOF)
{
CMP_DIFF_g_ucfinish=1;
}
else
{
changeindex=CMP_DIFF_fn_lCodedGetc(input);
}
}
else
{
bestblock=CMP_DIFF_fn_lCodedGetc(input);
if (bestblock==EOF)
{
for(j=0;j<C_CMP_DIFF_BLOCK_SIZE;j++)
{
CMP_DIFF_fn_lUncodedPutc(CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j],output);
}
CMP_DIFF_g_ucfinish=1;
}
else
{
changeindex=CMP_DIFF_fn_lCodedGetc(input);
if (changeindex==EOF)
{
for(j=0;j<bestblock;j++)
{
CMP_DIFF_fn_lUncodedPutc(CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j],output);
}
CMP_DIFF_g_ucfinish=1;
}
else
{
for(j=0;j<C_CMP_DIFF_BLOCK_SIZE;j++)
{
CMP_DIFF_fn_lUncodedPutc(CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j],output);
}
}
}
}
if (!CMP_DIFF_g_ucfinish)
{
for (i=0;i<C_CMP_DIFF_BLOCK_FACTOR;i++)
{
if (i>0)
changeindex=CMP_DIFF_fn_lCodedGetc(input);
for(j=i*8;j<i*8+8;j++)
{
if (changeindex % 2 == 1)
{
CMP_DIFF_g_aa_cBuffer[bestblock][j]=(char)CMP_DIFF_fn_lCodedGetc(input);
}
CMP_DIFF_g_aa_cBuffer[C_CMP_DIFF_NB_BLOCKS][j]=CMP_DIFF_g_aa_cBuffer[bestblock][j];
changeindex /= 2;
}
}
}
}
#ifdef D_CMP_DIFF_CODED
if (CMP_DIFF_g_lNbBytes==0)
{
if (CMP_DIFF_g_ucCheckSum!=0)
M_CMPFatalError(E_uwCMPCheckSum);
}
else
{
M_CMPFatalError(E_uwCMPFileCorrupted);
}
#endif
}
/**************************************************************************/
#endif /* D_CMP_DIFF */

View File

@@ -0,0 +1,7 @@
#if!defined(__CMP_DIFF_H__)
#define __CMP_DIFF_H__
void CMP_DIFF_fn_vCompressFile( FILE *input , FILE *output );
void CMP_DIFF_fn_vExpandFile( FILE *input , FILE *output );
#endif /* __CMP_DIFF_H__ */

View File

@@ -0,0 +1,156 @@
#include <stdio.h>
#include <malloc.h>
#include "CMP_CPA.h"
#include "ErmCmp.h"
#include "CMP_File.h"
/**************************************************************************/
/*#define PACIFIER*/
#define PACIFIER_COUNT 2047
/**************************************************************************/
tdstBitFile *CMP_fn_p_stOpenOutputBitFile( char *name )
{
tdstBitFile *bit_file=NULL;
FILE *file=NULL;
if ((file = fopen( name, "wb" ))!=NULL)
{
bit_file = (tdstBitFile *) calloc( 1, sizeof( tdstBitFile ) );
if ( bit_file == NULL )
return( bit_file );
bit_file->file = file;
bit_file->rack = 0;
bit_file->mask = 0x80;
bit_file->pacifier_counter = 0;
}
return( bit_file );
}
/**************************************************************************/
tdstBitFile *CMP_fn_p_stOpenInputBitFile( char *name )
{
tdstBitFile *bit_file=NULL;
FILE *file=NULL;
if ((file = fopen( name, "rb" ))!=NULL)
{
bit_file = (tdstBitFile *) calloc( 1, sizeof( tdstBitFile ) );
if ( bit_file == NULL )
return( bit_file );
bit_file->file = file;
bit_file->rack = 0;
bit_file->mask = 0x80;
bit_file->pacifier_counter = 0;
}
return( bit_file );
}
/**************************************************************************/
void CMP_fn_vCloseOutputBitFile( tdstBitFile *bit_file )
{
if ( bit_file->mask != 0x80 )
if ( putc( bit_file->rack, bit_file->file ) != bit_file->rack )
M_CMPFatalError(E_uwCMPCloseFileError);
fclose( bit_file->file );
free( (char *) bit_file );
}
/**************************************************************************/
void CMP_fn_vCloseInputBitFile( tdstBitFile *bit_file )
{
fclose( bit_file->file );
free( (char *) bit_file );
}
/**************************************************************************/
void CMP_fn_vOutputBit( tdstBitFile *bit_file , int bit )
{
if ( bit )
bit_file->rack |= bit_file->mask;
bit_file->mask >>= 1;
if ( bit_file->mask == 0 )
{
if ( putc( bit_file->rack, bit_file->file ) != bit_file->rack )
M_CMPFatalError(E_uwCMPOutputBitError);
#ifdef PACIFIER
else if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
putc( '.', stdout );
#endif /* PACIFIER */
bit_file->rack = 0;
bit_file->mask = 0x80;
}
}
/**************************************************************************/
void CMP_fn_vOutputBits( tdstBitFile *bit_file , unsigned long code , int count )
{
unsigned long mask;
mask = 1L << ( count - 1 );
while ( mask != 0)
{
if ( mask & code )
bit_file->rack |= bit_file->mask;
bit_file->mask >>= 1;
if ( bit_file->mask == 0 )
{
if ( putc( bit_file->rack, bit_file->file ) != bit_file->rack )
M_CMPFatalError(E_uwCMPOutputBitsError);
#ifdef PACIFIER
else if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
putc( '.', stdout );
#endif
bit_file->rack = 0;
bit_file->mask = 0x80;
}
mask >>= 1;
}
}
/**************************************************************************/
long CMP_fn_lInputBit( tdstBitFile *bit_file )
{
long value;
if ( bit_file->mask == 0x80 )
{
bit_file->rack = getc( bit_file->file );
if ( bit_file->rack == EOF )
M_CMPFatalError(E_uwCMPInputBitError);
#ifdef PACIFIER
if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
putc( '.', stdout );
#endif
}
value = bit_file->rack & bit_file->mask;
bit_file->mask >>= 1;
if ( bit_file->mask == 0 )
bit_file->mask = 0x80;
return( value ? 1 : 0 );
}
/**************************************************************************/
unsigned long CMP_fn_ulInputBits( tdstBitFile *bit_file , int bit_count )
{
unsigned long mask;
unsigned long return_value;
mask = 1L << ( bit_count - 1 );
return_value = 0;
while ( mask != 0)
{
if ( bit_file->mask == 0x80 )
{
bit_file->rack = getc( bit_file->file );
if ( bit_file->rack == EOF )
M_CMPFatalError(E_uwCMPInputBitsError);
#ifdef PACIFIER
if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
putc( '.', stdout );
#endif
}
if ( bit_file->rack & bit_file->mask )
return_value |= mask;
mask >>= 1;
bit_file->mask >>= 1;
if ( bit_file->mask == 0 ) bit_file->mask = 0x80;
}
return( return_value );
}
/**************************************************************************/

View File

@@ -0,0 +1,26 @@
#if !defined(__CMP_File_h__)
#define __CMP_File_h__
#define M_p_stOpenInput(x) fopen((x),"rb")
#define M_p_stOpenOutput(x) fopen((x),"wb")
#define M_vCloseInput(x) fclose((x))
#define M_vCloseOutput(x) fclose((x))
typedef struct tdstBitFile_
{
FILE *file;
unsigned char mask;
int rack;
int pacifier_counter;
} tdstBitFile;
tdstBitFile *CMP_fn_p_stOpenInputBitFile( char *name );
tdstBitFile *CMP_fn_p_stOpenOutputBitFile( char *name );
void CMP_fn_vCloseInputBitFile( tdstBitFile *bit_file );
void CMP_fn_vCloseOutputBitFile( tdstBitFile *bit_file );
void CMP_fn_vOutputBit( tdstBitFile *bit_file , int bit );
void CMP_fn_vOutputBits( tdstBitFile *bit_file , unsigned long code , int count );
long CMP_fn_lInputBit( tdstBitFile *bit_file );
unsigned long CMP_fn_ulInputBits( tdstBitFile *bit_file , int bit_count );
#endif /* __CMP_File_h__ */

View File

@@ -0,0 +1,250 @@
#include "CMP_Pub.h"
#if defined(D_CMP_LZSS)
#include <stdio.h>
#include "CMP_CPA.h"
#include "ErmCmp.h"
#include "CMP_File.h"
/**************************************************************************/
#define C_CMP_LZSS_INDEX_BIT_COUNT 12
#define C_CMP_LZSS_LENGTH_BIT_COUNT 4
#define C_CMP_LZSS_WINDOW_SIZE ( 1 << C_CMP_LZSS_INDEX_BIT_COUNT )
#define C_CMP_LZSS_RAW_LOOK_AHEAD_SIZE ( 1 << C_CMP_LZSS_LENGTH_BIT_COUNT )
#define C_CMP_LZSS_BREAK_EVEN ( ( 1 + C_CMP_LZSS_INDEX_BIT_COUNT + C_CMP_LZSS_LENGTH_BIT_COUNT ) / 9 )
#define C_CMP_LZSS_LOOK_AHEAD_SIZE ( C_CMP_LZSS_RAW_LOOK_AHEAD_SIZE + C_CMP_LZSS_BREAK_EVEN )
#define C_CMP_LZSS_TREE_ROOT C_CMP_LZSS_WINDOW_SIZE
#define C_CMP_LZSS_END_OF_STREAM 0
#define C_CMP_LZSS_UNUSED 0
/**************************************************************************/
#define M_CMP_LZSS_MOD_WINDOW( a ) ( ( a ) & ( C_CMP_LZSS_WINDOW_SIZE - 1 ) )
/**************************************************************************/
unsigned char CMP_LZSS_g_a_ucWindow[C_CMP_LZSS_WINDOW_SIZE];
struct
{
int parent;
int smaller_child;
int larger_child;
} CMP_LZSS_g_a_stTree[C_CMP_LZSS_WINDOW_SIZE + 1 ];
char *CMP_LZSS_CompressionName = "LZSS method";
/**************************************************************************/
void CMP_LZSS_InitTree( int r );
void CMP_LZSS_ContractNode( int old_node, int new_node );
void CMP_LZSS_ReplaceNode( int old_node, int new_node );
int CMP_LZSS_FindNextNode( int node );
void CMP_LZSS_DeleteString( int p );
int CMP_LZSS_AddString( int new_node, int *match_position );
/**************************************************************************/
void CMP_LZSS_fn_vInitTree( int r )
{
CMP_LZSS_g_a_stTree[ C_CMP_LZSS_TREE_ROOT ].larger_child = r;
CMP_LZSS_g_a_stTree[ r ].parent = C_CMP_LZSS_TREE_ROOT;
CMP_LZSS_g_a_stTree[ r ].larger_child = C_CMP_LZSS_UNUSED;
CMP_LZSS_g_a_stTree[ r ].smaller_child = C_CMP_LZSS_UNUSED;
}
/**************************************************************************/
void CMP_LZSS_fn_vContractNode( int old_node , int new_node )
{
CMP_LZSS_g_a_stTree[ new_node ].parent = CMP_LZSS_g_a_stTree[ old_node ].parent;
if ( CMP_LZSS_g_a_stTree[ CMP_LZSS_g_a_stTree[ old_node ].parent ].larger_child == old_node )
CMP_LZSS_g_a_stTree[ CMP_LZSS_g_a_stTree[ old_node ].parent ].larger_child = new_node;
else
CMP_LZSS_g_a_stTree[ CMP_LZSS_g_a_stTree[ old_node ].parent ].smaller_child = new_node;
CMP_LZSS_g_a_stTree[ old_node ].parent = C_CMP_LZSS_UNUSED;
}
/**************************************************************************/
void CMP_LZSS_fn_vReplaceNode( int old_node , int new_node )
{
int parent;
parent = CMP_LZSS_g_a_stTree[ old_node ].parent;
if ( CMP_LZSS_g_a_stTree[ parent ].smaller_child == old_node )
CMP_LZSS_g_a_stTree[ parent ].smaller_child = new_node;
else
CMP_LZSS_g_a_stTree[ parent ].larger_child = new_node;
CMP_LZSS_g_a_stTree[ new_node ] = CMP_LZSS_g_a_stTree[ old_node ];
CMP_LZSS_g_a_stTree[ CMP_LZSS_g_a_stTree[ new_node ].smaller_child ].parent = new_node;
CMP_LZSS_g_a_stTree[ CMP_LZSS_g_a_stTree[ new_node ].larger_child ].parent = new_node;
CMP_LZSS_g_a_stTree[ old_node ].parent = C_CMP_LZSS_UNUSED;
}
/**************************************************************************/
int CMP_LZSS_fn_vFindNextNode( int node )
{
int next;
next = CMP_LZSS_g_a_stTree[ node ].smaller_child;
while ( CMP_LZSS_g_a_stTree[ next ].larger_child != C_CMP_LZSS_UNUSED )
next = CMP_LZSS_g_a_stTree[ next ].larger_child;
return( next );
}
/**************************************************************************/
void CMP_LZSS_fn_vDeleteString( int p )
{
int replacement;
if ( CMP_LZSS_g_a_stTree[ p ].parent == C_CMP_LZSS_UNUSED )
return;
if ( CMP_LZSS_g_a_stTree[ p ].larger_child == C_CMP_LZSS_UNUSED )
CMP_LZSS_fn_vContractNode( p, CMP_LZSS_g_a_stTree[ p ].smaller_child );
else if ( CMP_LZSS_g_a_stTree[ p ].smaller_child == C_CMP_LZSS_UNUSED )
CMP_LZSS_fn_vContractNode( p, CMP_LZSS_g_a_stTree[ p ].larger_child );
else
{
replacement = CMP_LZSS_fn_vFindNextNode( p );
CMP_LZSS_fn_vDeleteString( replacement );
CMP_LZSS_fn_vReplaceNode( p, replacement );
}
}
/**************************************************************************/
int CMP_LZSS_fn_vAddString( int new_node , int *match_position )
{
int i;
int test_node;
int delta = 0;
int match_length;
int *child;
if ( new_node == C_CMP_LZSS_END_OF_STREAM )
return( 0 );
test_node = CMP_LZSS_g_a_stTree[ C_CMP_LZSS_TREE_ROOT ].larger_child;
match_length = 0;
for ( ; ; )
{
for ( i = 0 ; i < C_CMP_LZSS_LOOK_AHEAD_SIZE ; i++ )
{
delta = CMP_LZSS_g_a_ucWindow[ M_CMP_LZSS_MOD_WINDOW( new_node + i ) ] - CMP_LZSS_g_a_ucWindow[ M_CMP_LZSS_MOD_WINDOW( test_node + i ) ];
if ( delta != 0 )
break;
}
if ( i >= match_length )
{
match_length = i;
*match_position = test_node;
if ( match_length >= C_CMP_LZSS_LOOK_AHEAD_SIZE )
{
CMP_LZSS_fn_vReplaceNode( test_node, new_node );
return( match_length );
}
}
if ( delta >= 0 )
child = &CMP_LZSS_g_a_stTree[ test_node ].larger_child;
else
child = &CMP_LZSS_g_a_stTree[ test_node ].smaller_child;
if ( *child == C_CMP_LZSS_UNUSED )
{
*child = new_node;
CMP_LZSS_g_a_stTree[ new_node ].parent = test_node;
CMP_LZSS_g_a_stTree[ new_node ].larger_child = C_CMP_LZSS_UNUSED;
CMP_LZSS_g_a_stTree[ new_node ].smaller_child = C_CMP_LZSS_UNUSED;
return( match_length );
}
test_node = *child;
}
}
/**************************************************************************/
void CMP_LZSS_fn_vCompressFile( FILE *input , tdstBitFile *output )
{
int i;
int c;
int look_ahead_bytes;
int current_position;
int replace_count;
int match_length;
int match_position;
current_position = 1;
for ( i = 0 ; i < C_CMP_LZSS_LOOK_AHEAD_SIZE ; i++ )
{
if ( ( c = getc( input ) ) == EOF )
break;
CMP_LZSS_g_a_ucWindow[ current_position + i ] = (unsigned char) c;
}
look_ahead_bytes = i;
CMP_LZSS_fn_vInitTree( current_position );
match_length = 0;
match_position = 0;
while ( look_ahead_bytes > 0 )
{
if ( match_length > look_ahead_bytes )
match_length = look_ahead_bytes;
if ( match_length <= C_CMP_LZSS_BREAK_EVEN )
{
replace_count = 1;
CMP_fn_vOutputBit( output, 1 );
CMP_fn_vOutputBits( output,
(unsigned long) CMP_LZSS_g_a_ucWindow[ current_position ], 8 );
}
else
{
CMP_fn_vOutputBit( output, 0 );
CMP_fn_vOutputBits( output,
(unsigned long) match_position, C_CMP_LZSS_INDEX_BIT_COUNT );
CMP_fn_vOutputBits( output,
(unsigned long) ( match_length - ( C_CMP_LZSS_BREAK_EVEN + 1 ) ),
C_CMP_LZSS_LENGTH_BIT_COUNT );
replace_count = match_length;
}
for ( i = 0 ; i < replace_count ; i++ )
{
CMP_LZSS_fn_vDeleteString( M_CMP_LZSS_MOD_WINDOW( current_position + C_CMP_LZSS_LOOK_AHEAD_SIZE ) );
if ( ( c = getc( input ) ) == EOF )
look_ahead_bytes--;
else
CMP_LZSS_g_a_ucWindow[ M_CMP_LZSS_MOD_WINDOW( current_position + C_CMP_LZSS_LOOK_AHEAD_SIZE ) ] = (unsigned char) c;
current_position = M_CMP_LZSS_MOD_WINDOW( current_position + 1 );
if ( look_ahead_bytes )
match_length = CMP_LZSS_fn_vAddString( current_position, &match_position );
}
}
CMP_fn_vOutputBit( output, 0 );
CMP_fn_vOutputBits( output, (unsigned long) C_CMP_LZSS_END_OF_STREAM, C_CMP_LZSS_INDEX_BIT_COUNT );
}
/**************************************************************************/
void CMP_LZSS_fn_vExpandFile( tdstBitFile *input , FILE *output )
{
int i;
int current_position;
int c;
int match_length;
int match_position;
current_position = 1;
for ( ; ; )
{
if ( CMP_fn_lInputBit( input ) )
{
c = (int) CMP_fn_ulInputBits( input, 8 );
putc( c, output );
CMP_LZSS_g_a_ucWindow[ current_position ] = (unsigned char) c;
current_position = M_CMP_LZSS_MOD_WINDOW( current_position + 1 );
}
else
{
match_position = (int) CMP_fn_ulInputBits( input, C_CMP_LZSS_INDEX_BIT_COUNT );
if ( match_position == C_CMP_LZSS_END_OF_STREAM )
break;
match_length = (int) CMP_fn_ulInputBits( input, C_CMP_LZSS_LENGTH_BIT_COUNT );
match_length += C_CMP_LZSS_BREAK_EVEN;
for ( i = 0 ; i <= match_length ; i++ )
{
c = CMP_LZSS_g_a_ucWindow[ M_CMP_LZSS_MOD_WINDOW( match_position + i ) ];
putc( c, output );
CMP_LZSS_g_a_ucWindow[ current_position ] = (unsigned char) c;
current_position = M_CMP_LZSS_MOD_WINDOW( current_position + 1 );
}
}
}
}
/**************************************************************************/
#endif /* D_CMP_LZSS */

View File

@@ -0,0 +1,8 @@
#if!defined(__CMP_LZSS_H__)
#define __CMP_LZSS_H__
void CMP_LZSS_fn_vCompressFile( FILE *input , tdstBitFile *output );
void CMP_LZSS_fn_vExpandFile( tdstBitFile *input , FILE *output );
#endif /* __CMP_LZSS_H__ */

View File

@@ -0,0 +1,126 @@
#define D_CMP_Input_VariableDefine
#include "CMP_CPA.h"
#include "ErmCmp.h"
#include "CMP_File.h"
#include "CMP_Pub.h"
#include "CMP_DIFF.h"
#include "CMP_LZSS.h"
#define C_TemporaryFile "Temp.tmp"
/**************************************************************************/
void CMP_fn_vFirstInit()
{
Erm_M_InitErrMsg(CMP);
}
/**************************************************************************/
void CMP_fn_vCompressFile(char *_szFileName,unsigned char _ucCompressMethod)
{
rename(_szFileName,C_TemporaryFile);
CMP_fn_vCompressFileIn(C_TemporaryFile,_szFileName,_ucCompressMethod);
DeleteFile(C_TemporaryFile);
}
/**************************************************************************/
void CMP_fn_vCompressFileIn(char *_szInputFileName,char *_szOutputFileName,unsigned char _ucCompressMethod)
{
#if defined(D_CMP_LZSS)
if (_ucCompressMethod==D_CMP_LZSS)
{
FILE *p_stInputFile = NULL;
tdstBitFile *p_stOutputBitFile = NULL;
p_stInputFile = M_p_stOpenInput(_szInputFileName);
if (p_stInputFile!=NULL)
{
p_stOutputBitFile = CMP_fn_p_stOpenOutputBitFile(_szOutputFileName);
if (p_stOutputBitFile!=NULL)
{
CMP_LZSS_fn_vCompressFile(p_stInputFile,p_stOutputBitFile);
CMP_fn_vCloseOutputBitFile(p_stOutputBitFile);
}
M_vCloseInput(p_stInputFile);
}
}
#endif /* D_CMP_LZSS */
#if defined(D_CMP_DIFF)
if (_ucCompressMethod==D_CMP_DIFF)
{
FILE *p_stInputFile = NULL;
FILE *p_stOutputFile = NULL;
p_stInputFile = M_p_stOpenInput(_szInputFileName);
if (p_stInputFile!=NULL)
{
p_stOutputFile = M_p_stOpenOutput(_szOutputFileName);
if (p_stOutputFile!=NULL)
{
CMP_DIFF_fn_vCompressFile(p_stInputFile,p_stOutputFile);
M_vCloseOutput(p_stOutputFile);
}
M_vCloseInput(p_stInputFile);
}
}
#endif /* D_CMP_DIFF */
}
/**************************************************************************/
unsigned char CMP_fn_bExpandFile(char *_szFileName,unsigned char _ucCompressMethod)
{
unsigned char ucReturn = TRUE;
rename(_szFileName,C_TemporaryFile);
ucReturn = CMP_fn_bExpandFileIn(C_TemporaryFile,_szFileName,_ucCompressMethod);
DeleteFile(C_TemporaryFile);
return(ucReturn);
}
/**************************************************************************/
unsigned char CMP_fn_bExpandFileIn(char *_szInputFileName,char *_szOutputFileName,unsigned char _ucCompressMethod)
{
unsigned char ucReturn = FALSE;
#if defined(D_CMP_LZSS)
if (_ucCompressMethod==D_CMP_LZSS)
{
tdstBitFile *p_stInputBitFile = NULL;
FILE *p_stOutputFile = NULL;
p_stInputBitFile = CMP_fn_p_stOpenInputBitFile(_szInputFileName);
if (p_stInputBitFile!=NULL)
{
p_stOutputFile = M_p_stOpenOutput(_szOutputFileName);
if (p_stOutputFile!=NULL)
{
CMP_LZSS_fn_vExpandFile(p_stInputBitFile,p_stOutputFile);
ucReturn = TRUE;
M_vCloseOutput(p_stOutputFile);
}
CMP_fn_vCloseInputBitFile(p_stInputBitFile);
}
}
#endif /* D_CMP_LZSS */
#if defined(D_CMP_DIFF)
if (_ucCompressMethod==D_CMP_DIFF)
{
FILE *p_stInputFile = NULL;
FILE *p_stOutputFile = NULL;
p_stInputFile = M_p_stOpenInput(_szInputFileName);
if (p_stInputFile!=NULL)
{
p_stOutputFile = M_p_stOpenOutput(_szOutputFileName);
if (p_stOutputFile!=NULL)
{
CMP_DIFF_fn_vExpandFile(p_stInputFile,p_stOutputFile);
ucReturn = TRUE;
M_vCloseOutput(p_stOutputFile);
}
M_vCloseInput(p_stInputFile);
}
}
#endif /* D_CMP_DIFF */
return(ucReturn);
}
/**************************************************************************/

View File

@@ -0,0 +1,5 @@
SCC = This is a source code control file
[CMP.vcproj]
SCC_Aux_Path = "P4SCC#srvperforce-ma:1666##raymandata##Editor"
SCC_Project_Name = Perforce Project