例如伏魔记
(数据是可以用c直接读取的)
0x0 :lib
0x3 伏魔记 00 0
0x0E 全局色彩字节数: 2或4,建议选择4
0x0F 非零有压缩,0无压缩,建议选择有压缩1
0x10开始 三字节索引(与lib一致索引)(unsigned char resType ,unsigned char type ,unsigned char index) ...;
(数据是可以用c直接读取的)
0x0 :lib
0x3 伏魔记 00 0
0x0E 全局色彩字节数: 2或4,建议选择4
0x0F 非零有压缩,0无压缩,建议选择有压缩1
0x10开始 三字节索引(与lib一致索引)(unsigned char resType ,unsigned char type ,unsigned char index) ...;
0x2000 开始 四字节地址(相对文件头偏移) (unsigned int mDataOffset)...
typedef struct GMCheadstru{char ckHeadstr[3];//校验GMC
char gamename[9];//游戏名
unsigned short sizeofIndexArea;//索引区域大小
unsigned char sizeofPixcel;// 像素字节数
unsigned char isComressed;//非零为有deflate压缩,0为无压缩
} GMChead; //16字节信息头
GMChead myGMChead;
typedef struct GMCIndexStru{unsigned char resType ;unsigned char objType;unsigned char index;}GMCIndex;
GMCIndex AllGMCIndex[2726]; //与lib一致的索引,0x10开始, (0x2000-16)的索引空间最多2725个资源
unsigned int AllGMCAddr[2725];//地址是真实地址,0x2000开始
初始化读取如下:
FILE* file;
/* 装载源文件数据到缓冲区 */
if((file = fopen("dat.gmc", "rb")) == NULL)
{
printf("Can\'t open %s!\n", "dat.gmc");
return -1;
}
// 测试文件头
fread(&myGMChead,16,1,file);
char testStr[4];
memset (testStr,0,4);
memcpy(testStr,myGMChead.ckHeadstr,3);
if(stricmp(testStr,"GMC")){
printf("不是有效GMC文件\n", argv[1]);
return -1;
}
//判断像素字节大小
if(myGMChead.sizeofPixcel!=4){
printf("不支持的像素字节数 status:%d","");
return -1;
}
//读取索引和地址
fseek(file,16,SEEK_SET);
fread(&AllGMCIndex,0x2000-16,1,file);
fseek(file,0X2000,SEEK_SET);
fread(&AllGMCAddr,2725<<2,1,file);