aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Cawley2019-03-01 00:10:08 +0000
committerBastien Bouclet2019-03-02 07:29:22 +0100
commit5d912b6923c231d8be15fcfa155f998ef55ef126 (patch)
treef866591485283df2009d702408327b4598825271
parentf14703e70964eb3247259110f3e4b18b97e1ff40 (diff)
downloadscummvm-rg350-5d912b6923c231d8be15fcfa155f998ef55ef126.tar.gz
scummvm-rg350-5d912b6923c231d8be15fcfa155f998ef55ef126.tar.bz2
scummvm-rg350-5d912b6923c231d8be15fcfa155f998ef55ef126.zip
COMMON: Add WRITE_UINT24
-rw-r--r--common/endian.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/endian.h b/common/endian.h
index a6b80f2451..fad9f3ccae 100644
--- a/common/endian.h
+++ b/common/endian.h
@@ -573,15 +573,31 @@ inline uint32 READ_LE_UINT24(const void *ptr) {
return (b[2] << 16) | (b[1] << 8) | (b[0]);
}
+inline void WRITE_LE_UINT24(void *ptr, uint32 value) {
+ uint8 *b = (uint8 *)ptr;
+ b[0] = (uint8)(value >> 0);
+ b[1] = (uint8)(value >> 8);
+ b[2] = (uint8)(value >> 16);
+}
+
inline uint32 READ_BE_UINT24(const void *ptr) {
const uint8 *b = (const uint8 *)ptr;
return (b[0] << 16) | (b[1] << 8) | (b[2]);
}
+inline void WRITE_BE_UINT24(void *ptr, uint32 value) {
+ uint8 *b = (uint8 *)ptr;
+ b[0] = (uint8)(value >> 16);
+ b[1] = (uint8)(value >> 8);
+ b[2] = (uint8)(value >> 0);
+}
+
#ifdef SCUMM_LITTLE_ENDIAN
#define READ_UINT24(a) READ_LE_UINT24(a)
+#define WRITE_UINT24(a,b) WRITE_LE_UINT24(a,b)
#else
#define READ_UINT24(a) READ_BE_UINT24(a)
+#define WRITE_UINT24(a,b) WRITE_BE_UINT24(a,b)
#endif
inline int16 READ_LE_INT16(const void *ptr) {