1
/* Copyright (c) 2003-2005 Various contributors
3
* Permission is hereby granted, free of charge, to any person obtaining a copy
4
* of this software and associated documentation files (the "Software"), to
5
* deal in the Software without restriction, including without limitation the
6
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
* sell copies of the Software, and to permit persons to whom the Software is
8
* furnished to do so, subject to the following conditions:
10
* The above copyright notice and this permission notice shall be included in
11
* all copies or substantial portions of the Software.
13
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27
bool File::readBit16u(Bit16u *in) {
29
if (read(&b[0], 2) != 2)
31
*in = ((b[0] << 8) | b[1]);
35
bool File::readBit32u(Bit32u *in) {
37
if (read(&b[0], 4) != 4)
39
*in = ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
43
bool File::writeBit16u(Bit16u out) {
44
if (!writeBit8u((Bit8u)((out & 0xFF00) >> 8))) {
47
if (!writeBit8u((Bit8u)(out & 0x00FF))) {
53
bool File::writeBit32u(Bit32u out) {
54
if (!writeBit8u((Bit8u)((out & 0xFF000000) >> 24))) {
57
if (!writeBit8u((Bit8u)((out & 0x00FF0000) >> 16))) {
60
if (!writeBit8u((Bit8u)((out & 0x0000FF00) >> 8))) {
63
if (!writeBit8u((Bit8u)(out & 0x000000FF))) {
69
} // End of namespace MT32Emu