diff options
author | Roman Masanin <36927roma@gmail.com> | 2020-10-12 12:42:57 +0200 |
---|---|---|
committer | Roman Masanin <36927roma@gmail.com> | 2020-10-12 12:42:57 +0200 |
commit | 417646819c5d88bb7774bbb0341d92ada3293196 (patch) | |
tree | 4da51aa3be7f75002b16985207d9411d900dde7d /src/core/common.h | |
parent | mark file and fix screen offset (diff) | |
parent | Merge pull request #753 from majesticCoding/miami (diff) | |
download | re3-417646819c5d88bb7774bbb0341d92ada3293196.tar re3-417646819c5d88bb7774bbb0341d92ada3293196.tar.gz re3-417646819c5d88bb7774bbb0341d92ada3293196.tar.bz2 re3-417646819c5d88bb7774bbb0341d92ada3293196.tar.lz re3-417646819c5d88bb7774bbb0341d92ada3293196.tar.xz re3-417646819c5d88bb7774bbb0341d92ada3293196.tar.zst re3-417646819c5d88bb7774bbb0341d92ada3293196.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/common.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/core/common.h b/src/core/common.h index 16d32b32..0e6bd60f 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -106,7 +106,7 @@ typedef uint16_t wchar; inline uint32 dpb(uint32 b, uint32 p, uint32 s, uint32 w) { uint32 m = MASK(p,s); - return w & ~m | b<<p & m; + return (w & ~m) | ((b<<p) & m); } inline uint32 ldb(uint32 p, uint32 s, uint32 w) { @@ -412,6 +412,15 @@ inline void SkipSaveBuf(uint8 *&buf, int32 skip) #endif } +inline void SkipSaveBuf(uint8*& buf, uint32 &length, int32 skip) +{ + buf += skip; + length += skip; +#ifdef VALIDATE_SAVE_SIZE + _saveBufCount += skip; +#endif +} + template<typename T> inline const T ReadSaveBuf(uint8 *&buf) { @@ -421,6 +430,14 @@ inline const T ReadSaveBuf(uint8 *&buf) } template<typename T> +inline const T ReadSaveBuf(uint8 *&buf, uint32 &length) +{ + T &value = *(T*)buf; + SkipSaveBuf(buf, length, sizeof(T)); + return value; +} + +template<typename T> inline T *WriteSaveBuf(uint8 *&buf, const T &value) { T *p = (T*)buf; @@ -429,6 +446,15 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value) return p; } +template<typename T> +inline T *WriteSaveBuf(uint8 *&buf, uint32 &length, const T &value) +{ + T *p = (T*)buf; + *p = value; + SkipSaveBuf(buf, length, sizeof(T)); + return p; +} + #define SAVE_HEADER_SIZE (4*sizeof(char)+sizeof(uint32)) @@ -439,6 +465,13 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value) WriteSaveBuf(buf, d);\ WriteSaveBuf<uint32>(buf, size); +#define WriteSaveHeaderWithLength(buf,len,a,b,c,d,size) \ + WriteSaveBuf(buf, len, a);\ + WriteSaveBuf(buf, len, b);\ + WriteSaveBuf(buf, len, c);\ + WriteSaveBuf(buf, len, d);\ + WriteSaveBuf<uint32>(buf, len, size); + #define CheckSaveHeader(buf,a,b,c,d,size)\ assert(ReadSaveBuf<char>(buf) == a);\ assert(ReadSaveBuf<char>(buf) == b);\ @@ -446,5 +479,12 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value) assert(ReadSaveBuf<char>(buf) == d);\ assert(ReadSaveBuf<uint32>(buf) == size); +#define CheckSaveHeaderWithLength(buf,len,a,b,c,d,size)\ + assert(ReadSaveBuf<char>(buf,len) == a);\ + assert(ReadSaveBuf<char>(buf,len) == b);\ + assert(ReadSaveBuf<char>(buf,len) == c);\ + assert(ReadSaveBuf<char>(buf,len) == d);\ + assert(ReadSaveBuf<uint32>(buf,len) == size); + void cprintf(char*, ...);
\ No newline at end of file |