Very rough approximation of UMD seek delays.

This commit is contained in:
Unknown W. Brackets 2013-12-27 16:49:35 -08:00
parent d6a113809b
commit 8f3a8fd233
4 changed files with 33 additions and 2 deletions

View file

@ -227,6 +227,7 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root,
{
u8 theSector[2048];
blockDevice->ReadBlock(secnum, theSector);
lastReadBlock_ = secnum;
for (int offset = 0; offset < 2048; )
{
@ -535,7 +536,12 @@ size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec)
{
// Whole sectors! Shortcut to this simple code.
blockDevice->ReadBlocks(e.seekPos, (int)size, pointer);
if (abs((int)lastReadBlock_ - (int)e.seekPos) > 100) {
// This is an estimate, sometimes it takes 1+ seconds, but it definitely takes time.
usec = 100000;
}
e.seekPos += (int)size;
lastReadBlock_ = e.seekPos;
return (int)size;
}
@ -594,6 +600,11 @@ size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec)
}
size_t totalBytes = pointer - start;
if (abs((int)lastReadBlock_ - (int)secNum) > 100) {
// This is an estimate, sometimes it takes 1+ seconds, but it definitely takes time.
usec = 100000;
}
lastReadBlock_ = secNum;
e.seekPos += (unsigned int)totalBytes;
return (size_t)totalBytes;
}
@ -750,7 +761,7 @@ ISOFileSystem::TreeEntry::~TreeEntry() {
void ISOFileSystem::DoState(PointerWrap &p)
{
auto s = p.Section("ISOFileSystem", 1);
auto s = p.Section("ISOFileSystem", 1, 2);
if (!s)
return;
@ -806,4 +817,10 @@ void ISOFileSystem::DoState(PointerWrap &p)
}
}
}
if (s >= 2) {
p.Do(lastReadBlock_);
} else {
lastReadBlock_ = 0;
}
}

View file

@ -86,6 +86,7 @@ private:
IHandleAllocator *hAlloc;
TreeEntry *treeroot;
BlockDevice *blockDevice;
u32 lastReadBlock_;
TreeEntry entireISO;

View file

@ -146,7 +146,7 @@ void VirtualDiscFileSystem::LoadFileListIndex() {
void VirtualDiscFileSystem::DoState(PointerWrap &p)
{
auto s = p.Section("VirtualDiscFileSystem", 1);
auto s = p.Section("VirtualDiscFileSystem", 1, 2);
if (!s)
return;
@ -217,6 +217,12 @@ void VirtualDiscFileSystem::DoState(PointerWrap &p)
}
}
if (s >= 2) {
p.Do(lastReadBlock_);
} else {
lastReadBlock_ = 0;
}
// We don't savestate handlers (loaded on fs load), but if they change, it may not load properly.
}
@ -473,6 +479,12 @@ size_t VirtualDiscFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &u
temp.Close();
iter->second.curOffset += size;
// TODO: This probably isn't enough...
if (abs((int)lastReadBlock_ - (int)iter->second.curOffset) > 100) {
// This is an estimate, sometimes it takes 1+ seconds, but it definitely takes time.
usec = 100000;
}
lastReadBlock_ = iter->second.curOffset;
return size;
}

View file

@ -180,6 +180,7 @@ private:
std::vector<FileListEntry> fileList;
u32 currentBlockIndex;
u32 lastReadBlock_;
std::map<std::string, Handler *> handlers;
};