diff --git a/desmume/src/addons/slot2_gbagame.cpp b/desmume/src/addons/slot2_gbagame.cpp index 024575c52..6a333a29d 100644 --- a/desmume/src/addons/slot2_gbagame.cpp +++ b/desmume/src/addons/slot2_gbagame.cpp @@ -60,6 +60,8 @@ private: 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); diff --git a/desmume/src/emufile.cpp b/desmume/src/emufile.cpp index 624d1dc26..a4ee0d76c 100644 --- a/desmume/src/emufile.cpp +++ b/desmume/src/emufile.cpp @@ -83,17 +83,19 @@ int EMUFILE_FILE::fseek(int offset, int origin) { if(mFilePosition == offset) { - return mFilePosition; + return 0; } } } mCondition = eCondition_Clean; - int pos = ::fseek(fp, offset, origin); - mPositionCacheEnabled = pos; - - return pos; + int ret = ::fseek(fp, offset, origin); + + if(mPositionCacheEnabled) + mFilePosition = ::ftell(fp); + + return ret; }