diff options
author | Max Horn | 2003-09-21 18:15:32 +0000 |
---|---|---|
committer | Max Horn | 2003-09-21 18:15:32 +0000 |
commit | 9abd9bb6b55b8843d46e8bd718b607d5fc58506c (patch) | |
tree | 7b67422edc81d16688b87d8d91609b71d367e23a /common | |
parent | 392651dc1bbb2f3f70b25814261884de2e5e7331 (diff) | |
download | scummvm-rg350-9abd9bb6b55b8843d46e8bd718b607d5fc58506c.tar.gz scummvm-rg350-9abd9bb6b55b8843d46e8bd718b607d5fc58506c.tar.bz2 scummvm-rg350-9abd9bb6b55b8843d46e8bd718b607d5fc58506c.zip |
added WRITE_LE/BE_16/32 functions to match our current READ_ funcs - useful in some places
svn-id: r10358
Diffstat (limited to 'common')
-rw-r--r-- | common/scummsys.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/common/scummsys.h b/common/scummsys.h index ff087b289b..0711c13a62 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -345,6 +345,18 @@ FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) { const byte *b = (const byte *)ptr; return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]); } + FORCEINLINE void WRITE_LE_UINT16(void *ptr, uint16 value) { + byte *b = (byte *)ptr; + b[0] = (byte)(value >> 0); + b[1] = (byte)(value >> 8); + } + FORCEINLINE void WRITE_LE_UINT32(void *ptr, uint32 value) { + byte *b = (byte *)ptr; + b[0] = (byte)(value >> 0); + b[1] = (byte)(value >> 8); + b[2] = (byte)(value >> 16); + b[3] = (byte)(value >> 24); + } #else FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) { return *(const uint16 *)(ptr); @@ -352,6 +364,12 @@ FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) { FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) { return *(const uint32 *)(ptr); } + FORCEINLINE void WRITE_LE_UINT16(void *ptr, uint16 value) { + *(uint16 *)(ptr) = value; + } + FORCEINLINE void WRITE_LE_UINT32(void *ptr, uint32 value) { + *(uint32 *)(ptr) = value; + } #endif @@ -364,6 +382,18 @@ FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) { const byte *b = (const byte*)ptr; return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]); } + FORCEINLINE void WRITE_BE_UINT16(void *ptr, uint16 value) { + byte *b = (byte *)ptr; + b[0] = (byte)(value >> 8); + b[1] = (byte)(value >> 0); + } + FORCEINLINE void WRITE_BE_UINT32(void *ptr, uint32 value) { + byte *b = (byte *)ptr; + b[0] = (byte)(value >> 24); + b[1] = (byte)(value >> 16); + b[2] = (byte)(value >> 8); + b[3] = (byte)(value >> 0); + } #else FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) { return *(const uint16 *)(ptr); @@ -371,6 +401,12 @@ FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) { FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) { return *(const uint32 *)(ptr); } + FORCEINLINE void WRITE_BE_UINT16(void *ptr, uint16 value) { + *(uint16 *)(ptr) = value; + } + FORCEINLINE void WRITE_BE_UINT32(void *ptr, uint32 value) { + *(uint32 *)(ptr) = value; + } #endif |