aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorGregory Montoir2007-02-17 01:33:47 +0000
committerGregory Montoir2007-02-17 01:33:47 +0000
commitf1f88c43c022912eb1f1ceee4d7a2d0630e08d5d (patch)
tree21f85efc264be16229d20c4f38d3c1e18957be55 /engines/scumm
parent441ea2bdb1cee99d6e6c26dd44e857753b0693c0 (diff)
downloadscummvm-rg350-f1f88c43c022912eb1f1ceee4d7a2d0630e08d5d.tar.gz
scummvm-rg350-f1f88c43c022912eb1f1ceee4d7a2d0630e08d5d.tar.bz2
scummvm-rg350-f1f88c43c022912eb1f1ceee4d7a2d0630e08d5d.zip
cleanup
svn-id: r25646
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/smush/codec47.cpp11
-rw-r--r--engines/scumm/smush/smush_player.cpp127
-rw-r--r--engines/scumm/smush/smush_player.h1
3 files changed, 41 insertions, 98 deletions
diff --git a/engines/scumm/smush/codec47.cpp b/engines/scumm/smush/codec47.cpp
index c9b5ffa329..6ef374fbca 100644
--- a/engines/scumm/smush/codec47.cpp
+++ b/engines/scumm/smush/codec47.cpp
@@ -543,7 +543,6 @@ bool Codec47Decoder::decode(byte *dst, const byte *src) {
int32 seq_nb = READ_LE_UINT16(src + 0);
const byte *gfx_data = src + 26;
- byte *tmp_ptr;
if (seq_nb == 0) {
makeTables47(_width);
@@ -583,14 +582,10 @@ bool Codec47Decoder::decode(byte *dst, const byte *src) {
if (seq_nb == _prevSeqNb + 1) {
if (src[3] == 1) {
- tmp_ptr = _curBuf;
- _curBuf = _deltaBufs[1];
- _deltaBufs[1] = tmp_ptr;
+ SWAP(_curBuf, _deltaBufs[1]);
} else if (src[3] == 2) {
- tmp_ptr = _deltaBufs[0];
- _deltaBufs[0] = _deltaBufs[1];
- _deltaBufs[1] = _curBuf;
- _curBuf = tmp_ptr;
+ SWAP(_deltaBufs[0], _deltaBufs[1]);
+ SWAP(_deltaBufs[1], _curBuf);
}
}
_prevSeqNb = seq_nb;
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index 15a05a9a5f..0cd4bfcc6c 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -63,6 +63,7 @@
namespace Scumm {
static const int MAX_STRINGS = 200;
+static const int ETRS_HEADER_LENGTH = 16;
class StringResource {
private:
@@ -193,26 +194,13 @@ static StringResource *getStrings(ScummEngine *vm, const char *file, bool is_enc
theFile.read(filebuffer, length);
filebuffer[length] = 0;
- if (is_encoded) {
- enum {
- ETRS_HEADER_LENGTH = 16
- };
+ if (is_encoded && READ_BE_UINT32(filebuffer) == MKID_BE('ETRS')) {
assert(length > ETRS_HEADER_LENGTH);
- Chunk::type type = READ_BE_UINT32(filebuffer);
-
- if (type != MKID_BE('ETRS')) {
- delete [] filebuffer;
- return getStrings(vm, file, false);
- }
-
- char *old = filebuffer;
- filebuffer = new char[length - ETRS_HEADER_LENGTH + 1];
- for (int32 i = ETRS_HEADER_LENGTH; i < length; i++) {
- filebuffer[i - ETRS_HEADER_LENGTH] = old[i] ^ 0xCC;
- }
- filebuffer[length - ETRS_HEADER_LENGTH] = '\0';
- delete []old;
length -= ETRS_HEADER_LENGTH;
+ for (int i = 0; i < length; ++i) {
+ filebuffer[i] = filebuffer[i + ETRS_HEADER_LENGTH] ^ 0xCC;
+ }
+ filebuffer[length] = '\0';
}
StringResource *sr = new StringResource;
assert(sr);
@@ -721,7 +709,7 @@ bool SmushPlayer::readString(const char *file) {
return true;
}
- if ((_strings = getStrings(_vm, "digtxt.trs", true)) != 0) {
+ if (_vm->_game.id == GID_DIG && (_strings = getStrings(_vm, "digtxt.trs", true)) != 0) {
return true;
}
return false;
@@ -733,11 +721,7 @@ void SmushPlayer::readPalette(byte *out, Chunk &in) {
static byte delta_color(byte org_color, int16 delta_color) {
int t = (org_color * 129 + delta_color) / 128;
- if (t > 255)
- t = 255;
- if (t < 0)
- t = 0;
- return (byte)t;
+ return CLIP(t, 0, 255);
}
void SmushPlayer::handleDeltaPalette(Chunk &b) {
@@ -783,6 +767,26 @@ void SmushPlayer::handleNewPalette(Chunk &b) {
void smush_decode_codec1(byte *dst, const byte *src, int left, int top, int width, int height, int pitch);
void SmushPlayer::decodeFrameObject(int codec, const uint8 *src, int left, int top, int width, int height) {
+ if ((height == 242) && (width == 384)) {
+ if (_specialBuffer == 0)
+ _specialBuffer = (byte *)malloc(242 * 384);
+ _dst = _specialBuffer;
+ } else if ((height > _vm->_screenHeight) || (width > _vm->_screenWidth))
+ return;
+ // FT Insane uses smaller frames to draw overlays with moving objects
+ // Other .san files do have them as well but their purpose in unknown
+ // and often it causes memory overdraw. So just skip those frames
+ else if (!_insanity && ((height != _vm->_screenHeight) || (width != _vm->_screenWidth)))
+ return;
+
+ if ((height == 242) && (width == 384)) {
+ _width = width;
+ _height = height;
+ } else {
+ _width = _vm->_screenWidth;
+ _height = _vm->_screenHeight;
+ }
+
switch (codec) {
case 1:
case 3:
@@ -803,6 +807,14 @@ void SmushPlayer::decodeFrameObject(int codec, const uint8 *src, int left, int t
default:
error("Invalid codec for frame object : %d", codec);
}
+
+ if (_storeFrame) {
+ if (_frameBuffer == NULL) {
+ _frameBuffer = (byte *)malloc(_width * _height);
+ }
+ memcpy(_frameBuffer, _dst, _width * _height);
+ _storeFrame = false;
+ }
}
#ifdef USE_ZLIB
@@ -831,37 +843,8 @@ void SmushPlayer::handleZlibFrameObject(Chunk &b) {
int width = READ_LE_UINT16(ptr); ptr += 2;
int height = READ_LE_UINT16(ptr); ptr += 2;
- if ((height == 242) && (width == 384)) {
- if (_specialBuffer == 0)
- _specialBuffer = (byte *)malloc(242 * 384);
- _dst = _specialBuffer;
- } else if ((height > _vm->_screenHeight) || (width > _vm->_screenWidth))
- return;
-
- // FT Insane uses smaller frames to draw overlays with moving objects
- // Other .san files do have them as well but their purpose in unknown
- // and often it causes memory overdraw. So just skip those frames
- else if (!_insanity && ((height != _vm->_screenHeight) || (width != _vm->_screenWidth)))
- return;
-
- if ((height == 242) && (width == 384)) {
- _width = width;
- _height = height;
- } else {
- _width = _vm->_screenWidth;
- _height = _vm->_screenHeight;
- }
-
decodeFrameObject(codec, fobjBuffer + 14, left, top, width, height);
- if (_storeFrame) {
- if (_frameBuffer == NULL) {
- _frameBuffer = (byte *)malloc(_width * _height);
- }
- memcpy(_frameBuffer, _dst, _width * _height);
- _storeFrame = false;
- }
-
free(fobjBuffer);
}
#endif
@@ -879,26 +862,6 @@ void SmushPlayer::handleFrameObject(Chunk &b) {
int width = b.readUint16LE();
int height = b.readUint16LE();
- if ((height == 242) && (width == 384)) {
- if (_specialBuffer == 0)
- _specialBuffer = (byte *)malloc(242 * 384);
- _dst = _specialBuffer;
- } else if ((height > _vm->_screenHeight) || (width > _vm->_screenWidth))
- return;
- // FT Insane uses smaller frames to draw overlays with moving objects
- // Other .san files do have them as well but their purpose in unknown
- // and often it causes memory overdraw. So just skip those frames
- else if (!_insanity && ((height != _vm->_screenHeight) || (width != _vm->_screenWidth)))
- return;
-
- if ((height == 242) && (width == 384)) {
- _width = width;
- _height = height;
- } else {
- _width = _vm->_screenWidth;
- _height = _vm->_screenHeight;
- }
-
b.readUint16LE();
b.readUint16LE();
@@ -909,14 +872,6 @@ void SmushPlayer::handleFrameObject(Chunk &b) {
decodeFrameObject(codec, chunk_buffer, left, top, width, height);
- if (_storeFrame) {
- if (_frameBuffer == NULL) {
- _frameBuffer = (byte *)malloc(_width * _height);
- }
- memcpy(_frameBuffer, _dst, _width * _height);
- _storeFrame = false;
- }
-
free(chunk_buffer);
}
@@ -1376,15 +1331,10 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st
skipped = 0;
if (_updateNeeded) {
if (!skipFrame) {
- int w = _width, h = _height;
-
// Workaround for bug #1386333: "FT DEMO: assertion triggered
// when playing movie". Some frames there are 384 x 224
- if (w > _vm->_screenWidth)
- w = _vm->_screenWidth;
-
- if (h > _vm->_screenHeight)
- h = _vm->_screenHeight;
+ int w = MIN(_width, _vm->_screenWidth);
+ int h = MIN(_height, _vm->_screenHeight);
_vm->_system->copyRectToScreen(_dst, _width, 0, 0, w, h);
_vm->_system->updateScreen();
@@ -1414,4 +1364,3 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st
}
} // End of namespace Scumm
-
diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h
index 9e3a59ab6a..a10ddd2fd4 100644
--- a/engines/scumm/smush/smush_player.h
+++ b/engines/scumm/smush/smush_player.h
@@ -71,7 +71,6 @@ private:
int32 _IACTpos;
bool _storeFrame;
int _speed;
- bool _outputSound;
bool _endOfFile;
byte *_dst;