22 #ifndef ULTIMA8_MISC_STREAM_H 23 #define ULTIMA8_MISC_STREAM_H 25 #include "common/stream.h" 33 val |=
static_cast<uint32
>(rs.
readByte());
34 val |=
static_cast<uint32
>(rs.
readByte() << 8);
35 val |=
static_cast<uint32
>(rs.
readByte() << 16);
40 assert(num_bytes > 0 && num_bytes <= 4);
41 if (num_bytes == 1)
return rs.
readByte();
43 else if (num_bytes == 3)
return readUint24LE(rs);
48 assert(num_bytes > 0 && num_bytes <= 4);
49 if (num_bytes == 1)
return static_cast<int8
>(rs.
readByte());
50 else if (num_bytes == 2)
return static_cast<int16
>(rs.
readUint16LE());
51 else if (num_bytes == 3)
return (((static_cast<int32>(readUint24LE(rs))) << 8) >> 8);
56 ws.
writeByte(static_cast<byte>(val & 0xff));
57 ws.
writeByte(static_cast<byte>((val >> 8) & 0xff));
58 ws.
writeByte(static_cast<byte>((val >> 16) & 0xff));
62 assert(num_bytes > 0 && num_bytes <= 4);
63 if (num_bytes == 1) ws.
writeByte(static_cast<byte>(val));
64 else if (num_bytes == 2) ws.
writeUint16LE(static_cast<uint16>(val));
65 else if (num_bytes == 3) writeUint24LE(ws, val);
uint16 readUint16LE()
Definition: stream.h:459
void writeUint32LE(uint32 value)
Definition: stream.h:159
uint32 readUint32LE()
Definition: stream.h:473
Definition: detection.h:27
byte readByte()
Definition: stream.h:434
void writeUint16LE(uint16 value)
Definition: stream.h:152
void writeByte(byte value)
Definition: stream.h:140