diff options
author | Wohlstand <admin@wohlnet.ru> | 2017-10-08 17:10:04 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2017-10-08 17:10:04 +0300 |
commit | adfa9ae4cfd230baa33a57196c88e618c156c94c (patch) | |
tree | 7abe3b4a736155c15680f357bd1f4f0376039e4d /src/gen_adldata/file_formats/common.h | |
parent | 685e7b200a29fdf8cc9dc5149c5173bac25caa9b (diff) | |
download | libADLMIDI-adfa9ae4cfd230baa33a57196c88e618c156c94c.tar.gz libADLMIDI-adfa9ae4cfd230baa33a57196c88e618c156c94c.tar.bz2 libADLMIDI-adfa9ae4cfd230baa33a57196c88e618c156c94c.zip |
Add support for WOPL banks format
Diffstat (limited to 'src/gen_adldata/file_formats/common.h')
-rw-r--r-- | src/gen_adldata/file_formats/common.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gen_adldata/file_formats/common.h b/src/gen_adldata/file_formats/common.h new file mode 100644 index 0000000..d06059e --- /dev/null +++ b/src/gen_adldata/file_formats/common.h @@ -0,0 +1,28 @@ +#ifndef COMMON_H +#define COMMON_H + +#include <stdint.h> + +inline uint16_t toUint16BE(const uint8_t *arr) +{ + uint16_t num = arr[1]; + num |= ((arr[0] << 8) & 0xFF00); + return num; +} + +inline int16_t toSint16BE(const uint8_t *arr) +{ + int16_t num = *reinterpret_cast<const int8_t *>(&arr[0]); + num *= 1 << 8; + num |= arr[1]; + return num; +} + +inline uint16_t toUint16LE(const uint8_t *arr) +{ + uint16_t num = arr[0]; + num |= ((arr[1] << 8) & 0xFF00); + return num; +} + +#endif // COMMON_H |