[Scummvm-cvs-logs] SF.net SVN: scummvm: [31841] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat May 3 21:23:45 CEST 2008


Revision: 31841
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31841&view=rev
Author:   lordhoto
Date:     2008-05-03 12:23:45 -0700 (Sat, 03 May 2008)

Log Message:
-----------
- Moved newShape/temporaryScript code to KyraEngine_v2.
- Renamed newShape/temporaryScript code to animationScript.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator_mr.cpp
    scummvm/trunk/engines/kyra/animator_v2.cpp
    scummvm/trunk/engines/kyra/kyra_hof.cpp
    scummvm/trunk/engines/kyra/kyra_hof.h
    scummvm/trunk/engines/kyra/kyra_mr.cpp
    scummvm/trunk/engines/kyra/kyra_mr.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/module.mk
    scummvm/trunk/engines/kyra/scene_v2.cpp
    scummvm/trunk/engines/kyra/script_hof.cpp
    scummvm/trunk/engines/kyra/script_mr.cpp
    scummvm/trunk/engines/kyra/script_v2.cpp
    scummvm/trunk/engines/kyra/sequences_hof.cpp
    scummvm/trunk/engines/kyra/sequences_mr.cpp
    scummvm/trunk/engines/kyra/staticres.cpp
    scummvm/trunk/engines/kyra/text_hof.cpp
    scummvm/trunk/engines/kyra/text_mr.cpp
    scummvm/trunk/engines/kyra/timer_hof.cpp

Added Paths:
-----------
    scummvm/trunk/engines/kyra/sequences_v2.cpp

Modified: scummvm/trunk/engines/kyra/animator_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator_mr.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/animator_mr.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -212,8 +212,8 @@
 		shapeOffsetX = _malcolmShapeXOffset;
 		shapeOffsetY = _malcolmShapeYOffset;
 	} else {
-		shapeOffsetX = _newShapeXAdd;
-		shapeOffsetY = _newShapeYAdd;
+		shapeOffsetX = _animShapeXAdd;
+		shapeOffsetY = _animShapeYAdd;
 	}
 
 	obj->xPos2 = _mainCharacter.x1;
@@ -425,7 +425,7 @@
 		snprintf(filename, 14, "MI0%s%.02d.EMC", facingTable[_mainCharacter.facing], _characterShapeFile);
 
 		if (_res->exists(filename))
-			runTemporaryScript(filename, 1, 1, 1, 1);
+			runAnimationScript(filename, 1, 1, 1, 1);
 	}
 
 	_nextIdleType = !_nextIdleType;

Modified: scummvm/trunk/engines/kyra/animator_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator_v2.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/animator_v2.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -163,14 +163,14 @@
 	animObj->xPos2 = animObj->xPos1 = _itemList[item].x;
 	animObj->yPos2 = animObj->yPos1 = _itemList[item].y;
 
-	animObj->shapePtr = getShapePtr(getItemShape(itemId));
+	animObj->shapePtr = getShapePtr(itemId + _desc.itemShapeStart);
 	animSetupPaletteEntry(animObj);
-	animObj->shapeIndex2 = animObj->shapeIndex1 = getItemShape(itemId);
+	animObj->shapeIndex2 = animObj->shapeIndex1 = itemId + _desc.itemShapeStart;
 
 	int scaleY, scaleX;
 	scaleY = scaleX = getScale(animObj->xPos1, animObj->yPos1);
 
-	uint8 *shapePtr = getShapePtr(getItemShape(itemId));
+	uint8 *shapePtr = getShapePtr(itemId + _desc.itemShapeStart);
 	animObj->xPos3 = (animObj->xPos2 -= (screen_v2()->getShapeScaledWidth(shapePtr, scaleX) >> 1));
 	animObj->yPos3 = (animObj->yPos2 -= screen_v2()->getShapeScaledHeight(shapePtr, scaleY));
 

Modified: scummvm/trunk/engines/kyra/kyra_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_hof.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/kyra_hof.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -40,7 +40,19 @@
 
 namespace Kyra {
 
-KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags), _updateFunctor(this, &KyraEngine_HoF::update) {
+namespace {
+const KyraEngine_v2::EngineDesc hofEngineDesc = {
+	64,
+
+	8,
+
+	33
+};
+} // end of anonymous namespace
+
+KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags, hofEngineDesc), _updateFunctor(this, &KyraEngine_HoF::update) {
+	KyraEngine_v2::_characterFrameTable = _characterFrameTable;
+
 	_mouseSHPBuf = 0;
 	_debugger = 0;
 	_screen = 0;
@@ -53,8 +65,6 @@
 	_sequences = 0;
 	_sequenceSoundList = 0;
 
-	_showCredits = false;
-
 	_gamePlayBuffer = 0;
 	_cCodeBuffer = _optionsBuffer = _chapterBuffer = 0;
 
@@ -74,14 +84,7 @@
 	_unkHandleSceneChangeFlag = false;
 	_pathfinderFlag = 0;
 	_mouseX = _mouseY = 0;
-	_newShapeCount = 0;
-	_newShapeFiledata = 0;
 
-	_vocHigh = -1;
-	_chatVocHigh = -1;
-	_chatVocLow = -1;
-	_chatText = 0;
-	_chatObject = -1;
 	_lastIdleScript = -1;
 
 	_currentTalkSections.STATim = 0;
@@ -128,8 +131,6 @@
 	_mainCharacter.dlgIndex = 0;
 	setNewDlgIndex(-1);
 
-	_deathHandler = -1;
-
 	_bookMaxPage = 6;
 	_bookCurPage = 0;
 	_bookNewPage = 0;
@@ -171,10 +172,6 @@
 		delete [] _conversationState[i];
 	delete [] _conversationState;
 
-	for (Common::Array<const Opcode*>::iterator i = _opcodesTemporary.begin(); i != _opcodesTemporary.end(); ++i)
-		delete *i;
-	_opcodesTemporary.clear();
-
 	for (Common::Array<const TIMOpcode*>::iterator i = _timOpcodes.begin(); i != _timOpcodes.end(); ++i)
 		delete *i;
 	_timOpcodes.clear();
@@ -267,7 +264,7 @@
 			runLoop();
 		cleanup();
 		
-		if (_showCredits)
+		if (_showOutro)
 			seq_playSequences(kSequenceFunters, kSequenceFrash);
 	}
 
@@ -594,7 +591,7 @@
 		if (queryGameFlag(0x1ED)) {
 			_sound->beginFadeOut();
 			_screen->fadeToBlack();
-			_showCredits = true;
+			_showOutro = true;
 			_runFlag = false;
 		}
 
@@ -835,10 +832,6 @@
 	delete [] _screenBuffer; _screenBuffer = 0;
 	delete [] _unkBuf200kByte; _unkBuf200kByte = 0;
 
-	resetNewShapes(_newShapeCount, _newShapeFiledata);
-	_newShapeFiledata = 0;
-	_newShapeCount = 0;
-
 	freeSceneShapePtrs();
 
 	if (_optionsBuffer != _cCodeBuffer)
@@ -1171,53 +1164,6 @@
 	_emc->load(filename, &_npcScriptData, &_opcodes);
 }
 
-void KyraEngine_HoF::runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload) {
-	memset(&_temporaryScriptData, 0, sizeof(_temporaryScriptData));
-	memset(&_temporaryScriptState, 0, sizeof(_temporaryScriptState));
-
-	if (!_emc->load(filename, &_temporaryScriptData, &_opcodesTemporary))
-		error("Couldn't load temporary script '%s'", filename);
-
-	_emc->init(&_temporaryScriptState, &_temporaryScriptData);
-	_emc->start(&_temporaryScriptState, 0);
-
-	_newShapeFlag = -1;
-
-	if (_newShapeFiledata && newShapes) {
-		resetNewShapes(_newShapeCount, _newShapeFiledata);
-		_newShapeFiledata = 0;
-		_newShapeCount = 0;
-	}
-
-	while (_emc->isValid(&_temporaryScriptState))
-		_emc->run(&_temporaryScriptState);
-
-	uint8 *fileData = 0;
-
-	if (newShapes)
-		_newShapeFiledata = _res->fileData(_newShapeFilename, 0);
-
-	fileData = _newShapeFiledata;
-
-	if (!fileData) {
-		_emc->unload(&_temporaryScriptData);
-		return;
-	}
-
-	if (newShapes)
-		_newShapeCount = initNewShapes(fileData);
-
-	processNewShapes(allowSkip, resetChar);
-
-	if (shapeUnload) {
-		resetNewShapes(_newShapeCount, fileData);
-		_newShapeCount = 0;
-		_newShapeFiledata = 0;
-	}
-
-	_emc->unload(&_temporaryScriptData);
-}
-
 #pragma mark -
 
 void KyraEngine_HoF::resetScaleTable() {
@@ -1376,7 +1322,7 @@
 		if (queryGameFlag(0x164)) {
 			_screen->hideMouse();
 			_timer->disable(5);
-			runTemporaryScript("_ZANBURN.EMC", 0, 1, 1, 0);
+			runAnimationScript("_ZANBURN.EMC", 0, 1, 1, 0);
 			_deathHandler = 7;
 			snd_playWanderScoreViaMap(0x53, 1);
 		} else {
@@ -1485,76 +1431,20 @@
 	return false;
 }
 
-int KyraEngine_HoF::initNewShapes(uint8 *filedata) {
-	const int lastEntry = MIN(_newShapeLastEntry, 31);
+int KyraEngine_HoF::initAnimationShapes(uint8 *filedata) {
+	const int lastEntry = MIN(_animShapeLastEntry, 31);
 	for (int i = 0; i < lastEntry; ++i) {
 		addShapeToPool(filedata, i+33, i);
 		ShapeDesc *desc = &_shapeDescTable[24+i];
-		desc->xAdd = _newShapeXAdd;
-		desc->yAdd = _newShapeYAdd;
-		desc->width = _newShapeWidth;
-		desc->height = _newShapeHeight;
+		desc->xAdd = _animShapeXAdd;
+		desc->yAdd = _animShapeYAdd;
+		desc->width = _animShapeWidth;
+		desc->height = _animShapeHeight;
 	}
 	return lastEntry;
 }
 
-void KyraEngine_HoF::processNewShapes(int allowSkip, int resetChar) {
-	setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
-
-	_emc->init(&_temporaryScriptState, &_temporaryScriptData);
-	_emc->start(&_temporaryScriptState, 1);
-
-	resetSkipFlag();
-
-	while (_emc->isValid(&_temporaryScriptState)) {
-		_temporaryScriptExecBit = false;
-		while (_emc->isValid(&_temporaryScriptState) && !_temporaryScriptExecBit)
-			_emc->run(&_temporaryScriptState);
-
-		if (_newShapeAnimFrame < 0)
-			continue;
-
-		_mainCharacter.animFrame = _newShapeAnimFrame + 33;
-		updateCharacterAnim(0);
-		if (_chatText)
-			updateWithText();
-		else
-			update();
-
-		uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength;
-
-		while ((!skipFlag() || !allowSkip) && _system->getMillis() < delayEnd) {
-			if (_chatText)
-				updateWithText();
-			else
-				update();
-
-			delay(10);
-		}
-
-		if (skipFlag())
-			resetSkipFlag();
-	}
-
-	if (resetChar) {
-		if (_newShapeFlag >= 0) {
-			_mainCharacter.animFrame = _newShapeFlag + 33;
-			updateCharacterAnim(0);
-			if (_chatText)
-				updateWithText();
-			else
-				update();
-		}
-
-		_mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
-		updateCharacterAnim(0);
-	}
-
-	_newShapeFlag = -1;
-	resetCharacterAnimDim();
-}
-
-void KyraEngine_HoF::resetNewShapes(int count, uint8 *filedata) {
+void KyraEngine_HoF::uninitAnimationShapes(int count, uint8 *filedata) {
 	for (int i = 0; i < count; ++i)
 		remShapeFromPool(i+33);
 	delete [] filedata;
@@ -1616,7 +1506,7 @@
 			"_IDLBRSH.EMC", "_Z3IDLE.EMC", "_Z4IDLE.EMC", "_Z6IDLE.EMC", "_Z7IDLE.EMC", "_Z8IDLE.EMC"
 		};
 
-		runTemporaryScript(idleScriptFiles[script], 1, 1, 1, 1);
+		runAnimationScript(idleScriptFiles[script], 1, 1, 1, 1);
 	}
 }
 

Modified: scummvm/trunk/engines/kyra/kyra_hof.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_hof.h	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/kyra_hof.h	2008-05-03 19:23:45 UTC (rev 31841)
@@ -204,9 +204,6 @@
 	virtual TextDisplayer *text() { return _text; }
 	int language() const { return _lang; }
 protected:
-	// KyraEngine_v2 API
-	int getFirstSpecialSceneScript() const { return 8; }
-
 	// intro/outro
 	void seq_playSequences(int startSeq, int endSeq = -1);
 
@@ -322,9 +319,6 @@
 	void loadItemShapes();
 
 	// run
-	bool _runFlag;
-	bool _showCredits;
-
 	void update();
 	void updateWithText();
 
@@ -369,8 +363,6 @@
 
 	ShapeDesc *_shapeDescTable;
 
-	int getItemShape(int item) const { return 64+item; }
-
 	void loadCharacterShapes(int shapes);
 	void loadInventoryShapes();
 
@@ -385,20 +377,9 @@
 
 	int _layerFlagTable[16]; // seems to indicate layers where items get destroyed when dropped to (TODO: check this!)
 
-	char _newShapeFilename[13];
-	int _newShapeLastEntry;
-	int _newShapeWidth, _newShapeHeight;
-	int _newShapeXAdd, _newShapeYAdd;
-	int _newShapeFlag;
-	uint8 *_newShapeFiledata;
-	int _newShapeCount;
-	int _newShapeAnimFrame;
-	int _newShapeDelay;
+	int initAnimationShapes(uint8 *filedata);
+	void uninitAnimationShapes(int count, uint8 *filedata);
 
-	int initNewShapes(uint8 *filedata);
-	void processNewShapes(int allowSkip, int resetChar);
-	void resetNewShapes(int count, uint8 *filedata);
-
 	// animator
 	uint8 *_gamePlayBuffer;
 	void restorePage3();
@@ -581,7 +562,6 @@
 	static const char *_scriptLangExt[];
 
 	// character
-	int8 _deathHandler;
 	bool _useCharPal;
 	int _charPalEntry;
 	uint8 _charPalTable[16];
@@ -593,7 +573,7 @@
 
 	bool checkCharCollision(int x, int y);
 
-	static const int _characterFrameTable[];
+	static const uint8 _characterFrameTable[];
 
 	// text
 	void showMessageFromCCode(int id, int16 palIndex, int);
@@ -609,17 +589,8 @@
 	void fadeMessagePalette();
 
 	// chat
-	int _vocHigh;
-
-	const char *_chatText;
-	int _chatObject;
 	bool _chatIsNote;
-	uint32 _chatEndTime;
-	int _chatVocHigh, _chatVocLow;
 
-	EMCData _chatScriptData;
-	EMCState _chatScriptState;
-
 	int chatGetType(const char *text);
 	int chatCalcDuration(const char *text);
 
@@ -874,13 +845,8 @@
 	int o2_demoFinale(EMCState *script);
 	int o2_dummy(EMCState *script);
 
-	// opcodes temporary
-	// TODO: rename it from temporary to something more appropriate
-	int o2t_defineNewShapes(EMCState *script);
-	int o2t_setCurrentFrame(EMCState *script);
-	int o2t_playSoundEffect(EMCState *script);
-	int o2t_fadeScenePal(EMCState *script);
-	int o2t_setShapeFlag(EMCState *script);
+	// animation opcodes
+	int o2a_setCharacterFrame(EMCState *script);
 
 	// script
 	void runStartScript(int script, int unk1);
@@ -890,13 +856,6 @@
 
 	EMCData _npcScriptData;
 
-	EMCData _temporaryScriptData;
-	EMCState _temporaryScriptState;
-	bool _temporaryScriptExecBit;
-	Common::Array<const Opcode*> _opcodesTemporary;
-
-	void runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload);
-
 	// pathfinder
 	uint8 *_unkBuf500Bytes;
 	uint8 *_unkBuf200kByte;

Modified: scummvm/trunk/engines/kyra/kyra_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -40,7 +40,20 @@
 #include "common/config-manager.h"
 
 namespace Kyra {
-KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags) {
+
+namespace {
+const KyraEngine_v2::EngineDesc mrEngineDesc = {
+	248,
+
+	9,
+
+	9
+};
+} // end of anonymous namespace
+
+KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags, mrEngineDesc) {
+	KyraEngine_v2::_characterFrameTable = _characterFrameTable;
+
 	_soundDigital = 0;
 	_musicSoundChannel = -1;
 	_menuAudioFile = "TITLE1.AUD";
@@ -90,8 +103,6 @@
 	_noStartupChat = false;
 	_pathfinderFlag = 0;
 	_talkObjectList = 0;
-	_chatText = 0;
-	_chatObject = -1;
 	memset(&_chatScriptState, 0, sizeof(_chatScriptState));
 	memset(&_chatScriptData, 0, sizeof(_chatScriptData));
 	_voiceSoundChannel = -1;
@@ -101,7 +112,6 @@
 	_curStudioSFX = 283;
 	_badConscienceShown = false;
 	_currentChapter = 1;
-	_deathHandler = -1;
 	_unkHandleSceneChangeFlag = false;
 	memset(_sceneShapeDescs, 0, sizeof(_sceneShapeDescs));
 	_cnvFile = _dlgBuffer = 0;
@@ -115,8 +125,6 @@
 	_malcolmsMood = 1;
 	_nextIdleAnim = 0;
 	_nextIdleType = false;
-	_newShapeFlag = -1;
-	_newShapeFiledata = 0;
 	_inventoryScrollSpeed = -1;
 	_invWsa = 0;
 	_invWsaFrame = -1;
@@ -130,7 +138,6 @@
 	_goodConscienceShown = false;
 	_goodConscienceAnim = -1;
 	_goodConsciencePosition = false;
-	_showOutro = false;
 }
 
 KyraEngine_MR::~KyraEngine_MR() {
@@ -167,10 +174,6 @@
 	delete [] _sceneStrings;
 	delete [] _talkObjectList;
 
-	for (Common::Array<const Opcode*>::iterator i = _opcodesTemporary.begin(); i != _opcodesTemporary.end(); ++i)
-		delete *i;
-	_opcodesTemporary.clear();
-
 	for (Common::Array<const Opcode*>::iterator i = _opcodesDialog.begin(); i != _opcodesDialog.end(); ++i)
 		delete *i;
 	_opcodesDialog.clear();
@@ -178,7 +181,6 @@
 	delete _cnvFile;
 	delete _dlgBuffer;
 	delete [] _stringBuffer;
-	delete [] _newShapeFiledata;
 	delete _invWsa;
 	delete _debugger;
 	delete [] _mainButtonData;

Modified: scummvm/trunk/engines/kyra/kyra_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-03 19:23:45 UTC (rev 31841)
@@ -62,9 +62,6 @@
 	void playVQA(const char *name);
 
 protected:
-	// KyraEngine_v2 API
-	int getFirstSpecialSceneScript() const { return 9; }
-
 	// --
 	Screen_MR *_screen;
 	SoundDigital *_soundDigital;
@@ -78,10 +75,6 @@
 	void setupOpcodeTable();
 
 	// run
-	bool _showOutro;
-	bool _runFlag;
-	int _deathHandler;
-
 	void runLoop();
 	void handleInput(int x, int y);
 	int inputSceneChange(int x, int y, int unk1, int unk2);
@@ -291,8 +284,6 @@
 	void setMouseCursor(uint16 item);
 
 	// shapes
-	int getItemShape(int item) const { return 248+item; }
-
 	void initMouseShapes();
 
 	void loadCharacterShapes(int newShapes);
@@ -392,16 +383,6 @@
 	bool talkObjectsInCurScene();
 
 	// chat
-	int _vocHigh;
-
-	const char *_chatText;
-	int _chatObject;
-	uint32 _chatEndTime;
-	int _chatVocHigh, _chatVocLow;
-
-	EMCData _chatScriptData;
-	EMCState _chatScriptState;
-
 	int chatGetType(const char *text);
 	int chatCalcDuration(const char *text);
 
@@ -474,37 +455,14 @@
 	void hideGoodConscience();
 
 	// special script code
-	bool _temporaryScriptExecBit;
 	bool _useFrameTable;
 	
-	Common::Array<const Opcode *> _opcodesTemporary;
+	int o3a_setCharacterFrame(EMCState *script);
 
-	int o3t_defineNewShapes(EMCState *script);
-	int o3t_setCurrentFrame(EMCState *script);
-	int o3t_setNewShapeFlag(EMCState *script);
-
-	EMCData _temporaryScriptData;
-	EMCState _temporaryScriptState;
-
-	void runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload);
-
 	// special shape code
-	char _newShapeFilename[13];
-	int _newShapeLastEntry;
-	int _newShapeWidth, _newShapeHeight;
-	int _newShapeXAdd, _newShapeYAdd;
+	int initAnimationShapes(uint8 *filedata);
+	void uninitAnimationShapes(int count, uint8 *filedata);
 
-	int _newShapeAnimFrame;
-	int _newShapeDelay;
-
-	int _newShapeFlag;
-	uint8 *_newShapeFiledata;
-	int _newShapeCount;
-
-	int initNewShapes(uint8 *filedata);
-	void processNewShapes(int allowSkip, int resetChar);
-	void resetNewShapes(int count, uint8 *filedata);
-
 	// unk
 	uint8 *_costPalBuffer;
 	uint8 *_screenBuffer;

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -28,7 +28,7 @@
 
 namespace Kyra {
 
-KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) {
+KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags, const EngineDesc &desc) : KyraEngine(system, flags), _desc(desc) {
 	memset(&_sceneAnims, 0, sizeof(_sceneAnims));
 	memset(&_sceneAnimMovie, 0, sizeof(_sceneAnimMovie));
 
@@ -46,6 +46,20 @@
 	memset(&_sceneScriptData, 0, sizeof(_sceneScriptData));
 
 	_animObjects = 0;
+
+	_runFlag = true;
+	_showOutro = false;
+	_deathHandler = -1;
+	_animNeedUpdate = false;
+
+	_animShapeCount = 0;
+	_animShapeFiledata = 0;
+
+	_vocHigh = -1;
+	_chatVocHigh = -1;
+	_chatVocLow = -1;
+	_chatText = 0;
+	_chatObject = -1;
 }
 
 KyraEngine_v2::~KyraEngine_v2() {
@@ -60,6 +74,11 @@
 	_emc->unload(&_sceneScriptData);
 
 	delete [] _animObjects;
+
+	for (Common::Array<const Opcode*>::iterator i = _opcodesAnimation.begin(); i != _opcodesAnimation.end(); ++i)
+		delete *i;
+	_opcodesAnimation.clear();
+
 }
 
 void KyraEngine_v2::updateInput() {

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-03 19:23:45 UTC (rev 31841)
@@ -40,12 +40,31 @@
 class KyraEngine_v2 : public KyraEngine {
 friend class Debugger_v2;
 public:
-	KyraEngine_v2(OSystem *system, const GameFlags &flags);
+	struct EngineDesc {
+		// Generic shape related
+		const int itemShapeStart;
+
+		// Scene script
+		const int firstAnimSceneScript;
+
+		// Animation script specific
+		const int animScriptFrameAdd;
+	};
+
+	KyraEngine_v2(OSystem *system, const GameFlags &flags, const EngineDesc &desc);
 	~KyraEngine_v2();
 
 	virtual Screen_v2 *screen_v2() const = 0;
+
+	const EngineDesc &engineDesc() const { return _desc; }
 protected:
+	EngineDesc _desc;
+
 	// run
+	bool _runFlag;
+	bool _showOutro;
+	int8 _deathHandler;
+
 	virtual void update() = 0;
 	virtual void updateWithText() = 0;
 
@@ -138,6 +157,8 @@
 
 	virtual int getScale(int x, int y) = 0;
 
+	const uint8 *_characterFrameTable;
+
 	// Scene
 	struct SceneDesc {
 		char filename1[10];
@@ -197,8 +218,37 @@
 	bool _specialSceneScriptRunFlag;
 
 	void updateSpecialSceneScripts();
-	virtual int getFirstSpecialSceneScript() const = 0;
 
+	// Sequences
+	EMCData _animationScriptData;
+	EMCState _animationScriptState;
+	Common::Array<const Opcode*> _opcodesAnimation;
+
+	void runAnimationScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload);
+
+	int o2a_setAnimationShapes(EMCState *script);
+	int o2a_setResetFrame(EMCState *script);
+
+	char _animShapeFilename[14];
+
+	uint8 *_animShapeFiledata;
+	int _animShapeCount;
+	int _animShapeLastEntry;
+
+	int _animNewFrame;
+	int _animDelayTime;
+
+	int _animResetFrame;
+
+	int _animShapeWidth, _animShapeHeight;
+	int _animShapeXAdd, _animShapeYAdd;
+
+	bool _animNeedUpdate;
+
+	virtual int initAnimationShapes(uint8 *filedata) = 0;
+	void processAnimationScript(int allowSkip, int resetChar);
+	virtual void uninitAnimationShapes(int count, uint8 *filedata) = 0;
+
 	// Shapes
 	typedef Common::HashMap<int, uint8*> ShapeMap;
 	ShapeMap _gameShapes;
@@ -208,8 +258,6 @@
 	void addShapeToPool(uint8 *shpData, int index);
 	void remShapeFromPool(int idx);
 
-	virtual int getItemShape(int item) const = 0;
-
 	int _characterShapeFile;
 	virtual void loadCharacterShapes(int shapes) = 0;
 	
@@ -289,6 +337,17 @@
 	virtual int getCharacterWalkspeed() const = 0;
 	virtual void updateCharAnimFrame(int num, int *table) = 0;
 
+	// chat
+	int _vocHigh;
+
+	const char *_chatText;
+	int _chatObject;
+	uint32 _chatEndTime;
+	int _chatVocHigh, _chatVocLow;
+
+	EMCData _chatScriptData;
+	EMCState _chatScriptState;
+
 	// unknown
 	int _unk3, _unk4, _unk5;
 	bool _unkSceneScreenFlag1;

Modified: scummvm/trunk/engines/kyra/module.mk
===================================================================
--- scummvm/trunk/engines/kyra/module.mk	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/module.mk	2008-05-03 19:23:45 UTC (rev 31841)
@@ -43,6 +43,7 @@
 	script_tim.o \
 	seqplayer.o \
 	sequences_v1.o \
+	sequences_v2.o \
 	sequences_hof.o \
 	sequences_mr.o \
 	sound_adlib.o \

Modified: scummvm/trunk/engines/kyra/scene_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v2.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/scene_v2.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -57,7 +57,7 @@
 		}
 
 		if (!_emc->isValid(&_sceneSpecialScripts[_lastProcessedSceneScript])) {
-			_emc->start(&_sceneSpecialScripts[_lastProcessedSceneScript], getFirstSpecialSceneScript()+_lastProcessedSceneScript);
+			_emc->start(&_sceneSpecialScripts[_lastProcessedSceneScript], _desc.firstAnimSceneScript+_lastProcessedSceneScript);
 			_specialSceneScriptRunFlag = false;
 		}
 

Modified: scummvm/trunk/engines/kyra/script_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_hof.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/script_hof.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -878,7 +878,7 @@
 	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2_setRunFlag(%p) (%d)", (const void *)script, stackPos(0));
 	// this is usually just _runFlag, but since this is just used when the game should play the credits
 	// we handle it a bit different :-)
-	_showCredits = true;
+	_showOutro = true;
 	_runFlag = false;
 	return 0;
 }
@@ -1013,7 +1013,7 @@
 	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2_runTemporaryScript(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1),
 			stackPos(2), stackPos(3));
 
-	runTemporaryScript(stackPosString(0), stackPos(3), stackPos(2) ? 1 : 0, stackPos(1), stackPos(2));
+	runAnimationScript(stackPosString(0), stackPos(3), stackPos(2) ? 1 : 0, stackPos(1), stackPos(2));
 	return 0;
 }
 
@@ -1678,48 +1678,14 @@
 
 #pragma mark -
 
-int KyraEngine_HoF::o2t_defineNewShapes(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_defineNewShapes(%p) ('%s', %d, %d, %d, %d, %d, %d)", (const void *)script, stackPosString(0),
-			stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6));
-
-	strcpy(_newShapeFilename, stackPosString(0));
-	_newShapeLastEntry = stackPos(1);
-	_newShapeWidth = stackPos(2);
-	_newShapeHeight = stackPos(3);
-	_newShapeXAdd = stackPos(4);
-	_newShapeYAdd = stackPos(5);
-	//word_324EB = stackPos(6); <- never used
-
+int KyraEngine_HoF::o2a_setCharacterFrame(EMCState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2a_setCharacterFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+	_animNewFrame = stackPos(0);
+	_animDelayTime = stackPos(1);
+	_animNeedUpdate = true;
 	return 0;
 }
 
-int KyraEngine_HoF::o2t_setCurrentFrame(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_setCurrentFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
-	_newShapeAnimFrame = stackPos(0);
-	_newShapeDelay = stackPos(1);
-	_temporaryScriptExecBit = true;
-	return 0;
-}
-
-int KyraEngine_HoF::o2t_playSoundEffect(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_playSoundEffect(%p) (%d)", (const void *)script, stackPos(0));
-	snd_playSoundEffect(stackPos(0));
-	return 0;
-}
-
-int KyraEngine_HoF::o2t_fadeScenePal(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_fadeScenePal(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
-	fadeScenePal(stackPos(0), stackPos(1));
-	return 0;
-}
-
-int KyraEngine_HoF::o2t_setShapeFlag(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2t_setShapeFlag(%p) (%d)", (const void *)script, stackPos(0));
-	if (_flags.isTalkie)
-		_newShapeFlag = stackPos(0);
-	return 0;
-}
-
 #pragma mark -
 
 int KyraEngine_HoF::t2_initChat(const TIM *tim, const uint16 *param) {
@@ -1995,15 +1961,15 @@
 	Opcode(o2_demoFinale);
 	Opcode(o2_dummy);
 
-	SetOpcodeTable(_opcodesTemporary);
+	SetOpcodeTable(_opcodesAnimation);
 
 	// 0x00
-	Opcode(o2t_defineNewShapes);
-	Opcode(o2t_setCurrentFrame);
-	Opcode(o2t_playSoundEffect);
-	Opcode(o2t_fadeScenePal);
+	Opcode(o2a_setAnimationShapes);
+	Opcode(o2a_setCharacterFrame);
+	Opcode(o2_playSoundEffect);
+	Opcode(o2_fadeScenePal);
 	// 0x04
-	Opcode(o2t_setShapeFlag);
+	_flags.isTalkie ? Opcode(o2a_setResetFrame) : Opcode(o2_dummy);
 	Opcode(o2_dummy);
 
 	// ---- TIM opcodes

Modified: scummvm/trunk/engines/kyra/script_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_mr.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/script_mr.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -905,7 +905,7 @@
 	const int newShapes = stackPos(1);
 	const int unloadShapes = stackPos(2);
 	const int allowSkip = stackPos(3);
-	runTemporaryScript(stackPosString(0), allowSkip, (unloadShapes != 0) ? 1 : 0, newShapes, unloadShapes);
+	runAnimationScript(stackPosString(0), allowSkip, (unloadShapes != 0) ? 1 : 0, newShapes, unloadShapes);
 	return 0;
 }
 
@@ -1264,39 +1264,21 @@
 
 #pragma mark -
 
-int KyraEngine_MR::o3t_defineNewShapes(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_defineNewShapes(%p) ('%s', %d, %d, %d, %d, %d)", (const void *)script,
-			stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5));
-	strcpy(_newShapeFilename, stackPosString(0));
-	_newShapeLastEntry = stackPos(1);
-	_newShapeWidth = stackPos(2);
-	_newShapeHeight = stackPos(3);
-	_newShapeXAdd = stackPos(4);
-	_newShapeYAdd = stackPos(5);
-	return 0;
-}
-
-int KyraEngine_MR::o3t_setCurrentFrame(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_setCurrentFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+int KyraEngine_MR::o3a_setCharacterFrame(EMCState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3a_setCharacterFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
 	static const uint8 frameTable[] = {
 		0x58, 0xD8, 0xD8, 0x98, 0x78, 0x78, 0xB8, 0xB8
 	};
 
-	_newShapeAnimFrame = stackPos(0);
+	_animNewFrame = stackPos(0);
 	if (_useFrameTable)
-		_newShapeAnimFrame += frameTable[_mainCharacter.facing];
+		_animNewFrame += frameTable[_mainCharacter.facing];
 
-	_newShapeDelay = stackPos(1);
-	_temporaryScriptExecBit = true;
+	_animDelayTime = stackPos(1);
+	_animNeedUpdate = true;
 	return 0;
 }
 
-int KyraEngine_MR::o3t_setNewShapeFlag(EMCState *script) {
-	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_setNewShapeFlag(%p) (%d)", (const void *)script, stackPos(0));
-	_newShapeFlag = stackPos(0);
-	return 0;
-}
-
 #pragma mark -
 
 int KyraEngine_MR::o3d_updateAnim(EMCState *script) {
@@ -1550,14 +1532,14 @@
 	OpcodeUnImpl();
 	Opcode(o3_dummy);
 	
-	SetOpcodeTable(_opcodesTemporary);
+	SetOpcodeTable(_opcodesAnimation);
 	// 0x00
-	Opcode(o3t_defineNewShapes);
-	Opcode(o3t_setCurrentFrame);
+	Opcode(o2a_setAnimationShapes);
+	Opcode(o3a_setCharacterFrame);
 	Opcode(o3_playSoundEffect);
 	Opcode(o3_dummy);
 	// 0x0a
-	Opcode(o3t_setNewShapeFlag);
+	Opcode(o2a_setResetFrame);
 	Opcode(o3_getRand);
 	Opcode(o3_getMalcolmShapes);
 	Opcode(o3_dummy);

Modified: scummvm/trunk/engines/kyra/script_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_v2.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/script_v2.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -26,6 +26,8 @@
 #include "kyra/kyra_v2.h"
 #include "kyra/screen_v2.h"
 
+#include "common/endian.h"
+
 namespace Kyra {
 
 int KyraEngine_v2::o2_getCharacterX(EMCState *script) {
@@ -137,5 +139,25 @@
 	return 0;
 }
 
+#pragma mark -
+
+int KyraEngine_v2::o2a_setAnimationShapes(EMCState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o2a_setAnimationShapes(%p) ('%s', %d, %d, %d, %d, %d)", (const void *)script,
+			stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5));
+	strcpy(_animShapeFilename, stackPosString(0));
+	_animShapeLastEntry = stackPos(1);
+	_animShapeWidth = stackPos(2);
+	_animShapeHeight = stackPos(3);
+	_animShapeXAdd = stackPos(4);
+	_animShapeYAdd = stackPos(5);
+	return 0;
+}
+
+int KyraEngine_v2::o2a_setResetFrame(EMCState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3t_setResetFrame(%p) (%d)", (const void *)script, stackPos(0));
+	_animResetFrame = stackPos(0);
+	return 0;
+}
+
 } // end of namespace Kyra
 

Modified: scummvm/trunk/engines/kyra/sequences_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_hof.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/sequences_hof.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -2626,13 +2626,13 @@
 		_demoAnimData = _staticres->loadHofShapeAnimDataV1(k2SeqplayShapeAnimData, _itemAnimDataSize);
 		uint8 *shp = _res->fileData("icons.shp", 0);
 		uint32 outsize = READ_LE_UINT16(shp + 4);
-		_newShapeFiledata = new uint8[outsize];
-		Screen::decodeFrame4(shp + 10, _newShapeFiledata, outsize);
+		_animShapeFiledata = new uint8[outsize];
+		Screen::decodeFrame4(shp + 10, _animShapeFiledata, outsize);
 		delete [] shp;
 
 		do {
 			numShp++;
-			addShapeToPool(_screen->getPtrToShape(_newShapeFiledata, numShp), numShp);
+			addShapeToPool(_screen->getPtrToShape(_animShapeFiledata, numShp), numShp);
 		} while (getShapePtr(numShp));
 	} else {	
 		MainMenu::StaticData data = {
@@ -2659,8 +2659,8 @@
 	delete _seqWsa;
 	_seqWsa = NULL;
 
-	delete [] _newShapeFiledata;
-	_newShapeFiledata = 0;
+	delete [] _animShapeFiledata;
+	_animShapeFiledata = 0;
 
 	if (_flags.isDemo && !_flags.isTalkie)
 		_staticres->unloadId(k2SeqplayShapeAnimData);

Modified: scummvm/trunk/engines/kyra/sequences_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_mr.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/sequences_mr.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -183,54 +183,6 @@
 	setNextIdleAnimTimer();
 }
 
-void KyraEngine_MR::runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload) {
-	debugC(9, kDebugLevelMain, "KyraEngine_MR::runTemporaryScript('%s', %d, %d, %d, %d)", filename, allowSkip, resetChar, newShapes, shapeUnload);
-	memset(&_temporaryScriptData, 0, sizeof(_temporaryScriptData));
-	memset(&_temporaryScriptState, 0, sizeof(_temporaryScriptState));
-
-	if (!_emc->load(filename, &_temporaryScriptData, &_opcodesTemporary))
-		error("Couldn't load temporary script '%s'", filename);
-
-	_emc->init(&_temporaryScriptState, &_temporaryScriptData);
-	_emc->start(&_temporaryScriptState, 0);
-
-	_newShapeFlag = -1;
-
-	if (_newShapeFiledata && newShapes) {
-		resetNewShapes(_newShapeCount, _newShapeFiledata);
-		_newShapeFiledata = 0;
-		_newShapeCount = 0;
-	}
-
-	while (_emc->isValid(&_temporaryScriptState))
-		_emc->run(&_temporaryScriptState);
-
-	uint8 *fileData = 0;
-
-	if (newShapes)
-		_newShapeFiledata = _res->fileData(_newShapeFilename, 0);
-
-	fileData = _newShapeFiledata;
-
-	if (!fileData) {
-		_emc->unload(&_temporaryScriptData);
-		return;
-	}
-
-	if (newShapes)
-		_newShapeCount = initNewShapes(fileData);
-
-	processNewShapes(allowSkip, resetChar);
-
-	if (shapeUnload) {
-		resetNewShapes(_newShapeCount, fileData);
-		_newShapeCount = 0;
-		_newShapeFiledata = 0;
-	}
-
-	_emc->unload(&_temporaryScriptData);
-}
-
 void KyraEngine_MR::eelScript() {
 	debugC(9, kDebugLevelMain, "KyraEngine_MR::eelScript()");
 	if (_chatText)
@@ -252,24 +204,24 @@
 
 	switch (_characterShapeFile-1) {
 	case 0:
-		runTemporaryScript("EELS01.EMC", 0, 0, 1, 1);
+		runAnimationScript("EELS01.EMC", 0, 0, 1, 1);
 		break;
 
 	case 1:
-		runTemporaryScript("EELS02.EMC", 0, 0, 1, 1);
+		runAnimationScript("EELS02.EMC", 0, 0, 1, 1);
 		break;
 
 	case 2:
-		runTemporaryScript("EELS03.EMC", 0, 0, 1, 1);
+		runAnimationScript("EELS03.EMC", 0, 0, 1, 1);
 		break;
 	
 	case 3:
-		runTemporaryScript("EELS04.EMC", 0, 0, 1, 1);
+		runAnimationScript("EELS04.EMC", 0, 0, 1, 1);
 		break;
 
 	default:
 		resetGameFlag(0x171);
-		runTemporaryScript("EELS00.EMC", 0, 0, 1, 1);
+		runAnimationScript("EELS00.EMC", 0, 0, 1, 1);
 		break;
 	}
 
@@ -277,73 +229,16 @@
 	_screen->showMouse();
 }
 
-int KyraEngine_MR::initNewShapes(uint8 *filedata) {
-	debugC(9, kDebugLevelAnimator, "KyraEngine_MR::initNewShapes(%p)", (const void*)filedata);
-	const int lastEntry = MIN(_newShapeLastEntry, 41);
+int KyraEngine_MR::initAnimationShapes(uint8 *filedata) {
+	debugC(9, kDebugLevelAnimator, "KyraEngine_MR::initAnimationShapes(%p)", (const void*)filedata);
+	const int lastEntry = MIN(_animShapeLastEntry, 41);
 	for (int i = 0; i < lastEntry; ++i)
 		_gameShapes[9+i] = _screen->getPtrToShape(filedata, i);
 	return lastEntry;
 }
 
-void KyraEngine_MR::processNewShapes(int allowSkip, int resetChar) {
-	debugC(9, kDebugLevelAnimator, "KyraEngine_MR::processNewShapes(%d, %d)", allowSkip, resetChar);
-	setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
-
-	_emc->init(&_temporaryScriptState, &_temporaryScriptData);
-	_emc->start(&_temporaryScriptState, 1);
-
-	resetSkipFlag();
-
-	while (_emc->isValid(&_temporaryScriptState)) {
-		_temporaryScriptExecBit = false;
-		while (_emc->isValid(&_temporaryScriptState) && !_temporaryScriptExecBit)
-			_emc->run(&_temporaryScriptState);
-
-		if (_newShapeAnimFrame < 0)
-			continue;
-
-		_mainCharacter.animFrame = _newShapeAnimFrame + 9;
-		updateCharacterAnim(0);
-		if (_chatText)
-			updateWithText();
-		else
-			update();
-
-		uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength;
-
-		while ((!skipFlag() || !allowSkip) && _system->getMillis() < delayEnd) {
-			if (_chatText)
-				updateWithText();
-			else
-				update();
-
-			delay(10);
-		}
-
-		if (skipFlag())
-			resetSkipFlag();
-	}
-
-	if (resetChar) {
-		if (_newShapeFlag >= 0) {
-			_mainCharacter.animFrame = _newShapeFlag + 9;
-			updateCharacterAnim(0);
-			if (_chatText)
-				updateWithText();
-			else
-				update();
-		}
-
-		_mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
-		updateCharacterAnim(0);
-	}
-
-	_newShapeFlag = -1;
-	resetCharacterAnimDim();
-}
-
-void KyraEngine_MR::resetNewShapes(int count, uint8 *filedata) {
-	debugC(9, kDebugLevelAnimator, "KyraEngine_MR::resetNewShapes(%d, %p)", count, (const void*)filedata);
+void KyraEngine_MR::uninitAnimationShapes(int count, uint8 *filedata) {
+	debugC(9, kDebugLevelAnimator, "KyraEngine_MR::uninitAnimationShapes(%d, %p)", count, (const void*)filedata);
 	for (int i = 0; i < count; ++i)
 		_gameShapes[9+i] = 0;
 	delete [] filedata;

Added: scummvm/trunk/engines/kyra/sequences_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_v2.cpp	                        (rev 0)
+++ scummvm/trunk/engines/kyra/sequences_v2.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -0,0 +1,137 @@
+/* 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 "kyra/kyra_v2.h"
+#include "kyra/resource.h"
+
+namespace Kyra {
+
+void KyraEngine_v2::runAnimationScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v2::runAnimationScript('%s', %d, %d, %d, %d)", filename, allowSkip, resetChar, newShapes, shapeUnload);
+	memset(&_animationScriptData, 0, sizeof(_animationScriptData));
+	memset(&_animationScriptState, 0, sizeof(_animationScriptState));
+
+	if (!_emc->load(filename, &_animationScriptData, &_opcodesAnimation))
+		error("Couldn't load temporary script '%s'", filename);
+
+	_emc->init(&_animationScriptState, &_animationScriptData);
+	_emc->start(&_animationScriptState, 0);
+
+	_animResetFrame = -1;
+
+	if (_animShapeFiledata && newShapes) {
+		uninitAnimationShapes(_animShapeCount, _animShapeFiledata);
+		_animShapeFiledata = 0;
+		_animShapeCount = 0;
+	}
+
+	while (_emc->isValid(&_animationScriptState))
+		_emc->run(&_animationScriptState);
+
+	uint8 *fileData = 0;
+
+	if (newShapes)
+		_animShapeFiledata = _res->fileData(_animShapeFilename, 0);
+
+	fileData = _animShapeFiledata;
+
+	if (!fileData) {
+		_emc->unload(&_animationScriptData);
+		return;
+	}
+
+	if (newShapes)
+		_animShapeCount = initAnimationShapes(fileData);
+
+	processAnimationScript(allowSkip, resetChar);
+
+	if (shapeUnload) {
+		uninitAnimationShapes(_animShapeCount, fileData);
+		_animShapeCount = 0;
+		_animShapeFiledata = 0;
+	}
+
+	_emc->unload(&_animationScriptData);
+}
+
+void KyraEngine_v2::processAnimationScript(int allowSkip, int resetChar) {
+	debugC(9, kDebugLevelAnimator, "KyraEngine_v2::processAnimationScript(%d, %d)", allowSkip, resetChar);
+	setCharacterAnimDim(_animShapeWidth, _animShapeHeight);
+
+	_emc->init(&_animationScriptState, &_animationScriptData);
+	_emc->start(&_animationScriptState, 1);
+
+	resetSkipFlag();
+
+	while (_emc->isValid(&_animationScriptState)) {
+		_animNeedUpdate = false;
+		while (_emc->isValid(&_animationScriptState) && !_animNeedUpdate)
+			_emc->run(&_animationScriptState);
+
+		if (_animNewFrame < 0)
+			continue;
+
+		_mainCharacter.animFrame = _animNewFrame + _desc.animScriptFrameAdd;
+		updateCharacterAnim(0);
+		if (_chatText)
+			updateWithText();
+		else
+			update();
+
+		uint32 delayEnd = _system->getMillis() + _animDelayTime * _tickLength;
+
+		while ((!skipFlag() || !allowSkip) && _system->getMillis() < delayEnd) {
+			if (_chatText)
+				updateWithText();
+			else
+				update();
+
+			delay(10);
+		}
+
+		if (skipFlag())
+			resetSkipFlag();
+	}
+
+	if (resetChar) {
+		if (_animResetFrame >= 0) {
+			_mainCharacter.animFrame = _animResetFrame + _desc.animScriptFrameAdd;
+			updateCharacterAnim(0);
+			if (_chatText)
+				updateWithText();
+			else
+				update();
+		}
+
+		_mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
+		updateCharacterAnim(0);
+	}
+
+	_animResetFrame = -1;
+	resetCharacterAnimDim();
+}
+
+} // end of namespace Kyra
+


Property changes on: scummvm/trunk/engines/kyra/sequences_v2.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -1540,7 +1540,7 @@
 	"JMC"
 };
 
-const int KyraEngine_HoF::_characterFrameTable[] = {
+const uint8 KyraEngine_HoF::_characterFrameTable[] = {
 	0x19, 0x09, 0x09, 0x12, 0x12, 0x12, 0x09, 0x09
 };
 

Modified: scummvm/trunk/engines/kyra/text_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_hof.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/text_hof.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -299,16 +299,16 @@
 	memset(&_chatScriptData, 0, sizeof(_chatScriptData));
 	memset(&_chatScriptState, 0, sizeof(_chatScriptState));
 
-	_emc->load(script, &_chatScriptData, &_opcodesTemporary);
+	_emc->load(script, &_chatScriptData, &_opcodesAnimation);
 	_emc->init(&_chatScriptState, &_chatScriptData);
 	_emc->start(&_chatScriptState, 0);
 	while (_emc->isValid(&_chatScriptState))
 		_emc->run(&_chatScriptState);
 
-	_newShapeFilename[2] = _characterShapeFile + '0';
-	uint8 *shapeBuffer = _res->fileData(_newShapeFilename, 0);
+	_animShapeFilename[2] = _characterShapeFile + '0';
+	uint8 *shapeBuffer = _res->fileData(_animShapeFilename, 0);
 	if (shapeBuffer) {
-		int shapeCount = initNewShapes(shapeBuffer);
+		int shapeCount = initAnimationShapes(shapeBuffer);
 
 		if (_chatVocHigh >= 0) {
 			playVoice(_chatVocHigh, _chatVocLow);
@@ -317,9 +317,9 @@
 
 		objectChatWaitToFinish();
 
-		resetNewShapes(shapeCount, shapeBuffer);
+		uninitAnimationShapes(shapeCount, shapeBuffer);
 	} else {
-		warning("couldn't load file '%s'", _newShapeFilename);
+		warning("couldn't load file '%s'", _animShapeFilename);
 	}
 
 	_emc->unload(&_chatScriptData);
@@ -327,7 +327,7 @@
 
 void KyraEngine_HoF::objectChatWaitToFinish() {
 	int charAnimFrame = _mainCharacter.animFrame;
-	setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
+	setCharacterAnimDim(_animShapeWidth, _animShapeHeight);
 
 	_emc->init(&_chatScriptState, &_chatScriptData);
 	_emc->start(&_chatScriptState, 1);
@@ -340,12 +340,12 @@
 		if (!_emc->isValid(&_chatScriptState))
 			_emc->start(&_chatScriptState, 1);
 
-		_temporaryScriptExecBit = false;
-		while (!_temporaryScriptExecBit && _emc->isValid(&_chatScriptState))
+		_animNeedUpdate = false;
+		while (!_animNeedUpdate && _emc->isValid(&_chatScriptState))
 			_emc->run(&_chatScriptState);
 
-		int curFrame = _newShapeAnimFrame;
-		uint32 delayTime = _newShapeDelay;
+		int curFrame = _animNewFrame;
+		uint32 delayTime = _animDelayTime;
 
 		if (!_chatIsNote)
 			_mainCharacter.animFrame = 33 + curFrame;

Modified: scummvm/trunk/engines/kyra/text_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_mr.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/text_mr.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -312,7 +312,7 @@
 	memset(&_chatScriptData, 0, sizeof(_chatScriptData));
 	memset(&_chatScriptState, 0, sizeof(_chatScriptState));
 
-	_emc->load(script, &_chatScriptData, &_opcodesTemporary);
+	_emc->load(script, &_chatScriptData, &_opcodesAnimation);
 	_emc->init(&_chatScriptState, &_chatScriptData);
 	_emc->start(&_chatScriptState, 0);
 	while (_emc->isValid(&_chatScriptState))
@@ -333,7 +333,7 @@
 void KyraEngine_MR::objectChatWaitToFinish() {
 	debugC(9, kDebugLevelMain, "KyraEngine_MR::objectChatWaitToFinish()");
 	int charAnimFrame = _mainCharacter.animFrame;
-	setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
+	setCharacterAnimDim(_animShapeWidth, _animShapeHeight);
 
 	_emc->init(&_chatScriptState, &_chatScriptData);
 	_emc->start(&_chatScriptState, 1);
@@ -346,14 +346,14 @@
 		if (!_emc->isValid(&_chatScriptState))
 			_emc->start(&_chatScriptState, 1);
 
-		_temporaryScriptExecBit = false;
-		while (!_temporaryScriptExecBit && _emc->isValid(&_chatScriptState)) {
+		_animNeedUpdate = false;
+		while (!_animNeedUpdate && _emc->isValid(&_chatScriptState)) {
 			musicUpdate(0);
 			_emc->run(&_chatScriptState);
 		}
 
-		int curFrame = _newShapeAnimFrame;
-		uint32 delayTime = _newShapeDelay;
+		int curFrame = _animNewFrame;
+		uint32 delayTime = _animDelayTime;
 
 		_mainCharacter.animFrame = curFrame;
 		updateCharacterAnim(0);

Modified: scummvm/trunk/engines/kyra/timer_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/timer_hof.cpp	2008-05-03 13:01:58 UTC (rev 31840)
+++ scummvm/trunk/engines/kyra/timer_hof.cpp	2008-05-03 19:23:45 UTC (rev 31841)
@@ -91,7 +91,7 @@
 	_timer->disable(5);
 	_screen->hideMouse();
 	snd_playSoundEffect(0x2D);
-	runTemporaryScript("_ZANBURN.EMC", 0, 1, 1, 0);
+	runAnimationScript("_ZANBURN.EMC", 0, 1, 1, 0);
 	_deathHandler = 7;
 	snd_playWanderScoreViaMap(0x53, 1);
 }


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