本文整理汇总了C++中EMUFILE::fseek方法的典型用法代码示例。如果您正苦于以下问题:C++ EMUFILE::fseek方法的具体用法?C++ EMUFILE::fseek怎么用?C++ EMUFILE::fseek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EMUFILE
的用法示例。
在下文中一共展示了EMUFILE::fseek方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
u32 readRom(const u32 pos, const u8 size)
{
if (!fROM) return 0xFFFFFFFF;
fROM->fseek(pos, SEEK_SET);
u32 data = 0xFFFFFFFF;
u32 readed = fROM->fread(&data, size);
return data;
}
示例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: readSRAM
u32 readSRAM(const u32 pos, const u8 size)
{
if (!fSRAM)
return 0xFFFFFFFF;
fSRAM->fseek(pos, SEEK_SET);
u32 data = 0xFFFFFFFF;
u32 readed = fSRAM->fread(&data, size);
return data;
}
示例4: scanSaveTypeGBA
u32 scanSaveTypeGBA()
{
if (!fROM) return 0xFF;
fROM->fseek(0, SEEK_SET);
int size = fROM->size();
int lastpct=1;
int len = fROM->size();
for(;;)
{
u32 tmp;
u32 readed = fROM->fread(&tmp, 4);
int pos = fROM->ftell();
int currPct = pos*100/(size-1);
for(int i=lastpct;i<currPct;i++)
{
if(i%10==0)
printf(" %d%%\n",i/10*10);
else printf(".");
lastpct = currPct;
}
if (readed < 4)
break;
if(pos >= len)
break;
switch (tmp)
{
case EEPROM:
return 1;
case SRAM_:
return 2;
case FLASH:
{
u32 tmp = fROM->read32le();
return ((tmp == FLASH1M_)?3:5);
}
case SIIRTC_V:
return 4;
}
}
return 0xFF;
}
示例5: dataChunk
static bool dataChunk(EMUFILE &inf)
{
bool found = false;
// seek to just after the RIFF header
inf.fseek(12,SEEK_SET);
// search for a format chunk
for (;;)
{
char chunk_id[4];
u32 chunk_length;
if (inf.eof()) return found;
if (inf.fread(chunk_id, 4) != 4) return found;
if (!inf.read_32LE(chunk_length)) return found;
// if we found a data chunk, excellent!
if (memcmp(chunk_id, "data", 4) == 0)
{
found = true;
u8 *temp = new u8[chunk_length];
if (inf.fread(temp,chunk_length) != chunk_length)
{
delete[] temp;
return false;
}
newWavData.fwrite(temp,chunk_length);
delete[] temp;
chunk_length = 0;
}
inf.fseek(chunk_length,SEEK_CUR);
}
return found;
}
示例6: 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);
}
示例7: 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);
}
示例8: mic_loadstate
bool mic_loadstate(EMUFILE &is, int size)
{
is.fseek(size, SEEK_CUR);
return true;
}