Add Tick Count to Movie Files

Added tick count to .dtm movie files for more accurate time calculations
This commit is contained in:
Fog 2014-06-18 16:13:46 -04:00
parent afc4a37058
commit c6e1a19e61
3 changed files with 17 additions and 3 deletions

View file

@ -13,6 +13,7 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "Core/State.h"
@ -54,6 +55,7 @@ u64 g_currentByte = 0, g_totalBytes = 0;
u64 g_currentFrame = 0, g_totalFrames = 0; // VI
u64 g_currentLagCount = 0, g_totalLagCount = 0; // just stats
u64 g_currentInputCount = 0, g_totalInputCount = 0; // just stats
u64 g_totalTickCount = 0, g_tickCountAtLastInput = 0; // just stats
u64 g_recordingStartTime; // seconds since 1970 that recording started
bool bSaveConfig = false, bSkipIdle = false, bDualCore = false, bProgressive = false, bDSPHLE = false, bFastDiscSpeed = false;
bool bMemcard = false, g_bClearSave = false, bSyncGPU = false, bNetPlay = false;
@ -176,6 +178,7 @@ void Init()
GetSettings();
std::thread md5thread(GetMD5);
md5thread.detach();
g_tickCountAtLastInput = 0;
}
g_frameSkipCounter = g_framesToSkip;
@ -201,7 +204,11 @@ void InputUpdate()
{
g_currentInputCount++;
if (IsRecordingInput())
{
g_totalInputCount = g_currentInputCount;
g_totalTickCount += CoreTiming::GetTicks() - g_tickCountAtLastInput;
g_tickCountAtLastInput = CoreTiming::GetTicks();
}
if (IsPlayingInput() && g_currentInputCount == (g_totalInputCount -1) && SConfig::GetInstance().m_PauseMovie)
Core::SetState(Core::CORE_PAUSE);
@ -421,6 +428,7 @@ bool BeginRecordingInput(int controllers)
g_currentFrame = g_totalFrames = 0;
g_currentLagCount = g_totalLagCount = 0;
g_currentInputCount = g_totalInputCount = 0;
g_totalTickCount = g_tickCountAtLastInput = 0;
if (NetPlay::IsNetPlayRunning())
{
bNetPlay = true;
@ -745,6 +753,7 @@ bool PlayInput(const std::string& filename)
g_totalFrames = tmpHeader.frameCount;
g_totalLagCount = tmpHeader.lagCount;
g_totalInputCount = tmpHeader.inputCount;
g_totalTickCount = tmpHeader.tickCount;
g_currentFrame = 0;
g_currentLagCount = 0;
g_currentInputCount = 0;
@ -786,6 +795,7 @@ void DoState(PointerWrap &p)
p.Do(g_currentLagCount);
p.Do(g_currentInputCount);
p.Do(g_bPolled);
p.Do(g_tickCountAtLastInput);
// other variables (such as g_totalBytes and g_totalFrames) are set in LoadInput
}
@ -834,6 +844,7 @@ void LoadInput(const std::string& filename)
g_totalFrames = tmpHeader.frameCount;
g_totalLagCount = tmpHeader.lagCount;
g_totalInputCount = tmpHeader.inputCount;
g_totalTickCount = tmpHeader.tickCount;
EnsureTmpInputSize((size_t)totalSavedBytes);
g_totalBytes = totalSavedBytes;
@ -1143,6 +1154,7 @@ void SaveRecording(const std::string& filename)
memcpy(header.revision, revision, ArraySize(header.revision));
header.DSPiromHash = DSPiromHash;
header.DSPcoefHash = DSPcoefHash;
header.tickCount = g_totalTickCount;
// TODO
header.uniqueID = 0;
@ -1276,7 +1288,7 @@ void GetMD5()
void Shutdown()
{
g_currentInputCount = g_totalInputCount = g_totalFrames = g_totalBytes = 0;
g_currentInputCount = g_totalInputCount = g_totalFrames = g_totalBytes = g_tickCountAtLastInput = 0;
delete [] tmpInput;
tmpInput = nullptr;
tmpInputAllocated = 0;

View file

@ -64,6 +64,7 @@ extern u64 g_currentByte, g_totalBytes;
extern u64 g_currentFrame, g_totalFrames;
extern u64 g_currentLagCount, g_totalLagCount;
extern u64 g_currentInputCount, g_totalInputCount;
extern u64 g_currentTickCount, g_totalTickCount, g_tickCountAtLastInput;
extern std::string g_discChange;
extern u32 g_rerecords;
@ -116,7 +117,8 @@ struct DTMHeader
u8 revision[20]; // Git hash
u32 DSPiromHash;
u32 DSPcoefHash;
u8 reserved2[19]; // Make heading 256 bytes, just because we can
u64 tickCount; // Number of ticks in the recording
u8 reserved2[11]; // Make heading 256 bytes, just because we can
};
static_assert(sizeof(DTMHeader) == 256, "DTMHeader should be 256 bytes");

View file

@ -63,7 +63,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
static std::thread g_save_thread;
// Don't forget to increase this after doing changes on the savestate system
static const u32 STATE_VERSION = 23;
static const u32 STATE_VERSION = 24;
enum
{