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

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Tue Mar 17 19:28:01 CET 2009


Revision: 39487
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39487&view=rev
Author:   athrxx
Date:     2009-03-17 18:27:56 +0000 (Tue, 17 Mar 2009)

Log Message:
-----------
LOL: added some new drawing code required for some shapes and fixed a minor text displaying bug

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/lol.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/screen.h
    scummvm/trunk/engines/kyra/screen_lol.cpp
    scummvm/trunk/engines/kyra/screen_lol.h
    scummvm/trunk/engines/kyra/script_lol.cpp
    scummvm/trunk/engines/kyra/script_tim.cpp
    scummvm/trunk/engines/kyra/sprites_lol.cpp
    scummvm/trunk/engines/kyra/text_lol.cpp
    scummvm/trunk/engines/kyra/text_lol.h

Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/lol.cpp	2009-03-17 18:27:56 UTC (rev 39487)
@@ -719,8 +719,6 @@
 	_txt->setAnimParameters("<MORE>", 10, 31, 0);
 	_txt->setAnimFlag(true);
 
-	_screen->_dimLineCount = 0;
-
 	_sound->loadSfxFile("LORESFX");
 
 	setMouseCursorToItemInHand();
@@ -1016,7 +1014,7 @@
 
 	updatePortraits();
 	if (_hideInventory)
-		_screen->clearDim(3);
+		_screen->setScreenDim(_txt->clearDim(3));
 
 	_fadeText = false;
 	_timer->disable(11);
@@ -1235,7 +1233,7 @@
 
 		_screen->modifyScreenDim(5, 8, 131, 304, 66);
 		_screen->modifyScreenDim(4, 1, 133, 38, 60);
-		_screen->clearDim(4);
+		_txt->clearDim(4);
 
 		_updateFlags |= 2;
 		_hideControls = controlMode;
@@ -1257,7 +1255,7 @@
 		_txt->setupField(true);
 		_txt->expandField();
 		setupScreenDims();
-		_screen->clearDim(4);
+		_txt->clearDim(4);
 	}
 	
 	_hideControls = controlMode;
@@ -1279,8 +1277,7 @@
 	} else {
 		const ScreenDim *d = _screen->getScreenDim(5);
 		_screen->fillRect(d->sx, d->sy, d->sx + d->w - 2, d->sy + d->h - 2, d->unkA);
-		_screen->clearDim(4);
-		_screen->setScreenDim(4);
+		_txt->clearDim(4);
 		_txt->setupField(false);
 	}
 
@@ -1305,7 +1302,7 @@
 	if (_hideInventory)
 		return;
 
-	_screen->clearDim(3);
+	_screen->setScreenDim(_txt->clearDim(3));
 
 	_timer->disable(11);
 
@@ -1690,15 +1687,13 @@
 			_txt->printDialogueText(3, str, script, paramList, paramIndex);
 
 		} else if (mode == 1) {
-			_screen->setScreenDim(4);
-			_screen->clearDim(4);
+			_txt->clearDim(4);
 			_screen->modifyScreenDim(4, 16, 123, 23, 47);
 			_txt->printDialogueText(4, str, script, paramList, paramIndex);
 			_screen->modifyScreenDim(4, 11, 123, 28, 47);
 
 		} else if (mode == 2) {
-			_screen->setScreenDim(4);
-			_screen->clearDim(4);
+			_txt->clearDim(4);
 			_screen->modifyScreenDim(4, 9, 133, 30, 60);
 			_txt->printDialogueText(4, str, script, paramList, 3);
 			_screen->modifyScreenDim(4, 1, 133, 37, 60);

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/lol.h	2009-03-17 18:27:56 UTC (rev 39487)
@@ -1031,9 +1031,9 @@
 	void removeDrawObjectFromBlock(LevelBlockProperty *l, int id);
 	void assignMonsterToBlock(uint16 *assignedBlockObjects, int id);
 	void giveItemToMonster(MonsterInPlay *monster, uint16 item);
-	int checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, int testFlag, int wallFlag);
-	int calcMonsterSkillLevel(int id, int a);
-	int checkBlockForWallsAndSufficientSpace(int block, int x, int y, int monsterWidth, int testFlag, int wallFlag);
+	int checkBlockBeforeObjectPlacement(int x, int y, int objectWidth, int testFlag, int wallFlag);
+	int checkBlockForWallsAndSufficientSpace(int block, int x, int y, int objectWidth, int testFlag, int wallFlag);
+	int calcMonsterSkillLevel(int id, int a);	
 	bool checkBlockOccupiedByParty(int x, int y, int testFlag);
 	const uint16 *getCharacterOrMonsterStats(int id);
 	void drawBlockObjects(int blockArrayIndex);

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/screen.cpp	2009-03-17 18:27:56 UTC (rev 39487)
@@ -1151,12 +1151,11 @@
 	_dsTable = 0;
 	_dsTableLoopCount = 0;
 	_dsTable2 = 0;
+	_dsTable3 = 0;
+	_dsTable4 = 0;
 	_dsTable5 = 0;
 	_dsDrawLayer = 0;
 
-	uint8 *table3 = 0;
-	uint8 *table4 = 0;
-
 	if (flags & 0x8000) {
 		_dsTable2 = va_arg(args, uint8*);
 	}
@@ -1169,8 +1168,8 @@
 	}
 
 	if (flags & 0x1000) {
-		table3 = va_arg(args, uint8*);
-		table4 = va_arg(args, uint8*);
+		_dsTable3 = va_arg(args, uint8*);
+		_dsTable4 = va_arg(args, uint8*);
 	}
 
 	if (flags & 0x200) {
@@ -1252,8 +1251,11 @@
 		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 		0,
 		&Screen::drawShapePlotType37,		// used by LoL (monsters)
-		0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 
+		&Screen::drawShapePlotType52,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0
 	};
 
 	int scaleCounterV = 0;
@@ -1827,6 +1829,16 @@
 		*dst = cmd;
 }
 
+void Screen::drawShapePlotType52(uint8 *dst, uint8 cmd) {
+	cmd = _dsTable2[cmd];
+	uint8 offs = _dsTable3[cmd];
+
+	if (!(offs & 0x80))
+		cmd = _dsTable4[(offs << 8) | *dst];
+
+	*dst = cmd;
+}
+
 void Screen::decodeFrame3(const uint8 *src, uint8 *dst, uint32 size) {
 	debugC(9, kDebugLevelScreen, "Screen::decodeFrame3(%p, %p, %u)", (const void *)src, (const void *)dst, size);
 	const uint8 *dstEnd = dst + size;

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/screen.h	2009-03-17 18:27:56 UTC (rev 39487)
@@ -333,6 +333,7 @@
 	void drawShapePlotType13(uint8 *dst, uint8 cmd);
 	void drawShapePlotType14(uint8 *dst, uint8 cmd);
 	void drawShapePlotType37(uint8 *dst, uint8 cmd);
+	void drawShapePlotType52(uint8 *dst, uint8 cmd);
 
 	typedef int (Screen::*DsMarginSkipFunc)(uint8 *&dst, const uint8 *&src, int &cnt);
 	typedef void (Screen::*DsLineFunc)(uint8 *&dst, const uint8 *&src, int &cnt, int scaleState);
@@ -346,6 +347,8 @@
 	const uint8 *_dsTable;
 	int _dsTableLoopCount;
 	const uint8 *_dsTable2;
+	const uint8 *_dsTable3;
+	const uint8 *_dsTable4;
 	const uint8 *_dsTable5;
 	int _dsDrawLayer;
 	uint8 *_dsDstPage;

Modified: scummvm/trunk/engines/kyra/screen_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen_lol.cpp	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/screen_lol.cpp	2009-03-17 18:27:56 UTC (rev 39487)
@@ -46,7 +46,6 @@
 	
 	_fadeFlag = 2;
 	_curDimIndex = 0;
-	_dimLineCount = 0;
 }
 
 Screen_LoL::~Screen_LoL() {
@@ -67,7 +66,6 @@
 	assert(dim < _screenDimTableCount);
 	_curDim = _customDimTable[dim] ? (const ScreenDim *)_customDimTable[dim] : &_screenDimTable[dim];
 	_curDimIndex = dim;
-	_dimLineCount = 0;
 }
 
 const ScreenDim *Screen_LoL::getScreenDim(int dim) {
@@ -87,11 +85,6 @@
 	setScreenDim(dim);
 }
 
-void Screen_LoL::clearDim(int dim) {
-	const ScreenDim *tmp = getScreenDim(dim);
-	fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 1, (tmp->sy + tmp->h) - 1, tmp->unkA);
-}
-
 void Screen_LoL::fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) {
 	debugC(9, kDebugLevelScreen, "Screen_LoL::fprintString('%s', %d, %d, %d, %d, %d, ...)", format, x, y, col1, col2, flags);
 	if (!format)

Modified: scummvm/trunk/engines/kyra/screen_lol.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_lol.h	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/screen_lol.h	2009-03-17 18:27:56 UTC (rev 39487)
@@ -43,7 +43,6 @@
 	const ScreenDim *getScreenDim(int dim);
 	int curDimIndex() { return _curDimIndex; }
 	void modifyScreenDim(int dim, int x, int y, int w, int h);
-	void clearDim(int dim);
 
 	void fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...);
 	void fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...);
@@ -77,7 +76,6 @@
 	uint8 *_paletteOverlay2;
 	uint8 *_grayOverlay;
 	int _fadeFlag;
-	int _dimLineCount;
 
 private:
 	LoLEngine *_vm;

Modified: scummvm/trunk/engines/kyra/script_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_lol.cpp	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/script_lol.cpp	2009-03-17 18:27:56 UTC (rev 39487)
@@ -471,7 +471,8 @@
 	_screen->setScreenDim(5);
 	const ScreenDim *d = _screen->getScreenDim(5);
 	_screen->fillRect(d->sx, d->sy, d->sx + d->w - 2, d->sy + d->h - 2, d->unkA);
-	_screen->clearDim(4);
+	_txt->clearDim(4);
+	_txt->resetDimTextPositions(4);
 
 	return 1;
 }

Modified: scummvm/trunk/engines/kyra/script_tim.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_tim.cpp	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/script_tim.cpp	2009-03-17 18:27:56 UTC (rev 39487)
@@ -1131,18 +1131,12 @@
 	if (!_vm->textEnabled() && _vm->_hideControls) {
 		_screen->setScreenDim(5);
 		const ScreenDim *d = _screen->getScreenDim(5);
-		_screen->hideMouse();
 		_screen->fillRect(d->sx, d->sy + d->h - 9, d->sx + d->w - 1, d->sy + d->h - 1, d->unkA);
-		_screen->showMouse();
 	} else {
 		const ScreenDim *d = _screen->_curDim;
-		_screen->hideMouse();
 		_screen->fillRect(d->sx, d->sy, d->sx + d->w - 2, d->sy + d->h - 1, d->unkA);
-		_screen->clearDim(4);
-		_screen->setScreenDim(4);
-		_screen->showMouse();
-		//_screen->setDialogueColumn(8, 0);
-		//_screen->setDialogueLine(8, 0);
+		_vm->_txt->clearDim(4);
+		_vm->_txt->resetDimTextPositions(4);
 	}
 
 	return res;

Modified: scummvm/trunk/engines/kyra/sprites_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sprites_lol.cpp	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/sprites_lol.cpp	2009-03-17 18:27:56 UTC (rev 39487)
@@ -325,7 +325,7 @@
 	*assignedBlockObjects = id;
 }
 
-int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, int testFlag, int wallFlag) {
+int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int objectWidth, int testFlag, int wallFlag) {
 	_monsterLastWalkDirection = 0;
 	int x2 = 0;
 	int y2 = 0;
@@ -333,7 +333,7 @@
 	int yOffs = 0;
 	int flag = 0;
 
-	int r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y), x, y, monsterWidth, testFlag, wallFlag);
+	int r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y), x, y, objectWidth, testFlag, wallFlag);
 	if (r)
 		return r;
 
@@ -342,12 +342,12 @@
 		return 4;
 
 	if (x & 0x80) {
-		if (((x & 0xff) + monsterWidth) & 0xff00) {
+		if (((x & 0xff) + objectWidth) & 0xff00) {
 			xOffs = 1;
 			_monsterLastWalkDirection = 2;
-			x2 = x + monsterWidth;
+			x2 = x + objectWidth;
 
-			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, monsterWidth, testFlag, wallFlag);
+			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, objectWidth, testFlag, wallFlag);
 			if (r)
 				return r;
 
@@ -358,12 +358,12 @@
 			flag = 1;
 		}
 	} else {
-		if (((x & 0xff) - monsterWidth) & 0xff00) {
+		if (((x & 0xff) - objectWidth) & 0xff00) {
 			xOffs = -1;
 			_monsterLastWalkDirection = 6;
-			x2 = x - monsterWidth;
+			x2 = x - objectWidth;
 
-			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, monsterWidth, testFlag, wallFlag);
+			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, objectWidth, testFlag, wallFlag);
 			if (r)
 				return r;
 
@@ -376,12 +376,12 @@
 	}
 
 	if (y & 0x80) {
-		if (((y & 0xff) + monsterWidth) & 0xff00) {
+		if (((y & 0xff) + objectWidth) & 0xff00) {
 			yOffs = 1;
 			_monsterLastWalkDirection = 4;
-			y2 = y + monsterWidth;
+			y2 = y + objectWidth;
 
-			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, monsterWidth, testFlag, wallFlag);
+			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, objectWidth, testFlag, wallFlag);
 			if (r)
 				return r;
 
@@ -392,12 +392,12 @@
 			flag = 0;
 		}
 	} else {
-		if (((y & 0xff) - monsterWidth) & 0xff00) {
+		if (((y & 0xff) - objectWidth) & 0xff00) {
 			yOffs = -1;
 			_monsterLastWalkDirection = 0;
-			y2 = y - monsterWidth;
+			y2 = y - objectWidth;
 
-			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, monsterWidth, testFlag, wallFlag);
+			r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, objectWidth, testFlag, wallFlag);
 			if (r)
 				return r;
 
@@ -412,7 +412,7 @@
 	if (!flag)
 		return 0;
 
-	r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y2), x, y, monsterWidth, testFlag, wallFlag);
+	r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y2), x, y, objectWidth, testFlag, wallFlag);
 	if (r)
 		return r;
 
@@ -423,24 +423,7 @@
 	return 0;
 }
 
-int LoLEngine::calcMonsterSkillLevel(int id, int a) {
-	const uint16 *c = getCharacterOrMonsterStats(id);
-	int r = (a << 8) / c[4];
-
-	if (!(id & 0x8000))
-		r = (r * _monsterModifiers[3 + ((_unkGameFlag & 0x30) << 4)]) >> 8;
-
-	id &= 0x7fff;
-
-	if (_characters[id].skillLevels[1] <= 3)
-		return r;
-	else if (_characters[id].skillLevels[1] <= 7)
-		return (r- (r >> 2));
-
-	return (r- (r >> 1));
-}
-
-int LoLEngine::checkBlockForWallsAndSufficientSpace(int block, int x, int y, int monsterWidth, int testFlag, int wallFlag) {
+int LoLEngine::checkBlockForWallsAndSufficientSpace(int block, int x, int y, int objectWidth, int testFlag, int wallFlag) {
 	if (block == _currentBlock)
 		testFlag &= 0xfffe;
 
@@ -461,7 +444,7 @@
 
 		if (monster->mode < 13) {
 			int r = checkDrawObjectSpace(x, y, monster->x, monster->y);
-			if ((monsterWidth + monster->properties->maxWidth) > r)
+			if ((objectWidth + monster->properties->maxWidth) > r)
 				return 2;
 		}
 
@@ -471,6 +454,23 @@
 	return 0;
 }
 
+int LoLEngine::calcMonsterSkillLevel(int id, int a) {
+	const uint16 *c = getCharacterOrMonsterStats(id);
+	int r = (a << 8) / c[4];
+
+	if (!(id & 0x8000))
+		r = (r * _monsterModifiers[3 + ((_unkGameFlag & 0x30) << 4)]) >> 8;
+
+	id &= 0x7fff;
+
+	if (_characters[id].skillLevels[1] <= 3)
+		return r;
+	else if (_characters[id].skillLevels[1] <= 7)
+		return (r- (r >> 2));
+
+	return (r- (r >> 1));
+}
+
 bool LoLEngine::checkBlockOccupiedByParty(int x, int y, int testFlag) {
 	if ((testFlag & 4) && (_currentBlock == calcBlockIndex(x, y)))
 		return true;
@@ -519,7 +519,7 @@
 
 			if ((_itemProperties[i->itemPropertyIndex].flags & 0x1000) && !(i->shpCurFrame_flg & 0xC000)) {
 				int shpIndex = _itemProperties[i->itemPropertyIndex].flags & 0x800 ? 7 : _itemProperties[i->itemPropertyIndex].shpIndex;
-				
+				shpIndex=12;
 				int ii = 0;
 				for (; ii < 8; ii++) {
 					if (!_flyingItems[ii].enable)
@@ -896,6 +896,7 @@
 		ovl = _screen->getLevelOverlay(r);
 	} else {
 		memset (tmpOvl + 1, tblValue, 15);
+		tmpOvl[0] = 0;
 		table = tmpOvl;
 		ovl = _screen->getLevelOverlay(7);
 	}

Modified: scummvm/trunk/engines/kyra/text_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_lol.cpp	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/text_lol.cpp	2009-03-17 18:27:56 UTC (rev 39487)
@@ -33,8 +33,8 @@
 namespace Kyra {
 
 TextDisplayer_LoL::TextDisplayer_LoL(LoLEngine *vm, Screen_LoL *screen) : _vm(vm), _screen(screen),
-	_scriptParameter(0), _animWidth(0), _animColour1(0), _animColour2(0), _animFlag(true),
-	_printFlag(false), _lineWidth(0), _numCharsTotal(0), _numCharsLeft(0), _numCharsPrinted(0), _posX(0), _posY(0), _colour1(0), _colour2(0) {
+	_scriptParameter(0), _animWidth(0), _animColour1(0), _animColour2(0), _animFlag(true), _lineCount(0),
+	_printFlag(false), _lineWidth(0), _numCharsTotal(0), _numCharsLeft(0), _numCharsPrinted(0) {
 	
 	memset(_stringParameters, 0, 15 * sizeof(char*));
 	_buffer = new char[600];
@@ -45,6 +45,14 @@
 
 	_currentLine = new char[85];
 	memset(_currentLine, 0, 85);
+
+	for (int i = 0; i < 14; i++){
+		const ScreenDim *d = _screen->getScreenDim(i);
+		_textDimData[i].color1 = d->unk8;
+		_textDimData[i].color2 = d->unkA;
+		_textDimData[i].line = d->unkC;
+		_textDimData[i].column = d->unkE;
+	}
 }
 
 TextDisplayer_LoL::~TextDisplayer_LoL() {
@@ -61,7 +69,7 @@
 			_screen->copyRegionToBuffer(3, 0, 0, 320, 40, _vm->_pageBuffer2);
 			_screen->copyBlockToPage(3, 0, 0, 320, 40, _vm->_pageBuffer1);
 		} else {
-			_screen->clearDim(4);
+			_screen->setScreenDim(clearDim(4));
 			int cp = _screen->setCurPage(2);
 			_screen->copyRegionToBuffer(3, 0, 0, 320, 40, _vm->_pageBuffer1);
 			_screen->copyBlockToPage(3, 0, 0, 320, 40, _vm->_pageBuffer2);
@@ -84,7 +92,7 @@
 		}
 	} else {
 		if (!mode)
-			_screen->clearDim(4);
+			_screen->setScreenDim(clearDim(4));
 		_vm->toggleSelectedCharacterFrame(1);
 	}
 }
@@ -96,7 +104,7 @@
 		_vm->_fadeText = false;
 		_vm->_textColourFlag = 0;
 		_vm->_timer->disable(11);
-		_screen->clearDim(3);
+		_screen->setScreenDim(clearDim(3));
 		_screen->copyRegionToBuffer(3, 0, 0, 320, 10, tmp);
 		_screen->copyRegion(83, 140, 0, 0, 235, 3, 0, 2, Screen::CR_NO_P_CHECK);
 
@@ -113,10 +121,25 @@
 		_vm->_updateFlags |= 2;
 
 	} else {
-		_screen->clearDim(3);
+		clearDim(3);
 		_vm->toggleSelectedCharacterFrame(0);
 	}
 }
+
+int TextDisplayer_LoL::clearDim(int dim) {
+	int res = _screen->curDimIndex();
+	_screen->setScreenDim(dim);
+	_textDimData[dim].color1 = _screen->_curDim->unk8;
+	_textDimData[dim].color2 = _screen->_curDim->unkA;
+	clearCurDim();
+	return res;
+}
+
+void TextDisplayer_LoL::resetDimTextPositions(int dim) {
+	_textDimData[dim].column = 0;
+	_textDimData[dim].line = 0;
+}
+
 void TextDisplayer_LoL::setAnimParameters(const char *str, int x, uint8 col1, uint8 col2) {
 	static const char defaultStr[] = "<MORE>";
 
@@ -134,29 +157,23 @@
 }
 
 void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex) {
-	_colour1prot = false;
-	int oldDim = _screen->curDimIndex();
+	int oldDim = 0;
 
 	if (dim == 3) {
 		if (_vm->_updateFlags & 2) {			
-			_screen->setScreenDim(4);
-			_screen->clearDim(4);			
-			_colour1 = 254;
-			_colour1prot = true;
+			oldDim = clearDim(4);			
+			_textDimData[4].color1 = 254;
 		} else {
-			_screen->setScreenDim(3);
-			_screen->clearDim(3);
-			_colour1 = 192;
-			_colour1prot = true;
+			oldDim = clearDim(3);
+			_textDimData[3].color1 = 192;
 			_screen->copyColour(192, 254);
 			_vm->enableTimer(11);
 			_vm->_textColourFlag = 0;
 			_vm->_fadeText = false;
 		}
 	} else {
-		_screen->setScreenDim(dim);
-		_colour1 = 254;
-		_colour1prot = true;
+		oldDim = clearDim(dim);			
+		_textDimData[dim].color1 = 254;
 	}
 
 	int cp = _screen->setCurPage(0);
@@ -186,18 +203,14 @@
 	int od = _screen->curDimIndex();
 
 	if (_vm->_updateFlags & 2) {
-		_screen->setScreenDim(4);
-		clearCurDim();
-		_colour1 = col;
+		clearDim(4);
+		_textDimData[4].color1 = col;
 	} else {
-		_screen->setScreenDim(3);
-		clearCurDim();
+		clearDim(3);
 		_screen->copyColour(192, col);
-		_colour1 = 192;
+		_textDimData[3].color1 = 192;
 		_vm->enableTimer(11);
 	}
-	
-	_colour1prot = true;
 
 	va_list args;
 	va_start(args, str);
@@ -330,18 +343,13 @@
 
 	memset(_ctrl, 0, 3);
 
-	if (!_colour1prot)
-		_colour1 = _screen->_curDim->unk8;
-	_colour2 = _screen->_curDim->unkA;
-	_posX = _screen->_curDim->unkC;
-	_posY = _screen->_curDim->unkE;
-	
 	char c = parseCommand();
 	
 	va_list args;
 	va_start(args, str);
 
 	const ScreenDim *sd = _screen->_curDim;
+	int sdx = _screen->curDimIndex();
 
 	while (c) {
 		char a = tolower(_ctrl[1]);
@@ -370,12 +378,12 @@
 
 			case 1:
 				printLine(_currentLine);
-				_colour2 = parseCommand();
+				_textDimData[sdx].color2 = parseCommand();
 				break;
 
 			case 5:
 				printLine(_currentLine);
-				_colour1 = parseCommand();
+				_textDimData[sdx].color1 = parseCommand();
 				break;
 
 			case 8:
@@ -388,9 +396,9 @@
 
 			case 12:
 				printLine(_currentLine);
-				_screen->_dimLineCount++;
-				_posX = 0;
-				_posY++;
+				_lineCount++;
+				_textDimData[sdx].column = 0;
+				_textDimData[sdx].line++;
 				break;
 
 			case 18:
@@ -418,7 +426,7 @@
 				_currentLine[_numCharsLeft++] = c;
 				_currentLine[_numCharsLeft] = 0;
 
-				if ((_posX + _lineWidth) > (sd->w << 3))
+				if ((_textDimData[sdx].column + _lineWidth) > (sd->w << 3))
 					printLine(_currentLine);
 				
 				break;
@@ -472,13 +480,14 @@
 
 void TextDisplayer_LoL::printLine(char *str) {
 	const ScreenDim *sd = _screen->_curDim;
+	int sdx = _screen->curDimIndex();
 
 	int fh = (_screen->getFontHeight() + _screen->_charOffset);
 	int lines = (sd->h - _screen->_charOffset) / fh;
 	
-	while (_posY >= lines) {
-		if (lines <= _screen->_dimLineCount && _animFlag) {
-			_screen->_dimLineCount = 0;
+	while (_textDimData[sdx].line >= lines) {
+		if (lines <= _lineCount && _animFlag) {
+			_lineCount = 0;
 			textPageBreak();
 			_numCharsPrinted = 0;
 		}
@@ -489,23 +498,23 @@
 		if (h2)
 			_screen->copyRegion(sd->sx << 3, sd->sy + fh, sd->sx << 3, sd->sy, sd->w << 3, h2, _screen->_curPage, _screen->_curPage, Screen::CR_NO_P_CHECK);
 
-		_screen->fillRect(sd->sx << 3, sd->sy + h1, (sd->sx + sd->w - 1) << 3, sd->sy + sd->h - 1, _colour2);	
-		if (_posY)
-			_posY--;
+		_screen->fillRect(sd->sx << 3, sd->sy + h1, (sd->sx + sd->w - 1) << 3, sd->sy + sd->h - 1, _textDimData[sdx].color2);	
+		if (_textDimData[sdx].line)
+			_textDimData[sdx].line--;
 	}
 
-	int x1 = (sd->sx << 3) + _posX;
-	int y = sd->sy + fh * _posY;
+	int x1 = (sd->sx << 3) + _textDimData[sdx].column;
+	int y = sd->sy + fh * _textDimData[sdx].line;
 	int w = sd->w << 3;
 	int lw = _lineWidth;
 	int s = _numCharsLeft;
 	char c = 0;
 
-	if ((lw + _posX) > w) {
-		if ((lines - 1) <= _screen->_dimLineCount && _animFlag)
+	if ((lw + _textDimData[sdx].column) > w) {
+		if ((lines - 1) <= _lineCount && _animFlag)
 			w -= (_animWidth * (_screen->getFontWidth() + _screen->_charWidth));
 
-		w -= _posX;
+		w -= _textDimData[sdx].column;
 
 		int n2 = 0;
 		int n1 = s - 1;
@@ -528,7 +537,7 @@
 		}
 
 		if (!n1) {
-			if (_posX && !_printFlag) {
+			if (_textDimData[sdx].column && !_printFlag) {
 				s = lw = 0;
 				_printFlag = true;
 			} else {
@@ -540,8 +549,8 @@
 	c = str[s];
 	str[s] = 0;
 	
-	_screen->printText(str, x1, y, _colour1, _colour2);
-	_posX += lw;
+	_screen->printText(str, x1, y, _textDimData[sdx].color1, _textDimData[sdx].color2);
+	_textDimData[sdx].column += lw;
 	_numCharsPrinted += strlen(str);
 	
 	str[s] = c;
@@ -560,12 +569,12 @@
 	_numCharsLeft = strlen(str);
 	_lineWidth = _screen->getTextWidth(str);
 
-	if (!_numCharsLeft && _posX < (sd->w << 3))
+	if (!_numCharsLeft && _textDimData[sdx].column < (sd->w << 3))
 		return;
 
-	_posX = 0;
-	_posY++;
-	_screen->_dimLineCount++;
+	_textDimData[sdx].column = 0;
+	_textDimData[sdx].line++;
+	_lineCount++;
 
 	printLine(str);
 }
@@ -661,7 +670,8 @@
 		}
 	} while (loop);
 
-	_screen->fillRect(x, y, x + 74, y + 9, _colour2);
+
+	_screen->fillRect(x, y, x + 74, y + 9, _textDimData[_screen->curDimIndex()].color2);
 	clearCurDim();
 
 	_vm->_timer->pauseSingleTimer(11, false);
@@ -682,10 +692,11 @@
 }
 
 void TextDisplayer_LoL::clearCurDim() {
+	int d = _screen->curDimIndex();
 	const ScreenDim *tmp = _screen->getScreenDim(_screen->curDimIndex());
-	_screen->fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 1, (tmp->sy + tmp->h) - 1, _colour2);
-	_screen->_dimLineCount = 0;
-	_posX = _posY = 0;	
+	_screen->fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 1, (tmp->sy + tmp->h) - 1, _textDimData[d].color2);
+	_lineCount = 0;
+	_textDimData[d].column = _textDimData[d].line = 0;
 }
 
 } // end of namespace Kyra

Modified: scummvm/trunk/engines/kyra/text_lol.h
===================================================================
--- scummvm/trunk/engines/kyra/text_lol.h	2009-03-17 16:45:09 UTC (rev 39486)
+++ scummvm/trunk/engines/kyra/text_lol.h	2009-03-17 18:27:56 UTC (rev 39487)
@@ -46,6 +46,9 @@
 	void setupField(bool mode);
 	void expandField();
 
+	int clearDim(int dim);
+	void resetDimTextPositions(int dim);
+
 	void printDialogueText(int dim, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex);
 	void printMessage(uint16 type, char *str, ...);
 	
@@ -72,6 +75,7 @@
 	char _scriptParaString[11];
 
 	uint16 _lineWidth;
+	int _lineCount;
 	uint32 _numCharsTotal;
 	uint32 _numCharsLeft;
 	uint32 _numCharsPrinted;
@@ -84,14 +88,17 @@
 	bool _animFlag;
 	bool _printFlag;
 
-	uint8 _posX;
-	uint8 _posY;
-	uint8 _colour1;
-	uint8 _colour2;
-	bool _colour1prot;
-
 	LoLEngine *_vm;
 	Screen_LoL *_screen;
+
+	struct TextDimData {
+		uint8 color1;
+		uint8 color2;
+		uint8 column;
+		uint8 line;
+	};
+
+	TextDimData _textDimData[14];
 };
 
 } // end of namespace Kyra


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