当前位置: 首页>>代码示例>>C++>>正文


C++ EMUFILE_MEMORY::truncate方法代码示例

本文整理汇总了C++中EMUFILE_MEMORY::truncate方法的典型用法代码示例。如果您正苦于以下问题:C++ EMUFILE_MEMORY::truncate方法的具体用法?C++ EMUFILE_MEMORY::truncate怎么用?C++ EMUFILE_MEMORY::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EMUFILE_MEMORY的用法示例。


在下文中一共展示了EMUFILE_MEMORY::truncate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadStateEmbed

int LoadStateEmbed(char *file) {
	GPUFreeze_t *gpufP;
	int Size;
	char header[32];
	FILE* fp;
	FILE* fp2;
	uint8 * embSaveTmp;
	size_t blockSize = Movie.memoryCard1Offset-Movie.saveStateOffset;

	embSaveTmp = (uint8*)malloc(blockSize);
	fp = fopen(file,"rb");
	fp2 = fopen("embsave.tmp","wb");
	fseek(fp, Movie.saveStateOffset, SEEK_SET);
	fread(embSaveTmp, 1, blockSize, fp);
	fwrite(embSaveTmp, 1, blockSize, fp2);
	fclose(fp);
	fclose(fp2);

	EMUFILE_FILE ef("embsave.tmp", "rb");
	if (ef.fail()) return -1;
	EMUFILE *f = &ef;

	psxCpu->Reset();

	gzread(f, header, 32);

	if (strncmp("STv3 PSXjin", header, 9)) { return -1; }

	exceptionPatches.clear();
	int tag;
	gzread(f, &tag, 4);
	if (tag == 'ExPs') {
		gzread(f, &Size, 4);
		while (Size--) {
			u32 addr, val;
			gzread(f, &addr, 4);
			gzread(f, &val, 4);
			exceptionPatches.push_back(std::make_pair(addr, val));
		}
		gzseek(f, 128*96*3-4-4-exceptionPatches.size()*4*2, SEEK_CUR);
	}
	else
		gzseek(f, 128*96*3-4, SEEK_CUR);

	gzread(f, psxM, 0x00200000);
	gzread(f, psxP, 0x00010000);
	gzread(f, psxR, 0x00080000);
	gzread(f, psxH, 0x00010000);
	gzread(f, (void*)&psxRegs, sizeof(psxRegs));

	if (Config.HLE)	//adelikat: TODO: remove all references to Config.HLE, we will not be using that BIOS, ever
		psxBiosFreeze(0);

	// gpu
	gpufP = (GPUFreeze_t *) malloc (sizeof(GPUFreeze_t));
	gzread(f, gpufP, sizeof(GPUFreeze_t));
	gpufP->extraData = malloc(gpufP->extraDataSize);
	gzread(f, gpufP->extraData, gpufP->extraDataSize);
	GPUfreeze(0, gpufP);
	free(gpufP->extraData);
	free(gpufP);

	sioFreeze(f, 0);
	cdrFreeze(f, 0);
	psxHwFreeze(f, 0);
	CDRisoFreeze(f,0);
	psxRcntFreeze(f, 0);
	mdecFreeze(f, 0);
	//TODO - no movie state? are you sure?

	// spu
	gzread(f, &Size, 4);
	EMUFILE_MEMORY memfile;
	memfile.truncate(Size);
	gzread(f, memfile.buf(), Size);
	bool ok = SPUunfreeze_new(&memfile);
	if(!ok) return 1;

	remove("embsave.tmp");

	return 0;
}
开发者ID:Nitrofski,项目名称:psxjin,代码行数:82,代码来源:Misc.cpp

示例2: LoadStateEmufile

int LoadStateEmufile(EMUFILE *f) {
	GPUFreeze_t *gpufP;
	int Size;
	char header[32];

	printf("loadstate---\n");

	psxCpu->Reset();

	gzread(f, header, 32);
	if (strncmp("STv3 PSXjin", header, 9)) { return -1; }

	exceptionPatches.clear();
	int tag;
	gzread(f, &tag, 4);
	if (tag == 'ExPs') {
		gzread(f, &Size, 4);
		while (Size--) {
			u32 addr, val;
			gzread(f, &addr, 4);
			gzread(f, &val, 4);
			exceptionPatches.push_back(std::make_pair(addr, val));
		}
		gzseek(f, 128*96*3-4-4-exceptionPatches.size()*4*2, SEEK_CUR);
	}
	else
		gzseek(f, 128*96*3-4, SEEK_CUR);

	gzread(f, psxM, 0x00200000);
	gzread(f, psxP, 0x00010000);
	gzread(f, psxR, 0x00080000);
	gzread(f, psxH, 0x00010000);
	gzread(f, (void*)&psxRegs, sizeof(psxRegs));

	if (Config.HLE)
		psxBiosFreeze(0);

	// gpu
	gpufP = (GPUFreeze_t *) malloc (sizeof(GPUFreeze_t));
	gzread(f, gpufP, sizeof(GPUFreeze_t));
	gpufP->extraData = malloc(gpufP->extraDataSize);
	gzread(f, gpufP->extraData, gpufP->extraDataSize);
	GPUfreeze(0, gpufP);
	free(gpufP->extraData);
	free(gpufP);

	sioFreeze(f, 0);
	cdrFreeze(f, 0);
	psxHwFreeze(f, 0);
	CDRisoFreeze(f,0);
	psxRcntFreeze(f, 0);
	mdecFreeze(f, 0);
	PadFreeze(f, 0);
	MovieFreeze(f, 0);

	// spu
	gzread(f, &Size, 4);
	EMUFILE_MEMORY memfile;
	memfile.truncate(Size);
	gzread(f, memfile.buf(), Size);
	bool ok = SPUunfreeze_new(&memfile);
	if(!ok) return 1;

	return 0;
}
开发者ID:Nitrofski,项目名称:psxjin,代码行数:65,代码来源:Misc.cpp


注:本文中的EMUFILE_MEMORY::truncate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。