diff options
| -rw-r--r-- | engines/kyra/kyra.cpp | 2 | ||||
| -rw-r--r-- | engines/kyra/kyra_v1.cpp | 2 | ||||
| -rw-r--r-- | engines/kyra/kyra_v2.cpp | 55 | ||||
| -rw-r--r-- | engines/kyra/kyra_v2.h | 28 | ||||
| -rw-r--r-- | engines/kyra/module.mk | 1 | ||||
| -rw-r--r-- | engines/kyra/script_v2.cpp | 34 | ||||
| -rw-r--r-- | engines/kyra/sequences_v2.cpp | 2 | ||||
| -rw-r--r-- | engines/kyra/text.h | 22 | ||||
| -rw-r--r-- | engines/kyra/text_v2.cpp | 323 | ||||
| -rw-r--r-- | engines/kyra/text_v2.h | 53 | 
10 files changed, 492 insertions, 30 deletions
| diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 29945f70f4..f690fde3cd 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -136,8 +136,6 @@ int KyraEngine::init() {  	_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()) diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 7a15fe848f..6f9d4062b9 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -175,6 +175,8 @@ int KyraEngine_v1::init() {  	assert(_animator);  	_animator->init(5, 11, 12);  	assert(*_animator); +	_text = new TextDisplayer(this, screen()); +	assert(_text);  	initStaticResource(); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 55cf843085..4df02963aa 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -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 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi  	_mouseSHPBuf = 0;  	_debugger = 0;  	_screen = 0; +	_text = 0;  	_gamePlayBuffer = 0;  	_cCodeBuffer = _optionsBuffer = _chapterBuffer = 0; @@ -72,6 +73,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi  KyraEngine_v2::~KyraEngine_v2() {  	delete [] _mouseSHPBuf;  	delete _screen; +	delete _text; +	_text = 0;  	delete _debugger;  } @@ -89,6 +92,8 @@ int KyraEngine_v2::init() {  	_debugger = new Debugger_v2(this);  	assert(_debugger); +	_text = new TextDisplayer_v2(this, _screen); +	assert(_text);  	setupTimers(); @@ -462,6 +467,30 @@ int KyraEngine_v2::update() {  	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 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {  		_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 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {  		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 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {  		if (_newShapeFlag >= 0) {  			_mainCharacter.animFrame = _newShapeFlag + 33;  			updateCharacterAnim(0); -			//if (dword_30BB2) -			//	sub_159D6(); -			//else +			if (_chatText) +				updateWithText(); +			else  				update();  		} @@ -1567,8 +1596,8 @@ void KyraEngine_v2::setupOpcodeTable() {  		Opcode(o2_wsaClose),  		OpcodeUnImpl(),  		// 0x98 -		OpcodeUnImpl(), -		OpcodeUnImpl(), +		Opcode(o2_customChat), +		Opcode(o2_customChatFinish),  		OpcodeUnImpl(),  		OpcodeUnImpl(),  		// 0x9c @@ -1588,7 +1617,7 @@ void KyraEngine_v2::setupOpcodeTable() {  		OpcodeUnImpl(),  		// 0xa8  		OpcodeUnImpl(), -		OpcodeUnImpl(), +		Opcode(o2_zanthiaChat),  		OpcodeUnImpl(),  		OpcodeUnImpl(),  		// 0xac diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index ab3e401eaa..636f47ffae 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -47,6 +47,7 @@ enum kSequences {  class WSAMovieV2;  class KyraEngine_v2; +class TextDisplayer_v2;  class Debugger_v2;  struct SequenceControl { @@ -87,12 +88,14 @@ struct Sequence {  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 @@ protected:  	int go();  	Screen_v2 *_screen; +	TextDisplayer_v2 *_text;  	Debugger_v2 *_debugger;  	ActiveWSA *_activeWSA; @@ -169,6 +173,7 @@ protected:  	// run  	int update(); +	void updateWithText();  	void updateMouse();  	int checkInput(void *p); @@ -492,6 +497,24 @@ protected:  	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 @@ protected:  	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 @@ protected:  		char filename[13];  		uint8 scriptId;  		int16 x, y; -		int8 unk12; +		int8 color;  	};  	Object *_objectList; diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index 0517c393a1..b5bf5ab73b 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -36,6 +36,7 @@ MODULE_OBJS := \  	staticres.o \  	text.o \  	text_v1.o \ +	text_v2.o \  	timer.o \  	timer_v1.o \  	timer_v2.o \ diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp index 0a23a53ce8..a91a296f7c 100644 --- a/engines/kyra/script_v2.cpp +++ b/engines/kyra/script_v2.cpp @@ -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 @@ int KyraEngine_v2::o2_defineObject(ScriptState *script) {  	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 KyraEngine_v2::o2_update(ScriptState *script) {  	int times = stackPos(0);  	while (times--) { -		//if (dword_30BB2) -		//	sub_159D6(); -		//else +		if (_chatText) +			updateWithText(); +		else  			update();  	} @@ -595,6 +596,31 @@ int KyraEngine_v2::o2_querySpecialSceneScriptState(ScriptState *script) {  	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; diff --git a/engines/kyra/sequences_v2.cpp b/engines/kyra/sequences_v2.cpp index 19412f6310..efa700d28a 100644 --- a/engines/kyra/sequences_v2.cpp +++ b/engines/kyra/sequences_v2.cpp @@ -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" diff --git a/engines/kyra/text.h b/engines/kyra/text.h index 7ffcbf0d06..f1016f26e8 100644 --- a/engines/kyra/text.h +++ b/engines/kyra/text.h @@ -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 @@ class TextDisplayer {  	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 @@ public:  	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; diff --git a/engines/kyra/text_v2.cpp b/engines/kyra/text_v2.cpp new file mode 100644 index 0000000000..59b11114c8 --- /dev/null +++ b/engines/kyra/text_v2.cpp @@ -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 + diff --git a/engines/kyra/text_v2.h b/engines/kyra/text_v2.h new file mode 100644 index 0000000000..88d446e7ec --- /dev/null +++ b/engines/kyra/text_v2.h @@ -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 + | 
