From 0b5bcd6ddae787a835c29d37c04709464300f898 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 22 Jan 2018 12:45:39 +0100 Subject: [PATCH] Removed the LED sequence cycle reset feature. After at most 1/6th of a second, a new sequence will be active anyway, so resetting it won't be very useful anyway. This removes the need to check if a new sequence is set, and the need for the bLedHasChanged status boolean, simplifying the code further. This should fix https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/885 --- src/Cxbx/WndMain.cpp | 21 ++------------------- src/CxbxKrnl/EmuShared.h | 3 --- src/devices/SMCDevice.cpp | 2 -- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/Cxbx/WndMain.cpp b/src/Cxbx/WndMain.cpp index db200becb..341fd41cb 100644 --- a/src/Cxbx/WndMain.cpp +++ b/src/Cxbx/WndMain.cpp @@ -470,11 +470,9 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP if (m_hwndChild == NULL) { float fps = 0; float mspf = 0; - bool LedHasChanged = false; int LedSequence[4] = { XBOX_LED_COLOUR_GREEN, XBOX_LED_COLOUR_GREEN, XBOX_LED_COLOUR_GREEN, XBOX_LED_COLOUR_GREEN }; g_EmuShared->SetCurrentMSpF(&mspf); g_EmuShared->SetCurrentFPS(&fps); - g_EmuShared->SetLedStatus(&LedHasChanged); g_EmuShared->SetLedSequence(LedSequence); SetTimer(hwnd, TIMERID_FPS, 1000, (TIMERPROC)NULL); SetTimer(hwnd, TIMERID_LED, XBOX_LED_FLASH_PERIOD, (TIMERPROC)NULL); @@ -2112,25 +2110,10 @@ void WndMain::DrawLedBitmap(HWND hwnd, bool bdefault) ActiveLEDColor = XBOX_LED_COLOUR_OFF; } else { // draw colored bitmap - static int LedSequence[4] = { XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF }; + int LedSequence[4] = { XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF }; static int LedSequenceOffset = 0; - bool bLedHasChanged; - - g_EmuShared->GetLedStatus(&bLedHasChanged); - if (bLedHasChanged) { - // To prevent restarting the sequence when identical sequences are set, check if the new sequence is actually different - int NewLedSequence[4]; - g_EmuShared->GetLedSequence(NewLedSequence); - if (LedSequence[0] != NewLedSequence[0] || LedSequence[1] != NewLedSequence[1] || LedSequence[2] != NewLedSequence[2] || LedSequence[3] != NewLedSequence[3]) { - // Only when the new sequence is different, restart it's cycle - g_EmuShared->GetLedSequence(LedSequence); - LedSequenceOffset = 0; - } - // Indicate we've handled the change - bLedHasChanged = false; - g_EmuShared->SetLedStatus(&bLedHasChanged); - } + g_EmuShared->GetLedSequence(LedSequence); // Select active color and cycle through all 4 phases in the sequence ActiveLEDColor = LedSequence[LedSequenceOffset & 3]; diff --git a/src/CxbxKrnl/EmuShared.h b/src/CxbxKrnl/EmuShared.h index 15ac8fbdb..45311670f 100644 --- a/src/CxbxKrnl/EmuShared.h +++ b/src/CxbxKrnl/EmuShared.h @@ -146,8 +146,6 @@ class EmuShared : public Mutex // ****************************************************************** // * Xbox LED values Accessors // ****************************************************************** - void GetLedStatus(bool *value) { Lock(); *value = m_bLedHasChanged; Unlock(); } - void SetLedStatus(bool *value) { Lock(); m_bLedHasChanged = *value; Unlock(); } void GetLedSequence(int *value) { Lock(); @@ -189,7 +187,6 @@ class EmuShared : public Mutex float m_FPS; bool m_bMultiXbe; PAddr m_LaunchDataPAddress; - bool m_bLedHasChanged; int m_LedSequence[4]; }; diff --git a/src/devices/SMCDevice.cpp b/src/devices/SMCDevice.cpp index 74aad143e..026e9e3bb 100644 --- a/src/devices/SMCDevice.cpp +++ b/src/devices/SMCDevice.cpp @@ -52,7 +52,6 @@ void SetLEDSequence(LED::Sequence aLEDSequence) // See http://xboxdevwiki.net/PIC#The_LED DbgPrintf("SMC : SetLEDSequence : %u\n", (byte)aLEDSequence); - bool bLedHasChanged = true; int LedSequence[4] = { XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF }; LedSequence[0] = ((aLEDSequence >> 6) & 2) | ((aLEDSequence >> 3) & 1); @@ -60,7 +59,6 @@ void SetLEDSequence(LED::Sequence aLEDSequence) LedSequence[2] = ((aLEDSequence >> 4) & 2) | ((aLEDSequence >> 1) & 1); LedSequence[3] = ((aLEDSequence >> 3) & 2) | ((aLEDSequence >> 0) & 1); - g_EmuShared->SetLedStatus(&bLedHasChanged); g_EmuShared->SetLedSequence(LedSequence); }