From 9cbfddd7883b5b69ac741cc3c5a49a735ff8ea67 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 6 Feb 2013 16:52:51 -0600 Subject: [PATCH] Only delay DI and fs IPC replies. Fixes issue 5982. --- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp | 8 ++++++-- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h | 2 ++ Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp | 7 +++++++ Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.h | 2 ++ Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp | 8 ++++++++ Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.h | 2 ++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index 620d6c7052..4149931353 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -405,6 +405,7 @@ void ExecuteCommand(u32 _Address) else { delete pDevice; + pDevice = NULL; } } @@ -435,7 +436,10 @@ void ExecuteCommand(u32 _Address) // Don't delete hardware if (!pDevice->IsHardware()) + { delete pDevice; + pDevice = NULL; + } } else { @@ -515,8 +519,8 @@ void ExecuteCommand(u32 _Address) if (CmdSuccess) { // Generate a reply to the IPC command - // TODO: should probably figure out which commands need delayed replies and which don't - EnqReply(_Address, SystemTimers::GetTicksPerSecond() / 100); + int const reply_delay = pDevice ? pDevice->GetCmdDelay(_Address) : 0; + EnqReply(_Address, reply_delay); } else { diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h index d2907d7ee9..d52bd4f1e3 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h @@ -95,6 +95,8 @@ public: virtual bool IOCtlV (u32) { UNIMPLEMENTED_CMD(IOCtlV) } #undef UNIMPLEMENTED_CMD + virtual int GetCmdDelay(u32) { return 0; } + virtual u32 Update() { return 0; } virtual bool IsHardware() { return m_Hardware; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp index 05b365ef01..0d610edb8c 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.cpp @@ -28,6 +28,7 @@ #include "VolumeCreator.h" #include "Filesystem.h" #include "LogManager.h" +#include "../HW/SystemTimers.h" #include "../../DiscIO/Src/FileMonitor.h" @@ -460,3 +461,9 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32 // i dunno but prolly 1 is okay all the time :) return 1; } + +int CWII_IPC_HLE_Device_di::GetCmdDelay(u32) +{ + // Less than ~1/150th of a second hangs Oregon Trail at "loading wheel". + return SystemTimers::GetTicksPerSecond() / 100; +} \ No newline at end of file diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.h index 36e9f89067..0b62daefa3 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_DI.h @@ -38,6 +38,8 @@ public: bool IOCtl(u32 _CommandAddress); bool IOCtlV(u32 _CommandAddress); + + int GetCmdDelay(u32); private: diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp index cc123ddf52..ecc4be0cb0 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp @@ -26,6 +26,7 @@ #include "FileUtil.h" #include "NandPaths.h" #include "ChunkFile.h" +#include "../HW/SystemTimers.h" #include "../VolumeHandler.h" @@ -499,6 +500,13 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B return FS_RESULT_FATAL; } +int CWII_IPC_HLE_Device_fs::GetCmdDelay(u32) +{ + // ~1/1000th of a second is too short and causes hangs in Wii Party + // Play it safe at 1/500th + return SystemTimers::GetTicksPerSecond() / 500; +} + void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) { DoStateShared(p); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.h index c98338e39d..17a574da64 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.h @@ -55,6 +55,8 @@ public: virtual bool IOCtl(u32 _CommandAddress); virtual bool IOCtlV(u32 _CommandAddress); + + virtual int GetCmdDelay(u32); private: