2023-08-10 04:46:57 +00:00
|
|
|
#include "RSPInfo.h"
|
2023-11-02 09:36:58 +00:00
|
|
|
#include <Project64-rsp-core/Recompiler/RspProfiling.h>
|
|
|
|
#include <Project64-rsp-core/Recompiler/RspRecompilerCPU.h>
|
2023-09-21 05:46:26 +00:00
|
|
|
#include <Project64-rsp-core/Settings/RspSettings.h>
|
|
|
|
#include <Project64-rsp-core/Settings/RspSettingsID.h>
|
|
|
|
#include <Project64-rsp-core/cpu/RSPCpu.h>
|
|
|
|
#include <Project64-rsp-core/cpu/RSPRegisters.h>
|
2023-11-02 09:36:58 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RspLog.h>
|
2023-09-21 05:46:26 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RspMemory.h>
|
2024-08-07 21:56:15 +00:00
|
|
|
#include <Project64-rsp-core/cpu/RspSystem.h>
|
2023-09-21 05:46:26 +00:00
|
|
|
#include <Settings/Settings.h>
|
2023-08-10 04:46:57 +00:00
|
|
|
|
2023-11-02 09:36:58 +00:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#include <Windows.h>
|
|
|
|
#endif
|
|
|
|
|
2023-08-10 04:46:57 +00:00
|
|
|
RSP_INFO RSPInfo;
|
2023-09-27 21:59:11 +00:00
|
|
|
uint32_t RdramSize = 0;
|
2023-11-02 09:36:58 +00:00
|
|
|
|
|
|
|
void ClearAllx86Code(void);
|
|
|
|
|
|
|
|
void DetectCpuSpecs(void)
|
|
|
|
{
|
|
|
|
uint32_t Intel_Features = 0;
|
|
|
|
uint32_t AMD_Features = 0;
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
__try
|
|
|
|
{
|
|
|
|
#ifdef _M_IX86
|
|
|
|
_asm {
|
|
|
|
// Intel features
|
|
|
|
mov eax, 1
|
|
|
|
cpuid
|
|
|
|
mov[Intel_Features], edx
|
|
|
|
|
|
|
|
// AMD features
|
|
|
|
mov eax, 80000001h
|
|
|
|
cpuid
|
|
|
|
or [AMD_Features], edx
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int cpuInfo[4];
|
|
|
|
__cpuid(cpuInfo, 1);
|
|
|
|
Intel_Features = cpuInfo[3];
|
|
|
|
__cpuid(cpuInfo, 0x80000001);
|
|
|
|
AMD_Features = cpuInfo[3];
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
AMD_Features = Intel_Features = 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
|
|
|
TODO: With GCC, there is <cpuid.h>, but __cpuid() there is a macro and
|
|
|
|
needs five arguments, not two. Also, GCC lacks SEH.
|
|
|
|
*/
|
|
|
|
|
|
|
|
AMD_Features = Intel_Features = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (Intel_Features & 0x02000000)
|
|
|
|
{
|
|
|
|
Compiler.mmx2 = true;
|
|
|
|
Compiler.sse = true;
|
|
|
|
}
|
|
|
|
if (Intel_Features & 0x00800000)
|
|
|
|
{
|
|
|
|
Compiler.mmx = true;
|
|
|
|
}
|
|
|
|
if (AMD_Features & 0x40000000)
|
|
|
|
{
|
|
|
|
Compiler.mmx2 = true;
|
|
|
|
}
|
|
|
|
if (Intel_Features & 0x00008000)
|
|
|
|
{
|
|
|
|
ConditionalMove = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ConditionalMove = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RspPluginLoaded(void)
|
|
|
|
{
|
|
|
|
BreakOnStart = false;
|
|
|
|
LogRDP = false;
|
|
|
|
LogX86Code = false;
|
|
|
|
Profiling = false;
|
|
|
|
IndvidualBlock = false;
|
|
|
|
ShowErrors = false;
|
|
|
|
|
|
|
|
memset(&Compiler, 0, sizeof(Compiler));
|
|
|
|
|
|
|
|
Compiler.bDest = true;
|
|
|
|
Compiler.bAlignVector = false;
|
|
|
|
Compiler.bFlags = true;
|
2024-07-20 07:38:20 +00:00
|
|
|
Compiler.bReOrdering = false;
|
|
|
|
Compiler.bSections = false;
|
2023-11-02 09:36:58 +00:00
|
|
|
Compiler.bAccum = true;
|
|
|
|
Compiler.bGPRConstants = true;
|
|
|
|
DetectCpuSpecs();
|
|
|
|
|
2024-08-29 01:56:53 +00:00
|
|
|
CRSPSettings::InitializeRspSetting();
|
2023-11-02 09:36:58 +00:00
|
|
|
}
|
2023-09-21 05:46:26 +00:00
|
|
|
|
|
|
|
void InitilizeRSP(RSP_INFO & Rsp_Info)
|
|
|
|
{
|
|
|
|
RSPInfo = Rsp_Info;
|
|
|
|
|
|
|
|
AudioHle = Set_AudioHle != 0 ? GetSystemSetting(Set_AudioHle) != 0 : false;
|
|
|
|
GraphicsHle = Set_GraphicsHle != 0 ? GetSystemSetting(Set_GraphicsHle) != 0 : true;
|
|
|
|
|
|
|
|
AllocateMemory();
|
2024-08-14 22:06:53 +00:00
|
|
|
RSPSystem.Reset(Rsp_Info);
|
2023-09-21 05:46:26 +00:00
|
|
|
Build_RSP();
|
|
|
|
#ifdef GenerateLog
|
|
|
|
Start_Log();
|
|
|
|
#endif
|
2023-11-02 09:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RspRomOpened(void)
|
|
|
|
{
|
2024-08-29 01:56:53 +00:00
|
|
|
CRSPSettings::SetRomOpen(true);
|
2023-11-02 09:36:58 +00:00
|
|
|
ClearAllx86Code();
|
2024-08-29 01:56:53 +00:00
|
|
|
|
2023-11-02 09:36:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RspRomClosed(void)
|
|
|
|
{
|
2024-08-29 01:56:53 +00:00
|
|
|
CRSPSettings::SetRomOpen(false);
|
2023-11-02 09:36:58 +00:00
|
|
|
if (Profiling)
|
|
|
|
{
|
|
|
|
StopTimer();
|
|
|
|
GenerateTimerResults();
|
|
|
|
}
|
2024-08-22 07:00:20 +00:00
|
|
|
RSPSystem.RomClosed();
|
2023-11-02 09:36:58 +00:00
|
|
|
ClearAllx86Code();
|
2024-08-15 04:13:56 +00:00
|
|
|
RDPLog.StopLog();
|
2023-11-02 09:36:58 +00:00
|
|
|
StopCPULog();
|
|
|
|
|
|
|
|
#ifdef GenerateLog
|
|
|
|
Stop_Log();
|
|
|
|
#endif
|
2023-09-21 05:46:26 +00:00
|
|
|
}
|
2023-11-02 09:36:58 +00:00
|
|
|
|
|
|
|
void FreeRSP(void)
|
|
|
|
{
|
|
|
|
FreeMemory();
|
|
|
|
}
|