RSP: Add clamp16
This commit is contained in:
parent
af1c0c2b55
commit
0cadbe0f70
|
@ -40,6 +40,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="cpu\RspClamp.cpp" />
|
||||||
<ClCompile Include="cpu\RSPCpu.cpp" />
|
<ClCompile Include="cpu\RSPCpu.cpp" />
|
||||||
<ClCompile Include="cpu\RspDma.cpp" />
|
<ClCompile Include="cpu\RspDma.cpp" />
|
||||||
<ClCompile Include="cpu\RSPiInstruction.cpp" />
|
<ClCompile Include="cpu\RSPiInstruction.cpp" />
|
||||||
|
@ -62,6 +63,7 @@
|
||||||
<ClCompile Include="Settings\RspSettings.cpp" />
|
<ClCompile Include="Settings\RspSettings.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="cpu\RspClamp.h" />
|
||||||
<ClInclude Include="cpu\RSPCpu.h" />
|
<ClInclude Include="cpu\RSPCpu.h" />
|
||||||
<ClInclude Include="cpu\RspDma.h" />
|
<ClInclude Include="cpu\RspDma.h" />
|
||||||
<ClInclude Include="cpu\RSPInstruction.h" />
|
<ClInclude Include="cpu\RSPInstruction.h" />
|
||||||
|
|
|
@ -93,6 +93,9 @@
|
||||||
<ClCompile Include="cpu\RspDma.cpp">
|
<ClCompile Include="cpu\RspDma.cpp">
|
||||||
<Filter>Source Files\cpu</Filter>
|
<Filter>Source Files\cpu</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="cpu\RspClamp.cpp">
|
||||||
|
<Filter>Source Files\cpu</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="cpu\RSPInstruction.h">
|
<ClInclude Include="cpu\RSPInstruction.h">
|
||||||
|
@ -149,5 +152,8 @@
|
||||||
<ClInclude Include="cpu\RspDma.h">
|
<ClInclude Include="cpu\RspDma.h">
|
||||||
<Filter>Header Files\cpu</Filter>
|
<Filter>Header Files\cpu</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="cpu\RspClamp.h">
|
||||||
|
<Filter>Header Files\cpu</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -6,6 +6,7 @@
|
||||||
#include <Project64-rsp-core/RSPDebugger.h>
|
#include <Project64-rsp-core/RSPDebugger.h>
|
||||||
#include <Project64-rsp-core/RSPInfo.h>
|
#include <Project64-rsp-core/RSPInfo.h>
|
||||||
#include <Project64-rsp-core/Settings/RspSettings.h>
|
#include <Project64-rsp-core/Settings/RspSettings.h>
|
||||||
|
#include <Project64-rsp-core/cpu/RspClamp.h>
|
||||||
#include <Project64-rsp-core/cpu/RspDma.h>
|
#include <Project64-rsp-core/cpu/RspDma.h>
|
||||||
#include <Settings/Settings.h>
|
#include <Settings/Settings.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "RspClamp.h"
|
||||||
|
|
||||||
|
uint16_t clamp16(int32_t Value)
|
||||||
|
{
|
||||||
|
if (Value > 0x7FFF)
|
||||||
|
{
|
||||||
|
return 0x7FFF;
|
||||||
|
}
|
||||||
|
if (Value < (int32_t)0xffff8000)
|
||||||
|
{
|
||||||
|
return 0x8000;
|
||||||
|
}
|
||||||
|
return (uint16_t)Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t clip48(uint64_t Value)
|
||||||
|
{
|
||||||
|
enum : uint64_t
|
||||||
|
{
|
||||||
|
b = 1ull << (48 - 1),
|
||||||
|
m = b * 2 - 1
|
||||||
|
};
|
||||||
|
return ((Value & m) ^ b) - b;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
uint16_t clamp16(int32_t Value);
|
||||||
|
int64_t clip48(uint64_t);
|
Loading…
Reference in New Issue