Index: engines/scumm/he/animation_he.h
===================================================================
--- engines/scumm/he/animation_he.h	(revision 23331)
+++ engines/scumm/he/animation_he.h	(working copy)
@@ -25,46 +25,28 @@
 #define ANIMATION_H
 
 #include "common/file.h"
+#include "graphics/animation.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
Index: engines/scumm/he/script_v90he.cpp
===================================================================
--- engines/scumm/he/script_v90he.cpp	(revision 23331)
+++ engines/scumm/he/script_v90he.cpp	(working copy)
@@ -550,7 +550,7 @@
 			}
 		} else if (_videoParams.status == 165) {
 			// Stop video
-			_moviePlay->close();
+			_moviePlay->closeFile();
 		}
 		break;
 	default:
Index: engines/scumm/he/animation_he.cpp
===================================================================
--- engines/scumm/he/animation_he.cpp	(revision 23331)
+++ engines/scumm/he/animation_he.cpp	(working copy)
@@ -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) {
+	: DXAPlayer(), _vm(vm) {
 
-	_frameBuffer1 = 0;
-	_frameBuffer2 = 0;
-
-	_width = 0;
-	_height = 0;
-
-	_frameSize = 0;
-	_framesCount = 0;
-	_frameNum = 0;
-	_framesPerSec = 0;
-	_frameTicks = 0;
-
 	_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 @@
 	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();
 
 	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);
+		copyFrame(dst, 0, 0, _vm->_screenWidth);
 	} else if (_flags & 1) {
-		dst = pvs->getBackPixels(0, 0);
-		copyFrame(dst, 0, 0);
+		copyFrame(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);
+		copyFrame(pvs->getPixels(0, 0), 0, 0, _vm->_screenWidth);
 
 		_vm->markRectAsDirty(kMainVirtScreen, 0, 0, _width, _height);
 	}
 
 	_frameNum++;
 	if (_frameNum == _framesCount) {
-		close();
+		closeFile();
 	}
 }
 
-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) {
+	_vm->setPaletteFromPtr(pal, 256);
 }
 
-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);
-	}
-#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];
-				}
-			}
-		}
-	}
-}
-
 } // End of namespace Simon
Index: engines/simon/animation.h
===================================================================
--- engines/simon/animation.h	(revision 23331)
+++ engines/simon/animation.h	(working copy)
@@ -27,13 +27,14 @@
 #include "common/file.h"
 #include "common/stream.h"
 
+#include "graphics/animation.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 @@
 	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 @@
 	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
Index: engines/simon/animation.cpp
===================================================================
--- engines/simon/animation.cpp	(revision 23331)
+++ engines/simon/animation.cpp	(working copy)
@@ -35,43 +35,21 @@
 #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;
@@ -85,7 +63,7 @@
 	// 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) {
@@ -98,7 +76,7 @@
 			memset(baseName, 0, sizeof(baseName));
 			memcpy(baseName, shortName, 8);
 
-			if (_fd.open(shortName) == false) {
+			if (!loadFile(shortName)) {
 				error("Failed to load video file %s or %s", videoName, shortName);
 			} else {
 				debug(0, "Playing video %s", shortName);
@@ -121,45 +99,12 @@
 		}
 	}
 
-	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 +122,7 @@
 		return;
 	}
 
-	if (_fd.isOpen() == false) {
+	if (!_fd.isOpen()) {
 		return;
 	}
 
@@ -198,7 +143,7 @@
 	while (_frameNum < _framesCount)
 		handleNextFrame();
 
-	close();
+	closeFile();
 
 	_vm->o_killAnimate();
 
@@ -214,12 +159,6 @@
 	_vm->_fastFadeOutFlag = true;
 }
 
-void MoviePlayer::close() {
-	_fd.close();
-	free(_frameBuffer1);
-	free(_frameBuffer2);
-}
-
 void MoviePlayer::startSound() {
 	byte *buffer;
 	uint32 offset, size, tag;
@@ -234,7 +173,7 @@
 			_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'");
 			}
 
@@ -271,22 +210,22 @@
 
 	if (_vm->getBitFlag(42)) {
 		_omniTV = false;
-		close();
+		closeFile();
 		return;
 	}
 
 	if (_mixer->isSoundHandleActive(_bgSound) && (_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum) {
-		copyFrame(_vm->getBackBuf(), 465, 222);
+		copyFrame(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
 		return;
 	}
 
 	if (_frameNum < _framesCount) {
 		decodeFrame();
-		copyFrame(_vm->getBackBuf(), 465, 222);
+		copyFrame(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
 		_frameNum++;
 	} else {
 		_omniTV = false;
-		close();
+		closeFile();
 		_vm->_variableArray[254] = 6747;
 	}
 }
@@ -332,92 +271,22 @@
 	}
 }
 
-void MoviePlayer::copyFrame(byte *dst, uint x, uint y) {
-	uint h = _height;
-	uint w = _width;
+void MoviePlayer::setPalette(byte *pal) {
+	byte palette[1024];
+	byte *p = palette;
 
-	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);
+	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);
+	copyFrame(_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) ||
Index: graphics/animation.cpp
===================================================================
--- graphics/animation.cpp	(revision 23331)
+++ graphics/animation.cpp	(working copy)
@@ -21,6 +21,7 @@
  */
 
 #include "common/stdafx.h"
+#include "common/endian.h"
 #include "graphics/animation.h"
 #include "sound/audiostream.h"
 #include "common/config-manager.h"
@@ -29,6 +30,10 @@
 #include "common/util.h"
 #include "graphics/scaler/intern.h"
 
+#ifdef USE_ZLIB
+#include <zlib.h>
+#endif
+
 namespace Graphics {
 
 BaseAnimationState::BaseAnimationState(Audio::Mixer *snd, OSystem *sys, int width, int height)
@@ -680,4 +685,277 @@
 	_sys->updateScreen();
 }
 
+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() == false)
+		return 0;
+	return _width;
+}
+
+int DXAPlayer::getHeight() {
+	if (_fd.isOpen() == false)
+		return 0;
+	return _height;
+}
+
+int DXAPlayer::getCurFrame() {
+	if (_fd.isOpen() == false)
+		return -1;
+	return _frameNum;
+}
+
+int DXAPlayer::getFrameCount() {
+	if (_fd.isOpen() == false)
+		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(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 DXAPlayer::closeFile() {
+	if (_fd.isOpen() == false)
+		return;
+
+	_fd.close();
+	free(_frameBuffer1);
+	free(_frameBuffer2);
+}
+
+void DXAPlayer::copyFrame(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::decode12(byte *data, int size, int totalSize) {
+#ifdef USE_ZLIB
+	/* decompress the input data */
+	decodeZlib(data, size, totalSize);
+
+	byte *dat = data;
+	byte *frame2 = (byte *)malloc(totalSize);
+
+	memcpy(frame2, _frameBuffer1, totalSize);
+
+	for (int by = 0; by < _height; by += BLOCKH) {
+		for (int bx = 0; bx < _width; bx += BLOCKW) {
+			byte type = *dat++;
+			byte *b2 = frame2 + bx + by * _width;
+
+			switch (type) {
+			case 0:
+				break;
+			case 10:
+			case 11:
+			case 12:
+			case 13:
+			case 14:
+			case 15:
+			case 1:	{
+				unsigned short diffMap;
+				if (type >= 10 && type <= 15) {
+					static const struct { uint8 sh1, sh2; } shiftTbl[6] = {
+						{0, 0},	{8, 0},	{8, 8},	{8, 4},	{4, 0},	{4, 4}
+					};
+					diffMap = ((*dat & 0xF0) << shiftTbl[type-10].sh1) | 
+						  ((*dat & 0x0F) << shiftTbl[type-10].sh2);
+					dat++;
+				} else {
+					diffMap = *(unsigned short*)dat;
+					dat += 2;
+				}
+
+				for (int yc = 0; yc < BLOCKH; yc++) {
+					for (int xc = 0; xc < BLOCKW; xc++) {
+						if (diffMap & 0x8000) {
+							b2[xc] = *dat++;
+						}
+						diffMap <<= 1;
+					}
+					b2 += _width;
+				}
+				break;
+			}
+			case 2:	{
+				byte color = *dat++;
+
+				for (int yc = 0; yc < BLOCKH; yc++) {
+					for (int xc = 0; xc < BLOCKW; xc++) {
+						b2[xc] = color;
+					}
+					b2 += _width;
+				}
+				break;
+			}
+			case 3:	{
+				for (int yc = 0; yc < BLOCKH; yc++) {
+					for (int xc = 0; xc < BLOCKW; xc++) {
+						b2[xc] = *dat++;
+					}
+					b2 += _width;
+				}
+				break;
+			}
+			case 4:	{
+				byte mbyte = *dat++;
+				int mx = (mbyte >> 4) & 0x07;
+				if (mbyte & 0x80)
+					mx = -mx;
+				int my = mbyte & 0x07;
+				if (mbyte & 0x08)
+					my = -my;
+				byte *b1 = _frameBuffer1 + (bx+mx) + (by+my) * _width;
+				for (int yc = 0; yc < BLOCKH; yc++) {
+					memcpy(b2, b1, BLOCKW);
+					b1 += _width;
+					b2 += _width;
+				}
+				break;
+			}
+			case 5:
+				break;
+			}
+		}
+	}
+
+	memcpy(data, frame2, totalSize);
+	free(frame2);
+#endif
+}
+
+void DXAPlayer::decodeFrame() {
+	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;
+		case 12:
+			decode12(_frameBuffer2, size, _frameSize);
+			break;
+		default:
+			error("decodeFrame: Unknown compression type %d", type);
+		}
+		if (type == 2 || type == 4 || type == 6 || type == 12) {
+			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
Index: graphics/animation.h
===================================================================
--- graphics/animation.h	(revision 23331)
+++ graphics/animation.h	(working copy)
@@ -24,6 +24,8 @@
 #define GRAPHICS_ANIMATION_H
 
 #include "common/scummsys.h"
+#include "common/file.h"
+
 #include "sound/mixer.h"
 
 namespace Audio {
@@ -156,7 +158,42 @@
 #endif
 };
 
+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();
+
+	int getWidth();
+	int getHeight();
+	int getCurFrame();
+	int getFrameCount();
+
+	bool loadFile(const char *filename);
+	void closeFile();
+
+protected:
+	virtual void setPalette(byte *pal) = 0;
+
+	void copyFrame(byte *dst, uint x, uint y, uint pitch);
+	void decodeFrame();
+	void decodeZlib(byte *data, int size, int totalSize);
+	void decode12(byte *data, int size, int totalSize);
+};
+ 
 } // End of namespace Graphics
 
 #endif
