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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Oct 12 02:58:59 CEST 2007


Revision: 29187
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29187&view=rev
Author:   lordhoto
Date:     2007-10-11 17:58:59 -0700 (Thu, 11 Oct 2007)

Log Message:
-----------
HoF:
- Subclassed TextDisplayer for use with Kyra2
- Implemented opcodes:
  -> o2_zanthiaChat 169
  -> o2_customChat 152
  -> o2_customChatFinish 153

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/module.mk
    scummvm/trunk/engines/kyra/script_v2.cpp
    scummvm/trunk/engines/kyra/sequences_v2.cpp
    scummvm/trunk/engines/kyra/text.h

Added Paths:
-----------
    scummvm/trunk/engines/kyra/text_v2.cpp
    scummvm/trunk/engines/kyra/text_v2.h

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2007-10-12 00:58:59 UTC (rev 29187)
@@ -136,8 +136,6 @@
 	_res = new Resource(this);
 	assert(_res);
 	_res->reset();
-	_text = new TextDisplayer(this, this->screen());
-	assert(_text);
 	_staticres = new StaticResource(this);
 	assert(_staticres);
 	if (!_staticres->init())

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2007-10-12 00:58:59 UTC (rev 29187)
@@ -175,6 +175,8 @@
 	assert(_animator);
 	_animator->init(5, 11, 12);
 	assert(*_animator);
+	_text = new TextDisplayer(this, screen());
+	assert(_text);
 
 	initStaticResource();
 	

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-10-12 00:58:59 UTC (rev 29187)
@@ -30,7 +30,7 @@
 #include "kyra/wsamovie.h"
 #include "kyra/sound.h"
 #include "kyra/script.h"
-#include "kyra/text.h"
+#include "kyra/text_v2.h"
 #include "kyra/timer.h"
 #include "kyra/debugger.h"
 
@@ -43,6 +43,7 @@
 	_mouseSHPBuf = 0;
 	_debugger = 0;
 	_screen = 0;
+	_text = 0;
 	
 	_gamePlayBuffer = 0;
 	_cCodeBuffer = _optionsBuffer = _chapterBuffer = 0;
@@ -72,6 +73,8 @@
 KyraEngine_v2::~KyraEngine_v2() {
 	delete [] _mouseSHPBuf;
 	delete _screen;
+	delete _text;
+	_text = 0;
 	delete _debugger;
 }
 
@@ -89,6 +92,8 @@
 
 	_debugger = new Debugger_v2(this);
 	assert(_debugger);
+	_text = new TextDisplayer_v2(this, _screen);
+	assert(_text);
 	
 	setupTimers();
 
@@ -462,6 +467,30 @@
 	return 0;
 }
 
+void KyraEngine_v2::updateWithText() {
+	updateInput();
+
+	updateMouse();
+	//sub_157C();
+	updateSpecialSceneScripts();
+	_timer->update();
+	//sub_274C0();
+	//updateInvWsa();
+	//XXX
+	restorePage3();
+	drawAnimObjects();
+
+	if (1/*textEnabled()*/ && _chatText) {
+		int pageBackUp = _screen->_curPage;
+		_screen->_curPage = 2;
+		objectChatPrintText(_chatText, _chatObject);
+		_screen->_curPage = pageBackUp;
+	}
+
+	refreshAnimObjects(0);
+	_screen->updateScreen();
+}
+
 void KyraEngine_v2::updateMouse() {
 	int shapeIndex = 0;
 	int type = 0;
@@ -1304,9 +1333,9 @@
 
 		_mainCharacter.animFrame = _newShapeAnimFrame + 33;
 		updateCharacterAnim(0);
-		//if (dword_30BB2)
-		//	sub_159D6();
-		//else
+		if (_chatText)
+			updateWithText();
+		else
 			update();
 
 		uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength;
@@ -1314,9 +1343,9 @@
 		while (!_skipFlag && _system->getMillis() < delayEnd) {
 			// XXX skipFlag handling, unk1 seems to make a scene not skipable
 
-			//if (dword_30BB2)
-			//	sub_159D6();
-			//else
+			if (_chatText)
+				updateWithText();
+			else
 				update();
 
 			delay(10);
@@ -1327,9 +1356,9 @@
 		if (_newShapeFlag >= 0) {
 			_mainCharacter.animFrame = _newShapeFlag + 33;
 			updateCharacterAnim(0);
-			//if (dword_30BB2)
-			//	sub_159D6();
-			//else
+			if (_chatText)
+				updateWithText();
+			else
 				update();
 		}
 
@@ -1567,10 +1596,10 @@
 		Opcode(o2_wsaClose),
 		OpcodeUnImpl(),
 		// 0x98
+		Opcode(o2_customChat),
+		Opcode(o2_customChatFinish),
 		OpcodeUnImpl(),
 		OpcodeUnImpl(),
-		OpcodeUnImpl(),
-		OpcodeUnImpl(),
 		// 0x9c
 		OpcodeUnImpl(),
 		OpcodeUnImpl(),
@@ -1588,9 +1617,9 @@
 		OpcodeUnImpl(),
 		// 0xa8
 		OpcodeUnImpl(),
+		Opcode(o2_zanthiaChat),
 		OpcodeUnImpl(),
 		OpcodeUnImpl(),
-		OpcodeUnImpl(),
 		// 0xac
 		OpcodeUnImpl(),
 		OpcodeUnImpl(),

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2007-10-12 00:58:59 UTC (rev 29187)
@@ -47,6 +47,7 @@
 
 class WSAMovieV2;
 class KyraEngine_v2;
+class TextDisplayer_v2;
 class Debugger_v2;
 
 struct SequenceControl {
@@ -87,12 +88,14 @@
 
 class KyraEngine_v2 : public KyraEngine {
 friend class Debugger_v2;
+friend class TextDisplayer_v2;
 public:
 	KyraEngine_v2(OSystem *system, const GameFlags &flags);
 	~KyraEngine_v2();
 	
 	virtual Screen *screen() { return _screen; }
 	Screen_v2 *screen_v2() { return _screen; }
+	int language() const { return _lang; }
 	
 	virtual Movie *createWSAMovie();
 protected:
@@ -137,6 +140,7 @@
 	int go();
 	
 	Screen_v2 *_screen;
+	TextDisplayer_v2 *_text;
 	Debugger_v2 *_debugger;
 	
 	ActiveWSA *_activeWSA;
@@ -169,6 +173,7 @@
 	
 	// run
 	int update();
+	void updateWithText();
 	void updateMouse();
 	
 	int checkInput(void *p);
@@ -492,6 +497,24 @@
 	byte _messagePal[3];
 	int _msgUnk1;
 
+	// chat
+	const char *_chatText;
+	int _chatObject;
+	bool _chatIsNote;
+	uint32 _chatEndTime;
+
+	ScriptData _chatScriptData;
+	ScriptState _chatScriptState;
+
+	int chatGetType(const char *text);
+	int chatCalcDuration(const char *text);
+
+	void objectChat(const char *text, int object, int unk1, int unk2);
+	void objectChatInit(const char *text, int object, int unk1, int unk2);
+	void objectChatPrintText(const char *text, int object);
+	void objectChatProcess(const char *script);
+	void objectChatWaitToFinish();
+
 	// sound
 	void snd_loadSoundFile(int id);
 	
@@ -556,6 +579,9 @@
 	int o2_setSpecialSceneScriptState(ScriptState *script);
 	int o2_clearSpecialSceneScriptState(ScriptState *script);
 	int o2_querySpecialSceneScriptState(ScriptState *script);
+	int o2_customChat(ScriptState *script);
+	int o2_customChatFinish(ScriptState *script);
+	int o2_zanthiaChat(ScriptState *script);
 	int o2_dummy(ScriptState *script);
 
 	// opcodes temporary
@@ -591,7 +617,7 @@
 		char filename[13];
 		uint8 scriptId;
 		int16 x, y;
-		int8 unk12;
+		int8 color;
 	};
 	Object *_objectList;
 	

Modified: scummvm/trunk/engines/kyra/module.mk
===================================================================
--- scummvm/trunk/engines/kyra/module.mk	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/module.mk	2007-10-12 00:58:59 UTC (rev 29187)
@@ -36,6 +36,7 @@
 	staticres.o \
 	text.o \
 	text_v1.o \
+	text_v2.o \
 	timer.o \
 	timer_v1.o \
 	timer_v2.o \

Modified: scummvm/trunk/engines/kyra/script_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_v2.cpp	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/script_v2.cpp	2007-10-12 00:58:59 UTC (rev 29187)
@@ -24,6 +24,7 @@
  */
 
 #include "kyra/kyra_v2.h"
+#include "kyra/text_v2.h"
 #include "kyra/wsamovie.h"
 
 #include "common/endian.h"
@@ -49,7 +50,7 @@
 	object->scriptId = stackPos(2);
 	object->x = stackPos(3);
 	object->y = stackPos(4);
-	object->unk12 = stackPos(5);
+	object->color = stackPos(5);
 	return 0;
 }
 
@@ -369,9 +370,9 @@
 
 	int times = stackPos(0);
 	while (times--) {
-		//if (dword_30BB2)
-		//	sub_159D6();
-		//else
+		if (_chatText)
+			updateWithText();
+		else
 			update();
 	}
 
@@ -595,6 +596,31 @@
 	return _specialSceneScriptState[stackPos(0)];
 }
 
+int KyraEngine_v2::o2_customChat(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_customChat(%p) ('%s', %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2));
+	strcpy((char*)_unkBuf500Bytes, stackPosString(0));
+	_chatText = (char*)_unkBuf500Bytes;
+	_chatObject = stackPos(1);
+	//XXX
+	objectChatInit(_chatText, _chatObject, 0/*_unk11*/, stackPos(2));
+	//XXX
+	return 0;
+}
+
+int KyraEngine_v2::o2_customChatFinish(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_customChatFinish(%p) ()", (const void *)script);
+	_text->restoreScreen();
+	_chatText = 0;
+	_chatObject = -1;
+	return 0;
+}
+
+int KyraEngine_v2::o2_zanthiaChat(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_zanthiaChat(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1));
+	objectChat(stackPosString(0), 0, /*_unk11*/0, stackPos(1));
+	return 0;
+}
+
 int KyraEngine_v2::o2_dummy(ScriptState *script) {
 	debugC(3, kDebugLevelScriptFuncs, "o2_dummy(%p) ()", (const void *)script);
 	return 0;

Modified: scummvm/trunk/engines/kyra/sequences_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_v2.cpp	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/sequences_v2.cpp	2007-10-12 00:58:59 UTC (rev 29187)
@@ -28,7 +28,7 @@
 #include "kyra/screen.h"
 #include "kyra/wsamovie.h"
 #include "kyra/sound.h"
-#include "kyra/text.h"
+#include "kyra/text_v2.h"
 
 #include "common/system.h"
 

Modified: scummvm/trunk/engines/kyra/text.h
===================================================================
--- scummvm/trunk/engines/kyra/text.h	2007-10-11 22:19:43 UTC (rev 29186)
+++ scummvm/trunk/engines/kyra/text.h	2007-10-12 00:58:59 UTC (rev 29187)
@@ -26,10 +26,12 @@
 #ifndef KYRA_TEXT_H
 #define KYRA_TEXT_H
 
+#include "common/scummsys.h"
+
+#include "kyra/screen.h"
+
 namespace Kyra {
-class Screen;
 class KyraEngine;
-class FontId;
 
 class TextDisplayer {
 	struct TalkCoords {
@@ -38,21 +40,23 @@
 
 	enum {
 		TALK_SUBSTRING_LEN = 80,
-		TALK_SUBSTRING_NUM = 3
+		TALK_SUBSTRING_NUM = 5
 	};
 public:
 	TextDisplayer(KyraEngine *vm, Screen *screen);
-	~TextDisplayer() {}
+	virtual ~TextDisplayer() {}
 
+	int maxSubstringLen() const { return TALK_SUBSTRING_LEN; }
+
 	void setTalkCoords(uint16 y);
 	int getCenterStringX(const char *str, int x1, int x2);
 	int getCharLength(const char *str, int len);
 	int dropCRIntoString(char *str, int offs);
-	char *preprocessString(const char *str);
+	virtual char *preprocessString(const char *str);
 	int buildMessageSubstrings(const char *str);
 	int getWidestLineWidth(int linesCount);
-	void calcWidestLineBounds(int &x1, int &x2, int w, int cx);
-	void restoreTalkTextMessageBkgd(int srcPage, int dstPage);
+	virtual void calcWidestLineBounds(int &x1, int &x2, int w, int cx);
+	virtual void restoreTalkTextMessageBkgd(int srcPage, int dstPage);
 	void printTalkTextMessage(const char *text, int x, int y, uint8 color, int srcPage, int dstPage);
 	void printIntroTextMessage(const char *text, int x, int y, uint8 col1, uint8 col2, uint8 col3,
 			int dstPage, Screen::FontId font=Screen::FID_8_FNT);	
@@ -62,11 +66,11 @@
 	uint16 _talkMessageY;
 	uint16 _talkMessageH;
 	bool printed() const { return _talkMessagePrinted; }
-private:
+protected:
 	Screen *_screen;
 	KyraEngine *_vm;
 
-	char _talkBuffer[300];
+	char _talkBuffer[1040];
 	char _talkSubstrings[TALK_SUBSTRING_LEN * TALK_SUBSTRING_NUM];
 	TalkCoords _talkCoords;
 	bool _talkMessagePrinted;

Added: scummvm/trunk/engines/kyra/text_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_v2.cpp	                        (rev 0)
+++ scummvm/trunk/engines/kyra/text_v2.cpp	2007-10-12 00:58:59 UTC (rev 29187)
@@ -0,0 +1,323 @@
+/* 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/text_v2.h"
+#include "kyra/kyra_v2.h"
+#include "kyra/resource.h"
+
+namespace Kyra {
+
+TextDisplayer_v2::TextDisplayer_v2(KyraEngine_v2 *vm, Screen_v2 *screen)
+	: _vm(vm), TextDisplayer(vm, screen) {
+}
+
+void TextDisplayer_v2::backupTalkTextMessageBkgd(int srcPage, int dstPage) {
+	_screen->copyRegion(_talkCoords.x, _talkMessageY, 0, 144, _talkCoords.w, _talkMessageH, srcPage, dstPage);
+}
+
+void TextDisplayer_v2::restoreScreen() {
+	_vm->restorePage3();
+	_vm->drawAnimObjects();
+	_screen->hideMouse();
+	_screen->copyRegion(_talkCoords.x, _talkMessageY, _talkCoords.x, _talkMessageY, _talkCoords.w, _talkMessageH, 2, 0);
+	_screen->showMouse();
+	_vm->flagAnimObjsForRefresh();
+	_vm->refreshAnimObjects(0);
+}
+
+char *TextDisplayer_v2::preprocessString(const char *str) {
+	debugC(9, kDebugLevelMain, "TextDisplayer_v2::preprocessString('%s')", str);
+	if (str != _talkBuffer) {
+		assert(strlen(str) < sizeof(_talkBuffer) - 1);
+		strcpy(_talkBuffer, str);
+	}
+	char *p = _talkBuffer;
+	while (*p) {
+		if (*p == '\r')
+			return _talkBuffer;
+		++p;
+	}
+	p = _talkBuffer;
+	Screen::FontId curFont = _screen->setFont(Screen::FID_8_FNT);
+	_screen->_charWidth = -2;
+	int textWidth = _screen->getTextWidth(p);
+	_screen->_charWidth = 0;
+
+	// longer text strings for German versions
+	int maxTextWidth = (_vm->language() == 2 ? 240 : 176);
+
+	if (textWidth > maxTextWidth) {
+		if (textWidth > (maxTextWidth*2)) {
+			int count = getCharLength(p, textWidth / 3);
+			int offs = dropCRIntoString(p, count);
+			p += count + offs;
+			_screen->_charWidth = -2;
+			textWidth = _screen->getTextWidth(p);
+			_screen->_charWidth = 0;
+			count = getCharLength(p, textWidth / 2);
+			dropCRIntoString(p, count);
+		} else {
+			int count = getCharLength(p, textWidth / 2);
+			dropCRIntoString(p, count);
+		}
+	}
+	_screen->setFont(curFont);
+	return _talkBuffer;
+}
+
+void TextDisplayer_v2::calcWidestLineBounds(int &x1, int &x2, int w, int x) {
+	debugC(9, kDebugLevelMain, "TextDisplayer_v2::calcWidestLineBounds(%d, %d)", w, x);
+	x1 = x;
+	x1 -= (w >> 1);
+	x2 = x1 + w + 1;
+	
+	if (x1 + w >= 311)
+		x1 = 311 - w - 1;
+
+	if (x1 < 8)
+		x1 = 8;
+
+	x2 = x1 + w + 1;
+}
+
+#pragma mark -
+
+int KyraEngine_v2::chatGetType(const char *str) {
+	str += strlen(str);
+	--str;
+	switch (*str) {
+	case '!':
+		return 2;
+	
+	case ')':
+		return -1;
+	
+	case '?':
+		return 1;
+	
+	default:
+		return 0;
+	}
+}
+
+int KyraEngine_v2::chatCalcDuration(const char *str) {
+	return MIN<int>(strlen(str) << 3, 120);
+}
+
+void KyraEngine_v2::objectChat(const char *str, int object, int unk1, int unk2) {
+	//setNextIdleAnimTimer();
+
+	//XXX
+	
+	objectChatInit(str, object, unk1, unk2);
+	_chatText = str;
+	_chatObject = object;
+	_chatIsNote = (chatGetType(str) == -1);
+
+	if (_mainCharacter.facing > 7)
+		_mainCharacter.facing = 5;
+
+	static const uint8 talkScriptTable[] = {
+		6, 7, 8,
+		3, 4, 5,
+		3, 4, 5,
+		0, 1, 2,
+		0, 1, 2,
+		0, 1, 2,
+		3, 4, 5,
+		3, 4, 5
+	};
+
+	assert(_mainCharacter.facing * 3 + object < ARRAYSIZE(talkScriptTable));
+	int script = talkScriptTable[_mainCharacter.facing * 3 + object];
+
+	static const char *chatScriptFilenames[] = {
+		"_Z1FSTMT.EMC",
+		"_Z1FQUES.EMC",
+		"_Z1FEXCL.EMC",
+		"_Z1SSTMT.EMC",
+		"_Z1SQUES.EMC",
+		"_Z1SEXCL.EMC",
+		"_Z1BSTMT.EMC",
+		"_Z1BQUES.EMC",
+		"_Z1BEXCL.EMC"
+	};
+
+	objectChatProcess(chatScriptFilenames[script]);
+	_chatIsNote = false;
+
+	_text->restoreScreen();
+
+	_mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
+	updateCharacterAnim(0);
+	
+	_chatText = 0;
+	_chatObject = -1;
+
+	//setNextIdelAnimTimer();
+}
+
+void KyraEngine_v2::objectChatInit(const char *str, int object, int unk1, int unk2) {
+	str = _text->preprocessString(str);
+	int lineNum = _text->buildMessageSubstrings(str);
+
+	int yPos = 0, xPos = 0;
+	
+	if (!object) {
+		int scale = getScale(_mainCharacter.x1, _mainCharacter.y1);
+		yPos = _mainCharacter.y1 - ((_mainCharacter.height * scale) >> 8) - 8;
+		xPos = _mainCharacter.x1;
+	} else {
+		yPos = _objectList[object].y;
+		xPos = _objectList[object].x;
+	}
+
+	yPos -= lineNum * 10;
+	yPos = MAX(yPos, 0);
+	_text->_talkMessageY = yPos;
+	_text->_talkMessageH = lineNum*10;
+
+	int width = _text->getWidestLineWidth(lineNum);
+	_text->calcWidestLineBounds(xPos, yPos, width, xPos);
+	_text->_talkCoords.x = xPos;
+	_text->_talkCoords.w = width + 2;
+
+	restorePage3();
+	_text->backupTalkTextMessageBkgd(2, 2);
+
+	_screen->hideMouse();
+
+	if (1/*textEnabled()*/) {
+		objectChatPrintText(str, object);
+		_chatEndTime = _system->getMillis() + chatCalcDuration(str) * _tickLength;
+	} else {
+		_chatEndTime = _system->getMillis();
+	}
+
+	//XXX
+	
+	_screen->showMouse();
+}
+
+void KyraEngine_v2::objectChatPrintText(const char *str, int object) {
+	int c1 = _objectList[object].color;
+	str = _text->preprocessString(str);
+	int lineNum = _text->buildMessageSubstrings(str);
+	int maxWidth = _text->getWidestLineWidth(lineNum);
+	int x = (object == 0) ? _mainCharacter.x1 : _objectList[object].x;
+	int cX1 = 0, cX2 = 0;
+	_text->calcWidestLineBounds(cX1, cX2, maxWidth, x);
+
+	for (int i = 0; i < lineNum; ++i) {
+		str = &_text->_talkSubstrings[i*_text->maxSubstringLen()];
+
+		int y = _text->_talkMessageY + i * 10;
+		x = _text->getCenterStringX(str, cX1, cX2);
+
+		_text->printText(str, x, y, c1, 0xCF, 0);
+	}
+}
+
+void KyraEngine_v2::objectChatProcess(const char *script) {
+	memset(&_chatScriptData, 0, sizeof(_chatScriptData));
+	memset(&_chatScriptState, 0, sizeof(_chatScriptState));
+
+	_scriptInterpreter->loadScript(script, &_chatScriptData, &_opcodesTemporary);
+	_scriptInterpreter->initScript(&_chatScriptState, &_chatScriptData);
+	_scriptInterpreter->startScript(&_chatScriptState, 0);
+	while (_scriptInterpreter->validScript(&_chatScriptState))
+		_scriptInterpreter->runScript(&_chatScriptState);
+
+	_newShapeFilename[2] = _loadedZTable + '0';
+	uint8 *shapeBuffer = _res->fileData(_newShapeFilename, 0);
+	if (shapeBuffer) {
+		int shapeCount = initNewShapes(shapeBuffer);
+		//XXX
+		objectChatWaitToFinish();
+		resetNewShapes(shapeCount, shapeBuffer);
+	} else {
+		warning("couldn't load file '%s'", _newShapeFilename);
+	}
+
+	_scriptInterpreter->unloadScript(&_chatScriptData);
+}
+
+void KyraEngine_v2::objectChatWaitToFinish() {
+	int charAnimFrame = _mainCharacter.animFrame;
+	setCharacterAnimDim(_newShapeWidth, _newShapeHeight);
+
+	_scriptInterpreter->initScript(&_chatScriptState, &_chatScriptData);
+	_scriptInterpreter->startScript(&_chatScriptState, 1);
+
+	bool running = true;
+	const uint32 endTime = _chatEndTime;
+
+	while (running) {
+		if (!_scriptInterpreter->validScript(&_chatScriptState))
+			_scriptInterpreter->startScript(&_chatScriptState, 1);
+
+		_temporaryScriptExecBit = false;
+		while (!_temporaryScriptExecBit && _scriptInterpreter->validScript(&_chatScriptState))
+			_scriptInterpreter->runScript(&_chatScriptState);
+
+		int curFrame = _newShapeAnimFrame;
+		uint32 delayTime = _newShapeDelay;
+
+		if (!_chatIsNote)
+			_mainCharacter.animFrame = 33 + curFrame;
+
+		updateCharacterAnim(0);
+
+		uint32 nextFrame = _system->getMillis() + delayTime * _tickLength;
+
+		while (_system->getMillis() < nextFrame) {
+			updateWithText();
+
+			int inputFlag = checkInput(0);
+			removeInputTop();
+			if (inputFlag == 198 || inputFlag == 199) {
+				//XXX
+				_skipFlag = true;
+			}
+
+			const uint32 curTime = _system->getMillis();
+			//XXX
+			if (curTime > endTime || _skipFlag) {
+				_skipFlag = false;
+				nextFrame = curTime;
+				running = false;
+			}
+
+			delay(10);
+		}
+	}
+
+	_mainCharacter.animFrame = charAnimFrame;
+	updateCharacterAnim(0);
+	resetCharacterAnimDim();
+}
+
+} // end of namespace Kyra
+


Property changes on: scummvm/trunk/engines/kyra/text_v2.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: scummvm/trunk/engines/kyra/text_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/text_v2.h	                        (rev 0)
+++ scummvm/trunk/engines/kyra/text_v2.h	2007-10-12 00:58:59 UTC (rev 29187)
@@ -0,0 +1,53 @@
+/* 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 KYRA_TEXT_V2_H
+#define KYRA_TEXT_V2_H
+
+#include "kyra/text.h"
+
+namespace Kyra {
+
+class Screen_v2;
+class KyraEngine_v2;
+
+class TextDisplayer_v2 : public TextDisplayer {
+friend class KyraEngine_v2;
+public:
+	TextDisplayer_v2(KyraEngine_v2 *vm, Screen_v2 *screen);
+
+	void backupTalkTextMessageBkgd(int srcPage, int dstPage);
+	void restoreScreen();
+
+	char *preprocessString(const char *str);
+	void calcWidestLineBounds(int &x1, int &x1, int w, int x);
+private:
+	KyraEngine_v2 *_vm;
+};
+
+} // end of namespace Kyra
+
+#endif
+


Property changes on: scummvm/trunk/engines/kyra/text_v2.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native


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