mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 02:42:20 +00:00
Moved this macro
This commit is contained in:
parent
a0ec86ce01
commit
6c37576bc0
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__
|
||||
#define __M_SWAP__
|
||||
|
||||
#include "endian.h"
|
||||
|
||||
// Endianess handling.
|
||||
// WAD files are stored little endian.
|
||||
#include "endian.h"
|
||||
|
||||
// Little to big endian
|
||||
#ifdef SRB2_BIG_ENDIAN
|
||||
|
||||
#define SHORT(x) ((INT16)(\
|
||||
(((UINT16)(x) & (UINT16)0x00ffU) << 8) \
|
||||
| \
|
||||
(((UINT16)(x) & (UINT16)0xff00U) >> 8))) \
|
||||
#define SHORT(x) ((INT16)(\
|
||||
(((UINT16)(x) & (UINT16)0x00ffU) << 8) \
|
||||
| \
|
||||
(((UINT16)(x) & (UINT16)0xff00U) >> 8))) \
|
||||
|
||||
#define LONG(x) ((INT32)(\
|
||||
(((UINT32)(x) & (UINT32)0x000000ffUL) << 24) \
|
||||
| \
|
||||
(((UINT32)(x) & (UINT32)0x0000ff00UL) << 8) \
|
||||
| \
|
||||
(((UINT32)(x) & (UINT32)0x00ff0000UL) >> 8) \
|
||||
| \
|
||||
(((UINT32)(x) & (UINT32)0xff000000UL) >> 24)))
|
||||
#define LONG(x) ((INT32)(\
|
||||
(((UINT32)(x) & (UINT32)0x000000ffUL) << 24) \
|
||||
| \
|
||||
(((UINT32)(x) & (UINT32)0x0000ff00UL) << 8) \
|
||||
| \
|
||||
(((UINT32)(x) & (UINT32)0x00ff0000UL) >> 8) \
|
||||
| \
|
||||
(((UINT32)(x) & (UINT32)0xff000000UL) >> 24)))
|
||||
|
||||
#else
|
||||
#define SHORT(x) ((INT16)(x))
|
||||
#define LONG(x) ((INT32)(x))
|
||||
#define SHORT(x) ((INT16)(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
|
||||
|
|
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))
|
||||
{
|
||||
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
|
||||
if (leftoffset != NULL)
|
||||
*leftoffset = (INT16)ENDIANESS(*offsets);
|
||||
*leftoffset = (INT16)BIGENDIAN_LONG(*offsets);
|
||||
offsets++;
|
||||
|
||||
// read top offset
|
||||
if (topoffset != NULL)
|
||||
*topoffset = (INT16)ENDIANESS(*offsets);
|
||||
|
||||
#undef ENDIANESS
|
||||
*topoffset = (INT16)BIGENDIAN_LONG(*offsets);
|
||||
}
|
||||
|
||||
// bye
|
||||
|
|
Loading…
Reference in a new issue