aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/scumm/he/animation_he.cpp186
-rw-r--r--engines/scumm/he/animation_he.h26
-rw-r--r--engines/scumm/he/script_v90he.cpp2
-rw-r--r--engines/simon/animation.cpp384
-rw-r--r--engines/simon/animation.h22
-rw-r--r--graphics/animation.h2
-rw-r--r--graphics/dxa_player.cpp209
-rw-r--r--graphics/dxa_player.h116
-rw-r--r--graphics/module.mk1
9 files changed, 474 insertions, 474 deletions
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index 327cde6d87..3fa58cac90 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -26,71 +26,26 @@
#include "scumm/he/animation_he.h"
#include "scumm/he/intern_he.h"
-#ifdef USE_ZLIB
-#include <zlib.h>
-#endif
-
namespace Scumm {
MoviePlayer::MoviePlayer(ScummEngine_v90he *vm)
- : _vm(vm) {
-
- _frameBuffer1 = 0;
- _frameBuffer2 = 0;
-
- _width = 0;
- _height = 0;
-
- _frameSize = 0;
- _framesCount = 0;
- _frameNum = 0;
- _framesPerSec = 0;
- _frameTicks = 0;
+ : DXAPlayer(), _vm(vm) {
_flags = 0;
_wizResNum = 0;
}
-MoviePlayer::~MoviePlayer() {
-}
-
-int MoviePlayer::getWidth() {
- if (_fd.isOpen() == false)
- return 0;
- return _width;
-}
-
-int MoviePlayer::getHeight() {
- if (_fd.isOpen() == false)
- return 0;
- return _height;
-}
-
-int MoviePlayer::getCurFrame() {
- if (_fd.isOpen() == false)
- return -1;
- return _frameNum;
-}
-
-int MoviePlayer::getFrameCount() {
- if (_fd.isOpen() == false)
- return 0;
- return _framesCount;
-}
-
int MoviePlayer::getImageNum() {
- if (_fd.isOpen() == false)
+ if (!_fd.isOpen())
return 0;
return _wizResNum;
}
int MoviePlayer::load(const char *filename, int flags, int image) {
char videoName[100];
- uint32 tag;
- int32 frameRate;
- if (_fd.isOpen() == true) {
- close();
+ if (_fd.isOpen()) {
+ closeFile();
}
// Change file extension to dxa
@@ -100,173 +55,60 @@ int MoviePlayer::load(const char *filename, int flags, int image) {
videoName[len++] = 'x';
videoName[len++] = 'a';
- if (_fd.open(videoName) == false) {
+ if (!loadFile(videoName)) {
warning("Failed to load video file %s", videoName);
return -1;
}
debug(1, "Playing video %s", videoName);
- tag = _fd.readUint32BE();
- assert(tag == MKID_BE('DEXA'));
-
- _fd.readByte();
- _framesCount = _fd.readUint16BE();
- frameRate = _fd.readUint32BE();
-
- if (frameRate > 0)
- _framesPerSec = 1000 / frameRate;
- else if (frameRate < 0)
- _framesPerSec = 100000 / (-frameRate);
- else
- _framesPerSec = 10;
-
- if (frameRate < 0)
- _frameTicks = -frameRate / 100;
- else
- _frameTicks = frameRate;
-
- _width = _fd.readUint16BE();
- _height = _fd.readUint16BE();
-
// Skip sound tag
_fd.readUint32BE();
- _frameSize = _width * _height;
- _frameBuffer1 = (uint8 *)malloc(_frameSize);
- _frameBuffer2 = (uint8 *)malloc(_frameSize);
- if (!_frameBuffer1 || !_frameBuffer2) {
- error("error allocating frame tables, size %d\n", _frameSize);
- }
-
if (flags & 2) {
_vm->_wiz->createWizEmptyImage(image, 0, 0, _width, _height);
}
- _frameNum = 0;
-
_flags = flags;
_wizResNum = image;
return 0;
}
-void MoviePlayer::close() {
- if (_fd.isOpen() == false)
- return;
-
- _fd.close();
- free(_frameBuffer1);
- free(_frameBuffer2);
-}
-
void MoviePlayer::handleNextFrame() {
if (_fd.isOpen() == false) {
return;
}
VirtScreen *pvs = &_vm->virtscr[kMainVirtScreen];
- uint8 *dst;
+ ;
- decodeFrame();
+ decodeNextFrame();
if (_flags & 2) {
uint8 *dstPtr = _vm->getResourceAddress(rtImage, _wizResNum);
assert(dstPtr);
- dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0);
+ uint8 *dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0);
assert(dst);
- copyFrame(dst, 0, 0);
+ copyFrameToBuffer(dst, 0, 0, _vm->_screenWidth);
} else if (_flags & 1) {
- dst = pvs->getBackPixels(0, 0);
- copyFrame(dst, 0, 0);
+ copyFrameToBuffer(pvs->getBackPixels(0, 0), 0, 0, _vm->_screenWidth);
Common::Rect imageRect(_width, _height);
_vm->gdi.copyVirtScreenBuffers(imageRect);
} else {
- dst = pvs->getPixels(0, 0);
- copyFrame(dst, 0, 0);
+ copyFrameToBuffer(pvs->getPixels(0, 0), 0, 0, _vm->_screenWidth);
_vm->markRectAsDirty(kMainVirtScreen, 0, 0, _width, _height);
}
_frameNum++;
if (_frameNum == _framesCount) {
- close();
- }
-}
-
-void MoviePlayer::copyFrame(byte *dst, uint x, uint y) {
- uint h = _height;
- uint w = _width;
-
- dst += y * _vm->_screenWidth + x;
- byte *src = _frameBuffer1;
-
- do {
- memcpy(dst, src, w);
- dst += _vm->_screenWidth;
- src += _width;
- } while (--h);
-}
-
-void MoviePlayer::decodeZlib(uint8 *data, int size, int totalSize) {
-#ifdef USE_ZLIB
- uint8 *temp = (uint8 *)malloc(size);
- if (temp) {
- memcpy(temp, data, size);
- z_stream d_stream;
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
- d_stream.next_in = temp;
- d_stream.avail_in = size;
- d_stream.total_in = size;
- d_stream.next_out = data;
- d_stream.avail_out = totalSize;
- inflateInit(&d_stream);
- inflate(&d_stream, Z_FINISH);
- inflateEnd(&d_stream);
- free(temp);
+ closeFile();
}
-#endif
}
-void MoviePlayer::decodeFrame() {
- uint32 tag;
-
- tag = _fd.readUint32BE();
- if (tag == MKID_BE('CMAP')) {
- uint8 rgb[768];
-
- _fd.read(rgb, ARRAYSIZE(rgb));
- _vm->setPaletteFromPtr(rgb, 256);
- }
-
- tag = _fd.readUint32BE();
- if (tag == MKID_BE('FRAM')) {
- uint8 type = _fd.readByte();
- uint32 size = _fd.readUint32BE();
-
- _fd.read(_frameBuffer2, size);
-
- switch (type) {
- case 2:
- case 3:
- decodeZlib(_frameBuffer2, size, _frameSize);
- break;
- default:
- error("decodeFrame: Unknown compression type %d", type);
- }
- if (type == 2) {
- memcpy(_frameBuffer1, _frameBuffer2, _frameSize);
- } else {
- for (int j = 0; j < _height; ++j) {
- for (int i = 0; i < _width; ++i) {
- const int offs = j * _width + i;
- _frameBuffer1[offs] ^= _frameBuffer2[offs];
- }
- }
- }
- }
+void MoviePlayer::setPalette(byte *pal) {
+ _vm->setPaletteFromPtr(pal, 256);
}
} // End of namespace Simon
diff --git a/engines/scumm/he/animation_he.h b/engines/scumm/he/animation_he.h
index d55f2feb05..f1c40a65a9 100644
--- a/engines/scumm/he/animation_he.h
+++ b/engines/scumm/he/animation_he.h
@@ -25,46 +25,28 @@
#define ANIMATION_H
#include "common/file.h"
+#include "graphics/dxa_player.h"
namespace Scumm {
class ScummEngine_v90he;
-class MoviePlayer {
+class MoviePlayer : public Graphics::DXAPlayer {
ScummEngine_v90he *_vm;
- Common::File _fd;
- uint8 *_frameBuffer1;
- uint8 *_frameBuffer2;
- uint16 _width;
- uint16 _height;
- uint16 _framesCount;
- uint32 _framesPerSec;
- uint16 _frameNum;
- uint32 _frameSize;
- uint32 _frameTicks;
-
uint32 _flags;
uint32 _wizResNum;
public:
MoviePlayer(ScummEngine_v90he *vm);
- ~MoviePlayer();
- int getWidth();
- int getHeight();
- int getCurFrame();
- int getFrameCount();
int getImageNum();
int load(const char *filename, int flags, int image = 0);
void handleNextFrame();
- void close();
-private:
- void copyFrame(byte *dst, uint x, uint y);
- void decodeFrame();
- void decodeZlib(uint8 *data, int size, int totalSize);
+protected:
+ virtual void setPalette(byte *pal);
};
} // End of namespace Simon
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index f18a049785..c8937a1035 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -550,7 +550,7 @@ void ScummEngine_v90he::o90_videoOps() {
}
} else if (_videoParams.status == 165) {
// Stop video
- _moviePlay->close();
+ _moviePlay->closeFile();
}
break;
default:
diff --git a/engines/simon/animation.cpp b/engines/simon/animation.cpp
index f6018b03a1..85d77e77c7 100644
--- a/engines/simon/animation.cpp
+++ b/engines/simon/animation.cpp
@@ -35,47 +35,23 @@
#include "sound/audiostream.h"
#include "sound/wave.h"
-
-#ifdef USE_ZLIB
-#include <zlib.h>
-#endif
-
namespace Simon {
MoviePlayer::MoviePlayer(SimonEngine *vm, Audio::Mixer *mixer)
- : _vm(vm), _mixer(mixer) {
+ : DXAPlayer(), _vm(vm), _mixer(mixer) {
_omniTV = false;
- _playing = false;
_leftButtonDown = false;
_rightButtonDown = false;
- _frameBuffer1 = 0;
- _frameBuffer2 = 0;
-
- _width = 0;
- _height = 0;
-
- _frameSize = 0;
- _framesCount = 0;
- _frameNum = 0;
- _framesPerSec = 0;
- _frameTicks = 0;
- _frameSkipped = 0;
-
memset(baseName, 0, sizeof(baseName));
_sequenceNum = 0;
_ticks = 0;
}
-MoviePlayer::~MoviePlayer() {
-}
-
bool MoviePlayer::load(const char *filename) {
char videoName[20];
- uint32 tag;
- int32 frameRate;
uint i;
int baseLen = strlen(filename) - 4;
@@ -84,8 +60,8 @@ bool MoviePlayer::load(const char *filename) {
// Change file extension to dxa
sprintf(videoName, "%s.dxa", baseName);
-
- if (_fd.open(videoName) == false) {
+
+ if (!loadFile(videoName)) {
// Check short filename to work around
// bug in a German Windows 2CD version.
if (baseLen >= 8) {
@@ -93,16 +69,14 @@ bool MoviePlayer::load(const char *filename) {
memset(shortName, 0, sizeof(shortName));
memcpy(shortName, filename, 6);
- sprintf(shortName, "%s~1.dxa", shortName);
+ sprintf(shortName, "%s~1", shortName);
+ if (!loadFile(shortName))
+ error("Failed to load video file %s or %s", videoName, shortName);
+
memset(baseName, 0, sizeof(baseName));
memcpy(baseName, shortName, 8);
-
- if (_fd.open(shortName) == false) {
- error("Failed to load video file %s or %s", videoName, shortName);
- } else {
- debug(0, "Playing video %s", shortName);
- }
+ debug(0, "Playing video %s", shortName);
} else {
error("Failed to load video file %s", videoName);
}
@@ -116,50 +90,17 @@ bool MoviePlayer::load(const char *filename) {
_vm->_language != Common::EN_ANY) {
_sequenceNum = 0;
for (i = 0; i < 90; i++) {
- if (!scumm_stricmp(videoName, _sequenceList[i]))
+ if (!scumm_stricmp(baseName, _sequenceList[i]))
_sequenceNum = i;
}
}
- tag = _fd.readUint32BE();
- assert(tag == MKID_BE('DEXA'));
-
- _fd.readByte();
- _framesCount = _fd.readUint16BE();
- frameRate = _fd.readUint32BE();
-
- if (frameRate > 0)
- _framesPerSec = 1000 / frameRate;
- else if (frameRate < 0)
- _framesPerSec = 100000 / (-frameRate);
- else
- _framesPerSec = 10;
-
- if (frameRate < 0)
- _frameTicks = -frameRate / 100;
- else
- _frameTicks = frameRate;
-
- _width = _fd.readUint16BE();
- _height = _fd.readUint16BE();
- debug(0, "frames_count %d width %d height %d rate %d ticks %d", _framesCount, _width, _height, _framesPerSec, _frameTicks);
-
- _frameSize = _width * _height;
- _frameBuffer1 = (uint8 *)malloc(_frameSize);
- _frameBuffer2 = (uint8 *)malloc(_frameSize);
- if (!_frameBuffer1 || !_frameBuffer2) {
- error("error allocating frame tables, size %d\n", _frameSize);
- }
-
- _frameNum = 0;
- _frameSkipped = 0;
-
return true;
}
void MoviePlayer::playOmniTV() {
// Load OmniTV video
- if (_fd.isOpen() == false) {
+ if (!_fd.isOpen()) {
_vm->_variableArray[254] = 6747;
return;
} else {
@@ -177,7 +118,7 @@ void MoviePlayer::play() {
return;
}
- if (_fd.isOpen() == false) {
+ if (!_fd.isOpen()) {
return;
}
@@ -198,7 +139,7 @@ void MoviePlayer::play() {
while (_frameNum < _framesCount)
handleNextFrame();
- close();
+ closeFile();
_vm->o_killAnimate();
@@ -214,12 +155,6 @@ void MoviePlayer::play() {
_vm->_fastFadeOutFlag = true;
}
-void MoviePlayer::close() {
- _fd.close();
- free(_frameBuffer1);
- free(_frameBuffer2);
-}
-
void MoviePlayer::startSound() {
byte *buffer;
uint32 offset, size, tag;
@@ -234,7 +169,7 @@ void MoviePlayer::startSound() {
_fd.seek(size, SEEK_CUR);
in.open((const char *)"audio.wav");
- if (in.isOpen() == false) {
+ if (!in.isOpen()) {
error("Can't read offset file 'audio.wav'");
}
@@ -253,15 +188,14 @@ void MoviePlayer::startSound() {
Common::MemoryReadStream stream(buffer, size);
_bgSoundStream = Audio::makeWAVStream(stream);
- _mixer->stopHandle(_bgSound);
- _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
free(buffer);
} else {
_bgSoundStream = Audio::AudioStream::openStreamFile(baseName);
- if (_bgSoundStream != NULL) {
- _mixer->stopHandle(_bgSound);
- _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
- }
+ }
+
+ if (_bgSoundStream != NULL) {
+ _mixer->stopHandle(_bgSound);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
}
}
@@ -271,28 +205,28 @@ void MoviePlayer::nextFrame() {
if (_vm->getBitFlag(42)) {
_omniTV = false;
- close();
+ closeFile();
return;
}
if (_mixer->isSoundHandleActive(_bgSound) && (_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum) {
- copyFrame(_vm->getBackBuf(), 465, 222);
+ copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
return;
}
if (_frameNum < _framesCount) {
- decodeFrame();
- copyFrame(_vm->getBackBuf(), 465, 222);
+ decodeNextFrame();
+ copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
_frameNum++;
} else {
_omniTV = false;
- close();
+ closeFile();
_vm->_variableArray[254] = 6747;
}
}
void MoviePlayer::handleNextFrame() {
- decodeFrame();
+ decodeNextFrame();
processFrame();
_vm->_system->updateScreen();
@@ -332,92 +266,22 @@ void MoviePlayer::handleNextFrame() {
}
}
-void MoviePlayer::copyFrame(byte *dst, uint x, uint y) {
- uint h = _height;
- uint w = _width;
-
- dst += y * _vm->_screenWidth + x;
- byte *src = _frameBuffer1;
-
- do {
- memcpy(dst, src, w);
- dst += _vm->_screenWidth;
- src += _width;
- } while (--h);
-}
+void MoviePlayer::setPalette(byte *pal) {
+ byte palette[1024];
+ byte *p = palette;
-void MoviePlayer::decodeZlib(uint8 *data, int size, int totalSize) {
-#ifdef USE_ZLIB
- uint8 *temp = (uint8 *)malloc(size);
- if (temp) {
- memcpy(temp, data, size);
- z_stream d_stream;
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
- d_stream.next_in = temp;
- d_stream.avail_in = size;
- d_stream.total_in = size;
- d_stream.next_out = data;
- d_stream.avail_out = totalSize;
- inflateInit(&d_stream);
- inflate(&d_stream, Z_FINISH);
- inflateEnd(&d_stream);
- free(temp);
+ for (int i = 0; i <= 256; i++) {
+ *p++ = *pal++;
+ *p++ = *pal++;
+ *p++ = *pal++;
+ *p++ = 0;
}
-#endif
-}
-
-void MoviePlayer::decodeFrame() {
- uint32 tag;
- tag = _fd.readUint32BE();
- if (tag == MKID_BE('CMAP')) {
- uint8 rgb[768];
- byte palette[1024];
- byte *p = palette;
-
- _fd.read(rgb, ARRAYSIZE(rgb));
- for (int i = 0; i <= 256; i++) {
- *p++ = rgb[i * 3 + 0];
- *p++ = rgb[i * 3 + 1];
- *p++ = rgb[i * 3 + 2];
- *p++ = 0;
- }
- _vm->_system->setPalette(palette, 0, 256);
- }
-
- tag = _fd.readUint32BE();
- if (tag == MKID_BE('FRAM')) {
- uint8 type = _fd.readByte();
- uint32 size = _fd.readUint32BE();
- debug(5, "frame %d type %d size %d", _frameNum, type, size);
-
- _fd.read(_frameBuffer2, size);
-
- switch (type) {
- case 2:
- case 3:
- decodeZlib(_frameBuffer2, size, _frameSize);
- break;
- default:
- error("decodeFrame: Unknown compression type %d", type);
- }
- if (type == 2) {
- memcpy(_frameBuffer1, _frameBuffer2, _frameSize);
- } else {
- for (int j = 0; j < _height; ++j) {
- for (int i = 0; i < _width; ++i) {
- const int offs = j * _width + i;
- _frameBuffer1[offs] ^= _frameBuffer2[offs];
- }
- }
- }
- }
+ _vm->_system->setPalette(palette, 0, 256);
}
void MoviePlayer::processFrame() {
- copyFrame(_vm->getFrontBuf(), (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2);
+ copyFrameToBuffer(_vm->getFrontBuf(), (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2, _vm->_screenWidth);
_vm->_system->copyRectToScreen(_vm->getFrontBuf(), _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum + 1) ||
@@ -447,96 +311,96 @@ void MoviePlayer::processFrame() {
}
const char * MoviePlayer::_sequenceList[90] = {
- "agent32.dxa",
- "Airlock.dxa",
- "Badluck.dxa",
- "bentalk1.dxa",
- "bentalk2.dxa",
- "bentalk3.dxa",
- "BigFight.dxa",
- "BLOWLAB.dxa",
- "breakdown.dxa",
- "bridge.dxa",
- "button2.dxa",
- "cargo.dxa",
- "COACH.dxa",
- "Colatalk.dxa",
- "cygnus2.dxa",
- "dream.dxa",
- "escape2.dxa",
- "FASALL.dxa",
- "fbikewurb.dxa",
- "feebdel.dxa",
- "Feebohno.dxa",
- "feebpump.dxa",
- "feefone1.dxa",
- "feefone2.dxa",
- "founder2.dxa",
- "founder3.dxa",
- "founder4.dxa",
- "fxmadsam.dxa",
- "fxwakeup.dxa",
- "gate.dxa",
- "Get Car.dxa",
- "getaxe.dxa",
- "getlift.dxa",
- "icetrench.dxa",
- "intomb1.dxa",
- "intomb2.dxa",
- "Jackpot.dxa",
- "knockout.dxa",
- "labocto.dxa",
- "longfeeb.dxa",
- "Mainmin.dxa",
- "maznat.dxa",
- "meetsquid.dxa",
- "mflirt.dxa",
- "mfxHappy.dxa",
- "Mix_Feeb1.dxa",
- "Mix_Feeb2.dxa",
- "Mix_Feeb3.dxa",
- "Mix_Guardscn.dxa",
- "Mlights1.dxa",
- "MLights2.dxa",
- "MProtest.dxa",
- "mudman.dxa",
- "munlock.dxa",
- "MUS5P2.dxa",
- "MUSOSP1.dxa",
- "Omenter.dxa",
- "Omnicofe.dxa",
- "OUTMIN~1.dxa",
- "Readbook.dxa",
- "Rebelhq.dxa",
- "RebelHQ2.dxa",
- "Reedin.dxa",
- "rescue1.dxa",
- "rescue2.dxa",
- "samcar.dxa",
- "Samdead.dxa",
- "scanner.dxa",
- "Sleepy.dxa",
- "spitbrai.dxa",
- "statue1.dxa",
- "statue2.dxa",
- "sva1.dxa",
- "sva2.dxa",
- "Teeter.dxa",
- "Temple2.dxa",
- "Temple3.dxa",
- "Temple4.dxa",
- "Temple5.dxa",
- "Temple6.dxa",
- "Temple7.dxa",
- "Temple8.dxa",
- "Tic-tac2.dxa",
- "torture.dxa",
- "transmit.dxa",
- "Typey.dxa",
- "ventfall.dxa",
- "ventoff.dxa",
- "wasting.dxa",
- "wurbatak.dxa"
+ "agent32",
+ "Airlock",
+ "Badluck",
+ "bentalk1",
+ "bentalk2",
+ "bentalk3",
+ "BigFight",
+ "BLOWLAB",
+ "breakdown",
+ "bridge",
+ "button2",
+ "cargo",
+ "COACH",
+ "Colatalk",
+ "cygnus2",
+ "dream",
+ "escape2",
+ "FASALL",
+ "fbikewurb",
+ "feebdel",
+ "Feebohno",
+ "feebpump",
+ "feefone1",
+ "feefone2",
+ "founder2",
+ "founder3",
+ "founder4",
+ "fxmadsam",
+ "fxwakeup",
+ "gate",
+ "Get Car",
+ "getaxe",
+ "getlift",
+ "icetrench",
+ "intomb1",
+ "intomb2",
+ "Jackpot",
+ "knockout",
+ "labocto",
+ "longfeeb",
+ "Mainmin",
+ "maznat",
+ "meetsquid",
+ "mflirt",
+ "mfxHappy",
+ "Mix_Feeb1",
+ "Mix_Feeb2",
+ "Mix_Feeb3",
+ "Mix_Guardscn",
+ "Mlights1",
+ "MLights2",
+ "MProtest",
+ "mudman",
+ "munlock",
+ "MUS5P2",
+ "MUSOSP1",
+ "Omenter",
+ "Omnicofe",
+ "OUTMIN~1",
+ "Readbook",
+ "Rebelhq",
+ "RebelHQ2",
+ "Reedin",
+ "rescue1",
+ "rescue2",
+ "samcar",
+ "Samdead",
+ "scanner",
+ "Sleepy",
+ "spitbrai",
+ "statue1",
+ "statue2",
+ "sva1",
+ "sva2",
+ "Teeter",
+ "Temple2",
+ "Temple3",
+ "Temple4",
+ "Temple5",
+ "Temple6",
+ "Temple7",
+ "Temple8",
+ "Tic-tac2",
+ "torture",
+ "transmit",
+ "Typey",
+ "ventfall",
+ "ventoff",
+ "wasting",
+ "wurbatak"
};
} // End of namespace Simon
diff --git a/engines/simon/animation.h b/engines/simon/animation.h
index 5f815ed631..782cea87a9 100644
--- a/engines/simon/animation.h
+++ b/engines/simon/animation.h
@@ -27,13 +27,14 @@
#include "common/file.h"
#include "common/stream.h"
+#include "graphics/dxa_player.h"
#include "sound/mixer.h"
namespace Simon {
class SimonEngine;
-class MoviePlayer {
+class MoviePlayer : public Graphics::DXAPlayer {
SimonEngine *_vm;
Audio::Mixer *_mixer;
@@ -42,20 +43,8 @@ class MoviePlayer {
Audio::AudioStream *_bgSoundStream;
bool _omniTV;
- bool _playing;
bool _leftButtonDown;
bool _rightButtonDown;
- Common::File _fd;
- uint8 *_frameBuffer1;
- uint8 *_frameBuffer2;
- uint16 _width;
- uint16 _height;
- uint16 _framesCount;
- uint32 _framesPerSec;
- uint16 _frameNum;
- uint32 _frameSize;
- uint16 _frameSkipped;
- uint32 _frameTicks;
uint32 _ticks;
char baseName[40];
@@ -63,21 +52,18 @@ class MoviePlayer {
uint8 _sequenceNum;
public:
MoviePlayer(SimonEngine *vm, Audio::Mixer *mixer);
- ~MoviePlayer();
bool load(const char *filename);
void play();
void nextFrame();
+protected:
+ virtual void setPalette(byte *pal);
private:
void playOmniTV();
- void close();
- void copyFrame(byte *dst, uint x, uint y);
- void decodeFrame();
void handleNextFrame();
void processFrame();
void startSound();
- void decodeZlib(uint8 *data, int size, int totalSize);
};
} // End of namespace Simon
diff --git a/graphics/animation.h b/graphics/animation.h
index 1ee6a12879..1b429ea27d 100644
--- a/graphics/animation.h
+++ b/graphics/animation.h
@@ -24,6 +24,7 @@
#define GRAPHICS_ANIMATION_H
#include "common/scummsys.h"
+
#include "sound/mixer.h"
namespace Audio {
@@ -156,7 +157,6 @@ protected:
#endif
};
-
} // End of namespace Graphics
#endif
diff --git a/graphics/dxa_player.cpp b/graphics/dxa_player.cpp
new file mode 100644
index 0000000000..18d28f6bf0
--- /dev/null
+++ b/graphics/dxa_player.cpp
@@ -0,0 +1,209 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/stdafx.h"
+#include "common/endian.h"
+#include "graphics/dxa_player.h"
+#include "common/util.h"
+
+#ifdef USE_ZLIB
+#include <zlib.h>
+#endif
+
+namespace Graphics {
+
+DXAPlayer::DXAPlayer() {
+ _frameBuffer1 = 0;
+ _frameBuffer2 = 0;
+
+ _width = 0;
+ _height = 0;
+
+ _frameSize = 0;
+ _framesCount = 0;
+ _frameNum = 0;
+ _framesPerSec = 0;
+ _frameSkipped = 0;
+ _frameTicks = 0;
+}
+
+DXAPlayer::~DXAPlayer() {
+}
+
+int DXAPlayer::getWidth() {
+ if (!_fd.isOpen())
+ return 0;
+ return _width;
+}
+
+int DXAPlayer::getHeight() {
+ if (!_fd.isOpen())
+ return 0;
+ return _height;
+}
+
+int DXAPlayer::getCurFrame() {
+ if (!_fd.isOpen())
+ return -1;
+ return _frameNum;
+}
+
+int DXAPlayer::getFrameCount() {
+ if (!_fd.isOpen())
+ return 0;
+ return _framesCount;
+}
+
+bool DXAPlayer::loadFile(const char *filename) {
+ uint32 tag;
+ int32 frameRate;
+
+ if (!_fd.open(filename)) {
+ return 0;
+ }
+
+ tag = _fd.readUint32BE();
+ assert(tag == MKID_BE('DEXA'));
+
+ _fd.readByte();
+ _framesCount = _fd.readUint16BE();
+ frameRate = _fd.readUint32BE();
+
+ if (frameRate > 0)
+ _framesPerSec = 1000 / frameRate;
+ else if (frameRate < 0)
+ _framesPerSec = 100000 / (-frameRate);
+ else
+ _framesPerSec = 10;
+
+ if (frameRate < 0)
+ _frameTicks = -frameRate / 100;
+ else
+ _frameTicks = frameRate;
+
+ _width = _fd.readUint16BE();
+ _height = _fd.readUint16BE();
+
+ debug(2, "frames_count %d width %d height %d rate %d ticks %d", _framesCount, _width, _height, _framesPerSec, _frameTicks);
+
+ _frameSize = _width * _height;
+ _frameBuffer1 = (uint8 *)malloc(_frameSize);
+ _frameBuffer2 = (uint8 *)malloc(_frameSize);
+ if (!_frameBuffer1 || !_frameBuffer2) {
+ error("error allocating frame tables, size %d\n", _frameSize);
+ }
+
+ _frameNum = 0;
+ _frameSkipped = 0;
+
+ return true;
+}
+
+void DXAPlayer::closeFile() {
+ if (!_fd.isOpen())
+ return;
+
+ _fd.close();
+ free(_frameBuffer1);
+ free(_frameBuffer2);
+}
+
+void DXAPlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
+ uint h = _height;
+ uint w = _width;
+
+ dst += y * pitch + x;
+ byte *src = _frameBuffer1;
+
+ do {
+ memcpy(dst, src, w);
+ dst += pitch;
+ src += _width;
+ } while (--h);
+}
+
+void DXAPlayer::decodeZlib(byte *data, int size, int totalSize) {
+#ifdef USE_ZLIB
+ byte *temp = (byte *)malloc(size);
+ if (temp) {
+ memcpy(temp, data, size);
+
+ z_stream d_stream;
+ d_stream.zalloc = (alloc_func)0;
+ d_stream.zfree = (free_func)0;
+ d_stream.opaque = (voidpf)0;
+ d_stream.next_in = temp;
+ d_stream.avail_in = size;
+ d_stream.total_in = size;
+ d_stream.next_out = data;
+ d_stream.avail_out = totalSize;
+ inflateInit(&d_stream);
+ inflate(&d_stream, Z_FINISH);
+ inflateEnd(&d_stream);
+ free(temp);
+ }
+#endif
+}
+
+#define BLOCKW 4
+#define BLOCKH 4
+
+void DXAPlayer::decodeNextFrame() {
+ uint32 tag;
+
+ tag = _fd.readUint32BE();
+ if (tag == MKID_BE('CMAP')) {
+ byte rgb[768];
+
+ _fd.read(rgb, ARRAYSIZE(rgb));
+ setPalette(rgb);
+ }
+
+ tag = _fd.readUint32BE();
+ if (tag == MKID_BE('FRAM')) {
+ byte type = _fd.readByte();
+ uint32 size = _fd.readUint32BE();
+
+ _fd.read(_frameBuffer2, size);
+
+ switch (type) {
+ case 2:
+ case 3:
+ decodeZlib(_frameBuffer2, size, _frameSize);
+ break;
+ default:
+ error("decodeFrame: Unknown compression type %d", type);
+ }
+ if (type == 2 || type == 4) {
+ memcpy(_frameBuffer1, _frameBuffer2, _frameSize);
+ } else {
+ for (int j = 0; j < _height; ++j) {
+ for (int i = 0; i < _width; ++i) {
+ const int offs = j * _width + i;
+ _frameBuffer1[offs] ^= _frameBuffer2[offs];
+ }
+ }
+ }
+ }
+}
+
+} // End of namespace Graphics
diff --git a/graphics/dxa_player.h b/graphics/dxa_player.h
new file mode 100644
index 0000000000..6537d743ca
--- /dev/null
+++ b/graphics/dxa_player.h
@@ -0,0 +1,116 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GRAPHICS_DXA_PLAYER_H
+#define GRAPHICS_DXA_PLAYER_H
+
+#include "common/scummsys.h"
+#include "common/file.h"
+
+namespace Common {
+ class File;
+}
+
+namespace Graphics {
+
+class DXAPlayer {
+protected:
+ Common::File _fd;
+
+ byte *_frameBuffer1;
+ byte *_frameBuffer2;
+ uint16 _width;
+ uint16 _height;
+ uint16 _framesCount;
+ uint32 _framesPerSec;
+ uint16 _frameNum;
+ uint32 _frameSize;
+ uint16 _frameSkipped;
+ uint32 _frameTicks;
+
+public:
+ DXAPlayer();
+ virtual ~DXAPlayer();
+
+ /**
+ * Returns the width of the video
+ * @return the width of the video
+ */
+ int getWidth();
+
+ /**
+ * Returns the height of the video
+ * @return the height of the video
+ */
+ int getHeight();
+
+ /**
+ * Returns the current frame number of the video
+ * @return the current frame number of the video
+ */
+ int getCurFrame();
+
+ /**
+ * Returns the amount of frames in the video
+ * @return the amount of frames in the video
+ */
+ int getFrameCount();
+
+ /**
+ * Load a DXA encoded video file
+ * @param filename the filename to load
+ */
+ bool loadFile(const char *filename);
+
+ /**
+ * Close a DXA encoded video file
+ */
+ void closeFile();
+
+protected:
+ /**
+ * Set palette, based on current frame
+ * @param pal the palette data
+ */
+ virtual void setPalette(byte *pal) = 0;
+
+ /**
+ * Copy current frame into the specified position of the destination
+ * buffer.
+ * @param dst the destination buffer
+ * @param x the x position of the frame
+ * @param y the y position of the frame
+ * @param pitch the pitch of desintation buffer
+ */
+ void copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch);
+
+ /**
+ * Decode the next frame
+ */
+ void decodeNextFrame();
+
+ void decodeZlib(byte *data, int size, int totalSize);
+};
+
+} // End of namespace Graphics
+
+#endif
diff --git a/graphics/module.mk b/graphics/module.mk
index 3479bd1bf3..104d4ea4da 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -3,6 +3,7 @@ MODULE := graphics
MODULE_OBJS := \
animation.o \
cursorman.o \
+ dxa_player.o \
font.o \
fontman.o \
fonts/consolefont.o \