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
This commit is contained in:
parent
b015cc715b
commit
0b5bcd6dda
|
@ -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);
|
||||
}
|
||||
|
||||
// Select active color and cycle through all 4 phases in the sequence
|
||||
ActiveLEDColor = LedSequence[LedSequenceOffset & 3];
|
||||
|
|
|
@ -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];
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue