Fix file seeking of gba ROM and fix seeking behaviour of EMUFILE_FILE

This commit is contained in:
alvinwong 2014-05-26 09:50:11 +00:00
parent 262fc4f14a
commit fca4afd7ce
2 changed files with 9 additions and 5 deletions

View File

@ -60,6 +60,8 @@ private:
u32 readRom(const u32 pos, const u8 size) u32 readRom(const u32 pos, const u8 size)
{ {
if (!fROM) return 0xFFFFFFFF; if (!fROM) return 0xFFFFFFFF;
fROM->fseek(pos, SEEK_SET);
u32 data = 0xFFFFFFFF; u32 data = 0xFFFFFFFF;
u32 readed = fROM->fread(&data, size); u32 readed = fROM->fread(&data, size);

View File

@ -83,17 +83,19 @@ int EMUFILE_FILE::fseek(int offset, int origin)
{ {
if(mFilePosition == offset) if(mFilePosition == offset)
{ {
return mFilePosition; return 0;
} }
} }
} }
mCondition = eCondition_Clean; mCondition = eCondition_Clean;
int pos = ::fseek(fp, offset, origin); int ret = ::fseek(fp, offset, origin);
mPositionCacheEnabled = pos;
if(mPositionCacheEnabled)
return pos; mFilePosition = ::ftell(fp);
return ret;
} }