beetle-pce-fast-libretro/mednafen/mednafen-endian.h

58 lines
1.3 KiB
C
Raw Normal View History

2012-06-03 15:48:14 +00:00
#ifndef __MDFN_ENDIAN_H
#define __MDFN_ENDIAN_H
2015-07-25 02:01:29 +00:00
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
void Endian_A16_Swap(void *src, uint32_t nelements);
void Endian_A32_Swap(void *src, uint32_t nelements);
void Endian_A64_Swap(void *src, uint32_t nelements);
2012-06-03 15:48:14 +00:00
2015-07-25 02:01:29 +00:00
void Endian_A16_NE_to_LE(void *src, uint32_t nelements);
void Endian_A32_NE_to_LE(void *src, uint32_t nelements);
void Endian_A64_NE_to_LE(void *src, uint32_t nelements);
2012-06-03 15:48:14 +00:00
2015-07-25 02:01:29 +00:00
void Endian_A16_LE_to_NE(void *src, uint32_t nelements);
void Endian_A32_LE_to_NE(void *src, uint32_t nelements);
void Endian_A64_LE_to_NE(void *src, uint32_t nelements);
2012-06-03 15:48:14 +00:00
2015-07-25 02:01:29 +00:00
void Endian_V_LE_to_NE(void *src, uint32_t bytesize);
void Endian_V_NE_to_LE(void *src, uint32_t bytesize);
2012-06-03 15:48:14 +00:00
2015-07-25 02:01:29 +00:00
void FlipByteOrder(uint8_t *src, uint32_t count);
2012-06-03 15:48:14 +00:00
// The following functions can encode/decode to unaligned addresses.
2017-07-06 16:14:09 +00:00
static INLINE void MDFN_en16lsb(uint8_t *buf, uint16_t morp)
2012-06-03 15:48:14 +00:00
{
buf[0]=morp;
buf[1]=morp>>8;
}
2017-07-06 16:14:09 +00:00
static INLINE void MDFN_en32lsb(uint8_t *buf, uint32_t morp)
2012-06-03 15:48:14 +00:00
{
buf[0]=morp;
buf[1]=morp>>8;
buf[2]=morp>>16;
buf[3]=morp>>24;
}
2017-07-06 16:14:09 +00:00
static INLINE uint16_t MDFN_de16lsb(const uint8_t *morp)
2012-06-03 15:48:14 +00:00
{
return(morp[0] | (morp[1] << 8));
}
2017-07-06 16:14:09 +00:00
static INLINE uint32_t MDFN_de32lsb(const uint8_t *morp)
2012-06-03 15:48:14 +00:00
{
return(morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24));
}
2015-07-25 02:01:29 +00:00
#ifdef __cplusplus
}
#endif
2012-06-03 15:48:14 +00:00
#endif