Disable some stuff in IPC_HLE when determinism is required.

This includes net, which is nonsensical to "sync" in netplay/replays
(could have the host do the Wii networking in future though...), and USB
keyboard, which just needs some love to do the same.
This commit is contained in:
comex 2014-11-15 16:42:15 -05:00
parent a0a80c9a9c
commit aae104ccb4
4 changed files with 28 additions and 6 deletions

View File

@ -15,6 +15,7 @@
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/ec_wii.h" #include "Core/ec_wii.h"
#include "Core/IPC_HLE/ICMP.h" #include "Core/IPC_HLE/ICMP.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_es.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_es.h"
@ -314,6 +315,10 @@ static void GetMacAddress(u8* mac)
// Parse MAC address from config, and generate a new one if it doesn't // Parse MAC address from config, and generate a new one if it doesn't
// exist or can't be parsed. // exist or can't be parsed.
std::string wireless_mac = SConfig::GetInstance().m_WirelessMac; std::string wireless_mac = SConfig::GetInstance().m_WirelessMac;
if (Core::g_want_determinism)
wireless_mac = "12:34:56:78:9a:bc";
if (!StringToMacAddress(wireless_mac, mac)) if (!StringToMacAddress(wireless_mac, mac))
{ {
GenerateMacAddress(IOS, mac); GenerateMacAddress(IOS, mac);

View File

@ -7,6 +7,7 @@
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/Timer.h" #include "Common/Timer.h"
#include "Core/HW/EXI_DeviceIPL.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
#ifdef _WIN32 #ifdef _WIN32
@ -528,21 +529,26 @@ private:
u64 rtc; u64 rtc;
s64 utcdiff; s64 utcdiff;
// Seconds between 1.1.1970 and 4.1.2008 16:00:38 // TODO: depending on CEXIIPL is a hack which I don't feel like removing
static const u64 wii_bias = 0x477E5826; // because the function itself is pretty hackish; wait until I re-port my
// netplay rewrite; also, is that random 16:00:38 actually meaningful?
// seems very very doubtful since Wii was released in 2006
// Seconds between 1.1.2000 and 4.1.2008 16:00:38
static const u64 wii_bias = 0x477E5826 - 0x386D4380;
// Returns seconds since Wii epoch // Returns seconds since Wii epoch
// +/- any bias set from IOCTL_NW24_SET_UNIVERSAL_TIME // +/- any bias set from IOCTL_NW24_SET_UNIVERSAL_TIME
u64 GetAdjustedUTC() const u64 GetAdjustedUTC() const
{ {
return Common::Timer::GetTimeSinceJan1970() - wii_bias + utcdiff; return CEXIIPL::GetGCTime() - wii_bias + utcdiff;
} }
// Store the difference between what the Wii thinks is UTC and // Store the difference between what the Wii thinks is UTC and
// what the host OS thinks // what the host OS thinks
void SetAdjustedUTC(u64 wii_utc) void SetAdjustedUTC(u64 wii_utc)
{ {
utcdiff = Common::Timer::GetTimeSinceJan1970() - wii_bias - wii_utc; utcdiff = CEXIIPL::GetGCTime() - wii_bias - wii_utc;
} }
}; };

View File

@ -5,6 +5,7 @@
#include <algorithm> #include <algorithm>
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Core/Core.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
#include "Core/IPC_HLE/WII_Socket.h" #include "Core/IPC_HLE/WII_Socket.h"
@ -127,6 +128,14 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
BufferOutSize3 = CommandBuffer.PayloadBuffer.at(2).m_Size; BufferOutSize3 = CommandBuffer.PayloadBuffer.at(2).m_Size;
} }
// I don't trust SSL to be deterministic, and this is never going to sync
// as such (as opposed to forwarding IPC results or whatever), so -
if (Core::g_want_determinism)
{
Memory::Write_U32(-1, _CommandAddress + 0x4);
return IPC_DEFAULT_REPLY;
}
switch (CommandBuffer.Parameter) switch (CommandBuffer.Parameter)
{ {
case IOCTLV_NET_SSL_NEW: case IOCTLV_NET_SSL_NEW:

View File

@ -13,6 +13,8 @@
#include <windows.h> #include <windows.h>
#endif #endif
// TODO: support in netplay/movies.
CWII_IPC_HLE_Device_usb_kbd::CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_usb_kbd::CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{} {}
@ -64,7 +66,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::IOCtl(u32 _CommandAddress)
{ {
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
if (SConfig::GetInstance().m_WiiKeyboard && !m_MessageQueue.empty()) if (SConfig::GetInstance().m_WiiKeyboard && !Core::g_want_determinism && !m_MessageQueue.empty())
{ {
Memory::CopyToEmu(BufferOut, &m_MessageQueue.front(), sizeof(SMessageData)); Memory::CopyToEmu(BufferOut, &m_MessageQueue.front(), sizeof(SMessageData));
m_MessageQueue.pop(); m_MessageQueue.pop();
@ -89,7 +91,7 @@ bool CWII_IPC_HLE_Device_usb_kbd::IsKeyPressed(int _Key)
u32 CWII_IPC_HLE_Device_usb_kbd::Update() u32 CWII_IPC_HLE_Device_usb_kbd::Update()
{ {
if (!SConfig::GetInstance().m_WiiKeyboard || !m_Active) if (!SConfig::GetInstance().m_WiiKeyboard || Core::g_want_determinism || !m_Active)
return 0; return 0;
u8 Modifiers = 0x00; u8 Modifiers = 0x00;