[Scummvm-cvs-logs] SF.net SVN: scummvm:[44326] scummvm/trunk

spalek at users.sourceforge.net spalek at users.sourceforge.net
Fri Sep 25 08:22:54 CEST 2009


Revision: 44326
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44326&view=rev
Author:   spalek
Date:     2009-09-25 06:22:54 +0000 (Fri, 25 Sep 2009)

Log Message:
-----------
MERGE branch gsoc2009-draci 41388:44325 into trunk

Modified Paths:
--------------
    scummvm/trunk/base/plugins.cpp
    scummvm/trunk/configure
    scummvm/trunk/engines/engines.mk

Added Paths:
-----------
    scummvm/trunk/engines/draci/
    scummvm/trunk/engines/draci/animation.cpp
    scummvm/trunk/engines/draci/animation.h
    scummvm/trunk/engines/draci/barchive.cpp
    scummvm/trunk/engines/draci/barchive.h
    scummvm/trunk/engines/draci/detection.cpp
    scummvm/trunk/engines/draci/draci.cpp
    scummvm/trunk/engines/draci/draci.h
    scummvm/trunk/engines/draci/font.cpp
    scummvm/trunk/engines/draci/font.h
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/game.h
    scummvm/trunk/engines/draci/module.mk
    scummvm/trunk/engines/draci/mouse.cpp
    scummvm/trunk/engines/draci/mouse.h
    scummvm/trunk/engines/draci/screen.cpp
    scummvm/trunk/engines/draci/screen.h
    scummvm/trunk/engines/draci/script.cpp
    scummvm/trunk/engines/draci/script.h
    scummvm/trunk/engines/draci/sprite.cpp
    scummvm/trunk/engines/draci/sprite.h
    scummvm/trunk/engines/draci/surface.cpp
    scummvm/trunk/engines/draci/surface.h

Removed Paths:
-------------
    scummvm/trunk/engines/draci/animation.cpp
    scummvm/trunk/engines/draci/animation.h
    scummvm/trunk/engines/draci/barchive.cpp
    scummvm/trunk/engines/draci/barchive.h
    scummvm/trunk/engines/draci/detection.cpp
    scummvm/trunk/engines/draci/draci.cpp
    scummvm/trunk/engines/draci/draci.h
    scummvm/trunk/engines/draci/font.cpp
    scummvm/trunk/engines/draci/font.h
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/game.h
    scummvm/trunk/engines/draci/module.mk
    scummvm/trunk/engines/draci/mouse.cpp
    scummvm/trunk/engines/draci/mouse.h
    scummvm/trunk/engines/draci/screen.cpp
    scummvm/trunk/engines/draci/screen.h
    scummvm/trunk/engines/draci/script.cpp
    scummvm/trunk/engines/draci/script.h
    scummvm/trunk/engines/draci/sprite.cpp
    scummvm/trunk/engines/draci/sprite.h
    scummvm/trunk/engines/draci/surface.cpp
    scummvm/trunk/engines/draci/surface.h

Property Changed:
----------------
    scummvm/trunk/


Property changes on: scummvm/trunk
___________________________________________________________________
Added: svn:mergeinfo
   + /scummvm/branches/gsoc2009-draci:41389-44325

Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/base/plugins.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -160,6 +160,9 @@
 		#if PLUGIN_ENABLED_STATIC(TUCKER)
 		LINK_PLUGIN(TUCKER)
 		#endif
+		#if PLUGIN_ENABLED_STATIC(DRACI)
+		LINK_PLUGIN(DRACI)
+		#endif
 
 		// Music plugins
 		// TODO: Use defines to disable or enable each MIDI driver as a

Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/configure	2009-09-25 06:22:54 UTC (rev 44326)
@@ -83,6 +83,7 @@
 add_engine agos2 "AGOS 2 games" yes
 add_engine cine "Cinematique evo 1" yes
 add_engine cruise "Cinematique evo 2" yes
+add_engine draci "Dragon History" no
 add_engine drascula "Drascula: The Vampire Strikes Back" yes
 add_engine gob "Gobli*ns" yes
 add_engine groovie "Groovie" yes "groovie2"

Deleted: scummvm/trunk/engines/draci/animation.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/engines/draci/animation.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -1,647 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 "draci/draci.h"
-#include "draci/animation.h"
-
-namespace Draci {
-
-Animation::Animation(DraciEngine *vm, int index) : _vm(vm) {
-	_id = kUnused;
-	_index = index;
-	_z = 0;
-	_relX = 0;
-	_relY = 0;
-	_scaleX = 1.0;
-	_scaleY = 1.0;
-	_playing = false;
-	_looping = false;
-	_paused = false;
-	_tick = _vm->_system->getMillis();
-	_currentFrame = 0;
-	_callback = &Animation::doNothing;
-}	
-
-Animation::~Animation() {
-	deleteFrames();
-}
-
-bool Animation::isLooping() {
-	return _looping;
-}
-
-void Animation::setRelative(int relx, int rely) {
-
-	// Delete the previous frame if there is one
-	if (_frames.size() > 0)	
-		markDirtyRect(_vm->_screen->getSurface());
-
-	_relX = relx;
-	_relY = rely;
-}
-
-void Animation::setLooping(bool looping) {
-	_looping = looping;
-	debugC(7, kDraciAnimationDebugLevel, "Setting looping to %d on animation %d", 
-		looping, _id);
-}
-
-void Animation::markDirtyRect(Surface *surface) {
-	// Fetch the current frame's rectangle
-	Drawable *frame = _frames[_currentFrame];
-	Common::Rect frameRect = frame->getRect();			
-
-	// Translate rectangle to compensate for relative coordinates	
-	frameRect.translate(_relX, _relY);
-	
-	// Take animation scaling into account
-	frameRect.setWidth(frameRect.width() * _scaleX);
-	frameRect.setHeight(frameRect.height() * _scaleY);
-
-	// Mark the rectangle dirty on the surface
-	surface->markDirtyRect(frameRect);
-}	
-
-void Animation::nextFrame(bool force) {
-
-	// If there are no frames or if the animation is not playing, return
-	if (getFrameCount() == 0 || !_playing)
-		return;
-
-	Drawable *frame = _frames[_currentFrame];
-	Surface *surface = _vm->_screen->getSurface();
-	
-	if (force || (_tick + frame->getDelay() <= _vm->_system->getMillis())) {
-		// If we are at the last frame and not looping, stop the animation
-		// The animation is also restarted to frame zero
-		if ((_currentFrame == getFrameCount() - 1) && !_looping) {
-			// When the animation reaches its end, call the preset callback
-			(this->*_callback)();
-		} else {
-			// Mark old frame dirty so it gets deleted
-			markDirtyRect(surface);
-
-			_currentFrame = nextFrameNum();
-			_tick = _vm->_system->getMillis();
-
-			// Fetch new frame and mark it dirty
-			markDirtyRect(surface);
-		}
-	}
-
-	debugC(6, kDraciAnimationDebugLevel, 
-	"anim=%d tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d x=%d y=%d", 
-	_id, _tick, frame->getDelay(), _tick + frame->getDelay(), _vm->_system->getMillis(), 
-	_currentFrame, _frames.size(), frame->getX(), frame->getY());
-}
-
-uint Animation::nextFrameNum() {
-
-	if (_paused) 
-		return _currentFrame;
-
-	if ((_currentFrame == getFrameCount() - 1) && _looping)
-		return 0;
-	else
-		return _currentFrame + 1;
-}
-
-void Animation::drawFrame(Surface *surface) {
-	
-	// If there are no frames or the animation is not playing, return
-	if (_frames.size() == 0 || !_playing)
-		return;
-
-	Drawable *frame = _frames[_currentFrame];
-
-	if (_id == kOverlayImage) {			
-		frame->draw(surface, false);
-	} else {
-
-		int x = frame->getX();
-		int y = frame->getY();
-
-		// Take account relative coordinates
-		int newX = x + _relX;
-		int newY = y + _relY;
-
-		// Translate the frame to those relative coordinates
-		frame->setX(newX);
-		frame->setY(newY);
-
-		// Save scaled width and height
-		int scaledWidth = frame->getScaledWidth();
-		int scaledHeight = frame->getScaledHeight();
-
-		// Take into account per-animation scaling and adjust the current frames dimensions	
-		if (_scaleX != 1.0 || _scaleY != 1.0)
-			frame->setScaled(scaledWidth * _scaleX, scaledHeight * _scaleY);
-
-		// Draw frame
-		frame->drawScaled(surface, false);
-
-		// Revert back to old coordinates
-		frame->setX(x);
-		frame->setY(y);
-
-		// Revert back to old dimensions
-		frame->setScaled(scaledWidth, scaledHeight);
-	}
-}
-
-void Animation::setID(int id) {
-	_id = id;
-}
-
-int Animation::getID() {
-	return _id;
-}
-
-void Animation::setZ(uint z) {
-	_z = z;
-}
-
-uint Animation::getZ() {
-	return _z;
-}
-
-int Animation::getRelativeX() {
-	return _relX;
-}
-
-int Animation::getRelativeY() {
-	return _relY;
-}
-
-bool Animation::isPlaying() {
-	return _playing;
-}
-
-void Animation::setPlaying(bool playing) {
-	_tick = _vm->_system->getMillis();
-	_playing = playing;
-}
-
-bool Animation::isPaused() {
-	return _paused;
-}
-
-void Animation::setPaused(bool paused) {
-	_paused = paused;
-}
-
-void Animation::setScaleFactors(double scaleX, double scaleY) {
-	
-	debugC(5, kDraciAnimationDebugLevel, 
-		"Setting scaling factors on anim %d (scaleX: %.3f scaleY: %.3f)", 
-		_id, scaleX, scaleY);
-
-	markDirtyRect(_vm->_screen->getSurface());	
-	
-	_scaleX = scaleX;
-	_scaleY = scaleY;
-}
-
-double Animation::getScaleX() {
-	return _scaleX;
-}
-
-double Animation::getScaleY() {
-	return _scaleY;
-}
-
-void Animation::addFrame(Drawable *frame) {
-	_frames.push_back(frame);	
-}
-
-int Animation::getIndex() {
-	return _index;
-}
-
-void Animation::setIndex(int index) {
-	_index = index;
-}
-
-Drawable *Animation::getFrame(int frameNum) {
-
-	// If there are no frames stored, return NULL
-	if (_frames.size() == 0) {
-		return NULL;
-	}
-
-	// If no argument is passed, return the current frame
-	if (frameNum == kCurrentFrame) {
-		return _frames[_currentFrame];
-	} else {
-		return _frames[frameNum];
-	}
-}
-
-uint Animation::getFrameCount() {
-	return _frames.size();
-}
-
-uint Animation::currentFrameNum() {
-	return _currentFrame;
-}
-
-void Animation::setCurrentFrame(uint frame) {
-
-	// Check whether the value is sane
-	if (frame >= _frames.size()) {
-		return;
-	}
-
-	_currentFrame = frame;
-}
-
-void Animation::deleteFrames() {
-	
-	// If there are no frames to delete, return
-	if (_frames.size() == 0) {
-		return;
-	}
-
-	markDirtyRect(_vm->_screen->getSurface());
-
-	for (int i = getFrameCount() - 1; i >= 0; --i) {		
-		delete _frames[i];
-		_frames.pop_back();	
-	}
-}
-
-void Animation::stopAnimation() { 
-	_vm->_anims->stop(_id);
-}
-
-void Animation::exitGameLoop() { 
-	_vm->_game->setExitLoop(true);
-}
-
-Animation *AnimationManager::addAnimation(int id, uint z, bool playing) {
-	
-	// Increment animation index
-	++_lastIndex;
-
-	Animation *anim = new Animation(_vm, _lastIndex);
-	
-	anim->setID(id);
-	anim->setZ(z);
-	anim->setPlaying(playing);
-
-	insertAnimation(anim);
-
-	return anim;
-}
-
-Animation *AnimationManager::addItem(int id, bool playing) {
-
-	Animation *anim = new Animation(_vm, kIgnoreIndex);
-
-	anim->setID(id);
-	anim->setZ(256);
-	anim->setPlaying(playing);
-
-	insertAnimation(anim);
-
-	return anim;
-}
-
-Animation *AnimationManager::addText(int id, bool playing) {
-
-	Animation *anim = new Animation(_vm, kIgnoreIndex);
-
-	anim->setID(id);
-	anim->setZ(257);
-	anim->setPlaying(playing);
-
-	insertAnimation(anim);
-
-	return anim;
-}
-
-void AnimationManager::play(int id) {
-	Animation *anim = getAnimation(id);
-
-	if (anim) {
-		// Mark the first frame dirty so it gets displayed
-		anim->markDirtyRect(_vm->_screen->getSurface());
-
-		anim->setPlaying(true);
-
-		debugC(3, kDraciAnimationDebugLevel, "Playing animation %d...", id);
-	}
-}
-
-void AnimationManager::stop(int id) {
-	Animation *anim = getAnimation(id);
-	
-	if (anim) {
-		// Clean up the last frame that was drawn before stopping
-		anim->markDirtyRect(_vm->_screen->getSurface());
-
-		anim->setPlaying(false);
-
-		// Reset the animation to the beginning
-		anim->setCurrentFrame(0);
-	
-		debugC(3, kDraciAnimationDebugLevel, "Stopping animation %d...", id);
-	}
-}
-
-void AnimationManager::pauseAnimations() {
-
-	Common::List<Animation *>::iterator it;
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if ((*it)->getID() > 0 || (*it)->getID() == kTitleText) {
-			// Clean up the last frame that was drawn before stopping
-			(*it)->markDirtyRect(_vm->_screen->getSurface());
-
-			(*it)->setPaused(true);
-		}
-	}
-}
-
-void AnimationManager::unpauseAnimations() {
-
-	Common::List<Animation *>::iterator it;
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if ((*it)->isPaused()) {
-			// Clean up the last frame that was drawn before stopping
-			(*it)->markDirtyRect(_vm->_screen->getSurface());
-
-			(*it)->setPaused(false);
-		}
-	}
-}
-
-Animation *AnimationManager::getAnimation(int id) {
-	
-	Common::List<Animation *>::iterator it;
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if ((*it)->getID() == id) {
-			return *it;
-		}
-	}
-
-	return NULL;
-}
-
-void AnimationManager::insertAnimation(Animation *animObj) {
-	
-	Common::List<Animation *>::iterator it;	
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if (animObj->getZ() < (*it)->getZ()) 
-			break;
-	}
-
-	_animations.insert(it, animObj);
-}
-
-void AnimationManager::addOverlay(Drawable *overlay, uint z) {
-	// Since this is an overlay, we don't need it to be deleted 
-	// when the GPL Release command is invoked so we pass the index
-	// as kIgnoreIndex
-	Animation *anim = new Animation(_vm, kIgnoreIndex);
-	
-	anim->setID(kOverlayImage);
-	anim->setZ(z);
-	anim->setPlaying(true);
-	anim->addFrame(overlay);
-
-	insertAnimation(anim);
-}
-
-void AnimationManager::drawScene(Surface *surf) {
-
-	// Fill the screen with colour zero since some rooms may rely on the screen being black	
-	_vm->_screen->getSurface()->fill(0);
-
-	sortAnimations();
-
-	Common::List<Animation *>::iterator it;
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if (! ((*it)->isPlaying()) ) {
-			continue;
-		}	
-	
-		(*it)->nextFrame();
-		(*it)->drawFrame(surf);
-	}
-}
-
-void AnimationManager::sortAnimations() {
-	Common::List<Animation *>::iterator cur;
-	Common::List<Animation *>::iterator next;
-
-	cur = _animations.begin();
-
-	// If the list is empty, we're done
-	if (cur == _animations.end())
-		return;	
-
-	while(1) {
-		next = cur;
-		next++;
-
-		// If we are at the last element, we're done
-		if (next == _animations.end())
-			break;
-
-		// If we find an animation out of order, reinsert it
-		if ((*next)->getZ() < (*cur)->getZ()) {
-
-			Animation *anim = *next;
-			_animations.erase(next);
-
-			insertAnimation(anim);
-		}
-
-		// Advance to next animation
-		cur = next;
-	}
-}
-
-void AnimationManager::deleteAnimation(int id) {
-	
-	Common::List<Animation *>::iterator it;
-  
-	int index = -1;
-
-	// Iterate for the first time to delete the animation
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if ((*it)->getID() == id) {
-			(*it)->deleteFrames();
-			_animations.erase(it);
-
-			// Remember index of the deleted animation
-			index = (*it)->getIndex();
-
-			debugC(3, kDraciAnimationDebugLevel, "Deleting animation %d...", id);
-
-			break;
-		}
-	}
-
-	// Iterate the second time to decrease indexes greater than the deleted animation index
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if ((*it)->getIndex() == index && (*it)->getIndex() != kIgnoreIndex) {
-			(*it)->setIndex(index-1);
-		}
-	}
-
-	// Decrement index of last animation 
-	_lastIndex -= 1;
-}
-
-void AnimationManager::deleteOverlays() {
-	
-	debugC(3, kDraciAnimationDebugLevel, "Deleting overlays...");
-
-	Common::List<Animation *>::iterator it;
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if ((*it)->getID() == kOverlayImage) {
-			(*it)->deleteFrames();
-			_animations.erase(it);
-		}	
-	}
-}
-
-void AnimationManager::deleteAll() {
-
-	debugC(3, kDraciAnimationDebugLevel, "Deleting all animations...");
-
-	Common::List<Animation *>::iterator it;
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		(*it)->deleteFrames();	
-	}
-
-	_animations.clear();
-
-	_lastIndex = -1;
-}
-
-int AnimationManager::getLastIndex() {
-	return _lastIndex;
-}
-
-void AnimationManager::deleteAfterIndex(int index) {
-
-	Common::List<Animation *>::iterator it;
-
-	for (it = _animations.begin(); it != _animations.end(); ++it) {
-		if ((*it)->getIndex() > index) {
-
-			debugC(3, kDraciAnimationDebugLevel, "Deleting animation %d...", (*it)->getID());
-
-			(*it)->deleteFrames();
-			_animations.erase(it);
-		}
-	}
-	
-	_lastIndex = index;
-}
-
-int AnimationManager::getTopAnimationID(int x, int y) {
-
-	Common::List<Animation *>::iterator it;
-
-	// The default return value if no animations were found on these coordinates (not even overlays)
-	// i.e. the black background shows through so treat it as an overlay
-	int retval = kOverlayImage;
-
-	// Get transparent colour for the current screen
-	const int transparent = _vm->_screen->getSurface()->getTransparentColour();
-
-	for (it = _animations.reverse_begin(); it != _animations.end(); --it) {
-
-		Animation *anim = *it;
-
-		// If the animation is not playing, ignore it
-		if (!anim->isPlaying() || anim->isPaused()) {
-			continue;
-		}
-
-		Drawable *frame = anim->getFrame();
-
-		if (frame == NULL) {
-			continue;
-		}
-
-		int oldX = frame->getX();
-		int oldY = frame->getY();
-
-		// Take account relative coordinates
-		int newX = oldX + anim->getRelativeX();
-		int newY = oldY + anim->getRelativeY();
-
-		// Translate the frame to those relative coordinates
-		frame->setX(newX);
-		frame->setY(newY);
-
-		// Save scaled width and height
-		int scaledWidth = frame->getScaledWidth();
-		int scaledHeight = frame->getScaledHeight();
-
-		// Take into account per-animation scaling and adjust the current frames dimensions	
-		if (anim->getScaleX() != 1.0 || anim->getScaleY() != 1.0)
-			frame->setScaled(scaledWidth * anim->getScaleX(), scaledHeight * anim->getScaleY());
-
-		if (frame->getRect().contains(x, y)) {
-
-			if (frame->getType() == kDrawableText) {
-
-				retval = anim->getID();
-
-			} else if (frame->getType() == kDrawableSprite && 
-					   reinterpret_cast<Sprite *>(frame)->getPixel(x, y) != transparent) {
-
-				retval = anim->getID();
-			}	
-		}
-
-		// Revert back to old coordinates
-		frame->setX(oldX);
-		frame->setY(oldY);
-
-		// Revert back to old dimensions
-		frame->setScaled(scaledWidth, scaledHeight);
-
-		// Found an animation
-		if (retval != kOverlayImage)
-			break;
-	}
-
-	return retval;
-}
-			
-}

Copied: scummvm/trunk/engines/draci/animation.cpp (from rev 44325, scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp)
===================================================================
--- scummvm/trunk/engines/draci/animation.cpp	                        (rev 0)
+++ scummvm/trunk/engines/draci/animation.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -0,0 +1,647 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 "draci/draci.h"
+#include "draci/animation.h"
+
+namespace Draci {
+
+Animation::Animation(DraciEngine *vm, int index) : _vm(vm) {
+	_id = kUnused;
+	_index = index;
+	_z = 0;
+	_relX = 0;
+	_relY = 0;
+	_scaleX = 1.0;
+	_scaleY = 1.0;
+	_playing = false;
+	_looping = false;
+	_paused = false;
+	_tick = _vm->_system->getMillis();
+	_currentFrame = 0;
+	_callback = &Animation::doNothing;
+}	
+
+Animation::~Animation() {
+	deleteFrames();
+}
+
+bool Animation::isLooping() {
+	return _looping;
+}
+
+void Animation::setRelative(int relx, int rely) {
+
+	// Delete the previous frame if there is one
+	if (_frames.size() > 0)	
+		markDirtyRect(_vm->_screen->getSurface());
+
+	_relX = relx;
+	_relY = rely;
+}
+
+void Animation::setLooping(bool looping) {
+	_looping = looping;
+	debugC(7, kDraciAnimationDebugLevel, "Setting looping to %d on animation %d", 
+		looping, _id);
+}
+
+void Animation::markDirtyRect(Surface *surface) {
+	// Fetch the current frame's rectangle
+	Drawable *frame = _frames[_currentFrame];
+	Common::Rect frameRect = frame->getRect();			
+
+	// Translate rectangle to compensate for relative coordinates	
+	frameRect.translate(_relX, _relY);
+	
+	// Take animation scaling into account
+	frameRect.setWidth(frameRect.width() * _scaleX);
+	frameRect.setHeight(frameRect.height() * _scaleY);
+
+	// Mark the rectangle dirty on the surface
+	surface->markDirtyRect(frameRect);
+}	
+
+void Animation::nextFrame(bool force) {
+
+	// If there are no frames or if the animation is not playing, return
+	if (getFrameCount() == 0 || !_playing)
+		return;
+
+	Drawable *frame = _frames[_currentFrame];
+	Surface *surface = _vm->_screen->getSurface();
+	
+	if (force || (_tick + frame->getDelay() <= _vm->_system->getMillis())) {
+		// If we are at the last frame and not looping, stop the animation
+		// The animation is also restarted to frame zero
+		if ((_currentFrame == getFrameCount() - 1) && !_looping) {
+			// When the animation reaches its end, call the preset callback
+			(this->*_callback)();
+		} else {
+			// Mark old frame dirty so it gets deleted
+			markDirtyRect(surface);
+
+			_currentFrame = nextFrameNum();
+			_tick = _vm->_system->getMillis();
+
+			// Fetch new frame and mark it dirty
+			markDirtyRect(surface);
+		}
+	}
+
+	debugC(6, kDraciAnimationDebugLevel, 
+	"anim=%d tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d x=%d y=%d", 
+	_id, _tick, frame->getDelay(), _tick + frame->getDelay(), _vm->_system->getMillis(), 
+	_currentFrame, _frames.size(), frame->getX(), frame->getY());
+}
+
+uint Animation::nextFrameNum() {
+
+	if (_paused) 
+		return _currentFrame;
+
+	if ((_currentFrame == getFrameCount() - 1) && _looping)
+		return 0;
+	else
+		return _currentFrame + 1;
+}
+
+void Animation::drawFrame(Surface *surface) {
+	
+	// If there are no frames or the animation is not playing, return
+	if (_frames.size() == 0 || !_playing)
+		return;
+
+	Drawable *frame = _frames[_currentFrame];
+
+	if (_id == kOverlayImage) {			
+		frame->draw(surface, false);
+	} else {
+
+		int x = frame->getX();
+		int y = frame->getY();
+
+		// Take account relative coordinates
+		int newX = x + _relX;
+		int newY = y + _relY;
+
+		// Translate the frame to those relative coordinates
+		frame->setX(newX);
+		frame->setY(newY);
+
+		// Save scaled width and height
+		int scaledWidth = frame->getScaledWidth();
+		int scaledHeight = frame->getScaledHeight();
+
+		// Take into account per-animation scaling and adjust the current frames dimensions	
+		if (_scaleX != 1.0 || _scaleY != 1.0)
+			frame->setScaled(scaledWidth * _scaleX, scaledHeight * _scaleY);
+
+		// Draw frame
+		frame->drawScaled(surface, false);
+
+		// Revert back to old coordinates
+		frame->setX(x);
+		frame->setY(y);
+
+		// Revert back to old dimensions
+		frame->setScaled(scaledWidth, scaledHeight);
+	}
+}
+
+void Animation::setID(int id) {
+	_id = id;
+}
+
+int Animation::getID() {
+	return _id;
+}
+
+void Animation::setZ(uint z) {
+	_z = z;
+}
+
+uint Animation::getZ() {
+	return _z;
+}
+
+int Animation::getRelativeX() {
+	return _relX;
+}
+
+int Animation::getRelativeY() {
+	return _relY;
+}
+
+bool Animation::isPlaying() {
+	return _playing;
+}
+
+void Animation::setPlaying(bool playing) {
+	_tick = _vm->_system->getMillis();
+	_playing = playing;
+}
+
+bool Animation::isPaused() {
+	return _paused;
+}
+
+void Animation::setPaused(bool paused) {
+	_paused = paused;
+}
+
+void Animation::setScaleFactors(double scaleX, double scaleY) {
+	
+	debugC(5, kDraciAnimationDebugLevel, 
+		"Setting scaling factors on anim %d (scaleX: %.3f scaleY: %.3f)", 
+		_id, scaleX, scaleY);
+
+	markDirtyRect(_vm->_screen->getSurface());	
+	
+	_scaleX = scaleX;
+	_scaleY = scaleY;
+}
+
+double Animation::getScaleX() {
+	return _scaleX;
+}
+
+double Animation::getScaleY() {
+	return _scaleY;
+}
+
+void Animation::addFrame(Drawable *frame) {
+	_frames.push_back(frame);	
+}
+
+int Animation::getIndex() {
+	return _index;
+}
+
+void Animation::setIndex(int index) {
+	_index = index;
+}
+
+Drawable *Animation::getFrame(int frameNum) {
+
+	// If there are no frames stored, return NULL
+	if (_frames.size() == 0) {
+		return NULL;
+	}
+
+	// If no argument is passed, return the current frame
+	if (frameNum == kCurrentFrame) {
+		return _frames[_currentFrame];
+	} else {
+		return _frames[frameNum];
+	}
+}
+
+uint Animation::getFrameCount() {
+	return _frames.size();
+}
+
+uint Animation::currentFrameNum() {
+	return _currentFrame;
+}
+
+void Animation::setCurrentFrame(uint frame) {
+
+	// Check whether the value is sane
+	if (frame >= _frames.size()) {
+		return;
+	}
+
+	_currentFrame = frame;
+}
+
+void Animation::deleteFrames() {
+	
+	// If there are no frames to delete, return
+	if (_frames.size() == 0) {
+		return;
+	}
+
+	markDirtyRect(_vm->_screen->getSurface());
+
+	for (int i = getFrameCount() - 1; i >= 0; --i) {		
+		delete _frames[i];
+		_frames.pop_back();	
+	}
+}
+
+void Animation::stopAnimation() { 
+	_vm->_anims->stop(_id);
+}
+
+void Animation::exitGameLoop() { 
+	_vm->_game->setExitLoop(true);
+}
+
+Animation *AnimationManager::addAnimation(int id, uint z, bool playing) {
+	
+	// Increment animation index
+	++_lastIndex;
+
+	Animation *anim = new Animation(_vm, _lastIndex);
+	
+	anim->setID(id);
+	anim->setZ(z);
+	anim->setPlaying(playing);
+
+	insertAnimation(anim);
+
+	return anim;
+}
+
+Animation *AnimationManager::addItem(int id, bool playing) {
+
+	Animation *anim = new Animation(_vm, kIgnoreIndex);
+
+	anim->setID(id);
+	anim->setZ(256);
+	anim->setPlaying(playing);
+
+	insertAnimation(anim);
+
+	return anim;
+}
+
+Animation *AnimationManager::addText(int id, bool playing) {
+
+	Animation *anim = new Animation(_vm, kIgnoreIndex);
+
+	anim->setID(id);
+	anim->setZ(257);
+	anim->setPlaying(playing);
+
+	insertAnimation(anim);
+
+	return anim;
+}
+
+void AnimationManager::play(int id) {
+	Animation *anim = getAnimation(id);
+
+	if (anim) {
+		// Mark the first frame dirty so it gets displayed
+		anim->markDirtyRect(_vm->_screen->getSurface());
+
+		anim->setPlaying(true);
+
+		debugC(3, kDraciAnimationDebugLevel, "Playing animation %d...", id);
+	}
+}
+
+void AnimationManager::stop(int id) {
+	Animation *anim = getAnimation(id);
+	
+	if (anim) {
+		// Clean up the last frame that was drawn before stopping
+		anim->markDirtyRect(_vm->_screen->getSurface());
+
+		anim->setPlaying(false);
+
+		// Reset the animation to the beginning
+		anim->setCurrentFrame(0);
+	
+		debugC(3, kDraciAnimationDebugLevel, "Stopping animation %d...", id);
+	}
+}
+
+void AnimationManager::pauseAnimations() {
+
+	Common::List<Animation *>::iterator it;
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if ((*it)->getID() > 0 || (*it)->getID() == kTitleText) {
+			// Clean up the last frame that was drawn before stopping
+			(*it)->markDirtyRect(_vm->_screen->getSurface());
+
+			(*it)->setPaused(true);
+		}
+	}
+}
+
+void AnimationManager::unpauseAnimations() {
+
+	Common::List<Animation *>::iterator it;
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if ((*it)->isPaused()) {
+			// Clean up the last frame that was drawn before stopping
+			(*it)->markDirtyRect(_vm->_screen->getSurface());
+
+			(*it)->setPaused(false);
+		}
+	}
+}
+
+Animation *AnimationManager::getAnimation(int id) {
+	
+	Common::List<Animation *>::iterator it;
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if ((*it)->getID() == id) {
+			return *it;
+		}
+	}
+
+	return NULL;
+}
+
+void AnimationManager::insertAnimation(Animation *animObj) {
+	
+	Common::List<Animation *>::iterator it;	
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if (animObj->getZ() < (*it)->getZ()) 
+			break;
+	}
+
+	_animations.insert(it, animObj);
+}
+
+void AnimationManager::addOverlay(Drawable *overlay, uint z) {
+	// Since this is an overlay, we don't need it to be deleted 
+	// when the GPL Release command is invoked so we pass the index
+	// as kIgnoreIndex
+	Animation *anim = new Animation(_vm, kIgnoreIndex);
+	
+	anim->setID(kOverlayImage);
+	anim->setZ(z);
+	anim->setPlaying(true);
+	anim->addFrame(overlay);
+
+	insertAnimation(anim);
+}
+
+void AnimationManager::drawScene(Surface *surf) {
+
+	// Fill the screen with colour zero since some rooms may rely on the screen being black	
+	_vm->_screen->getSurface()->fill(0);
+
+	sortAnimations();
+
+	Common::List<Animation *>::iterator it;
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if (! ((*it)->isPlaying()) ) {
+			continue;
+		}	
+	
+		(*it)->nextFrame();
+		(*it)->drawFrame(surf);
+	}
+}
+
+void AnimationManager::sortAnimations() {
+	Common::List<Animation *>::iterator cur;
+	Common::List<Animation *>::iterator next;
+
+	cur = _animations.begin();
+
+	// If the list is empty, we're done
+	if (cur == _animations.end())
+		return;	
+
+	while(1) {
+		next = cur;
+		next++;
+
+		// If we are at the last element, we're done
+		if (next == _animations.end())
+			break;
+
+		// If we find an animation out of order, reinsert it
+		if ((*next)->getZ() < (*cur)->getZ()) {
+
+			Animation *anim = *next;
+			_animations.erase(next);
+
+			insertAnimation(anim);
+		}
+
+		// Advance to next animation
+		cur = next;
+	}
+}
+
+void AnimationManager::deleteAnimation(int id) {
+	
+	Common::List<Animation *>::iterator it;
+  
+	int index = -1;
+
+	// Iterate for the first time to delete the animation
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if ((*it)->getID() == id) {
+			(*it)->deleteFrames();
+			_animations.erase(it);
+
+			// Remember index of the deleted animation
+			index = (*it)->getIndex();
+
+			debugC(3, kDraciAnimationDebugLevel, "Deleting animation %d...", id);
+
+			break;
+		}
+	}
+
+	// Iterate the second time to decrease indexes greater than the deleted animation index
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if ((*it)->getIndex() == index && (*it)->getIndex() != kIgnoreIndex) {
+			(*it)->setIndex(index-1);
+		}
+	}
+
+	// Decrement index of last animation 
+	_lastIndex -= 1;
+}
+
+void AnimationManager::deleteOverlays() {
+	
+	debugC(3, kDraciAnimationDebugLevel, "Deleting overlays...");
+
+	Common::List<Animation *>::iterator it;
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if ((*it)->getID() == kOverlayImage) {
+			(*it)->deleteFrames();
+			_animations.erase(it);
+		}	
+	}
+}
+
+void AnimationManager::deleteAll() {
+
+	debugC(3, kDraciAnimationDebugLevel, "Deleting all animations...");
+
+	Common::List<Animation *>::iterator it;
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		(*it)->deleteFrames();	
+	}
+
+	_animations.clear();
+
+	_lastIndex = -1;
+}
+
+int AnimationManager::getLastIndex() {
+	return _lastIndex;
+}
+
+void AnimationManager::deleteAfterIndex(int index) {
+
+	Common::List<Animation *>::iterator it;
+
+	for (it = _animations.begin(); it != _animations.end(); ++it) {
+		if ((*it)->getIndex() > index) {
+
+			debugC(3, kDraciAnimationDebugLevel, "Deleting animation %d...", (*it)->getID());
+
+			(*it)->deleteFrames();
+			_animations.erase(it);
+		}
+	}
+	
+	_lastIndex = index;
+}
+
+int AnimationManager::getTopAnimationID(int x, int y) {
+
+	Common::List<Animation *>::iterator it;
+
+	// The default return value if no animations were found on these coordinates (not even overlays)
+	// i.e. the black background shows through so treat it as an overlay
+	int retval = kOverlayImage;
+
+	// Get transparent colour for the current screen
+	const int transparent = _vm->_screen->getSurface()->getTransparentColour();
+
+	for (it = _animations.reverse_begin(); it != _animations.end(); --it) {
+
+		Animation *anim = *it;
+
+		// If the animation is not playing, ignore it
+		if (!anim->isPlaying() || anim->isPaused()) {
+			continue;
+		}
+
+		Drawable *frame = anim->getFrame();
+
+		if (frame == NULL) {
+			continue;
+		}
+
+		int oldX = frame->getX();
+		int oldY = frame->getY();
+
+		// Take account relative coordinates
+		int newX = oldX + anim->getRelativeX();
+		int newY = oldY + anim->getRelativeY();
+
+		// Translate the frame to those relative coordinates
+		frame->setX(newX);
+		frame->setY(newY);
+
+		// Save scaled width and height
+		int scaledWidth = frame->getScaledWidth();
+		int scaledHeight = frame->getScaledHeight();
+
+		// Take into account per-animation scaling and adjust the current frames dimensions	
+		if (anim->getScaleX() != 1.0 || anim->getScaleY() != 1.0)
+			frame->setScaled(scaledWidth * anim->getScaleX(), scaledHeight * anim->getScaleY());
+
+		if (frame->getRect().contains(x, y)) {
+
+			if (frame->getType() == kDrawableText) {
+
+				retval = anim->getID();
+
+			} else if (frame->getType() == kDrawableSprite && 
+					   reinterpret_cast<Sprite *>(frame)->getPixel(x, y) != transparent) {
+
+				retval = anim->getID();
+			}	
+		}
+
+		// Revert back to old coordinates
+		frame->setX(oldX);
+		frame->setY(oldY);
+
+		// Revert back to old dimensions
+		frame->setScaled(scaledWidth, scaledHeight);
+
+		// Found an animation
+		if (retval != kOverlayImage)
+			break;
+	}
+
+	return retval;
+}
+			
+}

Deleted: scummvm/trunk/engines/draci/animation.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/animation.h	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/engines/draci/animation.h	2009-09-25 06:22:54 UTC (rev 44326)
@@ -1,193 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 DRACI_ANIMATION_H
-#define DRACI_ANIMATION_H
-
-#include "draci/sprite.h"
-
-namespace Draci {
-
-/**
-  * Animation IDs for those animations that don't have their IDs
-  * specified in the data files.
-  */
-enum { kOverlayImage = -1, 
-	   kWalkingMapOverlay = -2, 
-	   kTitleText = -3, 
-	   kSpeechText = -4,
-	   kInventorySprite = -5,
-	   kDialogueLinesID = -6,
-	   kUnused = -10,
-	   kInventoryItemsID = -11};
-
-/**
-  * Default argument to Animation::getFrame() that makes it return 
-  * the current frame instead of the user specifying it.
-  */
-enum { kCurrentFrame = -1 };
-
-/** 
-  * Used by overlays as a neutral index that won't get 
-  * released with the GPL Release command.
-  */
-enum { kIgnoreIndex = -2 };
-
-class DraciEngine;
-
-class Animation {
-
-typedef void (Animation::* AnimationCallback)();
-
-public:
-	Animation(DraciEngine *v, int index);
-	~Animation();	
-	
-	uint getZ();
-	void setZ(uint z);
-	
-	void setID(int id);
-	int getID();
-
-	void nextFrame(bool force = false);
-	void drawFrame(Surface *surface);
-
-	void addFrame(Drawable *frame);
-	Drawable *getFrame(int frameNum = kCurrentFrame);
-	void setCurrentFrame(uint frame);
-	uint currentFrameNum();
-	uint getFrameCount();
-	void deleteFrames();
-
-	bool isPlaying();
-	void setPlaying(bool playing);
-
-	bool isPaused();
-	void setPaused(bool paused);
-
-	bool isLooping();
-	void setLooping(bool looping);
-
-	void setRelative(int relx, int rely);
-	int getRelativeX();
-	int getRelativeY();
-
-	int getIndex();
-	void setIndex(int index);
-
-	void setScaleFactors(double scaleX, double scaleY);
-	double getScaleX();
-	double getScaleY();
-
-	void markDirtyRect(Surface *surface);
-
-	// Animation callbacks
-
-	void registerCallback(AnimationCallback callback) { _callback = callback; }
-
-	void doNothing() {}
-	void stopAnimation();
-	void exitGameLoop();
-
-private:
-	
-	uint nextFrameNum();
-
-	/** Internal animation ID 
-	  *	(as specified in the data files and the bytecode)
-	  */
-	int _id; 
-	
-	/** The recency index of an animation, i.e. the most recently added animation has
-	  * the highest index. Some script commands need this.
-	  */
-	int _index;
-
-	uint _currentFrame;
-	uint _z;
-
-	int _relX;
-	int _relY;
-
-	double _scaleX;
-	double _scaleY;
-
-	uint _tick;
-	bool _playing;
-	bool _looping;
-	bool _paused;
-	Common::Array<Drawable*> _frames;
-
-	AnimationCallback _callback;
-
-	DraciEngine *_vm;
-};
-
-
-class AnimationManager {
-
-public:
-	AnimationManager(DraciEngine *vm) : _vm(vm), _lastIndex(-1) {}
-	~AnimationManager() { deleteAll(); }
-
-	Animation *addAnimation(int id, uint z, bool playing = false);
-	Animation *addText(int id, bool playing = false);
-	Animation *addItem(int id, bool playing = false);
-	void addOverlay(Drawable *overlay, uint z);
-	
-	void play(int id);
-	void stop(int id);
-	void pauseAnimations();
-	void unpauseAnimations();
-
-	void deleteAnimation(int id);
-	void deleteOverlays();
-	void deleteAll();
-
-	void drawScene(Surface *surf);
-
-	Animation *getAnimation(int id);
-
-	int getLastIndex();
-	void deleteAfterIndex(int index);
-
-	int getTopAnimationID(int x, int y);
-
-private:
-	void sortAnimations();	
-	void insertAnimation(Animation *anim);
-
-	DraciEngine *_vm;
-	Common::List<Animation *> _animations;
-
-	/** The index of the most recently added animation. 
-	  *	See Animation::_index for details.
-	  */
-	int _lastIndex;
-};
-
-}
-
-#endif // DRACI_ANIMATION_H

Copied: scummvm/trunk/engines/draci/animation.h (from rev 44325, scummvm/branches/gsoc2009-draci/engines/draci/animation.h)
===================================================================
--- scummvm/trunk/engines/draci/animation.h	                        (rev 0)
+++ scummvm/trunk/engines/draci/animation.h	2009-09-25 06:22:54 UTC (rev 44326)
@@ -0,0 +1,193 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 DRACI_ANIMATION_H
+#define DRACI_ANIMATION_H
+
+#include "draci/sprite.h"
+
+namespace Draci {
+
+/**
+  * Animation IDs for those animations that don't have their IDs
+  * specified in the data files.
+  */
+enum { kOverlayImage = -1, 
+	   kWalkingMapOverlay = -2, 
+	   kTitleText = -3, 
+	   kSpeechText = -4,
+	   kInventorySprite = -5,
+	   kDialogueLinesID = -6,
+	   kUnused = -10,
+	   kInventoryItemsID = -11};
+
+/**
+  * Default argument to Animation::getFrame() that makes it return 
+  * the current frame instead of the user specifying it.
+  */
+enum { kCurrentFrame = -1 };
+
+/** 
+  * Used by overlays as a neutral index that won't get 
+  * released with the GPL Release command.
+  */
+enum { kIgnoreIndex = -2 };
+
+class DraciEngine;
+
+class Animation {
+
+typedef void (Animation::* AnimationCallback)();
+
+public:
+	Animation(DraciEngine *v, int index);
+	~Animation();	
+	
+	uint getZ();
+	void setZ(uint z);
+	
+	void setID(int id);
+	int getID();
+
+	void nextFrame(bool force = false);
+	void drawFrame(Surface *surface);
+
+	void addFrame(Drawable *frame);
+	Drawable *getFrame(int frameNum = kCurrentFrame);
+	void setCurrentFrame(uint frame);
+	uint currentFrameNum();
+	uint getFrameCount();
+	void deleteFrames();
+
+	bool isPlaying();
+	void setPlaying(bool playing);
+
+	bool isPaused();
+	void setPaused(bool paused);
+
+	bool isLooping();
+	void setLooping(bool looping);
+
+	void setRelative(int relx, int rely);
+	int getRelativeX();
+	int getRelativeY();
+
+	int getIndex();
+	void setIndex(int index);
+
+	void setScaleFactors(double scaleX, double scaleY);
+	double getScaleX();
+	double getScaleY();
+
+	void markDirtyRect(Surface *surface);
+
+	// Animation callbacks
+
+	void registerCallback(AnimationCallback callback) { _callback = callback; }
+
+	void doNothing() {}
+	void stopAnimation();
+	void exitGameLoop();
+
+private:
+	
+	uint nextFrameNum();
+
+	/** Internal animation ID 
+	  *	(as specified in the data files and the bytecode)
+	  */
+	int _id; 
+	
+	/** The recency index of an animation, i.e. the most recently added animation has
+	  * the highest index. Some script commands need this.
+	  */
+	int _index;
+
+	uint _currentFrame;
+	uint _z;
+
+	int _relX;
+	int _relY;
+
+	double _scaleX;
+	double _scaleY;
+
+	uint _tick;
+	bool _playing;
+	bool _looping;
+	bool _paused;
+	Common::Array<Drawable*> _frames;
+
+	AnimationCallback _callback;
+
+	DraciEngine *_vm;
+};
+
+
+class AnimationManager {
+
+public:
+	AnimationManager(DraciEngine *vm) : _vm(vm), _lastIndex(-1) {}
+	~AnimationManager() { deleteAll(); }
+
+	Animation *addAnimation(int id, uint z, bool playing = false);
+	Animation *addText(int id, bool playing = false);
+	Animation *addItem(int id, bool playing = false);
+	void addOverlay(Drawable *overlay, uint z);
+	
+	void play(int id);
+	void stop(int id);
+	void pauseAnimations();
+	void unpauseAnimations();
+
+	void deleteAnimation(int id);
+	void deleteOverlays();
+	void deleteAll();
+
+	void drawScene(Surface *surf);
+
+	Animation *getAnimation(int id);
+
+	int getLastIndex();
+	void deleteAfterIndex(int index);
+
+	int getTopAnimationID(int x, int y);
+
+private:
+	void sortAnimations();	
+	void insertAnimation(Animation *anim);
+
+	DraciEngine *_vm;
+	Common::List<Animation *> _animations;
+
+	/** The index of the most recently added animation. 
+	  *	See Animation::_index for details.
+	  */
+	int _lastIndex;
+};
+
+}
+
+#endif // DRACI_ANIMATION_H

Deleted: scummvm/trunk/engines/draci/barchive.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/barchive.cpp	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/engines/draci/barchive.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -1,427 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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/debug.h"
-#include "common/file.h"
-#include "common/str.h"
-#include "common/stream.h"
-
-#include "draci/barchive.h"
-#include "draci/draci.h"
-
-namespace Draci {
-
-const char BArchive::_magicNumber[] = "BAR!";
-const char BArchive::_dfwMagicNumber[] = "BS";
-
-/**
- * @brief Loads a DFW archive
- * @param path Path to input file
- *
- * Tries to load the file as a DFW archive if opening as BAR fails. Should only be called
- * from openArchive(). Only one of the game files appears to use this format (HRA.DFW)
- * and this file is compressed using a simple run-length scheme.
- *
- * archive format: header
- *				   index table
- *				   file0, file1, ...
- *
- * header format: [uint16LE] file count
- *				  [uint16LE] index table size
- *				  [2 bytes]  magic number "BS" 
- *
- * index table format: entry0, entry1, ...
- *
- * entry<N> format: [uint16LE] compressed size (not including the 2 bytes for the 
- *							   "uncompressed size" field)
- *				 	[uint32LE] fileN offset from start of file
- *
- * file<N> format: [uint16LE] uncompressed size
- *				   [uint16LE] compressed size (the same as in the index table entry)
- *				   [byte] stopper mark (for run-length compression)
- *				   [multiple bytes] compressed data
- */
-
-void BArchive::openDFW(const Common::String &path) {
-	byte *table;
-	uint16 tableSize;
-	byte buf[2];
-
-	Common::File f;
-
-	f.open(path);
-	if (!f.isOpen()) {
-		debugC(2, kDraciArchiverDebugLevel, "Error opening file");
-		return;
-	}
-	
-	_fileCount = f.readUint16LE();
-	tableSize = f.readUint16LE();
-
-	f.read(buf, 2);
-	if (memcmp(buf, _dfwMagicNumber, 2) == 0) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");
-		_isDFW = true;
-	} else {
-		debugC(2, kDraciArchiverDebugLevel, "Not a DFW archive");
-		f.close();
-		return;
-	}
-
-	debugC(2, kDraciArchiverDebugLevel, "Archive info (DFW): %d files", _fileCount);
-
-	// Read in index table
-	table = new byte[tableSize];
-	f.read(table, tableSize);	
-	
-	// Read in file headers, but do not read the actual data yet
-	// The data will be read on demand to save memory
-	_files = new BAFile[_fileCount];
-	Common::MemoryReadStream tableReader(table, tableSize);
-	for (unsigned int i = 0; i < _fileCount; ++i) {
-		_files[i]._compLength = tableReader.readUint16LE();
-		_files[i]._offset = tableReader.readUint32LE();
-	
-		// Seek to the current file
-		f.seek(_files[i]._offset);
-		
-		_files[i]._length = f.readUint16LE(); // Read in uncompressed length
-		f.readUint16LE(); // Compressed length again (already read from the index table)
-		_files[i]._stopper = f.readByte();
-
-		_files[i]._data = NULL; // File data will be read in on demand
-		_files[i]._crc = 0; // Dummy value; not used in DFW archives
-	}
-
-	// Indicate that the archive was successfully opened
-	_opened = true;
-		
-	// Cleanup
-	delete[] table;
-	f.close();
-}		
-
-/**
- * @brief BArchive open method
- * @param path Path to input file
- *
- * Opens a BAR (Bob's Archiver) archive, which is the game's archiving format.
- * BAR archives have a .DFW file extension, due to a historical interface.
- * 
- * archive format: header, 
- *                 file0, file1, ...
- *                 footer
- *
- * header format: [4 bytes] magic number "BAR!"
- *                [uint16LE] file count (number of archived streams),
- *                [uint32LE] footer offset from start of file
- *
- * file<N> format: [2 bytes] compressed length
- *                 [2 bytes] original length
- *                 [1 byte] compression type
- *                 [1 byte] CRC
- *				   [multiple bytes] actual data
- *
- * footer format: [array of uint32LE] offsets of individual files from start of archive 
- *                (last entry is footer offset again)
- */
-
-void BArchive::openArchive(const Common::String &path) {
-	byte buf[4];
-	byte *footer;
-	uint32 footerOffset, footerSize;
-	Common::File f;
-
-	// Close previously opened archive (if any)
-	closeArchive();
-	
-	debugCN(2, kDraciArchiverDebugLevel, "Loading archive %s: ", path.c_str());
-
-	f.open(path);
-	if (f.isOpen()) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");
-	} else {
-		debugC(2, kDraciArchiverDebugLevel, "Error");
-		return;
-	}
-
-	// Save path for reading in files later on
-	_path = path;
-
-	// Read archive header
-	debugCN(2, kDraciArchiverDebugLevel, "Checking for BAR magic number: ");
-
-	f.read(buf, 4);
-	if (memcmp(buf, _magicNumber, 4) == 0) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");
-			
-		// Indicate this archive is a BAR	
-		_isDFW = false;
-	} else {
-		debugC(2, kDraciArchiverDebugLevel, "Not a BAR archive");
-		debugCN(2, kDraciArchiverDebugLevel, "Retrying as DFW: ");
-		f.close();
-
-		// Try to open as DFW
-		openDFW(_path);
-
-		return;
-	}
-
-	_fileCount = f.readUint16LE();
-	footerOffset = f.readUint32LE();
-	footerSize = f.size() - footerOffset;
-	
-	debugC(2, kDraciArchiverDebugLevel, "Archive info: %d files, %d data bytes",
-		_fileCount, footerOffset - _archiveHeaderSize);
-
-	// Read in footer	
-	footer = new byte[footerSize];	
-	f.seek(footerOffset);
-	f.read(footer, footerSize);
-	Common::MemoryReadStream reader(footer, footerSize);
-
-	// Read in file headers, but do not read the actual data yet
-	// The data will be read on demand to save memory
-	_files = new BAFile[_fileCount];
-
-	for (unsigned int i = 0; i < _fileCount; i++) {
-		uint32 fileOffset;			
-		
-		fileOffset = reader.readUint32LE();
-		f.seek(fileOffset); 						// Seek to next file in archive
-
-		_files[i]._compLength = f.readUint16LE(); 	// Compressed size 
-													// should be the same as uncompressed
-
-		_files[i]._length = f.readUint16LE(); 		// Original size
-	
-		_files[i]._offset = fileOffset;				// Offset of file from start
-
-		assert(f.readByte() == 0 && 
-			"Compression type flag is non-zero (file is compressed)");
-
-		_files[i]._crc = f.readByte(); 	// CRC checksum of the file
-		_files[i]._data = NULL; 		// File data will be read in on demand
-		_files[i]._stopper = 0; 		// Dummy value; not used in BAR files, needed in DFW
-	}	
-	
-	// Last footer item should be equal to footerOffset
-	assert(reader.readUint32LE() == footerOffset && "Footer offset mismatch");
-
-	// Indicate that the archive has been successfully opened
-	_opened = true; 
-	
-	delete[] footer;
-	f.close();
-}
-
-/**
- * @brief BArchive close method
- *
- * Closes the currently opened archive. It can be called explicitly to
- * free up memory.
- */
-void BArchive::closeArchive(void) {
-	if (!_opened) {
-		return;
-	}
-
-	for (unsigned int i = 0; i < _fileCount; ++i) {
-		if (_files[i]._data) {
-			delete[] _files[i]._data; 
-		}
-	}
-
-	delete[] _files;
-
-	_opened = false;
-	_files = NULL;
-	_fileCount = 0;
-}
-
-/**
- * @brief On-demand BAR file loader
- * @param i Index of file inside an archive
- * @return Pointer to a BAFile coresponding to the opened file or NULL (on failure)
- *
- * Loads individual BAR files from an archive to memory on demand. 
- * Should not be called directly. Instead, one should access files 
- * through the operator[] interface.
- */
-BAFile *BArchive::loadFileBAR(unsigned int i) const {
-	Common::File f;
-
-	// Else open archive and read in requested file
-	f.open(_path);
-	if (f.isOpen()) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");
-	} else {
-		debugC(2, kDraciArchiverDebugLevel, "Error");
-		return NULL;
-	}
-
-	// Read in the file (without the file header)
-	f.seek(_files[i]._offset + _fileHeaderSize);
-	_files[i]._data = new byte[_files[i]._length];
-	f.read(_files[i]._data, _files[i]._length);
-
-	// Calculate CRC
-	byte tmp = 0;
-	for (unsigned int j = 0; j < _files[i]._length; j++) {
-		tmp ^= _files[i]._data[j];
-	}
-	
-	debugC(3, kDraciArchiverDebugLevel, "Cached file %d from archive %s", 
-		i, _path.c_str());
-	assert(tmp == _files[i]._crc && "CRC checksum mismatch");
-
-	return _files + i;
-}
-
-/**
- * @brief On-demand DFW file loader
- * @param i Index of file inside an archive
- * @return Pointer to a BAFile coresponding to the opened file or NULL (on failure)
- *
- * Loads individual DFW files from an archive to memory on demand. 
- * Should not be called directly. Instead, one should access files 
- * through the operator[] interface.
- */
-BAFile *BArchive::loadFileDFW(unsigned int i) const {
-	Common::File f;
-	byte *buf;
-
-	// Else open archive and read in requested file
-	f.open(_path);
-	if (f.isOpen()) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");
-	} else {
-		debugC(2, kDraciArchiverDebugLevel, "Error");
-		return NULL;
-	}
-
-	// Seek to raw data of the file
-	// Five bytes are for the header (uncompressed and compressed length, stopper mark)
-	f.seek(_files[i]._offset + 5);
-	
-	// Since we are seeking directly to raw data, we subtract 3 bytes from the length
-	// (to take account the compressed length and stopper mark)
-	uint16 compressedLength = _files[i]._compLength - 3;
-	uint16 uncompressedLength = _files[i]._length;
-
-	debugC(2, kDraciArchiverDebugLevel, 
-		"File info (DFW): uncompressed %d bytes, compressed %d bytes", 
-		uncompressedLength, compressedLength);
-
-	// Allocate a buffer for the file data
-	buf = new byte[compressedLength];
-
-	// Read in file data into the buffer
-	f.read(buf, compressedLength);
-
-	// Allocate the space for the uncompressed file
-	byte *dst;	
-	dst = _files[i]._data = new byte[uncompressedLength];
-
-	Common::MemoryReadStream data(buf, compressedLength);
-
-	// Uncompress file
-	byte current, what;
-	byte stopper = _files[i]._stopper;
-	unsigned int repeat;
-	unsigned int len = 0; // Sanity check (counts uncompressed bytes)	
-	
-	current = data.readByte(); // Read initial byte
-	while (!data.eos()) {
-		
-		if (current != stopper) {
-			*dst++ = current;
-			++len;
-		} else {
-			// Inflate block			
-			repeat = data.readByte();
-			what = data.readByte();
-			len += repeat;
-			for (unsigned int j = 0; j < repeat; ++j) {
-				*dst++ = what;
-			}
-		}
-
-		current = data.readByte();
-	}
-
-	assert(len == _files[i]._length && "Uncompressed file not of the expected length");
-
-	delete[] buf;
-
-	return _files + i;
-}
-
-/**
- * Clears the cache of the open files inside the archive without closing it.
- * If the files are subsequently accessed, they are read from the disk.
- */
-void BArchive::clearCache() {
-
-	// Delete all cached data
-	for (unsigned int i = 0; i < _fileCount; ++i) {
-		_files[i].close();
-	}
-}
-	
-
-BAFile *BArchive::getFile(unsigned int i) const {
-
-	// Check whether requested file exists
-	if (i >= _fileCount) {
-		return NULL;
-	}
-
-	debugCN(2, kDraciArchiverDebugLevel, "Accessing file %d from archive %s... ", 
-		i, _path.c_str());
-
-	// Check if file has already been opened and return that
-	if (_files[i]._data) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");		
-		return _files + i;
-	}
-	
-	BAFile *file;
-	
-	// file will be NULL if something goes wrong
-	if (_isDFW) {
-		file = loadFileDFW(i);
-	} else {
-		file = loadFileBAR(i);
-	}
-
-	return file;
-}
-
-} // End of namespace Draci
-
-
-

Copied: scummvm/trunk/engines/draci/barchive.cpp (from rev 44325, scummvm/branches/gsoc2009-draci/engines/draci/barchive.cpp)
===================================================================
--- scummvm/trunk/engines/draci/barchive.cpp	                        (rev 0)
+++ scummvm/trunk/engines/draci/barchive.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -0,0 +1,427 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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/debug.h"
+#include "common/file.h"
+#include "common/str.h"
+#include "common/stream.h"
+
+#include "draci/barchive.h"
+#include "draci/draci.h"
+
+namespace Draci {
+
+const char BArchive::_magicNumber[] = "BAR!";
+const char BArchive::_dfwMagicNumber[] = "BS";
+
+/**
+ * @brief Loads a DFW archive
+ * @param path Path to input file
+ *
+ * Tries to load the file as a DFW archive if opening as BAR fails. Should only be called
+ * from openArchive(). Only one of the game files appears to use this format (HRA.DFW)
+ * and this file is compressed using a simple run-length scheme.
+ *
+ * archive format: header
+ *				   index table
+ *				   file0, file1, ...
+ *
+ * header format: [uint16LE] file count
+ *				  [uint16LE] index table size
+ *				  [2 bytes]  magic number "BS" 
+ *
+ * index table format: entry0, entry1, ...
+ *
+ * entry<N> format: [uint16LE] compressed size (not including the 2 bytes for the 
+ *							   "uncompressed size" field)
+ *				 	[uint32LE] fileN offset from start of file
+ *
+ * file<N> format: [uint16LE] uncompressed size
+ *				   [uint16LE] compressed size (the same as in the index table entry)
+ *				   [byte] stopper mark (for run-length compression)
+ *				   [multiple bytes] compressed data
+ */
+
+void BArchive::openDFW(const Common::String &path) {
+	byte *table;
+	uint16 tableSize;
+	byte buf[2];
+
+	Common::File f;
+
+	f.open(path);
+	if (!f.isOpen()) {
+		debugC(2, kDraciArchiverDebugLevel, "Error opening file");
+		return;
+	}
+	
+	_fileCount = f.readUint16LE();
+	tableSize = f.readUint16LE();
+
+	f.read(buf, 2);
+	if (memcmp(buf, _dfwMagicNumber, 2) == 0) {
+		debugC(2, kDraciArchiverDebugLevel, "Success");
+		_isDFW = true;
+	} else {
+		debugC(2, kDraciArchiverDebugLevel, "Not a DFW archive");
+		f.close();
+		return;
+	}
+
+	debugC(2, kDraciArchiverDebugLevel, "Archive info (DFW): %d files", _fileCount);
+
+	// Read in index table
+	table = new byte[tableSize];
+	f.read(table, tableSize);	
+	
+	// Read in file headers, but do not read the actual data yet
+	// The data will be read on demand to save memory
+	_files = new BAFile[_fileCount];
+	Common::MemoryReadStream tableReader(table, tableSize);
+	for (unsigned int i = 0; i < _fileCount; ++i) {
+		_files[i]._compLength = tableReader.readUint16LE();
+		_files[i]._offset = tableReader.readUint32LE();
+	
+		// Seek to the current file
+		f.seek(_files[i]._offset);
+		
+		_files[i]._length = f.readUint16LE(); // Read in uncompressed length
+		f.readUint16LE(); // Compressed length again (already read from the index table)
+		_files[i]._stopper = f.readByte();
+
+		_files[i]._data = NULL; // File data will be read in on demand
+		_files[i]._crc = 0; // Dummy value; not used in DFW archives
+	}
+
+	// Indicate that the archive was successfully opened
+	_opened = true;
+		
+	// Cleanup
+	delete[] table;
+	f.close();
+}		
+
+/**
+ * @brief BArchive open method
+ * @param path Path to input file
+ *
+ * Opens a BAR (Bob's Archiver) archive, which is the game's archiving format.
+ * BAR archives have a .DFW file extension, due to a historical interface.
+ * 
+ * archive format: header, 
+ *                 file0, file1, ...
+ *                 footer
+ *
+ * header format: [4 bytes] magic number "BAR!"
+ *                [uint16LE] file count (number of archived streams),
+ *                [uint32LE] footer offset from start of file
+ *
+ * file<N> format: [2 bytes] compressed length
+ *                 [2 bytes] original length
+ *                 [1 byte] compression type
+ *                 [1 byte] CRC
+ *				   [multiple bytes] actual data
+ *
+ * footer format: [array of uint32LE] offsets of individual files from start of archive 
+ *                (last entry is footer offset again)
+ */
+
+void BArchive::openArchive(const Common::String &path) {
+	byte buf[4];
+	byte *footer;
+	uint32 footerOffset, footerSize;
+	Common::File f;
+
+	// Close previously opened archive (if any)
+	closeArchive();
+	
+	debugCN(2, kDraciArchiverDebugLevel, "Loading archive %s: ", path.c_str());
+
+	f.open(path);
+	if (f.isOpen()) {
+		debugC(2, kDraciArchiverDebugLevel, "Success");
+	} else {
+		debugC(2, kDraciArchiverDebugLevel, "Error");
+		return;
+	}
+
+	// Save path for reading in files later on
+	_path = path;
+
+	// Read archive header
+	debugCN(2, kDraciArchiverDebugLevel, "Checking for BAR magic number: ");
+
+	f.read(buf, 4);
+	if (memcmp(buf, _magicNumber, 4) == 0) {
+		debugC(2, kDraciArchiverDebugLevel, "Success");
+			
+		// Indicate this archive is a BAR	
+		_isDFW = false;
+	} else {
+		debugC(2, kDraciArchiverDebugLevel, "Not a BAR archive");
+		debugCN(2, kDraciArchiverDebugLevel, "Retrying as DFW: ");
+		f.close();
+
+		// Try to open as DFW
+		openDFW(_path);
+
+		return;
+	}
+
+	_fileCount = f.readUint16LE();
+	footerOffset = f.readUint32LE();
+	footerSize = f.size() - footerOffset;
+	
+	debugC(2, kDraciArchiverDebugLevel, "Archive info: %d files, %d data bytes",
+		_fileCount, footerOffset - _archiveHeaderSize);
+
+	// Read in footer	
+	footer = new byte[footerSize];	
+	f.seek(footerOffset);
+	f.read(footer, footerSize);
+	Common::MemoryReadStream reader(footer, footerSize);
+
+	// Read in file headers, but do not read the actual data yet
+	// The data will be read on demand to save memory
+	_files = new BAFile[_fileCount];
+
+	for (unsigned int i = 0; i < _fileCount; i++) {
+		uint32 fileOffset;			
+		
+		fileOffset = reader.readUint32LE();
+		f.seek(fileOffset); 						// Seek to next file in archive
+
+		_files[i]._compLength = f.readUint16LE(); 	// Compressed size 
+													// should be the same as uncompressed
+
+		_files[i]._length = f.readUint16LE(); 		// Original size
+	
+		_files[i]._offset = fileOffset;				// Offset of file from start
+
+		assert(f.readByte() == 0 && 
+			"Compression type flag is non-zero (file is compressed)");
+
+		_files[i]._crc = f.readByte(); 	// CRC checksum of the file
+		_files[i]._data = NULL; 		// File data will be read in on demand
+		_files[i]._stopper = 0; 		// Dummy value; not used in BAR files, needed in DFW
+	}	
+	
+	// Last footer item should be equal to footerOffset
+	assert(reader.readUint32LE() == footerOffset && "Footer offset mismatch");
+
+	// Indicate that the archive has been successfully opened
+	_opened = true; 
+	
+	delete[] footer;
+	f.close();
+}
+
+/**
+ * @brief BArchive close method
+ *
+ * Closes the currently opened archive. It can be called explicitly to
+ * free up memory.
+ */
+void BArchive::closeArchive(void) {
+	if (!_opened) {
+		return;
+	}
+
+	for (unsigned int i = 0; i < _fileCount; ++i) {
+		if (_files[i]._data) {
+			delete[] _files[i]._data; 
+		}
+	}
+
+	delete[] _files;
+
+	_opened = false;
+	_files = NULL;
+	_fileCount = 0;
+}
+
+/**
+ * @brief On-demand BAR file loader
+ * @param i Index of file inside an archive
+ * @return Pointer to a BAFile coresponding to the opened file or NULL (on failure)
+ *
+ * Loads individual BAR files from an archive to memory on demand. 
+ * Should not be called directly. Instead, one should access files 
+ * through the operator[] interface.
+ */
+BAFile *BArchive::loadFileBAR(unsigned int i) const {
+	Common::File f;
+
+	// Else open archive and read in requested file
+	f.open(_path);
+	if (f.isOpen()) {
+		debugC(2, kDraciArchiverDebugLevel, "Success");
+	} else {
+		debugC(2, kDraciArchiverDebugLevel, "Error");
+		return NULL;
+	}
+
+	// Read in the file (without the file header)
+	f.seek(_files[i]._offset + _fileHeaderSize);
+	_files[i]._data = new byte[_files[i]._length];
+	f.read(_files[i]._data, _files[i]._length);
+
+	// Calculate CRC
+	byte tmp = 0;
+	for (unsigned int j = 0; j < _files[i]._length; j++) {
+		tmp ^= _files[i]._data[j];
+	}
+	
+	debugC(3, kDraciArchiverDebugLevel, "Cached file %d from archive %s", 
+		i, _path.c_str());
+	assert(tmp == _files[i]._crc && "CRC checksum mismatch");
+
+	return _files + i;
+}
+
+/**
+ * @brief On-demand DFW file loader
+ * @param i Index of file inside an archive
+ * @return Pointer to a BAFile coresponding to the opened file or NULL (on failure)
+ *
+ * Loads individual DFW files from an archive to memory on demand. 
+ * Should not be called directly. Instead, one should access files 
+ * through the operator[] interface.
+ */
+BAFile *BArchive::loadFileDFW(unsigned int i) const {
+	Common::File f;
+	byte *buf;
+
+	// Else open archive and read in requested file
+	f.open(_path);
+	if (f.isOpen()) {
+		debugC(2, kDraciArchiverDebugLevel, "Success");
+	} else {
+		debugC(2, kDraciArchiverDebugLevel, "Error");
+		return NULL;
+	}
+
+	// Seek to raw data of the file
+	// Five bytes are for the header (uncompressed and compressed length, stopper mark)
+	f.seek(_files[i]._offset + 5);
+	
+	// Since we are seeking directly to raw data, we subtract 3 bytes from the length
+	// (to take account the compressed length and stopper mark)
+	uint16 compressedLength = _files[i]._compLength - 3;
+	uint16 uncompressedLength = _files[i]._length;
+
+	debugC(2, kDraciArchiverDebugLevel, 
+		"File info (DFW): uncompressed %d bytes, compressed %d bytes", 
+		uncompressedLength, compressedLength);
+
+	// Allocate a buffer for the file data
+	buf = new byte[compressedLength];
+
+	// Read in file data into the buffer
+	f.read(buf, compressedLength);
+
+	// Allocate the space for the uncompressed file
+	byte *dst;	
+	dst = _files[i]._data = new byte[uncompressedLength];
+
+	Common::MemoryReadStream data(buf, compressedLength);
+
+	// Uncompress file
+	byte current, what;
+	byte stopper = _files[i]._stopper;
+	unsigned int repeat;
+	unsigned int len = 0; // Sanity check (counts uncompressed bytes)	
+	
+	current = data.readByte(); // Read initial byte
+	while (!data.eos()) {
+		
+		if (current != stopper) {
+			*dst++ = current;
+			++len;
+		} else {
+			// Inflate block			
+			repeat = data.readByte();
+			what = data.readByte();
+			len += repeat;
+			for (unsigned int j = 0; j < repeat; ++j) {
+				*dst++ = what;
+			}
+		}
+
+		current = data.readByte();
+	}
+
+	assert(len == _files[i]._length && "Uncompressed file not of the expected length");
+
+	delete[] buf;
+
+	return _files + i;
+}
+
+/**
+ * Clears the cache of the open files inside the archive without closing it.
+ * If the files are subsequently accessed, they are read from the disk.
+ */
+void BArchive::clearCache() {
+
+	// Delete all cached data
+	for (unsigned int i = 0; i < _fileCount; ++i) {
+		_files[i].close();
+	}
+}
+	
+
+BAFile *BArchive::getFile(unsigned int i) const {
+
+	// Check whether requested file exists
+	if (i >= _fileCount) {
+		return NULL;
+	}
+
+	debugCN(2, kDraciArchiverDebugLevel, "Accessing file %d from archive %s... ", 
+		i, _path.c_str());
+
+	// Check if file has already been opened and return that
+	if (_files[i]._data) {
+		debugC(2, kDraciArchiverDebugLevel, "Success");		
+		return _files + i;
+	}
+	
+	BAFile *file;
+	
+	// file will be NULL if something goes wrong
+	if (_isDFW) {
+		file = loadFileDFW(i);
+	} else {
+		file = loadFileBAR(i);
+	}
+
+	return file;
+}
+
+} // End of namespace Draci
+
+
+

Deleted: scummvm/trunk/engines/draci/barchive.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/barchive.h	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/engines/draci/barchive.h	2009-09-25 06:22:54 UTC (rev 44326)
@@ -1,99 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 DRACI_BARCHIVE_H
-#define DRACI_BARCHIVE_H
-
-#include "common/str.h"
-
-namespace Draci {
-
-/**
- *  Represents individual files inside the archive.
- */
-
-struct BAFile {
-	uint _compLength;	//!< Compressed length (the same as _length if the file is uncompressed) 	
-	uint _length; 	//!< Uncompressed length
-	uint32 _offset; 	//!< Offset of file inside archive	
-	byte *_data;
-	byte _crc;
-	byte _stopper;		//!< Not used in BAR files, needed for DFW
-
-	/** Releases the file data (for memory considerations) */
-	void close(void) {  
-		delete[] _data;
-		_data = NULL;
-	}
-};
-
-class BArchive {
-public:
-	BArchive() : _files(NULL), _fileCount(0), _opened(false) {}
-
-	BArchive(const Common::String &path) :
-	_files(NULL), _fileCount(0), _opened(false) { 
-		openArchive(path); 
-	}
-
-	~BArchive() { closeArchive(); }
-
-	void openArchive(const Common::String &path);
-	void closeArchive(void);
-	uint size() const { return _fileCount; }
-
-	/** 
-	 * Checks whether there is an archive opened. Should be called before reading
-	 * from the archive to check whether openArchive() succeeded.
-	 */	
-	bool isOpen() const { return _opened; }
-
-	void clearCache();
-
-	BAFile *getFile(unsigned int i) const;
-
-private:
-	// Archive header data
-	static const char _magicNumber[];
-	static const char _dfwMagicNumber[];
-	static const unsigned int _archiveHeaderSize = 10;
-	
-	// File stream header data
-	static const unsigned int _fileHeaderSize = 6;
-
-	Common::String _path;    //!< Path to file
-	BAFile *_files;          //!< Internal array of files
-	uint _fileCount;       //!< Number of files in archive
-	bool _isDFW;			 //!< True if the archive is in DFW format, false otherwise
-	bool _opened;			 //!< True if the archive is opened, false otherwise
-
-	void openDFW(const Common::String &path);
-	BAFile *loadFileDFW(unsigned int i) const;
-	BAFile *loadFileBAR(unsigned int i) const;
-};
-
-} // End of namespace Draci
-
-#endif // DRACI_BARCHIVE_H

Copied: scummvm/trunk/engines/draci/barchive.h (from rev 44325, scummvm/branches/gsoc2009-draci/engines/draci/barchive.h)
===================================================================
--- scummvm/trunk/engines/draci/barchive.h	                        (rev 0)
+++ scummvm/trunk/engines/draci/barchive.h	2009-09-25 06:22:54 UTC (rev 44326)
@@ -0,0 +1,99 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 DRACI_BARCHIVE_H
+#define DRACI_BARCHIVE_H
+
+#include "common/str.h"
+
+namespace Draci {
+
+/**
+ *  Represents individual files inside the archive.
+ */
+
+struct BAFile {
+	uint _compLength;	//!< Compressed length (the same as _length if the file is uncompressed) 	
+	uint _length; 	//!< Uncompressed length
+	uint32 _offset; 	//!< Offset of file inside archive	
+	byte *_data;
+	byte _crc;
+	byte _stopper;		//!< Not used in BAR files, needed for DFW
+
+	/** Releases the file data (for memory considerations) */
+	void close(void) {  
+		delete[] _data;
+		_data = NULL;
+	}
+};
+
+class BArchive {
+public:
+	BArchive() : _files(NULL), _fileCount(0), _opened(false) {}
+
+	BArchive(const Common::String &path) :
+	_files(NULL), _fileCount(0), _opened(false) { 
+		openArchive(path); 
+	}
+
+	~BArchive() { closeArchive(); }
+
+	void openArchive(const Common::String &path);
+	void closeArchive(void);
+	uint size() const { return _fileCount; }
+
+	/** 
+	 * Checks whether there is an archive opened. Should be called before reading
+	 * from the archive to check whether openArchive() succeeded.
+	 */	
+	bool isOpen() const { return _opened; }
+
+	void clearCache();
+
+	BAFile *getFile(unsigned int i) const;
+
+private:
+	// Archive header data
+	static const char _magicNumber[];
+	static const char _dfwMagicNumber[];
+	static const unsigned int _archiveHeaderSize = 10;
+	
+	// File stream header data
+	static const unsigned int _fileHeaderSize = 6;
+
+	Common::String _path;    //!< Path to file
+	BAFile *_files;          //!< Internal array of files
+	uint _fileCount;       //!< Number of files in archive
+	bool _isDFW;			 //!< True if the archive is in DFW format, false otherwise
+	bool _opened;			 //!< True if the archive is opened, false otherwise
+
+	void openDFW(const Common::String &path);
+	BAFile *loadFileDFW(unsigned int i) const;
+	BAFile *loadFileBAR(unsigned int i) const;
+};
+
+} // End of namespace Draci
+
+#endif // DRACI_BARCHIVE_H

Deleted: scummvm/trunk/engines/draci/detection.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/detection.cpp	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/engines/draci/detection.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -1,133 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 "draci/draci.h"
-
-#include "base/plugins.h"
-#include "engines/metaengine.h"
-
-static const PlainGameDescriptor draciGames[] = {
-	{ "draci", "Draci Historie" },
-	{ 0, 0 }
-};
-
-namespace Draci {
-
-using Common::GUIO_NONE;
-
-const ADGameDescription gameDescriptions[] = {
-	
-	{
-		"draci",
-		0,
-		AD_ENTRY1s("INIT.DFW", "b890a5aeebaf16af39219cba2416b0a3", 906),
-		Common::EN_ANY,
-		Common::kPlatformPC,
-		ADGF_NO_FLAGS,
-		GUIO_NONE
-	},
-	
-	{
-		"draci",
-		0,
-		AD_ENTRY1s("INIT.DFW", "9921c8f0045679a8f37eca8d41c5ec02", 906),
-		Common::CZ_CZE,
-		Common::kPlatformPC,
-		ADGF_NO_FLAGS,
-		GUIO_NONE
-	},
-
-	{
-		"draci",
-		0,
-		AD_ENTRY1s("INIT.DFW", "76b9b78a8a8809a240acc395df4d0715", 906),
-		Common::PL_POL,
-		Common::kPlatformPC,
-		ADGF_NO_FLAGS,
-		GUIO_NONE
-	},
-
-	AD_TABLE_END_MARKER
-};
-
-} // End of namespace Draci
-
-const ADParams detectionParams = {
-	// Pointer to ADGameDescription or its superset structure
-	(const byte *)Draci::gameDescriptions,
-	// Size of that superset structure
-	sizeof(ADGameDescription),
-	// Number of bytes to compute MD5 sum for
-	5000,
-	// List of all engine targets
-	draciGames,
-	// Structure for autoupgrading obsolete targets
-	0,
-	// Name of single gameid (optional)
-	"draci",
-	// List of files for file-based fallback detection (optional)
-	0,
-	// Flags
-	0,
-	// Global GUI options
-	Common::GUIO_NONE
-};
-
-class DraciMetaEngine : public AdvancedMetaEngine {
-public:
-	DraciMetaEngine() : AdvancedMetaEngine(detectionParams) {}
-	
-	virtual const char *getName() const {
-		return "Draci Historie Engine";
-	}
-
-	virtual const char *getOriginalCopyright() const {
-		return "Copyright (C) 1995 NoSense";
-	}
-	
-	virtual bool hasFeature(MetaEngineFeature f) const;
-	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
-};
-
-bool DraciMetaEngine::hasFeature(MetaEngineFeature f) const {
-	return false;
-}
-
-bool Draci::DraciEngine::hasFeature(EngineFeature f) const {
-	return false;
-}
-
-bool DraciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
-	if (desc) {
-		*engine = new Draci::DraciEngine(syst, desc);
-	}
-	return desc != 0;
-}
-
-#if PLUGIN_ENABLED_DYNAMIC(DRACI)
-	REGISTER_PLUGIN_DYNAMIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine);
-#else
-	REGISTER_PLUGIN_STATIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine);
-#endif

Copied: scummvm/trunk/engines/draci/detection.cpp (from rev 44325, scummvm/branches/gsoc2009-draci/engines/draci/detection.cpp)
===================================================================
--- scummvm/trunk/engines/draci/detection.cpp	                        (rev 0)
+++ scummvm/trunk/engines/draci/detection.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -0,0 +1,133 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 "draci/draci.h"
+
+#include "base/plugins.h"
+#include "engines/metaengine.h"
+
+static const PlainGameDescriptor draciGames[] = {
+	{ "draci", "Draci Historie" },
+	{ 0, 0 }
+};
+
+namespace Draci {
+
+using Common::GUIO_NONE;
+
+const ADGameDescription gameDescriptions[] = {
+	
+	{
+		"draci",
+		0,
+		AD_ENTRY1s("INIT.DFW", "b890a5aeebaf16af39219cba2416b0a3", 906),
+		Common::EN_ANY,
+		Common::kPlatformPC,
+		ADGF_NO_FLAGS,
+		GUIO_NONE
+	},
+	
+	{
+		"draci",
+		0,
+		AD_ENTRY1s("INIT.DFW", "9921c8f0045679a8f37eca8d41c5ec02", 906),
+		Common::CZ_CZE,
+		Common::kPlatformPC,
+		ADGF_NO_FLAGS,
+		GUIO_NONE
+	},
+
+	{
+		"draci",
+		0,
+		AD_ENTRY1s("INIT.DFW", "76b9b78a8a8809a240acc395df4d0715", 906),
+		Common::PL_POL,
+		Common::kPlatformPC,
+		ADGF_NO_FLAGS,
+		GUIO_NONE
+	},
+
+	AD_TABLE_END_MARKER
+};
+
+} // End of namespace Draci
+
+const ADParams detectionParams = {
+	// Pointer to ADGameDescription or its superset structure
+	(const byte *)Draci::gameDescriptions,
+	// Size of that superset structure
+	sizeof(ADGameDescription),
+	// Number of bytes to compute MD5 sum for
+	5000,
+	// List of all engine targets
+	draciGames,
+	// Structure for autoupgrading obsolete targets
+	0,
+	// Name of single gameid (optional)
+	"draci",
+	// List of files for file-based fallback detection (optional)
+	0,
+	// Flags
+	0,
+	// Global GUI options
+	Common::GUIO_NONE
+};
+
+class DraciMetaEngine : public AdvancedMetaEngine {
+public:
+	DraciMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+	
+	virtual const char *getName() const {
+		return "Draci Historie Engine";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "Copyright (C) 1995 NoSense";
+	}
+	
+	virtual bool hasFeature(MetaEngineFeature f) const;
+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+};
+
+bool DraciMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return false;
+}
+
+bool Draci::DraciEngine::hasFeature(EngineFeature f) const {
+	return false;
+}
+
+bool DraciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	if (desc) {
+		*engine = new Draci::DraciEngine(syst, desc);
+	}
+	return desc != 0;
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(DRACI)
+	REGISTER_PLUGIN_DYNAMIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine);
+#else
+	REGISTER_PLUGIN_STATIC(DRACI, PLUGIN_TYPE_ENGINE, DraciMetaEngine);
+#endif

Deleted: scummvm/trunk/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/engines/draci/draci.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -1,284 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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/scummsys.h"
- 
-#include "common/config-manager.h"
-#include "common/events.h"
-#include "common/file.h"
-#include "common/keyboard.h"
-
-#include "graphics/cursorman.h"
-#include "graphics/font.h"
- 
-#include "draci/draci.h"
-#include "draci/barchive.h"
-#include "draci/script.h"
-#include "draci/font.h"
-#include "draci/sprite.h"
-#include "draci/screen.h"
-#include "draci/mouse.h"
-
-namespace Draci {
-
-// Data file paths
-
-const Common::String objectsPath("OBJEKTY.DFW");
-const Common::String palettePath("PALETY.DFW");
-const Common::String spritesPath("OBR_AN.DFW");
-const Common::String overlaysPath("OBR_MAS.DFW");
-const Common::String roomsPath("MIST.DFW");
-const Common::String animationsPath("ANIM.DFW");
-const Common::String iconsPath("HRA.DFW");
-const Common::String walkingMapsPath("MAPY.DFW");
-const Common::String itemsPath("IKONY.DFW");
-const Common::String itemImagesPath("OBR_IK.DFW");
-const Common::String initPath("INIT.DFW");
-const Common::String stringsPath("RETEZCE.DFW");
-
-DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) 
- : Engine(syst) {
-	// Put your engine in a sane state, but do nothing big yet;
-	// in particular, do not load data from files; rather, if you
-	// need to do such things, do them from init().
- 
-	// Do not initialize graphics here
- 
-	// However this is the place to specify all default directories
-	//Common::File::addDefaultDirectory(_gameDataPath + "sound/");
-
-	// Here is the right place to set up the engine specific debug levels
-	Common::addDebugChannel(kDraciGeneralDebugLevel, "general", "Draci general debug info");
-	Common::addDebugChannel(kDraciBytecodeDebugLevel, "bytecode", "GPL bytecode instructions");
-	Common::addDebugChannel(kDraciArchiverDebugLevel, "archiver", "BAR archiver debug info");
-	Common::addDebugChannel(kDraciLogicDebugLevel, "logic", "Game logic debug info");
-	Common::addDebugChannel(kDraciAnimationDebugLevel, "animation", "Animation debug info");
- 
-	// Don't forget to register your random source
-	_eventMan->registerRandomSource(_rnd, "draci");
-}
-
-int DraciEngine::init() {
-	// Initialize graphics using following:
-	initGraphics(kScreenWidth, kScreenHeight, false);
-
-	// Open game's archives
-	_initArchive = new BArchive(initPath);
-	_objectsArchive = new BArchive(objectsPath);
-	_spritesArchive = new BArchive(spritesPath);
-	_paletteArchive = new BArchive(palettePath);
-	_roomsArchive = new BArchive(roomsPath);
-	_overlaysArchive = new BArchive(overlaysPath);
-	_animationsArchive = new BArchive(animationsPath);
-	_iconsArchive = new BArchive(iconsPath);
-	_walkingMapsArchive = new BArchive(walkingMapsPath);
-	_itemsArchive = new BArchive(itemsPath);
-	_itemImagesArchive = new BArchive(itemImagesPath);
-	_stringsArchive = new BArchive(stringsPath);
-
-	// Load the game's fonts
-	_smallFont = new Font(kFontSmall);
-	_bigFont = new Font(kFontBig);
-
-	_screen = new Screen(this);
-	_anims = new AnimationManager(this);
-	_mouse = new Mouse(this);
-	_script = new Script(this);
-	_game = new Game(this);
-
-	if(!_objectsArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening objects archive failed");
-		return Common::kUnknownError;
-	}	
-
-	if(!_spritesArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening sprites archive failed");
-		return Common::kUnknownError;
-	}	
-
-	if(!_paletteArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening palette archive failed");
-		return Common::kUnknownError;
-	}
-
-	if(!_roomsArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening rooms archive failed");
-		return Common::kUnknownError;
-	}
-
-	if(!_overlaysArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening overlays archive failed");
-		return Common::kUnknownError;
-	}
-
-	if(!_animationsArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening animations archive failed");
-		return Common::kUnknownError;
-	}
-
-	if(!_iconsArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening icons archive failed");
-		return Common::kUnknownError;
-	}
-
-	if(!_walkingMapsArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening walking maps archive failed");
-		return Common::kUnknownError;
-	}
-
-	_showWalkingMap = false;
-
-	// Basic archive test
-	debugC(2, kDraciGeneralDebugLevel, "Running archive tests...");	
-	Common::String path("INIT.DFW");	
-	BArchive ar(path);
-	BAFile *f;
-	debugC(3, kDraciGeneralDebugLevel, "Number of file streams in archive: %d", ar.size());	
-	
-	if(ar.isOpen()) {
-		f = ar.getFile(0);	
-	} else {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Archive not opened");
-		return Common::kUnknownError;
-	}	
-		
-	debugC(3, kDraciGeneralDebugLevel, "First 10 bytes of file %d: ", 0);
-	for (unsigned int i = 0; i < 10; ++i) {
-		debugC(3, kDraciGeneralDebugLevel, "0x%02x%c", f->_data[i], (i < 9) ? ' ' : '\n');
-	}
-
-	return Common::kNoError;
-}
-
-int DraciEngine::go() {
-	debugC(1, kDraciGeneralDebugLevel, "DraciEngine::go()");
- 
-	_game->init();
-	_game->start();
-
-	return Common::kNoError;
-}
-
-bool DraciEngine::handleEvents() {
-	Common::Event event;
-	bool quit = false;
-
-	while (_eventMan->pollEvent(event)) {
-		switch (event.type) {
-		case Common::EVENT_QUIT:
-			_game->setQuit(true);
-			break;
-		case Common::EVENT_KEYDOWN:
-			if (event.kbd.keycode == Common::KEYCODE_RIGHT) {
-				_game->setRoomNum(_game->nextRoomNum());
-				_game->setGateNum(0);
-			}
-			else if (event.kbd.keycode == Common::KEYCODE_LEFT) {
-				_game->setRoomNum(_game->prevRoomNum());
-				_game->setGateNum(0);
-			}
-			else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
-				int escRoom = _game->getEscRoom();
-
-				// Check if there is an escape room defined for the current room
-				if (escRoom != kNoEscRoom) {				
-
-					// Schedule room change
-					_game->setRoomNum(_game->getEscRoom());
-					_game->setGateNum(0);
-					_game->setExitLoop(true);
-
-					// End any currently running GPL programs
-					_script->endCurrentProgram();
-				}
-			}
-			// Show walking map toggle
-			else if (event.kbd.keycode == Common::KEYCODE_w) { 
-				_showWalkingMap = !_showWalkingMap;
-			}
-			else if (event.kbd.keycode == Common::KEYCODE_i) {
-				if(_game->getLoopStatus() == kStatusInventory &&
-				   _game->getLoopSubstatus() == kSubstatusOrdinary) {
-					_game->inventoryDone();
-				} else if (_game->getLoopStatus() == kStatusOrdinary &&
-				   _game->getLoopSubstatus() == kSubstatusOrdinary) {
-					_game->inventoryInit();
-				}		
-			}
-			break;					
-		default:
-			_mouse->handleEvent(event);
-		}		
-	}
-
-	// Show walking map overlay
-	// If the walking map overlay is already in the wanted state don't
-	// start / stop it constantly
-	if (_showWalkingMap && !_anims->getAnimation(kWalkingMapOverlay)->isPlaying()) {
-		_anims->play(kWalkingMapOverlay);
-	} else if (!_showWalkingMap && _anims->getAnimation(kWalkingMapOverlay)->isPlaying()) {
-		_anims->stop(kWalkingMapOverlay);
-	}
-
-	return quit;
-}
-DraciEngine::~DraciEngine() {
-	// Dispose your resources here
- 
- 	// TODO: Investigate possibility of using sharedPtr or similar
-
-	delete _smallFont;
-	delete _bigFont;
-
-	delete _mouse;
-	delete _script;
-	delete _anims;
-	delete _game;
-	delete _screen;
-
-	delete _initArchive;
-	delete _paletteArchive;
-	delete _objectsArchive;
-	delete _spritesArchive;
-	delete _roomsArchive;
-	delete _overlaysArchive;
-	delete _animationsArchive;
-	delete _iconsArchive;
-	delete _walkingMapsArchive;
-	delete _itemsArchive;
-	delete _itemImagesArchive;
-	delete _stringsArchive;
-	
-	// Remove all of our debug levels here
-	Common::clearAllDebugChannels();
-}
-
-Common::Error DraciEngine::run() {
-	init();
-	go();
-	return Common::kNoError;
-}
-
-} // End of namespace Draci

Copied: scummvm/trunk/engines/draci/draci.cpp (from rev 44325, scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp)
===================================================================
--- scummvm/trunk/engines/draci/draci.cpp	                        (rev 0)
+++ scummvm/trunk/engines/draci/draci.cpp	2009-09-25 06:22:54 UTC (rev 44326)
@@ -0,0 +1,284 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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/scummsys.h"
+ 
+#include "common/config-manager.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "common/keyboard.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/font.h"
+ 
+#include "draci/draci.h"
+#include "draci/barchive.h"
+#include "draci/script.h"
+#include "draci/font.h"
+#include "draci/sprite.h"
+#include "draci/screen.h"
+#include "draci/mouse.h"
+
+namespace Draci {
+
+// Data file paths
+
+const Common::String objectsPath("OBJEKTY.DFW");
+const Common::String palettePath("PALETY.DFW");
+const Common::String spritesPath("OBR_AN.DFW");
+const Common::String overlaysPath("OBR_MAS.DFW");
+const Common::String roomsPath("MIST.DFW");
+const Common::String animationsPath("ANIM.DFW");
+const Common::String iconsPath("HRA.DFW");
+const Common::String walkingMapsPath("MAPY.DFW");
+const Common::String itemsPath("IKONY.DFW");
+const Common::String itemImagesPath("OBR_IK.DFW");
+const Common::String initPath("INIT.DFW");
+const Common::String stringsPath("RETEZCE.DFW");
+
+DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc) 
+ : Engine(syst) {
+	// Put your engine in a sane state, but do nothing big yet;
+	// in particular, do not load data from files; rather, if you
+	// need to do such things, do them from init().
+ 
+	// Do not initialize graphics here
+ 
+	// However this is the place to specify all default directories
+	//Common::File::addDefaultDirectory(_gameDataPath + "sound/");
+
+	// Here is the right place to set up the engine specific debug levels
+	Common::addDebugChannel(kDraciGeneralDebugLevel, "general", "Draci general debug info");
+	Common::addDebugChannel(kDraciBytecodeDebugLevel, "bytecode", "GPL bytecode instructions");
+	Common::addDebugChannel(kDraciArchiverDebugLevel, "archiver", "BAR archiver debug info");
+	Common::addDebugChannel(kDraciLogicDebugLevel, "logic", "Game logic debug info");
+	Common::addDebugChannel(kDraciAnimationDebugLevel, "animation", "Animation debug info");
+ 
+	// Don't forget to register your random source
+	_eventMan->registerRandomSource(_rnd, "draci");
+}
+
+int DraciEngine::init() {
+	// Initialize graphics using following:
+	initGraphics(kScreenWidth, kScreenHeight, false);
+
+	// Open game's archives
+	_initArchive = new BArchive(initPath);
+	_objectsArchive = new BArchive(objectsPath);
+	_spritesArchive = new BArchive(spritesPath);
+	_paletteArchive = new BArchive(palettePath);
+	_roomsArchive = new BArchive(roomsPath);
+	_overlaysArchive = new BArchive(overlaysPath);
+	_animationsArchive = new BArchive(animationsPath);
+	_iconsArchive = new BArchive(iconsPath);
+	_walkingMapsArchive = new BArchive(walkingMapsPath);
+	_itemsArchive = new BArchive(itemsPath);
+	_itemImagesArchive = new BArchive(itemImagesPath);
+	_stringsArchive = new BArchive(stringsPath);
+
+	// Load the game's fonts
+	_smallFont = new Font(kFontSmall);
+	_bigFont = new Font(kFontBig);
+
+	_screen = new Screen(this);
+	_anims = new AnimationManager(this);
+	_mouse = new Mouse(this);
+	_script = new Script(this);
+	_game = new Game(this);
+
+	if(!_objectsArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening objects archive failed");
+		return Common::kUnknownError;
+	}	
+
+	if(!_spritesArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening sprites archive failed");
+		return Common::kUnknownError;
+	}	
+
+	if(!_paletteArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening palette archive failed");
+		return Common::kUnknownError;
+	}
+
+	if(!_roomsArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening rooms archive failed");
+		return Common::kUnknownError;
+	}
+
+	if(!_overlaysArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening overlays archive failed");
+		return Common::kUnknownError;
+	}
+
+	if(!_animationsArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening animations archive failed");
+		return Common::kUnknownError;
+	}
+
+	if(!_iconsArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening icons archive failed");
+		return Common::kUnknownError;
+	}
+
+	if(!_walkingMapsArchive->isOpen()) {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening walking maps archive failed");
+		return Common::kUnknownError;
+	}
+
+	_showWalkingMap = false;
+
+	// Basic archive test
+	debugC(2, kDraciGeneralDebugLevel, "Running archive tests...");	
+	Common::String path("INIT.DFW");	
+	BArchive ar(path);
+	BAFile *f;
+	debugC(3, kDraciGeneralDebugLevel, "Number of file streams in archive: %d", ar.size());	
+	
+	if(ar.isOpen()) {
+		f = ar.getFile(0);	
+	} else {
+		debugC(2, kDraciGeneralDebugLevel, "ERROR - Archive not opened");
+		return Common::kUnknownError;
+	}	
+		
+	debugC(3, kDraciGeneralDebugLevel, "First 10 bytes of file %d: ", 0);
+	for (unsigned int i = 0; i < 10; ++i) {
+		debugC(3, kDraciGeneralDebugLevel, "0x%02x%c", f->_data[i], (i < 9) ? ' ' : '\n');
+	}
+
+	return Common::kNoError;
+}
+
+int DraciEngine::go() {
+	debugC(1, kDraciGeneralDebugLevel, "DraciEngine::go()");
+ 
+	_game->init();
+	_game->start();
+
+	return Common::kNoError;
+}
+
+bool DraciEngine::handleEvents() {
+	Common::Event event;
+	bool quit = false;
+
+	while (_eventMan->pollEvent(event)) {
+		switch (event.type) {
+		case Common::EVENT_QUIT:
+			_game->setQuit(true);
+			break;
+		case Common::EVENT_KEYDOWN:
+			if (event.kbd.keycode == Common::KEYCODE_RIGHT) {
+				_game->setRoomNum(_game->nextRoomNum());
+				_game->setGateNum(0);
+			}
+			else if (event.kbd.keycode == Common::KEYCODE_LEFT) {
+				_game->setRoomNum(_game->prevRoomNum());
+				_game->setGateNum(0);
+			}
+			else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+				int escRoom = _game->getEscRoom();
+
+				// Check if there is an escape room defined for the current room
+				if (escRoom != kNoEscRoom) {				
+
+					// Schedule room change
+					_game->setRoomNum(_game->getEscRoom());
+					_game->setGateNum(0);
+					_game->setExitLoop(true);
+
+					// End any currently running GPL programs
+					_script->endCurrentProgram();
+				}
+			}
+			// Show walking map toggle
+			else if (event.kbd.keycode == Common::KEYCODE_w) { 
+				_showWalkingMap = !_showWalkingMap;
+			}
+			else if (event.kbd.keycode == Common::KEYCODE_i) {
+				if(_game->getLoopStatus() == kStatusInventory &&
+				   _game->getLoopSubstatus() == kSubstatusOrdinary) {
+					_game->inventoryDone();
+				} else if (_game->getLoopStatus() == kStatusOrdinary &&
+				   _game->getLoopSubstatus() == kSubstatusOrdinary) {
+					_game->inventoryInit();
+				}		
+			}
+			break;					
+		default:
+			_mouse->handleEvent(event);
+		}		
+	}
+
+	// Show walking map overlay
+	// If the walking map overlay is already in the wanted state don't
+	// start / stop it constantly
+	if (_showWalkingMap && !_anims->getAnimation(kWalkingMapOverlay)->isPlaying()) {
+		_anims->play(kWalkingMapOverlay);
+	} else if (!_showWalkingMap && _anims->getAnimation(kWalkingMapOverlay)->isPlaying()) {
+		_anims->stop(kWalkingMapOverlay);
+	}
+
+	return quit;
+}
+DraciEngine::~DraciEngine() {
+	// Dispose your resources here
+ 
+ 	// TODO: Investigate possibility of using sharedPtr or similar
+
+	delete _smallFont;
+	delete _bigFont;
+
+	delete _mouse;
+	delete _script;
+	delete _anims;
+	delete _game;
+	delete _screen;
+
+	delete _initArchive;
+	delete _paletteArchive;
+	delete _objectsArchive;
+	delete _spritesArchive;
+	delete _roomsArchive;
+	delete _overlaysArchive;
+	delete _animationsArchive;
+	delete _iconsArchive;
+	delete _walkingMapsArchive;
+	delete _itemsArchive;
+	delete _itemImagesArchive;
+	delete _stringsArchive;
+	
+	// Remove all of our debug levels here
+	Common::clearAllDebugChannels();
+}
+
+Common::Error DraciEngine::run() {
+	init();
+	go();
+	return Common::kNoError;
+}
+
+} // End of namespace Draci

Deleted: scummvm/trunk/engines/draci/draci.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.h	2009-09-25 06:06:01 UTC (rev 44325)
+++ scummvm/trunk/engines/draci/draci.h	2009-09-25 06:22:54 UTC (rev 44326)
@@ -1,94 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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 DRACI_H
-#define DRACI_H
- 
-#include "common/system.h"
-#include "engines/engine.h"
-#include "engines/advancedDetector.h"
-
-#include "draci/game.h"
-#include "draci/mouse.h"
-#include "draci/screen.h"
-#include "draci/font.h"
-#include "draci/script.h"
-#include "draci/barchive.h"
-#include "draci/animation.h"
-
-namespace Draci {
-
-class DraciEngine : public Engine {
-public:
-	DraciEngine(OSystem *syst, const ADGameDescription *gameDesc);
-	~DraciEngine();
-
-	int init();
-	int go();
-	Common::Error run();
-
-	bool hasFeature(Engine::EngineFeature f) const;
-	
-	bool handleEvents();
-
-	Screen *_screen;
-	Mouse *_mouse;
-	Game *_game;
-	Script *_script;
-	AnimationManager *_anims;
-
-	Font *_smallFont;
-	Font *_bigFont;
-
-	BArchive *_iconsArchive;
-	BArchive *_objectsArchive;
-	BArchive *_spritesArchive;
-	BArchive *_paletteArchive;
-	BArchive *_roomsArchive;
-	BArchive *_overlaysArchive;
-	BArchive *_animationsArchive;
-	BArchive *_walkingMapsArchive;
-	BArchive *_itemsArchive;
-	BArchive *_itemImagesArchive;
-	BArchive *_initArchive;
-	BArchive *_stringsArchive;
-
-	bool _showWalkingMap;
-
-	Common::RandomSource _rnd;
-};
-
-enum {
-	kDraciGeneralDebugLevel = 	1 << 0,
-	kDraciBytecodeDebugLevel = 	1 << 1,
-	kDraciArchiverDebugLevel = 	1 << 2,
-	kDraciLogicDebugLevel = 	1 << 3,
-	kDraciAnimationDebugLevel =	1 << 4
-};
-
-} // End of namespace Draci
-
-#endif // DRACI_H
-

Copied: scummvm/trunk/engines/draci/draci.h (from rev 44325, scummvm/branches/gsoc2009-draci/engines/draci/draci.h)
===================================================================
--- scummvm/trunk/engines/draci/draci.h	                        (rev 0)
+++ scummvm/trunk/engines/draci/draci.h	2009-09-25 06:22:54 UTC (rev 44326)
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 DRACI_H
+#define DRACI_H
+ 
+#include "common/system.h"
+#include "engines/engine.h"
+#include "engines/advancedDetector.h"
+
+#include "draci/game.h"
+#include "draci/mouse.h"
+#include "draci/screen.h"
+#include "draci/font.h"
+#include "draci/script.h"
+#include "draci/barchive.h"
+#include "draci/animation.h"
+
+namespace Draci {
+
+class DraciEngine : public Engine {
+public:
+	DraciEngine(OSystem *syst, const ADGameDescription *gameDesc);
+	~DraciEngine();
+
+	int init();
+	int go();
+	Common::Error run();
+

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list