aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/smush/chunk.cpp38
-rw-r--r--scumm/smush/codec1.cpp8
-rw-r--r--scumm/smush/codec37.cpp42
-rw-r--r--scumm/smush/codec47.cpp24
-rw-r--r--scumm/smush/imuse_channel.cpp94
-rw-r--r--scumm/smush/saud_channel.cpp70
-rw-r--r--scumm/smush/smush_font.cpp178
-rw-r--r--scumm/smush/smush_mixer.cpp46
-rw-r--r--scumm/smush/smush_player.cpp102
9 files changed, 296 insertions, 306 deletions
diff --git a/scumm/smush/chunk.cpp b/scumm/smush/chunk.cpp
index 79abc223b0..70e8a909aa 100644
--- a/scumm/smush/chunk.cpp
+++ b/scumm/smush/chunk.cpp
@@ -38,7 +38,7 @@ public:
_curPos(0) {
debug(9, "FilePtr created for %s", fname);
_ifs.open(fname, directory);
- if(_ifs.isOpen() == false) error("FilePtr unable to read file %s", fname);
+ if (_ifs.isOpen() == false) error("FilePtr unable to read file %s", fname);
}
~FilePtr() {
@@ -51,7 +51,7 @@ public:
}
bool seek(int32 pos) {
- if(pos != _curPos) {
+ if (pos != _curPos) {
_ifs.seek(pos, SEEK_SET);
_curPos = pos;
}
@@ -69,7 +69,7 @@ public:
}
void decRef() {
- if(--_refcount == 0)
+ if (--_refcount == 0)
delete this;
}
};
@@ -112,19 +112,19 @@ bool BaseChunk::seek(int32 delta, seek_type dir) {
_curPos += delta;
break;
case seek_start:
- if(delta < 0)
+ if (delta < 0)
error("invalid seek request");
_curPos = (uint32)delta;
break;
case seek_end:
- if(delta > 0 || _size < (uint32)-delta)
+ if (delta > 0 || _size < (uint32)-delta)
error("invalid seek request");
_curPos = (uint32)(_size + delta);
break;
}
- if(_curPos > _size) {
+ if (_curPos > _size) {
error("invalid seek request : %d > %d (delta == %d)", _curPos, _size, delta);
}
return true;
@@ -145,7 +145,7 @@ FileChunk::FileChunk(const char *fname, const char *directory) {
}
FileChunk::~FileChunk() {
- if(_data)
+ if (_data)
_data->decRef();
}
@@ -166,7 +166,7 @@ Chunk *FileChunk::subBlock() {
}
bool FileChunk::read(void *buffer, uint32 size) {
- if(size <= 0 || (_curPos + size) > _size)
+ if (size <= 0 || (_curPos + size) > _size)
error("invalid buffer read request");
_data->seek(_offset + _curPos);
@@ -176,7 +176,7 @@ bool FileChunk::read(void *buffer, uint32 size) {
}
int8 FileChunk::getChar() {
- if(_curPos >= _size)
+ if (_curPos >= _size)
error("invalid char read request");
_data->seek(_offset + _curPos);
@@ -187,7 +187,7 @@ int8 FileChunk::getChar() {
}
byte FileChunk::getByte() {
- if(_curPos >= _size)
+ if (_curPos >= _size)
error("invalid byte read request");
_data->seek(_offset + _curPos);
@@ -203,7 +203,7 @@ int16 FileChunk::getShort() {
}
uint16 FileChunk::getWord() {
- if(_curPos >= _size - 1)
+ if (_curPos >= _size - 1)
error("invalid word read request");
_data->seek(_offset + _curPos);
@@ -214,7 +214,7 @@ uint16 FileChunk::getWord() {
}
uint32 FileChunk::getDword() {
- if(_curPos >= _size - 3)
+ if (_curPos >= _size - 3)
error("invalid dword read request");
_data->seek(_offset + _curPos);
@@ -225,7 +225,7 @@ uint32 FileChunk::getDword() {
}
MemoryChunk::MemoryChunk(byte *data) {
- if(data == 0)
+ if (data == 0)
error("Chunk() called with NULL pointer");
_type = (Chunk::type)READ_BE_UINT32(data);
@@ -241,7 +241,7 @@ Chunk *MemoryChunk::subBlock() {
}
bool MemoryChunk::read(void *buffer, uint32 size) {
- if(size <= 0 || (_curPos + size) > _size)
+ if (size <= 0 || (_curPos + size) > _size)
error("invalid buffer read request");
memcpy(buffer, _data + _curPos, size);
@@ -250,14 +250,14 @@ bool MemoryChunk::read(void *buffer, uint32 size) {
}
int8 MemoryChunk::getChar() {
- if(_curPos >= _size)
+ if (_curPos >= _size)
error("invalid char read request");
return _data[_curPos++];
}
byte MemoryChunk::getByte() {
- if(_curPos >= _size)
+ if (_curPos >= _size)
error("invalid byte read request");
byte *ptr = (byte *)(_data + _curPos);
@@ -266,7 +266,7 @@ byte MemoryChunk::getByte() {
}
int16 MemoryChunk::getShort() {
- if(_curPos >= _size - 1)
+ if (_curPos >= _size - 1)
error("invalid int16 read request");
int16 buffer = getWord();
@@ -274,7 +274,7 @@ int16 MemoryChunk::getShort() {
}
uint16 MemoryChunk::getWord() {
- if(_curPos >= _size - 1)
+ if (_curPos >= _size - 1)
error("invalid word read request");
uint16 *ptr = (uint16 *)(_data + _curPos);
@@ -283,7 +283,7 @@ uint16 MemoryChunk::getWord() {
}
uint32 MemoryChunk::getDword() {
- if(_curPos >= _size - 3)
+ if (_curPos >= _size - 3)
error("invalid dword read request");
uint32 *ptr = (uint32 *)(_data + _curPos);
diff --git a/scumm/smush/codec1.cpp b/scumm/smush/codec1.cpp
index 8269d85950..5df800b43b 100644
--- a/scumm/smush/codec1.cpp
+++ b/scumm/smush/codec1.cpp
@@ -27,14 +27,14 @@ void smush_decode_codec1(byte *dst, byte *src, int height) {
int32 length;
int h = height, size_line;
- for(h = 0; h < height; h++) {
+ for (h = 0; h < height; h++) {
size_line = READ_LE_UINT16(src);
src += 2;
- while(size_line > 0) {
+ while (size_line > 0) {
code = *src++;
size_line--;
length = (code >> 1) + 1;
- if(code & 1) {
+ if (code & 1) {
val = *src++;
size_line--;
if (val)
@@ -42,7 +42,7 @@ void smush_decode_codec1(byte *dst, byte *src, int height) {
dst += length;
} else {
size_line -= length;
- while(length--) {
+ while (length--) {
val = *src++;
if (val)
*dst = val;
diff --git a/scumm/smush/codec37.cpp b/scumm/smush/codec37.cpp
index 8ae00fa957..64154747ad 100644
--- a/scumm/smush/codec37.cpp
+++ b/scumm/smush/codec37.cpp
@@ -32,13 +32,13 @@ void Codec37Decoder::init(int width, int height) {
_frameSize = _width * _height;
_deltaSize = _frameSize * 3 + 0x13600;
_deltaBuf = (byte *)calloc(_deltaSize, sizeof(byte));
- if(_deltaBuf == 0)
+ if (_deltaBuf == 0)
error("unable to allocate decoder buffer");
_deltaBufs[0] = _deltaBuf + 0x4D80;
_deltaBufs[1] = _deltaBuf + 0xE880 + _frameSize;
_offsetTable = new int16[255];
_curtable = 0;
- if(_offsetTable == 0)
+ if (_offsetTable == 0)
error("unable to allocate decoder offset table");
_tableLastPitch = -1;
_tableLastIndex = -1;
@@ -57,13 +57,13 @@ Codec37Decoder::Codec37Decoder() {
}
void Codec37Decoder::deinit() {
- if(_offsetTable) {
+ if (_offsetTable) {
delete []_offsetTable;
_offsetTable = 0;
_tableLastPitch = -1;
_tableLastIndex = -1;
}
- if(_deltaBuf) {
+ if (_deltaBuf) {
free(_deltaBuf);
_deltaSize = 0;
_deltaBuf = 0;
@@ -258,16 +258,16 @@ void Codec37Decoder::maketable(int pitch, int index) {
#define WRITE_4X1_LINE(dst, v) \
do { \
int j; \
- for(j=0; j<4; j++) \
+ for (j=0; j<4; j++) \
(dst)[j] = v; \
- } while(0)
+ } while (0)
#define COPY_4X1_LINE(dst, src) \
do { \
int j; \
- for(j=0; j<4; j++) \
+ for (j=0; j<4; j++) \
(dst)[j] = (src)[j]; \
- } while(0)
+ } while (0)
#else /* SCUMM_NEED_ALIGNMENT */
@@ -278,7 +278,7 @@ void Codec37Decoder::maketable(int pitch, int index) {
do { \
v = *src++; \
v += (v << 8) + (v << 16) + (v << 24); \
- } while(0)
+ } while (0)
#define WRITE_4X1_LINE(dst, v) \
*(uint32 *)(dst) = v
@@ -295,11 +295,11 @@ void Codec37Decoder::maketable(int pitch, int index) {
int x; \
DECLARE_LITERAL_TEMP(t); \
READ_LITERAL_PIXEL(src, t); \
- for(x=0; x<4; x++) { \
+ for (x=0; x<4; x++) { \
WRITE_4X1_LINE(dst + pitch * x, t); \
} \
dst += 4; \
- } while(0)
+ } while (0)
/* Fill four 4x1 pixel blocks with literal pixel values */
@@ -307,35 +307,35 @@ void Codec37Decoder::maketable(int pitch, int index) {
do { \
int x; \
DECLARE_LITERAL_TEMP(t); \
- for(x=0; x<4; x++) { \
+ for (x=0; x<4; x++) { \
READ_LITERAL_PIXEL(src, t); \
WRITE_4X1_LINE(dst + pitch * x, t); \
} \
dst += 4; \
- } while(0)
+ } while (0)
/* Fill sixteen 1x1 pixel blocks with literal pixel values */
#define LITERAL_1X1(src, dst, pitch) \
do { \
int x; \
- for(x=0; x<4; x++) { \
+ for (x=0; x<4; x++) { \
COPY_4X1_LINE(dst + pitch * x, src); \
src += 4; \
} \
dst += 4; \
- } while(0)
+ } while (0)
/* Copy a 4x4 pixel block from a different place in the framebuffer */
#define COPY_4X4(dst2, dst, pitch) \
do { \
int x; \
- for(x=0; x<4; x++) { \
+ for (x=0; x<4; x++) { \
COPY_4X1_LINE(dst + pitch * x, dst2 + pitch * x); \
} \
dst += 4; \
- } while(0)
+ } while (0)
void Codec37Decoder::proc3WithFDFE(byte *dst, const byte *src, int32 next_offs, int bw, int bh, int pitch, int16 *offset_table) {
do {
@@ -396,7 +396,7 @@ void Codec37Decoder::proc4WithFDFE(byte *dst, const byte *src, int32 next_offs,
i = bw;
}
}
- if(bh == 0) {
+ if (bh == 0) {
return;
}
i++;
@@ -428,7 +428,7 @@ void Codec37Decoder::proc4WithoutFDFE(byte *dst, const byte *src, int32 next_off
i = bw;
}
}
- if(bh == 0) {
+ if (bh == 0) {
return;
}
i++;
@@ -480,7 +480,7 @@ void Codec37Decoder::decode(byte *dst, const byte *src) {
_curtable ^= 1;
}
- if((mask_flags & 4) != 0) {
+ if ((mask_flags & 4) != 0) {
proc3WithFDFE(_deltaBufs[_curtable], src + 16,
_deltaBufs[_curtable ^ 1] - _deltaBufs[_curtable], bw, bh,
pitch, _offsetTable);
@@ -495,7 +495,7 @@ void Codec37Decoder::decode(byte *dst, const byte *src) {
_curtable ^= 1;
}
- if((mask_flags & 4) != 0) {
+ if ((mask_flags & 4) != 0) {
proc4WithFDFE(_deltaBufs[_curtable], src + 16,
_deltaBufs[_curtable ^ 1] - _deltaBufs[_curtable], bw, bh,
pitch, _offsetTable);
diff --git a/scumm/smush/codec47.cpp b/scumm/smush/codec47.cpp
index f2a074402d..5519dca5a1 100644
--- a/scumm/smush/codec47.cpp
+++ b/scumm/smush/codec47.cpp
@@ -33,13 +33,13 @@
(dst)[1] = (src)[1]; \
(dst)[2] = (src)[2]; \
(dst)[3] = (src)[3]; \
- } while(0)
+ } while (0)
#define COPY_2X1_LINE(dst, src) \
do { \
(dst)[0] = (src)[0]; \
(dst)[1] = (src)[1]; \
- } while(0)
+ } while (0)
#else /* SCUMM_NEED_ALIGNMENT */
@@ -58,13 +58,13 @@
(dst)[1] = val; \
(dst)[2] = val; \
(dst)[3] = val; \
- } while(0)
+ } while (0)
#define FILL_2X1_LINE(dst, val) \
do { \
(dst)[0] = val; \
(dst)[1] = val; \
- } while(0)
+ } while (0)
#ifdef __PALM_OS__
static int32 *codec37_table;
@@ -311,7 +311,7 @@ void Codec47Decoder::makeTables37(int32 param) {
for (x = 0; x < 16; x++) {
value_table37_1_1 = table37_1[x];
value_table37_2_1 = table37_2[x];
- for(y = 0; y < 16; y++) {
+ for (y = 0; y < 16; y++) {
value_table37_1_2 = table37_1[y];
value_table37_2_2 = table37_2[y];
@@ -382,7 +382,7 @@ void Codec47Decoder::makeTables37(int32 param) {
} else if ((b1 == 2 && b2 != 3) || (b2 == 2 && b1 != 3)) {
if (variable4 >= 0) {
i = variable4 + 1;
- while(i--) {
+ while (i--) {
*(ptr_small_big--) = 1;
}
}
@@ -390,7 +390,7 @@ void Codec47Decoder::makeTables37(int32 param) {
(b1 == 3 && b2 != 2) || (b2 == 3 && b1 != 2)) {
if (param > variable4) {
i = param - variable4;
- while(i--) {
+ while (i--) {
*(ptr_small_big++) = 1;
}
}
@@ -532,14 +532,14 @@ void Codec47Decoder::level2(byte *d_dst) {
int32 l = tmp_ptr[96];
byte val = *_d_src++;
int16 *tmp_ptr2 = (int16 *)tmp_ptr;
- while(l--) {
+ while (l--) {
*(d_dst + READ_LE_UINT16(tmp_ptr2)) = val;
tmp_ptr2++;
}
l = tmp_ptr[97];
val = *_d_src++;
tmp_ptr2 = (int16 *)(tmp_ptr + 32);
- while(l--) {
+ while (l--) {
*(d_dst + READ_LE_UINT16(tmp_ptr2)) = val;
tmp_ptr2++;
}
@@ -593,14 +593,14 @@ void Codec47Decoder::level1(byte *d_dst) {
byte l = tmp_ptr[384];
byte val = *_d_src++;
int16 *tmp_ptr2 = (int16 *)tmp_ptr;
- while(l--) {
+ while (l--) {
*(d_dst + READ_LE_UINT16(tmp_ptr2)) = val;
tmp_ptr2++;
}
l = tmp_ptr[385];
val = *_d_src++;
tmp_ptr2 = (int16 *)(tmp_ptr + 128);
- while(l--) {
+ while (l--) {
*(d_dst + READ_LE_UINT16(tmp_ptr2)) = val;
tmp_ptr2++;
}
@@ -664,7 +664,7 @@ Codec47Decoder::Codec47Decoder() {
void Codec47Decoder::deinit() {
_lastTableWidth = -1;
- if(_deltaBuf) {
+ if (_deltaBuf) {
delete []_deltaBuf;
_deltaSize = 0;
_deltaBuf = 0;
diff --git a/scumm/smush/imuse_channel.cpp b/scumm/smush/imuse_channel.cpp
index 113d6257c1..617932e75c 100644
--- a/scumm/smush/imuse_channel.cpp
+++ b/scumm/smush/imuse_channel.cpp
@@ -36,10 +36,10 @@ ImuseChannel::ImuseChannel(int32 track, int32 freq) :
}
ImuseChannel::~ImuseChannel() {
- if(_tbuffer) {
+ if (_tbuffer) {
delete []_tbuffer;
}
- if(_sbuffer) {
+ if (_sbuffer) {
warning("_sbuffer should be 0 !!!");
delete []_sbuffer;
}
@@ -70,26 +70,26 @@ bool ImuseChannel::checkParameters(int32 index, int32 nbframes, int32 size, int3
}
bool ImuseChannel::appendData(Chunk &b, int32 size) {
- if(_dataSize == -1) {
+ if (_dataSize == -1) {
assert(size > 8);
Chunk::type imus_type = b.getDword(); imus_type = SWAP_BYTES(imus_type);
uint32 imus_size = b.getDword(); imus_size = SWAP_BYTES(imus_size);
- if(imus_type != TYPE_iMUS)
+ if (imus_type != TYPE_iMUS)
error("Invalid Chunk for imuse_channel");
size -= 8;
_tbufferSize = size;
assert(_tbufferSize);
_tbuffer = new byte[_tbufferSize];
- if(!_tbuffer)
+ if (!_tbuffer)
error("imuse_channel failed to allocate memory");
b.read(_tbuffer, size);
_dataSize = -2;
} else {
- if(_tbuffer) {
+ if (_tbuffer) {
byte *old = _tbuffer;
int32 new_size = size + _tbufferSize;
_tbuffer = new byte[new_size];
- if(!_tbuffer)
+ if (!_tbuffer)
error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, old, _tbufferSize);
delete []old;
@@ -98,7 +98,7 @@ bool ImuseChannel::appendData(Chunk &b, int32 size) {
} else {
_tbufferSize = size;
_tbuffer = new byte[_tbufferSize];
- if(!_tbuffer)
+ if (!_tbuffer)
error("imuse_channel failed to allocate memory");
b.read(_tbuffer, size);
}
@@ -107,7 +107,7 @@ bool ImuseChannel::appendData(Chunk &b, int32 size) {
}
bool ImuseChannel::handleFormat(Chunk &src) {
- if(src.getSize() != 20) error("invalid size for FRMT Chunk");
+ if (src.getSize() != 20) error("invalid size for FRMT Chunk");
uint32 imuse_start = src.getDword();
imuse_start = SWAP_BYTES(imuse_start);
src.seek(4);
@@ -126,19 +126,19 @@ bool ImuseChannel::handleText(Chunk &src) {
}
bool ImuseChannel::handleRegion(Chunk &src) {
- if(src.getSize() != 8)
+ if (src.getSize() != 8)
error("invalid size for REGN Chunk");
return true;
}
bool ImuseChannel::handleStop(Chunk &src) {
- if(src.getSize() != 4)
+ if (src.getSize() != 4)
error("invalid size for STOP Chunk");
return true;
}
bool ImuseChannel::handleMap(Chunk &map) {
- while(!map.eof()) {
+ while (!map.eof()) {
Chunk *sub = map.subBlock();
switch(sub->getType()) {
case TYPE_FRMT:
@@ -163,10 +163,10 @@ bool ImuseChannel::handleMap(Chunk &map) {
void ImuseChannel::decode() {
int remaining_size = _sbufferSize % 3;
- if(remaining_size) {
+ if (remaining_size) {
_srbufferSize -= remaining_size;
assert(_inData);
- if(_tbuffer == 0) {
+ if (_tbuffer == 0) {
_tbuffer = new byte[remaining_size];
memcpy(_tbuffer, _sbuffer + _sbufferSize - remaining_size, remaining_size);
_tbufferSize = remaining_size;
@@ -177,7 +177,7 @@ void ImuseChannel::decode() {
byte *old = _tbuffer;
int new_size = remaining_size + _tbufferSize;
_tbuffer = new byte[new_size];
- if(!_tbuffer) error("imuse_channel failed to allocate memory");
+ if (!_tbuffer) error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, old, _tbufferSize);
delete []old;
memcpy(_tbuffer + _tbufferSize, _sbuffer + _sbufferSize - remaining_size, remaining_size);
@@ -191,7 +191,7 @@ void ImuseChannel::decode() {
keep = decoded = new byte[new_size * 2];
assert(keep);
unsigned char * source = _sbuffer;
- while(loop_size--) {
+ while (loop_size--) {
byte v1 = *source++;
byte v2 = *source++;
byte v3 = *source++;
@@ -208,14 +208,14 @@ void ImuseChannel::decode() {
}
bool ImuseChannel::handleSubTags(int32 &offset) {
- if(_tbufferSize - offset >= 8) {
+ if (_tbufferSize - offset >= 8) {
Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
uint32 size = READ_BE_UINT32(_tbuffer + offset + 4);
uint32 available_size = _tbufferSize - offset;
switch(type) {
case TYPE_MAP_:
_inData = false;
- if(available_size >= (size + 8)) {
+ if (available_size >= (size + 8)) {
MemoryChunk c((byte *)_tbuffer + offset);
handleMap(c);
}
@@ -226,16 +226,16 @@ bool ImuseChannel::handleSubTags(int32 &offset) {
offset += 8;
{
int reqsize = 1;
- if(_channels == 2)
+ if (_channels == 2)
reqsize *= 2;
- if(_bitsize == 16)
+ if (_bitsize == 16)
reqsize *= 2;
- else if(_bitsize == 12) {
- if(reqsize > 1)
+ else if (_bitsize == 12) {
+ if (reqsize > 1)
reqsize = reqsize * 3 / 2;
else reqsize = 3;
}
- if((size % reqsize) != 0) {
+ if ((size % reqsize) != 0) {
debug(2, "Invalid iMUS sound data size : (%d %% %d) != 0, correcting...", size, reqsize);
size += 3 - (size % reqsize);
}
@@ -256,23 +256,23 @@ bool ImuseChannel::processBuffer() {
assert(_sbuffer == 0);
assert(_sbufferSize == 0);
- if(_inData) {
- if(_dataSize < _tbufferSize) {
+ if (_inData) {
+ if (_dataSize < _tbufferSize) {
int32 offset= _dataSize;
- while(handleSubTags(offset));
+ while (handleSubTags(offset));
_sbufferSize = _dataSize;
_sbuffer = _tbuffer;
- if(offset < _tbufferSize) {
+ if (offset < _tbufferSize) {
int32 new_size = _tbufferSize - offset;
_tbuffer = new byte[new_size];
- if(!_tbuffer) error("imuse_channel failed to allocate memory");
+ if (!_tbuffer) error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, _sbuffer + offset, new_size);
_tbufferSize = new_size;
} else {
_tbuffer = 0;
_tbufferSize = 0;
}
- if(_sbufferSize == 0) {
+ if (_sbufferSize == 0) {
delete []_sbuffer;
_sbuffer = 0;
}
@@ -284,22 +284,22 @@ bool ImuseChannel::processBuffer() {
}
} else {
int32 offset = 0;
- while(handleSubTags(offset));
- if(_inData) {
+ while (handleSubTags(offset));
+ if (_inData) {
_sbufferSize = _tbufferSize - offset;
assert(_sbufferSize);
_sbuffer = new byte[_sbufferSize];
- if(!_sbuffer) error("imuse_channel failed to allocate memory");
+ if (!_sbuffer) error("imuse_channel failed to allocate memory");
memcpy(_sbuffer, _tbuffer + offset, _sbufferSize);
delete []_tbuffer;
_tbuffer = 0;
_tbufferSize = 0;
} else {
- if(offset) {
+ if (offset) {
byte * old = _tbuffer;
int32 new_size = _tbufferSize - offset;
_tbuffer = new byte[new_size];
- if(!_tbuffer) error("imuse_channel failed to allocate memory");
+ if (!_tbuffer) error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, old + offset, new_size);
_tbufferSize = new_size;
delete []old;
@@ -307,23 +307,23 @@ bool ImuseChannel::processBuffer() {
}
}
_srbufferSize = _sbufferSize;
- if(_sbuffer && _bitsize == 12) decode();
+ if (_sbuffer && _bitsize == 12) decode();
return true;
}
int32 ImuseChannel::availableSoundData(void) const {
int32 ret = _sbufferSize;
- if(_channels == 2) ret /= 2;
- if(_bitsize > 8) ret /= 2;
+ if (_channels == 2) ret /= 2;
+ if (_bitsize > 8) ret /= 2;
return ret;
}
void ImuseChannel::getSoundData(int16 *snd, int32 size) {
- if(_dataSize <= 0 || _bitsize <= 8) error("invalid call to imuse_channel::read_sound_data()");
- if(_channels == 2) size *= 2;
+ if (_dataSize <= 0 || _bitsize <= 8) error("invalid call to imuse_channel::read_sound_data()");
+ if (_channels == 2) size *= 2;
byte * buf = (byte*)snd;
- if(_rate == 11025) {
- for(int32 i = 0; i < size; i++) {
+ if (_rate == 11025) {
+ for (int32 i = 0; i < size; i++) {
byte sample1 = *(_sbuffer + i * 2);
byte sample2 = *(_sbuffer + i * 2 + 1);
uint16 sample = (uint16)(((int16)((sample1 << 8) | sample2) * _volume) >> 8);
@@ -333,7 +333,7 @@ void ImuseChannel::getSoundData(int16 *snd, int32 size) {
buf[i * 4 + 3] = buf[i * 4 + 1];
}
} else {
- for(int32 i = 0; i < size; i++){
+ for (int32 i = 0; i < size; i++){
byte sample1 = *(_sbuffer + i * 2);
byte sample2 = *(_sbuffer + i * 2 + 1);
uint16 sample = (uint16)(((int16)((sample1 << 8) | sample2) * _volume) >> 8);
@@ -349,15 +349,15 @@ void ImuseChannel::getSoundData(int16 *snd, int32 size) {
}
void ImuseChannel::getSoundData(int8 *snd, int32 size) {
- if(_dataSize <= 0 || _bitsize > 8) error("invalid call to imuse_channel::read_sound_data()");
- if(_channels == 2) size *= 2;
- if(_rate == 11025) {
- for(int32 i = 0; i < size; i++) {
+ if (_dataSize <= 0 || _bitsize > 8) error("invalid call to imuse_channel::read_sound_data()");
+ if (_channels == 2) size *= 2;
+ if (_rate == 11025) {
+ for (int32 i = 0; i < size; i++) {
snd[i * 2] = (int8)(((int8)(_sbuffer[i] ^ 0x80) * _volume) >> 8) ^ 0x80;
snd[i * 2 + 1] = snd[i * 2];
}
} else {
- for(int32 i = 0; i < size; i++){
+ for (int32 i = 0; i < size; i++){
snd[i] = (int8)(((int8)(_sbuffer[i] ^ 0x80) * _volume) >> 8) ^ 0x80;
}
}
diff --git a/scumm/smush/saud_channel.cpp b/scumm/smush/saud_channel.cpp
index 994aac64aa..b5d5b25ded 100644
--- a/scumm/smush/saud_channel.cpp
+++ b/scumm/smush/saud_channel.cpp
@@ -27,7 +27,7 @@
void SaudChannel::handleStrk(Chunk &b) {
int32 size = b.getSize();
- if(size != 14 && size != 10) {
+ if (size != 14 && size != 10) {
error("STRK has a invalid size : %d", size);
}
}
@@ -38,12 +38,12 @@ void SaudChannel::handleSmrk(Chunk &b) {
void SaudChannel::handleShdr(Chunk &b) {
int32 size = b.getSize();
- if(size != 4)
+ if (size != 4)
warning("SMRK has a invalid size : %d", size);
}
bool SaudChannel::handleSubTags(int32 &offset) {
- if(_tbufferSize - offset >= 8) {
+ if (_tbufferSize - offset >= 8) {
Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
uint32 size = READ_BE_UINT32(_tbuffer + offset + 4);
uint32 available_size = _tbufferSize - offset;
@@ -51,7 +51,7 @@ bool SaudChannel::handleSubTags(int32 &offset) {
switch(type) {
case TYPE_STRK:
_inData = false;
- if(available_size >= (size + 8)) {
+ if (available_size >= (size + 8)) {
MemoryChunk c((byte *)_tbuffer + offset);
handleStrk(c);
}
@@ -60,7 +60,7 @@ bool SaudChannel::handleSubTags(int32 &offset) {
break;
case TYPE_SMRK:
_inData = false;
- if(available_size >= (size + 8)) {
+ if (available_size >= (size + 8)) {
MemoryChunk c((byte *)_tbuffer + offset);
handleSmrk(c);
}
@@ -69,7 +69,7 @@ bool SaudChannel::handleSubTags(int32 &offset) {
break;
case TYPE_SHDR:
_inData = false;
- if(available_size >= (size + 8)) {
+ if (available_size >= (size + 8)) {
MemoryChunk c((byte *)_tbuffer + offset);
handleShdr(c);
}
@@ -96,23 +96,23 @@ bool SaudChannel::processBuffer() {
assert(_sbuffer == 0);
assert(_sbufferSize == 0);
- if(_inData) {
- if(_dataSize < _tbufferSize) {
+ if (_inData) {
+ if (_dataSize < _tbufferSize) {
int32 offset = _dataSize;
- while(handleSubTags(offset));
+ while (handleSubTags(offset));
_sbufferSize = _dataSize;
_sbuffer = _tbuffer;
- if(offset < _tbufferSize) {
+ if (offset < _tbufferSize) {
int new_size = _tbufferSize - offset;
_tbuffer = new byte[new_size];
- if(!_tbuffer) error("SaudChannel failed to allocate memory");
+ if (!_tbuffer) error("SaudChannel failed to allocate memory");
memcpy(_tbuffer, _sbuffer + offset, new_size);
_tbufferSize = new_size;
} else {
_tbuffer = 0;
_tbufferSize = 0;
}
- if(_sbufferSize == 0) {
+ if (_sbufferSize == 0) {
delete []_sbuffer;
_sbuffer = 0;
}
@@ -124,23 +124,23 @@ bool SaudChannel::processBuffer() {
}
} else {
int32 offset = 0;
- while(handleSubTags(offset));
- if(_inData) {
+ while (handleSubTags(offset));
+ if (_inData) {
_sbufferSize = _tbufferSize - offset;
assert(_sbufferSize);
_sbuffer = new byte[_sbufferSize];
- if(!_sbuffer)
+ if (!_sbuffer)
error("saud_channel failed to allocate memory");
memcpy(_sbuffer, _tbuffer + offset, _sbufferSize);
delete []_tbuffer;
_tbuffer = 0;
_tbufferSize = 0;
} else {
- if(offset) {
+ if (offset) {
byte *old = _tbuffer;
int32 new_size = _tbufferSize - offset;
_tbuffer = new byte[new_size];
- if(!_tbuffer)
+ if (!_tbuffer)
error("SaudChannel failed to allocate memory");
memcpy(_tbuffer, old + offset, new_size);
_tbufferSize = new_size;
@@ -166,8 +166,8 @@ SaudChannel::SaudChannel(int32 track, int32 freq) :
}
SaudChannel::~SaudChannel() {
- if(_tbuffer) delete []_tbuffer;
- if(_sbuffer) {
+ if (_tbuffer) delete []_tbuffer;
+ if (_sbuffer) {
warning("this should never happen !!!! (_sbuffer not NULL here)");
delete []_sbuffer;
}
@@ -180,7 +180,7 @@ bool SaudChannel::isTerminated() const {
void SaudChannel::recalcVolumeTable() {
const int32 MAX_BALANCE = 100;
int32 volume_left, volume_right;
- if(_balance < -MAX_BALANCE || _balance > MAX_BALANCE) {
+ if (_balance < -MAX_BALANCE || _balance > MAX_BALANCE) {
warning("balance is out of range ! : %d", _balance);
return;
}
@@ -188,15 +188,15 @@ void SaudChannel::recalcVolumeTable() {
int32 right_multiplier = MAX_BALANCE + _balance;
volume_left = _volume * left_multiplier / (MAX_BALANCE * 2);
volume_right = _volume * right_multiplier / (MAX_BALANCE * 2);
- if(volume_left < 0)
+ if (volume_left < 0)
volume_left = 0;
- if(volume_left > 128)
+ if (volume_left > 128)
volume_left = 128;
- if(volume_right < 0)
+ if (volume_right < 0)
volume_right = 0;
- if(volume_right > 128)
+ if (volume_right > 128)
volume_right = 128;
- for(int32 i = 0; i < 256; i++) {
+ for (int32 i = 0; i < 256; i++) {
int16 value = volume_left * (int8)i;
_voltable[0][i] = TO_BE_16(value);
value = volume_right * (int8)i;
@@ -215,13 +215,13 @@ bool SaudChannel::setParameters(int32 nb, int32 flags, int32 volume, int32 balan
}
bool SaudChannel::checkParameters(int32 index, int32 nb, int32 flags, int32 volume, int32 balance) {
- if(++_index != index)
+ if (++_index != index)
error("invalid index in SaudChannel::checkParameters()");
- if(_nbframes != nb)
+ if (_nbframes != nb)
error("invalid duration in SaudChannel::checkParameters()");
- if(_flags != flags)
+ if (_flags != flags)
error("invalid flags in SaudChannel::checkParameters()");
- if(_volume != volume || _balance != balance) {
+ if (_volume != volume || _balance != balance) {
_volume = volume;
_balance = balance;
recalcVolumeTable();
@@ -230,18 +230,18 @@ bool SaudChannel::checkParameters(int32 index, int32 nb, int32 flags, int32 volu
}
bool SaudChannel::appendData(Chunk &b, int32 size) {
- if(_dataSize == -1) {
+ if (_dataSize == -1) {
assert(size > 8);
Chunk::type saud_type = b.getDword(); saud_type = SWAP_BYTES(saud_type);
uint32 saud_size = b.getDword(); saud_size = SWAP_BYTES(saud_size);
- if(saud_type != TYPE_SAUD) error("Invalid Chunk for SaudChannel : %X", saud_type);
+ if (saud_type != TYPE_SAUD) error("Invalid Chunk for SaudChannel : %X", saud_type);
size -= 8;
_dataSize = -2;
}
- if(_tbuffer) {
+ if (_tbuffer) {
byte *old = _tbuffer;
_tbuffer = new byte[_tbufferSize + size];
- if(!_tbuffer) error("saud_channel failed to allocate memory");
+ if (!_tbuffer) error("saud_channel failed to allocate memory");
memcpy(_tbuffer, old, _tbufferSize);
delete []old;
b.read(_tbuffer + _tbufferSize, size);
@@ -249,7 +249,7 @@ bool SaudChannel::appendData(Chunk &b, int32 size) {
} else {
_tbufferSize = size;
_tbuffer = new byte[_tbufferSize];
- if(!_tbuffer) error("saud_channel failed to allocate memory");
+ if (!_tbuffer) error("saud_channel failed to allocate memory");
b.read(_tbuffer, _tbufferSize);
}
return processBuffer();
@@ -260,7 +260,7 @@ int32 SaudChannel::availableSoundData(void) const {
}
void SaudChannel::getSoundData(int16 *snd, int32 size) {
- for(int32 i = 0; i < size; i++) {
+ for (int32 i = 0; i < size; i++) {
snd[2 * i] = _voltable[0][_sbuffer[i] ^ 0x80];
snd[2 * i + 1] = _voltable[1][_sbuffer[i] ^ 0x80];
}
diff --git a/scumm/smush/smush_font.cpp b/scumm/smush/smush_font.cpp
index 3c7887e3ba..45afb71834 100644
--- a/scumm/smush/smush_font.cpp
+++ b/scumm/smush/smush_font.cpp
@@ -39,7 +39,7 @@ int SmushFont::getStringWidth(const char *str) {
}
int width = 0;
- while(*str) {
+ while (*str) {
width += getCharWidth(*str++);
}
return width;
@@ -52,7 +52,7 @@ int SmushFont::getStringHeight(const char *str) {
}
int height = 0;
- while(*str) {
+ while (*str) {
int charHeight = getCharHeight(*str++);
if (height < charHeight)
height = charHeight;
@@ -66,39 +66,39 @@ int SmushFont::drawChar(byte *buffer, int dst_width, int x, int y, byte chr) {
const byte *src = _chars[chr].src;
byte *dst = buffer + dst_width * y + x;
- assert(dst_width == g_scumm->_screenWidth);
+ assert(dst_width == _vm->_screenWidth);
- if(_original) {
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
+ if (_original) {
+ for (int j = 0; j < h; j++) {
+ for (int i = 0; i < w; i++) {
char value = *src++;
- if(value) dst[i] = value;
+ if (value) dst[i] = value;
}
dst += dst_width;
}
} else {
char color = (_color != -1) ? _color : 1;
if (_new_colors) {
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
+ for (int j = 0; j < h; j++) {
+ for (int i = 0; i < w; i++) {
char value = *src++;
- if(value == -color) {
+ if (value == -color) {
dst[i] = 0xFF;
- } else if(value == -31) {
+ } else if (value == -31) {
dst[i] = 0;
- } else if(value) {
+ } else if (value) {
dst[i] = value;
}
}
dst += dst_width;
}
} else {
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
+ for (int j = 0; j < h; j++) {
+ for (int i = 0; i < w; i++) {
char value = *src++;
- if(value == 1) {
+ if (value == 1) {
dst[i] = color;
- } else if(value) {
+ } else if (value) {
dst[i] = 0;
}
}
@@ -110,36 +110,26 @@ int SmushFont::drawChar(byte *buffer, int dst_width, int x, int y, byte chr) {
}
int SmushFont::draw2byte(byte *buffer, int dst_width, int x, int y, int idx) {
- int w = g_scumm->_2byteWidth;
- int h = g_scumm->_2byteHeight;
+ int w = _vm->_2byteWidth;
+ int h = _vm->_2byteHeight;
- byte *src = g_scumm->get2byteCharPtr(idx);
- byte *dst = buffer + dst_width * (y + (g_scumm->_gameId == GID_CMI ? 7 : 2)) + x;
+ byte *src = _vm->get2byteCharPtr(idx);
+ byte *dst = buffer + dst_width * (y + (_vm->_gameId == GID_CMI ? 7 : 2)) + x;
byte bits = 0;
- if(_original) {
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
- char value = 1;//*src++;
- if(value) dst[i] = value;
+ char color = (_color != -1) ? _color : 1;
+ if (_new_colors)
+ color = (char)0xff; //FIXME;
+ for (int j = 0; j < h; j++) {
+ for (int i = 0; i < w; i++) {
+ if ((i % 8) == 0)
+ bits = *src++;
+ if (bits & revBitMask[i % 8]) {
+ dst[i + 1] = 0;
+ dst[i] = color;
}
- dst += dst_width;
- }
- } else {
- char color = (_color != -1) ? _color : 1;
- if (_new_colors)
- color = (char)0xff; //FIXME;
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
- if((i % 8) == 0)
- bits = *src++;
- if (bits & revBitMask[i % 8]) {
- dst[i + 1] = 0;
- dst[i] = color;
- }
- }
- dst += dst_width;
}
+ dst += dst_width;
}
return w + 1;
}
@@ -150,7 +140,7 @@ static char **split(const char *str, char sep) {
const char *i = str;
char *j = strchr(i, sep);
- while(j != NULL) {
+ while (j != NULL) {
assert(n < 60);
ret[n] = new char[j - i + 1];
memcpy(ret[n], i, j - i);
@@ -169,8 +159,8 @@ static char **split(const char *str, char sep) {
}
void SmushFont::drawSubstring(const char *str, byte *buffer, int dst_width, int x, int y) {
- for(int i = 0; str[i] != 0; i++) {
- if((byte)str[i] >= 0x80 && g_scumm->_CJKMode) {
+ for (int i = 0; str[i] != 0; i++) {
+ if ((byte)str[i] >= 0x80 && _vm->_CJKMode) {
x += draw2byte(buffer, dst_width, x, y, (byte)str[i] + 256 * (byte)str[i+1]);
i++;
} else
@@ -181,10 +171,10 @@ void SmushFont::drawSubstring(const char *str, byte *buffer, int dst_width, int
void SmushFont::drawStringAbsolute(const char *str, byte *buffer, int dst_width, int x, int y) {
debug(9, "SmushFont::drawStringAbsolute(%s, %d, %d)", str, x, y);
- while(str) {
+ while (str) {
char line[256];
char *pos = strchr(str, '\n');
- if(pos) {
+ if (pos) {
memcpy(line, str, pos - str - 1);
line[pos - str - 1] = 0;
str = pos + 1;
@@ -207,13 +197,13 @@ void SmushFont::drawStringCentered(const char *str, byte *buffer, int dst_width,
char **words = split(str, ' ');
int nb_sub = 0;
- while(words[nb_sub])
+ while (words[nb_sub])
nb_sub++;
int *sizes = new int[nb_sub];
int i = 0, max_width = 0, height = 0, nb_subs = 0;
- for(i = 0; i < nb_sub; i++)
+ for (i = 0; i < nb_sub; i++)
sizes[i] = getStringWidth(words[i]);
char **substrings = new char *[nb_sub];
@@ -221,57 +211,57 @@ void SmushFont::drawStringCentered(const char *str, byte *buffer, int dst_width,
int space_width = getCharWidth(' ');
i = 0;
- while(i < nb_sub) {
+ while (i < nb_sub) {
int substr_width = sizes[i];
char *substr = new char[1000];
strcpy(substr, words[i]);
int j = i + 1;
- while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
+ while (j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
substr_width += sizes[j++] + space_width;
}
- for(int k = i + 1; k < j; k++) {
+ for (int k = i + 1; k < j; k++) {
strcat(substr, " ");
strcat(substr, words[k]);
}
substrings[nb_subs] = substr;
substr_widths[nb_subs++] = substr_width;
- if(substr_width > max_width)
+ if (substr_width > max_width)
max_width = substr_width;
i = j;
height += getStringHeight(substr);
}
- delete []sizes;
- for(i = 0; i < nb_sub; i++) {
- delete []words[i];
+ delete[] sizes;
+ for (i = 0; i < nb_sub; i++) {
+ delete[] words[i];
}
- delete []words;
+ delete[] words;
max_width = (max_width + 1) >> 1;
int x = xmin + width / 2;
x += offset - dst_width / 2;
- if(x < max_width) x = max_width;
- if(x + max_width > dst_width) {
+ if (x < max_width) x = max_width;
+ if (x + max_width > dst_width) {
x = dst_width - max_width;
}
- if(y + height > dst_height) {
+ if (y + height > dst_height) {
y = dst_height - height;
}
- for(i = 0; i < nb_subs; i++) {
+ for (i = 0; i < nb_subs; i++) {
int substr_width = substr_widths[i];
drawSubstring(substrings[i], buffer, dst_width, x - substr_width / 2, y);
y += getStringHeight(substrings[i]);
- delete []substrings[i];
+ delete[] substrings[i];
}
- delete []substr_widths;
- delete []substrings;
+ delete[] substr_widths;
+ delete[] substrings;
}
void SmushFont::drawStringWrap(const char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width) {
@@ -284,13 +274,13 @@ void SmushFont::drawStringWrap(const char *str, byte *buffer, int dst_width, int
char ** words = split(str, ' ');
int nb_sub = 0;
- while(words[nb_sub])
+ while (words[nb_sub])
nb_sub++;
int *sizes = new int[nb_sub];
int i = 0, max_width = 0, height = 0, nb_subs = 0, left_x;
- for(i = 0; i < nb_sub; i++)
+ for (i = 0; i < nb_sub; i++)
sizes[i] = getStringWidth(words[i]);
char **substrings = new char *[nb_sub];
@@ -298,17 +288,17 @@ void SmushFont::drawStringWrap(const char *str, byte *buffer, int dst_width, int
int space_width = getCharWidth(' ');
i = 0;
- while(i < nb_sub) {
+ while (i < nb_sub) {
int substr_width = sizes[i];
char *substr = new char[1000];
strcpy(substr, words[i]);
int j = i + 1;
- while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
+ while (j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
substr_width += sizes[j++] + space_width;
}
- for(int k = i + 1; k < j; k++) {
+ for (int k = i + 1; k < j; k++) {
strcat(substr, " ");
strcat(substr, words[k]);
}
@@ -319,35 +309,35 @@ void SmushFont::drawStringWrap(const char *str, byte *buffer, int dst_width, int
height += getStringHeight(substr);
}
- delete []sizes;
- for(i = 0; i < nb_sub; i++) {
- delete []words[i];
+ delete[] sizes;
+ for (i = 0; i < nb_sub; i++) {
+ delete[] words[i];
}
- delete []words;
+ delete[] words;
- if(y + height > dst_height) {
+ if (y + height > dst_height) {
y = dst_height - height;
}
- for(i = 0; i < nb_subs; i++)
+ for (i = 0; i < nb_subs; i++)
max_width = MAX(max_width, substr_widths[i]);
- if(max_width + x > dst_width)
+ if (max_width + x > dst_width)
left_x = dst_width - max_width + getCharWidth(' ');
else
left_x = x;
- if(max_width + left_x > dst_height)
+ if (max_width + left_x > dst_height)
left_x = dst_width - max_width;
- for(i = 0; i < nb_subs; i++) {
+ for (i = 0; i < nb_subs; i++) {
drawSubstring(substrings[i], buffer, dst_width, left_x, y);
y += getStringHeight(substrings[i]);
- delete []substrings[i];
+ delete[] substrings[i];
}
- delete []substr_widths;
- delete []substrings;
+ delete[] substr_widths;
+ delete[] substrings;
}
void SmushFont::drawStringWrapCentered(const char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width) {
@@ -361,13 +351,13 @@ void SmushFont::drawStringWrapCentered(const char *str, byte *buffer, int dst_wi
char **words = split(str, ' ');
int nb_sub = 0;
- while(words[nb_sub])
+ while (words[nb_sub])
nb_sub++;
int *sizes = new int[nb_sub];
int i = 0, height = 0, nb_subs = 0;
- for(i = 0; i < nb_sub; i++)
+ for (i = 0; i < nb_sub; i++)
sizes[i] = getStringWidth(words[i]);
char **substrings = new char *[nb_sub];
@@ -376,17 +366,17 @@ void SmushFont::drawStringWrapCentered(const char *str, byte *buffer, int dst_wi
i = 0;
width = MIN(width, dst_width);
- while(i < nb_sub) {
+ while (i < nb_sub) {
int substr_width = sizes[i];
char *substr = new char[1000];
strcpy(substr, words[i]);
int j = i + 1;
- while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
+ while (j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
substr_width += sizes[j++] + space_width;
}
- for(int k = i + 1; k < j; k++) {
+ for (int k = i + 1; k < j; k++) {
strcat(substr, " ");
strcat(substr, words[k]);
}
@@ -398,25 +388,25 @@ void SmushFont::drawStringWrapCentered(const char *str, byte *buffer, int dst_wi
height += getStringHeight(substr);
}
- delete []sizes;
- for(i = 0; i < nb_sub; i++) {
- delete []words[i];
+ delete[] sizes;
+ for (i = 0; i < nb_sub; i++) {
+ delete[] words[i];
}
- delete []words;
+ delete[] words;
- if(y + height > dst_height) {
+ if (y + height > dst_height) {
y = dst_height - height;
}
x = (dst_width - max_substr_width) / 2;
- for(i = 0; i < nb_subs; i++) {
+ for (i = 0; i < nb_subs; i++) {
int substr_width = substr_widths[i];
drawSubstring(substrings[i], buffer, dst_width, x + (max_substr_width - substr_width) / 2, y);
y += getStringHeight(substrings[i]);
- delete []substrings[i];
+ delete[] substrings[i];
}
- delete []substr_widths;
- delete []substrings;
+ delete[] substr_widths;
+ delete[] substrings;
}
diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp
index 69eb686ce9..795772aa39 100644
--- a/scumm/smush/smush_mixer.cpp
+++ b/scumm/smush/smush_mixer.cpp
@@ -32,7 +32,7 @@ SmushMixer::SmushMixer(SoundMixer *m) :
_mixer(m),
_nextIndex(_mixer->_beginSlots),
_soundFrequency(22050) {
- for(int32 i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (int32 i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
_channels[i].id = -1;
_channels[i].chan = NULL;
_channels[i].first = true;
@@ -44,8 +44,8 @@ SmushMixer::~SmushMixer() {
SmushChannel *SmushMixer::findChannel(int32 track) {
debug(9, "SmushMixer::findChannel(%d)", track);
- for(int32 i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
- if(_channels[i].id == track)
+ for (int32 i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
+ if (_channels[i].id == track)
return _channels[i].chan;
}
return NULL;
@@ -57,15 +57,15 @@ bool SmushMixer::addChannel(SmushChannel *c) {
debug(9, "SmushMixer::addChannel(%d)", track);
- for(i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
- if(_channels[i].id == track)
+ for (i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
+ if (_channels[i].id == track)
warning("SmushMixer::addChannel(%d) : channel already exists", track);
}
- if(_nextIndex >= SoundMixer::NUM_CHANNELS)
+ if (_nextIndex >= SoundMixer::NUM_CHANNELS)
_nextIndex = _mixer->_beginSlots;
- for(i = _nextIndex; i < SoundMixer::NUM_CHANNELS; i++) {
- if(_channels[i].chan == NULL || _channels[i].id == -1) {
+ for (i = _nextIndex; i < SoundMixer::NUM_CHANNELS; i++) {
+ if (_channels[i].chan == NULL || _channels[i].id == -1) {
_channels[i].chan = c;
_channels[i].id = track;
_channels[i].first = true;
@@ -74,8 +74,8 @@ bool SmushMixer::addChannel(SmushChannel *c) {
}
}
- for(i = _mixer->_beginSlots; i < _nextIndex; i++) {
- if(_channels[i].chan == NULL || _channels[i].id == -1) {
+ for (i = _mixer->_beginSlots; i < _nextIndex; i++) {
+ if (_channels[i].chan == NULL || _channels[i].id == -1) {
_channels[i].chan = c;
_channels[i].id = track;
_channels[i].first = true;
@@ -86,7 +86,7 @@ bool SmushMixer::addChannel(SmushChannel *c) {
warning("_nextIndex == %d", _nextIndex);
- for(i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
warning("channel %d : %p(%d, %d) %d %d", i, (void *)_channels[i].chan,
_channels[i].chan ? _channels[i].chan->getTrackIdentifier() : -1,
_channels[i].chan ? _channels[i].chan->isTerminated() : 1,
@@ -99,9 +99,9 @@ bool SmushMixer::addChannel(SmushChannel *c) {
bool SmushMixer::handleFrame() {
debug(9, "SmushMixer::handleFrame()");
- for(int i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
- if(_channels[i].id != -1) {
- if(_channels[i].chan->isTerminated()) {
+ for (int i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
+ if (_channels[i].id != -1) {
+ if (_channels[i].chan->isTerminated()) {
delete _channels[i].chan;
_channels[i].id = -1;
_channels[i].chan = NULL;
@@ -113,14 +113,14 @@ bool SmushMixer::handleFrame() {
int32 size = _channels[i].chan->availableSoundData();
int32 flags = stereo ? SoundMixer::FLAG_STEREO : 0;
- if(is_short) {
+ if (is_short) {
short *data = new int16[size * (stereo ? 2 : 1) * 2];
_channels[i].chan->getSoundData(data, size);
- if(_channels[i].chan->getRate() == 11025) size *= 2;
+ if (_channels[i].chan->getRate() == 11025) size *= 2;
size *= stereo ? 4 : 2;
- if(_silentMixer == false) {
- if(_channels[i].first) {
+ if (_silentMixer == false) {
+ if (_channels[i].first) {
_channels[i].mixer_index = _mixer->playStream(NULL, -1, data, size, rate, flags | SoundMixer::FLAG_16BITS);
_channels[i].first = false;
} else {
@@ -132,11 +132,11 @@ bool SmushMixer::handleFrame() {
} else {
int8 *data = new int8[size * (stereo ? 2 : 1) * 2];
_channels[i].chan->getSoundData(data, size);
- if(_channels[i].chan->getRate() == 11025) size *= 2;
+ if (_channels[i].chan->getRate() == 11025) size *= 2;
size *= stereo ? 2 : 1;
- if(_silentMixer == false) {
- if(_channels[i].first) {
+ if (_silentMixer == false) {
+ if (_channels[i].first) {
_channels[i].mixer_index = _mixer->playStream(NULL, -1, data, size, rate, flags | SoundMixer::FLAG_UNSIGNED);
_channels[i].first = false;
} else {
@@ -154,8 +154,8 @@ bool SmushMixer::handleFrame() {
bool SmushMixer::stop() {
debug(9, "SmushMixer::stop()");
- for(int i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
- if(_channels[i].id != -1) {
+ for (int i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
+ if (_channels[i].id != -1) {
delete _channels[i].chan;
_channels[i].id = -1;
_channels[i].chan = NULL;
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp
index 5d0cac3f04..a7efd84ca8 100644
--- a/scumm/smush/smush_player.cpp
+++ b/scumm/smush/smush_player.cpp
@@ -57,25 +57,25 @@ public:
_lastId(-1) {
};
~StringResource() {
- for(int32 i = 0; i < _nbStrings; i++) {
+ for (int32 i = 0; i < _nbStrings; i++) {
delete []_strings[i].string;
}
}
bool init(char *buffer, int32 length) {
char *def_start = strchr(buffer, '#');
- while(def_start != NULL) {
+ while (def_start != NULL) {
char *def_end = strchr(def_start, '\n');
assert(def_end != NULL);
char *id_end = def_end;
- while(id_end >= def_start && !isdigit(*(id_end-1))) {
+ while (id_end >= def_start && !isdigit(*(id_end-1))) {
id_end--;
}
assert(id_end > def_start);
char *id_start = id_end;
- while(isdigit(*(id_start - 1))) {
+ while (isdigit(*(id_start - 1))) {
id_start--;
}
@@ -85,17 +85,17 @@ public:
int32 id = atoi(idstring);
char *data_start = def_end;
- while(*data_start == '\n' || *data_start == '\r') {
+ while (*data_start == '\n' || *data_start == '\r') {
data_start++;
}
char *data_end = data_start;
- while(1) {
- if(data_end[-2] == '\r' && data_end[1] == '\n' && data_end[-1] == '\n' && data_end[0] == '\r') {
+ while (1) {
+ if (data_end[-2] == '\r' && data_end[1] == '\n' && data_end[-1] == '\n' && data_end[0] == '\r') {
break;
}
data_end++;
- if(data_end >= buffer + length) {
+ if (data_end >= buffer + length) {
data_end = buffer + length;
break;
}
@@ -130,11 +130,11 @@ public:
}
const char *get(int id) {
- if(id == _lastId) {
+ if (id == _lastId) {
return _lastString;
}
- for(int i = 0; i < _nbStrings; i++) {
- if(_strings[i].id == id) {
+ for (int i = 0; i < _nbStrings; i++) {
+ if (_strings[i].id == id) {
_lastId = id;
_lastString = _strings[i].string;
return _strings[i].string;
@@ -161,19 +161,19 @@ static StringResource *getStrings(const char *file, const char *directory, bool
theFile.read(filebuffer, length);
filebuffer[length] = 0;
- if(is_encoded) {
+ if (is_encoded) {
static const int32 ETRS_HEADER_LENGTH = 16;
assert(length > ETRS_HEADER_LENGTH);
Chunk::type type = READ_BE_UINT32(filebuffer);
- if(type != TYPE_ETRS) {
+ if (type != TYPE_ETRS) {
delete [] filebuffer;
return getStrings(file, directory, false);
}
char *old = filebuffer;
filebuffer = new char[length - ETRS_HEADER_LENGTH + 1];
- for(int32 i = ETRS_HEADER_LENGTH; i < length; i++) {
+ for (int32 i = ETRS_HEADER_LENGTH; i < length; i++) {
filebuffer[i - ETRS_HEADER_LENGTH] = old[i] ^ 0xCC;
}
filebuffer[length - ETRS_HEADER_LENGTH] = '\0';
@@ -191,7 +191,7 @@ SmushPlayer *player;
void smush_callback(void *ptr) {
Scumm *scumm = (Scumm *)ptr;
- if (scumm->_smushPlay == false)
+ if (!scumm->_smushPlay)
return;
player->_smushProcessFrame = true;
@@ -256,19 +256,19 @@ void SmushPlayer::deinit() {
while (_smushProcessFrame) {}
_scumm->_timer->releaseProcedure(&smush_callback);
- for(int i = 0; i < 5; i++) {
+ for (int i = 0; i < 5; i++) {
if (_sf[i]) {
delete _sf[i];
_sf[i] = NULL;
}
}
- if(_strings) {
+ if (_strings) {
delete _strings;
_strings = NULL;
}
- if(_smixer) {
+ if (_smixer) {
_smixer->stop();
delete _smixer;
_smixer = NULL;
@@ -284,28 +284,28 @@ void SmushPlayer::deinit() {
}
void SmushPlayer::checkBlock(const Chunk &b, Chunk::type type_expected, uint32 min_size) {
- if(type_expected != b.getType()) {
+ if (type_expected != b.getType()) {
error("Chunk type is different from expected : %d != %d", b.getType(), type_expected);
}
- if(min_size > b.getSize()) {
+ if (min_size > b.getSize()) {
error("Chunk size is inferior than minimum required size : %d < %d", b.getSize(), min_size);
}
}
void SmushPlayer::handleSoundBuffer(int32 track_id, int32 index, int32 max_frames, int32 flags, int32 vol, int32 bal, Chunk &b, int32 size) {
debug(6, "SmushPlayer::handleSoundBuffer(%d)", track_id);
-// if((flags & 128) == 128) {
+// if ((flags & 128) == 128) {
// return;
// }
-// if((flags & 64) == 64) {
+// if ((flags & 64) == 64) {
// return;
// }
SmushChannel *c = _smixer->findChannel(track_id);
- if(c == NULL) {
+ if (c == NULL) {
c = new SaudChannel(track_id, _soundFrequency);
_smixer->addChannel(c);
}
- if(index == 0) {
+ if (index == 0) {
c->setParameters(max_frames, flags, vol, bal);
} else {
c->checkParameters(index, max_frames, flags, vol, bal);
@@ -324,7 +324,7 @@ void SmushPlayer::handleSoundFrame(Chunk &b) {
int32 vol = b.getByte();
int32 bal = b.getChar();
#ifdef DEBUG
- if(index == 0) {
+ if (index == 0) {
debug(5, "track_id == %d, max_frames == %d, %d, %d, %d", track_id, max_frames, flags, vol, bal);
}
#endif
@@ -336,7 +336,7 @@ void SmushPlayer::handleSkip(Chunk &b) {
checkBlock(b, TYPE_SKIP, 4);
int32 code = b.getDword();
debug(6, "SmushPlayer::handleSkip(%d)", code);
- if(code >= 0 && code < 37)
+ if (code >= 0 && code < 37)
_skipNext = _skips[code];
else
_skipNext = true;
@@ -361,11 +361,11 @@ void SmushPlayer::handleImuseBuffer(int32 track_id, int32 index, int32 nbframes,
int32 track = (track_flags << 16) | track_id;
SmushChannel *c = _smixer->findChannel(track);
- if(c == 0) {
+ if (c == 0) {
c = new ImuseChannel(track, _soundFrequency);
_smixer->addChannel(c);
}
- if(index == 0)
+ if (index == 0)
c->setParameters(nbframes, size, track_flags, unk1);
else
c->checkParameters(index, nbframes, size, track_flags, unk1);
@@ -496,24 +496,24 @@ void SmushPlayer::handleTextResource(Chunk &b) {
b.read(string, b.getSize() - 16);
} else {
int string_id = b.getWord();
- if(!_strings)
+ if (!_strings)
return;
str = _strings->get(string_id);
}
// if subtitles disabled and bit 3 is set, then do not draw
- if((!_subtitles) && ((flags & 8) == 8))
+ if ((!_subtitles) && ((flags & 8) == 8))
return;
SmushFont *sf = _sf[0];
int color = 15;
- while(*str == '/') {
+ while (*str == '/') {
str++; // For Full Throttle text resources
}
if (_scumm->_gameId == GID_CMI) {
_scumm->translateText((const byte *)str - 1, _scumm->_transText);
- while(*str++ != '/')
+ while (*str++ != '/')
;
string2 = (char *)_scumm->_transText;
@@ -524,7 +524,7 @@ void SmushPlayer::handleTextResource(Chunk &b) {
string2[0] = 0;
}
- while(str[0] == '^') {
+ while (str[0] == '^') {
switch(str[1]) {
case 'f':
{
@@ -592,17 +592,17 @@ void SmushPlayer::handleTextResource(Chunk &b) {
bool SmushPlayer::readString(const char *file, const char *directory) {
const char *i = strrchr(file, '.');
- if(i == NULL) {
+ if (i == NULL) {
error("invalid filename : %s", file);
}
char fname[260];
memcpy(fname, file, i - file);
strcpy(fname + (i - file), ".trs");
- if((_strings = getStrings(fname, directory, false)) != 0) {
+ if ((_strings = getStrings(fname, directory, false)) != 0) {
return true;
}
- if((_strings = getStrings("digtxt.trs", directory, true)) != 0) {
+ if ((_strings = getStrings("digtxt.trs", directory, true)) != 0) {
return true;
}
return false;
@@ -625,23 +625,23 @@ void SmushPlayer::handleDeltaPalette(Chunk &b) {
checkBlock(b, TYPE_XPAL);
debug(6, "SmushPlayer::handleDeltaPalette()");
- if(b.getSize() == 0x300 * 3 + 4) {
+ if (b.getSize() == 0x300 * 3 + 4) {
b.getWord();
b.getWord();
- for(int i = 0; i < 0x300; i++) {
+ for (int i = 0; i < 0x300; i++) {
_deltaPal[i] = b.getWord();
}
readPalette(_pal, b);
setPalette(_pal);
- } else if(b.getSize() == 6) {
+ } else if (b.getSize() == 6) {
b.getWord();
b.getWord();
b.getWord();
- for(int i = 0; i < 0x300; i++) {
+ for (int i = 0; i < 0x300; i++) {
_pal[i] = delta_color(_pal[i], _deltaPal[i]);
}
setPalette(_pal);
@@ -660,7 +660,7 @@ void SmushPlayer::handleNewPalette(Chunk &b) {
void SmushPlayer::handleFrameObject(Chunk &b) {
checkBlock(b, TYPE_FOBJ, 14);
- if(_skipNext) {
+ if (_skipNext) {
_skipNext = false;
return;
}
@@ -671,10 +671,10 @@ void SmushPlayer::handleFrameObject(Chunk &b) {
int width = b.getWord();
int height = b.getWord();
- if((height != _scumm->_screenHeight) || (width != _scumm->_screenWidth))
+ if ((height != _scumm->_screenHeight) || (width != _scumm->_screenWidth))
return;
- if(_alreadyInit == false) {
+ if (!_alreadyInit) {
_codec37.init(width, height);
_codec47.init(width, height);
_alreadyInit = true;
@@ -719,7 +719,7 @@ void SmushPlayer::handleFrameObject(Chunk &b) {
error("Invalid codec for frame object : %d", (int)codec);
}
- if (_storeFrame == true) {
+ if (_storeFrame) {
if (_frameBuffer == NULL) {
_frameBuffer = (byte *)malloc(_width * _height);
}
@@ -738,9 +738,9 @@ void SmushPlayer::handleFrame(Chunk &b) {
uint32 start_time, end_time;
start_time = _scumm->_system->get_msecs();
- while(!b.eof()) {
+ while (!b.eof()) {
Chunk *sub = b.subBlock();
- if(sub->getSize() & 1) b.seek(1);
+ if (sub->getSize() & 1) b.seek(1);
switch(sub->getType()) {
case TYPE_NPAL:
handleNewPalette(*sub);
@@ -813,14 +813,14 @@ void SmushPlayer::setupAnim(const char *file, const char *directory) {
_sf[0]->loadFont("scummfnt.nut", directory);
_sf[2]->loadFont("titlfnt.nut", directory);
} else if (_scumm->_gameId == GID_DIG) {
- for(int i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
char file_font[11];
sprintf((char *)&file_font, "font%d.nut", i);
_sf[i] = new SmushFont(i != 0, false);
_sf[i]->loadFont(file_font, directory);
}
} else if (_scumm->_gameId == GID_CMI) {
- for(int i = 0; i < 5; i++) {
+ for (int i = 0; i < 5; i++) {
char file_font[11];
sprintf((char *)&file_font, "font%d.nut", i);
_sf[i] = new SmushFont(false, true);
@@ -876,7 +876,7 @@ void SmushPlayer::updateScreen() {
void SmushPlayer::play(const char *filename, const char *directory) {
File f;
f.open(filename, directory);
- if(f.isOpen() == false) {
+ if (!f.isOpen()) {
warning("SmushPlayer::setupAnim() File not found %s", filename);
return;
}
@@ -889,7 +889,7 @@ void SmushPlayer::play(const char *filename, const char *directory) {
while (true) {
_scumm->parseEvents();
_scumm->processKbd();
- if(_updateNeeded == true) {
+ if (_updateNeeded) {
uint32 end_time, start_time = _scumm->_system->get_msecs();
_scumm->_system->update_screen();
@@ -898,7 +898,7 @@ void SmushPlayer::play(const char *filename, const char *directory) {
debug(4, "Smush stats: BackendUpdateScreen( %03d )", end_time - start_time);
}
- if (_scumm->_videoFinished == true)
+ if (_scumm->_videoFinished)
break;
if (_scumm->_saveLoadFlag)
break;