aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2017-07-30 17:26:04 +0100
committerEugene Sandulenko2017-07-30 22:03:29 +0200
commitd2a7c296a2dc7d3f7618acd5785f59ee8508a1f0 (patch)
tree069c3c1daa49cdd794293c28ec0f02419e198453
parent06566151f92d2aa6d40b81972b3c342f038a2596 (diff)
downloadscummvm-rg350-d2a7c296a2dc7d3f7618acd5785f59ee8508a1f0.tar.gz
scummvm-rg350-d2a7c296a2dc7d3f7618acd5785f59ee8508a1f0.tar.bz2
scummvm-rg350-d2a7c296a2dc7d3f7618acd5785f59ee8508a1f0.zip
COMMON: Migrate Various Endian Functions to Common from Engine Code.
Thanks to N.E.C <beholdnec@gmail.com> for this.
-rw-r--r--common/endian.h32
-rw-r--r--engines/hopkins/hopkins.h2
-rw-r--r--engines/lure/luredefs.h3
-rw-r--r--engines/queen/queen.h18
-rw-r--r--engines/toon/tools.h6
5 files changed, 32 insertions, 29 deletions
diff --git a/common/endian.h b/common/endian.h
index 7278265961..e924b5142d 100644
--- a/common/endian.h
+++ b/common/endian.h
@@ -608,4 +608,36 @@ inline uint32 READ_BE_UINT24(const void *ptr) {
#define READ_UINT24(a) READ_BE_UINT24(a)
#endif
+inline int16 READ_LE_INT16(const void *ptr) {
+ return static_cast<int16>(READ_LE_UINT16(ptr));
+}
+
+inline void WRITE_LE_INT16(void *ptr, int16 value) {
+ WRITE_LE_UINT16(ptr, static_cast<uint16>(value));
+}
+
+inline int16 READ_BE_INT16(const void *ptr) {
+ return static_cast<int16>(READ_BE_UINT16(ptr));
+}
+
+inline void WRITE_BE_INT16(void *ptr, int16 value) {
+ WRITE_BE_UINT16(ptr, static_cast<uint16>(value));
+}
+
+inline int32 READ_LE_INT32(const void *ptr) {
+ return static_cast<int32>(READ_LE_UINT32(ptr));
+}
+
+inline void WRITE_LE_INT32(void *ptr, int32 value) {
+ WRITE_LE_UINT32(ptr, static_cast<uint32>(value));
+}
+
+inline int32 READ_BE_INT32(const void *ptr) {
+ return static_cast<int32>(READ_BE_UINT32(ptr));
+}
+
+inline void WRITE_BE_INT32(void *ptr, int32 value) {
+ WRITE_BE_UINT32(ptr, static_cast<uint32>(value));
+}
+
#endif
diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h
index 30140baa2e..3528a98d58 100644
--- a/engines/hopkins/hopkins.h
+++ b/engines/hopkins/hopkins.h
@@ -72,8 +72,6 @@ enum HopkinsDebugChannels {
*/
#define MKTAG24(a0,a1,a2) ((uint32)((a2) | (a1) << 8 | ((a0) << 16)))
-#define READ_LE_INT16(x) (int16) READ_LE_UINT16(x)
-
struct HopkinsGameDescription;
class HopkinsEngine : public Engine {
diff --git a/engines/lure/luredefs.h b/engines/lure/luredefs.h
index 7b39710798..c6d0afa34c 100644
--- a/engines/lure/luredefs.h
+++ b/engines/lure/luredefs.h
@@ -37,9 +37,6 @@ namespace Lure {
#define LURE_DEBUG 1
-#define READ_LE_INT16(x) (int16) READ_LE_UINT16(x)
-#define READ_LE_INT32(x) (int32) READ_LE_UINT32(x)
-
enum {
kLureDebugScripts = 1 << 0,
kLureDebugAnimations = 1 << 1,
diff --git a/engines/queen/queen.h b/engines/queen/queen.h
index 789025c264..3c38ccd312 100644
--- a/engines/queen/queen.h
+++ b/engines/queen/queen.h
@@ -30,24 +30,6 @@ namespace Common {
class SeekableReadStream;
}
-#if defined(_WIN32_WCE) && (_WIN32_WCE <= 300)
-
-#include "common/endian.h"
-
-FORCEINLINE int16 READ_BE_INT16(const void *ptr) {
- uint16 result;
- char dummy[2];
- result = READ_BE_UINT16(ptr);
- strcpy(dummy, "x"); // Hello, I'm a drunk optimizer. Thanks for helping me.
- return result;
-}
-
-#else
-
-#define READ_BE_INT16 READ_BE_UINT16
-
-#endif
-
/**
* This is the namespace of the Queen engine.
*
diff --git a/engines/toon/tools.h b/engines/toon/tools.h
index d80ec006b0..1ba8cebdb7 100644
--- a/engines/toon/tools.h
+++ b/engines/toon/tools.h
@@ -36,12 +36,6 @@ const uint32 kCompSPCN = 0x5350434E;
const uint32 kCompRNC1 = 0x524E4301;
const uint32 kCompRNC2 = 0x524E4302;
-#define READ_LE_INT16(x) (int16) READ_LE_UINT16(x)
-#define READ_LE_INT32(x) (int32) READ_LE_UINT32(x)
-
-#define WRITE_LE_INT16(x, y) WRITE_LE_UINT16(x, (int16)y)
-#define WRITE_LE_INT32(x, y) WRITE_LE_UINT32(x, (int32)y)
-
uint32 decompressSPCN(byte *src, byte *dst, uint32 dstsize);
uint32 decompressLZSS(byte *src, byte *dst, int dstsize);