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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Jun 7 22:43:43 CEST 2009


Revision: 41351
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41351&view=rev
Author:   lordhoto
Date:     2009-06-07 20:43:43 +0000 (Sun, 07 Jun 2009)

Log Message:
-----------
Remove LoLEngine::_gameFlags and convert all Lands of Lore code to use _flagsTable instead.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/debugger.cpp
    scummvm/trunk/engines/kyra/debugger.h
    scummvm/trunk/engines/kyra/gui_lol.cpp
    scummvm/trunk/engines/kyra/items_lol.cpp
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/lol.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/saveload.cpp
    scummvm/trunk/engines/kyra/saveload_lol.cpp
    scummvm/trunk/engines/kyra/scene_lol.cpp
    scummvm/trunk/engines/kyra/script_lol.cpp
    scummvm/trunk/engines/kyra/timer_lol.cpp

Modified: scummvm/trunk/engines/kyra/debugger.cpp
===================================================================
--- scummvm/trunk/engines/kyra/debugger.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/debugger.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -465,53 +465,6 @@
 #ifdef ENABLE_LOL
 Debugger_LoL::Debugger_LoL(LoLEngine *vm) : Debugger(vm), _vm(vm) {
 }
-
-bool Debugger_LoL::cmd_listFlags(int argc, const char **argv) {
-	for (int i = 0, p = 0; i < (int)sizeof(_vm->_gameFlags)*8; ++i, ++p) {
-		const uint8 index = (i >> 4);
-		const uint8 offset = i & 0xF;
-
-		DebugPrintf("(%-3i): %-2i", i, (_vm->_gameFlags[index] >> offset) & 1);
-		if (p == 5) {
-			DebugPrintf("\n");
-			p -= 6;
-		}
-	}
-	DebugPrintf("\n");
-	return true;
-}
-
-bool Debugger_LoL::cmd_toggleFlag(int argc, const char **argv) {
-	if (argc > 1) {
-		uint flag = atoi(argv[1]);
-
-		const uint8 index = (flag >> 4);
-		const uint8 offset = flag & 0xF;
-
-		_vm->_gameFlags[index] ^= _vm->_gameFlags[index] & (1 << offset);
-
-		DebugPrintf("Flag %i is now %i\n", flag, (_vm->_gameFlags[index] >> offset) & 1);
-	} else {
-		DebugPrintf("Syntax: toggleflag <flag>\n");
-	}
-
-	return true;
-}
-
-bool Debugger_LoL::cmd_queryFlag(int argc, const char **argv) {
-	if (argc > 1) {
-		uint flag = atoi(argv[1]);
-
-		const uint8 index = (flag >> 4);
-		const uint8 offset = flag & 0xF;
-
-		DebugPrintf("Flag %i is %i\n", flag, (_vm->_gameFlags[index] >> offset) & 1);
-	} else {
-		DebugPrintf("Syntax: queryflag <flag>\n");
-	}
-
-	return true;
-}
 #endif // ENABLE_LOL
 
 } // End of namespace Kyra

Modified: scummvm/trunk/engines/kyra/debugger.h
===================================================================
--- scummvm/trunk/engines/kyra/debugger.h	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/debugger.h	2009-06-07 20:43:43 UTC (rev 41351)
@@ -47,9 +47,9 @@
 	bool cmd_loadPalette(int argc, const char **argv);
 	bool cmd_showFacings(int argc, const char **argv);
 	bool cmd_gameSpeed(int argc, const char **argv);
-	virtual bool cmd_listFlags(int argc, const char **argv);
-	virtual bool cmd_toggleFlag(int argc, const char **argv);
-	virtual bool cmd_queryFlag(int argc, const char **argv);
+	bool cmd_listFlags(int argc, const char **argv);
+	bool cmd_toggleFlag(int argc, const char **argv);
+	bool cmd_queryFlag(int argc, const char **argv);
 	bool cmd_listTimers(int argc, const char **argv);
 	bool cmd_setTimerCountdown(int argc, const char **argv);
 };
@@ -106,10 +106,6 @@
 
 protected:
 	LoLEngine *_vm;
-
-	bool cmd_listFlags(int argc, const char **argv);
-	bool cmd_toggleFlag(int argc, const char **argv);
-	bool cmd_queryFlag(int argc, const char **argv);
 };
 #endif // ENABLE_LOL
 

Modified: scummvm/trunk/engines/kyra/gui_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_lol.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/gui_lol.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -34,26 +34,26 @@
 void LoLEngine::gui_drawPlayField() {
 	_screen->loadBitmap("PLAYFLD.CPS", 3, 3, 0);
 
-	if (_gameFlags[15] & 0x4000) {
+	if (_flagsTable[31] & 0x40) {
 		// copy compass shape
 		static const int cx[] = { 112, 152, 224 };
 		_screen->copyRegion(cx[_lang], 32, 288, 0, 32, 32, 2, 2, Screen::CR_NO_P_CHECK);
 		_compassDirection = -1;
 	}
 
-	if (_gameFlags[15] & 0x1000)
+	if (_flagsTable[31] & 0x10)
 		// draw automap book
 		_screen->drawShape(2, _gameShapes[78], 290, 32, 0, 0);
 
 	int cp = _screen->setCurPage(2);
 
-	if (_gameFlags[15] & 0x2000) {
+	if (_flagsTable[31] & 0x20) {
 		gui_drawScroll();
 	} else {
 		_selectedSpell = 0;
 	}
 
-	if (_gameFlags[15] & 0x800)
+	if (_flagsTable[31] & 0x08)
 		resetLampStatus();
 
 	updateDrawPage2();
@@ -548,7 +548,7 @@
 }
 
 void LoLEngine::gui_drawCompass() {
-	if (!(_gameFlags[15] & 0x4000))
+	if (!(_flagsTable[31] & 0x40))
 		return;
 
 	if (_compassDirection == -1) {
@@ -606,7 +606,7 @@
 	static const int16 buttonX[] = { 0x0056, 0x0128, 0x000C, 0x0021, 0x0122, 0x000C, 0x0021, 0x0036, 0x000C, 0x0021, 0x0036 };
 	static const int16 buttonY[] = { 0x00B4, 0x00B4, 0x00B4, 0x00B4, 0x0020, 0x0084, 0x0084, 0x0084, 0x0096, 0x0096, 0x0096 };
 
-	if (shapeIndex == 78 && !(_gameFlags[15] & 0x1000))
+	if (shapeIndex == 78 && !(_flagsTable[31] & 0x10))
 		return;
 
 	if (_currentControlMode && _needSceneRestore)
@@ -836,7 +836,7 @@
 	gui_setFaceFramesControlButtons(29, 0);
 	gui_setFaceFramesControlButtons(25, 33);
 
-	if (_gameFlags[15] & 0x2000)
+	if (_flagsTable[31] & 0x20)
 		gui_initMagicScrollButtons();
 }
 
@@ -1752,7 +1752,7 @@
 }
 
 int LoLEngine::clickedCompass(Button *button) {
-	if (!(_gameFlags[15] & 0x4000))
+	if (!(_flagsTable[31] & 0x40))
 		return 0;
 
 	if (_compassBroken) {
@@ -1766,7 +1766,7 @@
 }
 
 int LoLEngine::clickedAutomap(Button *button) {
-	if (!(_gameFlags[15] & 0x1000))
+	if (!(_flagsTable[31] & 0x10))
 		return 0;
 
 	removeInputTop();
@@ -1778,7 +1778,7 @@
 }
 
 int LoLEngine::clickedLamp(Button *button) {
-	if (!(_gameFlags[15] & 0x800))
+	if (!(_flagsTable[31] & 0x08))
 		return 0;
 
 	if (_itemsInPlay[_itemInHand].itemPropertyIndex == 248) {

Modified: scummvm/trunk/engines/kyra/items_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_lol.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/items_lol.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -279,7 +279,7 @@
 
 	int mouseOffs = 0;
 
-	if (itemIndex && !(_gameFlags[15] & 0x200)) {
+	if (itemIndex && !(_flagsTable[31] & 0x02)) {
 		mouseOffs = 10;
 		if (!_currentControlMode || textEnabled())
 			_txt->printMessage(0, getLangString(0x403E), getLangString(_itemProperties[_itemsInPlay[itemIndex].itemPropertyIndex].nameStringId));

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -470,15 +470,18 @@
 
 
 int KyraEngine_v1::setGameFlag(int flag) {
+	assert((flag >> 3) >= 0 && (flag >> 3) <= ARRAYSIZE(_flagsTable));
 	_flagsTable[flag >> 3] |= (1 << (flag & 7));
 	return 1;
 }
 
 int KyraEngine_v1::queryGameFlag(int flag) const {
+	assert((flag >> 3) >= 0 && (flag >> 3) <= ARRAYSIZE(_flagsTable));
 	return ((_flagsTable[flag >> 3] >> (flag & 7)) & 1);
 }
 
 int KyraEngine_v1::resetGameFlag(int flag) {
+	assert((flag >> 3) >= 0 && (flag >> 3) <= ARRAYSIZE(_flagsTable));
 	_flagsTable[flag >> 3] &= ~(1 << (flag & 7));
 	return 0;
 }

Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/lol.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -500,7 +500,6 @@
 	_flyingObjects = new FlyingObject[8];
 	memset(_flyingObjects, 0, 8 * sizeof(FlyingObject));
 
-	memset(_gameFlags, 0, sizeof(_gameFlags));
 	memset(_globalScriptVars, 0, sizeof(_globalScriptVars));
 
 	_levelFileData = 0;
@@ -643,7 +642,7 @@
 }
 
 void LoLEngine::setMouseCursorToIcon(int icon) {
-	_gameFlags[15] |= 0x200;
+	_flagsTable[31] |= 0x02;
 	int i = _itemProperties[_itemsInPlay[_itemInHand].itemPropertyIndex].shpIndex;
 	if (i == icon)
 		return;
@@ -651,7 +650,7 @@
 }
 
 void LoLEngine::setMouseCursorToItemInHand() {
-	_gameFlags[15] &= 0xFDFF;
+	_flagsTable[31] &= 0xFD;
 	int o = (_itemInHand == 0) ? 0 : 10;
 	_screen->setMouseCursor(o, o, getItemIconShapePtr(_itemInHand));
 }
@@ -856,7 +855,7 @@
 	enableSysTimer(2);
 
 	bool _runFlag = true;
-	_gameFlags[36] |= 0x800;
+	_flagsTable[73] |= 0x08;
 
 	while (!shouldQuit() && _runFlag) {
 		if (_nextScriptFunc) {
@@ -891,10 +890,10 @@
 	if (_updateCharNum != -1 && _system->getMillis() > _updatePortraitNext)
 		updatePortraitSpeechAnim();
 
-	if (_gameFlags[15] & 0x800 || !(_updateFlags & 4))
+	if (_flagsTable[31] & 0x08 || !(_updateFlags & 4))
 		updateLampStatus();
 
-	if (_gameFlags[15] & 0x4000 && !(_updateFlags & 4) && (_compassDirection == -1 || (_currentDirection << 6) != _compassDirection || _compassStep))
+	if (_flagsTable[31] & 0x40 && !(_updateFlags & 4) && (_compassDirection == -1 || (_currentDirection << 6) != _compassDirection || _compassStep))
 		updateCompass();
 
 	snd_updateCharacterSpeech();
@@ -1595,7 +1594,7 @@
 	memcpy(dst, src, 0x300);
 	_screen->loadSpecialColors(dst);
 	brightness = (8 - brightness) << 5;
-	if (modifier >= 0 && modifier < 8 && _gameFlags[15] & 0x800) {
+	if (modifier >= 0 && modifier < 8 && (_flagsTable[31] & 0x08)) {
 		brightness = 256 - ((((modifier & 0xfffe) << 5) * (256 - brightness)) >> 8);
 		if (brightness < 0)
 			brightness = 0;
@@ -2124,12 +2123,12 @@
 	uint8 *tpal = new uint8[768];
 	uint8 *swampCol = new uint8[768];
 
-	if (_currentLevel == 11 && !(_gameFlags[26] & 4)) {
+	if (_currentLevel == 11 && !(_flagsTable[52] & 0x04)) {
 		uint8 *sc = _screen->_currentPalette;
 		uint8 *dc = _screen->getPalette(2);
 		for (int i = 1; i < 768; i++)
 			SWAP(sc[i], dc[i]);
-		_gameFlags[26] |= 4;
+		_flagsTable[52] |= 0x04;
 		static const uint8 freezeTimes[] =  { 20, 28, 40, 60 };
 		setCharacterUpdateEvent(charNum, 8, freezeTimes[spellLevel], 1);
 	}
@@ -3496,7 +3495,7 @@
 }
 
 void LoLEngine::restoreSwampPalette() {
-	_gameFlags[26] &= 0xfffb;
+	_flagsTable[52] &= 0xFB;
 	if (_currentLevel != 11)
 		return;
 
@@ -3761,7 +3760,7 @@
 }
 
 void LoLEngine::updateAutoMap(uint16 block) {
-	if (!(_gameFlags[15] & 0x1000))
+	if (!(_flagsTable[31] & 0x10))
 		return;
 	_levelBlockProperties[block].flags |= 7;
 

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/lol.h	2009-06-07 20:43:43 UTC (rev 41351)
@@ -627,7 +627,6 @@
 	uint16 _currentBlock;
 	bool _sceneUpdateRequired;
 	int16 _visibleBlockIndex[18];
-	uint16 _gameFlags[40];
 	int16 _globalScriptVars[24];
 
 	// emc opcode

Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/saveload.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -30,7 +30,7 @@
 
 #include "kyra/kyra_v1.h"
 
-#define CURRENT_SAVE_VERSION 15
+#define CURRENT_SAVE_VERSION 16
 
 #define GF_FLOPPY  (1 <<  0)
 #define GF_TALKIE  (1 <<  1)

Modified: scummvm/trunk/engines/kyra/saveload_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload_lol.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/saveload_lol.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -119,15 +119,33 @@
 	_inventoryCurItem = in.readSint16BE();
 	_itemInHand = in.readSint16BE();
 	_lastMouseRegion = in.readSint16BE();
-	if (header.version == 14) {
-		for (int i = 0; i < 16; i++)
-			_gameFlags[i] = in.readUint16BE();
-		_gameFlags[26] = in.readUint16BE();
-		_gameFlags[36] = in.readUint16BE();
+
+	if (header.version <= 15) {
+		uint16 flags[40];
+		memset(flags, 0, sizeof(flags));
+
+		if (header.version == 14) {
+			for (int i = 0; i < 16; i++)
+				flags[i] = in.readUint16BE();
+			flags[26] = in.readUint16BE();
+			flags[36] = in.readUint16BE();
+		} else if (header.version == 15) {
+			for (int i = 0; i < 40; i++)
+				flags[i] = in.readUint16BE();
+		}
+
+		for (uint i = 0; i < ARRAYSIZE(flags); ++i) {
+			for (uint k = 0; k < 16; ++k) {
+				if (flags[i] & (1 << k))
+					setGameFlag(((i << 4) & 0xFFF0) | (k & 0x000F));
+			}
+		}
 	} else {
-		for (int i = 0; i < 40; i++)
-			_gameFlags[i] = in.readUint16BE();
+		uint32 flagsSize = in.readUint32BE();
+		assert(flagsSize <= sizeof(_flagsTable));
+		in.read(_flagsTable, flagsSize);
 	}
+
 	for (int i = 0; i < 24; i++)
 		_globalScriptVars[i] = in.readUint16BE();
 	_brightness = in.readByte();
@@ -245,7 +263,7 @@
 	loadLevel(_currentLevel);
 	gui_drawPlayField();
 	timerSpecialCharacterUpdate(0);
-	_gameFlags[36] |= 0x800;
+	_flagsTable[73] |= 0x08;
 
 	while (!_screen->isMouseVisible())
 		_screen->showMouse();
@@ -323,8 +341,8 @@
 	out->writeSint16BE(_inventoryCurItem);
 	out->writeSint16BE(_itemInHand);
 	out->writeSint16BE(_lastMouseRegion);
-	for (int i = 0; i < 40; i++)
-		out->writeUint16BE(_gameFlags[i]);
+	out->writeUint32BE(ARRAYSIZE(_flagsTable));
+	out->write(_flagsTable, ARRAYSIZE(_flagsTable));
 	for (int i = 0; i < 24; i++)
 		out->writeUint16BE(_globalScriptVars[i]);
 	out->writeByte(_brightness);

Modified: scummvm/trunk/engines/kyra/scene_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_lol.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/scene_lol.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -36,7 +36,7 @@
 namespace Kyra {
 
 void LoLEngine::loadLevel(int index) {
-	_gameFlags[36] |= 0x800;
+	_flagsTable[73] |= 0x08;
 	setMouseCursorToIcon(0x85);
 	_nextScriptFunc = 0;
 
@@ -398,7 +398,7 @@
 		memcpy(_screen->getPalette(2) + 384, _screen->_currentPalette + 384, 384);
 		delete[] swampPal;
 
-		if (_gameFlags[26] & 4) {
+		if (_flagsTable[52] & 0x04) {
 			uint8 *pal0 = _screen->_currentPalette;
 			uint8 *pal2 = _screen->getPalette(2);
 			for (int i = 1; i < 768; i++)
@@ -524,14 +524,14 @@
 }
 
 void LoLEngine::resetLampStatus() {
-	_gameFlags[15] |= 0x400;
+	_flagsTable[31] |= 0x04;
 	_lampEffect = -1;
 	updateLampStatus();
 }
 
 void LoLEngine::setLampMode(bool lampOn) {
-	_gameFlags[15] &= 0xFBFF;
-	if (!(_gameFlags[15] & 0x800) || !lampOn)
+	_flagsTable[31] &= 0xFB;
+	if (!(_flagsTable[30] & 0x08) || !lampOn)
 		return;
 
 	_screen->drawShape(0, _gameShapes[43], 291, 56, 0, 0);
@@ -542,7 +542,7 @@
 	uint8 newLampEffect = 0;
 	uint8 tmpOilStatus = 0;
 
-	if ((_updateFlags & 4) || !(_gameFlags[15] & 0x800))
+	if ((_updateFlags & 4) || !(_flagsTable[31] & 0x08))
 		return;
 
 	if (!_brightness || !_lampOilStatus) {
@@ -584,7 +584,7 @@
 }
 
 void LoLEngine::updateCompass() {
-	if (!(_gameFlags[15] & 0x4000) || (_updateFlags & 4))
+	if (!(_flagsTable[31] & 0x40) || (_updateFlags & 4))
 		return;
 
 	if (_compassDirection == -1) {
@@ -651,12 +651,12 @@
 	_sceneDefaultUpdate = 1;
 
 	calcCoordinates(_partyPosX, _partyPosY, _currentBlock, 0x80, 0x80);
-	_gameFlags[36] &= 0xfdff;
+	_flagsTable[73] &= 0xFD;
 
 	runLevelScript(opos, 4);
 	runLevelScript(npos, 1);
 
-	if (!(_gameFlags[36] & 0x200)) {
+	if (!(_flagsTable[73] & 0x02)) {
 		initTextFading(2, 0);
 
 		if (_sceneDefaultUpdate) {

Modified: scummvm/trunk/engines/kyra/script_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_lol.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/script_lol.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -206,12 +206,10 @@
 int LoLEngine::olol_setGameFlag(EMCState *script) {
 	debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_setGameFlag(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
 
-	assert((stackPos(0) >> 4) < 40);
-
 	if (stackPos(1))
-		_gameFlags[stackPos(0) >> 4] |= (1 << (stackPos(0) & 0x0f));
+		setGameFlag(stackPos(0));
 	else
-		_gameFlags[stackPos(0) >> 4] &= (~(1 << (stackPos(0) & 0x0f)));
+		resetGameFlag(stackPos(0));
 
 	return 1;
 }
@@ -221,12 +219,7 @@
 	if (stackPos(0) < 0)
 		return 0;
 
-	assert((stackPos(0) >> 4) < 40);
-
-	if (_gameFlags[stackPos(0) >> 4] & (1 << (stackPos(0) & 0x0f)))
-		return 1;
-
-	return 0;
+	return queryGameFlag(stackPos(0));
 }
 
 int LoLEngine::olol_loadLevelGraphics(EMCState *script) {

Modified: scummvm/trunk/engines/kyra/timer_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/timer_lol.cpp	2009-06-07 19:58:00 UTC (rev 41350)
+++ scummvm/trunk/engines/kyra/timer_lol.cpp	2009-06-07 20:43:43 UTC (rev 41351)
@@ -247,7 +247,7 @@
 }
 
 void LoLEngine::timerUpdateLampState(int timerNum) {
-	if ((_gameFlags[15] & 0x800) && (_gameFlags[15] & 0x400) && _lampOilStatus > 0)
+	if ((_flagsTable[31] & 0x08) && (_flagsTable[31] & 0x04) && _lampOilStatus > 0)
 		_lampOilStatus--;
 }
 


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