⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resfile.h

📁 一个3D的保龄球的源代码
💻 H
字号:
/*
* ============================================================================
*  Name     : CResFile from ResFile.h
*  Part of  : Game
*  Created  : 2003-06-16 by Qiu Wei Min
*  Description:
*     Resource store for game.
*  Version  :
*  Copyright: Gameloft S.A.
*
*  Port from symbian to Brew LG6000 to use old pack tool. 
* ============================================================================
*/

#ifndef RESFILE_H
#define RESFILE_H

#include "aeefile.h"
#include "engine.h"
class CEngine;

#ifndef UInt32
#ifdef _LZMA_UINT32_IS_ULONG
#define UInt32 unsigned long
#else
#define UInt32 unsigned int
#endif
#endif

#ifndef Byte
#define Byte unsigned char
#endif



//##ModelId=402850A502CB
class CResFile
{
public:
	//##ModelId=402850A5030D
	bool Read(void* hRecord, void* pBuf, int len = -1, int ofs = 0);
	//##ModelId=402850A5030B
	int GetRecordSize(void* hRecord);
	//##ModelId=402850A50301
	int GetDecompressedSize(void *hRecord);
	//##ModelId=402850A502FF
	void* ReadToStack(void* hRecord);
	//##ModelId=402850A502FC
	void* ReadBMPToHeap(void *hRecord, bool bGlobal);
	//##ModelId=402850A502FA
	unsigned long ComputeHash(const char *s);
	//##ModelId=402850A502F5
	void* FindRecord(const char *name);
	//##ModelId=402850A502F3
	bool Open(const char *fn);
	int LoadFileToStack(const char *fName, void **pData);
	
	enum {
		MAX_ENTRY = 100
	};

	struct PakEntry{
		unsigned long nameHash; // hashValue of fileName.
		unsigned long start;	//*4 is the start address.
		unsigned long len;
	};

	struct Pak{
		long nPak;
		struct PakEntry aPak[1];
	} ;

	typedef struct FileIO{
		char isPaked	;
		char foo1,foo2,foo3;
		struct Pak *pak;
	} FileIO;

	//##ModelId=402850A502F1
	CResFile(CEngine *pEngine);
	//##ModelId=402850A502F0
	virtual ~CResFile();

protected:
	//RESENTRY m_entry[MAX_ENTRY];
	//##ModelId=402850A502EF
	int m_nEntry;
	//##ModelId=402850A502EC
	FileIO m_f;
	//##ModelId=402850A502E7
	IFile *m_handle;
	//##ModelId=402850A502E2
	CEngine *m_pEngine;
	//##ModelId=402850A502DD
	//CZLibBrew* m_pZlib;
	////lzma start
	typedef struct _CRangeDecoder
{
  Byte *Buffer;
  Byte *BufferLim;
  UInt32 Range;
  UInt32 Code;
  #ifdef _LZMA_IN_CB
  ILzmaInCallback *InCallback;
  int Result;
  #endif
  int ExtraBytes;
} CRangeDecoder;

	#ifndef UInt32
	#ifdef _LZMA_UINT32_IS_ULONG
	#define UInt32 unsigned long
	#else
	#define UInt32 unsigned int
	#endif
	#endif

	#ifdef _LZMA_PROB32
	#define CProb UInt32
	#else
	#define CProb unsigned short
	#endif

	#define LZMA_RESULT_OK 0
	#define LZMA_RESULT_DATA_ERROR 1
	#define LZMA_RESULT_NOT_ENOUGH_MEM 2

	#ifdef _LZMA_IN_CB
	typedef struct _ILzmaInCallback
	{
	  int (*Read)(void *object, unsigned char **buffer, UInt32 *bufferSize);
	} ILzmaInCallback;
	#endif

	#define LZMA_BASE_SIZE 1846
	#define LZMA_LIT_SIZE 768

	/* 
	bufferSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)))* sizeof(CProb)
	bufferSize += 100 in case of _LZMA_OUT_READ
	by default CProb is unsigned short, 
	but if specify _LZMA_PROB_32, CProb will be UInt32(unsigned int)
	*/

	#ifdef _LZMA_OUT_READ
	int LzmaDecoderInit(
		unsigned char *buffer, UInt32 bufferSize,
		int lc, int lp, int pb,
		unsigned char *dictionary, UInt32 dictionarySize,
	  #ifdef _LZMA_IN_CB
		ILzmaInCallback *inCallback
	  #else
		unsigned char *inStream, UInt32 inSize
	  #endif
	);
	#endif

	int LzmaDecode(
		unsigned char *buffer, 
	  #ifndef _LZMA_OUT_READ
		UInt32 bufferSize,
		int lc, int lp, int pb,
	  #ifdef _LZMA_IN_CB
		ILzmaInCallback *inCallback,
	  #else
		unsigned char *inStream, UInt32 inSize,
	  #endif
	  #endif
		unsigned char *outStream, UInt32 outSize,
		UInt32 *outSizeProcessed,
		IShell *pShell
		);
	Byte RangeDecoderReadByte(CRangeDecoder *rd);

	Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd);
	void RangeDecoderInit(CRangeDecoder *rd,
	  #ifdef _LZMA_IN_CB
		ILzmaInCallback *inCallback
	  #else
		Byte *stream, UInt32 bufferSize
	  #endif
    );
	UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits);
	int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd);
	int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd);
	int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd);

	Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte);
	int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState);
	///lzma end
};

#endif

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -