// Write to the status bar void WriteStatus() { std::string TmpStr = "Time: " + ReRecTimer.GetTimeElapsedFormatted(); TmpStr += StringFromFormat(" Frame: %s", ThousandSeparate(g_FrameCounter).c_str()); // The FPS is the total average since the game was booted TmpStr += StringFromFormat(" FPS: %i", (g_FrameCounter * 1000) / ReRecTimer.GetTimeElapsed()); TmpStr += StringFromFormat(" FrameStep: %s", g_FrameStep ? "On" : "Off"); Host_UpdateStatusBar(TmpStr.c_str(), 1); }
/* Wind back the frame counter when a save state is loaded. Currently we don't know what that means in time so we just guess that the time is proportional the the number of frames Todo: There are many assumptions here: We probably want to replace the time here by the actual time that we save together with the save state or the input recording for example. And have it adjusted for full speed playback (whether it's 30 fps or 60 fps or some other speed that the game is natively capped at). Also the input interrupts do not occur as often as the frame renderings, they occur more often. So we may want to move the input recording to fram updates, or perhaps sync the input interrupts to frame updates. */ void WindBack(int Counter) { /* Counter should be smaller than g_FrameCounter, however it currently updates faster than the frames so currently it may not be the same. Therefore I use the abs() function. */ int AbsoluteFrameDifference = abs(g_FrameCounter - Counter); float FractionalFrameDifference = (float) AbsoluteFrameDifference / (float) g_FrameCounter; // Update the frame counter g_FrameCounter = Counter; // Approximate a time to wind back the clock to // Get the current time u64 CurrentTimeMs = ReRecTimer.GetTimeElapsed(); // Save the current time in seconds in a new double double CurrentTimeSeconds = (double) (CurrentTimeMs / 1000); // Reduce it by the same proportion as the counter was wound back CurrentTimeSeconds = CurrentTimeSeconds * FractionalFrameDifference; // Update the clock ReRecTimer.WindBackStartingTime((u64)CurrentTimeSeconds * 1000); // Logging DEBUG_LOG(CONSOLE, "WindBack: %i %u\n", Counter, (u64)CurrentTimeSeconds); }