diff options
author | David Guillen Fandos | 2021-06-27 01:16:28 +0200 |
---|---|---|
committer | David Guillen Fandos | 2021-06-27 01:16:28 +0200 |
commit | 8dbf5f6c17e3d217877119620e5bbfeba05abd7a (patch) | |
tree | cc50bd05fd8fd14444825c4929fb94ea6e98b1dc /common.h | |
parent | bdf029398070b338e28318d5e1e2418a1815c3a6 (diff) | |
download | picogpsp-8dbf5f6c17e3d217877119620e5bbfeba05abd7a.tar.gz picogpsp-8dbf5f6c17e3d217877119620e5bbfeba05abd7a.tar.bz2 picogpsp-8dbf5f6c17e3d217877119620e5bbfeba05abd7a.zip |
Enable big-endian devices: gc/wii
This patch adds big-endian compatibility in gpsp (in general but only
for the interpreter). There's no performance hit for little-endian
platforms (should be a no-op) and only add a small overhead in memory
accesses for big-endian platforms.
Most memory accesses are wrapped with a byteswap instruction and I/O reg
accesses are also rewired for proper access (using macros). Video
rendering has been fixed to also do byteswaps but there's a couple of
games and rendering modes that still seem broken (but they amount to
less than 20 games in my tests with 1K ROMs).
This also adds build rules and CI for NGC/WII/WIIU (untested)
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -124,6 +124,22 @@ typedef u32 fixed8_24; #define address32(base, offset) \ *((u32 *)((u8 *)base + (offset))) \ +#define eswap8(value) (value) +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define eswap16(value) __builtin_bswap16(value) + #define eswap32(value) __builtin_bswap32(value) +#else + #define eswap16(value) (value) + #define eswap32(value) (value) +#endif + +#define readaddress8(base, offset) eswap8( address8( base, offset)) +#define readaddress16(base, offset) eswap16(address16(base, offset)) +#define readaddress32(base, offset) eswap32(address32(base, offset)) + +#define read_ioreg(regnum) (eswap16(io_registers[(regnum)])) +#define write_ioreg(regnum, val) io_registers[(regnum)] = eswap16(val) + #include <unistd.h> #include <time.h> #include <stdlib.h> |