mirror of
https://github.com/libretro/beetle-psx-libretro.git
synced 2024-11-23 08:49:47 +00:00
Remove C++11 dependency
This commit is contained in:
parent
f5bdb19385
commit
b537b04866
74
libretro.cpp
74
libretro.cpp
@ -844,8 +844,8 @@ template<typename T, bool IsWrite, bool Access24> static INLINE void MemRW(int32
|
||||
else switch(sizeof(T))
|
||||
{
|
||||
case 1: V = TextMem[(A & 0x7FFFFF) - 65536]; break;
|
||||
case 2: V = MDFN_de16lsb(&TextMem[(A & 0x7FFFFF) - 65536]); break;
|
||||
case 4: V = MDFN_de32lsb(&TextMem[(A & 0x7FFFFF) - 65536]); break;
|
||||
case 2: V = MDFN_de16lsb<false>(&TextMem[(A & 0x7FFFFF) - 65536]); break;
|
||||
case 4: V = MDFN_de32lsb<false>(&TextMem[(A & 0x7FFFFF) - 65536]); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1032,9 +1032,9 @@ template<typename T, bool Access24> static INLINE uint32_t MemPeek(int32_t times
|
||||
case 1:
|
||||
return(TextMem[(A & 0x7FFFFF) - 65536]);
|
||||
case 2:
|
||||
return(MDFN_de16lsb(&TextMem[(A & 0x7FFFFF) - 65536]));
|
||||
return(MDFN_de16lsb<false>(&TextMem[(A & 0x7FFFFF) - 65536]));
|
||||
case 4:
|
||||
return(MDFN_de32lsb(&TextMem[(A & 0x7FFFFF) - 65536]));
|
||||
return(MDFN_de32lsb<false>(&TextMem[(A & 0x7FFFFF) - 65536]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1269,8 +1269,8 @@ static const char *CalcDiscSCEx_BySYSTEMCNF(CDIF *c, unsigned *rr)
|
||||
} while(pvd[0] != 0x01);
|
||||
|
||||
/*[156 ... 189], 34 bytes */
|
||||
rdel = MDFN_de32lsb(&pvd[0x9E]);
|
||||
rdel_len = MDFN_de32lsb(&pvd[0xA6]);
|
||||
rdel = MDFN_de32lsb<false>(&pvd[0x9E]);
|
||||
rdel_len = MDFN_de32lsb<false>(&pvd[0xA6]);
|
||||
|
||||
if(rdel_len >= (1024 * 1024 * 10)) /* Arbitrary sanity check. */
|
||||
{
|
||||
@ -1299,8 +1299,8 @@ static const char *CalcDiscSCEx_BySYSTEMCNF(CDIF *c, unsigned *rr)
|
||||
|
||||
if(len_fi == 12 && !memcmp(&dr[0x21], "SYSTEM.CNF;1", 12))
|
||||
{
|
||||
uint32_t file_lba = MDFN_de32lsb(&dr[0x02]);
|
||||
//uint32_t file_len = MDFN_de32lsb(&dr[0x0A]);
|
||||
uint32_t file_lba = MDFN_de32lsb<false>(&dr[0x02]);
|
||||
//uint32_t file_len = MDFN_de32lsb<false>(&dr[0x0A]);
|
||||
uint8_t fb[2048 + 1];
|
||||
char *bootpos;
|
||||
|
||||
@ -1650,10 +1650,10 @@ static void InitCommon(std::vector<CDIF *> *CDInterfaces, const bool EmulateMemc
|
||||
|
||||
static bool LoadEXE(const uint8_t *data, const uint32_t size, bool ignore_pcsp = false)
|
||||
{
|
||||
uint32 PC = MDFN_de32lsb(&data[0x10]);
|
||||
uint32 SP = MDFN_de32lsb(&data[0x30]);
|
||||
uint32 TextStart = MDFN_de32lsb(&data[0x18]);
|
||||
uint32 TextSize = MDFN_de32lsb(&data[0x1C]);
|
||||
uint32 PC = MDFN_de32lsb<false>(&data[0x10]);
|
||||
uint32 SP = MDFN_de32lsb<false>(&data[0x30]);
|
||||
uint32 TextStart = MDFN_de32lsb<false>(&data[0x18]);
|
||||
uint32 TextSize = MDFN_de32lsb<false>(&data[0x1C]);
|
||||
|
||||
if(ignore_pcsp)
|
||||
log_cb(RETRO_LOG_INFO, "TextStart=0x%08x\nTextSize=0x%08x\n", TextStart, TextSize);
|
||||
@ -1713,23 +1713,23 @@ static bool LoadEXE(const uint8_t *data, const uint32_t size, bool ignore_pcsp =
|
||||
|
||||
po = &PIOMem->data8[0x0800];
|
||||
|
||||
MDFN_en32lsb(po, (0x0 << 26) | (31 << 21) | (0x8 << 0)); // JR
|
||||
MDFN_en32lsb<false>(po, (0x0 << 26) | (31 << 21) | (0x8 << 0)); // JR
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, 0); // NOP(kinda)
|
||||
MDFN_en32lsb<false>(po, 0); // NOP(kinda)
|
||||
po += 4;
|
||||
|
||||
po = &PIOMem->data8[0x1000];
|
||||
|
||||
// Load cacheable-region target PC into r2
|
||||
MDFN_en32lsb(po, (0xF << 26) | (0 << 21) | (1 << 16) | (0x9F001010 >> 16)); // LUI
|
||||
MDFN_en32lsb<false>(po, (0xF << 26) | (0 << 21) | (1 << 16) | (0x9F001010 >> 16)); // LUI
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, (0xD << 26) | (1 << 21) | (2 << 16) | (0x9F001010 & 0xFFFF)); // ORI
|
||||
MDFN_en32lsb<false>(po, (0xD << 26) | (1 << 21) | (2 << 16) | (0x9F001010 & 0xFFFF)); // ORI
|
||||
po += 4;
|
||||
|
||||
// Jump to r2
|
||||
MDFN_en32lsb(po, (0x0 << 26) | (2 << 21) | (0x8 << 0)); // JR
|
||||
MDFN_en32lsb<false>(po, (0x0 << 26) | (2 << 21) | (0x8 << 0)); // JR
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, 0); // NOP(kinda)
|
||||
MDFN_en32lsb<false>(po, 0); // NOP(kinda)
|
||||
po += 4;
|
||||
|
||||
//
|
||||
@ -1738,42 +1738,42 @@ static bool LoadEXE(const uint8_t *data, const uint32_t size, bool ignore_pcsp =
|
||||
|
||||
// Load source address into r8
|
||||
uint32 sa = 0x9F000000 + 65536;
|
||||
MDFN_en32lsb(po, (0xF << 26) | (0 << 21) | (1 << 16) | (sa >> 16)); // LUI
|
||||
MDFN_en32lsb<false>(po, (0xF << 26) | (0 << 21) | (1 << 16) | (sa >> 16)); // LUI
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, (0xD << 26) | (1 << 21) | (8 << 16) | (sa & 0xFFFF)); // ORI
|
||||
MDFN_en32lsb<false>(po, (0xD << 26) | (1 << 21) | (8 << 16) | (sa & 0xFFFF)); // ORI
|
||||
po += 4;
|
||||
|
||||
// Load dest address into r9
|
||||
MDFN_en32lsb(po, (0xF << 26) | (0 << 21) | (1 << 16) | (TextMem_Start >> 16)); // LUI
|
||||
MDFN_en32lsb<false>(po, (0xF << 26) | (0 << 21) | (1 << 16) | (TextMem_Start >> 16)); // LUI
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, (0xD << 26) | (1 << 21) | (9 << 16) | (TextMem_Start & 0xFFFF)); // ORI
|
||||
MDFN_en32lsb<false>(po, (0xD << 26) | (1 << 21) | (9 << 16) | (TextMem_Start & 0xFFFF)); // ORI
|
||||
po += 4;
|
||||
|
||||
// Load size into r10
|
||||
MDFN_en32lsb(po, (0xF << 26) | (0 << 21) | (1 << 16) | (TextMem.size() >> 16)); // LUI
|
||||
MDFN_en32lsb<false>(po, (0xF << 26) | (0 << 21) | (1 << 16) | (TextMem.size() >> 16)); // LUI
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, (0xD << 26) | (1 << 21) | (10 << 16) | (TextMem.size() & 0xFFFF)); // ORI
|
||||
MDFN_en32lsb<false>(po, (0xD << 26) | (1 << 21) | (10 << 16) | (TextMem.size() & 0xFFFF)); // ORI
|
||||
po += 4;
|
||||
|
||||
//
|
||||
// Loop begin
|
||||
//
|
||||
|
||||
MDFN_en32lsb(po, (0x24 << 26) | (8 << 21) | (1 << 16)); // LBU to r1
|
||||
MDFN_en32lsb<false>(po, (0x24 << 26) | (8 << 21) | (1 << 16)); // LBU to r1
|
||||
po += 4;
|
||||
|
||||
MDFN_en32lsb(po, (0x08 << 26) | (10 << 21) | (10 << 16) | 0xFFFF); // Decrement size
|
||||
MDFN_en32lsb<false>(po, (0x08 << 26) | (10 << 21) | (10 << 16) | 0xFFFF); // Decrement size
|
||||
po += 4;
|
||||
|
||||
MDFN_en32lsb(po, (0x28 << 26) | (9 << 21) | (1 << 16)); // SB from r1
|
||||
MDFN_en32lsb<false>(po, (0x28 << 26) | (9 << 21) | (1 << 16)); // SB from r1
|
||||
po += 4;
|
||||
|
||||
MDFN_en32lsb(po, (0x08 << 26) | (8 << 21) | (8 << 16) | 0x0001); // Increment source addr
|
||||
MDFN_en32lsb<false>(po, (0x08 << 26) | (8 << 21) | (8 << 16) | 0x0001); // Increment source addr
|
||||
po += 4;
|
||||
|
||||
MDFN_en32lsb(po, (0x05 << 26) | (0 << 21) | (10 << 16) | (-5 & 0xFFFF));
|
||||
MDFN_en32lsb<false>(po, (0x05 << 26) | (0 << 21) | (10 << 16) | (-5 & 0xFFFF));
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, (0x08 << 26) | (9 << 21) | (9 << 16) | 0x0001); // Increment dest addr
|
||||
MDFN_en32lsb<false>(po, (0x08 << 26) | (9 << 21) | (9 << 16) | 0x0001); // Increment dest addr
|
||||
po += 4;
|
||||
|
||||
//
|
||||
@ -1787,31 +1787,31 @@ static bool LoadEXE(const uint8_t *data, const uint32_t size, bool ignore_pcsp =
|
||||
}
|
||||
else
|
||||
{
|
||||
MDFN_en32lsb(po, (0xF << 26) | (0 << 21) | (1 << 16) | (SP >> 16)); // LUI
|
||||
MDFN_en32lsb<false>(po, (0xF << 26) | (0 << 21) | (1 << 16) | (SP >> 16)); // LUI
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, (0xD << 26) | (1 << 21) | (29 << 16) | (SP & 0xFFFF)); // ORI
|
||||
MDFN_en32lsb<false>(po, (0xD << 26) | (1 << 21) | (29 << 16) | (SP & 0xFFFF)); // ORI
|
||||
po += 4;
|
||||
|
||||
// Load PC into r2
|
||||
MDFN_en32lsb(po, (0xF << 26) | (0 << 21) | (1 << 16) | ((PC >> 16) | 0x8000)); // LUI
|
||||
MDFN_en32lsb<false>(po, (0xF << 26) | (0 << 21) | (1 << 16) | ((PC >> 16) | 0x8000)); // LUI
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, (0xD << 26) | (1 << 21) | (2 << 16) | (PC & 0xFFFF)); // ORI
|
||||
MDFN_en32lsb<false>(po, (0xD << 26) | (1 << 21) | (2 << 16) | (PC & 0xFFFF)); // ORI
|
||||
po += 4;
|
||||
}
|
||||
|
||||
// Half-assed instruction cache flush. ;)
|
||||
for(unsigned i = 0; i < 1024; i++)
|
||||
{
|
||||
MDFN_en32lsb(po, 0);
|
||||
MDFN_en32lsb<false>(po, 0);
|
||||
po += 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Jump to r2
|
||||
MDFN_en32lsb(po, (0x0 << 26) | (2 << 21) | (0x8 << 0)); // JR
|
||||
MDFN_en32lsb<false>(po, (0x0 << 26) | (2 << 21) | (0x8 << 0)); // JR
|
||||
po += 4;
|
||||
MDFN_en32lsb(po, 0); // NOP(kinda)
|
||||
MDFN_en32lsb<false>(po, 0); // NOP(kinda)
|
||||
po += 4;
|
||||
|
||||
return true;
|
||||
|
@ -37,6 +37,11 @@ void Endian_A64_NE_BE(void *src, uint32 nelements);
|
||||
void Endian_V_NE_LE(void* p, size_t len);
|
||||
void Endian_V_NE_BE(void* p, size_t len);
|
||||
|
||||
// This is a hack to remove the dependency on C++11. This is *not*
|
||||
// correct for structs and anything but base types, but it shoud be
|
||||
// enough for our case.
|
||||
#define alignof(T) sizeof(T)
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
@ -119,7 +124,9 @@ static INLINE T MDFN_deXsb(const void* ptr)
|
||||
|
||||
if(isbigendian != -1 && isbigendian != (int)MDFN_IS_BIGENDIAN)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Gummy penguins.");
|
||||
#endif
|
||||
|
||||
if(sizeof(T) == 8)
|
||||
return MDFN_bswap64(tmp);
|
||||
@ -135,7 +142,7 @@ static INLINE T MDFN_deXsb(const void* ptr)
|
||||
//
|
||||
// Native endian.
|
||||
//
|
||||
template<typename T, bool aligned = false>
|
||||
template<typename T, bool aligned>
|
||||
static INLINE T MDFN_densb(const void* ptr)
|
||||
{
|
||||
return MDFN_deXsb<-1, T, aligned>(ptr);
|
||||
@ -144,13 +151,13 @@ static INLINE T MDFN_densb(const void* ptr)
|
||||
//
|
||||
// Little endian.
|
||||
//
|
||||
template<typename T, bool aligned = false>
|
||||
template<typename T, bool aligned>
|
||||
static INLINE T MDFN_delsb(const void* ptr)
|
||||
{
|
||||
return MDFN_deXsb<0, T, aligned>(ptr);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE uint16 MDFN_de16lsb(const void* ptr)
|
||||
{
|
||||
return MDFN_delsb<uint16, aligned>(ptr);
|
||||
@ -163,13 +170,13 @@ static INLINE uint32 MDFN_de24lsb(const void* ptr)
|
||||
return (ptr_u8[0] << 0) | (ptr_u8[1] << 8) | (ptr_u8[2] << 16);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE uint32 MDFN_de32lsb(const void* ptr)
|
||||
{
|
||||
return MDFN_delsb<uint32, aligned>(ptr);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE uint64 MDFN_de64lsb(const void* ptr)
|
||||
{
|
||||
return MDFN_delsb<uint64, aligned>(ptr);
|
||||
@ -178,13 +185,13 @@ static INLINE uint64 MDFN_de64lsb(const void* ptr)
|
||||
//
|
||||
// Big endian.
|
||||
//
|
||||
template<typename T, bool aligned = false>
|
||||
template<typename T, bool aligned>
|
||||
static INLINE T MDFN_demsb(const void* ptr)
|
||||
{
|
||||
return MDFN_deXsb<1, T, aligned>(ptr);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE uint16 MDFN_de16msb(const void* ptr)
|
||||
{
|
||||
return MDFN_demsb<uint16, aligned>(ptr);
|
||||
@ -197,13 +204,13 @@ static INLINE uint32 MDFN_de24msb(const void* ptr)
|
||||
return (ptr_u8[0] << 16) | (ptr_u8[1] << 8) | (ptr_u8[2] << 0);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE uint32 MDFN_de32msb(const void* ptr)
|
||||
{
|
||||
return MDFN_demsb<uint32, aligned>(ptr);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE uint64 MDFN_de64msb(const void* ptr)
|
||||
{
|
||||
return MDFN_demsb<uint64, aligned>(ptr);
|
||||
@ -228,7 +235,9 @@ static INLINE void MDFN_enXsb(void* ptr, T value)
|
||||
|
||||
if(isbigendian != -1 && isbigendian != (int)MDFN_IS_BIGENDIAN)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Gummy penguins.");
|
||||
#endif
|
||||
|
||||
if(sizeof(T) == 8)
|
||||
tmp = MDFN_bswap64(value);
|
||||
@ -244,7 +253,7 @@ static INLINE void MDFN_enXsb(void* ptr, T value)
|
||||
//
|
||||
// Native endian.
|
||||
//
|
||||
template<typename T, bool aligned = false>
|
||||
template<typename T, bool aligned>
|
||||
static INLINE void MDFN_ennsb(void* ptr, T value)
|
||||
{
|
||||
MDFN_enXsb<-1, T, aligned>(ptr, value);
|
||||
@ -253,13 +262,13 @@ static INLINE void MDFN_ennsb(void* ptr, T value)
|
||||
//
|
||||
// Little endian.
|
||||
//
|
||||
template<typename T, bool aligned = false>
|
||||
template<typename T, bool aligned>
|
||||
static INLINE void MDFN_enlsb(void* ptr, T value)
|
||||
{
|
||||
MDFN_enXsb<0, T, aligned>(ptr, value);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE void MDFN_en16lsb(void* ptr, uint16 value)
|
||||
{
|
||||
MDFN_enlsb<uint16, aligned>(ptr, value);
|
||||
@ -274,13 +283,13 @@ static INLINE void MDFN_en24lsb(void* ptr, uint32 value)
|
||||
ptr_u8[2] = value >> 16;
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE void MDFN_en32lsb(void* ptr, uint32 value)
|
||||
{
|
||||
MDFN_enlsb<uint32, aligned>(ptr, value);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE void MDFN_en64lsb(void* ptr, uint64 value)
|
||||
{
|
||||
MDFN_enlsb<uint64, aligned>(ptr, value);
|
||||
@ -290,13 +299,13 @@ static INLINE void MDFN_en64lsb(void* ptr, uint64 value)
|
||||
//
|
||||
// Big endian.
|
||||
//
|
||||
template<typename T, bool aligned = false>
|
||||
template<typename T, bool aligned>
|
||||
static INLINE void MDFN_enmsb(void* ptr, T value)
|
||||
{
|
||||
MDFN_enXsb<1, T, aligned>(ptr, value);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE void MDFN_en16msb(void* ptr, uint16 value)
|
||||
{
|
||||
MDFN_enmsb<uint16, aligned>(ptr, value);
|
||||
@ -311,13 +320,13 @@ static INLINE void MDFN_en24msb(void* ptr, uint32 value)
|
||||
ptr_u8[2] = value >> 0;
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE void MDFN_en32msb(void* ptr, uint32 value)
|
||||
{
|
||||
MDFN_enmsb<uint32, aligned>(ptr, value);
|
||||
}
|
||||
|
||||
template<bool aligned = false>
|
||||
template<bool aligned>
|
||||
static INLINE void MDFN_en64msb(void* ptr, uint64 value)
|
||||
{
|
||||
MDFN_enmsb<uint64, aligned>(ptr, value);
|
||||
@ -354,8 +363,10 @@ static INLINE uintptr_t neX_ptr_le(uintptr_t const base, const size_t byte_offse
|
||||
template<typename T, typename BT>
|
||||
static INLINE void ne16_wbo_be(BT base, const size_t byte_offset, const T value)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint16*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_be<T, uint16>((uintptr_t)base, byte_offset);
|
||||
|
||||
@ -373,8 +384,10 @@ static INLINE void ne16_wbo_be(BT base, const size_t byte_offset, const T value)
|
||||
template<typename T, typename BT>
|
||||
static INLINE T ne16_rbo_be(BT base, const size_t byte_offset)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint16*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_be<T, uint16>((uintptr_t)base, byte_offset);
|
||||
|
||||
@ -408,8 +421,10 @@ static INLINE void ne16_rwbo_be(BT base, const size_t byte_offset, T* value)
|
||||
template<typename T, typename BT>
|
||||
static INLINE void ne16_wbo_le(BT base, const size_t byte_offset, const T value)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint16*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_le<T, uint16>((uintptr_t)base, byte_offset);
|
||||
|
||||
@ -427,8 +442,10 @@ static INLINE void ne16_wbo_le(BT base, const size_t byte_offset, const T value)
|
||||
template<typename T, typename BT>
|
||||
static INLINE T ne16_rbo_le(BT base, const size_t byte_offset)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint16*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_le<T, uint16>((uintptr_t)base, byte_offset);
|
||||
|
||||
@ -462,8 +479,10 @@ static INLINE void ne16_rwbo_le(BT base, const size_t byte_offset, T* value)
|
||||
template<typename T, typename BT>
|
||||
static INLINE void ne64_wbo_be(BT base, const size_t byte_offset, const T value)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint64*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_be<T, uint64>((uintptr_t)base, byte_offset);
|
||||
|
||||
@ -473,8 +492,10 @@ static INLINE void ne64_wbo_be(BT base, const size_t byte_offset, const T value)
|
||||
template<typename T, typename BT>
|
||||
static INLINE T ne64_rbo_be(BT base, const size_t byte_offset)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint64*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_be<T, uint64>((uintptr_t)base, byte_offset);
|
||||
T ret;
|
||||
@ -498,8 +519,10 @@ static INLINE void ne64_rwbo_be(BT base, const size_t byte_offset, T* value)
|
||||
template<typename T, typename BT>
|
||||
static INLINE void ne64_wbo_le(BT base, const size_t byte_offset, const T value)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, uint64*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_le<T, uint64>((uintptr_t)base, byte_offset);
|
||||
|
||||
@ -509,8 +532,10 @@ static INLINE void ne64_wbo_le(BT base, const size_t byte_offset, const T value)
|
||||
template<typename T, typename BT>
|
||||
static INLINE T ne64_rbo_le(BT base, const size_t byte_offset)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Unsupported type size");
|
||||
static_assert(std::is_same<BT, uintptr_t>::value || std::is_convertible<BT, const uint64*>::value, "Wrong base type");
|
||||
#endif
|
||||
|
||||
uintptr_t const ptr = neX_ptr_le<T, uint64>((uintptr_t)base, byte_offset);
|
||||
T ret;
|
||||
|
@ -16,7 +16,7 @@
|
||||
#endif
|
||||
|
||||
#if __cplusplus <= 199711L
|
||||
# define static_assert(_x, _y)
|
||||
# define HAS_CXX11
|
||||
#endif
|
||||
|
||||
#define GET_FDATA_PTR(fp) (fp->data)
|
||||
|
@ -882,8 +882,8 @@ void PS_CDC::EnbufferizeCDDASector(const uint8 *buf)
|
||||
{
|
||||
for(int i = 0; i < 588; i++)
|
||||
{
|
||||
ab->Samples[0][i] = (int16)MDFN_de16lsb(&buf[i * sizeof(int16) * 2 + 0]);
|
||||
ab->Samples[1][i] = (int16)MDFN_de16lsb(&buf[i * sizeof(int16) * 2 + 2]);
|
||||
ab->Samples[0][i] = (int16)MDFN_de16lsb<false>(&buf[i * sizeof(int16) * 2 + 0]);
|
||||
ab->Samples[1][i] = (int16)MDFN_de16lsb<false>(&buf[i * sizeof(int16) * 2 + 2]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -976,7 +976,7 @@ void PS_CDC::HandlePlayRead(void)
|
||||
bool abs_lev_chselect = SubQBuf_Safe[0x8] & 0x01;
|
||||
|
||||
for(int i = 0; i < 588; i++)
|
||||
abs_lev_max = std::max<uint16>(abs_lev_max, std::min<int>(abs((int16)MDFN_de16lsb(&read_buf[i * 4 + (abs_lev_chselect * 2)])), 32767));
|
||||
abs_lev_max = std::max<uint16>(abs_lev_max, std::min<int>(abs((int16)MDFN_de16lsb<false>(&read_buf[i * 4 + (abs_lev_chselect * 2)])), 32767));
|
||||
abs_lev_max |= abs_lev_chselect << 15;
|
||||
#endif
|
||||
|
||||
|
@ -58,6 +58,7 @@ namespace MDFN_IEN_PSX
|
||||
|
||||
|
||||
PS_CPU::PS_CPU()
|
||||
:addr_mask{ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x1FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }
|
||||
{
|
||||
//printf("%zu\n", (size_t)((uintptr_t)ICache - (uintptr_t)this));
|
||||
|
||||
|
@ -131,7 +131,7 @@ class PS_CPU
|
||||
|
||||
uint32 BIU;
|
||||
|
||||
const uint32 addr_mask[8] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x1FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
|
||||
const uint32 addr_mask[8];
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -184,7 +184,9 @@ struct TexCache_t
|
||||
template<uint32_t TexMode_TA>
|
||||
static INLINE uint16_t GetTexel(PS_GPU *g, int32_t u_arg, int32_t v_arg)
|
||||
{
|
||||
#ifdef HAS_CXX11
|
||||
static_assert(TexMode_TA <= 2, "TexMode_TA must be <= 2");
|
||||
#endif
|
||||
|
||||
uint32_t u_ext = ((u_arg & g->SUCV.TWX_AND) + g->SUCV.TWX_ADD);
|
||||
uint32_t fbtex_x = ((u_ext >> (2 - TexMode_TA))) & 1023;
|
||||
|
@ -123,7 +123,7 @@ void InputDevice_DualAnalog::UpdateInput(const void *data)
|
||||
//revert to 0.9.33, should be fixed on libretro side instead
|
||||
//tmp = 32768 + MDFN_de16lsb(&aba[0]) - ((int32)MDFN_de16lsb(&aba[2]) * 32768 / 32767);
|
||||
|
||||
tmp = 32768 + MDFN_de32lsb((const uint8 *)data + stick * 16 + axis * 8 + 4) - ((int32)MDFN_de32lsb((const uint8 *)data + stick * 16 + axis * 8 + 8) * 32768 / 32767);
|
||||
tmp = 32768 + MDFN_de32lsb<false>((const uint8 *)data + stick * 16 + axis * 8 + 4) - ((int32)MDFN_de32lsb<false>((const uint8 *)data + stick * 16 + axis * 8 + 8) * 32768 / 32767);
|
||||
tmp >>= 8;
|
||||
|
||||
axes[stick][axis] = tmp;
|
||||
|
@ -311,7 +311,7 @@ void InputDevice_DualShock::UpdateInput(const void *data)
|
||||
//tmp = 32767 + MDFN_de16lsb(&aba[0]) - MDFN_de16lsb(&aba[2]);
|
||||
//tmp = (tmp * 0x100) / 0xFFFF;
|
||||
|
||||
tmp = 32768 + MDFN_de32lsb((const uint8 *)data + stick * 16 + axis * 8 + 4) - ((int32)MDFN_de32lsb((const uint8 *)data + stick * 16 + axis * 8 + 8) * 32768 / 32767);
|
||||
tmp = 32768 + MDFN_de32lsb<false>((const uint8 *)data + stick * 16 + axis * 8 + 4) - ((int32)MDFN_de32lsb<false>((const uint8 *)data + stick * 16 + axis * 8 + 8) * 32768 / 32767);
|
||||
tmp >>= 8;
|
||||
axes[stick][axis] = tmp;
|
||||
}
|
||||
@ -331,7 +331,7 @@ void InputDevice_DualShock::UpdateInput(const void *data)
|
||||
//revert to 0.9.33, should be fixed on libretro side instead
|
||||
//MDFN_en16lsb(rumb_dp, (sneaky_weaky << 0) | (rumble_param[1] << 8));
|
||||
|
||||
MDFN_en32lsb(&d8[4 + 32 + 0], (sneaky_weaky << 0) | (rumble_param[1] << 8));
|
||||
MDFN_en32lsb<false>(&d8[4 + 32 + 0], (sneaky_weaky << 0) | (rumble_param[1] << 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -342,7 +342,7 @@ void InputDevice_DualShock::UpdateInput(const void *data)
|
||||
|
||||
//revert to 0.9.33, should be fixed on libretro side instead
|
||||
//MDFN_en16lsb(rumb_dp, sneaky_weaky << 0);
|
||||
MDFN_en32lsb(&d8[4 + 32 + 0], sneaky_weaky << 0);
|
||||
MDFN_en32lsb<false>(&d8[4 + 32 + 0], sneaky_weaky << 0);
|
||||
}
|
||||
|
||||
//printf("%d %d %d %d\n", axes[0][0], axes[0][1], axes[1][0], axes[1][1]);
|
||||
|
@ -163,8 +163,8 @@ void InputDevice_GunCon::UpdateInput(const void *data)
|
||||
{
|
||||
uint8 *d8 = (uint8 *)data;
|
||||
|
||||
nom_x = (int16)MDFN_de16lsb(&d8[0]);
|
||||
nom_y = (int16)MDFN_de16lsb(&d8[2]);
|
||||
nom_x = (int16)MDFN_de16lsb<false>(&d8[0]);
|
||||
nom_y = (int16)MDFN_de16lsb<false>(&d8[2]);
|
||||
|
||||
trigger_noclear = (bool)(d8[4] & 0x1);
|
||||
trigger_eff |= trigger_noclear;
|
||||
@ -327,8 +327,8 @@ bool InputDevice_GunCon::Clock(bool TxD, int32 &dsr_pulse_delay)
|
||||
}
|
||||
}
|
||||
|
||||
MDFN_en16lsb(&transmit_buffer[3], hit_x);
|
||||
MDFN_en16lsb(&transmit_buffer[5], hit_y);
|
||||
MDFN_en16lsb<false>(&transmit_buffer[3], hit_x);
|
||||
MDFN_en16lsb<false>(&transmit_buffer[5], hit_y);
|
||||
|
||||
hit_x = 0x01;
|
||||
hit_y = 0x0A;
|
||||
|
@ -119,8 +119,8 @@ void InputDevice_Justifier::UpdateInput(const void *data)
|
||||
{
|
||||
uint8 *d8 = (uint8 *)data;
|
||||
|
||||
nom_x = (int16)MDFN_de16lsb(&d8[0]);
|
||||
nom_y = (int16)MDFN_de16lsb(&d8[2]);
|
||||
nom_x = (int16)MDFN_de16lsb<false>(&d8[0]);
|
||||
nom_y = (int16)MDFN_de16lsb<false>(&d8[2]);
|
||||
|
||||
trigger_noclear = (bool)(d8[4] & 0x1);
|
||||
trigger_eff |= trigger_noclear;
|
||||
|
@ -146,8 +146,8 @@ int InputDevice_Mouse::StateAction(StateMem* sm, int load, int data_only, const
|
||||
|
||||
void InputDevice_Mouse::UpdateInput(const void *data)
|
||||
{
|
||||
accum_xdelta += (int32)MDFN_de32lsb((uint8*)data + 0);
|
||||
accum_ydelta += (int32)MDFN_de32lsb((uint8*)data + 4);
|
||||
accum_xdelta += (int32)MDFN_de32lsb<false>((uint8*)data + 0);
|
||||
accum_ydelta += (int32)MDFN_de32lsb<false>((uint8*)data + 4);
|
||||
|
||||
if(accum_xdelta > 30 * 127) accum_xdelta = 30 * 127;
|
||||
if(accum_xdelta < 30 * -128) accum_xdelta = 30 * -128;
|
||||
|
@ -98,11 +98,11 @@ void InputDevice_neGcon::UpdateInput(const void *data)
|
||||
buttons[0] = d8[0];
|
||||
buttons[1] = d8[1];
|
||||
|
||||
twist = ((32768 + MDFN_de32lsb((const uint8 *)data + 4) - (((int32)MDFN_de32lsb((const uint8 *)data + 8) * 32768 + 16383) / 32767)) * 255 + 32767) / 65535;
|
||||
twist = ((32768 + MDFN_de32lsb<false>((const uint8 *)data + 4) - (((int32)MDFN_de32lsb<false>((const uint8 *)data + 8) * 32768 + 16383) / 32767)) * 255 + 32767) / 65535;
|
||||
|
||||
anabuttons[0] = (MDFN_de32lsb((const uint8 *)data + 12) * 255 + 16383) / 32767;
|
||||
anabuttons[1] = (MDFN_de32lsb((const uint8 *)data + 16) * 255 + 16383) / 32767;
|
||||
anabuttons[2] = (MDFN_de32lsb((const uint8 *)data + 20) * 255 + 16383) / 32767;
|
||||
anabuttons[0] = (MDFN_de32lsb<false>((const uint8 *)data + 12) * 255 + 16383) / 32767;
|
||||
anabuttons[1] = (MDFN_de32lsb<false>((const uint8 *)data + 16) * 255 + 16383) / 32767;
|
||||
anabuttons[2] = (MDFN_de32lsb<false>((const uint8 *)data + 20) * 255 + 16383) / 32767;
|
||||
|
||||
//printf("%02x %02x %02x %02x\n", twist, anabuttons[0], anabuttons[1], anabuttons[2]);
|
||||
}
|
||||
|
@ -458,9 +458,9 @@ int MDFNSS_SaveSM(void *st_p, int, int, const void*, const void*, const void*)
|
||||
memset(header, 0, sizeof(header));
|
||||
memcpy(header, header_magic, 8);
|
||||
|
||||
MDFN_en32lsb(header + 16, MEDNAFEN_VERSION_NUMERIC);
|
||||
MDFN_en32lsb(header + 24, neowidth);
|
||||
MDFN_en32lsb(header + 28, neoheight);
|
||||
MDFN_en32lsb<false>(header + 16, MEDNAFEN_VERSION_NUMERIC);
|
||||
MDFN_en32lsb<false>(header + 24, neowidth);
|
||||
MDFN_en32lsb<false>(header + 28, neoheight);
|
||||
smem_write(st, header, 32);
|
||||
|
||||
if(!StateAction(st, 0, 0))
|
||||
@ -484,7 +484,7 @@ int MDFNSS_LoadSM(void *st_p, int, int)
|
||||
if(memcmp(header, "MEDNAFENSVESTATE", 16) && memcmp(header, "MDFNSVST", 8))
|
||||
return(0);
|
||||
|
||||
stateversion = MDFN_de32lsb(header + 16);
|
||||
stateversion = MDFN_de32lsb<false>(header + 16);
|
||||
|
||||
return(StateAction(st, stateversion, 0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user