mirror of https://github.com/mgba-emu/mgba.git
The old implementation of endian swapping was sufficient, put it back
This commit is contained in:
parent
f4d27e5e40
commit
5afd8ea1bb
|
@ -16,44 +16,11 @@
|
||||||
|
|
||||||
#define UNUSED(V) (void)(V)
|
#define UNUSED(V) (void)(V)
|
||||||
|
|
||||||
#ifdef __BIG_ENDIAN__
|
|
||||||
|
|
||||||
#if defined(__PPC__) || defined(__POWERPC__)
|
#if defined(__PPC__) || defined(__POWERPC__)
|
||||||
#define SWAP_32(DEST, VAR) asm(\
|
#define LOAD_32(DEST, ADDR, ARR) asm("lwbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR))
|
||||||
"rlwinm %0, %1, 8, 24, 31\n" \
|
#define LOAD_16(DEST, ADDR, ARR) asm("lhbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR))
|
||||||
"rlwimi %0, %1, 24, 16, 23\n" \
|
#define STORE_32(SRC, ADDR, ARR) asm("stwbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR))
|
||||||
"rlwimi %0, %1, 8, 8, 15\n" \
|
#define STORE_16(SRC, ADDR, ARR) asm("sthbrx %0, %1, %2" : : "r"(SRC), "r"(ADDR), "r"(ARR))
|
||||||
"rlwimi %0, %1, 24, 0, 7\n" \
|
|
||||||
: "+r"(DEST) : "r"(VAR))
|
|
||||||
|
|
||||||
#define SWAP_16(DEST, VAR) asm(\
|
|
||||||
"rlwinm %0, %1, 24, 24, 31\n" \
|
|
||||||
"rlwimi %0, %1, 8, 16, 23\n" \
|
|
||||||
: "+r"(DEST) : "r"(VAR))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOAD_32(DEST, ADDR, ARR) { \
|
|
||||||
uint32_t _tmp = ((uint32_t*) ARR)[(ADDR) >> 2]; \
|
|
||||||
SWAP_32(DEST, _tmp); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define LOAD_16(DEST, ADDR, ARR) { \
|
|
||||||
uint16_t _tmp = ((uint16_t*) ARR)[(ADDR) >> 1]; \
|
|
||||||
SWAP_16(DEST, _tmp); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define STORE_32(SRC, ADDR, ARR) { \
|
|
||||||
uint32_t _tmp; \
|
|
||||||
SWAP_32(_tmp, SRC); \
|
|
||||||
((uint32_t*) ARR)[(ADDR) >> 2] = _tmp; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define STORE_16(SRC, ADDR, ARR) { \
|
|
||||||
uint16_t _tmp; \
|
|
||||||
SWAP_16(_tmp, SRC); \
|
|
||||||
((uint16_t*) ARR)[(ADDR) >> 2] = _tmp; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define LOAD_32(DEST, ADDR, ARR) DEST = ((uint32_t*) ARR)[(ADDR) >> 2]
|
#define LOAD_32(DEST, ADDR, ARR) DEST = ((uint32_t*) ARR)[(ADDR) >> 2]
|
||||||
#define LOAD_16(DEST, ADDR, ARR) DEST = ((uint16_t*) ARR)[(ADDR) >> 1]
|
#define LOAD_16(DEST, ADDR, ARR) DEST = ((uint16_t*) ARR)[(ADDR) >> 1]
|
||||||
|
|
Loading…
Reference in New Issue