本文整理汇总了C++中EMUFILE::fwrite方法的典型用法代码示例。如果您正苦于以下问题:C++ EMUFILE::fwrite方法的具体用法?C++ EMUFILE::fwrite怎么用?C++ EMUFILE::fwrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EMUFILE
的用法示例。
在下文中一共展示了EMUFILE::fwrite方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DEBUG_dumpMemory_fill
static void DEBUG_dumpMemory_fill(EMUFILE &fp, u32 size)
{
static std::vector<u8> buf;
buf.resize(size);
memset(&buf[0],0,size);
fp.fwrite(&buf[0],size);
}
示例2: writeSRAM
void writeSRAM(const u32 pos, const u8 *data, u32 size)
{
if (!fSRAM)
return;
fSRAM->fseek(pos, SEEK_SET);
u32 writed = size;
fSRAM->fwrite(data, size);
fSRAM->fflush();
}
示例3: DEBUG_dumpMemory
void DEBUG_dumpMemory(EMUFILE &fp)
{
fp.fseek(0x000000,SEEK_SET); fp.fwrite(MMU.MAIN_MEM,0x800000); //arm9 main mem (8192K)
fp.fseek(0x900000,SEEK_SET); fp.fwrite(MMU.ARM9_DTCM,0x4000); //arm9 DTCM (16K)
fp.fseek(0xA00000,SEEK_SET); fp.fwrite(MMU.ARM9_ITCM,0x8000); //arm9 ITCM (32K)
fp.fseek(0xB00000,SEEK_SET); fp.fwrite(MMU.ARM9_LCD,0xA4000); //LCD mem 656K
fp.fseek(0xC00000,SEEK_SET); fp.fwrite(MMU.ARM9_VMEM,0x800); //OAM
fp.fseek(0xD00000,SEEK_SET); fp.fwrite(MMU.ARM7_ERAM,0x10000); //arm7 WRAM (64K)
fp.fseek(0xE00000,SEEK_SET); fp.fwrite(MMU.ARM7_WIRAM,0x10000); //arm7 wifi RAM ?
fp.fseek(0xF00000,SEEK_SET); fp.fwrite(MMU.SWIRAM,0x8000); //arm9/arm7 shared WRAM (32KB)
}
示例4: flush
void BackupDevice::flush()
{
//never use save files if we are in movie mode
if(isMovieMode) return;
if (filename.length() == 0) return;
EMUFILE* outf = new EMUFILE_FILE(filename.c_str(),"wb");
if(!outf->fail())
{
if(data.size()>0)
outf->fwrite(&data[0],data.size());
//write the footer. we use a footer so that we can maximize the chance of the
//save file being recognized as a raw save file by other emulators etc.
//first, pad up to the next largest known save size.
u32 size = data.size();
u32 padSize = pad_up_size(size);
for(u32 i=size;i<padSize;i++)
outf->fputc(kUninitializedSaveDataValue);
//this is just for humans to read
outf->fprintf("|<--Snip above here to create a raw sav by excluding this DeSmuME savedata footer:");
//and now the actual footer
write32le(size,outf); //the size of data that has actually been written
write32le(padSize,outf); //the size we padded it to
write32le(info.type,outf); //save memory type
write32le(addr_size,outf);
write32le(info.size,outf); //save memory size
write32le(0,outf); //version number
outf->fprintf("%s", kDesmumeSaveCookie); //this is what we'll use to recognize the desmume format save
delete outf;
}
else
{
delete outf;
printf("Unable to open savefile %s\n", filename.c_str());
}
}
示例5: FCEUSS_SaveMS
bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel)
{
// reinit memory_savestate
// memory_savestate is global variable which already has its vector of bytes, so no need to allocate memory every time we use save/loadstate
memory_savestate.set_len(0); // this also seeks to the beginning
memory_savestate.unfail();
EMUFILE* os = &memory_savestate;
uint32 totalsize = 0;
FCEUPPU_SaveState();
FCEUSND_SaveState();
totalsize=WriteStateChunk(os,1,SFCPU);
totalsize+=WriteStateChunk(os,2,SFCPUC);
totalsize+=WriteStateChunk(os,3,FCEUPPU_STATEINFO);
totalsize+=WriteStateChunk(os,31,FCEU_NEWPPU_STATEINFO);
totalsize+=WriteStateChunk(os,4,FCEUCTRL_STATEINFO);
totalsize+=WriteStateChunk(os,5,FCEUSND_STATEINFO);
if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD|MOVIEMODE_FINISHED))
{
totalsize+=WriteStateChunk(os,6,FCEUMOV_STATEINFO);
//MBG TAS Editor HACK HACK HACK!
//do not save the movie state if we are in Taseditor! That would be a huge waste of time and space!
if(!FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
{
os->fseek(5,SEEK_CUR);
int size = FCEUMOV_WriteState(os);
os->fseek(-(size+5),SEEK_CUR);
os->fputc(7);
write32le(size, os);
os->fseek(size,SEEK_CUR);
totalsize += 5 + size;
}
}
// save back buffer
{
extern uint8 *XBackBuf;
uint32 size = 256 * 256 + 8;
os->fputc(8);
write32le(size, os);
os->fwrite((char*)XBackBuf,size);
totalsize += 5 + size;
}
if(SPreSave) SPreSave();
totalsize+=WriteStateChunk(os,0x10,SFMDATA);
if(SPreSave) SPostSave();
//save the length of the file
int len = memory_savestate.size();
//sanity check: len and totalsize should be the same
if(len != totalsize)
{
FCEUD_PrintError("sanity violation: len != totalsize");
return false;
}
int error = Z_OK;
uint8* cbuf = (uint8*)memory_savestate.buf();
uLongf comprlen = -1;
if(compressionLevel != Z_NO_COMPRESSION && (compressSavestates || FCEUMOV_Mode(MOVIEMODE_TASEDITOR)))
{
// worst case compression: zlib says "0.1% larger than sourceLen plus 12 bytes"
comprlen = (len>>9)+12 + len;
if (compressed_buf.size() < comprlen) compressed_buf.resize(comprlen);
cbuf = &compressed_buf[0];
// do compression
error = compress2(cbuf, &comprlen, (uint8*)memory_savestate.buf(), len, compressionLevel);
}
示例6: FCEUSS_SaveMS
bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel)
{
//a temp memory stream. we'll dump some data here and then compress
//TODO - support dumping directly without compressing to save a buffer copy
EMUFILE_MEMORY ms;
EMUFILE* os = &ms;
uint32 totalsize = 0;
FCEUPPU_SaveState();
FCEUSND_SaveState();
totalsize=WriteStateChunk(os,1,SFCPU);
totalsize+=WriteStateChunk(os,2,SFCPUC);
totalsize+=WriteStateChunk(os,3,FCEUPPU_STATEINFO);
totalsize+=WriteStateChunk(os,31,FCEU_NEWPPU_STATEINFO);
totalsize+=WriteStateChunk(os,4,FCEUCTRL_STATEINFO);
totalsize+=WriteStateChunk(os,5,FCEUSND_STATEINFO);
if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD|MOVIEMODE_FINISHED))
{
totalsize+=WriteStateChunk(os,6,FCEUMOV_STATEINFO);
//MBG tasedit HACK HACK HACK!
//do not save the movie state if we are in tasedit! that is a huge waste of time and space!
if(!FCEUMOV_Mode(MOVIEMODE_TASEDIT))
{
os->fseek(5,SEEK_CUR);
int size = FCEUMOV_WriteState(os);
os->fseek(-(size+5),SEEK_CUR);
os->fputc(7);
write32le(size, os);
os->fseek(size,SEEK_CUR);
totalsize += 5 + size;
}
}
// save back buffer
{
extern uint8 *XBackBuf;
uint32 size = 256 * 256 + 8;
os->fputc(8);
write32le(size, os);
os->fwrite((char*)XBackBuf,size);
totalsize += 5 + size;
}
if(SPreSave) SPreSave();
totalsize+=WriteStateChunk(os,0x10,SFMDATA);
if(SPreSave) SPostSave();
//save the length of the file
int len = ms.size();
//sanity check: len and totalsize should be the same
if(len != totalsize)
{
FCEUD_PrintError("sanity violation: len != totalsize");
return false;
}
int error = Z_OK;
uint8* cbuf = (uint8*)ms.buf();
uLongf comprlen = -1;
if(compressionLevel != Z_NO_COMPRESSION && compressSavestates)
{
//worst case compression.
//zlib says "0.1% larger than sourceLen plus 12 bytes"
comprlen = (len>>9)+12 + len;
cbuf = new uint8[comprlen];
error = compress2(cbuf,&comprlen,(uint8*)ms.buf(),len,compressionLevel);
}