project64/Source/Project64-rsp-core/cpu/RspClamp.cpp

24 lines
372 B
C++
Raw Normal View History

2023-09-07 02:01:31 +00:00
#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
2023-09-07 02:01:31 +00:00
};
return ((Value & m) ^ b) - b;
}