Add rayman2 source files
This commit is contained in:
190
Rayman_X/cpa/tempgrp/FIL/ErmFil.h
Normal file
190
Rayman_X/cpa/tempgrp/FIL/ErmFil.h
Normal file
@@ -0,0 +1,190 @@
|
||||
#if !defined(__ErmFIL_h__)
|
||||
#define __ErmFIL_h__
|
||||
|
||||
/******************************************/
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif /* _MSC_VER >= 1000 */
|
||||
/******************************************/
|
||||
|
||||
#include "FIL_Ver.h"
|
||||
|
||||
/***************************************/
|
||||
/**** Error macros (using ACPerror) ****/
|
||||
/***************************************/
|
||||
#define M_FILFatalError(ErrorNum) \
|
||||
{ \
|
||||
if (ErrorNum>E_uwFILFatalErr&&ErrorNum<E_uwFILStartOfWarning) \
|
||||
{ \
|
||||
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,E_uwFILFatalErrorNotAFatalError,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
|
||||
} \
|
||||
}
|
||||
|
||||
#define M_FILFatalErrorWithMessage(ErrorNum,Message) \
|
||||
{ \
|
||||
if (ErrorNum>E_uwFILFatalErr&&ErrorNum<E_uwFILStartOfWarning) \
|
||||
{ \
|
||||
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, Message);\
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,E_uwFILFatalErrorNotAFatalError,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
|
||||
} \
|
||||
}
|
||||
|
||||
#define M_FILInformationError(ErrorNum) \
|
||||
{ \
|
||||
if (ErrorNum>E_uwFILStartOfInformationWarning&&ErrorNum<E_uwFILErrNumber) \
|
||||
{ \
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,g_stInternalGeneral.ucDisplayInformation,C_ucNeverStopForDebug, NULL);\
|
||||
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
M_FILFatalError(E_uwFILInformationErrorIsNotAInformationError); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define M_FILInformationErrorWithMessage(ErrorNum,Message) \
|
||||
{ \
|
||||
if (ErrorNum>E_uwFILStartOfInformationWarning&&ErrorNum<E_uwFILErrNumber) \
|
||||
{ \
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,g_stInternalGeneral.ucDisplayInformation,C_ucNeverStopForDebug, Message);\
|
||||
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
M_FILFatalError(E_uwFILInformationErrorIsNotAInformationError); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define M_FILWarningError(ErrorNum) \
|
||||
{ \
|
||||
if (ErrorNum>E_uwFILStartOfWarning&&ErrorNum<E_uwFILStartOfInformationWarning) \
|
||||
{ \
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
M_FILFatalError(E_uwFILWarningErrorIsNotAWarningError); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define M_FILWarningErrorWithMessage(ErrorNum,Message) \
|
||||
{ \
|
||||
if (ErrorNum>E_uwFILStartOfWarning&&ErrorNum<E_uwFILStartOfInformationWarning) \
|
||||
{ \
|
||||
Erm_M_UpdateLastError(FIL,C_ucErmDefaultChannel,ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, Message);\
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
M_FILFatalError(E_uwFILWarningErrorIsNotAWarningError); \
|
||||
} \
|
||||
}
|
||||
|
||||
#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_uwFILErrNumber
|
||||
{
|
||||
E_uwFILFatalErr,
|
||||
#if defined(__FATAL_ERR_INPUT__)
|
||||
/**** Error's errors ****/
|
||||
E_uwFILFatalErrorNotAFatalError,
|
||||
E_uwFILInformationErrorIsNotAInformationError,
|
||||
E_uwFILWarningErrorIsNotAWarningError,
|
||||
E_uwFILConcatCheckSumOpen,
|
||||
E_uwFILConcatCheckSumRead,
|
||||
#endif /*__FATAL_ERR_INPUT__*/
|
||||
|
||||
E_uwFILStartOfWarning,
|
||||
|
||||
#if defined(__WARNING_ERR_INPUT__)
|
||||
#endif /*__WARNING_ERR_INPUT__*/
|
||||
|
||||
E_uwFILStartOfInformationWarning,
|
||||
|
||||
#if defined(__INFORMATION_ERR_INPUT__)
|
||||
E_uwFILBadBmpFormat,
|
||||
E_uwFILBadTgaFormat,
|
||||
E_uwFILInvalidGFVersion,
|
||||
#endif /*__INFORMATION_ERR_INPUT__*/
|
||||
|
||||
E_uwFILErrNumber,
|
||||
};
|
||||
|
||||
/*------------------*/
|
||||
/* Global Variables*/
|
||||
/*------------------*/
|
||||
#undef EXTERN
|
||||
#undef extern
|
||||
#undef LOCAL
|
||||
#if !defined(D_FIL_VariableDefine)
|
||||
#define EXTERN extern /*external declaration*/
|
||||
#define LOCAL /*replace by nothing : we have to declare*/
|
||||
#else /* D_FIL_VariableDefine */
|
||||
#define EXTERN /*replace by nothing : we have to declare*/
|
||||
#define LOCAL /*replace by nothing : we have to declare*/
|
||||
#endif /* D_FIL_VariableDefine */
|
||||
|
||||
EXTERN unsigned char g_ucFILModuleId /* number of identification of the Game module*/
|
||||
#if defined(D_FIL_VariableDefine)
|
||||
= C_ucModuleNotInitialized
|
||||
#endif /* D_FIL_VariableDefine */
|
||||
;
|
||||
|
||||
#if defined(__ERROR_STRINGS__)
|
||||
|
||||
EXTERN CPA_EXPORT char * g_a_szFILInformationModule []
|
||||
#if defined(D_FIL_VariableDefine) && !defined(CPA_WANTS_IMPORT)
|
||||
= {C_szFILVersion, C_szFILFullName, C_szFILDate}
|
||||
#endif /* D_FIL_VariableDefine && CPA_WANTS_IMPORT */
|
||||
;
|
||||
|
||||
EXTERN char * g_szFILModuleName /* Obliged syntax 'sz'+[Abbreviation of ModuleName]+'ModuleName'*/
|
||||
#if defined(D_FIL_VariableDefine)
|
||||
= {"FIL"}
|
||||
#endif /* D_FIL_VariableDefine */
|
||||
;
|
||||
|
||||
EXTERN tdstErrorMsg g_a_stFILTabErr[] /* Obliged syntax 'a_sz'+[Abbreviation of ModuleName]+'TabErr'*/
|
||||
#if defined(D_FIL_VariableDefine)
|
||||
=
|
||||
{
|
||||
#if defined(__FATAL_ERR_INPUT__)
|
||||
/**** Error's errors ****/
|
||||
E_uwFILFatalErrorNotAFatalError,"M_FILFatalError : try to raise a warning or an information",
|
||||
E_uwFILInformationErrorIsNotAInformationError,"M_FILInformationError : try to raise a fatal or a warning",
|
||||
E_uwFILWarningErrorIsNotAWarningError,"M_FILWarningError : try to raise a fatal or a information",
|
||||
E_uwFILConcatCheckSumOpen,"FIL_fn_vOpenConcatFile : File integrity fault when open :",
|
||||
E_uwFILConcatCheckSumRead,"FIL_fn_hOpenFileInConcatFile : File integrity fault when read :",
|
||||
#endif /*__FATAL_ERR_INPUT__*/
|
||||
|
||||
#ifdef __WARNING_ERR_INPUT__
|
||||
#endif /*__WARNING_ERR_INPUT__*/
|
||||
|
||||
#ifdef __INFORMATION_ERR_INPUT__
|
||||
E_uwFILBadBmpFormat,"Bad Bmp format",
|
||||
E_uwFILBadTgaFormat,"Bad Tga format",
|
||||
E_uwFILInvalidGFVersion,"Bad GF format",
|
||||
#endif /*__INFORMATION_ERR_INPUT__*/
|
||||
|
||||
0xffff,"\0"/*fin*/
|
||||
}
|
||||
#endif /* D_FIL_VariableDefine */
|
||||
;
|
||||
#endif /* __ERROR_STRINGS__ */
|
||||
|
||||
#undef EXTERN
|
||||
#undef extern
|
||||
|
||||
#endif /* !__ErmFIL_h__ */
|
181
Rayman_X/cpa/tempgrp/FIL/FIL.DSP
Normal file
181
Rayman_X/cpa/tempgrp/FIL/FIL.DSP
Normal file
@@ -0,0 +1,181 @@
|
||||
# Microsoft Developer Studio Project File - Name="FIL" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=FIL - 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 "Fil.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 "Fil.mak" CFG="FIL - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "FIL - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "FIL - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "FIL - Win32 Retail" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""$/cpa/tempgrp/FIL", SPCAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "FIL - 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\FIL" /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\FILP5_vr.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "FIL - 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 "Temp\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\FIL" /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\FILP5_vd.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "FIL - Win32 Retail"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "FIL___Wi"
|
||||
# PROP BASE Intermediate_Dir "FIL___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\FIL" /D "NDEBUG" /D "WIN32" /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\FIL" /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\FILP5_vr.lib"
|
||||
# ADD LIB32 /nologo /out:"x:\CPA\Lib\FILP5_vf.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "FIL - Win32 Release"
|
||||
# Name "FIL - Win32 Debug"
|
||||
# Name "FIL - Win32 Retail"
|
||||
# Begin Group "Sources"
|
||||
|
||||
# PROP Default_Filter ".c"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Bmp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Conc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_GF.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Priv.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Pub.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Tga.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Includes"
|
||||
|
||||
# PROP Default_Filter ".h"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ErmFil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Public\FIL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Bmp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Conc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_CPA.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_GF.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Priv.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Public\FIL\FIL_Pub.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Tga.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FIL_Ver.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Fil.mak
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
377
Rayman_X/cpa/tempgrp/FIL/FIL.vcproj
Normal file
377
Rayman_X/cpa/tempgrp/FIL/FIL.vcproj
Normal file
@@ -0,0 +1,377 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="FIL"
|
||||
ProjectGUID="{CDB5C2C7-2C29-42D5-8D4F-353F59E156D6}"
|
||||
SccProjectName=""$/cpa/tempgrp/FIL", SPCAAAAA"
|
||||
SccAuxPath=""
|
||||
SccLocalPath="."
|
||||
SccProvider="MSSCCI:NXN alienbrain">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<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\FIL"
|
||||
PreprocessorDefinitions="NDEBUG;VISUAL;WIN32;RETAIL"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\tmp\retail/FIL.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\FILP5_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="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\FIL"
|
||||
PreprocessorDefinitions="NDEBUG;VISUAL;WIN32;USE_PROFILER"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Tmp\Release/FIL.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\FILP5_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="Debug|Win32"
|
||||
OutputDirectory="x:\cpa\libd"
|
||||
IntermediateDirectory=".\Temp\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
OptimizeForProcessor="1"
|
||||
AdditionalIncludeDirectories="x:\cpa\Public,x:\cpa\Public\FIL"
|
||||
PreprocessorDefinitions="_DEBUG;VISUAL;WIN32;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT"
|
||||
RuntimeLibrary="3"
|
||||
PrecompiledHeaderFile=".\Temp\Debug/FIL.pch"
|
||||
AssemblerListingLocation=".\Temp\Debug/"
|
||||
ObjectFile=".\Temp\Debug/"
|
||||
ProgramDataBaseFileName=".\Temp\Debug/"
|
||||
WarningLevel="4"
|
||||
WarnAsError="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="1"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="x:\CPA\Libd\FILP5_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="FIL_Bmp.c">
|
||||
<FileConfiguration
|
||||
Name="Retail|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Conc.c">
|
||||
<FileConfiguration
|
||||
Name="Retail|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_GF.c">
|
||||
<FileConfiguration
|
||||
Name="Retail|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Priv.c">
|
||||
<FileConfiguration
|
||||
Name="Retail|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Pub.c">
|
||||
<FileConfiguration
|
||||
Name="Retail|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Tga.c">
|
||||
<FileConfiguration
|
||||
Name="Retail|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|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="ErmFil.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\FIL.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Bmp.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Conc.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_CPA.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_GF.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Priv.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\FIL\FIL_Pub.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Tga.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FIL_Ver.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="Fil.mak">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
281
Rayman_X/cpa/tempgrp/FIL/FIL_Bmp.c
Normal file
281
Rayman_X/cpa/tempgrp/FIL/FIL_Bmp.c
Normal file
@@ -0,0 +1,281 @@
|
||||
#if defined(WIN32)
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include "FIL_CPA.h"
|
||||
|
||||
#define D_FIL_StructureDefine
|
||||
|
||||
#include "ErmFil.h"
|
||||
|
||||
#include "FIL_Pub.h"
|
||||
#include "FIL_Priv.h"
|
||||
|
||||
#include "FIL_Bmp.h"
|
||||
|
||||
#include "MMG.h"
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vSaveBMPInFile(char *p_szFileName,unsigned char *p_ucSource,unsigned long ulWidth,unsigned long ulHeight,unsigned char ucNumberOfBytesInFile,unsigned char ucNumberOfBytesInSource)
|
||||
{
|
||||
struct FIL_tdstBmp_ stBmp;
|
||||
|
||||
FILE *p_stFile;
|
||||
long x,y;
|
||||
|
||||
/**** Bmp File Header ****/
|
||||
stBmp.stFileHeader.uwType = 0x4D42; /**** BM ****/
|
||||
stBmp.stFileHeader.ulSize = sizeof(struct FIL_tdstBmpFileHeader_)+sizeof(struct FIL_tdstBmpInfoHeader_)+ucNumberOfBytesInFile*ulHeight*ulWidth;
|
||||
stBmp.stFileHeader.ulReserved = 0x00000000;
|
||||
stBmp.stFileHeader.ulOffsetBits = sizeof(struct FIL_tdstBmpFileHeader_)+sizeof(struct FIL_tdstBmpInfoHeader_);
|
||||
|
||||
/**** Bmp Info Header ****/
|
||||
stBmp.stInfoHeader.ulSize = sizeof(struct FIL_tdstBmpInfoHeader_);
|
||||
stBmp.stInfoHeader.ulWidth = ulWidth;
|
||||
stBmp.stInfoHeader.ulHeight = ulHeight;
|
||||
stBmp.stInfoHeader.uwPlanes = 1;
|
||||
stBmp.stInfoHeader.uwBitCount = (unsigned short)(8*ucNumberOfBytesInFile);
|
||||
stBmp.stInfoHeader.ulCompression = 0;
|
||||
stBmp.stInfoHeader.ulSizeImage = ucNumberOfBytesInFile*ulHeight*ulWidth;
|
||||
stBmp.stInfoHeader.ulXPelsPerMeter = 0;
|
||||
stBmp.stInfoHeader.ulYPelsPerMeter = 0;
|
||||
stBmp.stInfoHeader.ulColorsUsed = 0;
|
||||
stBmp.stInfoHeader.ulColorsImportant = 0;
|
||||
|
||||
stBmp.p_ucBitMap = p_ucSource;
|
||||
|
||||
FIL_fn_bValidatePath("",p_szFileName);
|
||||
if ((p_stFile = fopen(p_szFileName,"wb"))!=NULL)
|
||||
{
|
||||
fwrite(&stBmp.stFileHeader,sizeof(struct FIL_tdstBmpFileHeader_),1,p_stFile);
|
||||
fwrite(&stBmp.stInfoHeader,sizeof(struct FIL_tdstBmpInfoHeader_),1,p_stFile);
|
||||
for (y=ulHeight-1;y>=0;y--)
|
||||
{
|
||||
for (x=0;x<(long)ulWidth;x++)
|
||||
{
|
||||
fwrite(stBmp.p_ucBitMap+(y*ulWidth+x)*ucNumberOfBytesInSource,sizeof(unsigned char),ucNumberOfBytesInFile,p_stFile);
|
||||
}
|
||||
}
|
||||
fclose(p_stFile);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadBMPInformationFromFile(char *p_szPath,char *p_szFileName,unsigned char *p_ucNumberOfBytesInDest,unsigned long *p_ulWidth,unsigned long *p_ulHeight)
|
||||
{
|
||||
FILE *p_stFile;
|
||||
struct FIL_tdstBmp_ stBmp;
|
||||
char szCompleteName[_MAX_PATH];
|
||||
|
||||
sprintf(szCompleteName,"%s\\%s",p_szPath,p_szFileName);
|
||||
|
||||
*p_ucNumberOfBytesInDest = 0;
|
||||
*p_ulWidth = 0;
|
||||
*p_ulHeight = 0;
|
||||
|
||||
if ((p_stFile = fopen(szCompleteName,"rb"))!=NULL)
|
||||
{
|
||||
fread(&stBmp.stFileHeader,sizeof(struct FIL_tdstBmpFileHeader_),1,p_stFile);
|
||||
fread(&stBmp.stInfoHeader,sizeof(struct FIL_tdstBmpInfoHeader_),1,p_stFile);
|
||||
if ( stBmp.stFileHeader.uwType!=0x4D42 /**** BM ****/
|
||||
||stBmp.stInfoHeader.uwPlanes!=1
|
||||
/* CGHT Palette*/
|
||||
||((stBmp.stInfoHeader.uwBitCount!=24)&&(stBmp.stInfoHeader.uwBitCount!=8))
|
||||
||stBmp.stInfoHeader.ulCompression!=0
|
||||
)
|
||||
{
|
||||
M_FILInformationErrorWithMessage(E_uwFILBadBmpFormat,szCompleteName);
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_ucNumberOfBytesInDest = (unsigned char)(stBmp.stInfoHeader.uwBitCount/8);
|
||||
*p_ulWidth = stBmp.stInfoHeader.ulWidth;
|
||||
*p_ulHeight = stBmp.stInfoHeader.ulHeight;
|
||||
}
|
||||
fclose(p_stFile);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
#if !defined(RETAIL) /* Use only in ConvImg*/
|
||||
void FIL_fn_vLoadBMPFromFileWithInvertPicture(char *p_szPath, char *p_szFileName, FIL_tdstGF *_p_stHeader)
|
||||
{
|
||||
FIL_fn_vLoadBMPFromFileWithoutInvertPicture(p_szPath,p_szFileName,
|
||||
&_p_stHeader->p_ucBitMap,
|
||||
&_p_stHeader->stFileHeader.ucBpp,
|
||||
&_p_stHeader->stFileHeader.ulWidth,
|
||||
&_p_stHeader->stFileHeader.ulHeight);
|
||||
if (_p_stHeader ->p_ucBitMap != NULL)
|
||||
FIL_fn_vInvertBMP( _p_stHeader ->p_ucBitMap,
|
||||
_p_stHeader->stFileHeader.ucBpp,
|
||||
_p_stHeader->stFileHeader.ulWidth,
|
||||
_p_stHeader->stFileHeader.ulHeight);
|
||||
}
|
||||
#endif /*RETAIL*/
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadBMPFromFileWithoutInvertPicture(char *p_szPath,char *p_szFileName,unsigned char **pp_ucDest,unsigned char *p_ucNumberOfBytesInDest,unsigned long *p_ulWidth,unsigned long *p_ulHeight)
|
||||
{
|
||||
FILE *p_stFile;
|
||||
struct FIL_tdstBmp_ stBmp;
|
||||
char szCompleteName[_MAX_PATH];
|
||||
|
||||
if (p_szPath[0]!=0)
|
||||
sprintf(szCompleteName,"%s\\%s",p_szPath,p_szFileName);
|
||||
else
|
||||
sprintf(szCompleteName,"%s",p_szFileName);
|
||||
|
||||
*pp_ucDest = NULL;
|
||||
*p_ucNumberOfBytesInDest = 0;
|
||||
*p_ulWidth = 0;
|
||||
*p_ulHeight = 0;
|
||||
|
||||
if ((p_stFile = fopen(szCompleteName,"rb"))!=NULL)
|
||||
{
|
||||
fread(&stBmp.stFileHeader,sizeof(struct FIL_tdstBmpFileHeader_),1,p_stFile);
|
||||
fread(&stBmp.stInfoHeader,sizeof(struct FIL_tdstBmpInfoHeader_),1,p_stFile);
|
||||
if ( stBmp.stFileHeader.uwType!=0x4D42 /**** BM ****/
|
||||
||stBmp.stInfoHeader.uwPlanes!=1
|
||||
/* CGHT Palette*/
|
||||
||((stBmp.stInfoHeader.uwBitCount!=24)&&(stBmp.stInfoHeader.uwBitCount!=8))
|
||||
||stBmp.stInfoHeader.ulCompression!=0
|
||||
)
|
||||
{
|
||||
M_FILInformationErrorWithMessage(E_uwFILBadBmpFormat,szCompleteName);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long ulSizeOfPalette;
|
||||
|
||||
*p_ucNumberOfBytesInDest = (unsigned char)(stBmp.stInfoHeader.uwBitCount/8);
|
||||
*p_ulWidth = stBmp.stInfoHeader.ulWidth;
|
||||
*p_ulHeight = stBmp.stInfoHeader.ulHeight;
|
||||
|
||||
/* CGHT Palette*/
|
||||
if(stBmp.stInfoHeader.uwBitCount==8)
|
||||
{
|
||||
/* Palette is on the start of the block*/
|
||||
ulSizeOfPalette=256*sizeof(RGBQUAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
ulSizeOfPalette=0;
|
||||
}
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeBmpFile , NULL);
|
||||
stBmp.p_ucBitMap = (unsigned char *)TMP_M_p_Malloc(*p_ulWidth**p_ulHeight**p_ucNumberOfBytesInDest+ulSizeOfPalette);
|
||||
*pp_ucDest = stBmp.p_ucBitMap;
|
||||
/* CGHT Palette*/
|
||||
fread(stBmp.p_ucBitMap,1,*p_ucNumberOfBytesInDest**p_ulWidth**p_ulHeight+ulSizeOfPalette,p_stFile);
|
||||
}
|
||||
fclose(p_stFile);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadBMPInformationFromConcatFile(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFileName,unsigned char *p_ucNumberOfBytesInDest,unsigned long *p_ulWidth,unsigned long *p_ulHeight)
|
||||
{
|
||||
FIL_tdxHandleToFileInConcatFile hHandleToFile;
|
||||
struct FIL_tdstBmp_ stBmp;
|
||||
|
||||
*p_ucNumberOfBytesInDest = 0;
|
||||
*p_ulWidth = 0;
|
||||
*p_ulHeight = 0;
|
||||
|
||||
if ((hHandleToFile = FIL_fn_hOpenFileInConcatFile(hConcatFile,p_szPath,p_szFileName))!=NULL)
|
||||
{
|
||||
FIL_fn_lReadFileInConcatFile(&stBmp.stFileHeader,sizeof(struct FIL_tdstBmpFileHeader_),1,hHandleToFile);
|
||||
FIL_fn_lReadFileInConcatFile(&stBmp.stInfoHeader,sizeof(struct FIL_tdstBmpInfoHeader_),1,hHandleToFile);
|
||||
if ( stBmp.stFileHeader.uwType!=0x4D42 /**** BM ****/
|
||||
||stBmp.stInfoHeader.uwPlanes!=1
|
||||
||stBmp.stInfoHeader.uwBitCount!=24
|
||||
||stBmp.stInfoHeader.ulCompression!=0
|
||||
)
|
||||
{
|
||||
M_FILInformationErrorWithMessage(E_uwFILBadBmpFormat,p_szFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_ucNumberOfBytesInDest = (unsigned char)(stBmp.stInfoHeader.uwBitCount/8);
|
||||
*p_ulWidth = stBmp.stInfoHeader.ulWidth;
|
||||
*p_ulHeight = stBmp.stInfoHeader.ulHeight;
|
||||
}
|
||||
FIL_fn_vCloseFileInConcatFile(&hHandleToFile);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadBMPFromConcatFileWithInvertPicture(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFileName,unsigned char **pp_ucDest,unsigned char *p_ucNumberOfBytesInDest,unsigned long *p_ulWidth,unsigned long *p_ulHeight)
|
||||
{
|
||||
FIL_fn_vLoadBMPFromConcatFileWithoutInvertPicture(hConcatFile,p_szPath,p_szFileName,pp_ucDest,p_ucNumberOfBytesInDest,p_ulWidth,p_ulHeight);
|
||||
if (*pp_ucDest!=NULL)
|
||||
FIL_fn_vInvertBMP(*pp_ucDest,*p_ucNumberOfBytesInDest,*p_ulWidth,*p_ulHeight);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadBMPFromConcatFileWithoutInvertPicture(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFileName,unsigned char **pp_ucDest,unsigned char *p_ucNumberOfBytesInDest,unsigned long *p_ulWidth,unsigned long *p_ulHeight)
|
||||
{
|
||||
FIL_tdxHandleToFileInConcatFile hHandleToFile;
|
||||
struct FIL_tdstBmp_ stBmp;
|
||||
|
||||
*pp_ucDest = NULL;
|
||||
*p_ucNumberOfBytesInDest = 0;
|
||||
*p_ulWidth = 0;
|
||||
*p_ulHeight = 0;
|
||||
|
||||
if ((hHandleToFile = FIL_fn_hOpenFileInConcatFile(hConcatFile,p_szPath,p_szFileName))!=NULL)
|
||||
{
|
||||
FIL_fn_lReadFileInConcatFile(&stBmp.stFileHeader,sizeof(struct FIL_tdstBmpFileHeader_),1,hHandleToFile);
|
||||
FIL_fn_lReadFileInConcatFile(&stBmp.stInfoHeader,sizeof(struct FIL_tdstBmpInfoHeader_),1,hHandleToFile);
|
||||
if ( stBmp.stFileHeader.uwType!=0x4D42 /**** BM ****/
|
||||
||stBmp.stInfoHeader.uwPlanes!=1
|
||||
/* CGHT Palette*/
|
||||
||((stBmp.stInfoHeader.uwBitCount!=24)&&(stBmp.stInfoHeader.uwBitCount!=8))
|
||||
||stBmp.stInfoHeader.ulCompression!=0
|
||||
)
|
||||
{
|
||||
M_FILInformationErrorWithMessage(E_uwFILBadBmpFormat,p_szFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_ucNumberOfBytesInDest = (unsigned char)(stBmp.stInfoHeader.uwBitCount/8);
|
||||
*p_ulWidth = stBmp.stInfoHeader.ulWidth;
|
||||
*p_ulHeight = stBmp.stInfoHeader.ulHeight;
|
||||
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeBmpFile , NULL);
|
||||
stBmp.p_ucBitMap = (unsigned char *)TMP_M_p_Malloc(*p_ulWidth**p_ulHeight**p_ucNumberOfBytesInDest);
|
||||
*pp_ucDest = stBmp.p_ucBitMap;
|
||||
FIL_fn_lReadFileInConcatFile(stBmp.p_ucBitMap,*p_ucNumberOfBytesInDest,*p_ulWidth**p_ulHeight,hHandleToFile);
|
||||
}
|
||||
FIL_fn_vCloseFileInConcatFile(&hHandleToFile);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vFreeBMP(unsigned char **pp_ucMemory)
|
||||
{
|
||||
if (*pp_ucMemory!=NULL)
|
||||
TMP_M_Free(*pp_ucMemory);
|
||||
*pp_ucMemory = NULL;
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vInvertBMP(unsigned char *p_ucDest,unsigned char ucNumberOfBytesInDest,unsigned long ulWidth,unsigned long ulHeight)
|
||||
{
|
||||
unsigned char *p_ucOneLine,*p_ucBlockStart;
|
||||
unsigned long y;
|
||||
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeBmpFile , NULL);
|
||||
p_ucOneLine = (unsigned char *)TMP_M_p_Malloc(ulWidth*ucNumberOfBytesInDest);
|
||||
|
||||
/* CGHT Palette*/
|
||||
|
||||
p_ucBlockStart=p_ucDest;
|
||||
|
||||
if(ucNumberOfBytesInDest==1)
|
||||
{
|
||||
p_ucBlockStart+=256*sizeof(RGBQUAD);
|
||||
}
|
||||
|
||||
|
||||
for (y=0;y<ulHeight/2;y++)
|
||||
{
|
||||
memcpy(p_ucOneLine,p_ucBlockStart+y*ulWidth*ucNumberOfBytesInDest,ulWidth*ucNumberOfBytesInDest);
|
||||
memcpy(p_ucBlockStart+y*ulWidth*ucNumberOfBytesInDest,p_ucBlockStart+(ulHeight-1-y)*ulWidth*ucNumberOfBytesInDest,ulWidth*ucNumberOfBytesInDest);
|
||||
memcpy(p_ucBlockStart+(ulHeight-1-y)*ulWidth*ucNumberOfBytesInDest,p_ucOneLine,ulWidth*ucNumberOfBytesInDest);
|
||||
}
|
||||
|
||||
TMP_M_Free(p_ucOneLine);
|
||||
}
|
||||
/**************************************************************************/
|
62
Rayman_X/cpa/tempgrp/FIL/FIL_Bmp.h
Normal file
62
Rayman_X/cpa/tempgrp/FIL/FIL_Bmp.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#if !defined(__FIL_Bmp_h__)
|
||||
#define __FIL_Bmp_h__
|
||||
|
||||
/******************************************/
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif /* _MSC_VER >= 1000 */
|
||||
/******************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "CPA_Expt.h"
|
||||
|
||||
#undef EXTERN
|
||||
#undef extern
|
||||
#if !defined(D_FIL_Globals)
|
||||
#define EXTERN extern
|
||||
#else
|
||||
#define EXTERN
|
||||
#endif /* D_FIL_Globals */
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef struct FIL_tdstBmpFileHeader_
|
||||
{
|
||||
unsigned short uwType;
|
||||
unsigned long ulSize;
|
||||
unsigned long ulReserved;
|
||||
unsigned long ulOffsetBits;
|
||||
} FIL_tdstBmpFileHeader;
|
||||
|
||||
typedef struct FIL_tdstBmpInfoHeader_
|
||||
{
|
||||
unsigned long ulSize;
|
||||
unsigned long ulWidth;
|
||||
unsigned long ulHeight;
|
||||
unsigned short uwPlanes;
|
||||
unsigned short uwBitCount;
|
||||
unsigned long ulCompression;
|
||||
unsigned long ulSizeImage;
|
||||
unsigned long ulXPelsPerMeter;
|
||||
unsigned long ulYPelsPerMeter;
|
||||
unsigned long ulColorsUsed;
|
||||
unsigned long ulColorsImportant;
|
||||
} FIL_tdstBmpInfoHeader;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct FIL_tdstBmp_
|
||||
{
|
||||
struct FIL_tdstBmpFileHeader_ stFileHeader;
|
||||
struct FIL_tdstBmpInfoHeader_ stInfoHeader;
|
||||
|
||||
unsigned char *p_ucBitMap;
|
||||
} FIL_tdstBmp;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __FIL_Bmp_h__ */
|
40
Rayman_X/cpa/tempgrp/FIL/FIL_CPA.h
Normal file
40
Rayman_X/cpa/tempgrp/FIL/FIL_CPA.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#if !defined(__FIL_CPA_H__)
|
||||
#define __FIL_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 */
|
||||
|
||||
#if defined(WIN32)&&defined(__cplusplus)
|
||||
#include "stdafx.h"
|
||||
#endif /* WIN32&&__cplusplus */
|
||||
|
||||
#define HieFriend
|
||||
#include "ACP_Base.h"
|
||||
#include "CPA_Expt.h"
|
||||
#include "CPA_Std.h"
|
||||
|
||||
#include "ERM.h"
|
||||
#include "LST.h"
|
||||
#include "TMP.h"
|
||||
|
||||
#endif /* __FIL_CPA_H__ */
|
606
Rayman_X/cpa/tempgrp/FIL/FIL_Conc.c
Normal file
606
Rayman_X/cpa/tempgrp/FIL/FIL_Conc.c
Normal file
@@ -0,0 +1,606 @@
|
||||
#include <io.h>
|
||||
|
||||
#include "FIL_CPA.h"
|
||||
|
||||
#define D_FIL_StructureDefine
|
||||
|
||||
#include "ErmFil.h"
|
||||
|
||||
#include "FIL_GF.h"
|
||||
#include "FIL_Pub.h"
|
||||
#include "FIL_Priv.h"
|
||||
#include "FIL_Conc.h"
|
||||
|
||||
#include "MMG.h"
|
||||
/**************************************************************************/
|
||||
FIL_tdxHandleToConcatFile FIL_fn_hCreateConcatFileHandle(unsigned long ulNumberOfPath,unsigned long ulNumberOfFiles)
|
||||
{
|
||||
FIL_tdstConcatFile *p_stConcatFile = NULL;
|
||||
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
p_stConcatFile = (FIL_tdstConcatFile *)TMP_M_p_Malloc(sizeof(FIL_tdstConcatFile));
|
||||
|
||||
p_stConcatFile->ulNumberOfPath = ulNumberOfPath;
|
||||
p_stConcatFile->ulNumberOfFile = ulNumberOfFiles;
|
||||
|
||||
if (ulNumberOfPath)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
p_stConcatFile->d_szPathList = (char **)TMP_M_p_Malloc(ulNumberOfPath*sizeof(char *));
|
||||
}
|
||||
else
|
||||
p_stConcatFile->d_szPathList = NULL;
|
||||
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
p_stConcatFile->d_stConcatFileElement = (FIL_tdstConcatFileElement *)TMP_M_p_Malloc(ulNumberOfFiles*sizeof(struct FIL_tdstConcatFileElement_));
|
||||
|
||||
return(p_stConcatFile);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void fn_vDestroyConcatFileHandle(FIL_tdxHandleToConcatFile hConcatFile)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
if (hConcatFile->d_szPathList!=NULL)
|
||||
{
|
||||
for (i=0;i<hConcatFile->ulNumberOfPath;i++)
|
||||
TMP_M_Free(hConcatFile->d_szPathList[i]);
|
||||
TMP_M_Free(hConcatFile->d_szPathList);
|
||||
}
|
||||
if (hConcatFile->d_stConcatFileElement!=NULL)
|
||||
{
|
||||
for (i=0;i<hConcatFile->ulNumberOfFile;i++)
|
||||
TMP_M_Free(hConcatFile->d_stConcatFileElement[i].p_szFileName);
|
||||
TMP_M_Free(hConcatFile->d_stConcatFileElement);
|
||||
}
|
||||
|
||||
TMP_M_Free(hConcatFile);
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bSetConcatPathElement(FIL_tdxHandleToConcatFile hConcatFile,unsigned long ulPathNumber,char *p_szPathName)
|
||||
{
|
||||
unsigned char bReturn = FALSE;
|
||||
|
||||
if (ulPathNumber<hConcatFile->ulNumberOfPath)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hConcatFile->d_szPathList[ulPathNumber] = (char *)TMP_M_p_Malloc((strlen(p_szPathName)+1)*sizeof(char));
|
||||
strcpy(hConcatFile->d_szPathList[ulPathNumber],p_szPathName);
|
||||
bReturn = TRUE;
|
||||
}
|
||||
return(bReturn);
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bSetConcatFileElementWithoutPath(FIL_tdxHandleToConcatFile hConcatFile,unsigned long ulFileNumber,char *p_szFileName)
|
||||
{
|
||||
unsigned char bReturn = FALSE;
|
||||
|
||||
if (ulFileNumber<hConcatFile->ulNumberOfFile)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hConcatFile->d_stConcatFileElement[ulFileNumber].p_szFileName = (char *)TMP_M_p_Malloc((strlen(p_szFileName)+1)*sizeof(char));
|
||||
strcpy(hConcatFile->d_stConcatFileElement[ulFileNumber].p_szFileName,p_szFileName);
|
||||
bReturn = TRUE;
|
||||
}
|
||||
return(bReturn);
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bSetConcatFileElement(FIL_tdxHandleToConcatFile hConcatFile,unsigned long ulFileNumber,char *p_szFileName)
|
||||
{
|
||||
char szTemp[_MAX_PATH];
|
||||
unsigned char bReturn = FALSE;
|
||||
unsigned long i;
|
||||
|
||||
if (ulFileNumber<hConcatFile->ulNumberOfFile)
|
||||
{
|
||||
if (strrchr(p_szFileName,'\\')==NULL)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hConcatFile->d_stConcatFileElement[ulFileNumber].p_szFileName = (char *)TMP_M_p_Malloc((strlen(p_szFileName)+1)*sizeof(char));
|
||||
strcpy(hConcatFile->d_stConcatFileElement[ulFileNumber].p_szFileName,p_szFileName);
|
||||
hConcatFile->d_stConcatFileElement[ulFileNumber].lPathNumber = -1;
|
||||
bReturn = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(szTemp,p_szFileName);
|
||||
*strrchr(szTemp,'\\')=0;
|
||||
for (i=0;i<hConcatFile->ulNumberOfPath&&stricmp(szTemp,hConcatFile->d_szPathList[i]);i++);
|
||||
if (i!=hConcatFile->ulNumberOfPath)
|
||||
{
|
||||
strcpy(szTemp,strrchr(p_szFileName,'\\')+1);
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hConcatFile->d_stConcatFileElement[ulFileNumber].p_szFileName = (char *)TMP_M_p_Malloc((strlen(szTemp)+1)*sizeof(char));
|
||||
strcpy(hConcatFile->d_stConcatFileElement[ulFileNumber].p_szFileName,szTemp);
|
||||
hConcatFile->d_stConcatFileElement[ulFileNumber].lPathNumber = i;
|
||||
bReturn = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return(bReturn);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vBuildConcatCompleteFileName(char *szCompleteFilename,FIL_tdxHandleToConcatFile hConcatFile,unsigned long ulIndex)
|
||||
{
|
||||
if (hConcatFile->d_stConcatFileElement[ulIndex].lPathNumber==-1)
|
||||
strcpy(szCompleteFilename,hConcatFile->d_stConcatFileElement[ulIndex].p_szFileName);
|
||||
else
|
||||
sprintf(szCompleteFilename,"%s\\%s",hConcatFile->d_szPathList[hConcatFile->d_stConcatFileElement[ulIndex].lPathNumber],hConcatFile->d_stConcatFileElement[ulIndex].p_szFileName);
|
||||
}
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
/* O.C start*/
|
||||
#define C_MARK_SIZE 4
|
||||
#define C_RIFF_MARK "RIFF"
|
||||
#define C_AVI_MARK "AVI "
|
||||
#define C_AVI_HEADER_SIZE sizeof(tdstAviHeader)
|
||||
#define C_CHUNK_HEADER_SIZE sizeof(tdstChunkHeader)
|
||||
#define C_DEFAULT_CHUNK_NAME ".CNT"
|
||||
|
||||
typedef struct tdstAviHeader_
|
||||
{
|
||||
unsigned char ucRIFFMark[C_MARK_SIZE];
|
||||
long lLength;
|
||||
unsigned char ucAVIMark[C_MARK_SIZE];
|
||||
|
||||
} tdstAviHeader;
|
||||
|
||||
typedef struct tdstChunkHeader_
|
||||
{
|
||||
unsigned char ucChunkMark[C_MARK_SIZE];
|
||||
long lChunkLength;
|
||||
} tdstChunkHeader;
|
||||
|
||||
tdstAviHeader stAviHeader;
|
||||
tdstChunkHeader stChunkHeader;
|
||||
|
||||
long fn_lCheckForFileinAVI(FILE *p_stFile,char *szFileToFind,char *szChunkToFind)
|
||||
{
|
||||
long lOffset=-1L;
|
||||
if (
|
||||
(fseek(p_stFile,0,SEEK_SET)==0) &&
|
||||
(fread(&stAviHeader,1,C_AVI_HEADER_SIZE,p_stFile)==C_AVI_HEADER_SIZE) &&
|
||||
(!strncmp((char*) &(stAviHeader.ucRIFFMark),C_RIFF_MARK,C_MARK_SIZE)) &&
|
||||
(!strncmp((char*) &(stAviHeader.ucAVIMark),C_AVI_MARK,C_MARK_SIZE))
|
||||
)
|
||||
{
|
||||
long lTotalLen=stAviHeader.lLength+C_CHUNK_HEADER_SIZE;
|
||||
long lLen;
|
||||
|
||||
unsigned char ucSize=0;
|
||||
char szBuffer[_MAX_PATH];
|
||||
|
||||
while
|
||||
(
|
||||
((lLen=ftell(p_stFile))!=-1L) &&
|
||||
(lLen<lTotalLen) &&
|
||||
(fread(&stChunkHeader,1,C_CHUNK_HEADER_SIZE,p_stFile)==C_CHUNK_HEADER_SIZE)
|
||||
)
|
||||
{
|
||||
if (
|
||||
(!strncmp((char*) &(stChunkHeader.ucChunkMark),szChunkToFind,C_MARK_SIZE)) &&
|
||||
(fread(&ucSize,1,1,p_stFile)==1) &&
|
||||
(fread(szBuffer,1,ucSize,p_stFile)==(size_t) ucSize) &&
|
||||
(
|
||||
(strlen(szFileToFind)==0) ||
|
||||
(!stricmp(szBuffer,szFileToFind))
|
||||
)
|
||||
)
|
||||
{
|
||||
lOffset=ftell(p_stFile);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fseek(p_stFile,stChunkHeader.lChunkLength + (stChunkHeader.lChunkLength &1),SEEK_CUR)!=0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return(lOffset);
|
||||
}
|
||||
|
||||
/* To access file in avi FILE.CNT@FILE.AVI*/
|
||||
/* or first chunk in FILE.AVI*/
|
||||
FILE *fn_p_stExtendedFopenForCNTinAVI(char *p_szFilename,long *p_lOffset)
|
||||
{
|
||||
FILE *p_stFile=NULL;
|
||||
char *szPtr=NULL;
|
||||
char szFileToOpen[_MAX_PATH];
|
||||
char szFileToFind[_MAX_PATH];
|
||||
char szChunkToFind[C_MARK_SIZE+1];
|
||||
*p_lOffset=0;
|
||||
|
||||
szPtr=strrchr(p_szFilename,'@');
|
||||
if (szPtr!=NULL)
|
||||
{
|
||||
strcpy(szFileToOpen,szPtr+1);
|
||||
|
||||
strcpy(szFileToFind,p_szFilename);
|
||||
szFileToFind[szPtr-p_szFilename]=0;
|
||||
|
||||
szPtr=strrchr(szFileToFind,'.');
|
||||
if (szPtr!=NULL)
|
||||
{
|
||||
memset(szChunkToFind,0,sizeof(szChunkToFind));
|
||||
strncpy(szChunkToFind,szPtr,C_MARK_SIZE);
|
||||
*szPtr=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(szChunkToFind,C_DEFAULT_CHUNK_NAME);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(szFileToOpen,p_szFilename);
|
||||
szFileToFind[0]=0;
|
||||
strcpy(szChunkToFind,C_DEFAULT_CHUNK_NAME);
|
||||
}
|
||||
|
||||
strupr(szFileToFind);
|
||||
strupr(szChunkToFind);
|
||||
if ((p_stFile=fopen(szFileToOpen,"rb"))!=NULL)
|
||||
{
|
||||
*p_lOffset=fn_lCheckForFileinAVI(p_stFile,szFileToFind,szChunkToFind);
|
||||
if (*p_lOffset==-1L)
|
||||
{
|
||||
*p_lOffset=0;
|
||||
rewind(p_stFile);
|
||||
}
|
||||
}
|
||||
return(p_stFile);
|
||||
}
|
||||
/* O.C end*/
|
||||
|
||||
FIL_tdxHandleToConcatFile FIL_fn_vOpenConcatFile(char *p_szFilename)
|
||||
{
|
||||
FIL_tdxHandleToConcatFile hConcatFile = NULL;
|
||||
unsigned long ulNumberOfPath,ulNumberOfFile;
|
||||
unsigned long ulInternalLength;
|
||||
unsigned long i,j;
|
||||
unsigned char ucInternalCheckSum;
|
||||
char szTemp[_MAX_PATH];
|
||||
FILE *p_stFile;
|
||||
|
||||
/* O.C*/
|
||||
long lOffsetToAdd=0;
|
||||
if ((p_stFile=fn_p_stExtendedFopenForCNTinAVI(p_szFilename,&lOffsetToAdd))!=NULL)
|
||||
/*if ((p_stFile=fopen(p_szFilename,"rb"))!=NULL)*/
|
||||
{
|
||||
/**** Number of paths and files ****/
|
||||
fread(&ulNumberOfPath,sizeof(unsigned long),1,p_stFile);
|
||||
fread(&ulNumberOfFile,sizeof(unsigned long),1,p_stFile);
|
||||
hConcatFile = FIL_fn_hCreateConcatFileHandle(ulNumberOfPath,ulNumberOfFile);
|
||||
fread(&hConcatFile->bUseXorCode,sizeof(unsigned char),1,p_stFile);
|
||||
fread(&hConcatFile->bUseCheckSum,sizeof(unsigned char),1,p_stFile);
|
||||
|
||||
hConcatFile->p_stFile = p_stFile;
|
||||
|
||||
/**** Load path table ****/
|
||||
fread(&hConcatFile->ucPathXorCode,sizeof(unsigned char),1,p_stFile);
|
||||
ucInternalCheckSum = 0;
|
||||
for (i=0;i<hConcatFile->ulNumberOfPath;i++)
|
||||
{
|
||||
fread(&ulInternalLength,sizeof(unsigned long),1,p_stFile);
|
||||
fread(szTemp,sizeof(char),ulInternalLength,p_stFile);
|
||||
szTemp[ulInternalLength] = 0;
|
||||
if (hConcatFile->bUseXorCode||hConcatFile->bUseCheckSum)
|
||||
{
|
||||
for (j=0;j<ulInternalLength;j++)
|
||||
{
|
||||
if (hConcatFile->bUseXorCode)
|
||||
szTemp[j]^=hConcatFile->ucPathXorCode;
|
||||
if (hConcatFile->bUseCheckSum)
|
||||
ucInternalCheckSum=(unsigned char)(ucInternalCheckSum+szTemp[j]);
|
||||
}
|
||||
}
|
||||
FIL_fn_bSetConcatPathElement(hConcatFile,i,szTemp);
|
||||
}
|
||||
fread(&hConcatFile->ucPathCheckSum,sizeof(unsigned char),1,p_stFile);
|
||||
if (hConcatFile->ucPathCheckSum!=ucInternalCheckSum)
|
||||
M_FILFatalErrorWithMessage(E_uwFILConcatCheckSumOpen,p_szFilename);
|
||||
|
||||
/**** Load filenames table ****/
|
||||
ucInternalCheckSum = 0;
|
||||
for (i=0;i<hConcatFile->ulNumberOfFile;i++)
|
||||
{
|
||||
fread(&hConcatFile->d_stConcatFileElement[i].lPathNumber,sizeof(long),1,p_stFile);
|
||||
fread(&ulInternalLength,sizeof(unsigned long),1,p_stFile);
|
||||
fread(szTemp,sizeof(char),ulInternalLength,p_stFile);
|
||||
szTemp[ulInternalLength] = 0;
|
||||
if (hConcatFile->bUseXorCode)
|
||||
{
|
||||
for (j=0;j<ulInternalLength;j++)
|
||||
szTemp[j]^=hConcatFile->ucPathXorCode;
|
||||
}
|
||||
FIL_fn_bSetConcatFileElementWithoutPath(hConcatFile,i,szTemp);
|
||||
fread(&hConcatFile->d_stConcatFileElement[i].ulXorCode,sizeof(unsigned long),1,p_stFile);
|
||||
fread(&hConcatFile->d_stConcatFileElement[i].ulCheckSum,sizeof(unsigned long),1,p_stFile);
|
||||
fread(&hConcatFile->d_stConcatFileElement[i].lOffset,sizeof(long),1,p_stFile);
|
||||
fread(&hConcatFile->d_stConcatFileElement[i].ulFileLength,sizeof(unsigned long),1,p_stFile);
|
||||
|
||||
/* O.C.*/
|
||||
hConcatFile->d_stConcatFileElement[i].lOffset+=lOffsetToAdd;
|
||||
}
|
||||
}
|
||||
return(hConcatFile);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vCloseConcatFile(FIL_tdxHandleToConcatFile *hConcatFile)
|
||||
{
|
||||
if (*hConcatFile!=NULL)
|
||||
{
|
||||
fclose((*hConcatFile)->p_stFile);
|
||||
fn_vDestroyConcatFileHandle(*hConcatFile);
|
||||
*hConcatFile = NULL;
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
FIL_tdxHandleToFileInConcatFile FIL_fn_hOpenFileInConcatFile(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFilename)
|
||||
{
|
||||
FIL_tdxHandleToFileInConcatFile hHandleToFile = NULL;
|
||||
unsigned char bFileFound = FALSE;
|
||||
char szTemp[_MAX_PATH];
|
||||
FILE *p_stFile;
|
||||
unsigned long ulInternalLength;
|
||||
/* unsigned long ulInternalCheckSum;*/
|
||||
unsigned long i/*,j*/;
|
||||
|
||||
char *p_szPointer;
|
||||
|
||||
/**** Convert / by \ in p_szFileName ****/
|
||||
while((p_szPointer=strchr(p_szFilename,'/'))!=NULL)
|
||||
*p_szPointer = '\\';
|
||||
|
||||
if ((p_szPointer=strrchr(p_szFilename,'\\'))==NULL)
|
||||
p_szPointer = p_szFilename;
|
||||
else
|
||||
p_szPointer++;
|
||||
|
||||
/**** Search file in concat file ****/
|
||||
if (hConcatFile!=NULL)
|
||||
{
|
||||
for (i=0;i<hConcatFile->ulNumberOfFile&&!bFileFound;i++)
|
||||
{
|
||||
if (!stricmp(p_szPointer,hConcatFile->d_stConcatFileElement[i].p_szFileName))
|
||||
{
|
||||
FIL_fn_vBuildConcatCompleteFileName(szTemp,hConcatFile,i);
|
||||
if (!stricmp(p_szFilename,szTemp))
|
||||
{
|
||||
bFileFound = TRUE;
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hHandleToFile = (FIL_tdxHandleToFileInConcatFile)TMP_M_p_Malloc(sizeof(FIL_tdstFileInConcatFile));
|
||||
hHandleToFile->bUseConcatFile = TRUE;
|
||||
hHandleToFile->p_stFile = hConcatFile->p_stFile;
|
||||
hHandleToFile->ulFileActualSeek = hConcatFile->d_stConcatFileElement[i].lOffset;
|
||||
hHandleToFile->ulFileEndSeek = hConcatFile->d_stConcatFileElement[i].lOffset + hConcatFile->d_stConcatFileElement[i].ulFileLength;
|
||||
if (!hConcatFile->bUseXorCode&&!hConcatFile->bUseCheckSum)
|
||||
{
|
||||
hHandleToFile->ulFileXorCode = 0;
|
||||
hHandleToFile->ulFileCheckSum = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
hHandleToFile->ulFileXorCode = hConcatFile->d_stConcatFileElement[i].ulXorCode;
|
||||
hHandleToFile->ulFileCheckSum = hConcatFile->d_stConcatFileElement[i].ulCheckSum;
|
||||
}
|
||||
|
||||
hHandleToFile->ulCacheCheckSum = 0;
|
||||
|
||||
if (hConcatFile->d_stConcatFileElement[i].ulFileLength>FIL_C_MaxConcatCacheSize)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hHandleToFile->p_ucCache = (unsigned char *)TMP_M_p_Malloc(FIL_C_MaxConcatCacheSize*sizeof(unsigned char));
|
||||
hHandleToFile->ulCacheSize = FIL_C_MaxConcatCacheSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hHandleToFile->p_ucCache = (unsigned char *)TMP_M_p_Malloc(hConcatFile->d_stConcatFileElement[i].ulFileLength*sizeof(unsigned char));
|
||||
hHandleToFile->ulCacheSize = hConcatFile->d_stConcatFileElement[i].ulFileLength;
|
||||
}
|
||||
hHandleToFile->ulCacheSeek = hHandleToFile->ulCacheSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFileFound)
|
||||
{
|
||||
sprintf(szTemp,"%s\\%s",p_szPath,p_szFilename);
|
||||
ulInternalLength = FIL_fn_ulGetFileSize(szTemp);
|
||||
if ((p_stFile = fopen(szTemp,"rb"))!=NULL)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hHandleToFile = (FIL_tdxHandleToFileInConcatFile)TMP_M_p_Malloc(sizeof(FIL_tdstFileInConcatFile));
|
||||
hHandleToFile->bUseConcatFile = FALSE;
|
||||
hHandleToFile->p_stFile = p_stFile;
|
||||
hHandleToFile->ulFileActualSeek = 0;
|
||||
hHandleToFile->ulFileEndSeek = ulInternalLength;
|
||||
hHandleToFile->ulFileXorCode = 0;
|
||||
hHandleToFile->ulFileCheckSum = 0;
|
||||
|
||||
hHandleToFile->ulCacheCheckSum = 0;
|
||||
|
||||
if (ulInternalLength>FIL_C_MaxConcatCacheSize)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hHandleToFile->p_ucCache = (unsigned char *)TMP_M_p_Malloc(FIL_C_MaxConcatCacheSize*sizeof(unsigned char));
|
||||
hHandleToFile->ulCacheSize = FIL_C_MaxConcatCacheSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeConcatFile , NULL);
|
||||
hHandleToFile->p_ucCache = (unsigned char *)TMP_M_p_Malloc(ulInternalLength*sizeof(unsigned char));
|
||||
hHandleToFile->ulCacheSize = ulInternalLength;
|
||||
}
|
||||
hHandleToFile->ulCacheSeek = hHandleToFile->ulCacheSize;
|
||||
}
|
||||
}
|
||||
|
||||
return(hHandleToFile);
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned long FIL_fn_ulReadFromFileToCacheinConcatFile(FIL_tdxHandleToFileInConcatFile hHandleToFile)
|
||||
{
|
||||
unsigned long ulReadReturn;
|
||||
unsigned long i;
|
||||
|
||||
fseek(hHandleToFile->p_stFile,hHandleToFile->ulFileActualSeek,SEEK_SET);
|
||||
if (hHandleToFile->ulFileActualSeek+hHandleToFile->ulCacheSize>hHandleToFile->ulFileEndSeek)
|
||||
ulReadReturn=fread(hHandleToFile->p_ucCache,sizeof(unsigned char),hHandleToFile->ulFileEndSeek-hHandleToFile->ulFileActualSeek,hHandleToFile->p_stFile);
|
||||
else
|
||||
ulReadReturn=fread(hHandleToFile->p_ucCache,sizeof(unsigned char),hHandleToFile->ulCacheSize,hHandleToFile->p_stFile);
|
||||
|
||||
hHandleToFile->ulFileActualSeek += ulReadReturn*sizeof(unsigned char);
|
||||
hHandleToFile->ulCacheSeek = 0;
|
||||
hHandleToFile->ulCacheSize = ulReadReturn*sizeof(unsigned char);
|
||||
|
||||
if (hHandleToFile->ulFileXorCode||hHandleToFile->ulFileCheckSum)
|
||||
{
|
||||
for (i=0;i<ulReadReturn/4;i++)
|
||||
{
|
||||
if (hHandleToFile->ulFileXorCode)
|
||||
((unsigned long*)hHandleToFile->p_ucCache)[i]^=hHandleToFile->ulFileXorCode;
|
||||
if (hHandleToFile->ulFileCheckSum)
|
||||
hHandleToFile->ulCacheCheckSum+=((unsigned long*)hHandleToFile->p_ucCache)[i];
|
||||
}
|
||||
}
|
||||
return(ulReadReturn);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vCloseFileInConcatFile(FIL_tdxHandleToFileInConcatFile *hHandleToFile)
|
||||
{
|
||||
if ((*hHandleToFile)->ulFileEndSeek==(*hHandleToFile)->ulFileActualSeek&&(*hHandleToFile)->ulFileCheckSum&&(*hHandleToFile)->ulCacheCheckSum!=(*hHandleToFile)->ulFileCheckSum)
|
||||
M_FILFatalError(E_uwFILConcatCheckSumRead);
|
||||
|
||||
if (!(*hHandleToFile)->bUseConcatFile)
|
||||
fclose((*hHandleToFile)->p_stFile);
|
||||
|
||||
if (hHandleToFile!=NULL)
|
||||
{
|
||||
if ((*hHandleToFile)->p_ucCache!=NULL)
|
||||
TMP_M_Free((*hHandleToFile)->p_ucCache);
|
||||
TMP_M_Free(*hHandleToFile);
|
||||
*hHandleToFile=NULL;
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
long FIL_fn_lReadFileInConcatFile(void *p_vBuffer,long lSize,long lNumber,FIL_tdxHandleToFileInConcatFile hHandleToFile)
|
||||
{
|
||||
long lInternalLength = 0;
|
||||
long lReadLength = 0;
|
||||
void *p_vInternalPointer;
|
||||
|
||||
if (hHandleToFile!=NULL&&lSize*lNumber>0)
|
||||
{
|
||||
/**** The asking size is above the file size ****/
|
||||
if ((unsigned long)(lSize*lNumber)>(hHandleToFile->ulCacheSize-hHandleToFile->ulCacheSeek)+(hHandleToFile->ulFileEndSeek-hHandleToFile->ulFileActualSeek))
|
||||
lInternalLength = (hHandleToFile->ulCacheSize-hHandleToFile->ulCacheSeek)+(hHandleToFile->ulFileEndSeek-hHandleToFile->ulFileActualSeek);
|
||||
else
|
||||
lInternalLength = lSize*lNumber;
|
||||
|
||||
lReadLength = lInternalLength/lSize;
|
||||
|
||||
|
||||
for (p_vInternalPointer=p_vBuffer;lInternalLength!=0;)
|
||||
{
|
||||
if (hHandleToFile->ulCacheSeek+lInternalLength<=hHandleToFile->ulCacheSize)
|
||||
{
|
||||
memcpy(p_vInternalPointer,hHandleToFile->p_ucCache+hHandleToFile->ulCacheSeek,lInternalLength);
|
||||
hHandleToFile->ulCacheSeek+=lInternalLength;
|
||||
p_vInternalPointer=(void*)((unsigned long)p_vInternalPointer+lInternalLength);
|
||||
lInternalLength = 0;
|
||||
}
|
||||
else if (hHandleToFile->ulCacheSeek<hHandleToFile->ulCacheSize)
|
||||
{
|
||||
memcpy(p_vInternalPointer,hHandleToFile->p_ucCache+hHandleToFile->ulCacheSeek,hHandleToFile->ulCacheSize-hHandleToFile->ulCacheSeek);
|
||||
lInternalLength -= hHandleToFile->ulCacheSize-hHandleToFile->ulCacheSeek;
|
||||
p_vInternalPointer=(void*)((unsigned long)p_vInternalPointer+hHandleToFile->ulCacheSize-hHandleToFile->ulCacheSeek);
|
||||
hHandleToFile->ulCacheSeek = hHandleToFile->ulCacheSize;
|
||||
}
|
||||
else
|
||||
FIL_fn_ulReadFromFileToCacheinConcatFile(hHandleToFile);
|
||||
}
|
||||
}
|
||||
return(lReadLength);
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*------------------------------------------------------------------------*/
|
||||
/**/
|
||||
/* Author David Lassonde*/
|
||||
/* Date 2 Sep 1998*/
|
||||
/* */
|
||||
/* Prototype FIL_fn_vOpenFileInConcatFile*/
|
||||
/* Parameters hConcatFile : The concat file*/
|
||||
/* p_szPath : */
|
||||
/* p_szFilename : */
|
||||
/* hHandleToFile : the global variable*/
|
||||
/* Return Type int 0 : the handle is OK (the file was found and the global Handle is set)*/
|
||||
/* -1 : the wanted file is not in the big file*/
|
||||
/* */
|
||||
/* Description */
|
||||
/**/
|
||||
/* same as FIL_fn_hOpenFileInConcatFile, except that it doesn't allocate a new handle for each texture loaded*/
|
||||
/* */
|
||||
/*------------------------------------------------------------------------*/
|
||||
int FIL_fn_iOpenFileInConcatFile(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFilename, FIL_tdxHandleToFileInConcatFile hHandleToFile)
|
||||
{
|
||||
/* FIL_tdxHandleToFileInConcatFile hHandleToFile = NULL;*/
|
||||
unsigned char bFileFound = FALSE;
|
||||
char szTemp[_MAX_PATH];
|
||||
/* unsigned long ulInternalCheckSum;*/
|
||||
unsigned long i/*,j*/;
|
||||
|
||||
char *p_szPointer;
|
||||
|
||||
/**** Convert / by \ in p_szFileName ****/
|
||||
while((p_szPointer=strchr(p_szFilename,'/'))!=NULL)
|
||||
*p_szPointer = '\\';
|
||||
|
||||
if ((p_szPointer=strrchr(p_szFilename,'\\'))==NULL)
|
||||
p_szPointer = p_szFilename;
|
||||
else
|
||||
p_szPointer++;
|
||||
|
||||
/**** Search file in concat file ****/
|
||||
if (hConcatFile!=NULL)
|
||||
{
|
||||
for (i=0;i<hConcatFile->ulNumberOfFile&&!bFileFound;i++)
|
||||
{
|
||||
if (!stricmp(p_szPointer,hConcatFile->d_stConcatFileElement[i].p_szFileName))
|
||||
{
|
||||
FIL_fn_vBuildConcatCompleteFileName(szTemp,hConcatFile,i);
|
||||
if (!stricmp(p_szFilename,szTemp))
|
||||
{
|
||||
bFileFound = TRUE;
|
||||
hHandleToFile->ulFileActualSeek = hConcatFile->d_stConcatFileElement[i].lOffset;
|
||||
hHandleToFile->ulFileEndSeek = hConcatFile->d_stConcatFileElement[i].lOffset + hConcatFile->d_stConcatFileElement[i].ulFileLength;
|
||||
if (!hConcatFile->bUseXorCode&&!hConcatFile->bUseCheckSum)
|
||||
{
|
||||
hHandleToFile->ulFileXorCode = 0;
|
||||
hHandleToFile->ulFileCheckSum = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
hHandleToFile->ulFileXorCode = hConcatFile->d_stConcatFileElement[i].ulXorCode;
|
||||
hHandleToFile->ulFileCheckSum = hConcatFile->d_stConcatFileElement[i].ulCheckSum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFileFound)
|
||||
{
|
||||
/* the file is not in the big file... We'll have to use the old function...*/
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
36
Rayman_X/cpa/tempgrp/FIL/FIL_Conc.h
Normal file
36
Rayman_X/cpa/tempgrp/FIL/FIL_Conc.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#if !defined(__FIL_Conc_h__)
|
||||
#define __FIL_Conc_h__
|
||||
|
||||
/******************************************/
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif /* _MSC_VER >= 1000 */
|
||||
/******************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "CPA_Expt.h"
|
||||
|
||||
/**** The cache size must be a multiply of 4 ****/
|
||||
#define FIL_C_MaxConcatCacheSize (256L*1024L)
|
||||
|
||||
#undef EXTERN
|
||||
#undef extern
|
||||
#if !defined(D_FIL_Globals)
|
||||
#define EXTERN extern
|
||||
#else
|
||||
#define EXTERN
|
||||
#endif /* D_FIL_Globals */
|
||||
|
||||
unsigned char FIL_fn_bSetConcatFileElementWithoutPath(FIL_tdxHandleToConcatFile hConcatFile,unsigned long ulFileNumber,char *p_szFileName);
|
||||
unsigned long FIL_fn_ulReadFromFileToCacheinConcatFile(FIL_tdxHandleToFileInConcatFile hHandleToFile);
|
||||
int FIL_fn_iOpenFileInConcatFile(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFilename, FIL_tdxHandleToFileInConcatFile hHandleToFile);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __FIL_Conc_h__ */
|
774
Rayman_X/cpa/tempgrp/FIL/FIL_GF.c
Normal file
774
Rayman_X/cpa/tempgrp/FIL/FIL_GF.c
Normal file
@@ -0,0 +1,774 @@
|
||||
/* MTL Stuff*/
|
||||
/*#include "gam/mtl/mtl.h"*/
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include "FIL_CPA.h"
|
||||
|
||||
#define D_FIL_StructureDefine
|
||||
|
||||
#include "ErmFil.h"
|
||||
|
||||
#include "FIL_Pub.h"
|
||||
#include "FIL_Priv.h"
|
||||
|
||||
/* dlassonde - 2 Sep 1998*/
|
||||
/* Global handle to avoid repeated allocations and deallocations*/
|
||||
FIL_tdxHandleToFileInConcatFile FIL_g_hHandleToFileInConcatFile = NULL;
|
||||
/*extern int FIL_fn_iOpenFileInConcatFile(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFilename, FIL_tdxHandleToFileInConcatFile hHandleToFile);*/
|
||||
|
||||
#include"FIL_Conc.h"
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vSaveGFInFile
|
||||
(
|
||||
char *p_szFileName,
|
||||
unsigned char ucNumberOfBytesInSource,
|
||||
FIL_tdstGF *_p_stSrcGF
|
||||
)
|
||||
{
|
||||
unsigned long ulCodeNumber[256];
|
||||
unsigned long i,j;
|
||||
FILE *p_stFile;
|
||||
struct FIL_tdstGF_ stGF;
|
||||
long c;
|
||||
unsigned char ucCodeNumber;
|
||||
|
||||
stGF.stFileHeader.ucRLECode = 0;
|
||||
stGF.stFileHeader.ulWidth = _p_stSrcGF->stFileHeader.ulWidth;
|
||||
stGF.stFileHeader.ulHeight = _p_stSrcGF->stFileHeader.ulHeight;
|
||||
stGF.stFileHeader.ucBpp = _p_stSrcGF->stFileHeader.ucBpp;
|
||||
stGF.stFileHeader.uwNbColorInPalette = _p_stSrcGF->stFileHeader.uwNbColorInPalette;
|
||||
stGF.stFileHeader.ucBpcInPalette = _p_stSrcGF->stFileHeader.ucBpcInPalette;
|
||||
stGF.p_ucPalette = _p_stSrcGF->p_ucPalette;
|
||||
stGF.stFileHeader.ucRed = _p_stSrcGF->stFileHeader.ucRed;
|
||||
stGF.stFileHeader.ucGreen = _p_stSrcGF->stFileHeader.ucGreen;
|
||||
stGF.stFileHeader.ucBlue = _p_stSrcGF->stFileHeader.ucBlue;
|
||||
stGF.stFileHeader.lChromakeyIndex = _p_stSrcGF->stFileHeader.lChromakeyIndex;
|
||||
stGF.stFileHeader.ulImageSize = _p_stSrcGF->stFileHeader.ulImageSize;
|
||||
stGF.stFileHeader.ucFormat = _p_stSrcGF->stFileHeader.ucFormat;
|
||||
stGF.stFileHeader.ucVersion = GF_VERSION;
|
||||
|
||||
|
||||
/**** Copy the picture for processing ****/
|
||||
stGF.p_ucBitMap = (unsigned char *) TMP_M_p_Malloc( _p_stSrcGF->stFileHeader.ulImageSize * ucNumberOfBytesInSource );
|
||||
memcpy( stGF.p_ucBitMap, _p_stSrcGF->p_ucBitMap, _p_stSrcGF->stFileHeader.ulImageSize * ucNumberOfBytesInSource );
|
||||
|
||||
/**** Search for the useless bytes ****/
|
||||
memset( ulCodeNumber, 0, 256 * 4 );
|
||||
for( i=0; i < ucNumberOfBytesInSource * _p_stSrcGF->stFileHeader.ulImageSize; i++ )
|
||||
{
|
||||
/* ulCodeNumber[ p_ucSource[i] ]++;*/
|
||||
ulCodeNumber[ _p_stSrcGF->p_ucBitMap[i] ]++;
|
||||
}
|
||||
|
||||
for( i=0; i < 256; i++ )
|
||||
{
|
||||
if( ulCodeNumber[i] < ulCodeNumber[stGF.stFileHeader.ucRLECode] )
|
||||
{
|
||||
stGF.stFileHeader.ucRLECode = (unsigned char) i;
|
||||
}
|
||||
}
|
||||
|
||||
/**** Save file ****/
|
||||
FIL_fn_bValidatePath("",p_szFileName);
|
||||
if( (p_stFile = fopen(p_szFileName,"wb")) !=NULL )
|
||||
{
|
||||
/* write header*/
|
||||
fwrite( &stGF.stFileHeader,
|
||||
sizeof(struct FIL_tdstFileHeader_),
|
||||
1,
|
||||
p_stFile );
|
||||
|
||||
/* write palette, if one*/
|
||||
|
||||
if( stGF.stFileHeader.uwNbColorInPalette != 0 &&
|
||||
stGF.stFileHeader.ucBpcInPalette != 0 )
|
||||
{
|
||||
fwrite( stGF.p_ucPalette,
|
||||
stGF.stFileHeader.ucBpcInPalette,
|
||||
stGF.stFileHeader.uwNbColorInPalette,
|
||||
p_stFile );
|
||||
}
|
||||
|
||||
for( c=0; c < _p_stSrcGF->stFileHeader.ucBpp; c++ )
|
||||
{
|
||||
for( i=0; i <_p_stSrcGF->stFileHeader.ulImageSize; )
|
||||
{
|
||||
/**** If byte is RLECode ****/
|
||||
if( stGF.p_ucBitMap[i*_p_stSrcGF->stFileHeader.ucBpp+c] == stGF.stFileHeader.ucRLECode )
|
||||
{
|
||||
if( i < _p_stSrcGF->stFileHeader.ulImageSize - 1 )
|
||||
{
|
||||
for( j=1;
|
||||
j < 256
|
||||
&& i + j < _p_stSrcGF->stFileHeader.ulImageSize
|
||||
&& stGF.p_ucBitMap[ (i + j) * _p_stSrcGF->stFileHeader.ucBpp + c ] ==
|
||||
stGF.p_ucBitMap[( i + j - 1) * _p_stSrcGF->stFileHeader.ucBpp + c];
|
||||
j++)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
if( j == 256 || i + j == _p_stSrcGF->stFileHeader.ulImageSize )
|
||||
{
|
||||
j--;
|
||||
}
|
||||
|
||||
ucCodeNumber = (unsigned char) j;
|
||||
fwrite( &stGF.stFileHeader.ucRLECode, sizeof(unsigned char), 1, p_stFile );
|
||||
fwrite( &stGF.p_ucBitMap[ i * _p_stSrcGF->stFileHeader.ucBpp + c], sizeof(unsigned char), 1, p_stFile );
|
||||
fwrite( &ucCodeNumber, sizeof(unsigned char), 1, p_stFile );
|
||||
i += ucCodeNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucCodeNumber = 1;
|
||||
fwrite( &stGF.stFileHeader.ucRLECode, sizeof(unsigned char), 1, p_stFile );
|
||||
fwrite( &stGF.p_ucBitMap[ i * _p_stSrcGF->stFileHeader.ucBpp + c], sizeof(unsigned char), 1, p_stFile );
|
||||
fwrite( &ucCodeNumber, sizeof(unsigned char), 1, p_stFile );
|
||||
i += ucCodeNumber;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**** If byte number is not 4 above the end ****/
|
||||
if (i<_p_stSrcGF->stFileHeader.ulImageSize-4)
|
||||
{
|
||||
if ( stGF.p_ucBitMap[i*_p_stSrcGF->stFileHeader.ucBpp+c]==stGF.p_ucBitMap[(i+1)*_p_stSrcGF->stFileHeader.ucBpp+c]
|
||||
&&stGF.p_ucBitMap[i*_p_stSrcGF->stFileHeader.ucBpp+c]==stGF.p_ucBitMap[(i+2)*_p_stSrcGF->stFileHeader.ucBpp+c]
|
||||
&&stGF.p_ucBitMap[i*_p_stSrcGF->stFileHeader.ucBpp+c]==stGF.p_ucBitMap[(i+3)*_p_stSrcGF->stFileHeader.ucBpp+c])
|
||||
{
|
||||
for (j=1;stGF.p_ucBitMap[(i+j)*_p_stSrcGF->stFileHeader.ucBpp+c]==stGF.p_ucBitMap[(i+j-1)*_p_stSrcGF->stFileHeader.ucBpp+c]&&j<256&&i+j<_p_stSrcGF->stFileHeader.ulImageSize;j++);
|
||||
if (j==256)
|
||||
j--;
|
||||
if (i+j==_p_stSrcGF->stFileHeader.ulImageSize)
|
||||
j--;
|
||||
ucCodeNumber = (unsigned char)j;
|
||||
fwrite(&stGF.stFileHeader.ucRLECode,sizeof(unsigned char),1,p_stFile);
|
||||
fwrite(&stGF.p_ucBitMap[i*_p_stSrcGF->stFileHeader.ucBpp+c],sizeof(unsigned char),1,p_stFile);
|
||||
fwrite(&ucCodeNumber,sizeof(unsigned char),1,p_stFile);
|
||||
i+=ucCodeNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(&stGF.p_ucBitMap[i*_p_stSrcGF->stFileHeader.ucBpp+c],sizeof(unsigned char),1,p_stFile);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(&stGF.p_ucBitMap[i*_p_stSrcGF->stFileHeader.ucBpp+c],sizeof(unsigned char),1,p_stFile);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
fclose(p_stFile);
|
||||
}
|
||||
|
||||
TMP_M_Free(stGF.p_ucBitMap);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadGFInformationFromFile(
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
ACP_tdxBool *p_bTextureInPalette,
|
||||
struct FIL_tdstGF_ *_p_stGF
|
||||
)
|
||||
{
|
||||
FILE *p_stFile;
|
||||
char szCompleteName[_MAX_PATH];
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
|
||||
sprintf(szCompleteName,"%s\\%s",p_szPath,p_szFileName);
|
||||
|
||||
p_stGFHeader->ucBpp = 0;
|
||||
p_stGFHeader->ulWidth = 0;
|
||||
p_stGFHeader->ulHeight = 0;
|
||||
*p_bTextureInPalette = 0;
|
||||
|
||||
|
||||
if( (p_stFile = fopen(szCompleteName,"rb")) != NULL )
|
||||
{
|
||||
fread(p_stGFHeader,sizeof(struct FIL_tdstFileHeader_),1,p_stFile);
|
||||
|
||||
*p_bTextureInPalette = (ACP_tdxBool)( p_stGFHeader->uwNbColorInPalette != 0 );
|
||||
|
||||
if(p_stGFHeader->ucVersion != GF_VERSION)
|
||||
{
|
||||
char ErrorMessage[60];
|
||||
sprintf(ErrorMessage,"File is Version: %d, Expected version: %d",p_stGFHeader->ucVersion, GF_VERSION);
|
||||
M_FILFatalErrorWithMessage(E_uwFILInvalidGFVersion, ErrorMessage);
|
||||
}
|
||||
if(p_stGFHeader->lChromakeyIndex == 0xffffffff)
|
||||
{
|
||||
p_stGFHeader->ucRed = 0;
|
||||
p_stGFHeader->ucGreen = 0;
|
||||
p_stGFHeader->ucBlue = 0;
|
||||
}
|
||||
|
||||
fclose(p_stFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadGFFromFileWithInvertPicture(
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
struct FIL_tdstGF_ *_p_stGF)
|
||||
{
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
|
||||
FIL_fn_vLoadGFFromFileWithoutInvertPicture(
|
||||
p_szPath,
|
||||
p_szFileName,
|
||||
_p_stGF);
|
||||
|
||||
if (_p_stGF->p_ucBitMap!=NULL)
|
||||
{
|
||||
FIL_fn_vInvertGF(_p_stGF->p_ucBitMap, p_stGFHeader->ucBpp, p_stGFHeader->ulWidth, p_stGFHeader->ulHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadGFFromFileWithoutInvertPicture(
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
struct FIL_tdstGF_ *_p_stGF)
|
||||
{
|
||||
FILE *p_stFile;
|
||||
char szCompleteName[_MAX_PATH];
|
||||
unsigned long c,i,j;
|
||||
unsigned char ucCode;
|
||||
unsigned char ucColor;
|
||||
unsigned char ucNumber;
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
/*VLHorror*/
|
||||
FIL_tdstRealGFFileHeader stGFRealHeader;
|
||||
/*EVL*/
|
||||
|
||||
sprintf(szCompleteName,"%s\\%s",p_szPath,p_szFileName);
|
||||
|
||||
/* set default values */
|
||||
memset( _p_stGF, 0, sizeof( FIL_tdstGF ) );
|
||||
p_stGFHeader->ucFormat = 0xff;
|
||||
|
||||
if( (p_stFile = fopen(szCompleteName,"rb")) != NULL )
|
||||
{
|
||||
/*VLHorror*/
|
||||
/* read file header*/
|
||||
/*fread( p_stGFHeader, sizeof(struct FIL_tdstFileHeader_), 1, p_stFile );*/
|
||||
fread( &stGFRealHeader, sizeof( FIL_tdstRealGFFileHeader ), 1, p_stFile );
|
||||
p_stGFHeader->ulWidth = stGFRealHeader.ulWidth;
|
||||
p_stGFHeader->ulHeight = stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ulImageSize = stGFRealHeader.ulWidth * stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ucBpp = stGFRealHeader.ucBpp;
|
||||
p_stGFHeader->ucRLECode = stGFRealHeader.ucRLECode;
|
||||
p_stGFHeader->ucVersion = GF_VERSION;
|
||||
if (p_stGFHeader->ucBpp == 1)
|
||||
{
|
||||
p_stGFHeader->uwNbColorInPalette = 256;
|
||||
p_stGFHeader->ucBpcInPalette = 4;
|
||||
}
|
||||
/*EVL*/
|
||||
|
||||
/* set return values*/
|
||||
if(p_stGFHeader->ucVersion != GF_VERSION)
|
||||
{
|
||||
char ErrorMessage[60];
|
||||
sprintf(ErrorMessage,"File is Version: %d, Expected version: %d",p_stGFHeader->ucVersion, GF_VERSION);
|
||||
M_FILFatalErrorWithMessage(E_uwFILInvalidGFVersion, ErrorMessage);
|
||||
}
|
||||
|
||||
if(p_stGFHeader->lChromakeyIndex == 0xffffffff)
|
||||
{
|
||||
p_stGFHeader->ucRed = 0;
|
||||
p_stGFHeader->ucGreen = 0;
|
||||
p_stGFHeader->ucBlue = 0;
|
||||
}
|
||||
|
||||
|
||||
_p_stGF->p_ucBitMap = (unsigned char *) TMP_M_p_Malloc( p_stGFHeader->ulImageSize * p_stGFHeader->ucBpp );
|
||||
|
||||
if( p_stGFHeader->uwNbColorInPalette != 0 && p_stGFHeader->ucBpcInPalette != 0 )
|
||||
{
|
||||
_p_stGF->p_ucPalette = (unsigned char *) TMP_M_p_Malloc( p_stGFHeader->uwNbColorInPalette * p_stGFHeader->ucBpcInPalette );
|
||||
fread( _p_stGF->p_ucPalette, p_stGFHeader->ucBpcInPalette, p_stGFHeader->uwNbColorInPalette, p_stFile );
|
||||
}
|
||||
|
||||
|
||||
for( c=0; c < p_stGFHeader->ucBpp; c++ )
|
||||
{
|
||||
for( i=0; i < p_stGFHeader->ulImageSize; )
|
||||
{
|
||||
fread(&ucCode,sizeof(unsigned char),1,p_stFile);
|
||||
|
||||
if( ucCode == p_stGFHeader->ucRLECode )
|
||||
{
|
||||
fread( &ucColor, sizeof(unsigned char), 1, p_stFile );
|
||||
fread( &ucNumber, sizeof(unsigned char), 1, p_stFile );
|
||||
|
||||
for( j=0; j < ucNumber; j++ )
|
||||
{
|
||||
_p_stGF->p_ucBitMap[ (i + j) * (p_stGFHeader->ucBpp) + c ] = ucColor;
|
||||
}
|
||||
|
||||
i += ucNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
_p_stGF->p_ucBitMap[i * p_stGFHeader->ucBpp + c] = ucCode;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(p_stFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* dlassonde - 2 Sep 1998 */
|
||||
/* I renamed the function Old because the optimized one is just below and */
|
||||
/* if the file wanted is not in the big file, it will call the old function*/
|
||||
/* to load it*/
|
||||
void FIL_fn_vOldLoadGFInformationFromConcatFile(
|
||||
FIL_tdxHandleToConcatFile hConcatFile,
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
ACP_tdxBool *p_bTextureInPalette,
|
||||
struct FIL_tdstGF_ *_p_stGF)
|
||||
{
|
||||
FIL_tdxHandleToFileInConcatFile hHandleToFile;
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
/*VLHorror*/
|
||||
FIL_tdstRealGFFileHeader stGFRealHeader;
|
||||
/*EVL*/
|
||||
|
||||
p_stGFHeader->ucBpp = 0;
|
||||
p_stGFHeader->ulWidth = 0;
|
||||
p_stGFHeader->ulHeight = 0;
|
||||
*p_bTextureInPalette = FALSE;
|
||||
|
||||
if( (hHandleToFile = FIL_fn_hOpenFileInConcatFile(hConcatFile,p_szPath,p_szFileName)) != NULL )
|
||||
{
|
||||
/*VLHorror*/
|
||||
/* read file header*/
|
||||
/*FIL_fn_lReadFileInConcatFile(p_stGFHeader,sizeof(struct FIL_tdstFileHeader_),1,hHandleToFile);*/
|
||||
FIL_fn_lReadFileInConcatFile( &stGFRealHeader, sizeof( FIL_tdstRealGFFileHeader ), 1, hHandleToFile );
|
||||
p_stGFHeader->ulWidth = stGFRealHeader.ulWidth;
|
||||
p_stGFHeader->ulHeight = stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ulImageSize = stGFRealHeader.ulWidth * stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ucBpp = stGFRealHeader.ucBpp;
|
||||
p_stGFHeader->ucRLECode = stGFRealHeader.ucRLECode;
|
||||
p_stGFHeader->ucVersion = GF_VERSION;
|
||||
if (p_stGFHeader->ucBpp == 1)
|
||||
{
|
||||
p_stGFHeader->uwNbColorInPalette = 256;
|
||||
p_stGFHeader->ucBpcInPalette = 4;
|
||||
}
|
||||
/*EVL*/
|
||||
|
||||
*p_bTextureInPalette = (ACP_tdxBool)( p_stGFHeader->uwNbColorInPalette!= 0 );
|
||||
FIL_fn_vCloseFileInConcatFile(&hHandleToFile);
|
||||
|
||||
if(p_stGFHeader->ucVersion != GF_VERSION)
|
||||
{
|
||||
char ErrorMessage[60];
|
||||
sprintf(ErrorMessage,"File is Version: %d, Expected version: %d",p_stGFHeader->ucVersion, GF_VERSION);
|
||||
M_FILFatalErrorWithMessage(E_uwFILInvalidGFVersion, ErrorMessage);
|
||||
}
|
||||
|
||||
|
||||
if(p_stGFHeader->lChromakeyIndex == 0xffffffff)
|
||||
{
|
||||
p_stGFHeader->ucRed = 0;
|
||||
p_stGFHeader->ucGreen = 0;
|
||||
p_stGFHeader->ucBlue = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/**/
|
||||
/* Author David Lassonde*/
|
||||
/* Date 2 Sep 1998*/
|
||||
/* */
|
||||
/* Prototype FIL_fn_vLoadGFInformationFromConcatFile*/
|
||||
/* Parameters hConcatFile : */
|
||||
/* p_szPath : */
|
||||
/* p_szFileName : */
|
||||
/* p_ucNumberOfBytesInDest : */
|
||||
/* p_ulWidth : */
|
||||
/* p_ulHeight : */
|
||||
/* p_bTextureInPalette : */
|
||||
/* Return Type void*/
|
||||
/* */
|
||||
/* Description */
|
||||
|
||||
/* The same as the function above but the file handle is not allocated each time*/
|
||||
/* a file is read from the big file... We use a global handle instead*/
|
||||
/* */
|
||||
/*------------------------------------------------------------------------*/
|
||||
void FIL_fn_vLoadGFInformationFromConcatFile
|
||||
(
|
||||
FIL_tdxHandleToConcatFile hConcatFile,
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
ACP_tdxBool *p_bTextureInPalette,
|
||||
struct FIL_tdstGF_ *_p_stGF
|
||||
)
|
||||
{
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
/*VLHorror*/
|
||||
FIL_tdstRealGFFileHeader stGFRealHeader;
|
||||
/*EVL*/
|
||||
|
||||
*p_bTextureInPalette = FALSE;
|
||||
p_stGFHeader->uwNbColorInPalette = 0;
|
||||
p_stGFHeader->ulWidth = 0;
|
||||
p_stGFHeader->ulHeight = 0;
|
||||
p_stGFHeader->ucBpp = 0;
|
||||
p_stGFHeader->ucBpcInPalette = 0;
|
||||
p_stGFHeader->ulImageSize = 0;
|
||||
p_stGFHeader->ucFormat = 0xff;
|
||||
|
||||
/* if the global handle is not valid, call the old function*/
|
||||
if (FIL_g_hHandleToFileInConcatFile == NULL || hConcatFile == NULL)
|
||||
{
|
||||
FIL_fn_vOldLoadGFInformationFromConcatFile(hConcatFile,
|
||||
p_szPath,
|
||||
p_szFileName,
|
||||
p_bTextureInPalette,
|
||||
_p_stGF);
|
||||
return;
|
||||
}
|
||||
|
||||
/* let the handle point to the right big file*/
|
||||
FIL_g_hHandleToFileInConcatFile->p_stFile = hConcatFile->p_stFile;
|
||||
|
||||
if (FIL_fn_iOpenFileInConcatFile(hConcatFile,p_szPath,p_szFileName, FIL_g_hHandleToFileInConcatFile ) == -1)
|
||||
{
|
||||
/* if the file is not in the big file, we use the old function...*/
|
||||
FIL_fn_vOldLoadGFInformationFromConcatFile(hConcatFile,
|
||||
p_szPath,
|
||||
p_szFileName,
|
||||
p_bTextureInPalette,
|
||||
_p_stGF);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*VLHorror*/
|
||||
/* read file header*/
|
||||
/*FIL_fn_lReadFileInConcatFile(p_stGFHeader,sizeof(struct FIL_tdstFileHeader_),1,FIL_g_hHandleToFileInConcatFile );*/
|
||||
FIL_fn_lReadFileInConcatFile( &stGFRealHeader, sizeof( FIL_tdstRealGFFileHeader ), 1, FIL_g_hHandleToFileInConcatFile );
|
||||
p_stGFHeader->ulWidth = stGFRealHeader.ulWidth;
|
||||
p_stGFHeader->ulHeight = stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ulImageSize = stGFRealHeader.ulWidth * stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ucBpp = stGFRealHeader.ucBpp;
|
||||
p_stGFHeader->ucRLECode = stGFRealHeader.ucRLECode;
|
||||
p_stGFHeader->ucVersion = GF_VERSION;
|
||||
if (p_stGFHeader->ucBpp == 1)
|
||||
{
|
||||
p_stGFHeader->uwNbColorInPalette = 256;
|
||||
p_stGFHeader->ucBpcInPalette = 4;
|
||||
}
|
||||
/*EVL*/
|
||||
|
||||
*p_bTextureInPalette = (ACP_tdxBool)( p_stGFHeader->uwNbColorInPalette != 0 );
|
||||
|
||||
if(p_stGFHeader->ucVersion != GF_VERSION)
|
||||
{
|
||||
char ErrorMessage[60];
|
||||
sprintf(ErrorMessage,"File is Version: %d, Expected version: %d",p_stGFHeader->ucVersion, GF_VERSION);
|
||||
M_FILFatalErrorWithMessage(E_uwFILInvalidGFVersion, ErrorMessage);
|
||||
}
|
||||
|
||||
|
||||
/* we reset the cache...*/
|
||||
FIL_g_hHandleToFileInConcatFile->ulCacheCheckSum = 0;
|
||||
FIL_g_hHandleToFileInConcatFile->ulCacheSize = FIL_C_MaxConcatCacheSize;
|
||||
FIL_g_hHandleToFileInConcatFile->ulCacheSeek = FIL_g_hHandleToFileInConcatFile ->ulCacheSize;
|
||||
|
||||
if(p_stGFHeader->lChromakeyIndex == 0xffffffff)
|
||||
{
|
||||
p_stGFHeader->ucRed = 0;
|
||||
p_stGFHeader->ucGreen = 0;
|
||||
p_stGFHeader->ucBlue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadGFFromConcatFileWithInvertPicture(
|
||||
FIL_tdxHandleToConcatFile hConcatFile,
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
struct FIL_tdstGF_ *_p_stGF)
|
||||
{
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
|
||||
FIL_fn_vLoadGFFromConcatFileWithoutInvertPicture(
|
||||
hConcatFile,
|
||||
p_szPath,
|
||||
p_szFileName,
|
||||
_p_stGF);
|
||||
|
||||
if(_p_stGF->p_ucBitMap!=NULL)
|
||||
{
|
||||
FIL_fn_vInvertGF(_p_stGF->p_ucBitMap, p_stGFHeader->ucBpp, p_stGFHeader->ulWidth, p_stGFHeader->ulHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vLoadGFFromConcatFileWithoutInvertPicture(
|
||||
FIL_tdxHandleToConcatFile hConcatFile,
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
struct FIL_tdstGF_ *_p_stGF)
|
||||
{
|
||||
FIL_tdxHandleToFileInConcatFile hHandleToFile;
|
||||
unsigned long c,i,j;
|
||||
unsigned char ucCode;
|
||||
unsigned char ucColor;
|
||||
unsigned char ucNumber;
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
/*VLHorror*/
|
||||
FIL_tdstRealGFFileHeader stGFRealHeader;
|
||||
/*EVL*/
|
||||
|
||||
|
||||
/* set default values*/
|
||||
_p_stGF->p_ucBitMap = NULL;
|
||||
_p_stGF->p_ucPalette = NULL;
|
||||
p_stGFHeader->uwNbColorInPalette = 0;
|
||||
p_stGFHeader->ulWidth = 0;
|
||||
p_stGFHeader->ulHeight = 0;
|
||||
p_stGFHeader->ucBpp = 0;
|
||||
p_stGFHeader->ucBpcInPalette = 0;
|
||||
p_stGFHeader->ulImageSize = 0;
|
||||
p_stGFHeader->ucFormat = 0xff;
|
||||
|
||||
if( (hHandleToFile = FIL_fn_hOpenFileInConcatFile(hConcatFile,p_szPath,p_szFileName)) != NULL )
|
||||
{
|
||||
/*VLHorror*/
|
||||
/* read file header*/
|
||||
/*FIL_fn_lReadFileInConcatFile( p_stGFHeader, sizeof(struct FIL_tdstFileHeader_), 1, hHandleToFile );*/
|
||||
FIL_fn_lReadFileInConcatFile( &stGFRealHeader, sizeof( FIL_tdstRealGFFileHeader ), 1, hHandleToFile );
|
||||
p_stGFHeader->ulWidth = stGFRealHeader.ulWidth;
|
||||
p_stGFHeader->ulHeight = stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ulImageSize = stGFRealHeader.ulWidth * stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ucBpp = stGFRealHeader.ucBpp;
|
||||
p_stGFHeader->ucRLECode = stGFRealHeader.ucRLECode;
|
||||
p_stGFHeader->ucVersion = GF_VERSION;
|
||||
if (p_stGFHeader->ucBpp == 1)
|
||||
{
|
||||
p_stGFHeader->uwNbColorInPalette = 256;
|
||||
p_stGFHeader->ucBpcInPalette = 4;
|
||||
}
|
||||
/*EVL*/
|
||||
|
||||
/* set return values*/
|
||||
if(p_stGFHeader->ucVersion != GF_VERSION)
|
||||
{
|
||||
char ErrorMessage[60];
|
||||
sprintf(ErrorMessage,"File is Version: %d, Expected version: %d",p_stGFHeader->ucVersion, GF_VERSION);
|
||||
M_FILFatalErrorWithMessage(E_uwFILInvalidGFVersion, ErrorMessage);
|
||||
}
|
||||
|
||||
|
||||
if(p_stGFHeader->lChromakeyIndex == 0xffffffff)
|
||||
{
|
||||
p_stGFHeader->ucRed = 0;
|
||||
p_stGFHeader->ucGreen = 0;
|
||||
p_stGFHeader->ucBlue = 0;
|
||||
}
|
||||
|
||||
_p_stGF->p_ucBitMap = (unsigned char *) TMP_M_p_Malloc( p_stGFHeader->ulImageSize * p_stGFHeader->ucBpp );
|
||||
|
||||
/* read palette, if one*/
|
||||
if( p_stGFHeader->uwNbColorInPalette != 0 && p_stGFHeader->ucBpcInPalette != 0 )
|
||||
{
|
||||
_p_stGF->p_ucPalette = (unsigned char *) TMP_M_p_Malloc( p_stGFHeader->uwNbColorInPalette * p_stGFHeader->ucBpcInPalette );
|
||||
FIL_fn_lReadFileInConcatFile( _p_stGF->p_ucPalette, (long)p_stGFHeader->ucBpcInPalette, p_stGFHeader->uwNbColorInPalette, hHandleToFile );
|
||||
}
|
||||
|
||||
/* read bitmap and decompress it*/
|
||||
for( c=0; c < p_stGFHeader->ucBpp; c++ )
|
||||
{
|
||||
for( i=0; i < p_stGFHeader->ulImageSize; )
|
||||
{
|
||||
FIL_fn_lReadFileInConcatFile(&ucCode,sizeof(unsigned char),1,hHandleToFile);
|
||||
if( ucCode == p_stGFHeader->ucRLECode )
|
||||
{
|
||||
FIL_fn_lReadFileInConcatFile(&ucColor,sizeof(unsigned char),1,hHandleToFile);
|
||||
FIL_fn_lReadFileInConcatFile(&ucNumber,sizeof(unsigned char),1,hHandleToFile);
|
||||
|
||||
for( j=0; j < ucNumber; j++ )
|
||||
{
|
||||
_p_stGF->p_ucBitMap[ ( i + j ) * p_stGFHeader->ucBpp + c ] = ucColor;
|
||||
}
|
||||
|
||||
i += ucNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
_p_stGF->p_ucBitMap[ i * p_stGFHeader->ucBpp + c ] = ucCode;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
FIL_fn_vCloseFileInConcatFile(&hHandleToFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vFreeGF( unsigned char **pp_ucBitMap, unsigned char **pp_ucPalette )
|
||||
{
|
||||
if( *pp_ucBitMap != NULL )
|
||||
{
|
||||
TMP_M_Free( *pp_ucBitMap );
|
||||
*pp_ucBitMap = NULL;
|
||||
}
|
||||
|
||||
if( *pp_ucPalette != NULL )
|
||||
{
|
||||
TMP_M_Free( *pp_ucPalette );
|
||||
*pp_ucPalette = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vInvertGF(
|
||||
unsigned char *p_ucDest,
|
||||
unsigned char ucNumberOfBytesInDest,
|
||||
unsigned long ulWidth,
|
||||
unsigned long ulHeight )
|
||||
{
|
||||
unsigned char *p_ucOneLine;
|
||||
unsigned long y;
|
||||
|
||||
p_ucOneLine = (unsigned char *)TMP_M_p_Malloc(ulWidth*ucNumberOfBytesInDest);
|
||||
|
||||
for (y=0;y<ulHeight/2;y++)
|
||||
{
|
||||
memcpy(p_ucOneLine,p_ucDest+y*ulWidth*ucNumberOfBytesInDest,ulWidth*ucNumberOfBytesInDest);
|
||||
memcpy(p_ucDest+y*ulWidth*ucNumberOfBytesInDest,p_ucDest+(ulHeight-1-y)*ulWidth*ucNumberOfBytesInDest,ulWidth*ucNumberOfBytesInDest);
|
||||
memcpy(p_ucDest+(ulHeight-1-y)*ulWidth*ucNumberOfBytesInDest,p_ucOneLine,ulWidth*ucNumberOfBytesInDest);
|
||||
}
|
||||
|
||||
TMP_M_Free(p_ucOneLine);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/**/
|
||||
/* Author David Lassonde*/
|
||||
/* Date 2 Sep 1998*/
|
||||
/* */
|
||||
/* Prototype FIL_fn_vInitGlobalHandleToConcatFiles*/
|
||||
/* Return Type void*/
|
||||
/* */
|
||||
/* Description */
|
||||
/* */
|
||||
/* Initializes the global handle*/
|
||||
/* To be called before textures are loaded (before each map is loaded but also*/
|
||||
/* when the engine initializes (vignettes...)*/
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void FIL_fn_vInitGlobalHandleToFileInConcatFile()
|
||||
{
|
||||
if (FIL_g_hHandleToFileInConcatFile != NULL)/*|| GLI_g_hConcatTexturesFile == NULL)*/
|
||||
return;
|
||||
|
||||
FIL_g_hHandleToFileInConcatFile = (FIL_tdxHandleToFileInConcatFile)TMP_M_p_Malloc(sizeof(FIL_tdstFileInConcatFile));
|
||||
FIL_g_hHandleToFileInConcatFile ->bUseConcatFile = TRUE;
|
||||
|
||||
/* cache initialization*/
|
||||
FIL_g_hHandleToFileInConcatFile ->ulCacheCheckSum = 0;
|
||||
FIL_g_hHandleToFileInConcatFile ->p_ucCache = (unsigned char *)TMP_M_p_Malloc(FIL_C_MaxConcatCacheSize*sizeof(unsigned char));
|
||||
FIL_g_hHandleToFileInConcatFile ->ulCacheSize = FIL_C_MaxConcatCacheSize;
|
||||
FIL_g_hHandleToFileInConcatFile ->ulCacheSeek = FIL_g_hHandleToFileInConcatFile ->ulCacheSize;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/**/
|
||||
/* Author David Lassonde*/
|
||||
/* Date 3 Sep 1998*/
|
||||
/* */
|
||||
/* Prototype FIL_fn_vFreeGlobalHandleToFileInConcatFile*/
|
||||
/* Return Type void*/
|
||||
/* */
|
||||
/* Description */
|
||||
/**/
|
||||
/* Frees the global handle when loading is completed*/
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void FIL_fn_vFreeGlobalHandleToFileInConcatFile()
|
||||
{
|
||||
if (FIL_g_hHandleToFileInConcatFile != NULL)
|
||||
{
|
||||
/* we reset the cache*/
|
||||
FIL_g_hHandleToFileInConcatFile->ulCacheCheckSum = FIL_g_hHandleToFileInConcatFile->ulFileCheckSum;
|
||||
FIL_g_hHandleToFileInConcatFile->ulCacheSize = FIL_C_MaxConcatCacheSize;
|
||||
FIL_g_hHandleToFileInConcatFile->ulCacheSeek = FIL_g_hHandleToFileInConcatFile ->ulCacheSize;
|
||||
FIL_fn_vCloseFileInConcatFile(&FIL_g_hHandleToFileInConcatFile);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vGFLoadInformationFromConcatFile
|
||||
(
|
||||
FIL_tdxHandleToConcatFile hConcatFile,
|
||||
char *p_szPath,
|
||||
char *p_szFileName,
|
||||
FIL_tdstGF *_p_stGF)
|
||||
{
|
||||
FIL_tdxHandleToFileInConcatFile hHandleToFile;
|
||||
struct FIL_tdstFileHeader_ *p_stGFHeader = &(_p_stGF -> stFileHeader);
|
||||
/*VLHorror*/
|
||||
FIL_tdstRealGFFileHeader stGFRealHeader;
|
||||
|
||||
memset( &stGFRealHeader, 0, sizeof( FIL_tdstRealGFFileHeader ) );
|
||||
/*EVL*/
|
||||
|
||||
|
||||
p_stGFHeader->ucBpp = 0;
|
||||
p_stGFHeader->ulWidth = 0;
|
||||
p_stGFHeader->ulHeight = 0;
|
||||
|
||||
if ((hHandleToFile = FIL_fn_hOpenFileInConcatFile(hConcatFile,p_szPath,p_szFileName))!=NULL)
|
||||
{
|
||||
/*VLHorror*/
|
||||
/* read file header*/
|
||||
/*FIL_fn_lReadFileInConcatFile(p_stGFHeader,sizeof(struct FIL_tdstFileHeader_),1,hHandleToFile);*/
|
||||
FIL_fn_lReadFileInConcatFile( &stGFRealHeader, sizeof( FIL_tdstRealGFFileHeader ), 1, hHandleToFile );
|
||||
p_stGFHeader->ulWidth = stGFRealHeader.ulWidth;
|
||||
p_stGFHeader->ulHeight = stGFRealHeader.ulHeight;
|
||||
p_stGFHeader->ucBpp = stGFRealHeader.ucBpp;
|
||||
/*EVL*/
|
||||
|
||||
FIL_fn_vCloseFileInConcatFile(&hHandleToFile);
|
||||
}
|
||||
}
|
37
Rayman_X/cpa/tempgrp/FIL/FIL_GF.h
Normal file
37
Rayman_X/cpa/tempgrp/FIL/FIL_GF.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#if !defined(__FIL_GF_h__)
|
||||
#define __FIL_GF_h__
|
||||
|
||||
/***************************************************************************************
|
||||
*** This Graphic Format is a format used RLE compression on 24 and 32 bits pictures ***
|
||||
*** by using RRRRGGGGBBBB[AAAA] format. The RLE's code is found by scanning picture ***
|
||||
*** and founding the userless bytes. ***
|
||||
*** The GF is generate from BMP or TGA format, then the first line is the last line ***
|
||||
***************************************************************************************/
|
||||
|
||||
/******************************************/
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif /* _MSC_VER >= 1000 */
|
||||
/******************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "CPA_Expt.h"
|
||||
|
||||
#undef EXTERN
|
||||
#undef extern
|
||||
#if !defined(D_FIL_Globals)
|
||||
#define EXTERN extern
|
||||
#else
|
||||
#define EXTERN
|
||||
#endif /* D_FIL_Globals */
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __FIL_GF_h__ */
|
181
Rayman_X/cpa/tempgrp/FIL/FIL_Priv.c
Normal file
181
Rayman_X/cpa/tempgrp/FIL/FIL_Priv.c
Normal file
@@ -0,0 +1,181 @@
|
||||
#if defined(WIN32)
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include "FIL_CPA.h"
|
||||
|
||||
#define D_FIL_StructureDefine
|
||||
#define D_FIL_Globals
|
||||
|
||||
|
||||
#include "FIL_GF.h"
|
||||
#include "FIL_Pub.h"
|
||||
#include "FIL_Priv.h"
|
||||
|
||||
#include "MMG.h"
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bDestroyRecurseDirectory(char *_szFileName)
|
||||
{
|
||||
long hHandle;
|
||||
struct _finddata_t stFindData;
|
||||
char szFileName[_MAX_PATH];
|
||||
|
||||
if ((hHandle=_findfirst(_szFileName,&stFindData))!=-1)
|
||||
{
|
||||
if (stFindData.attrib & _A_SUBDIR)
|
||||
{
|
||||
if (strcmp(stFindData.name,".")&&strcmp(stFindData.name,".."))
|
||||
{
|
||||
strcpy(szFileName,_szFileName);
|
||||
if (strrchr(szFileName,'*'))
|
||||
*strrchr(szFileName,'/') = 0;
|
||||
strcat(szFileName,"/*");
|
||||
FIL_fn_bDestroyRecurseDirectory(szFileName);
|
||||
_rmdir(_szFileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink(_szFileName);
|
||||
}
|
||||
|
||||
while (_findnext(hHandle,&stFindData)!=-1)
|
||||
{
|
||||
if (stFindData.attrib & _A_SUBDIR)
|
||||
{
|
||||
if (strcmp(stFindData.name,".")&&strcmp(stFindData.name,".."))
|
||||
{
|
||||
strcpy(szFileName,_szFileName);
|
||||
if (strrchr(szFileName,'*'))
|
||||
*strrchr(szFileName,'/') = 0;
|
||||
strcat(szFileName,"/");
|
||||
strcat(szFileName,stFindData.name);
|
||||
FIL_fn_bDestroyRecurseDirectory(szFileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(szFileName,_szFileName);
|
||||
if (strrchr(szFileName,'*'))
|
||||
*strrchr(szFileName,'/') = 0;
|
||||
strcat(szFileName,"/");
|
||||
strcat(szFileName,stFindData.name);
|
||||
unlink(szFileName);
|
||||
}
|
||||
}
|
||||
|
||||
_findclose(hHandle);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_TryToInsertFileNameInList(FIL_tdxHandleToFileNameList _hFileNameList,char *_szParentDir,struct _finddata_t *_p_stFindData,unsigned long ulAttrib)
|
||||
{
|
||||
FIL_tdxHandleToFileNameListElement hFileNameListElement=NULL;
|
||||
|
||||
if ( _p_stFindData->attrib&ulAttrib
|
||||
&&strcmp(_p_stFindData->name,".")
|
||||
&&strcmp(_p_stFindData->name,".."))
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeMiscellaneousFile , NULL);
|
||||
hFileNameListElement = (FIL_tdxHandleToFileNameListElement)TMP_M_p_Malloc(sizeof(struct FIL_tdstFileNameListElement_));
|
||||
|
||||
LST2_M_DynamicInitElement(hFileNameListElement);
|
||||
if (_szParentDir[0]!=0)
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeMiscellaneousFile , NULL);
|
||||
hFileNameListElement->szFileName = (char*)TMP_M_p_Malloc(strlen(_szParentDir)+strlen(_p_stFindData->name)+2);
|
||||
sprintf(hFileNameListElement->szFileName,"%s\\%s",_szParentDir,_p_stFindData->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeMiscellaneousFile , NULL);
|
||||
hFileNameListElement->szFileName = (char*)TMP_M_p_Malloc(strlen(_p_stFindData->name)+1);
|
||||
sprintf(hFileNameListElement->szFileName,"%s",_p_stFindData->name);
|
||||
}
|
||||
LST2_M_DynamicAddTail(&_hFileNameList->hFileNameListAnchor,hFileNameListElement);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vSearchInFile(FIL_tdxHandleToFileNameList _hFileNameList,char *_szFileName,unsigned long ulAttrib)
|
||||
{
|
||||
long hHandle;
|
||||
struct _finddata_t stFindData;
|
||||
|
||||
if ((hHandle=_findfirst(_szFileName,&stFindData))!=-1)
|
||||
{
|
||||
FIL_TryToInsertFileNameInList(_hFileNameList,"",&stFindData,ulAttrib);
|
||||
while (_findnext(hHandle,&stFindData)!=-1)
|
||||
FIL_TryToInsertFileNameInList(_hFileNameList,"",&stFindData,ulAttrib);
|
||||
_findclose(hHandle);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vSearchRecurseInFile(FIL_tdxHandleToFileNameList _hFileNameList,char *_szParentDir,char *_szFileName,unsigned long ulAttrib)
|
||||
{
|
||||
char szPath[_MAX_PATH];
|
||||
char szInternalFileName[_MAX_PATH];
|
||||
long hHandle;
|
||||
struct _finddata_t stFindData;
|
||||
|
||||
strcpy(szInternalFileName,_szFileName);
|
||||
if (_szParentDir[0]!=0&&strrchr(szInternalFileName,'\\')!=NULL)
|
||||
{
|
||||
*(strrchr(szInternalFileName,'\\')+1) = 0;
|
||||
strcat(szInternalFileName,_szParentDir);
|
||||
strcat(szInternalFileName,"\\*.*");
|
||||
}
|
||||
else
|
||||
{
|
||||
*(strrchr(szInternalFileName,'\\')) = 0;
|
||||
strcat(szInternalFileName,"\\*.*");
|
||||
}
|
||||
|
||||
if ((hHandle=_findfirst(szInternalFileName,&stFindData))!=-1)
|
||||
{
|
||||
if ( stFindData.attrib&_A_SUBDIR
|
||||
&&strcmp(stFindData.name,".")
|
||||
&&strcmp(stFindData.name,".."))
|
||||
{
|
||||
if (_szParentDir[0]!=0)
|
||||
sprintf(szPath,"%s\\%s",_szParentDir,stFindData.name);
|
||||
else
|
||||
sprintf(szPath,"%s",stFindData.name);
|
||||
FIL_fn_vSearchRecurseInFile(_hFileNameList,szPath,_szFileName,ulAttrib);
|
||||
}
|
||||
while (_findnext(hHandle,&stFindData)!=-1)
|
||||
{
|
||||
if ( stFindData.attrib&_A_SUBDIR
|
||||
&&strcmp(stFindData.name,".")
|
||||
&&strcmp(stFindData.name,".."))
|
||||
{
|
||||
if (_szParentDir[0]!=0)
|
||||
sprintf(szPath,"%s\\%s",_szParentDir,stFindData.name);
|
||||
else
|
||||
sprintf(szPath,"%s",stFindData.name);
|
||||
FIL_fn_vSearchRecurseInFile(_hFileNameList,szPath,_szFileName,ulAttrib);
|
||||
}
|
||||
}
|
||||
_findclose(hHandle);
|
||||
}
|
||||
|
||||
strcpy(szInternalFileName,_szFileName);
|
||||
if (_szParentDir[0]!=0&&strrchr(szInternalFileName,'\\')!=NULL)
|
||||
{
|
||||
*(strrchr(szInternalFileName,'\\')+1) = 0;
|
||||
strcat(szInternalFileName,_szParentDir);
|
||||
strcat(szInternalFileName,strrchr(_szFileName,'\\'));
|
||||
}
|
||||
|
||||
if ((hHandle=_findfirst(szInternalFileName,&stFindData))!=-1)
|
||||
{
|
||||
FIL_TryToInsertFileNameInList(_hFileNameList,_szParentDir,&stFindData,ulAttrib);
|
||||
while (_findnext(hHandle,&stFindData)!=-1)
|
||||
{
|
||||
FIL_TryToInsertFileNameInList(_hFileNameList,_szParentDir,&stFindData,ulAttrib);
|
||||
}
|
||||
_findclose(hHandle);
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
41
Rayman_X/cpa/tempgrp/FIL/FIL_Priv.h
Normal file
41
Rayman_X/cpa/tempgrp/FIL/FIL_Priv.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#if !defined(__FIL_Priv_h__)
|
||||
#define __FIL_Priv_h__
|
||||
|
||||
/******************************************/
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif /* _MSC_VER >= 1000 */
|
||||
/******************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "CPA_Expt.h"
|
||||
|
||||
typedef struct FIL_tdstInternalGeneral_
|
||||
{
|
||||
unsigned char ucDisplayInformation;
|
||||
} FIL_tdstInternalGeneral;
|
||||
|
||||
#undef EXTERN
|
||||
#undef extern
|
||||
#if !defined(D_FIL_Globals)
|
||||
#define EXTERN extern
|
||||
#else
|
||||
#define EXTERN
|
||||
#endif /* D_FIL_Globals */
|
||||
|
||||
unsigned char FIL_fn_bDestroyRecurseDirectory(char *_szFileName);
|
||||
void FIL_TryToInsertFileNameInList(FIL_tdxHandleToFileNameList _hFileNameList,char *_szParentDir,struct _finddata_t *_p_stFindData,unsigned long ulAttrib);
|
||||
void FIL_fn_vSearchInFile(FIL_tdxHandleToFileNameList _hFileNameList,char *_szFileName,unsigned long ulAttrib);
|
||||
void FIL_fn_vSearchRecurseInFile(FIL_tdxHandleToFileNameList _hFileNameList,char *_szParentDir,char *_szFileName,unsigned long ulAttrib);
|
||||
|
||||
EXTERN struct FIL_tdstInternalGeneral_ g_stInternalGeneral;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __FIL_Priv_h__ */
|
203
Rayman_X/cpa/tempgrp/FIL/FIL_Pub.c
Normal file
203
Rayman_X/cpa/tempgrp/FIL/FIL_Pub.c
Normal file
@@ -0,0 +1,203 @@
|
||||
#if defined(WIN32)
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#define D_FIL_VariableDefine
|
||||
|
||||
#include "FIL_CPA.h"
|
||||
|
||||
#include "ErmFil.h"
|
||||
|
||||
#define D_FIL_StructureDefine
|
||||
|
||||
#include "FIL_GF.h"
|
||||
#include "FIL_Pub.h"
|
||||
#include "FIL_Priv.h"
|
||||
|
||||
#include "MMG.h"
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vFirstInit(void)
|
||||
{
|
||||
Erm_M_InitErrMsg(FIL);
|
||||
g_stInternalGeneral.ucDisplayInformation = C_ucErmOpenInfoWindow;
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vDisplayInformationError(unsigned char bValue)
|
||||
{
|
||||
if (bValue)
|
||||
g_stInternalGeneral.ucDisplayInformation = C_ucErmOpenInfoWindow;
|
||||
else
|
||||
g_stInternalGeneral.ucDisplayInformation = C_ucErmNoOpenInfoWindow;
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bDestroyFileOrDirectory(char *_szFileName)
|
||||
{
|
||||
return(FIL_fn_bDestroyRecurseDirectory(_szFileName));
|
||||
}
|
||||
/**************************************************************************/
|
||||
FIL_tdxHandleToFileNameList FIL_fn_hSearchFile(char *_szFileName,unsigned long ulAttrib)
|
||||
{
|
||||
FIL_tdxHandleToFileNameList hFileNameList = NULL;
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeMiscellaneousFile , NULL);
|
||||
hFileNameList = (FIL_tdxHandleToFileNameList)TMP_M_p_Malloc(sizeof(struct FIL_tdstFileNameList_));
|
||||
LST2_M_DynamicInitAnchor(&hFileNameList->hFileNameListAnchor);
|
||||
|
||||
FIL_fn_vSearchInFile(hFileNameList,_szFileName,ulAttrib);
|
||||
|
||||
return(hFileNameList);
|
||||
}
|
||||
/**************************************************************************/
|
||||
FIL_tdxHandleToFileNameList FIL_fn_hSearchRecurseFile(char *_szFileName,unsigned long ulAttrib)
|
||||
{
|
||||
FIL_tdxHandleToFileNameList hFileNameList = NULL;
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeMiscellaneousFile , NULL);
|
||||
hFileNameList = (FIL_tdxHandleToFileNameList)TMP_M_p_Malloc(sizeof(struct FIL_tdstFileNameList_));
|
||||
LST2_M_DynamicInitAnchor(&hFileNameList->hFileNameListAnchor);
|
||||
|
||||
FIL_fn_vSearchRecurseInFile(hFileNameList,"",_szFileName,ulAttrib);
|
||||
|
||||
return(hFileNameList);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vContinueSearchRecurseFile(char *_szFileName,unsigned long ulAttrib,FIL_tdxHandleToFileNameList hFileNameList)
|
||||
{
|
||||
FIL_fn_vSearchRecurseInFile(hFileNameList,"",_szFileName,ulAttrib);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vDestroySearchedFile(FIL_tdxHandleToFileNameList _hFileNameList)
|
||||
{
|
||||
unsigned long i;
|
||||
FIL_tdxHandleToFileNameListElement hFileNameListElement,hNextFileNameListElement;
|
||||
|
||||
LST2_M_DynamicForEachMovingElementOf(&_hFileNameList->hFileNameListAnchor,hFileNameListElement,hNextFileNameListElement,i)
|
||||
{
|
||||
FIL_fn_vDestroyOnElementInFileNameList(hFileNameListElement);
|
||||
}
|
||||
TMP_M_Free(_hFileNameList);
|
||||
}
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vDestroyOnElementInFileNameList(FIL_tdxHandleToFileNameListElement hFileNameListElement)
|
||||
{
|
||||
LST2_M_DynamicIsolate(hFileNameListElement);
|
||||
|
||||
TMP_M_Free(hFileNameListElement->szFileName);
|
||||
TMP_M_Free(hFileNameListElement);
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bIsFileExist(char *_szFileName)
|
||||
{
|
||||
unsigned char bReturn = FALSE;
|
||||
FILE *p_stFile;
|
||||
|
||||
p_stFile = fopen(_szFileName,"rb");
|
||||
if (p_stFile!=NULL)
|
||||
{
|
||||
fclose(p_stFile);
|
||||
bReturn = TRUE;
|
||||
}
|
||||
return(bReturn);
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bIsValidPath(char *_szFileName)
|
||||
{
|
||||
struct _stat stFileInfo;
|
||||
|
||||
return (unsigned char)(!_stat(_szFileName,&stFileInfo));
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned char FIL_fn_bValidatePath(char *_p_szStartPath, char *_p_szFileName)
|
||||
{
|
||||
char a_szCurrentDir[_MAX_PATH];
|
||||
char a_szCompleteFileName[_MAX_PATH];
|
||||
char *p_szCompleteFileName, *p_szTemp;
|
||||
char cMemo1, cMemo2;
|
||||
unsigned char bReturn = TRUE;
|
||||
|
||||
/* Unix style convert */
|
||||
while(strchr(_p_szStartPath, '/'))
|
||||
*strchr(_p_szStartPath,'/') = '\\';
|
||||
while(strchr(_p_szFileName,'/'))
|
||||
*strchr(_p_szFileName,'/') = '\\';
|
||||
|
||||
/* Compute complete name */
|
||||
if(_p_szStartPath[strlen(_p_szStartPath) - 1] == '\\'||_p_szStartPath[0]==0)
|
||||
sprintf(a_szCompleteFileName, "%s%s", _p_szStartPath, _p_szFileName);
|
||||
else
|
||||
sprintf(a_szCompleteFileName, "%s\\%s", _p_szStartPath, _p_szFileName);
|
||||
|
||||
p_szCompleteFileName = strrchr(a_szCompleteFileName,'\\');
|
||||
*p_szCompleteFileName = 0;
|
||||
/* test if the directory already exist */
|
||||
if (_access(a_szCompleteFileName,0x00)==-1)
|
||||
{
|
||||
*p_szCompleteFileName = '\\';
|
||||
p_szCompleteFileName = a_szCompleteFileName;
|
||||
|
||||
/* Get current directory to restore it at the end of the analyse */
|
||||
getcwd(a_szCurrentDir, _MAX_PATH);
|
||||
|
||||
/* Is it an absolute path ? */
|
||||
if(p_szCompleteFileName[0] && p_szCompleteFileName[1] == ':')
|
||||
{
|
||||
cMemo1 = p_szCompleteFileName[2];
|
||||
p_szCompleteFileName[2] = '\\';
|
||||
cMemo2 = p_szCompleteFileName[3];
|
||||
p_szCompleteFileName[3] = '\0';
|
||||
|
||||
if(chdir(p_szCompleteFileName) == -1)
|
||||
{
|
||||
bReturn = FALSE;
|
||||
}
|
||||
p_szCompleteFileName[2] = cMemo1;
|
||||
p_szCompleteFileName[3] = cMemo2;
|
||||
}
|
||||
|
||||
/* Get and create directories */
|
||||
while(bReturn&&(p_szTemp = strchr(p_szCompleteFileName,'\\')) != NULL)
|
||||
{
|
||||
*p_szTemp = '\0';
|
||||
if(*p_szCompleteFileName != '\0')
|
||||
{
|
||||
if(chdir(p_szCompleteFileName) == -1)
|
||||
{
|
||||
mkdir(p_szCompleteFileName);
|
||||
if(chdir(p_szCompleteFileName) == -1)
|
||||
{
|
||||
bReturn = FALSE;
|
||||
}
|
||||
}
|
||||
p_szCompleteFileName += strlen(p_szCompleteFileName) + 1;
|
||||
*p_szTemp = '\\';
|
||||
}
|
||||
else
|
||||
chdir("\\");
|
||||
}
|
||||
if(chdir(a_szCurrentDir) == -1)
|
||||
{
|
||||
bReturn = FALSE;
|
||||
}
|
||||
}
|
||||
return(bReturn);
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned long FIL_fn_ulGetNumberOfFiles(FIL_tdxHandleToFileNameList hHandleToFileNameList)
|
||||
{
|
||||
return(LST2_M_DynamicGetNumberOfElements(&hHandleToFileNameList->hFileNameListAnchor));
|
||||
}
|
||||
/**************************************************************************/
|
||||
unsigned long FIL_fn_ulGetFileSize(char *_szFileName)
|
||||
{
|
||||
unsigned long ulReturn = 0;
|
||||
int fh;
|
||||
|
||||
if( (fh = open(_szFileName, _O_BINARY|_O_RDONLY,_S_IREAD)) != -1 )
|
||||
{
|
||||
ulReturn = filelength(fh);
|
||||
close(fh);
|
||||
}
|
||||
return(ulReturn);
|
||||
}
|
||||
/**************************************************************************/
|
281
Rayman_X/cpa/tempgrp/FIL/FIL_Tga.c
Normal file
281
Rayman_X/cpa/tempgrp/FIL/FIL_Tga.c
Normal file
@@ -0,0 +1,281 @@
|
||||
#if defined(WIN32)
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include "FIL_CPA.h"
|
||||
|
||||
#define D_FIL_StructureDefine
|
||||
|
||||
#include "ErmFil.h"
|
||||
|
||||
#include "FIL_Pub.h"
|
||||
#include "FIL_Priv.h"
|
||||
|
||||
#include "FIL_Tga.h"
|
||||
|
||||
#include "MMG.h"
|
||||
|
||||
/**************************************************************************/
|
||||
/*
|
||||
EXTERN CPA_EXPORT void FIL_fn_vTGASaveInFile(char *p_szFileName, unsigned char ucNumberOfBytesInSource, FIL_tdstBitmapData *_p_stSource )
|
||||
{
|
||||
}
|
||||
*/
|
||||
/**************************************************************************/
|
||||
FILE *FIL_fn_hTGAOpenFile( char *_p_szPath, char *_p_szFileName, FIL_tdstTga *_p_stTga )
|
||||
{
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
FILE *p_stFile;
|
||||
char szCompleteName[_MAX_PATH];
|
||||
unsigned char ucBpp, ucDesc, ucCode;
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
if ( *_p_szPath != 0)
|
||||
sprintf(szCompleteName, "%s\\%s", _p_szPath, _p_szFileName);
|
||||
else
|
||||
sprintf(szCompleteName,"%s", _p_szFileName);
|
||||
|
||||
if ( (p_stFile = fopen(szCompleteName,"rb")) !=NULL)
|
||||
{
|
||||
fread(&_p_stTga->stFileHeader,sizeof(struct FIL_tdstTgaFileHeader_),1,p_stFile);
|
||||
ucBpp = _p_stTga->stFileHeader.stImageSpecification.ucPixelSize;
|
||||
ucDesc = _p_stTga->stFileHeader.stImageSpecification.ucDescriptorByte;
|
||||
ucCode = _p_stTga->stFileHeader.ucImageTypeCode;
|
||||
|
||||
if (
|
||||
( ucBpp != 24 || ucDesc != 0 ) && ( ucBpp != 32 || ( ucDesc != 0 && ucDesc != 8) ) && ( ucBpp!=8 || ( ucDesc != 0 && ucDesc != 8) )
|
||||
||( ucCode !=1 &&ucCode!=2 && ucCode != 3 && ucCode != 10)
|
||||
)
|
||||
{
|
||||
M_FILInformationErrorWithMessage(E_uwFILBadTgaFormat, szCompleteName);
|
||||
fclose( p_stFile );
|
||||
p_stFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return p_stFile;
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vTGALoadInformationFromFile(char *p_szPath,char *p_szFileName, struct FIL_tdstGF_ *_p_stHeader )
|
||||
{
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
FILE *p_stFile;
|
||||
struct FIL_tdstTga_ stTga;
|
||||
struct FIL_tdstFileHeader_ *p_stFileHeader = &(_p_stHeader -> stFileHeader);
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
p_stFile = FIL_fn_hTGAOpenFile( p_szPath, p_szFileName, &stTga );
|
||||
if (p_stFile == NULL)
|
||||
{
|
||||
p_stFileHeader->ucBpcInPalette = 0;
|
||||
p_stFileHeader->ucBpp = 0;
|
||||
p_stFileHeader->ulWidth = 0;
|
||||
p_stFileHeader->ulHeight = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
p_stFileHeader->ulWidth = (unsigned long)stTga.stFileHeader.stImageSpecification.uwWidth;
|
||||
p_stFileHeader->ulHeight = (unsigned long)stTga.stFileHeader.stImageSpecification.uwHeight;
|
||||
p_stFileHeader->ucBpp = (unsigned char)(stTga.stFileHeader.stImageSpecification.ucPixelSize/8);
|
||||
p_stFileHeader->ucBpcInPalette = (unsigned char)(stTga.stFileHeader.stColorMapSpecification.ucEntrySize/8);
|
||||
/*
|
||||
if (stTga.stFileHeader.ucImageTypeCode==1) //*** No compression in palette ***
|
||||
{
|
||||
//VL
|
||||
//*p_ucNumberOfBytesInDest = (unsigned char)(stTga.stFileHeader.stColorMapSpecification.ucEntrySize/8);
|
||||
*p_ucNumberOfBytesInDest = (unsigned char)(stTga.stFileHeader.stImageSpecification.ucPixelSize/8);
|
||||
*p_ucPaletteDepth = (unsigned char)(stTga.stFileHeader.stColorMapSpecification.ucEntrySize/8);
|
||||
//EVL
|
||||
}
|
||||
else if (stTga.stFileHeader.ucImageTypeCode==3) //*** No compression 8 bits (gray levels) ***
|
||||
*p_ucNumberOfBytesInDest = 3;
|
||||
else
|
||||
*p_ucNumberOfBytesInDest = (unsigned char)(stTga.stFileHeader.stImageSpecification.ucPixelSize/8);
|
||||
*/
|
||||
fclose(p_stFile);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
#ifndef RETAIL
|
||||
void FIL_fn_vTGALoadFromFileWithInvertPicture(char *p_szPath,char *p_szFileName, FIL_tdstGF *_p_stHeader )
|
||||
{
|
||||
FIL_fn_vTGALoadFromFileWithoutInvertPicture(p_szPath, p_szFileName, _p_stHeader );
|
||||
if ( _p_stHeader->p_ucBitMap != NULL )
|
||||
FIL_fn_vTGAInvert( _p_stHeader );
|
||||
}
|
||||
#endif /*RETAIL*/
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vTGALoadFromFileWithoutInvertPicture(char *p_szPath, char *p_szFileName, FIL_tdstGF *_p_stHeader)
|
||||
{
|
||||
FILE *p_stFile;
|
||||
struct FIL_tdstTga_ stTga;
|
||||
unsigned long i,j;
|
||||
unsigned char ucCount;
|
||||
unsigned char ucColorTable[4]; /**** RGBA ****/
|
||||
unsigned long ulBitmapSize;
|
||||
struct FIL_tdstFileHeader_ *p_stFileHeader = &(_p_stHeader -> stFileHeader);
|
||||
|
||||
|
||||
stTga.p_ucBitMap = NULL;
|
||||
stTga.ucColorMapData = NULL;
|
||||
memset( _p_stHeader, 0, sizeof( FIL_tdstGF ) );
|
||||
|
||||
p_stFile = FIL_fn_hTGAOpenFile( p_szPath, p_szFileName, &stTga );
|
||||
if (p_stFile == NULL)
|
||||
return;
|
||||
p_stFileHeader->ulWidth = (unsigned long)stTga.stFileHeader.stImageSpecification.uwWidth;
|
||||
p_stFileHeader->ulHeight = (unsigned long)stTga.stFileHeader.stImageSpecification.uwHeight;
|
||||
p_stFileHeader->ucBpp = (unsigned char)(stTga.stFileHeader.stImageSpecification.ucPixelSize/8);
|
||||
p_stFileHeader->ucBpcInPalette = (unsigned char)(stTga.stFileHeader.stColorMapSpecification.ucEntrySize/8);
|
||||
p_stFileHeader->uwNbColorInPalette = stTga.stFileHeader.stColorMapSpecification.uwLength;
|
||||
|
||||
ulBitmapSize = p_stFileHeader->ulWidth * p_stFileHeader->ulHeight * p_stFileHeader->ucBpp;
|
||||
|
||||
if (stTga.stFileHeader.ucImageTypeCode==1) /**** No compression in palette ****/
|
||||
{
|
||||
if ( p_stFileHeader->ucBpp != 1 || p_stFileHeader->ucBpcInPalette != 3)
|
||||
{
|
||||
char szCompleteName[MAX_PATH];
|
||||
sprintf( szCompleteName, "%s\\%s", p_szPath, p_szFileName );
|
||||
M_FILInformationErrorWithMessage( E_uwFILBadTgaFormat, szCompleteName);
|
||||
}
|
||||
else
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeTgaFile , NULL);
|
||||
stTga.p_ucBitMap = (unsigned char *) TMP_M_p_Malloc (max(ulBitmapSize, p_stFileHeader->uwNbColorInPalette * sizeof(RGBQUAD)) );
|
||||
|
||||
fseek(p_stFile, sizeof(struct FIL_tdstTgaFileHeader_) + stTga.stFileHeader.ucNumberOfCharInIdentField, SEEK_SET);
|
||||
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeTgaFile , NULL);
|
||||
stTga.ucColorMapData = (unsigned char *) TMP_M_p_Malloc ( p_stFileHeader->uwNbColorInPalette * sizeof(RGBQUAD) );
|
||||
/*fread( stTga.ucColorMapData, p_stFileHeader->ucBpcInPalette, p_stFileHeader->uwNbColorInPalette, p_stFile);*/
|
||||
/* We first put the colormap in the bitmap field, then we convert it into the colormap field */
|
||||
fread( stTga.p_ucBitMap, p_stFileHeader->ucBpcInPalette, p_stFileHeader->uwNbColorInPalette, p_stFile);
|
||||
for (i=0 ; i<p_stFileHeader->uwNbColorInPalette ; i++)
|
||||
{
|
||||
stTga.ucColorMapData[i*sizeof(RGBQUAD)+0] = stTga.p_ucBitMap[i*p_stFileHeader->ucBpcInPalette + 0];
|
||||
stTga.ucColorMapData[i*sizeof(RGBQUAD)+1] = stTga.p_ucBitMap[i*p_stFileHeader->ucBpcInPalette + 1];
|
||||
stTga.ucColorMapData[i*sizeof(RGBQUAD)+2] = stTga.p_ucBitMap[i*p_stFileHeader->ucBpcInPalette + 2];
|
||||
stTga.ucColorMapData[i*sizeof(RGBQUAD)+3] = 0xff;
|
||||
}
|
||||
/* Then we read the bitmap */
|
||||
fread( stTga.p_ucBitMap, 1, ulBitmapSize, p_stFile);
|
||||
/*TMP_M_Free(stTga.ucColorMapData);*/
|
||||
}
|
||||
}
|
||||
else if (stTga.stFileHeader.ucImageTypeCode == 2) /**** No compression 24 or 32 bits ****/
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeTgaFile , NULL);
|
||||
stTga.p_ucBitMap = (unsigned char *) TMP_M_p_Malloc( ulBitmapSize );
|
||||
fseek(p_stFile, sizeof(struct FIL_tdstTgaFileHeader_) + stTga.stFileHeader.ucNumberOfCharInIdentField + stTga.stFileHeader.stColorMapSpecification.uwLength, SEEK_SET);
|
||||
fread(stTga.p_ucBitMap, 1, ulBitmapSize, p_stFile);
|
||||
}
|
||||
else if (stTga.stFileHeader.ucImageTypeCode == 3) /**** No compression 8 bits (gray levels) ****/
|
||||
{
|
||||
p_stFileHeader->ucBpp = 3;
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeTgaFile , NULL);
|
||||
stTga.p_ucBitMap = (unsigned char *) TMP_M_p_Malloc( ulBitmapSize );
|
||||
fseek(p_stFile, sizeof(struct FIL_tdstTgaFileHeader_) + stTga.stFileHeader.ucNumberOfCharInIdentField + stTga.stFileHeader.stColorMapSpecification.uwLength, SEEK_SET);
|
||||
for(i=0;i < p_stFileHeader->ulWidth * p_stFileHeader->ulHeight ; i++)
|
||||
{
|
||||
fread(&ucCount,sizeof(unsigned char),1,p_stFile);
|
||||
memset(stTga.p_ucBitMap + i * p_stFileHeader->ucBpp , ucCount, p_stFileHeader->ucBpp);
|
||||
}
|
||||
|
||||
}
|
||||
else if (stTga.stFileHeader.ucImageTypeCode==10) /**** RLE compression 24 or 32 bits ****/
|
||||
{
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeTgaFile , NULL);
|
||||
stTga.p_ucBitMap = (unsigned char *)TMP_M_p_Malloc( ulBitmapSize );
|
||||
fseek(p_stFile, sizeof(struct FIL_tdstTgaFileHeader_) +stTga.stFileHeader.ucNumberOfCharInIdentField +stTga.stFileHeader.stColorMapSpecification.uwLength, SEEK_SET);
|
||||
for(i=0;i < p_stFileHeader->ulWidth * p_stFileHeader->ulHeight ;)
|
||||
{
|
||||
fread(&ucCount,sizeof(unsigned char),1,p_stFile);
|
||||
if (ucCount&0x80) /**** RLE package ****/
|
||||
{
|
||||
ucCount = (unsigned char)((ucCount&0x7f)+1);
|
||||
fread(ucColorTable,sizeof(unsigned char), p_stFileHeader->ucBpp, p_stFile);
|
||||
for (j=0;j<(unsigned long)ucCount;j++)
|
||||
{
|
||||
memcpy(stTga.p_ucBitMap+i * p_stFileHeader->ucBpp, ucColorTable, p_stFileHeader->ucBpp );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else /**** Raw package ****/
|
||||
{
|
||||
ucCount = (unsigned char)((ucCount&0x7f)+1);
|
||||
for (j=0;j<(unsigned long)ucCount;j++)
|
||||
{
|
||||
fread(ucColorTable,sizeof(unsigned char),p_stFileHeader->ucBpp,p_stFile);
|
||||
memcpy(stTga.p_ucBitMap+i*p_stFileHeader->ucBpp,ucColorTable,p_stFileHeader->ucBpp);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(p_stFile);
|
||||
_p_stHeader->p_ucBitMap = stTga.p_ucBitMap;
|
||||
_p_stHeader->p_ucPalette = stTga.ucColorMapData;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vTGALoadInformationFromConcatFile(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFileName, struct FIL_tdstGF_ *_p_stHeader)
|
||||
{
|
||||
FIL_fn_vTGALoadInformationFromFile(p_szPath,p_szFileName, _p_stHeader );
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vTGALoadFromConcatFileWithInvertPicture(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFileName, struct FIL_tdstGF_ *_p_stHeader )
|
||||
{
|
||||
FIL_fn_vTGALoadFromConcatFileWithoutInvertPicture(hConcatFile, p_szPath, p_szFileName, _p_stHeader);
|
||||
if ( _p_stHeader->p_ucBitMap != NULL)
|
||||
FIL_fn_vTGAInvert( _p_stHeader );
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vTGALoadFromConcatFileWithoutInvertPicture(FIL_tdxHandleToConcatFile hConcatFile,char *p_szPath,char *p_szFileName,struct FIL_tdstGF_ *_p_stHeader )
|
||||
{
|
||||
FIL_fn_vTGALoadFromFileWithoutInvertPicture(p_szPath,p_szFileName,_p_stHeader);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vTGAFree( unsigned char **pp_ucMemory )
|
||||
{
|
||||
if (*pp_ucMemory!=NULL)
|
||||
TMP_M_Free(*pp_ucMemory);
|
||||
|
||||
*pp_ucMemory = NULL;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void FIL_fn_vTGAInvert( struct FIL_tdstGF_ *_p_stHeader )
|
||||
{
|
||||
unsigned char *p_ucOneLine,*p_ucBlockStart;
|
||||
unsigned long y, ulLineSize;
|
||||
struct FIL_tdstFileHeader_ *p_stFileHeader = &(_p_stHeader -> stFileHeader);
|
||||
|
||||
MMG_fn_vAddMemoryInfo (MMG_C_lTypeFile , MMG_C_lSubTypeTgaFile , NULL);
|
||||
ulLineSize = p_stFileHeader->ulWidth * p_stFileHeader->ucBpp;
|
||||
p_ucOneLine = (unsigned char *) TMP_M_p_Malloc ( ulLineSize );
|
||||
|
||||
p_ucBlockStart = _p_stHeader->p_ucBitMap;
|
||||
/* GuS : palette is now stored into the filed ucColorMapData
|
||||
if(p_stFileHeader->ucBpp == 1)
|
||||
{
|
||||
p_ucBlockStart += 256 * sizeof(RGBQUAD);
|
||||
}
|
||||
*/
|
||||
for (y=0; y < p_stFileHeader->ulHeight / 2 ; y++)
|
||||
{
|
||||
memcpy( p_ucOneLine , p_ucBlockStart + y * ulLineSize , ulLineSize);
|
||||
memcpy( p_ucBlockStart + y * ulLineSize , p_ucBlockStart+(p_stFileHeader->ulHeight - 1 - y) * ulLineSize, ulLineSize);
|
||||
memcpy( p_ucBlockStart + (p_stFileHeader->ulHeight - 1 - y) * ulLineSize, p_ucOneLine , ulLineSize);
|
||||
}
|
||||
|
||||
TMP_M_Free(p_ucOneLine);
|
||||
}
|
||||
/**************************************************************************/
|
62
Rayman_X/cpa/tempgrp/FIL/FIL_Tga.h
Normal file
62
Rayman_X/cpa/tempgrp/FIL/FIL_Tga.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#if !defined(__FIL_Tga_h__)
|
||||
#define __FIL_Tga_h__
|
||||
|
||||
/******************************************/
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif /* _MSC_VER >= 1000 */
|
||||
/******************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "CPA_Expt.h"
|
||||
|
||||
#undef EXTERN
|
||||
#undef extern
|
||||
#if !defined(D_FIL_Globals)
|
||||
#define EXTERN extern
|
||||
#else
|
||||
#define EXTERN
|
||||
#endif /* D_FIL_Globals */
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef struct FIL_tdstTgaFileHeader_
|
||||
{
|
||||
unsigned char ucNumberOfCharInIdentField;
|
||||
unsigned char ucColorMapType;
|
||||
unsigned char ucImageTypeCode;
|
||||
struct
|
||||
{
|
||||
unsigned short uwOrigin;
|
||||
unsigned short uwLength;
|
||||
unsigned char ucEntrySize;
|
||||
} stColorMapSpecification;
|
||||
struct
|
||||
{
|
||||
unsigned short uwXOrigin;
|
||||
unsigned short uwYOrigin;
|
||||
unsigned short uwWidth;
|
||||
unsigned short uwHeight;
|
||||
unsigned char ucPixelSize;
|
||||
unsigned char ucDescriptorByte;
|
||||
} stImageSpecification;
|
||||
} FIL_tdstTgaFileHeader;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct FIL_tdstTga_
|
||||
{
|
||||
struct FIL_tdstTgaFileHeader_ stFileHeader;
|
||||
|
||||
unsigned char *szIdentificationField;
|
||||
unsigned char *ucColorMapData;
|
||||
unsigned char *p_ucBitMap;
|
||||
} FIL_tdstTga;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __FIL_Tga_h__ */
|
9
Rayman_X/cpa/tempgrp/FIL/FIL_Ver.h
Normal file
9
Rayman_X/cpa/tempgrp/FIL/FIL_Ver.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/******************************************/
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif /* _MSC_VER >= 1000 */
|
||||
/******************************************/
|
||||
|
||||
#define C_szFILVersion "FIL V5.1.0" /* The format is XXX Va.b.c with Xxx is the Tag of the module */
|
||||
#define C_szFILFullName "Files and paths management" /* the complete and clear name of the module */
|
||||
#define C_szFILDate "Nov 18 1997" /* The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/
|
5
Rayman_X/cpa/tempgrp/FIL/mssccprj.scc
Normal file
5
Rayman_X/cpa/tempgrp/FIL/mssccprj.scc
Normal file
@@ -0,0 +1,5 @@
|
||||
SCC = This is a source code control file
|
||||
|
||||
[FIL.vcproj]
|
||||
SCC_Aux_Path = "P4SCC#srvperforce-ma:1666##raymandata##Editor"
|
||||
SCC_Project_Name = Perforce Project
|
Reference in New Issue
Block a user