From 0ef1ee7a83d0f6c11d1d9115af852bd7aed697fc Mon Sep 17 00:00:00 2001 From: Chris Burgener Date: Tue, 19 Jul 2016 20:23:25 -0400 Subject: [PATCH] Display RTC on OSD --- Source/Core/Core/ConfigManager.cpp | 2 ++ Source/Core/Core/ConfigManager.h | 1 + Source/Core/Core/HW/EXI_DeviceIPL.cpp | 8 +++++++- Source/Core/Core/HW/EXI_DeviceIPL.h | 1 + Source/Core/Core/Movie.cpp | 12 ++++++++++++ Source/Core/Core/Movie.h | 1 + Source/Core/DolphinWX/Frame.cpp | 1 + Source/Core/DolphinWX/Frame.h | 1 + Source/Core/DolphinWX/FrameTools.cpp | 8 ++++++++ Source/Core/DolphinWX/Globals.h | 1 + Source/Core/VideoCommon/RenderBase.cpp | 6 ++++++ 11 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 5d2adf1e83..edca937120 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -286,6 +286,7 @@ void SConfig::SaveMovieSettings(IniFile& ini) movie->Set("DumpFrames", m_DumpFrames); movie->Set("DumpFramesSilent", m_DumpFramesSilent); movie->Set("ShowInputDisplay", m_ShowInputDisplay); + movie->Set("ShowRTC", m_ShowRTC); } void SConfig::SaveDSPSettings(IniFile& ini) @@ -564,6 +565,7 @@ void SConfig::LoadMovieSettings(IniFile& ini) movie->Get("DumpFrames", &m_DumpFrames, false); movie->Get("DumpFramesSilent", &m_DumpFramesSilent, false); movie->Get("ShowInputDisplay", &m_ShowInputDisplay, false); + movie->Get("ShowRTC", &m_ShowRTC, false); } void SConfig::LoadDSPSettings(IniFile& ini) diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index e5a4f5cc89..4a7209f11e 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -255,6 +255,7 @@ struct SConfig : NonCopyable bool m_PauseMovie; bool m_ShowLag; bool m_ShowFrameCount; + bool m_ShowRTC; std::string m_strMovieAuthor; unsigned int m_FrameSkip; bool m_DumpFrames; diff --git a/Source/Core/Core/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI_DeviceIPL.cpp index e66a8dc378..51e55511ea 100644 --- a/Source/Core/Core/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI_DeviceIPL.cpp @@ -32,6 +32,8 @@ static const char iplverPAL[0x100] = "(C) 1999-2001 Nintendo. All rights reserv static const char iplverNTSC[0x100] = "(C) 1999-2001 Nintendo. All rights reserved." "(C) 1999 ArtX Inc. All rights reserved."; +static constexpr u32 cJanuary2000 = 0x386D4380; // Seconds between 1.1.1970 and 1.1.2000 + // bootrom descrambler reversed by segher // Copyright 2008 Segher Boessenkool void CEXIIPL::Descrambler(u8* data, u32 size) @@ -405,7 +407,6 @@ void CEXIIPL::TransferByte(u8& _uByte) u32 CEXIIPL::GetGCTime() { u64 ltime = 0; - static const u32 cJanuary2000 = 0x386D4380; // Seconds between 1.1.1970 and 1.1.2000 if (Movie::IsMovieActive()) { @@ -446,3 +447,8 @@ u32 CEXIIPL::GetGCTime() return ((u32)ltime - cJanuary2000 - Bias); #endif } + +u32 CEXIIPL::GetGCTimeJan1970() +{ + return GetGCTime() + cJanuary2000; +} diff --git a/Source/Core/Core/HW/EXI_DeviceIPL.h b/Source/Core/Core/HW/EXI_DeviceIPL.h index 5fc20b8abc..7a5c76cff9 100644 --- a/Source/Core/Core/HW/EXI_DeviceIPL.h +++ b/Source/Core/Core/HW/EXI_DeviceIPL.h @@ -21,6 +21,7 @@ public: void DoState(PointerWrap& p) override; static u32 GetGCTime(); + static u32 GetGCTimeJan1970(); static u64 NetPlay_GetGCTime(); static void Descrambler(u8* data, u32 size); diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index b42b008327..7eb6f0308a 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -178,6 +178,18 @@ std::string GetInputDisplay() return input_display; } +// NOTE: GPU Thread +std::string GetRTCDisplay() +{ + time_t current_time = CEXIIPL::GetGCTimeJan1970(); + tm* gm_time = gmtime(¤t_time); + char buffer[256]; + strftime(buffer, sizeof(buffer), "Date/Time: %c", gm_time); + std::stringstream format_time; + format_time << buffer; + return format_time.str(); +} + // NOTE: GPU Thread void FrameUpdate() { diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index 5edb8e3fa3..c7b9d8c5a6 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -179,6 +179,7 @@ void CheckWiimoteStatus(int wiimote, u8* data, const struct WiimoteEmu::ReportFe int ext, const wiimote_key key); std::string GetInputDisplay(); +std::string GetRTCDisplay(); // Done this way to avoid mixing of core and gui code typedef void (*GCManipFunction)(GCPadStatus*, int); diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 4260644e46..e918db9b59 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -255,6 +255,7 @@ EVT_MENU(IDM_TOGGLE_PAUSE_MOVIE, CFrame::OnTogglePauseMovie) EVT_MENU(IDM_SHOW_LAG, CFrame::OnShowLag) EVT_MENU(IDM_SHOW_FRAME_COUNT, CFrame::OnShowFrameCount) EVT_MENU(IDM_SHOW_INPUT_DISPLAY, CFrame::OnShowInputDisplay) +EVT_MENU(IDM_SHOW_RTC_DISPLAY, CFrame::OnShowRTCDisplay) EVT_MENU(IDM_FRAMESTEP, CFrame::OnFrameStep) EVT_MENU(IDM_SCREENSHOT, CFrame::OnScreenshot) EVT_MENU(IDM_TOGGLE_DUMP_FRAMES, CFrame::OnToggleDumpFrames) diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index f600a91bf5..067d80675e 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -265,6 +265,7 @@ private: void OnShowLag(wxCommandEvent& event); void OnShowFrameCount(wxCommandEvent& event); void OnShowInputDisplay(wxCommandEvent& event); + void OnShowRTCDisplay(wxCommandEvent& event); void OnChangeDisc(wxCommandEvent& event); void OnScreenshot(wxCommandEvent& event); void OnActive(wxActivateEvent& event); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 79e395337f..0ea5685a17 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -206,6 +206,8 @@ wxMenuBar* CFrame::CreateMenu() movieMenu->Check(IDM_RECORD_READ_ONLY, true); movieMenu->AppendCheckItem(IDM_SHOW_INPUT_DISPLAY, _("Show Input Display")); movieMenu->Check(IDM_SHOW_INPUT_DISPLAY, SConfig::GetInstance().m_ShowInputDisplay); + movieMenu->AppendCheckItem(IDM_SHOW_RTC_DISPLAY, _("Show System Clock")); + movieMenu->Check(IDM_SHOW_RTC_DISPLAY, SConfig::GetInstance().m_ShowRTC); movieMenu->AppendSeparator(); movieMenu->AppendCheckItem(IDM_TOGGLE_DUMP_FRAMES, _("Dump Frames")); movieMenu->Check(IDM_TOGGLE_DUMP_FRAMES, SConfig::GetInstance().m_DumpFrames); @@ -757,6 +759,12 @@ void CFrame::OnShowInputDisplay(wxCommandEvent& WXUNUSED(event)) SConfig::GetInstance().SaveSettings(); } +void CFrame::OnShowRTCDisplay(wxCommandEvent& WXUNUSED(event)) +{ + SConfig::GetInstance().m_ShowRTC = !SConfig::GetInstance().m_ShowRTC; + SConfig::GetInstance().SaveSettings(); +} + void CFrame::OnFrameStep(wxCommandEvent& event) { bool wasPaused = (Core::GetState() == Core::CORE_PAUSE); diff --git a/Source/Core/DolphinWX/Globals.h b/Source/Core/DolphinWX/Globals.h index f5364e7e6b..5779334918 100644 --- a/Source/Core/DolphinWX/Globals.h +++ b/Source/Core/DolphinWX/Globals.h @@ -98,6 +98,7 @@ enum IDM_SHOW_LAG, IDM_SHOW_FRAME_COUNT, IDM_SHOW_INPUT_DISPLAY, + IDM_SHOW_RTC_DISPLAY, IDM_FRAMESTEP, IDM_SCREENSHOT, IDM_TOGGLE_DUMP_FRAMES, diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index eb2ec723f9..07854ba42f 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -333,6 +333,12 @@ void Renderer::DrawDebugText() final_yellow += "\n"; } + if (SConfig::GetInstance().m_ShowRTC) + { + final_cyan += Movie::GetRTCDisplay(); + final_yellow += "\n"; + } + // OSD Menu messages if (OSDChoice > 0) {