MVE: Add support for big-endian systems

This commit is contained in:
Azamat H. Hackimov 2024-05-05 21:01:12 +03:00
parent afd7c1a636
commit 96c240a4c0

View File

@ -30,6 +30,7 @@
#include <SDL.h> #include <SDL.h>
#endif #endif
#include "byteswap.h"
#include "decoders.h" #include "decoders.h"
#include "mvelib.h" #include "mvelib.h"
#include "mve_audio.h" #include "mve_audio.h"
@ -64,22 +65,16 @@ static int g_frameUpdated = 0;
static ISoundDevice *snd_ds = nullptr; static ISoundDevice *snd_ds = nullptr;
static short get_short(unsigned char *data) { static short get_short(const unsigned char *data) {
short value; return D3::convert_le<int16_t>(data[0] | (data[1] << 8));
value = data[0] | (data[1] << 8);
return value;
} }
static unsigned short get_ushort(unsigned char *data) { static unsigned short get_ushort(const unsigned char *data) {
unsigned short value; return D3::convert_le<uint16_t>(data[0] | (data[1] << 8));
value = data[0] | (data[1] << 8);
return value;
} }
static int get_int(unsigned char *data) { static int get_int(const unsigned char *data) {
int value; return D3::convert_le<int32_t>(data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24));
value = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
return value;
} }
static unsigned int unhandled_chunks[32 * 256]; static unsigned int unhandled_chunks[32 * 256];