From a6d511d12357187356afa000bab843b6b1edd261 Mon Sep 17 00:00:00 2001 From: shenweip <1037567878@qq.com> Date: Fri, 13 Dec 2019 08:19:17 +0800 Subject: [PATCH 1/4] IO:Add an extra delay to simulate umd delay in file seek whence. Pangya(KS) seems want to check something base on this delay and system time.Anyhow, the game work now. --- Core/HLE/sceIo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 5550411fcf..2baa398a7e 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -2531,6 +2531,10 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, // TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem. INFO_LOG(SCEIO, "sceIoIoctl: Sector seek for file %i", id); // Even if the size is 4, it still actually reads a 16 byte struct, it seems. + + if (GetIOTimingMethod() == IOTIMING_REALISTIC) + usec = 15000;// Fantasy Golf Pangya Portable(KS) needs a delay over 15000us. + if (Memory::IsValidAddress(indataPtr) && inlen >= 4) { struct SeekInfo { u64 offset; From fd6b0554d6c6c356f6a9f29f87aebc9f87ee0fd4 Mon Sep 17 00:00:00 2001 From: shenweip <1037567878@qq.com> Date: Fri, 13 Dec 2019 11:15:58 +0800 Subject: [PATCH 2/4] IO:Re-grab SCE_KERNEL_ERROR_NOCWD. Fix issue#12492,the issue occur since commit e09296b9b10d6ee9997dcd86bc10d172a48a4b1b --- Core/FileSystems/MetaFileSystem.cpp | 47 ++++++++++++++++++++--------- Core/FileSystems/MetaFileSystem.h | 2 +- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 933f56f5b1..e7936014dc 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -226,7 +226,7 @@ int MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath currentDirectory = &(it->second); } - if ( RealPath(*currentDirectory, inpath, realpath) ) + if (RealPath(*currentDirectory, inpath, realpath)) { std::string prefix = realpath; size_t prefixPos = realpath.find(':'); @@ -243,7 +243,10 @@ int MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath VERBOSE_LOG(FILESYS, "MapFilePath: mapped \"%s\" to prefix: \"%s\", path: \"%s\"", inpath.c_str(), fileSystems[i].prefix.c_str(), outpath.c_str()); - return 0; + if (error == SCE_KERNEL_ERROR_NOCWD) + return error; + else + return 0; } } } @@ -339,9 +342,13 @@ int MetaFileSystem::OpenFile(std::string filename, FileAccess access, const char std::string of; MountPoint *mount; int error = MapFilePath(filename, of, &mount); - if (error == 0) - return mount->system->OpenFile(of, access, mount->prefix.c_str()); - else + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { + int h = mount->system->OpenFile(of, access, mount->prefix.c_str()); + if (h < 0 && error == SCE_KERNEL_ERROR_NOCWD) + return SCE_KERNEL_ERROR_NOCWD; + else + return h; + } else return error == -1 ? SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND : error; } @@ -350,7 +357,8 @@ PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename) std::lock_guard guard(lock); std::string of; IFileSystem *system; - if (MapFilePath(filename, of, &system) == 0) + int error = MapFilePath(filename, of, &system); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { return system->GetFileInfo(of); } @@ -366,7 +374,8 @@ bool MetaFileSystem::GetHostPath(const std::string &inpath, std::string &outpath std::lock_guard guard(lock); std::string of; IFileSystem *system; - if (MapFilePath(inpath, of, &system) == 0) { + int error = MapFilePath(inpath, of, &system); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { return system->GetHostPath(of, outpath); } else { return false; @@ -378,7 +387,8 @@ std::vector MetaFileSystem::GetDirListing(std::string path) std::lock_guard guard(lock); std::string of; IFileSystem *system; - if (MapFilePath(path, of, &system) == 0) + int error = MapFilePath(path, of, &system); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { return system->GetDirListing(of); } @@ -406,7 +416,8 @@ int MetaFileSystem::ChDir(const std::string &dir) std::string of; MountPoint *mountPoint; - if (MapFilePath(dir, of, &mountPoint) == 0) + int error = MapFilePath(dir, of, &mountPoint); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { currentDir[curThread] = mountPoint->prefix + of; return 0; @@ -435,7 +446,8 @@ bool MetaFileSystem::MkDir(const std::string &dirname) std::lock_guard guard(lock); std::string of; IFileSystem *system; - if (MapFilePath(dirname, of, &system) == 0) + int error = MapFilePath(dirname, of, &system); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { return system->MkDir(of); } @@ -450,7 +462,8 @@ bool MetaFileSystem::RmDir(const std::string &dirname) std::lock_guard guard(lock); std::string of; IFileSystem *system; - if (MapFilePath(dirname, of, &system) == 0) + int error = MapFilePath(dirname, of, &system); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { return system->RmDir(of); } @@ -467,12 +480,14 @@ int MetaFileSystem::RenameFile(const std::string &from, const std::string &to) std::string rf; IFileSystem *osystem; IFileSystem *rsystem = NULL; - if (MapFilePath(from, of, &osystem) == 0) + int error = MapFilePath(from, of, &osystem); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { // If it's a relative path, it seems to always use from's filesystem. if (to.find(":/") != to.npos) { - if (!MapFilePath(to, rf, &rsystem)) + error = MapFilePath(to, rf, &rsystem); + if (error != 0) return -1; } else @@ -497,7 +512,8 @@ bool MetaFileSystem::RemoveFile(const std::string &filename) std::lock_guard guard(lock); std::string of; IFileSystem *system; - if (MapFilePath(filename, of, &system) == 0) + int error = MapFilePath(filename, of, &system); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { return system->RemoveFile(of); } @@ -604,7 +620,8 @@ u64 MetaFileSystem::FreeSpace(const std::string &path) std::lock_guard guard(lock); std::string of; IFileSystem *system; - if (MapFilePath(path, of, &system) == 0) + int error = MapFilePath(path, of, &system); + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) return system->FreeSpace(of); else return 0; diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index cfc202b0d1..7335646170 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -79,7 +79,7 @@ public: inline int MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system) { MountPoint *mountPoint; int error = MapFilePath(_inpath, outpath, &mountPoint); - if (error == 0) { + if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { *system = mountPoint->system; return error; } From c3a489fa90f7ea6d031ad931ec997f42474d1abf Mon Sep 17 00:00:00 2001 From: shenweip <1037567878@qq.com> Date: Fri, 13 Dec 2019 17:59:55 +0800 Subject: [PATCH 3/4] Don't ignore SCE_KERNEL_ERROR_NOCWD in many cases. Use a error 1 to mean the uccessful mapping but carry with SCE_KERNEL_ERROR_NOCWD error. --- Core/FileSystems/MetaFileSystem.cpp | 26 +++++++++++++------------- Core/FileSystems/MetaFileSystem.h | 2 +- Core/HLE/sceIo.cpp | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index e7936014dc..2c0fd58e5c 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -244,7 +244,7 @@ int MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath VERBOSE_LOG(FILESYS, "MapFilePath: mapped \"%s\" to prefix: \"%s\", path: \"%s\"", inpath.c_str(), fileSystems[i].prefix.c_str(), outpath.c_str()); if (error == SCE_KERNEL_ERROR_NOCWD) - return error; + return 1; // This means successful mapping but carry with SCE_KERNEL_ERROR_NOCWD error. else return 0; } @@ -342,9 +342,9 @@ int MetaFileSystem::OpenFile(std::string filename, FileAccess access, const char std::string of; MountPoint *mount; int error = MapFilePath(filename, of, &mount); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { + if (error >= 0) { int h = mount->system->OpenFile(of, access, mount->prefix.c_str()); - if (h < 0 && error == SCE_KERNEL_ERROR_NOCWD) + if (h < 0 && error == 1) return SCE_KERNEL_ERROR_NOCWD; else return h; @@ -358,7 +358,7 @@ PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename) std::string of; IFileSystem *system; int error = MapFilePath(filename, of, &system); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) { return system->GetFileInfo(of); } @@ -375,7 +375,7 @@ bool MetaFileSystem::GetHostPath(const std::string &inpath, std::string &outpath std::string of; IFileSystem *system; int error = MapFilePath(inpath, of, &system); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { + if (error >= 0) { return system->GetHostPath(of, outpath); } else { return false; @@ -388,7 +388,7 @@ std::vector MetaFileSystem::GetDirListing(std::string path) std::string of; IFileSystem *system; int error = MapFilePath(path, of, &system); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) { return system->GetDirListing(of); } @@ -417,7 +417,7 @@ int MetaFileSystem::ChDir(const std::string &dir) std::string of; MountPoint *mountPoint; int error = MapFilePath(dir, of, &mountPoint); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) { currentDir[curThread] = mountPoint->prefix + of; return 0; @@ -447,7 +447,7 @@ bool MetaFileSystem::MkDir(const std::string &dirname) std::string of; IFileSystem *system; int error = MapFilePath(dirname, of, &system); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) { return system->MkDir(of); } @@ -463,7 +463,7 @@ bool MetaFileSystem::RmDir(const std::string &dirname) std::string of; IFileSystem *system; int error = MapFilePath(dirname, of, &system); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) { return system->RmDir(of); } @@ -481,13 +481,13 @@ int MetaFileSystem::RenameFile(const std::string &from, const std::string &to) IFileSystem *osystem; IFileSystem *rsystem = NULL; int error = MapFilePath(from, of, &osystem); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) { // If it's a relative path, it seems to always use from's filesystem. if (to.find(":/") != to.npos) { error = MapFilePath(to, rf, &rsystem); - if (error != 0) + if (error < 0) return -1; } else @@ -513,7 +513,7 @@ bool MetaFileSystem::RemoveFile(const std::string &filename) std::string of; IFileSystem *system; int error = MapFilePath(filename, of, &system); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) { return system->RemoveFile(of); } @@ -621,7 +621,7 @@ u64 MetaFileSystem::FreeSpace(const std::string &path) std::string of; IFileSystem *system; int error = MapFilePath(path, of, &system); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) + if (error >= 0) return system->FreeSpace(of); else return 0; diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index 7335646170..ad9af8d2e8 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -79,7 +79,7 @@ public: inline int MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system) { MountPoint *mountPoint; int error = MapFilePath(_inpath, outpath, &mountPoint); - if (error == 0 || error == SCE_KERNEL_ERROR_NOCWD) { + if (error >= 0) { *system = mountPoint->system; return error; } diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 2baa398a7e..36166cf6bb 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -2532,8 +2532,8 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, INFO_LOG(SCEIO, "sceIoIoctl: Sector seek for file %i", id); // Even if the size is 4, it still actually reads a 16 byte struct, it seems. - if (GetIOTimingMethod() == IOTIMING_REALISTIC) - usec = 15000;// Fantasy Golf Pangya Portable(KS) needs a delay over 15000us. + //if (GetIOTimingMethod() == IOTIMING_REALISTIC) // Need a check for io timing method? + usec = 15000;// Fantasy Golf Pangya Portable(KS) needs a delay over 15000us. if (Memory::IsValidAddress(indataPtr) && inlen >= 4) { struct SeekInfo { From fb696f8a7126fe22eaa6c6baa2291b2733c6e115 Mon Sep 17 00:00:00 2001 From: shenweip <1037567878@qq.com> Date: Wed, 25 Dec 2019 11:16:56 +0800 Subject: [PATCH 4/4] Just return error if current directory not be setted. --- Core/FileSystems/MetaFileSystem.cpp | 33 ++++++++++++----------------- Core/FileSystems/MetaFileSystem.h | 2 +- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 2c0fd58e5c..0cf66541e3 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -243,10 +243,7 @@ int MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath VERBOSE_LOG(FILESYS, "MapFilePath: mapped \"%s\" to prefix: \"%s\", path: \"%s\"", inpath.c_str(), fileSystems[i].prefix.c_str(), outpath.c_str()); - if (error == SCE_KERNEL_ERROR_NOCWD) - return 1; // This means successful mapping but carry with SCE_KERNEL_ERROR_NOCWD error. - else - return 0; + return error == SCE_KERNEL_ERROR_NOCWD ? error : 0; } } } @@ -342,13 +339,9 @@ int MetaFileSystem::OpenFile(std::string filename, FileAccess access, const char std::string of; MountPoint *mount; int error = MapFilePath(filename, of, &mount); - if (error >= 0) { - int h = mount->system->OpenFile(of, access, mount->prefix.c_str()); - if (h < 0 && error == 1) - return SCE_KERNEL_ERROR_NOCWD; - else - return h; - } else + if (error == 0) + return mount->system->OpenFile(of, access, mount->prefix.c_str()); + else return error == -1 ? SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND : error; } @@ -358,7 +351,7 @@ PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename) std::string of; IFileSystem *system; int error = MapFilePath(filename, of, &system); - if (error >= 0) + if (error == 0) { return system->GetFileInfo(of); } @@ -375,7 +368,7 @@ bool MetaFileSystem::GetHostPath(const std::string &inpath, std::string &outpath std::string of; IFileSystem *system; int error = MapFilePath(inpath, of, &system); - if (error >= 0) { + if (error == 0) { return system->GetHostPath(of, outpath); } else { return false; @@ -388,7 +381,7 @@ std::vector MetaFileSystem::GetDirListing(std::string path) std::string of; IFileSystem *system; int error = MapFilePath(path, of, &system); - if (error >= 0) + if (error == 0) { return system->GetDirListing(of); } @@ -417,7 +410,7 @@ int MetaFileSystem::ChDir(const std::string &dir) std::string of; MountPoint *mountPoint; int error = MapFilePath(dir, of, &mountPoint); - if (error >= 0) + if (error == 0) { currentDir[curThread] = mountPoint->prefix + of; return 0; @@ -447,7 +440,7 @@ bool MetaFileSystem::MkDir(const std::string &dirname) std::string of; IFileSystem *system; int error = MapFilePath(dirname, of, &system); - if (error >= 0) + if (error == 0) { return system->MkDir(of); } @@ -463,7 +456,7 @@ bool MetaFileSystem::RmDir(const std::string &dirname) std::string of; IFileSystem *system; int error = MapFilePath(dirname, of, &system); - if (error >= 0) + if (error == 0) { return system->RmDir(of); } @@ -481,7 +474,7 @@ int MetaFileSystem::RenameFile(const std::string &from, const std::string &to) IFileSystem *osystem; IFileSystem *rsystem = NULL; int error = MapFilePath(from, of, &osystem); - if (error >= 0) + if (error == 0) { // If it's a relative path, it seems to always use from's filesystem. if (to.find(":/") != to.npos) @@ -513,7 +506,7 @@ bool MetaFileSystem::RemoveFile(const std::string &filename) std::string of; IFileSystem *system; int error = MapFilePath(filename, of, &system); - if (error >= 0) + if (error == 0) { return system->RemoveFile(of); } @@ -621,7 +614,7 @@ u64 MetaFileSystem::FreeSpace(const std::string &path) std::string of; IFileSystem *system; int error = MapFilePath(path, of, &system); - if (error >= 0) + if (error == 0) return system->FreeSpace(of); else return 0; diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index ad9af8d2e8..cfc202b0d1 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -79,7 +79,7 @@ public: inline int MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system) { MountPoint *mountPoint; int error = MapFilePath(_inpath, outpath, &mountPoint); - if (error >= 0) { + if (error == 0) { *system = mountPoint->system; return error; }