This commit is contained in:
oddMLan 2025-06-22 00:59:21 -06:00 committed by GitHub
commit a43d82decd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 295 additions and 0 deletions

View File

@ -188,14 +188,42 @@ CEnhancement::CEnhancement(const char * Ident, const char * Entry) :
{
m_Note = &Pos[1];
}
else if (stricmp(Key.c_str(), "WIP") == 0)
{
// TODO
}
else if (stricmp(Key.c_str(), "OnByDefault") == 0 || stricmp(Key.c_str(), "On By Default") == 0)
{
m_OnByDefault = Pos[1] == '1';
}
else if (stricmp(Key.c_str(), "Counter Factor") == 0)
{
SetCounterFactor(true, atoi(&Pos[1]));
}
else if (stricmp(Key.c_str(), "Overclock") == 0)
{
SetOverClock(true, atoi(&Pos[1]));
}
else if (stricmp(Key.c_str(), "VI Refresh") == 0)
{
SetViRefresh(true, atoi(&Pos[1]));
}
else if (stricmp(Key.c_str(), "RDRAM Size") == 0)
{
SetRdramSize(true, atoi(&Pos[1]));
}
else if (stricmp(Key.c_str(), "SMM-Protect") == 0)
{
SetSmmProtect(true, Pos[1] == '1');
}
else if (stricmp(Key.c_str(), "Fixed Audio") == 0)
{
SetFixedAudio(true, Pos[1] == '1');
}
else if (stricmp(Key.c_str(), "Sync Audio") == 0)
{
SetSyncAudio(true, Pos[1] == '1');
}
else
{
g_Notify->BreakPoint(__FILE__, __LINE__);
@ -369,6 +397,42 @@ void CEnhancement::SetOverClock(bool OverClock, uint32_t OverClockModifier)
}
}
void CEnhancement::SetCounterFactor(bool hasValue, uint32_t value)
{
m_HasCounterFactor = hasValue;
m_CounterFactor = value;
}
void CEnhancement::SetViRefresh(bool hasValue, uint32_t value)
{
m_HasViRefresh = hasValue;
m_ViRefresh = value;
}
void CEnhancement::SetRdramSize(bool hasValue, uint32_t value)
{
m_HasRdramSize = hasValue;
m_RdramSize = value;
}
void CEnhancement::SetSmmProtect(bool hasValue, bool value)
{
m_HasSmmProtect = hasValue;
m_SmmProtect = value;
}
void CEnhancement::SetFixedAudio(bool hasValue, bool value)
{
m_HasFixedAudio = hasValue;
m_FixedAudio = value;
}
void CEnhancement::SetSyncAudio(bool hasValue, bool value)
{
m_HasSyncAudio = hasValue;
m_SyncAudio = value;
}
void CEnhancement::CheckValid(void)
{
m_Valid = false;

View File

@ -35,6 +35,12 @@ public:
void SetActive(bool Active);
void SetOnByDefault(bool OnByDefault);
void SetOverClock(bool OverClock, uint32_t OverClockModifier);
void SetCounterFactor(bool hasValue, uint32_t value);
void SetViRefresh(bool hasValue, uint32_t value);
void SetRdramSize(bool hasValue, uint32_t value);
void SetSmmProtect(bool hasValue, bool value);
void SetFixedAudio(bool hasValue, bool value);
void SetSyncAudio(bool hasValue, bool value);
inline const std::string & GetName(void) const
{
@ -88,6 +94,54 @@ public:
{
return m_OverClockModifier;
}
inline bool HasCounterFactor() const
{
return m_HasCounterFactor;
}
inline uint32_t CounterFactor() const
{
return m_CounterFactor;
}
inline bool HasViRefresh() const
{
return m_HasViRefresh;
}
inline uint32_t ViRefresh() const
{
return m_ViRefresh;
}
inline bool HasRdramSize() const
{
return m_HasRdramSize;
}
inline uint32_t RdramSize() const
{
return m_RdramSize;
}
inline bool HasSmmProtect() const
{
return m_HasSmmProtect;
}
inline bool SmmProtect() const
{
return m_SmmProtect;
}
inline bool HasFixedAudio() const
{
return m_HasFixedAudio;
}
inline bool FixedAudio() const
{
return m_FixedAudio;
}
inline bool HasSyncAudio() const
{
return m_HasSyncAudio;
}
inline bool SyncAudio() const
{
return m_SyncAudio;
}
bool OptionSelected() const
{
return (m_SelectedOption & 0xFFFF0000) == 0;
@ -118,4 +172,16 @@ private:
uint32_t m_OverClockModifier;
bool m_Active;
bool m_Valid;
bool m_HasCounterFactor = false;
uint32_t m_CounterFactor = 0;
bool m_HasViRefresh = false;
uint32_t m_ViRefresh = 0;
bool m_HasRdramSize = false;
uint32_t m_RdramSize = 0;
bool m_HasSmmProtect = false;
bool m_SmmProtect = false;
bool m_HasFixedAudio = false;
bool m_FixedAudio = false;
bool m_HasSyncAudio = false;
bool m_SyncAudio = false;
};

View File

@ -280,11 +280,72 @@ void CEnhancements::LoadActive(CMipsMemoryVM * MMU, CPlugins * Plugins)
m_OverClock = false;
m_OverClockModifier = 1;
// Track enhancement overrides for each setting
bool hasCounterFactor = false;
uint32_t counterFactor = 2;
bool hasViRefresh = false;
uint32_t viRefresh = 1500;
bool hasRdramSize = false;
uint32_t rdramSize = 0;
bool hasSmmProtect = false;
bool smmProtect = false;
bool hasFixedAudio = false;
bool fixedAudio = true;
bool hasSyncAudio = false;
bool syncAudio = true;
ResetCodes(MMU);
LoadActive(m_Cheats, nullptr);
LoadActive(m_Enhancements, Plugins);
// Scan all active enhancements for overrides
for (const auto & list : {m_Cheats, m_Enhancements})
{
for (const auto & pair : list)
{
const CEnhancement & enh = pair.second;
if (!enh.Valid() || !enh.Active()) continue;
if (enh.HasCounterFactor())
{
hasCounterFactor = true;
counterFactor = enh.CounterFactor();
}
if (enh.HasViRefresh())
{
hasViRefresh = true;
viRefresh = enh.ViRefresh();
}
if (enh.HasRdramSize())
{
hasRdramSize = true;
rdramSize = enh.RdramSize();
}
if (enh.HasSmmProtect())
{
hasSmmProtect = true;
smmProtect = enh.SmmProtect();
}
if (enh.HasFixedAudio())
{
hasFixedAudio = true;
fixedAudio = enh.FixedAudio();
}
if (enh.HasSyncAudio())
{
hasSyncAudio = true;
syncAudio = enh.SyncAudio();
}
}
}
// Apply enhancement overrides
CGameSettings::SetOverClockModifier(m_OverClock, m_OverClockModifier);
CGameSettings::SetCountPerOp(hasCounterFactor, counterFactor);
CGameSettings::SetViRefreshRate(hasViRefresh, viRefresh);
CGameSettings::SetRdramSize(hasRdramSize, rdramSize);
CGameSettings::SetSmmProtect(hasSmmProtect, smmProtect);
CGameSettings::SetFixedAudio(hasFixedAudio, fixedAudio);
CGameSettings::SetSyncAudio(hasSyncAudio, syncAudio);
}
CEnhancementList CEnhancements::Cheats(void)

View File

@ -147,3 +147,101 @@ void CGameSettings::EnableDiskChanged(void *)
{
m_EnableDisk = g_Settings->LoadBool(Setting_EnableDisk);
}
void CGameSettings::SetCountPerOp(bool enhancementActive, uint32_t value)
{
static bool s_EnhancementActive = false;
static uint32_t s_EnhancementValue = 2;
s_EnhancementActive = enhancementActive;
s_EnhancementValue = value;
if (s_EnhancementActive)
{
m_CountPerOp = s_EnhancementValue;
}
else
{
m_CountPerOp = g_Settings->LoadDword(Game_CounterFactor);
if (m_CountPerOp == 0) m_CountPerOp = 2;
}
}
void CGameSettings::SetViRefreshRate(bool enhancementActive, uint32_t value)
{
static bool s_EnhancementActive = false;
static uint32_t s_EnhancementValue = 1500;
s_EnhancementActive = enhancementActive;
s_EnhancementValue = value;
if (s_EnhancementActive)
{
m_ViRefreshRate = s_EnhancementValue;
}
else
{
m_ViRefreshRate = g_Settings->LoadDword(Game_ViRefreshRate);
if (m_ViRefreshRate == 0) m_ViRefreshRate = 1500;
}
}
void CGameSettings::SetRdramSize(bool enhancementActive, uint32_t value)
{
static bool s_EnhancementActive = false;
static uint32_t s_EnhancementValue = 0;
s_EnhancementActive = enhancementActive;
s_EnhancementValue = value;
if (s_EnhancementActive)
{
m_RdramSize = s_EnhancementValue;
}
else
{
m_RdramSize = g_Settings->LoadDword(Game_RDRamSize);
}
}
void CGameSettings::SetFixedAudio(bool enhancementActive, bool value)
{
static bool s_EnhancementActive = false;
static bool s_EnhancementValue = true;
s_EnhancementActive = enhancementActive;
s_EnhancementValue = value;
if (s_EnhancementActive)
{
m_bFixedAudio = s_EnhancementValue;
}
else
{
m_bFixedAudio = g_Settings->LoadBool(Game_FixedAudio);
}
}
void CGameSettings::SetSyncAudio(bool enhancementActive, bool value)
{
static bool s_EnhancementActive = false;
static bool s_EnhancementValue = true;
s_EnhancementActive = enhancementActive;
s_EnhancementValue = value;
if (s_EnhancementActive)
{
m_bSyncToAudio = s_EnhancementValue;
}
else
{
m_bSyncToAudio = g_Settings->LoadBool(Game_SyncViaAudio) && g_Settings->LoadBool(Setting_SyncViaAudioEnabled) && g_Settings->LoadBool(Plugin_EnableAudio);
}
}
void CGameSettings::SetSmmProtect(bool enhancementActive, bool value)
{
static bool s_EnhancementActive = false;
static bool s_EnhancementValue = false;
s_EnhancementActive = enhancementActive;
s_EnhancementValue = value;
if (s_EnhancementActive)
{
m_bSMM_StoreInstruc = s_EnhancementValue;
}
else
{
m_bSMM_StoreInstruc = g_Settings->LoadBool(Game_SMM_StoreInstruc);
}
}

View File

@ -134,6 +134,12 @@ public:
void RefreshSyncToAudio(void);
static void SetOverClockModifier(bool EnhancmentOverClock, uint32_t EnhancmentOverClockModifier);
static void SetCountPerOp(bool enhancementActive, uint32_t value);
static void SetViRefreshRate(bool enhancementActive, uint32_t value);
static void SetRdramSize(bool enhancementActive, uint32_t value);
static void SetFixedAudio(bool enhancementActive, bool value);
static void SetSyncAudio(bool enhancementActive, bool value);
static void SetSmmProtect(bool enhancementActive, bool value);
protected:
static void SpeedChanged(int32_t SpeedLimit);