From 500497ec2df523b06f160b110ba099f0c9ba3089 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 21 Oct 2009 05:24:45 +0000 Subject: [PATCH] Use the SIPoll register to determine how frequent to poll SI git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4447 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/SI.cpp | 25 +++++++++++++++++----- Source/Core/Core/Src/HW/SI.h | 2 ++ Source/Core/Core/Src/HW/SystemTimers.cpp | 7 +++--- Source/Core/Core/Src/HW/VideoInterface.cpp | 8 ++++++- Source/Core/Core/Src/HW/VideoInterface.h | 3 ++- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 33317f4065..382f06744d 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -20,7 +20,9 @@ #include "../ConfigManager.h" #include "../CoreTiming.h" +#include "SystemTimers.h" #include "ProcessorInterface.h" +#include "VideoInterface.h" #include "SI.h" @@ -246,6 +248,7 @@ void Init() } g_Poll.Hex = 0; + g_Poll.X = 7; g_ComCSR.Hex = 0; g_StatusReg.Hex = 0; g_EXIClockCount.Hex = 0; @@ -399,10 +402,12 @@ void Write32(const u32 _iValue, const u32 _iAddress) case SI_CHANNEL_3_IN_LO: g_Channel[3].m_InLo.Hex = _iValue; break; case SI_POLL: - DEBUG_LOG(SERIALINTERFACE, "Poll: X=%03d Y=%03d %s%s%s%s%s%s%s%s", + INFO_LOG(SERIALINTERFACE, "Poll: X=%03d Y=%03d %s%s%s%s%s%s%s%s", g_Poll.X, g_Poll.Y, - g_Poll.EN0 ? "EN0 ":" ", g_Poll.EN1 ? "EN1 ":" ", g_Poll.EN2 ? "EN2 ":" ", g_Poll.EN3 ? "EN3 ":" ", - g_Poll.VBCPY0 ? "VBCPY0 ":" ", g_Poll.VBCPY1 ? "VBCPY1 ":" ", g_Poll.VBCPY2 ? "VBCPY2 ":" ", g_Poll.VBCPY3 ? "VBCPY3 ":" "); + g_Poll.EN0 ? "EN0 ":" ", g_Poll.EN1 ? "EN1 ":" ", + g_Poll.EN2 ? "EN2 ":" ", g_Poll.EN3 ? "EN3 ":" ", + g_Poll.VBCPY0 ? "VBCPY0 ":" ", g_Poll.VBCPY1 ? "VBCPY1 ":" ", + g_Poll.VBCPY2 ? "VBCPY2 ":" ", g_Poll.VBCPY3 ? "VBCPY3 ":" "); g_Poll.Hex = _iValue; break; @@ -600,16 +605,26 @@ void RunSIBuffer() else outLength++; -#if MAX_LOGLEVEL >= INFO_LEVEL +#if MAX_LOGLEVEL >= DEBUG_LEVEL int numOutput = #endif g_Channel[g_ComCSR.CHANNEL].m_pDevice->RunBuffer(g_SIBuffer, inLength); - INFO_LOG(SERIALINTERFACE, "RunSIBuffer (intLen: %i outLen: %i) (processed: %i)", inLength, outLength, numOutput); + DEBUG_LOG(SERIALINTERFACE, "RunSIBuffer (intLen: %i outLen: %i) (processed: %i)", inLength, outLength, numOutput); // Transfer completed GenerateSIInterrupt(INT_TCINT); g_ComCSR.TSTART = 0; } +int GetTicksToNextSIPoll() +{ + if (!g_Poll.Y && g_Poll.X) + return VideoInterface::GetTicksPerLine() * g_Poll.X; + else if (!g_Poll.Y) + return SystemTimers::GetTicksPerSecond() / 60; + + return min(VideoInterface::GetTicksPerFrame() / g_Poll.Y, VideoInterface::GetTicksPerLine() * g_Poll.X); +} + } // end of namespace SerialInterface diff --git a/Source/Core/Core/Src/HW/SI.h b/Source/Core/Core/Src/HW/SI.h index 9e20ac99a6..5a76df1212 100644 --- a/Source/Core/Core/Src/HW/SI.h +++ b/Source/Core/Core/Src/HW/SI.h @@ -39,6 +39,8 @@ void ChangeDevice(TSIDevices device, int deviceNumber); void Read32(u32& _uReturnValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress); +int GetTicksToNextSIPoll(); + }; // end of namespace SerialInterface #endif diff --git a/Source/Core/Core/Src/HW/SystemTimers.cpp b/Source/Core/Core/Src/HW/SystemTimers.cpp index a325379a62..da0816a490 100644 --- a/Source/Core/Core/Src/HW/SystemTimers.cpp +++ b/Source/Core/Core/Src/HW/SystemTimers.cpp @@ -184,14 +184,13 @@ void VICallback(u64 userdata, int cyclesLate) WII_IPC_HLE_Interface::Update(); VideoInterface::Update(); - CoreTiming::ScheduleEvent(VideoInterface::getTicksPerLine() - cyclesLate, et_VI); + CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerLine() - cyclesLate, et_VI); } void SICallback(u64 userdata, int cyclesLate) { - // TODO make this obey the SIPoll register SerialInterface::UpdateDevices(); - CoreTiming::ScheduleEvent((GetTicksPerSecond() / 60) - cyclesLate, et_SI); + CoreTiming::ScheduleEvent(SerialInterface::GetTicksToNextSIPoll() - cyclesLate, et_SI); } void DecrementerCallback(u64 userdata, int cyclesLate) @@ -286,7 +285,7 @@ void Init() et_PatchEngine = CoreTiming::RegisterEvent("PatchEngine", PatchEngineCallback); CoreTiming::ScheduleEvent(AI_PERIOD, et_AI); - CoreTiming::ScheduleEvent(VideoInterface::getTicksPerLine(), et_VI); + CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerLine(), et_VI); CoreTiming::ScheduleEvent(DSP_PERIOD, et_DSP); CoreTiming::ScheduleEvent(GetTicksPerSecond() / 60, et_SI); CoreTiming::ScheduleEvent(CPU_CORE_CLOCK / (32000 * 4 / 32), et_AudioFifo); diff --git a/Source/Core/Core/Src/HW/VideoInterface.cpp b/Source/Core/Core/Src/HW/VideoInterface.cpp index b464182212..9aa34a6b71 100644 --- a/Source/Core/Core/Src/HW/VideoInterface.cpp +++ b/Source/Core/Core/Src/HW/VideoInterface.cpp @@ -1044,12 +1044,18 @@ void UpdateTiming() } } -int getTicksPerLine() { +int GetTicksPerLine() +{ if (s_lineCount == 0) return 100000; return TicksPerFrame / s_lineCount; } +int GetTicksPerFrame() +{ + return TicksPerFrame; +} + static void BeginField(FieldType field) { diff --git a/Source/Core/Core/Src/HW/VideoInterface.h b/Source/Core/Core/Src/HW/VideoInterface.h index 5959c325c9..0260adf24e 100644 --- a/Source/Core/Core/Src/HW/VideoInterface.h +++ b/Source/Core/Core/Src/HW/VideoInterface.h @@ -54,7 +54,8 @@ namespace VideoInterface // Change values pertaining to video mode void UpdateTiming(); - int getTicksPerLine(); + int GetTicksPerLine(); + int GetTicksPerFrame(); }; #endif // _VIDEOINTERFACE_H