[NetPlay] Allow recording movies during netplay.
Fixes issue 6207.
This commit is contained in:
parent
7e1959a200
commit
8ae10b3e12
|
@ -644,6 +644,9 @@ int GetTicksToNextSIPoll()
|
||||||
// Poll for input at regular intervals (once per frame) when playing or recording a movie
|
// Poll for input at regular intervals (once per frame) when playing or recording a movie
|
||||||
if (Movie::IsPlayingInput() || Movie::IsRecordingInput())
|
if (Movie::IsPlayingInput() || Movie::IsRecordingInput())
|
||||||
{
|
{
|
||||||
|
if (Movie::IsNetPlayRecording())
|
||||||
|
return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate / 2;
|
||||||
|
else
|
||||||
return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate;
|
return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate;
|
||||||
}
|
}
|
||||||
if (NetPlay::IsNetPlayRunning())
|
if (NetPlay::IsNetPlayRunning())
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "../../Common/Src/NandPaths.h"
|
#include "../../Common/Src/NandPaths.h"
|
||||||
#include "polarssl/md5.h"
|
#include "polarssl/md5.h"
|
||||||
#include "scmrev.h"
|
#include "scmrev.h"
|
||||||
|
#include "NetPlayClient.h"
|
||||||
|
|
||||||
// The chunk to allocate movie data in multiples of.
|
// The chunk to allocate movie data in multiples of.
|
||||||
#define DTM_BASE_LENGTH (1024)
|
#define DTM_BASE_LENGTH (1024)
|
||||||
|
@ -50,8 +51,8 @@ u64 g_currentFrame = 0, g_totalFrames = 0; // VI
|
||||||
u64 g_currentLagCount = 0, g_totalLagCount = 0; // just stats
|
u64 g_currentLagCount = 0, g_totalLagCount = 0; // just stats
|
||||||
u64 g_currentInputCount = 0, g_totalInputCount = 0; // just stats
|
u64 g_currentInputCount = 0, g_totalInputCount = 0; // just stats
|
||||||
u64 g_recordingStartTime; // seconds since 1970 that recording started
|
u64 g_recordingStartTime; // seconds since 1970 that recording started
|
||||||
bool bSaveConfig, bSkipIdle, bDualCore, bProgressive, bDSPHLE, bFastDiscSpeed = false;
|
bool bSaveConfig = false, bSkipIdle = false, bDualCore = false, bProgressive = false, bDSPHLE = false, bFastDiscSpeed = false;
|
||||||
bool bMemcard, g_bClearSave, bSyncGPU = false;
|
bool bMemcard = false, g_bClearSave = false, bSyncGPU = false, bNetPlay = false;
|
||||||
std::string videoBackend = "unknown";
|
std::string videoBackend = "unknown";
|
||||||
int iCPUCore = 1;
|
int iCPUCore = 1;
|
||||||
bool g_bDiscChange = false;
|
bool g_bDiscChange = false;
|
||||||
|
@ -360,6 +361,11 @@ bool IsSyncGPU()
|
||||||
return bSyncGPU;
|
return bSyncGPU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsNetPlayRecording()
|
||||||
|
{
|
||||||
|
return bNetPlay;
|
||||||
|
}
|
||||||
|
|
||||||
void ChangePads(bool instantly)
|
void ChangePads(bool instantly)
|
||||||
{
|
{
|
||||||
if (Core::GetState() == Core::CORE_UNINITIALIZED)
|
if (Core::GetState() == Core::CORE_UNINITIALIZED)
|
||||||
|
@ -409,7 +415,14 @@ bool BeginRecordingInput(int controllers)
|
||||||
g_currentFrame = g_totalFrames = 0;
|
g_currentFrame = g_totalFrames = 0;
|
||||||
g_currentLagCount = g_totalLagCount = 0;
|
g_currentLagCount = g_totalLagCount = 0;
|
||||||
g_currentInputCount = g_totalInputCount = 0;
|
g_currentInputCount = g_totalInputCount = 0;
|
||||||
|
if (NetPlay::IsNetPlayRunning())
|
||||||
|
{
|
||||||
|
bNetPlay = true;
|
||||||
|
g_recordingStartTime = NETPLAY_INITIAL_GCTIME;
|
||||||
|
}
|
||||||
|
else
|
||||||
g_recordingStartTime = Common::Timer::GetLocalTimeSinceJan1970();
|
g_recordingStartTime = Common::Timer::GetLocalTimeSinceJan1970();
|
||||||
|
|
||||||
g_rerecords = 0;
|
g_rerecords = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
|
@ -682,6 +695,7 @@ void ReadHeader()
|
||||||
bMemcard = tmpHeader.bMemcard;
|
bMemcard = tmpHeader.bMemcard;
|
||||||
bongos = tmpHeader.bongos;
|
bongos = tmpHeader.bongos;
|
||||||
bSyncGPU = tmpHeader.bSyncGPU;
|
bSyncGPU = tmpHeader.bSyncGPU;
|
||||||
|
bNetPlay = tmpHeader.bNetPlay;
|
||||||
memcpy(revision, tmpHeader.revision, ARRAYSIZE(revision));
|
memcpy(revision, tmpHeader.revision, ARRAYSIZE(revision));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1108,6 +1122,7 @@ void SaveRecording(const char *filename)
|
||||||
header.bMemcard = bMemcard;
|
header.bMemcard = bMemcard;
|
||||||
header.bClearSave = g_bClearSave;
|
header.bClearSave = g_bClearSave;
|
||||||
header.bSyncGPU = bSyncGPU;
|
header.bSyncGPU = bSyncGPU;
|
||||||
|
header.bNetPlay = bNetPlay;
|
||||||
strncpy((char *)header.discChange, g_discChange.c_str(),ARRAYSIZE(header.discChange));
|
strncpy((char *)header.discChange, g_discChange.c_str(),ARRAYSIZE(header.discChange));
|
||||||
strncpy((char *)header.author, author.c_str(),ARRAYSIZE(header.author));
|
strncpy((char *)header.author, author.c_str(),ARRAYSIZE(header.author));
|
||||||
memcpy(header.md5,MD5,16);
|
memcpy(header.md5,MD5,16);
|
||||||
|
@ -1168,6 +1183,7 @@ void GetSettings()
|
||||||
videoBackend = g_video_backend->GetName();
|
videoBackend = g_video_backend->GetName();
|
||||||
bSyncGPU = SConfig::GetInstance().m_LocalCoreStartupParameter.bSyncGPU;
|
bSyncGPU = SConfig::GetInstance().m_LocalCoreStartupParameter.bSyncGPU;
|
||||||
iCPUCore = SConfig::GetInstance().m_LocalCoreStartupParameter.iCPUCore;
|
iCPUCore = SConfig::GetInstance().m_LocalCoreStartupParameter.iCPUCore;
|
||||||
|
bNetPlay = NetPlay::IsNetPlayRunning();
|
||||||
if (!Core::g_CoreStartupParameter.bWii)
|
if (!Core::g_CoreStartupParameter.bWii)
|
||||||
g_bClearSave = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
|
g_bClearSave = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
|
||||||
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;
|
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;
|
||||||
|
|
|
@ -107,7 +107,8 @@ struct DTMHeader {
|
||||||
bool bClearSave; // Create a new memory card when playing back a movie if true
|
bool bClearSave; // Create a new memory card when playing back a movie if true
|
||||||
u8 bongos;
|
u8 bongos;
|
||||||
bool bSyncGPU;
|
bool bSyncGPU;
|
||||||
u8 reserved[14]; // Padding for any new config options
|
bool bNetPlay;
|
||||||
|
u8 reserved[13]; // Padding for any new config options
|
||||||
u8 discChange[40]; // Name of iso file to switch to, for two disc games.
|
u8 discChange[40]; // Name of iso file to switch to, for two disc games.
|
||||||
u8 revision[20]; // Git hash
|
u8 revision[20]; // Git hash
|
||||||
u8 reserved2[27]; // Make heading 256 bytes, just because we can
|
u8 reserved2[27]; // Make heading 256 bytes, just because we can
|
||||||
|
@ -142,6 +143,7 @@ bool IsUsingMemcard();
|
||||||
bool IsSyncGPU();
|
bool IsSyncGPU();
|
||||||
void SetGraphicsConfig();
|
void SetGraphicsConfig();
|
||||||
void GetSettings();
|
void GetSettings();
|
||||||
|
bool IsNetPlayRecording();
|
||||||
|
|
||||||
bool IsUsingPad(int controller);
|
bool IsUsingPad(int controller);
|
||||||
bool IsUsingWiimote(int wiimote);
|
bool IsUsingWiimote(int wiimote);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
// for wiimote/ OSD messages
|
// for wiimote/ OSD messages
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "ConfigManager.h"
|
#include "ConfigManager.h"
|
||||||
|
#include "Movie.h"
|
||||||
|
|
||||||
std::mutex crit_netplay_client;
|
std::mutex crit_netplay_client;
|
||||||
static NetPlayClient * netplay_client = NULL;
|
static NetPlayClient * netplay_client = NULL;
|
||||||
|
@ -420,6 +421,21 @@ bool NetPlayClient::StartGame(const std::string &path)
|
||||||
|
|
||||||
ClearBuffers();
|
ClearBuffers();
|
||||||
|
|
||||||
|
if (m_dialog->IsRecording())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Movie::IsReadOnly())
|
||||||
|
Movie::SetReadOnly(false);
|
||||||
|
|
||||||
|
u8 controllers_mask = 0;
|
||||||
|
for (unsigned int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
if (m_pad_map[i] > 0)
|
||||||
|
controllers_mask |= (1 << i);
|
||||||
|
}
|
||||||
|
Movie::BeginRecordingInput(controllers_mask);
|
||||||
|
}
|
||||||
|
|
||||||
// boot game
|
// boot game
|
||||||
m_dialog->BootGame(path);
|
m_dialog->BootGame(path);
|
||||||
|
|
||||||
|
@ -527,6 +543,18 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_stat
|
||||||
Common::SleepCurrentThread(1);
|
Common::SleepCurrentThread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPADStatus tmp;
|
||||||
|
tmp.stickY = ((u8*)&netvalues->nHi)[0];
|
||||||
|
tmp.stickX = ((u8*)&netvalues->nHi)[1];
|
||||||
|
tmp.button = ((u16*)&netvalues->nHi)[1];
|
||||||
|
|
||||||
|
tmp.substickX = ((u8*)&netvalues->nLo)[3];
|
||||||
|
tmp.substickY = ((u8*)&netvalues->nLo)[2];
|
||||||
|
tmp.triggerLeft = ((u8*)&netvalues->nLo)[1];
|
||||||
|
tmp.triggerRight = ((u8*)&netvalues->nLo)[0];
|
||||||
|
Movie::RecordInput(&tmp, pad_nb);
|
||||||
|
Movie::InputUpdate();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,7 +662,7 @@ u32 CEXIIPL::NetPlay_GetGCTime()
|
||||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||||
|
|
||||||
if (netplay_client)
|
if (netplay_client)
|
||||||
return 1272737767; // watev
|
return NETPLAY_INITIAL_GCTIME; // watev
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "FifoQueue.h"
|
#include "FifoQueue.h"
|
||||||
|
|
||||||
|
const int NETPLAY_INITIAL_GCTIME = 1272737767;
|
||||||
|
|
||||||
class NetPad
|
class NetPad
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -46,6 +48,7 @@ public:
|
||||||
virtual void OnMsgChangeGame(const std::string& filename) = 0;
|
virtual void OnMsgChangeGame(const std::string& filename) = 0;
|
||||||
virtual void OnMsgStartGame() = 0;
|
virtual void OnMsgStartGame() = 0;
|
||||||
virtual void OnMsgStopGame() = 0;
|
virtual void OnMsgStopGame() = 0;
|
||||||
|
virtual bool IsRecording() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NetSettings g_NetPlaySettings;
|
extern NetSettings g_NetPlaySettings;
|
||||||
|
@ -117,6 +120,8 @@ protected:
|
||||||
|
|
||||||
PadMapping m_pad_map[4];
|
PadMapping m_pad_map[4];
|
||||||
|
|
||||||
|
bool m_is_recording;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateDevices();
|
void UpdateDevices();
|
||||||
void SendPadState(const PadMapping in_game_pad, const NetPad& np);
|
void SendPadState(const PadMapping in_game_pad, const NetPad& np);
|
||||||
|
|
|
@ -354,6 +354,9 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
|
||||||
bottom_szr->Add(m_memcard_write, 0, wxCENTER);
|
bottom_szr->Add(m_memcard_write, 0, wxCENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_record_chkbox = new wxCheckBox(panel, wxID_ANY, _("Record input"));
|
||||||
|
bottom_szr->Add(m_record_chkbox, 0, wxCENTER);
|
||||||
|
|
||||||
bottom_szr->AddStretchSpacer(1);
|
bottom_szr->AddStretchSpacer(1);
|
||||||
bottom_szr->Add(quit_btn);
|
bottom_szr->Add(quit_btn);
|
||||||
|
|
||||||
|
@ -565,6 +568,11 @@ void NetPlayDiag::OnConfigPads(wxCommandEvent&)
|
||||||
netplay_server->SetPadMapping(mapping);
|
netplay_server->SetPadMapping(mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NetPlayDiag::IsRecording()
|
||||||
|
{
|
||||||
|
return m_record_chkbox->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* const game_list, wxString& game_name)
|
ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* const game_list, wxString& game_name)
|
||||||
: wxDialog(parent, wxID_ANY, _("Change Game"), wxDefaultPosition, wxDefaultSize)
|
: wxDialog(parent, wxID_ANY, _("Change Game"), wxDefaultPosition, wxDefaultSize)
|
||||||
, m_game_name(game_name)
|
, m_game_name(game_name)
|
||||||
|
|
|
@ -81,6 +81,8 @@ public:
|
||||||
|
|
||||||
static NetPlayDiag *&GetInstance() { return npd; };
|
static NetPlayDiag *&GetInstance() { return npd; };
|
||||||
|
|
||||||
|
bool IsRecording();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
@ -97,6 +99,7 @@ private:
|
||||||
wxTextCtrl* m_chat_text;
|
wxTextCtrl* m_chat_text;
|
||||||
wxTextCtrl* m_chat_msg_text;
|
wxTextCtrl* m_chat_msg_text;
|
||||||
wxCheckBox* m_memcard_write;
|
wxCheckBox* m_memcard_write;
|
||||||
|
wxCheckBox* m_record_chkbox;
|
||||||
|
|
||||||
std::string m_selected_game;
|
std::string m_selected_game;
|
||||||
wxButton* m_game_btn;
|
wxButton* m_game_btn;
|
||||||
|
|
Loading…
Reference in New Issue