mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
Moved this macro
This commit is contained in:
parent
e3ceadbfe3
commit
d2bc3de4ae
2 changed files with 28 additions and 29 deletions
42
src/m_swap.h
42
src/m_swap.h
|
|
@ -14,29 +14,39 @@
|
||||||
#ifndef __M_SWAP__
|
#ifndef __M_SWAP__
|
||||||
#define __M_SWAP__
|
#define __M_SWAP__
|
||||||
|
|
||||||
#include "endian.h"
|
|
||||||
|
|
||||||
// Endianess handling.
|
// Endianess handling.
|
||||||
// WAD files are stored little endian.
|
// WAD files are stored little endian.
|
||||||
|
#include "endian.h"
|
||||||
|
|
||||||
|
// Little to big endian
|
||||||
#ifdef SRB2_BIG_ENDIAN
|
#ifdef SRB2_BIG_ENDIAN
|
||||||
|
|
||||||
#define SHORT(x) ((INT16)(\
|
#define SHORT(x) ((INT16)(\
|
||||||
(((UINT16)(x) & (UINT16)0x00ffU) << 8) \
|
(((UINT16)(x) & (UINT16)0x00ffU) << 8) \
|
||||||
| \
|
| \
|
||||||
(((UINT16)(x) & (UINT16)0xff00U) >> 8))) \
|
(((UINT16)(x) & (UINT16)0xff00U) >> 8))) \
|
||||||
|
|
||||||
#define LONG(x) ((INT32)(\
|
#define LONG(x) ((INT32)(\
|
||||||
(((UINT32)(x) & (UINT32)0x000000ffUL) << 24) \
|
(((UINT32)(x) & (UINT32)0x000000ffUL) << 24) \
|
||||||
| \
|
| \
|
||||||
(((UINT32)(x) & (UINT32)0x0000ff00UL) << 8) \
|
(((UINT32)(x) & (UINT32)0x0000ff00UL) << 8) \
|
||||||
| \
|
| \
|
||||||
(((UINT32)(x) & (UINT32)0x00ff0000UL) >> 8) \
|
(((UINT32)(x) & (UINT32)0x00ff0000UL) >> 8) \
|
||||||
| \
|
| \
|
||||||
(((UINT32)(x) & (UINT32)0xff000000UL) >> 24)))
|
(((UINT32)(x) & (UINT32)0xff000000UL) >> 24)))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define SHORT(x) ((INT16)(x))
|
#define SHORT(x) ((INT16)(x))
|
||||||
#define LONG(x) ((INT32)(x))
|
#define LONG(x) ((INT32)(x))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Big to little endian
|
||||||
|
#ifdef SRB2_LITTLE_ENDIAN
|
||||||
|
#define BIGENDIAN_LONG(x) ((INT32)((x>>24)&0xff)|((x<<8)&0xff0000)|((x>>8)&0xff00)|((x<<24)&0xff000000))
|
||||||
|
#define BIGENDIAN_SHORT(x) ((INT16)((x>>8)|(x<<8)))
|
||||||
|
#else
|
||||||
|
#define BIGENDIAN_LONG(x) ((INT32)(x))
|
||||||
|
#define BIGENDIAN_SHORT(x) ((INT16)(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
15
src/r_data.c
15
src/r_data.c
|
|
@ -2747,24 +2747,13 @@ static png_bytep *PNG_Read(UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, I
|
||||||
if ((topoffset || leftoffset) && (chunk.data != NULL))
|
if ((topoffset || leftoffset) && (chunk.data != NULL))
|
||||||
{
|
{
|
||||||
INT32 *offsets = (INT32 *)chunk.data;
|
INT32 *offsets = (INT32 *)chunk.data;
|
||||||
|
|
||||||
// The grAb chunk stores offsets as big-endian numbers.
|
|
||||||
#ifdef SRB2_BIG_ENDIAN
|
|
||||||
#define ENDIANESS(x) (x)
|
|
||||||
#else
|
|
||||||
#define ENDIANESS(x) ((x>>24)&0xff)|((x<<8)&0xff0000)|((x>>8)&0xff00)|((x<<24)&0xff000000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// read left offset
|
// read left offset
|
||||||
if (leftoffset != NULL)
|
if (leftoffset != NULL)
|
||||||
*leftoffset = (INT16)ENDIANESS(*offsets);
|
*leftoffset = (INT16)BIGENDIAN_LONG(*offsets);
|
||||||
offsets++;
|
offsets++;
|
||||||
|
|
||||||
// read top offset
|
// read top offset
|
||||||
if (topoffset != NULL)
|
if (topoffset != NULL)
|
||||||
*topoffset = (INT16)ENDIANESS(*offsets);
|
*topoffset = (INT16)BIGENDIAN_LONG(*offsets);
|
||||||
|
|
||||||
#undef ENDIANESS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// bye
|
// bye
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue