Fixed bug where flags could be permanently on or off due to multithreaded issues
This commit is contained in:
parent
97c9fb88dd
commit
c093de422d
2 changed files with 24 additions and 15 deletions
|
@ -11,6 +11,7 @@ uint8_t EmulationSettings::_versionRevision = 1;
|
||||||
|
|
||||||
Language EmulationSettings::_displayLanguage = Language::English;
|
Language EmulationSettings::_displayLanguage = Language::English;
|
||||||
|
|
||||||
|
SimpleLock EmulationSettings::_lock;
|
||||||
uint64_t EmulationSettings::_flags = 0;
|
uint64_t EmulationSettings::_flags = 0;
|
||||||
|
|
||||||
bool EmulationSettings::_audioSettingsChanged = true;
|
bool EmulationSettings::_audioSettingsChanged = true;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "MessageManager.h"
|
#include "MessageManager.h"
|
||||||
#include "GameClient.h"
|
#include "GameClient.h"
|
||||||
|
#include "../Utilities/SimpleLock.h"
|
||||||
|
|
||||||
enum EmulationFlags : uint64_t
|
enum EmulationFlags : uint64_t
|
||||||
{
|
{
|
||||||
|
@ -438,6 +439,8 @@ private:
|
||||||
static EmulatorKeyMappingSet _emulatorKeys;
|
static EmulatorKeyMappingSet _emulatorKeys;
|
||||||
|
|
||||||
static RamPowerOnState _ramPowerOnState;
|
static RamPowerOnState _ramPowerOnState;
|
||||||
|
|
||||||
|
static SimpleLock _lock;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static uint32_t GetMesenVersion()
|
static uint32_t GetMesenVersion()
|
||||||
|
@ -452,35 +455,40 @@ public:
|
||||||
|
|
||||||
static void SetFlags(uint64_t flags)
|
static void SetFlags(uint64_t flags)
|
||||||
{
|
{
|
||||||
_flags |= flags;
|
if((_flags & flags) != flags) {
|
||||||
|
//Need a lock to prevent flag changes from being ignored due to multithreaded access
|
||||||
|
LockHandler lock = _lock.AcquireSafe();
|
||||||
|
_flags |= flags;
|
||||||
|
|
||||||
_backgroundEnabled = !CheckFlag(EmulationFlags::DisableBackground);
|
_backgroundEnabled = !CheckFlag(EmulationFlags::DisableBackground);
|
||||||
_spritesEnabled = !CheckFlag(EmulationFlags::DisableSprites);
|
_spritesEnabled = !CheckFlag(EmulationFlags::DisableSprites);
|
||||||
if(flags & EmulationFlags::UseCustomVsPalette) {
|
if(flags & EmulationFlags::UseCustomVsPalette) {
|
||||||
UpdateCurrentPalette();
|
UpdateCurrentPalette();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetFlagState(EmulationFlags flag, bool enabled)
|
static void SetFlagState(EmulationFlags flag, bool enabled)
|
||||||
{
|
{
|
||||||
if(enabled) {
|
if(enabled) {
|
||||||
_flags |= flag;
|
SetFlags(flag);
|
||||||
} else {
|
} else {
|
||||||
_flags &= ~flag;
|
ClearFlags(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
_backgroundEnabled = !CheckFlag(EmulationFlags::DisableBackground);
|
|
||||||
_spritesEnabled = !CheckFlag(EmulationFlags::DisableSprites);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClearFlags(uint64_t flags)
|
static void ClearFlags(uint64_t flags)
|
||||||
{
|
{
|
||||||
_flags &= ~flags;
|
if((_flags & flags) != 0) {
|
||||||
|
//Need a lock to prevent flag changes from being ignored due to multithreaded access
|
||||||
|
LockHandler lock = _lock.AcquireSafe();
|
||||||
|
_flags &= ~flags;
|
||||||
|
|
||||||
_backgroundEnabled = !CheckFlag(EmulationFlags::DisableBackground);
|
_backgroundEnabled = !CheckFlag(EmulationFlags::DisableBackground);
|
||||||
_spritesEnabled = !CheckFlag(EmulationFlags::DisableSprites);
|
_spritesEnabled = !CheckFlag(EmulationFlags::DisableSprites);
|
||||||
if(flags & EmulationFlags::UseCustomVsPalette) {
|
if(flags & EmulationFlags::UseCustomVsPalette) {
|
||||||
UpdateCurrentPalette();
|
UpdateCurrentPalette();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue