mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-02 23:26:44 +00:00
STREAM: add read/write functions for float LE/BE
This commit is contained in:
parent
d37888ad5f
commit
8f2a177cef
@ -185,6 +185,32 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Write the given 32-bit floating point value stored
|
||||
* in little endian(LSB first) order into the stream.
|
||||
*/
|
||||
FORCEINLINE void writeFloatLE(float value) {
|
||||
uint32 n;
|
||||
|
||||
memcpy(&n, &value, 4);
|
||||
|
||||
writeUint32LE(n);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write the given 32-bit floating point value stored
|
||||
* in big endian order into the stream.
|
||||
*/
|
||||
FORCEINLINE void writeFloatBE(float value) {
|
||||
uint32 n;
|
||||
|
||||
memcpy(&n, &value, 4);
|
||||
|
||||
writeUint32BE(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the given string to the stream.
|
||||
* This writes str.size() characters, but no terminating zero byte.
|
||||
@ -417,6 +443,22 @@ public:
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a 32-bit floating point value stored in big endian
|
||||
* order from the stream and return it.
|
||||
* Performs no error checking. The return value is undefined
|
||||
* if a read error occurred (for which client code can check by
|
||||
* calling err() and eos() ).
|
||||
*/
|
||||
FORCEINLINE float readFloatBE() {
|
||||
uint32 n = readUint32BE();
|
||||
float f;
|
||||
|
||||
memcpy(&f, &n, 4);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the specified amount of data into a malloc'ed buffer
|
||||
* which then is wrapped into a MemoryReadStream.
|
||||
|
Loading…
Reference in New Issue
Block a user