RSP: Setup option to run in a thread

This commit is contained in:
zilmar 2023-09-21 14:25:07 +09:30
parent c4abebe201
commit 42a944c660
20 changed files with 356 additions and 231 deletions

View File

@ -74,6 +74,7 @@ CJniBridegSettings::CJniBridegSettings()
// Default settings
ADD_SETTING(Default_RDRamSizeUnknown);
ADD_SETTING(Default_RDRamSizeKnown);
ADD_SETTING(Default_RspMultiThreaded);
ADD_SETTING(Default_UseHleGfx);
ADD_SETTING(Default_ViRefreshRate);
ADD_SETTING(Default_AiCountPerBytes);
@ -100,6 +101,7 @@ CJniBridegSettings::CJniBridegSettings()
ADD_SETTING(Rdb_TLB_VAddrStart);
ADD_SETTING(Rdb_TLB_VAddrLen);
ADD_SETTING(Rdb_TLB_PAddrStart);
ADD_SETTING(Rdb_RspMultiThreaded);
ADD_SETTING(Rdb_UseHleGfx);
ADD_SETTING(Rdb_UseHleAudio);
ADD_SETTING(Rdb_ScreenHertz);
@ -162,6 +164,7 @@ CJniBridegSettings::CJniBridegSettings()
ADD_SETTING(Game_BlockLinking);
ADD_SETTING(Game_ScreenHertz);
ADD_SETTING(Game_RspAudioSignal);
ADD_SETTING(Game_RspMultiThreaded);
ADD_SETTING(Game_UseHleGfx);
ADD_SETTING(Game_UseHleAudio);
ADD_SETTING(Game_ViRefreshRate);
@ -304,6 +307,7 @@ CJniBridegSettings::CJniBridegSettings()
ADD_SETTING(Plugin_AUDIO_CurVer);
ADD_SETTING(Plugin_CONT_Current);
ADD_SETTING(Plugin_CONT_CurVer);
ADD_SETTING(Plugin_RspMultiThreaded);
ADD_SETTING(Plugin_UseHleGfx);
ADD_SETTING(Plugin_UseHleAudio);
ADD_SETTING(Plugin_EnableAudio);

View File

@ -127,14 +127,7 @@ bool DisplayControlRegHandler::Write32(uint32_t Address, uint32_t Value, uint32_
{
if ((SP_STATUS_REG & SP_STATUS_BROKE) == 0)
{
__except_try()
{
m_System.RunRSP();
}
__except_catch()
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
m_Plugins->RSP()->RunRSP();
}
}
}

View File

@ -255,7 +255,7 @@ bool SPRegistersHandler::Write32(uint32_t Address, uint32_t Value, uint32_t Mask
MI_INTR_REG |= MI_INTR_SP;
m_Reg.CheckInterrupts();
}
m_System.RunRSP();
m_System.GetPlugins()->RSP()->RunRSP();
break;
case 0x0404001C: SP_SEMAPHORE_REG = 0; break;
case 0x04080000: SP_PC_REG = MaskedValue & 0xFFC; break;

View File

@ -1187,21 +1187,7 @@ void CMipsMemoryVM::ChangeSpStatus()
g_Reg->MI_INTR_REG |= MI_INTR_SP;
g_Reg->CheckInterrupts();
}
//if (*( uint32_t *)(DMEM + 0xFC0) == 1)
//{
// ChangeTimer(RspTimer,0x40000);
//}
//else
//{
try
{
g_System->RunRSP();
}
catch (...)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
//}
g_Plugins->RSP()->RunRSP();
}
void CMipsMemoryVM::ChangeMiIntrMask()

View File

@ -246,14 +246,7 @@ void CSystemTimer::TimerDone()
break;
case CSystemTimer::RspTimer:
StopTimer(CSystemTimer::RspTimer);
try
{
m_System.RunRSP();
}
catch (...)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
m_System.GetPlugins()->RSP()->RunRSP();
break;
case CSystemTimer::RSPTimerDlist:
StopTimer(CSystemTimer::RSPTimerDlist);

View File

@ -39,7 +39,6 @@ CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesR
m_NextTimer(0),
m_SystemTimer(*this),
m_bCleanFrameBox(true),
m_RspBroke(true),
m_TestTimer(false),
m_PipelineStage(PIPELINE_STAGE_NORMAL),
m_JumpToLocation(0),
@ -912,10 +911,6 @@ void CN64System::Reset(bool bInitReg, bool ClearMenory)
m_MMU_VM.Reset(ClearMenory);
m_CyclesToSkip = 0;
m_AlistCount = 0;
m_DlistCount = 0;
m_UnknownCount = 0;
m_RspBroke = true;
m_SyncCount = 0;
for (int i = 0, n = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i < n; i++)
@ -2176,11 +2171,6 @@ uint32_t CN64System::GetButtons(int32_t Control) const
return m_Buttons[Control];
}
void CN64System::DisplayRSPListCount()
{
g_Notify->DisplayMessage(0, stdstr_f("Dlist: %d Alist: %d Unknown: %d", m_DlistCount, m_AlistCount, m_UnknownCount).c_str());
}
void CN64System::NotifyCallback(CN64SystemCB Type)
{
SETTING_CALLBACK::iterator Callback = m_Callback.find(Type);
@ -2234,103 +2224,6 @@ void CN64System::DelayedRelativeJump(uint32_t RelativeLocation)
}
}
void CN64System::RunRSP()
{
WriteTrace(TraceRSP, TraceDebug, "Start (SP Status %X)", m_Reg.SP_STATUS_REG);
PROFILE_TIMERS CPU_UsageAddr = m_CPU_Usage.StopTimer();
if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0)
{
HighResTimeStamp StartTime;
uint32_t Task = 0;
if (m_RspBroke)
{
g_MMU->MemoryValue32(0xA4000FC0, Task);
if (Task == 1 && UseHleGfx() && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0)
{
WriteTrace(TraceRSP, TraceDebug, "Dlist that is frozen");
return;
}
if (g_Debugger != NULL && HaveDebugger())
{
g_Debugger->RSPReceivedTask();
}
switch (Task)
{
case 1:
WriteTrace(TraceRSP, TraceDebug, "*** Display list ***");
m_DlistCount += 1;
m_FPS.UpdateDlCounter();
break;
case 2:
WriteTrace(TraceRSP, TraceDebug, "*** Audio list ***");
m_AlistCount += 1;
break;
default:
WriteTrace(TraceRSP, TraceDebug, "*** Unknown list ***");
m_UnknownCount += 1;
break;
}
if (bShowDListAListCount())
{
DisplayRSPListCount();
}
if (bRecordExecutionTimes() || bShowCPUPer())
{
StartTime.SetToNow();
}
}
WriteTrace(TraceRSP, TraceDebug, "Do cycles - starting");
m_Plugins->RSP()->DoRspCycles(100);
WriteTrace(TraceRSP, TraceDebug, "Do cycles - done");
if (Task == 1 && bDelayDP() && ((m_Reg.m_GfxIntrReg & MI_INTR_DP) != 0))
{
g_SystemTimer->SetTimer(CSystemTimer::RSPTimerDlist, 0x1000, false);
m_Reg.m_GfxIntrReg &= ~MI_INTR_DP;
}
if (bRecordExecutionTimes() || bShowCPUPer())
{
HighResTimeStamp EndTime;
EndTime.SetToNow();
uint32_t TimeTaken = (uint32_t)(EndTime.GetMicroSeconds() - StartTime.GetMicroSeconds());
switch (Task)
{
case 1: m_CPU_Usage.RecordTime(Timer_RSP_Dlist, TimeTaken); break;
case 2: m_CPU_Usage.RecordTime(Timer_RSP_Alist, TimeTaken); break;
default: m_CPU_Usage.RecordTime(Timer_RSP_Unknown, TimeTaken); break;
}
}
if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0 &&
(m_Reg.SP_STATUS_REG & SP_STATUS_BROKE) == 0 &&
m_Reg.m_RspIntrReg == 0)
{
g_SystemTimer->SetTimer(CSystemTimer::RspTimer, 0x200, false);
m_RspBroke = false;
}
else
{
m_RspBroke = true;
}
WriteTrace(TraceRSP, TraceDebug, "Check interrupts");
g_Reg->CheckInterrupts();
}
if (bShowCPUPer())
{
m_CPU_Usage.StartTimer(CPU_UsageAddr);
}
WriteTrace(TraceRSP, TraceDebug, "Done (SP Status %X)", m_Reg.SP_STATUS_REG);
}
void CN64System::RefreshScreen()
{
PROFILE_TIMERS CPU_UsageAddr = Timer_None /*, ProfilingAddr = Timer_None*/;

View File

@ -92,7 +92,6 @@ public:
void ApplyGSButton(void);
void Pause();
void RunRSP();
bool SaveState();
bool LoadState(const char * FileName);
bool LoadState();
@ -162,7 +161,6 @@ private:
void DumpSyncErrors(CN64System * SecondCPU);
void StartEmulation2(bool NewThread);
bool SetActiveSystem(bool bActive = true);
void DisplayRSPListCount();
void NotifyCallback(CN64SystemCB Type);
void DelayedJump(uint32_t JumpLocation);
void DelayedRelativeJump(uint32_t RelativeLocation);
@ -196,7 +194,6 @@ private:
int32_t m_NextTimer;
CSystemTimer m_SystemTimer;
bool m_bCleanFrameBox;
bool m_RspBroke;
uint32_t m_Buttons[4];
bool m_TestTimer;
PIPELINE_STAGE m_PipelineStage;
@ -218,9 +215,6 @@ private:
// Handle to pause mutex
SyncEvent m_hPauseEvent;
// Number of Alist and Dlist sent to the RSP
uint32_t m_AlistCount, m_DlistCount, m_UnknownCount;
// List of function that have been called (used in profiling)
FUNC_CALLS m_FunctionCalls;

View File

@ -22,6 +22,7 @@ CPlugins::CPlugins(SettingID PluginDirSetting, bool SyncPlugins) :
g_Settings->RegisterChangeCB(Plugin_GFX_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Plugin_AUDIO_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Plugin_CONT_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Plugin_RspMultiThreaded, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Plugin_UseHleAudio, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Game_EditPlugin_Gfx, this, (CSettings::SettingChangedFunc)PluginChanged);
@ -37,6 +38,7 @@ CPlugins::~CPlugins(void)
g_Settings->UnregisterChangeCB(Plugin_GFX_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Plugin_AUDIO_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Plugin_CONT_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Plugin_RspMultiThreaded, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Plugin_UseHleAudio, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Game_EditPlugin_Gfx, this, (CSettings::SettingChangedFunc)PluginChanged);
@ -159,12 +161,9 @@ void CPlugins::CreatePlugins(void)
LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir.c_str(), m_RSPFile, TraceRSPPlugin, "RSP", m_SyncPlugins);
LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir.c_str(), m_ControlFile, TraceControllerPlugin, "Control", m_SyncPlugins);
// Enable debugger
if (m_RSP != nullptr && m_RSP->EnableDebugging)
if (m_RSP != nullptr)
{
WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging starting");
m_RSP->EnableDebugging(HaveDebugger());
WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging done");
}
WriteTrace(TracePlugins, TraceInfo, "Done");
}

View File

@ -4,10 +4,10 @@
#include <Project64-core/Plugins/Plugin.h>
#include <Project64-core/Settings/DebugSettings.h>
#include <Project64-core/TraceModulesProject64.h>
#include <Project64-plugin-spec\Base.h>
#include <Project64-plugin-spec/Base.h>
class CPlugin :
private CDebugSettings
protected CDebugSettings
{
public:
CPlugin();

View File

@ -2,6 +2,8 @@
#include "GFXPlugin.h"
#include "RSPPlugin.h"
#include <Common/Util.h>
#include <Project64-core/Debugger.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/Mips/Register.h>
#include <Project64-core/N64System/N64Disk.h>
@ -10,17 +12,19 @@
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/Plugins/AudioPlugin.h>
void DummyFunc1(int a)
{
a += 1;
}
CRSP_Plugin::CRSP_Plugin(void) :
DoRspCycles(nullptr),
EnableDebugging(nullptr),
m_DoRspCycles(nullptr),
m_EnableDebugging(nullptr),
m_GetDebugInfo(nullptr),
m_InitiateDebugger(nullptr),
m_Thread(stRspThread),
m_CycleCount(0),
GetDebugInfo(nullptr),
InitiateDebugger(nullptr)
m_Plugins(nullptr),
m_System(nullptr),
m_AlistCount(0),
m_DlistCount(0),
m_UnknownCount(0),
m_RomOpened(false)
{
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
}
@ -33,20 +37,13 @@ CRSP_Plugin::~CRSP_Plugin()
bool CRSP_Plugin::LoadFunctions(void)
{
// Find entries for functions in DLL
void(CALL * InitiateRSP)(void);
LoadFunction(InitiateRSP);
LoadFunction(DoRspCycles);
_LoadFunction("GetRspDebugInfo", GetDebugInfo);
_LoadFunction("InitiateRSPDebugger", InitiateDebugger);
LoadFunction(EnableDebugging);
if (EnableDebugging == nullptr)
{
EnableDebugging = DummyFunc1;
}
void(CALL * InitiateRSP)(void) = (void(CALL *)(void))DynamicLibraryGetProc(m_LibHandle, "InitiateRSP");
m_DoRspCycles = (uint32_t(CALL *)(uint32_t))DynamicLibraryGetProc(m_LibHandle, "DoRspCycles");
m_GetDebugInfo = (void(CALL *)(RSPDEBUG_INFO * GFXDebugInfo)) DynamicLibraryGetProc(m_LibHandle, "GetRspDebugInfo");
m_InitiateDebugger = (void(CALL *)(DEBUG_INFO DebugInfo))DynamicLibraryGetProc(m_LibHandle, "InitiateRSPDebugger");
m_EnableDebugging = (void(CALL *)(int32_t Enable))DynamicLibraryGetProc(m_LibHandle, "EnableDebugging");
// Make sure DLL had all needed functions
if (DoRspCycles == nullptr)
if (m_DoRspCycles == nullptr)
{
UnloadPlugin();
return false;
@ -76,17 +73,49 @@ bool CRSP_Plugin::LoadFunctions(void)
}
}
// Get debug info if possible
if (GetDebugInfo != nullptr)
if (m_GetDebugInfo != nullptr)
{
GetDebugInfo(&m_RSPDebug);
m_GetDebugInfo(&m_RSPDebug);
}
return true;
}
void CRSP_Plugin::RomOpened(RenderWindow * Render)
{
CPlugin::RomOpened(Render);
m_AlistCount = 0;
m_DlistCount = 0;
m_UnknownCount = 0;
m_RomOpened = true;
m_Thread.Start(this);
}
void CRSP_Plugin::RomClose(RenderWindow * Render)
{
m_RomOpened = false;
m_RunEvent.Trigger();
for (uint32_t i = 0; i < 300; i++)
{
if (!m_Thread.isRunning())
{
break;
}
pjutil::Sleep(10);
}
if (m_Thread.isRunning())
{
m_Thread.Terminate();
}
CPlugin::RomClose(Render);
m_Plugins = nullptr;
m_System = nullptr;
}
bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
{
WriteTrace(TraceRSPPlugin, TraceDebug, "Starting");
m_Plugins = Plugins;
m_System = System;
if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100)
{
WriteTrace(TraceRSPPlugin, TraceDebug, "Invalid version: %X", m_PluginInfo.Version);
@ -192,21 +221,17 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
Info.DPC__PIPEBUSY_REG = &Value;
Info.DPC__TMEM_REG = &Value;
}
// Send initialization information to the DLL
else
{
CMipsMemoryVM & MMU = System->m_MMU_VM;
CRegisters & Reg = System->m_Reg;
Info.ProcessDlist = Plugins->Gfx()->ProcessDList;
Info.ProcessRdpList = Plugins->Gfx()->ProcessRDPList;
Info.ShowCFB = Plugins->Gfx()->ShowCFB;
Info.ProcessAlist = Plugins->Audio()->ProcessAList;
CMipsMemoryVM & MMU = System->m_MMU_VM;
CRegisters & Reg = System->m_Reg;
if (g_Rom->IsLoadedRomDDIPL() && g_Disk != nullptr)
Info.HEADER = g_Disk->GetDiskHeader();
else
Info.HEADER = g_Rom->GetRomAddress();
Info.HEADER = g_Rom->IsLoadedRomDDIPL() && g_Disk != nullptr ? g_Disk->GetDiskHeader() : g_Rom->GetRomAddress();
Info.RDRAM = MMU.Rdram();
Info.DMEM = MMU.Dmem();
Info.IMEM = MMU.Imem();
@ -376,19 +401,209 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
return m_Initialized;
}
void CRSP_Plugin::EnableDebugging(int32_t Enable)
{
if (m_EnableDebugging != nullptr)
{
WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging starting");
m_EnableDebugging(Enable);
WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging done");
}
}
void CRSP_Plugin::RunRSP()
{
CRegisters & Reg = m_System->m_Reg;
WriteTrace(TraceRSP, TraceDebug, "Start (SP Status %X)", Reg.SP_STATUS_REG);
if ((Reg.SP_STATUS_REG & SP_STATUS_HALT) != 0)
{
WriteTrace(TraceRSP, TraceDebug, "Done (SP Status %X)", Reg.SP_STATUS_REG);
return;
}
CProfiling & CPU_Usage = m_System->m_CPU_Usage;
PROFILE_TIMERS CPU_UsageAddr = CPU_Usage.StopTimer();
CMipsMemoryVM & Memory = m_System->m_MMU_VM;
HighResTimeStamp StartTime;
uint32_t TaskType = 0;
Memory.MemoryValue32(0xA4000FC0, TaskType);
if (TaskType == 1 && UseHleGfx() && (Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0)
{
WriteTrace(TraceRSP, TraceDebug, "Dlist that is frozen");
WriteTrace(TraceRSP, TraceDebug, "Done (SP Status %X)", Reg.SP_STATUS_REG);
return;
}
if (g_Debugger != NULL && HaveDebugger())
{
g_Debugger->RSPReceivedTask();
}
switch (TaskType)
{
case 1:
WriteTrace(TraceRSP, TraceDebug, "*** Display list ***");
m_DlistCount += 1;
m_System->m_FPS.UpdateDlCounter();
break;
case 2:
WriteTrace(TraceRSP, TraceDebug, "*** Audio list ***");
m_AlistCount += 1;
break;
default:
WriteTrace(TraceRSP, TraceDebug, "*** Unknown list ***");
m_UnknownCount += 1;
break;
}
if (bShowDListAListCount())
{
g_Notify->DisplayMessage(0, stdstr_f("Dlist: %d Alist: %d Unknown: %d", m_DlistCount, m_AlistCount, m_UnknownCount).c_str());
}
if (bRecordExecutionTimes() || bShowCPUPer())
{
StartTime.SetToNow();
}
uint32_t DataPtr = 0;
Memory.MemoryValue32(0xA4000FC0, DataPtr);
bool ExecuteCycles = true;
if (TaskType == 1 && UseHleGfx() && DataPtr != 0)
{
Memory.MemoryValue32(0xA4000FF0, TaskType);
if (m_Plugins->Gfx()->ProcessDList != nullptr)
{
m_Plugins->Gfx()->ProcessDList();
}
Reg.SP_STATUS_REG |= (0x0203);
if ((Reg.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0)
{
Reg.MI_INTR_REG |= MI_INTR_SP;
}
Reg.DPC_STATUS_REG &= ~0x0002;
if (bDelayDP() && ((Reg.m_GfxIntrReg & MI_INTR_DP) != 0))
{
g_SystemTimer->SetTimer(CSystemTimer::RSPTimerDlist, 0x1000, false);
Reg.m_GfxIntrReg &= ~MI_INTR_DP;
}
ExecuteCycles = false;
}
else if (TaskType == 2 && UseHleAudio())
{
if (m_Plugins->Audio()->ProcessAList != nullptr)
{
m_Plugins->Audio()->ProcessAList();
}
Reg.SP_STATUS_REG |= (0x0203);
if ((Reg.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0)
{
Reg.MI_INTR_REG |= MI_INTR_SP;
}
ExecuteCycles = false;
}
else if (TaskType == 7 && UseHleGfx() && m_Plugins->Gfx()->ShowCFB != nullptr)
{
m_Plugins->Gfx()->ShowCFB();
}
if (ExecuteCycles)
{
if (RspMultiThreaded())
{
m_RunEvent.Trigger();
}
else
{
WriteTrace(TraceRSP, TraceDebug, "Do cycles - starting");
m_DoRspCycles(100);
WriteTrace(TraceRSP, TraceDebug, "Do cycles - done");
}
}
if (bRecordExecutionTimes() || bShowCPUPer())
{
HighResTimeStamp EndTime;
EndTime.SetToNow();
uint32_t TimeTaken = (uint32_t)(EndTime.GetMicroSeconds() - StartTime.GetMicroSeconds());
switch (TaskType)
{
case 1: CPU_Usage.RecordTime(Timer_RSP_Dlist, TimeTaken); break;
case 2: CPU_Usage.RecordTime(Timer_RSP_Alist, TimeTaken); break;
default: CPU_Usage.RecordTime(Timer_RSP_Unknown, TimeTaken); break;
}
}
if (ExecuteCycles && (Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0 && Reg.m_RspIntrReg == 0)
{
g_SystemTimer->SetTimer(CSystemTimer::RspTimer, 0x200, false);
}
WriteTrace(TraceRSP, TraceDebug, "Check interrupts");
g_Reg->CheckInterrupts();
if (bShowCPUPer())
{
CPU_Usage.StartTimer(CPU_UsageAddr);
}
WriteTrace(TraceRSP, TraceDebug, "Done (SP Status %X)", Reg.SP_STATUS_REG);
}
void CRSP_Plugin::UnloadPluginDetails(void)
{
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
DoRspCycles = nullptr;
EnableDebugging = nullptr;
GetDebugInfo = nullptr;
InitiateDebugger = nullptr;
m_DoRspCycles = nullptr;
m_EnableDebugging = nullptr;
m_GetDebugInfo = nullptr;
m_InitiateDebugger = nullptr;
}
void CRSP_Plugin::ProcessMenuItem(int id)
uint32_t CRSP_Plugin::RspThread(void)
{
CRegisters & Reg = m_System->m_Reg;
for (;;)
{
m_RunEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT);
if (!m_RomOpened)
{
break;
}
m_DoRspCycles(100);
if ((Reg.SP_STATUS_REG & SP_STATUS_HALT) != 0)
{
m_RunEvent.Reset();
}
}
return 0;
}
uint32_t CRSP_Plugin::stRspThread(void * lpThreadParameter)
{
return ((CRSP_Plugin *)lpThreadParameter)->RspThread();
}
void * CRSP_Plugin::GetDebugMenu(void)
{
return m_RSPDebug.hRSPMenu;
}
void CRSP_Plugin::ProcessMenuItem(int32_t id)
{
if (m_RSPDebug.ProcessMenuItem)
{
m_RSPDebug.ProcessMenuItem(id);
}
}
PLUGIN_TYPE CRSP_Plugin::type()
{
return PLUGIN_TYPE_RSP;
}
int32_t CRSP_Plugin::GetDefaultSettingStartRange() const
{
return FirstRSPDefaultSet;
}
int32_t CRSP_Plugin::GetSettingStartRange() const
{
return FirstRSPSettings;
}

View File

@ -1,7 +1,15 @@
#pragma once
#include <Common/SyncEvent.h>
#include <Common/Thread.h>
#include <Project64-core/Plugins/PluginBase.h>
#include <Project64-core/Settings/DebugSettings.h>
#include <Project64-core/Settings/GameSettings.h>
#include <Project64-core/Settings/N64SystemSettings.h>
class CRSP_Plugin : public CPlugin
class CRSP_Plugin :
public CPlugin,
protected CN64SystemSettings,
protected CGameSettings
{
typedef struct
{
@ -42,40 +50,40 @@ public:
CRSP_Plugin(void);
~CRSP_Plugin();
void RomOpened(RenderWindow * Render);
void RomClose(RenderWindow * Render);
bool Initiate(CPlugins * Plugins, CN64System * System);
void EnableDebugging(int32_t Enable);
void RunRSP(void);
uint32_t(CALL * DoRspCycles)(uint32_t);
void(CALL * EnableDebugging)(int32_t Enable);
void * GetDebugMenu(void)
{
return m_RSPDebug.hRSPMenu;
}
void * GetDebugMenu(void);
void ProcessMenuItem(int32_t id);
private:
CRSP_Plugin(const CRSP_Plugin &);
CRSP_Plugin & operator=(const CRSP_Plugin &);
PLUGIN_TYPE type()
{
return PLUGIN_TYPE_RSP;
}
virtual int32_t GetDefaultSettingStartRange() const
{
return FirstRSPDefaultSet;
}
virtual int32_t GetSettingStartRange() const
{
return FirstRSPSettings;
}
PLUGIN_TYPE type();
int32_t GetDefaultSettingStartRange() const;
int32_t GetSettingStartRange() const;
uint32_t RspThread(void);
static uint32_t stRspThread(void * lpThreadParameter);
bool LoadFunctions(void);
void UnloadPluginDetails(void);
void(CALL * m_EnableDebugging)(int32_t Enable);
void(CALL * m_GetDebugInfo)(RSPDEBUG_INFO * GFXDebugInfo);
void(CALL * m_InitiateDebugger)(DEBUG_INFO DebugInfo);
uint32_t(CALL * m_DoRspCycles)(uint32_t);
CPlugins * m_Plugins;
CN64System * m_System;
uint32_t m_AlistCount, m_DlistCount, m_UnknownCount;
SyncEvent m_RunEvent;
CThread m_Thread;
RSPDEBUG_INFO m_RSPDebug;
uint32_t m_CycleCount;
void(CALL * GetDebugInfo)(RSPDEBUG_INFO * GFXDebugInfo);
void(CALL * InitiateDebugger)(DEBUG_INFO DebugInfo);
bool m_RomOpened;
};

View File

@ -131,6 +131,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Default_RDRamSizeUnknown, new CSettingTypeApplication("Defaults", "Unknown RDRAM Size", 0x800000u));
AddHandler(Default_RDRamSizeKnown, new CSettingTypeApplication("Defaults", "Known RDRAM Size", 0x400000u));
AddHandler(Default_RspMultiThreaded, new CSettingTypeApplication("Defaults", "Rsp Multi Threaded Default", false));
AddHandler(Default_UseHleGfx, new CSettingTypeApplication("Defaults", "HLE GFX Default", true));
AddHandler(Default_ViRefreshRate, new CSettingTypeApplication("Defaults", "ViRefresh", 1500u));
AddHandler(Default_AiCountPerBytes, new CSettingTypeApplication("Defaults", "AiCountPerBytes", 0u));
@ -157,6 +158,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Rdb_TLB_VAddrStart, new CSettingTypeRomDatabase("TLB: Vaddr Start", (uint32_t)0));
AddHandler(Rdb_TLB_VAddrLen, new CSettingTypeRomDatabase("TLB: Vaddr Len", (uint32_t)0));
AddHandler(Rdb_TLB_PAddrStart, new CSettingTypeRomDatabase("TLB: PAddr Start", (uint32_t)0));
AddHandler(Rdb_RspMultiThreaded, new CSettingTypeRomDatabase("Rsp Multi Threaded", Plugin_RspMultiThreaded));
AddHandler(Rdb_UseHleGfx, new CSettingTypeRomDatabase("HLE GFX RDB", Plugin_UseHleGfx));
AddHandler(Rdb_UseHleAudio, new CSettingTypeRomDatabase("HLE Audio RDB", Plugin_UseHleAudio));
AddHandler(Rdb_ScreenHertz, new CSettingTypeRomDatabase("ScreenHertz", (uint32_t)0));
@ -217,6 +219,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
#endif
AddHandler(Game_LastSaveTime, new CSettingTypeTempNumber(0));
AddHandler(Game_SyncViaAudio, new CSettingTypeGame("Sync Audio", Rdb_SyncViaAudio));
AddHandler(Game_RspMultiThreaded, new CSettingTypeGame("Rsp Multi Threaded", Rdb_RspMultiThreaded));
AddHandler(Game_UseHleGfx, new CSettingTypeGame("HLE GFX", Rdb_UseHleGfx));
AddHandler(Game_UseHleAudio, new CSettingTypeGame("HLE Audio", Rdb_UseHleAudio));
AddHandler(Game_ScreenHertz, new CSettingTypeGame("ScreenHertz", Rdb_ScreenHertz));
@ -401,6 +404,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Plugin_AUDIO_CurVer, new CSettingTypeApplication("Plugin", "Audio Dll Ver", ""));
AddHandler(Plugin_CONT_CurVer, new CSettingTypeApplication("Plugin", "Controller Dll Ver", ""));
AddHandler(Plugin_RspMultiThreaded, new CSettingTypeApplication("RSP", "Rsp Multi Threaded Plugin", Default_RspMultiThreaded));
AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX Plugin", Default_UseHleGfx));
AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio Plugin", false));
AddHandler(Plugin_EnableAudio, new CSettingTypeApplication("Audio", "Enable Audio", true));

View File

@ -4,7 +4,9 @@
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/Settings/GameSettings.h>
bool CGameSettings::m_RspMultiThreaded = false;
bool CGameSettings::m_UseHleGfx = true;
bool CGameSettings::m_UseHleAudio = false;
bool CGameSettings::m_bSMM_StoreInstruc;
bool CGameSettings::m_bSMM_Protect;
bool CGameSettings::m_bSMM_ValidFunc;
@ -60,7 +62,9 @@ CGameSettings::~CGameSettings()
void CGameSettings::RefreshGameSettings()
{
WriteTrace(TraceN64System, TraceDebug, "start");
m_RspMultiThreaded = g_Settings->LoadBool(Game_RspMultiThreaded);
m_UseHleGfx = g_Settings->LoadBool(Game_UseHleGfx);
m_UseHleAudio = g_Settings->LoadBool(Game_UseHleAudio);
m_bSMM_StoreInstruc = g_Settings->LoadBool(Game_SMM_StoreInstruc);
m_bSMM_Protect = g_Settings->LoadBool(Game_SMM_Protect);
m_bSMM_ValidFunc = g_Settings->LoadBool(Game_SMM_ValidFunc);

View File

@ -11,10 +11,18 @@ public:
void RefreshGameSettings(void);
inline static bool RspMultiThreaded(void)
{
return m_RspMultiThreaded;
}
inline static bool UseHleGfx(void)
{
return m_UseHleGfx;
}
inline static bool UseHleAudio(void)
{
return m_UseHleAudio;
}
inline static bool bFPURegCaching(void)
{
return m_FPURegCaching;
@ -141,8 +149,9 @@ private:
static void EnableDiskChanged(void *);
// Settings that can be changed on the fly
static bool m_RspMultiThreaded;
static bool m_UseHleGfx;
static bool m_UseHleAudio;
static bool m_RegCaching;
static bool m_FPURegCaching;
static bool m_bLinkBlocks;

View File

@ -66,6 +66,7 @@ enum SettingID
// Default settings
Default_RDRamSizeUnknown,
Default_RDRamSizeKnown,
Default_RspMultiThreaded,
Default_UseHleGfx,
Default_ViRefreshRate,
Default_AiCountPerBytes,
@ -92,6 +93,7 @@ enum SettingID
Rdb_TLB_VAddrStart,
Rdb_TLB_VAddrLen,
Rdb_TLB_PAddrStart,
Rdb_RspMultiThreaded,
Rdb_UseHleGfx,
Rdb_UseHleAudio,
Rdb_ScreenHertz,
@ -157,6 +159,7 @@ enum SettingID
Game_BlockLinking,
Game_ScreenHertz,
Game_RspAudioSignal,
Game_RspMultiThreaded,
Game_UseHleGfx,
Game_UseHleAudio,
Game_ViRefreshRate,
@ -302,6 +305,7 @@ enum SettingID
Plugin_AUDIO_CurVer,
Plugin_CONT_Current,
Plugin_CONT_CurVer,
Plugin_RspMultiThreaded,
Plugin_UseHleGfx,
Plugin_UseHleAudio,
Plugin_EnableAudio,

View File

@ -53,7 +53,8 @@ typedef struct {
long left, top, right, bottom;
} rectangle; // <windows.h> equivalent: RECT
typedef struct {
typedef struct
{
void * hdc;
int32_t fErase;
rectangle rcPaint;
@ -62,11 +63,12 @@ typedef struct {
uint8_t rgbReserved[32];
} window_paint; // <windows.h> equivalent: PAINTSTRUCT
typedef struct {
typedef struct
{
// Menu
// Items should have an ID between 5001 and 5100
void * hRSPMenu;
void(*ProcessMenuItem) (int ID);
void(*ProcessMenuItem) (int32_t ID);
// Breakpoints
int UseBPoints;

View File

@ -33,7 +33,7 @@
#include <Project64-rsp-core/cpu/RspTypes.h>
void ClearAllx86Code(void);
void ProcessMenuItem(int ID);
void ProcessMenuItem(int32_t ID);
#ifdef _WIN32
BOOL CALLBACK CompilerDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
HMENU hRSPMenu = NULL;
@ -159,6 +159,9 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/
void FixMenuState(void)
{
short Set_MultiThreadedDefault = FindSystemSettingId("Rsp Multi Threaded Default");
bool MultiThreadedDefault = Set_MultiThreadedDefault != 0 ? GetSystemSetting(Set_MultiThreadedDefault) != 0 : false;
EnableMenuItem(hRSPMenu, ID_RSPCOMMANDS, MF_BYCOMMAND | (DebuggingEnabled ? MF_ENABLED : (MF_GRAYED | MF_DISABLED)));
EnableMenuItem(hRSPMenu, ID_RSPREGISTERS, MF_BYCOMMAND | (DebuggingEnabled ? MF_ENABLED : (MF_GRAYED | MF_DISABLED)));
EnableMenuItem(hRSPMenu, ID_PROFILING_RESETSTATS, MF_BYCOMMAND | (DebuggingEnabled ? MF_ENABLED : (MF_GRAYED | MF_DISABLED)));
@ -171,6 +174,7 @@ void FixMenuState(void)
CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | (BreakOnStart ? MFS_CHECKED : MF_UNCHECKED));
CheckMenuItem(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND | (LogRDP ? MFS_CHECKED : MF_UNCHECKED));
CheckMenuItem(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND | (LogX86Code ? MFS_CHECKED : MF_UNCHECKED));
CheckMenuItem(hRSPMenu, ID_SETTINGS_MULTITHREADED, MF_BYCOMMAND | (MultiThreadedDefault ? MFS_CHECKED : MF_UNCHECKED));
CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | (Profiling ? MFS_CHECKED : MF_UNCHECKED));
CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | (Profiling ? MFS_UNCHECKED : MF_CHECKED));
CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | (IndvidualBlock ? MFS_CHECKED : MF_UNCHECKED));
@ -348,7 +352,7 @@ EXPORT void InitiateRSPDebugger(DEBUG_INFO Debug_Info)
}
#ifdef _WIN32
void ProcessMenuItem(int ID)
void ProcessMenuItem(int32_t ID)
{
switch (ID)
{
@ -446,6 +450,17 @@ void ProcessMenuItem(int ID)
}
break;
}
case ID_SETTINGS_MULTITHREADED:
{
bool Checked = (GetMenuState(hRSPMenu, ID_SETTINGS_MULTITHREADED, MF_BYCOMMAND) & MFS_CHECKED) != 0;
CheckMenuItem(hRSPMenu, ID_SETTINGS_MULTITHREADED, MF_BYCOMMAND | (Checked ? MFS_UNCHECKED : MFS_CHECKED));
short Set_MultiThreadedDefault = FindSystemSettingId("Rsp Multi Threaded Default");
if (Set_MultiThreadedDefault != 0)
{
SetSystemSetting(Set_MultiThreadedDefault, !Checked);
}
break;
}
case ID_CPUMETHOD_RECOMPILER:
SetSetting(Set_CPUCore, RecompilerCPU);
g_CPUCore = RecompilerCPU;

View File

@ -194,6 +194,7 @@ BEGIN
MENUITEM "Break on start of task", ID_BREAKONSTARTOFTASK
MENUITEM "Log RDP Commands", ID_LOGRDPCOMMANDS
MENUITEM "Log X86 code", ID_SETTINGS_LOGX86CODE
MENUITEM "Multithreaded", ID_SETTINGS_MULTITHREADED
END
END

View File

@ -40,11 +40,6 @@
<Filter>Header Files\Debugger</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Project64-rsp.rc">
<Filter>Source Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="breakpoint.cpp">
<Filter>Source Files</Filter>
@ -62,4 +57,9 @@
<Filter>Source Files\Debugger</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Project64-rsp.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -37,13 +37,14 @@
#define ID_CPUMETHOD_RECOMPILER 5016
#define ID_CPUMETHOD_INTERPT 5017
#define ID_SETTINGS_LOGX86CODE 5019
#define ID_SETTINGS_MULTITHREADED 5020
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 5020
#define _APS_NEXT_COMMAND_VALUE 5021
#define _APS_NEXT_CONTROL_VALUE 1032
#define _APS_NEXT_SYMED_VALUE 101
#endif