[Scummvm-cvs-logs] SF.net SVN: scummvm:[35100] scummvm/trunk

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun Nov 16 21:51:10 CET 2008


Revision: 35100
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35100&view=rev
Author:   cyx
Date:     2008-11-16 20:51:10 +0000 (Sun, 16 Nov 2008)

Log Message:
-----------
some fixes to input handling, cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/tucker/locations.cpp
    scummvm/trunk/engines/tucker/resource.cpp
    scummvm/trunk/engines/tucker/sequences.cpp
    scummvm/trunk/engines/tucker/tucker.cpp
    scummvm/trunk/engines/tucker/tucker.h
    scummvm/trunk/graphics/flic_player.cpp

Modified: scummvm/trunk/engines/tucker/locations.cpp
===================================================================
--- scummvm/trunk/engines/tucker/locations.cpp	2008-11-16 20:46:18 UTC (rev 35099)
+++ scummvm/trunk/engines/tucker/locations.cpp	2008-11-16 20:51:10 UTC (rev 35100)
@@ -358,17 +358,18 @@
 }
 
 void TuckerEngine::updateSprite_locationNum4(int i) {
-	int flag = -1;
+	int state = -1;
+	printf("_flagsTable[9] %d\n", _flagsTable[9]);
 	if (_flagsTable[9] == 2) {
 		if (_charSpeechSoundCounter > 0 && _actionCharacterNum == i) {
-			flag = 1;
+			state = 1;
 			_spritesTable[i].needUpdate = 1;
 		} else {
-			flag = 2;
+			state = 2;
 			_spritesTable[i].needUpdate = 0;
 		}
 	}
-	_spritesTable[i].state = -1;
+	_spritesTable[i].state = state;
 }
 
 void TuckerEngine::execData3PreUpdate_locationNum4() {

Modified: scummvm/trunk/engines/tucker/resource.cpp
===================================================================
--- scummvm/trunk/engines/tucker/resource.cpp	2008-11-16 20:46:18 UTC (rev 35099)
+++ scummvm/trunk/engines/tucker/resource.cpp	2008-11-16 20:51:10 UTC (rev 35100)
@@ -215,15 +215,8 @@
 		return;
 	}
 	f.seek(128, SEEK_SET);
-	int size = 0, count = 0;
+	int size = 0;
 	while (size < 64000) {
-		if (type == 2) {
-			++count;
-			if (count > 500) {
-				count = 0;
-				isSpeechSoundPlaying();
-			}
-		}
 		int code = f.readByte();
 		if (code >= 0xC0) {
 			const int sz = code - 0xC0;
@@ -587,10 +580,10 @@
 	loadFile(_loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	t.findNextToken(kDataTokenDw);
-	_data4FlagDebug = t.getNextInteger();
-	_displayGameHints = t.getNextInteger();
+	_gameDebug = t.getNextInteger() != 0;
+	_displayGameHints = t.getNextInteger() != 0;
 	// forces game hints feature
-//	_displayGameHints = 1;
+//	_displayGameHints = true;
 	_locationObjectsCount = 0;
 	if (t.findIndex(_locationNum)) {
 		while (t.findNextToken(kDataTokenDw)) {
@@ -728,10 +721,7 @@
 }
 
 void TuckerEngine::loadSprA02_01() {
-	for (int i = 1; i < kSprA02TableSize; ++i) {
-		free(_sprA02Table[i]);
-		_sprA02Table[i] = 0;
-	}
+	unloadSprA02_01();
 	const int count = _sprA02LookupTable[_locationNum];
 	for (int i = 1; i < count + 1; ++i) {
 		sprintf(_fileToLoad, "sprites/a%02d_%02d.spr", _locationNum, i);
@@ -740,6 +730,13 @@
 	_sprA02Table[0] = _sprA02Table[1];
 }
 
+void TuckerEngine::unloadSprA02_01() {
+	for (int i = 1; i < kSprA02TableSize; ++i) {
+		free(_sprA02Table[i]);
+		_sprA02Table[i] = 0;
+	}
+}
+
 void TuckerEngine::loadSprC02_01() {
 	for (int i = 1; i < kSprC02TableSize; ++i) {
 		free(_sprC02Table[i]);
@@ -759,6 +756,13 @@
 	}
 }
 
+void TuckerEngine::unloadSprC02_01() {
+	for (int i = 1; i < kSprC02TableSize; ++i) {
+		free(_sprC02Table[i]);
+		_sprC02Table[i] = 0;
+	}
+}
+
 void TuckerEngine::loadFx() {
 	strcpy(_fileToLoad, "fx.c");
 	loadFile(_loadTempBuf);
@@ -888,6 +892,7 @@
 		}
 	}
 	if (stream) {
+		_mixer->stopHandle(*handle);
 		_mixer->playInputStream(type, handle, stream, -1, volume * Audio::Mixer::kMaxChannelVolume / kMaxSoundVolume);
 	}
 }
@@ -951,7 +956,7 @@
 			}
 		}
 		if (_conversationOptionsCount != 0) {
-			if (_mouseButtons != 0 && _nextTableToLoadIndex != -1) {
+			if (_leftMouseButtonPressed && _nextTableToLoadIndex != -1) {
 				_nextAction = _nextTableToLoadTable[_nextTableToLoadIndex];
 				_csDataLoaded = false;
 				 _conversationOptionsCount = 0;

Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp	2008-11-16 20:46:18 UTC (rev 35099)
+++ scummvm/trunk/engines/tucker/sequences.cpp	2008-11-16 20:51:10 UTC (rev 35100)
@@ -76,7 +76,8 @@
 		if (num < 6) {
 			Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf, 320, 320, 200);
 		} else {
-			if (getLastKeyCode() > 0) {
+			if (_inputKeys[kInputKeyEscape]) {
+				_inputKeys[kInputKeyEscape] = false;
 				return;
 			}
 			Graphics::copyTo640(_locationBackgroundGfxBuf, imgBuf + imgNum * 64000, 320, 320, 200);
@@ -107,11 +108,9 @@
 		}
 		for (int i = 0; i < _spritesCount; ++i) {
 			drawSprite(i);
-			isSpeechSoundPlaying();
 		}
 		copyToVGA(_locationBackgroundGfxBuf);
 		waitForTimer(3);
-		isSpeechSoundPlaying();
 		_timerCounter1 = 0;
 		counter4 = _timerCounter2 / 3;
 		if (counter4 == _creditsSequenceData1[num]) {
@@ -228,14 +227,8 @@
 	_spritesTable[0].stateIndex = -1;
 	int currentLocation = _locationNum;
 	_locationNum = 98;
-	for (int i = 1; i < kSprA02TableSize; ++i) {
-		free(_sprA02Table[i]);
-		_sprA02Table[i] = 0;
-	}
-	for (int i = 1; i < kSprC02TableSize; ++i) {
-		free(_sprC02Table[i]);
-		_sprC02Table[i] = 0;
-	}
+	unloadSprA02_01();
+	unloadSprC02_01();
 	_sprC02Table[1] = loadFile();
 	startSpeechSound(9000, 60);
 	_fadePaletteCounter = 0;
@@ -249,10 +242,12 @@
 		drawSprite(0);
 		copyToVGA(_locationBackgroundGfxBuf);
 		waitForTimer(3);
-		if (getLastKeyCode() > 0) {
-			stopSounds();
+		if (_inputKeys[kInputKeyEscape]) {
+			_inputKeys[kInputKeyEscape] = false;
+			break;
 		}
 	} while (isSpeechSoundPlaying());
+	stopSpeechSound();
 	do {
 		if (_fadePaletteCounter > 0) {
 			fadeInPalette();
@@ -268,7 +263,8 @@
 }
 
 void TuckerEngine::handleMeanwhileSequence() {
-	backupPalette();
+	uint8 backupPalette[256 * 3];
+	memcpy(backupPalette, _currentPalette, 256 * 3);
 	switch (_partNum) {
 	case 1:
 		strcpy(_fileToLoad, "meanw01.pcx");
@@ -304,7 +300,7 @@
 		copyToVGA(_locationBackgroundGfxBuf);
 		waitForTimer(3);
 	} while (_fadePaletteCounter > 0);
-	restorePalette();
+	memcpy(_currentPalette, backupPalette, 256 * 3);
 }
 
 void TuckerEngine::handleMapSequence() {
@@ -365,16 +361,16 @@
 			if (!_noPositionChangeAfterMap) {
 				xPos = _xPosCurrent;
 				yPos = _yPosCurrent;
-			} else if (_locationNum == 3 ||_locationNum == 65) {
+			} else if (_locationNum == 3 || _locationNum == 65) {
 				xPos = 620;
 				yPos = 130;
-			} else if (_locationNum == 9 ||_locationNum == 66) {
+			} else if (_locationNum == 9 || _locationNum == 66) {
 				xPos = 344;
 				yPos = 120;
-			} else if (_locationNum == 16 ||_locationNum == 61) {
+			} else if (_locationNum == 16 || _locationNum == 61) {
 				xPos = 590;
 				yPos = 130;
-			} else if (_locationNum == 20 ||_locationNum == 68) {
+			} else if (_locationNum == 20 || _locationNum == 68) {
 				xPos = 20;
 				yPos = 130;
 			} else {
@@ -570,8 +566,9 @@
 				break;
 			}
 		}
-	} while (_system->getMillis() <= end);
-	_lastFrameTime = _system->getMillis();
+		_system->delayMillis(10);
+		_lastFrameTime = _system->getMillis();
+	} while (_lastFrameTime <= end);
 }
 
 Audio::AudioStream *AnimationSequencePlayer::loadSoundFileAsStream(const char *name, AnimationSoundType type) {

Modified: scummvm/trunk/engines/tucker/tucker.cpp
===================================================================
--- scummvm/trunk/engines/tucker/tucker.cpp	2008-11-16 20:46:18 UTC (rev 35099)
+++ scummvm/trunk/engines/tucker/tucker.cpp	2008-11-16 20:51:10 UTC (rev 35100)
@@ -130,6 +130,9 @@
 		_nextLocationNum = kStartupLocation;
 	}
 	_gamePaused = _gamePaused2 = false;
+	_gameDebug = false;
+	_displayGameHints = false;
+	_displaySpeechText = false;
 	memset(_flagsTable, 0, sizeof(_flagsTable));
 
 	_gameHintsIndex = 0;
@@ -163,7 +166,8 @@
 	_mouseClickOnPanelSliders = 0;
 	_mouseIdleCounter = 0;
 	_leftMouseButtonPressed = _rightMouseButtonPressed = false;
-	_keyLastKeyCodePressed = _lastKeyPressed = 0;
+	_lastKeyPressed = 0;
+	memset(_inputKeys, 0, sizeof(_inputKeys));
 	_cursorNum = 0;
 	_cursorType = 0;
 	_updateCursorFlag = 0;
@@ -293,7 +297,6 @@
 	_currentGfxBackground = 0;
 	_fadePaletteCounter = 0;
 	memset(&_currentPalette, 0, sizeof(_currentPalette));
-	memset(&_backupPalette, 0, sizeof(_backupPalette));
 
 	_updateLocationFadePaletteCounter = 0;
 	_updateLocationCounter = 10;
@@ -335,6 +338,7 @@
 	strcpy(_fileToLoad, "csdata.c");
 	_csDataBuf = loadFile();
 	_csDataSize = _fileLoadSize;
+
 	_currentSaveGameSlot = _firstSaveGameSlot = 1;
 	_maxSaveGameSlot = _lastSaveGameSlot = 99;
 	loadBudSpr(0);
@@ -420,7 +424,7 @@
 		if (_locationHeight == 140) {
 			switchPanelType();
 			redrawPanelItems();
-			if (_displayGameHints != 0 && _gameHintsIndex < 6) {
+			if (_displayGameHints && _gameHintsIndex < 6) {
 				updateGameHints();
 			}
 			if (_panelState == 0) {
@@ -493,7 +497,7 @@
 		if (_currentFxSet != 0) {
 			setSoundVolumeDistance();
 		}
-		if (_data4FlagDebug != 0) {
+		if (_gameDebug) {
 			drawStringInteger(_scrollOffset + _mousePosX, 0, 10, 3);
 			drawStringInteger(_scrollOffset + _mousePosY, 0, 20, 3);
 			drawStringInteger(_backgroundSpriteCurrentFrame, 0, 40, 3);
@@ -512,38 +516,62 @@
 				}
 			}
 		}
-		_lastKeyPressed = getLastKeyCode();
 		if (_gamePaused && _charSpeechSoundCounter == 0) {
 			stopSounds();
 			_gamePaused2 = true;
 			while (1) {
-				if (_lastKeyPressed == Common::KEYCODE_p && _charSpeechSoundCounter <= 0) { // Paused
-					playSounds();
-					_gamePaused = _gamePaused2 = false;
-					break;
+				waitForTimer(1);
+				if (_inputKeys[kInputKeyPause]) {
+					_inputKeys[kInputKeyPause] = false;
+					if (_charSpeechSoundCounter <= 0) {
+						break;
+					}
 				}
-				_lastKeyPressed = getLastKeyCode();
 				if (_charSpeechSoundCounter == 0) {
 					if (_lastKeyPressed >= Common::KEYCODE_1 && _lastKeyPressed <= Common::KEYCODE_5) {
 						if (_speechHistoryTable[_lastKeyPressed - Common::KEYCODE_1] > 0) {
 							startSpeechSound(_speechHistoryTable[_lastKeyPressed - Common::KEYCODE_1], 100);
 							_charSpeechSoundCounter = kDefaultCharSpeechSoundCounter;
 						}
+						_lastKeyPressed = 0;
 					}
 				}
 				updateCharSpeechSound();
 			}
+			playSounds();
+			_gamePaused = _gamePaused2 = false;
 		}
-		if (_lastKeyPressed == Common::KEYCODE_p && _locationNum == 70) {
-			_gamePaused = true;
+		if (_inputKeys[kInputKeyPause]) {
+			_inputKeys[kInputKeyPause] = false;
+			if (_locationNum != 70) {
+				_gamePaused = true;
+			}
 		}
-		if (_lastKeyPressed == Common::KEYCODE_F3 && _displayGameHints != 0 && _gameHintsDisplayText == 1) {
-			_mouseButton2 = _gameHintsIndex + 1;
-			_mouseIdleCounter = 1100;
+		if (_inputKeys[kInputKeyToggleTextSpeech]) {
+			_inputKeys[kInputKeyToggleTextSpeech] = false;
+			if (_lang != Common::FR_FRA) {
+				if (_displaySpeechText) {
+					_displaySpeechText = false;
+//					kDefaultCharSpeechSoundCounter = 1;
+				} else {
+					_displaySpeechText = true;
+//					kDefaultCharSpeechSoundCounter = 70;
+				}
+			}
 		}
-		if (_lastKeyPressed == 1 && _data4FlagDebug != 0) {
-			_flagsTable[236] = 74;
+		if (_inputKeys[kInputKeyHelp]) {
+			_inputKeys[kInputKeyHelp] = false;
+			if (_displayGameHints && _gameHintsDisplayText == 1) {
+				_mouseButton2 = _gameHintsIndex + 1;
+				_mouseIdleCounter = 1100;
+			}
 		}
+		if (_inputKeys[kInputKeyEscape]) {
+			_inputKeys[kInputKeyEscape] = false;
+			if (_gameDebug) {
+				_flagsTable[236] = 74;
+			}
+		}
 		if (_flagsTable[236] > 70) {
 			handleCreditsSequence();
 			_quitGame = true;
@@ -552,7 +580,10 @@
 	if (_flagsTable[100] == 1) {
 		handleCongratulationsSequence();
 	}
+
 	closeCompressedSoundFile();
+	unloadSprA02_01();
+	unloadSprC02_01();
 	freeBuffers();
 }
 
@@ -577,12 +608,31 @@
 	while (_eventMan->pollEvent(ev)) {
 		switch (ev.type) {
 		case Common::EVENT_KEYDOWN:
-			if (ev.kbd.flags == Common::KBD_CTRL) {
-				if (ev.kbd.keycode == Common::KEYCODE_f) {
+			switch (ev.kbd.keycode) {
+			case Common::KEYCODE_f:
+				if (ev.kbd.flags == Common::KBD_CTRL) {
 					_fastMode = !_fastMode;
 				}
+				break;
+			case Common::KEYCODE_p:
+				_inputKeys[kInputKeyPause] = true;
+				break;
+			case Common::KEYCODE_F1:
+				_inputKeys[kInputKeyToggleInventory] = true;
+				break;
+			case Common::KEYCODE_F2:
+				_inputKeys[kInputKeyToggleTextSpeech] = true;
+				break;
+			case Common::KEYCODE_F3:
+				_inputKeys[kInputKeyHelp] = true;
+				break;
+			case Common::KEYCODE_ESCAPE:
+				_inputKeys[kInputKeyEscape] = true;
+				break;
+			default:
+				break;
 			}
-			_keyLastKeyCodePressed = ev.kbd.keycode;
+			_lastKeyPressed = ev.kbd.keycode;
 			break;
 		case Common::EVENT_MOUSEMOVE:
 			updateCursorPos(ev.mouse.x, ev.mouse.y);
@@ -710,12 +760,6 @@
 			_mouseButton2 = 0;
 		}
 	}
-	if (_mousePosX > 307) {
-		_mousePosX = 307;
-	}
-	if (_mousePosY > 195) {
-		_mousePosY = 195;
-	}
 	if (_cursorType == 1) {
 		if (_panelState == 1) {
 			setCursorNum(1);
@@ -886,14 +930,6 @@
 	}
 }
 
-void TuckerEngine::backupPalette() {
-	memcpy(_backupPalette, _currentPalette, 256 * 3);
-}
-
-void TuckerEngine::restorePalette() {
-	memcpy(_currentPalette, _backupPalette, 256 * 3);
-}
-
 void TuckerEngine::fadeOutPalette(int colorsCount) {
 	uint8 pal[256 * 4];
 	_system->grabPalette(pal, 0, colorsCount);
@@ -929,6 +965,7 @@
 		const int c = _currentPalette[color * 3 + i] + step * 4;
 		rgb[i] = MIN(c, 255);
 	}
+	rgb[3] = 255;
 	_system->setPalette(rgb, color, 1);
 }
 
@@ -1050,12 +1087,6 @@
 	}
 }
 
-int TuckerEngine::getLastKeyCode() {
-	int keyCode = _keyLastKeyCodePressed;
-	_keyLastKeyCodePressed = 0;
-	return keyCode;
-}
-
 void TuckerEngine::stopSounds() {
 	for (int i = 0; i < _locationSoundsCount; ++i) {
 		stopSound(i);
@@ -1348,10 +1379,13 @@
 }
 
 void TuckerEngine::switchPanelType() {
-	if (_panelState == 0 && _switchPanelFlag == 0 && _lastKeyPressed == Common::KEYCODE_F1) {
-		_switchPanelFlag = 1;
-		_switchPanelCounter = 1;
-		return;
+	if (_inputKeys[kInputKeyToggleInventory]) {
+		_inputKeys[kInputKeyToggleInventory] = false;
+		if (_panelState == 0 && _switchPanelFlag == 0) {
+			_switchPanelFlag = 1;
+			_switchPanelCounter = 1;
+			return;
+		}
 	}
 	if (_switchPanelFlag == 0) {
 		return;
@@ -1687,29 +1721,25 @@
 }
 
 void TuckerEngine::drawCurrentSprite() {
-	int offset;
 	SpriteFrame *chr = &_spriteFramesTable[_currentSpriteAnimationFrame];
+	int offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent;
 	if (_mirroredDrawing == 0) {
-		offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent;
 		offset += chr->xOffset - 14;
 	} else {
-		offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent;
 		offset -= chr->xSize + chr->xOffset - 14;
 	}
 	Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr->sourceOffset, chr->xSize, chr->ySize,
 		chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0);
 	if (_currentSpriteAnimationLength > 1) {
 		SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2];
+		offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
 		if (_mirroredDrawing == 0) {
-			offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
 			offset += chr2->xOffset - 14;
 		} else {
-			offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
 			offset -= chr2->xSize + chr2->xOffset - 14;
 		}
 		Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr2->sourceOffset, chr2->xSize, chr2->ySize,
-			_spriteFramesTable[_currentSpriteAnimationFrame].yOffset, // _currentCharacter instead ?
-			_locationHeightTable[_locationNum], _mirroredDrawing != 0);
+			chr2->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0);
 	}
 }
 
@@ -1753,6 +1783,10 @@
 	loadSound(Audio::Mixer::kSpeechSoundType, num, volume, false, &_speechHandle);
 }
 
+void TuckerEngine::stopSpeechSound() {
+	_mixer->stopHandle(_speechHandle);
+}
+
 bool TuckerEngine::isSpeechSoundPlaying() {
 	return _mixer->isSoundHandleActive(_speechHandle);
 }
@@ -2068,21 +2102,21 @@
 		_backgroundSpriteDataPtr = _sprA02Table[_backgroundSpriteCurrentAnimation];
 		_backgroundSpriteLastFrame = READ_LE_UINT16(_backgroundSpriteDataPtr);
 	}
-	int var8 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex];
+	int frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex];
 	if (_panelLockedFlag == 0 && _characterFacingDirection < 5 && _selectedObject.locationObject_locationNum == 0) {
 		_characterFacingDirection = 0;
 	}
 	if (_charSpeechSoundCounter > 0 && _characterFacingDirection == 6 && _actionCharacterNum == 99) {
 		_characterFacingDirection = 6;
-		var8 = 999;
+		frame = 999;
 	} else {
 		if (_characterFacingDirection == 6 && _charSpeechSoundCounter != 0 && _actionCharacterNum != 99) {
 			_characterFacingDirection = 0;
-			var8 = 999;
+			frame = 999;
 		}
 	}
 	int num = 0;
-	if (var8 == 999 || (_characterFacingDirection != _characterPrevFacingDirection && _characterFacingDirection < 5)) {
+	if (frame == 999 || (_characterFacingDirection != _characterPrevFacingDirection && _characterFacingDirection < 5)) {
 		_mirroredDrawing = 0;
 		if (_characterFacingDirection == 6) {
 			if (_csDataHandled != 0) {
@@ -2140,16 +2174,16 @@
 		}
 		_currentSpriteAnimationLength = _spriteAnimationsTable[num].numParts;
 		_spriteAnimationFrameIndex = _spriteAnimationsTable[num].firstFrameIndex;
-		var8 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex];
+		frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex];
 	}
 	if (_characterAnimationNum > 0) {
 		num = _characterAnimationNum;
 		_currentSpriteAnimationLength = _spriteAnimationsTable[num].numParts;
 		_spriteAnimationFrameIndex = _spriteAnimationsTable[num].firstFrameIndex;
-		var8 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex];
+		frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex];
 		_characterAnimationNum = 0;
 	}
-	_currentSpriteAnimationFrame = var8;
+	_currentSpriteAnimationFrame = frame;
 	++_spriteAnimationFrameIndex;
 	if (_currentSpriteAnimationLength > 1) {
 		_currentSpriteAnimationFrame2 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex];
@@ -2226,17 +2260,17 @@
 }
 
 void TuckerEngine::removeObjectFromInventory(int num) {
-	int i = 0;
-	while (_inventoryObjectsList[i] != num && i < _inventoryObjectsCount) {
-		++i;
+	for (int i = 0; i < _inventoryObjectsCount; ++i) {
+		if (_inventoryObjectsList[i] == num) {
+			--_inventoryObjectsCount;
+			_inventoryItemsState[num] = 2;
+			const int count = _inventoryObjectsCount - i;
+			if (count != 0) {
+				memmove(_inventoryObjectsList + i, _inventoryObjectsList + i + 1, count * sizeof(int));
+			}
+			break;
+		}
 	}
-	--_inventoryObjectsCount;
-	int j = i;
-	while (j < _inventoryObjectsCount) {
-		_inventoryObjectsList[j] = _inventoryObjectsList[j + 1];
-		++j;
-	}
-	_inventoryItemsState[num] = 2;
 }
 
 void TuckerEngine::handleMap() {
@@ -2777,6 +2811,10 @@
 		if (_updateSpriteFlag1 == 0) {
 			_spritesTable[i].animationFrame = 1;
 		}
+		if (_spritesTable[i].state < 0 || !_sprC02Table[_spritesTable[i].state]) {
+			warning("Invalid state %d for sprite %d location %d", _spritesTable[i].state, i, _locationNum);
+			return;
+		}
 		_spritesTable[i].animationData = _sprC02Table[_spritesTable[i].state];
 		_spritesTable[i].firstFrame = READ_LE_UINT16(_spritesTable[i].animationData);
 		if (_updateSpriteFlag2 == 1) {
@@ -2846,8 +2884,7 @@
 		setCursorType(0);
 		return;
 	}
-	static const int constEq0 = 0; // display text for speech
-	if (constEq0 == 1 && !_gamePaused2) {
+	if (_displaySpeechText && !_gamePaused2) {
 		drawSpeechText(_actionPosX, _actionPosY, _characterSpeechDataPtr, _speechSoundNum, _actionTextColor);
 	}
 }
@@ -2931,7 +2968,7 @@
 
 int TuckerEngine::parseTableInstruction() {
 	int spr;
-	printf("parseTableInstruction instruction %c %c %c\n", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]);
+	debug(2, "parseTableInstruction instruction %c%c%c", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]);
 	switch (_tableInstructionsPtr[0]) {
 	case 'p': // 12
 		if (_tableInstructionsPtr[1] == 'a') { // 0
@@ -3277,7 +3314,7 @@
 		}
 		break;
 	}
-	printf("Instruction not recognised %c %c %c\n", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]);
+	warning("Instruction not recognised %c%c%c", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]);
 	return 2;
 }
 
@@ -3450,48 +3487,38 @@
 }
 
 int TuckerEngine::testLocationMaskArea(int xBase, int yBase, int xPos, int yPos) {
-	int i = 0;
-	bool quitLoop = false;
-	while (!quitLoop) {
-		bool flag = false;
+	while (true) {
+		bool loop = false;
 		if (yBase > yPos) {
 			if (testLocationMask(xBase, yBase - 1) == 1) {
 				--yBase;
-				flag = true;
-			} else {
-				++i;
+				loop = true;
 			}
 		} else if (yBase < yPos) {
 			if (testLocationMask(xBase, yBase + 1) == 1) {
 				++yBase;
-				flag = true;
-			} else {
-				++i;
+				loop = true;
 			}
 		}
 		if (xBase > xPos) {
 			if (testLocationMask(xBase - 1, yBase) == 1) {
 				--xBase;
-				flag = true;
-			} else {
-				++i;
+				loop = true;
 			}
-		} else if (xBase <= xPos) {
+		} else if (xBase < xPos) {
 			if (testLocationMask(xBase + 1, yBase) == 1) {
 				++xBase;
-				flag = true;
-			} else {
-				++i;
+				loop = true;
 			}
 		}
 		if (xBase == xPos && yBase == yPos) {
+			return 0;
+		}
+		if (!loop) {
 			break;
 		}
-		if (!flag) {
-			return 1;
-		}
 	}
-	return 0;
+	return 1;
 }
 
 void TuckerEngine::handleMouseClickOnInventoryObject() {

Modified: scummvm/trunk/engines/tucker/tucker.h
===================================================================
--- scummvm/trunk/engines/tucker/tucker.h	2008-11-16 20:46:18 UTC (rev 35099)
+++ scummvm/trunk/engines/tucker/tucker.h	2008-11-16 20:51:10 UTC (rev 35100)
@@ -191,6 +191,15 @@
 	kVerbUse   = 8
 };
 
+enum InputKey {
+	kInputKeyPause = 0,
+	kInputKeyEscape,
+	kInputKeyToggleInventory,
+	kInputKeyToggleTextSpeech,
+	kInputKeyHelp,
+	kInputKeyCount
+};
+
 class TuckerEngine: public Engine {
 public:
 
@@ -236,15 +245,12 @@
 	void updateCharPositionHelper();
 	void updateCharPosition();
 	void updateFlagsForCharPosition();
-	void backupPalette();
-	void restorePalette();
 	void fadeOutPalette(int colorsCount = 256);
 	void fadeInPalette(int colorsCount = 256);
 	void fadePaletteColor(int color, int step);
 	void setBlackPalette();
 	void setPaletteColor(int color, int r, int g, int b);
 	void updateCursor();
-	int getLastKeyCode();
 	void stopSounds();
 	void playSounds();
 	void updateCharactersPath();
@@ -274,8 +280,8 @@
 	void startMusic(int offset, int index, int volume);
 	void stopMusic(int index);
 	void startSpeechSound(int num, int volume);
+	void stopSpeechSound();
 	bool isSpeechSoundPlaying();
-	void isSoundFinished();
 	void redrawPanelItems();
 	void redrawPanelItemsHelper();
 	void drawSprite(int i);
@@ -537,7 +543,9 @@
 	void loadActionFile();
 	void loadCharPos();
 	void loadSprA02_01();
+	void unloadSprA02_01();
 	void loadSprC02_01();
+	void unloadSprC02_01();
 	void loadFx();
 	void loadSound(Audio::Mixer::SoundType type, int num, int volume, bool loop, Audio::SoundHandle *handle);
 	void loadActionsTable();
@@ -562,9 +570,10 @@
 	int _nextLocationNum;
 	bool _gamePaused;
 	bool _gamePaused2;
-	int _data4FlagDebug;
-	int _displayGameHints;
+	bool _gameDebug;
+	bool _displayGameHints;
 	int _execData3Counter;
+	bool _displaySpeechText;
 
 	uint8 _maxSaveGameSlot, _currentSaveGameSlot;
 	uint8 _firstSaveGameSlot, _lastSaveGameSlot;
@@ -602,7 +611,6 @@
 	int _mousePosX, _mousePosY;
 	int _prevMousePosX, _prevMousePosY;
 	int _mouseButtonsMask;
-	int _mouseButtons;
 	int _mouseButton2;
 	int _mouseClick;
 	int _mouseClickOnPanelSliders;
@@ -610,7 +618,7 @@
 	bool _leftMouseButtonPressed;
 	bool _rightMouseButtonPressed;
 	int _lastKeyPressed;
-	int _keyLastKeyCodePressed;
+	bool _inputKeys[kInputKeyCount];
 	int _cursorNum;
 	int _cursorType;
 	int _updateCursorFlag;
@@ -774,7 +782,6 @@
 	uint8 *_currentGfxBackground;
 	int _fadePaletteCounter;
 	uint8 _currentPalette[768];
-	uint8 _backupPalette[768];
 
 	int _updateLocationFadePaletteCounter;
 	int _updateLocationCounter;
@@ -876,7 +883,7 @@
 	int _updateScreenOffset;
 	int _frameCounter;
 	int _frameTime;
-	int _lastFrameTime;
+	uint32 _lastFrameTime;
 	uint8 *_picBufPtr, *_pic2BufPtr;
 	Audio::SoundHandle _soundsHandle[15];
 	Audio::SoundHandle _sfxHandle;

Modified: scummvm/trunk/graphics/flic_player.cpp
===================================================================
--- scummvm/trunk/graphics/flic_player.cpp	2008-11-16 20:46:18 UTC (rev 35099)
+++ scummvm/trunk/graphics/flic_player.cpp	2008-11-16 20:51:10 UTC (rev 35100)
@@ -71,7 +71,7 @@
 
 	head.size = _fileStream.readUint32LE();
 	head.type = _fileStream.readUint16LE();
-	
+
 	return head;
 }
 
@@ -154,9 +154,9 @@
 				data += rleCount * 2;
 				column += rleCount * 2;
 			} else if (rleCount < 0) {
-				uint16 dataWord = *(uint16 *)data; data += 2;
+				uint16 dataWord = READ_UINT16(data); data += 2;
 				for (int i = 0; i < -(int16)rleCount; ++i) {
-					WRITE_LE_UINT16(_offscreen + (currentLine * _flicInfo.width) + column + (i * 2), dataWord);
+					WRITE_UINT16(_offscreen + (currentLine * _flicInfo.width) + column + (i * 2), dataWord);
 				}
 				_dirtyRects.push_back(Common::Rect(column, currentLine, column + (-(int16)rleCount * 2), currentLine + 1));
 
@@ -237,8 +237,7 @@
 	if (0 == READ_LE_UINT16(mem)) { //special case
 		mem += 2;
 		for (int i = 0; i < 256; ++i) {
-			for (int j = 0; j < 3; ++j)
-				_palette[i * 4 + j] = (mem[i * 3 + j]);
+			memcpy(_palette + i * 4, mem + i * 3, 3);
 			_palette[i * 4 + 3] = 0;
 		}
 	} else {
@@ -249,8 +248,7 @@
 			uint8 change = *mem++;
 
 			for (int i = 0; i < change; ++i) {
-				for (int j = 0; j < 3; ++j)
-					_palette[(palPos + i) * 4 + j] = (mem[i * 3 + j]);
+				memcpy(_palette + (palPos + i) * 4, mem + i * 3, 3);
 				_palette[(palPos + i) * 4 + 3] = 0;
 			}
 


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