Skip to content

Commit

Permalink
Merge pull request #11767 from hrydgard/force-umd-delay
Browse files Browse the repository at this point in the history
Compat: Force realistic UMD timing for F1 2006.
  • Loading branch information
hrydgard authored Feb 6, 2019
2 parents 7e9b889 + 3d114c5 commit b465d41
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions Core/Compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
CheckSetting(iniFile, gameID, "SonicRivalsHack", &flags_.SonicRivalsHack);
CheckSetting(iniFile, gameID, "BlockTransferAllowCreateFB", &flags_.BlockTransferAllowCreateFB);
CheckSetting(iniFile, gameID, "YugiohSaveFix", &flags_.YugiohSaveFix);
CheckSetting(iniFile, gameID, "ForceUMDDelay", &flags_.ForceUMDDelay);
}

void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) {
Expand Down
1 change: 1 addition & 0 deletions Core/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct CompatFlags {
bool SonicRivalsHack;
bool BlockTransferAllowCreateFB;
bool YugiohSaveFix;
bool ForceUMDDelay;
};

class IniFile;
Expand Down
25 changes: 18 additions & 7 deletions Core/HLE/sceIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ class FileNode : public KernelObject {

u64 __IoCompleteAsyncIO(FileNode *f);

static int GetIOTimingMethod() {
if (PSP_CoreParameter().compat.flags().ForceUMDDelay) {
return IOTIMING_REALISTIC;
} else {
return g_Config.iIOTimingMethod;
}
}

static void TellFsThreadEnded (SceUID threadID) {
pspFileSystem.ThreadEnded(threadID);
}
Expand Down Expand Up @@ -339,15 +347,16 @@ static void __IoAsyncNotify(u64 userdata, int cyclesLate) {
return;
}

if (g_Config.iIOTimingMethod == IOTIMING_HOST) {
int ioTimingMethod = GetIOTimingMethod();
if (ioTimingMethod == IOTIMING_HOST) {
// Not all async operations actually queue up. Maybe should separate them?
if (!ioManager.HasResult(f->handle) && ioManager.HasOperation(f->handle)) {
// Try again in another 0.5ms until the IO completes on the host.
CoreTiming::ScheduleEvent(usToCycles(500) - cyclesLate, asyncNotifyEvent, userdata);
return;
}
__IoCompleteAsyncIO(f);
} else if (g_Config.iIOTimingMethod == IOTIMING_REALISTIC) {
} else if (ioTimingMethod == IOTIMING_REALISTIC) {
u64 finishTicks = __IoCompleteAsyncIO(f);
if (finishTicks > CoreTiming::GetTicks()) {
// Reschedule for later, since we now know how long it ought to take.
Expand Down Expand Up @@ -396,13 +405,14 @@ static void __IoSyncNotify(u64 userdata, int cyclesLate) {
return;
}

if (g_Config.iIOTimingMethod == IOTIMING_HOST) {
int ioTimingMethod = GetIOTimingMethod();
if (ioTimingMethod == IOTIMING_HOST) {
if (!ioManager.HasResult(f->handle)) {
// Try again in another 0.5ms until the IO completes on the host.
CoreTiming::ScheduleEvent(usToCycles(500) - cyclesLate, syncNotifyEvent, userdata);
return;
}
} else if (g_Config.iIOTimingMethod == IOTIMING_REALISTIC) {
} else if (ioTimingMethod == IOTIMING_REALISTIC) {
u64 finishTicks = ioManager.ResultFinishTicks(f->handle);
if (finishTicks > CoreTiming::GetTicks()) {
// Reschedule for later when the result should finish.
Expand Down Expand Up @@ -723,7 +733,8 @@ static u32 sceKernelStderr() {
u64 __IoCompleteAsyncIO(FileNode *f) {
PROFILE_THIS_SCOPE("io_rw");

if (g_Config.iIOTimingMethod == IOTIMING_REALISTIC) {
int ioTimingMethod = GetIOTimingMethod();
if (ioTimingMethod == IOTIMING_REALISTIC) {
u64 finishTicks = ioManager.ResultFinishTicks(f->handle);
if (finishTicks > CoreTiming::GetTicks()) {
return finishTicks;
Expand Down Expand Up @@ -921,7 +932,7 @@ static bool __IoRead(int &result, int id, u32 data_addr, int size, int &us) {
ioManager.ScheduleOperation(ev);
return false;
} else {
if (g_Config.iIOTimingMethod != IOTIMING_REALISTIC) {
if (GetIOTimingMethod() != IOTIMING_REALISTIC) {
result = (int) pspFileSystem.ReadFile(f->handle, data, size);
} else {
result = (int) pspFileSystem.ReadFile(f->handle, data, size, us);
Expand Down Expand Up @@ -1056,7 +1067,7 @@ static bool __IoWrite(int &result, int id, u32 data_addr, int size, int &us) {
ioManager.ScheduleOperation(ev);
return false;
} else {
if (g_Config.iIOTimingMethod != IOTIMING_REALISTIC) {
if (GetIOTimingMethod() != IOTIMING_REALISTIC) {
result = (int) pspFileSystem.WriteFile(f->handle, (u8 *) data_ptr, size);
} else {
result = (int) pspFileSystem.WriteFile(f->handle, (u8 *) data_ptr, size, us);
Expand Down
5 changes: 5 additions & 0 deletions assets/compat.ini
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,8 @@ ULJM05940 = true

# Yu-Gi-Oh! ARC-V Tag Force Special
NPJH00142 = true

[ForceUMDDelay]
# F1 2006
UCES00238 = true
UCJS10045 = true

0 comments on commit b465d41

Please sign in to comment.