Core: Create a setting for RDRAM Size that plugins can read

This commit is contained in:
zilmar 2023-09-28 07:29:11 +09:30
parent 99417fc5d9
commit bd1ec4ff0f
11 changed files with 44 additions and 11 deletions

View File

@ -70,6 +70,8 @@ CJniBridegSettings::CJniBridegSettings()
ADD_SETTING(Setting_SyncViaAudioEnabled);
ADD_SETTING(Setting_Enhancement);
ADD_SETTING(Setting_DiskSaveType);
ADD_SETTING(Setting_UpdateControllerOnRefresh);
ADD_SETTING(Setting_AllocatedRdramSize);
// Default settings
ADD_SETTING(Default_RDRamSizeUnknown);

View File

@ -172,6 +172,7 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem)
FreeMemory();
return false;
}
g_Settings->SaveDword(Setting_AllocatedRdramSize, m_AllocatedRdramSize);
m_MemoryReadMap = new size_t[0x100000];
if (m_MemoryReadMap == nullptr)

View File

@ -128,6 +128,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Setting_SyncViaAudioEnabled, new CSettingTypeTempBool(false, "SyncViaAudioEnabled"));
AddHandler(Setting_DiskSaveType, new CSettingTypeApplication("Settings", "Disk Save Type", (uint32_t)1));
AddHandler(Setting_UpdateControllerOnRefresh, new CSettingTypeTempBool(false));
AddHandler(Setting_AllocatedRdramSize, new CSettingTypeTempNumber(0, "AllocatedRdramSize"));
AddHandler(Default_RDRamSizeUnknown, new CSettingTypeApplication("Defaults", "Unknown RDRAM Size", 0x800000u));
AddHandler(Default_RDRamSizeKnown, new CSettingTypeApplication("Defaults", "Known RDRAM Size", 0x400000u));
@ -497,6 +498,19 @@ uint32_t CSettings::FindSetting(CSettings * _this, const char * Name)
}
setting_id = iter->first;
}
else if (Setting->GetSettingType() == SettingType_NumberVariable)
{
CSettingTypeTempNumber * NumberSetting = (CSettingTypeTempNumber *)Setting;
if (_stricmp(NumberSetting->GetName(), Name) != 0)
{
continue;
}
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
}
}
return setting_id;
}

View File

@ -2,9 +2,10 @@
#include "SettingsType-TempNumber.h"
CSettingTypeTempNumber::CSettingTypeTempNumber(uint32_t initialValue) :
m_value(initialValue),
m_initialValue(initialValue)
CSettingTypeTempNumber::CSettingTypeTempNumber(uint32_t initialValue, const char * Name) :
m_Value(initialValue),
m_InitialValue(initialValue),
m_Name(Name ? Name : "")
{
}
@ -20,7 +21,7 @@ bool CSettingTypeTempNumber::Load(uint32_t /*Index*/, bool & /*Value*/) const
bool CSettingTypeTempNumber::Load(uint32_t /*Index*/, uint32_t & Value) const
{
Value = m_value;
Value = m_Value;
return false;
}
@ -38,7 +39,7 @@ void CSettingTypeTempNumber::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) c
void CSettingTypeTempNumber::LoadDefault(uint32_t /*Index*/, uint32_t & Value) const
{
Value = m_initialValue;
Value = m_InitialValue;
}
void CSettingTypeTempNumber::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const
@ -53,7 +54,7 @@ void CSettingTypeTempNumber::Save(uint32_t /*Index*/, bool /*Value*/)
void CSettingTypeTempNumber::Save(uint32_t /*Index*/, uint32_t Value)
{
m_value = Value;
m_Value = Value;
}
void CSettingTypeTempNumber::Save(uint32_t /*Index*/, const std::string & /*Value*/)

View File

@ -6,7 +6,7 @@ class CSettingTypeTempNumber :
public CSettingType
{
public:
CSettingTypeTempNumber(uint32_t initialValue);
CSettingTypeTempNumber(uint32_t initialValue, const char * Name = nullptr);
~CSettingTypeTempNumber();
bool IndexBasedSetting(void) const
@ -21,6 +21,10 @@ public:
{
return false;
}
const char * GetName(void) const
{
return m_Name.c_str();
}
// Return the values
bool Load(uint32_t Index, bool & Value) const;
@ -46,6 +50,7 @@ private:
CSettingTypeTempNumber(const CSettingTypeTempNumber &);
CSettingTypeTempNumber & operator=(const CSettingTypeTempNumber &);
uint32_t m_value;
uint32_t m_initialValue;
uint32_t m_Value;
uint32_t m_InitialValue;
std::string m_Name;
};

View File

@ -62,6 +62,7 @@ enum SettingID
Setting_Enhancement,
Setting_DiskSaveType,
Setting_UpdateControllerOnRefresh,
Setting_AllocatedRdramSize,
// Default settings
Default_RDRamSizeUnknown,

View File

@ -7,6 +7,7 @@
#include <Settings/Settings.h>
RSP_INFO RSPInfo;
uint32_t RdramSize = 0;
void InitilizeRSP(RSP_INFO & Rsp_Info)
{

View File

@ -1,5 +1,6 @@
#include <Project64-plugin-spec/Rsp.h>
extern RSP_INFO RSPInfo;
extern uint32_t RdramSize;
void InitilizeRSP(RSP_INFO & Rsp_Info);

View File

@ -4,7 +4,7 @@
#include <Project64-rsp-core/cpu/RSPCpu.h>
#include <Settings/Settings.h>
uint16_t Set_AudioHle = 0, Set_GraphicsHle = 0;
uint16_t Set_AudioHle = 0, Set_GraphicsHle = 0, Set_AllocatedRdramSize = 0;
bool GraphicsHle = true, AudioHle, ConditionalMove;
bool DebuggingEnabled = false, Profiling, IndvidualBlock, ShowErrors, BreakOnStart = false, LogRDP = false, LogX86Code = false;
@ -13,6 +13,7 @@ void InitializeRspSetting(void)
SetModuleName("RSP");
Set_GraphicsHle = FindSystemSettingId("HLE GFX");
Set_AudioHle = FindSystemSettingId("HLE Audio");
Set_AllocatedRdramSize = FindSystemSettingId("AllocatedRdramSize");
RegisterSetting(Set_BreakOnStart, Data_DWORD_General, "Break on Start", NULL, BreakOnStart, NULL);
RegisterSetting(Set_CPUCore, Data_DWORD_General, "CPU Method", NULL, g_CPUCore, NULL);

View File

@ -3,6 +3,6 @@
void InitializeRspSetting(void);
extern uint16_t Set_AudioHle, Set_GraphicsHle;
extern uint16_t Set_AudioHle, Set_GraphicsHle, Set_AllocatedRdramSize;
extern bool GraphicsHle, AudioHle, ConditionalMove;
extern bool DebuggingEnabled, Profiling, IndvidualBlock, ShowErrors, BreakOnStart, LogRDP, LogX86Code;

View File

@ -485,6 +485,12 @@ EXPORT void RomOpen(void)
JumpTableSize = GetSetting(Set_JumpTableSize);
Mfc0Count = GetSetting(Set_Mfc0Count);
SemaphoreExit = GetSetting(Set_SemaphoreExit);
RdramSize = Set_AllocatedRdramSize != 0 ? GetSystemSetting(Set_AllocatedRdramSize) : 0;
if (RdramSize == 0)
{
RdramSize = 0x00400000;
}
}
/*