[Scummvm-cvs-logs] SF.net SVN: scummvm: [24644] scummvm/trunk/engines/touche

cyx at users.sourceforge.net cyx at users.sourceforge.net
Tue Nov 7 00:32:46 CET 2006


Revision: 24644
          http://svn.sourceforge.net/scummvm/?rev=24644&view=rev
Author:   cyx
Date:     2006-11-06 15:32:37 -0800 (Mon, 06 Nov 2006)

Log Message:
-----------
some fixes, some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/touche/resource.cpp
    scummvm/trunk/engines/touche/staticres.cpp
    scummvm/trunk/engines/touche/touche.cpp
    scummvm/trunk/engines/touche/touche.h
    scummvm/trunk/engines/touche/ui.cpp

Modified: scummvm/trunk/engines/touche/resource.cpp
===================================================================
--- scummvm/trunk/engines/touche/resource.cpp	2006-11-06 23:28:40 UTC (rev 24643)
+++ scummvm/trunk/engines/touche/resource.cpp	2006-11-06 23:32:37 UTC (rev 24644)
@@ -108,7 +108,7 @@
 		error("Unable to allocate memory for conv kit data");
 	}
 
-	for (int i = 0; i < 5; ++i) {
+	for (int i = 0; i < NUM_SEQUENCES; ++i) {
 		_sequenceDataTable[i] = (uint8 *)malloc(16384);
 		if (!_sequenceDataTable[i]) {
 			error("Unable to allocate memory for sequence data %d", i);
@@ -429,6 +429,9 @@
 	_fullRedrawCounter = 1;
 	_roomNeedRedraw = true;
 
+//	uint8 *p = _backdropBuffer + _currentBitmapWidth * _currentBitmapHeight;
+//	_spritesTable[5].ptr = p + 16384;
+//	_spritesTable[6].ptr = p + 145728 + 16384;
 	_sequenceEntryTable[5].sprNum = -1;
 	_sequenceEntryTable[5].seqNum = -1;
 	_sequenceEntryTable[6].sprNum = -1;

Modified: scummvm/trunk/engines/touche/staticres.cpp
===================================================================
--- scummvm/trunk/engines/touche/staticres.cpp	2006-11-06 23:28:40 UTC (rev 24643)
+++ scummvm/trunk/engines/touche/staticres.cpp	2006-11-06 23:32:37 UTC (rev 24644)
@@ -32,7 +32,9 @@
 	{ 0x1E848, 0, 0, 0, 0, 0 },
 	{ 0x1E848, 0, 0, 0, 0, 0 },
 	{ 0x23A50, 0, 0, 0, 0, 0 },
-	{ 0x1E848, 0, 0, 0, 0, 0 }
+	{ 0x1E848, 0, 0, 0, 0, 0 },
+	{ 0x23940, 0, 0, 0, 0, 0 }, // room sprite 1
+	{ 0x1E848, 0, 0, 0, 0, 0 }  // room sprite 2
 };
 
 const uint8 ToucheEngine::_directionsTable[] = {
@@ -59,26 +61,6 @@
 	"[Empty.9.......................]"
 };
 
-void ToucheEngine::setupRect() {
-	static const Common::Rect inventoryAreasTable[13] = {
-		Common::Rect(  0, 354,  50, 400),
-		Common::Rect( 66, 354, 124, 380),
-		Common::Rect( 74, 380, 116, 398),
-		Common::Rect(116, 380, 158, 398),
-		Common::Rect(144, 354, 198, 380),
-		Common::Rect(202, 354, 238, 396),
-		Common::Rect(242, 354, 300, 396),
-		Common::Rect(300, 354, 358, 396),
-		Common::Rect(358, 354, 416, 396),
-		Common::Rect(416, 354, 474, 396),
-		Common::Rect(474, 354, 532, 396),
-		Common::Rect(532, 354, 590, 396),
-		Common::Rect(594, 354, 640, 395)
-	};
-
-	_inventoryAreasTable = inventoryAreasTable;
-}
-
 const uint16 Graphics::_fontOffs[] = {
 	0x0000, 0x0007, 0x0024, 0x0043, 0x0072, 0x00AD, 0x00E0, 0x0113, 0x0124, 0x0141,
 	0x015E, 0x0191, 0x01C4, 0x01E3, 0x01F8, 0x0215, 0x0232, 0x0269, 0x0286, 0x02BD,

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2006-11-06 23:28:40 UTC (rev 24643)
+++ scummvm/trunk/engines/touche/touche.cpp	2006-11-06 23:32:37 UTC (rev 24644)
@@ -64,7 +64,6 @@
 	memset(_paletteBuffer, 0, sizeof(_paletteBuffer));
 
 	setupOpcodes();
-	setupRect();
 	setupUIRect();
 
 	Common::addSpecialDebugLevel(kDebugEngine,   "Engine",   "Engine debug level");
@@ -157,6 +156,7 @@
 	clearAreaTable();
 	clearAnimationTable();
 
+	setupInventoryAreas();
 	initInventoryObjectsTable();
 	initInventoryLists();
 	drawInventory(0, 1);
@@ -1189,6 +1189,7 @@
 
 void ToucheEngine::setKeyCharMoney() {
 	_keyCharsTable[_currentKeyCharNum].money += _currentAmountOfMoney;
+	_currentAmountOfMoney = 0;
 	drawAmountOfMoneyInInventory();
 }
 
@@ -1373,83 +1374,83 @@
 }
 
 void ToucheEngine::handleMouseButtonClicked() {
-	for (int i = 0; i < 13; ++i) {
-		if (_inventoryAreasTable[i].contains(_inp_mousePos)) {
-			switch (i) {
-			case 0:
-				_keyCharsTable[_currentKeyCharNum].money += _currentAmountOfMoney;
-				_currentAmountOfMoney = 0;
-				ui_handleOptions(0);
-				break;
-			case 1:
-				setKeyCharMoney();
+	for (int area = 0; area < ARRAYSIZE(_inventoryAreasTable); ++area) {
+		if (_inventoryAreasTable[area].contains(_inp_mousePos)) {
+			if (area >= kInventoryObject1 && area <= kInventoryObject6) {
+				int item = _inventoryVar1[area - 6 + *_inventoryVar2];
+				_flagsTable[119] = _currentCursorObject;
 				if (_currentCursorObject == 1) {
-					setCursor(0);
-				}
-				break;
-			case 2:
-				if (_keyCharsTable[_currentKeyCharNum].money >= 10) {
-					_keyCharsTable[_currentKeyCharNum].money -= 10;
-					_currentAmountOfMoney += 10;
-				}
-				break;
-			case 3:
-				if (_keyCharsTable[_currentKeyCharNum].money != 0) {
-					--_keyCharsTable[_currentKeyCharNum].money;
-					++_currentAmountOfMoney;
-					drawAmountOfMoneyInInventory();
-				}
-				break;
-			case 4:
-				if (_currentAmountOfMoney != 0) {
-					updateCursor(_objectDescriptionNum);
-					int money = _currentAmountOfMoney;
+					setKeyCharMoney();
+					_flagsTable[118] = _currentAmountOfMoney;
 					_currentAmountOfMoney = 0;
-					drawAmountOfMoneyInInventory();
-					setCursor(1);
-					_currentAmountOfMoney = money;
 				}
-				break;
-			case 5:
-				if (*_inventoryVar2 != 0) {
-					*_inventoryVar2 -= 6;
+				if (item != 0 && _currentCursorObject != 0) {
+					if (restartKeyCharScriptOnAction(-53, item | 0x1000, 0)) {
+						updateCursor(_objectDescriptionNum);
+						drawInventory(_objectDescriptionNum, 1);
+					}
+				} else {
+					_inventoryVar1[area - 6 + *_inventoryVar2] = 0;
+					if (_currentCursorObject != 0) {
+						updateCursor(_objectDescriptionNum);
+					}
+					if (item != 0) {
+						setCursor(item);
+						packInventoryItems(0);
+						packInventoryItems(1);
+					}
 					drawInventory(_objectDescriptionNum, 1);
 				}
-				break;
-			case 12:
-				if (_inventoryVar1[12 + *_inventoryVar2] != 0) {
-					*_inventoryVar2 += 6;
-					drawInventory(_objectDescriptionNum, 1);
-				}
-				break;
-			default:
-				if (i >= 6 && i <= 11) {
-					int item = _inventoryVar1[i - 6 + *_inventoryVar2];
-					_flagsTable[119] = _currentCursorObject;
+			} else {
+				switch (area) {
+				case kInventoryCharacter:
+					_keyCharsTable[_currentKeyCharNum].money += _currentAmountOfMoney;
+					_currentAmountOfMoney = 0;
+					ui_handleOptions(0);
+					break;
+				case kInventoryMoneyDisplay:
+					setKeyCharMoney();
 					if (_currentCursorObject == 1) {
-						setKeyCharMoney();
-						_flagsTable[118] = _currentAmountOfMoney;
+						setCursor(0);
+					}
+					break;
+				case kInventoryGoldCoins:
+					if (_keyCharsTable[_currentKeyCharNum].money >= 10) {
+						_keyCharsTable[_currentKeyCharNum].money -= 10;
+						_currentAmountOfMoney += 10;
+						drawAmountOfMoneyInInventory();
+					}
+					break;
+				case kInventorySilverCoins:
+					if (_keyCharsTable[_currentKeyCharNum].money != 0) {
+						--_keyCharsTable[_currentKeyCharNum].money;
+						++_currentAmountOfMoney;
+						drawAmountOfMoneyInInventory();
+					}
+					break;
+				case kInventoryMoney:
+					if (_currentAmountOfMoney != 0) {
+						updateCursor(_objectDescriptionNum);
+						int money = _currentAmountOfMoney;
 						_currentAmountOfMoney = 0;
+						drawAmountOfMoneyInInventory();
+						setCursor(1);
+						_currentAmountOfMoney = money;
 					}
-					if (item != 0 && _currentCursorObject != 0) {
-						if (restartKeyCharScriptOnAction(-53, item | 0x1000, 0)) {
-							updateCursor(_objectDescriptionNum);
-							drawInventory(_objectDescriptionNum, 1);
-						}
-					} else {
-						_inventoryVar1[i - 6 + *_inventoryVar2] = 0;
-						if (_currentCursorObject != 0) {
-							updateCursor(_objectDescriptionNum);
-						}
-						if (item != 0) {
-							setCursor(item);
-							packInventoryItems(0);
-							packInventoryItems(1);
-						}
+					break;
+				case kInventoryScroller1:
+					if (*_inventoryVar2 != 0) {
+						*_inventoryVar2 -= 6;
 						drawInventory(_objectDescriptionNum, 1);
 					}
+					break;
+				case kInventoryScroller2:
+					if (_inventoryVar1[6 + *_inventoryVar2] != 0) {
+						*_inventoryVar2 += 6;
+						drawInventory(_objectDescriptionNum, 1);
+					}
+					break;
 				}
-				break;
 			}
 			break;
 		}
@@ -1457,24 +1458,22 @@
 }
 
 void ToucheEngine::handleMouseButtonPressed() {
-	for (int pos = 0; pos < 13; ++pos) {
-		const Common::Rect &r = _inventoryAreasTable[pos];
+	for (int area = kInventoryObject1; area <= kInventoryObject6; ++area) {
+		const Common::Rect &r = _inventoryAreasTable[area];
 		if (r.contains(_inp_mousePos)) {
-			if (pos >= 6 && pos <= 11) {
-				int item = _inventoryVar1[pos - 6 + *_inventoryVar2] | 0x1000;
-				for (uint i = 0; i < _programHitBoxTable.size(); ++i) {
-					const ProgramHitBoxData *hitBox = &_programHitBoxTable[i];
-					if (hitBox->item == item) {
-						const int menuX = r.left + r.width() / 2;
-						const int menuY = 352;
-						int act = handleActionMenuUnderCursor(hitBox->actions, menuX, menuY, hitBox->str);
-						if (act != 0) {
-							restartKeyCharScriptOnAction(act, hitBox->item, 0);
-						}
+			int item = _inventoryVar1[area - 6 + *_inventoryVar2] | 0x1000;
+			for (uint i = 0; i < _programHitBoxTable.size(); ++i) {
+				const ProgramHitBoxData *hitBox = &_programHitBoxTable[i];
+				if (hitBox->item == item) {
+					const int menuX = r.left + r.width() / 2;
+					const int menuY = 352;
+					int act = handleActionMenuUnderCursor(hitBox->actions, menuX, menuY, hitBox->str);
+					if (act != 0) {
+						restartKeyCharScriptOnAction(act, hitBox->item, 0);
 					}
 				}
-				break;
 			}
+			break;
 		}
 	}
 }
@@ -1841,6 +1840,7 @@
 				break;
 			}
 		}
+		_system->updateScreen();
 		_system->delayMillis(50);
 	}
 
@@ -2025,6 +2025,22 @@
 	_inventoryListCount[3 * 2 + 2] = 6;
 }
 
+void ToucheEngine::setupInventoryAreas() {
+	_inventoryAreasTable[kInventoryCharacter]    = Common::Rect(  0, 354,  50, 400);
+	_inventoryAreasTable[kInventoryMoneyDisplay] = Common::Rect( 66, 354, 124, 380);
+	_inventoryAreasTable[kInventoryGoldCoins]    = Common::Rect( 74, 380, 116, 398);
+	_inventoryAreasTable[kInventorySilverCoins]  = Common::Rect(116, 380, 158, 398);
+	_inventoryAreasTable[kInventoryMoney]        = Common::Rect(144, 354, 198, 380);
+	_inventoryAreasTable[kInventoryScroller1]    = Common::Rect(202, 354, 238, 396);
+	_inventoryAreasTable[kInventoryObject1]      = Common::Rect(242, 354, 300, 396);
+	_inventoryAreasTable[kInventoryObject2]      = Common::Rect(300, 354, 358, 396);
+	_inventoryAreasTable[kInventoryObject3]      = Common::Rect(358, 354, 416, 396);
+	_inventoryAreasTable[kInventoryObject4]      = Common::Rect(416, 354, 474, 396);
+	_inventoryAreasTable[kInventoryObject5]      = Common::Rect(474, 354, 532, 396);
+	_inventoryAreasTable[kInventoryObject6]      = Common::Rect(532, 354, 590, 396);
+	_inventoryAreasTable[kInventoryScroller2]    = Common::Rect(594, 354, 640, 395);
+}
+
 void ToucheEngine::drawInventory(int index, int flag) {
 	if (_flagsTable[606] == 0) {
 		if (index > 1) {

Modified: scummvm/trunk/engines/touche/touche.h
===================================================================
--- scummvm/trunk/engines/touche/touche.h	2006-11-06 23:28:40 UTC (rev 24643)
+++ scummvm/trunk/engines/touche/touche.h	2006-11-06 23:32:37 UTC (rev 24644)
@@ -290,6 +290,22 @@
 	kLoadGameState
 };
 
+enum InventoryArea {
+	kInventoryCharacter = 0,
+	kInventoryMoneyDisplay,
+	kInventoryGoldCoins,
+	kInventorySilverCoins,
+	kInventoryMoney,
+	kInventoryScroller1,
+	kInventoryObject1,
+	kInventoryObject2,
+	kInventoryObject3,
+	kInventoryObject4,
+	kInventoryObject5,
+	kInventoryObject6,
+	kInventoryScroller2
+};
+
 class MidiPlayer;
 
 class ToucheEngine: public Engine {
@@ -299,7 +315,7 @@
 		NUM_FLAGS = 2000,
 		NUM_KEYCHARS = 32,
 		NUM_AREAS = 10,
-		NUM_SPRITES = 5,
+		NUM_SPRITES = 7,
 		NUM_SEQUENCES = 7,
 		NUM_CONVERSATION_CHOICES = 40,
 		NUM_TALK_ENTRIES = 16,
@@ -391,6 +407,7 @@
 
 	void initInventoryObjectsTable();
 	void initInventoryLists();
+	void setupInventoryAreas();
 	void drawInventory(int index, int flag);
 	void drawAmountOfMoneyInInventory();
 	void packInventoryItems(int index);
@@ -618,6 +635,7 @@
 	int16 *_inventoryVar1;
 	int16 *_inventoryVar2;
 	int _currentCursorObject;
+	Common::Rect _inventoryAreasTable[13];
 
 	int _talkTextMode;
 	int _talkListEnd;
@@ -687,7 +705,7 @@
 	uint8 *_backdropBuffer;
 	uint8 *_menuKitData;
 	uint8 *_convKitData;
-	uint8 *_sequenceDataTable[5];
+	uint8 *_sequenceDataTable[NUM_SEQUENCES];
 	uint8 *_programData;
 	uint32 _programDataSize;
 	uint8 *_mouseData;
@@ -726,8 +744,6 @@
 	static const uint8 _directionsTable[];
 	static char _saveLoadDescriptionsTable[10][33];
 
-	const Common::Rect *_inventoryAreasTable;
-	void setupRect();
 	void setupUIRect();
 };
 

Modified: scummvm/trunk/engines/touche/ui.cpp
===================================================================
--- scummvm/trunk/engines/touche/ui.cpp	2006-11-06 23:28:40 UTC (rev 24643)
+++ scummvm/trunk/engines/touche/ui.cpp	2006-11-06 23:32:37 UTC (rev 24644)
@@ -167,7 +167,7 @@
 }
 
 void ToucheEngine::ui_drawCurrentGameStateDescription() {
-	const Common::Rect *r = &buttonsRectTable1[_saveLoadCurrentSlot];
+	const Common::Rect *r = &buttonsRectTable1[_saveLoadCurrentSlot % 10];
 	Graphics::fillRect(_offscreenBuffer, 640, r->left, r->top, r->width(), r->height(), 0xF8);
 
 	int y = r->top;
@@ -292,7 +292,6 @@
 				button = -1;
 			}
 			if (mode == kSaveGameState) {
-				_saveLoadCurrentPage = (_saveLoadCurrentSlot / 10) * 10;
 				if (_saveLoadCurrentDescriptionLen != descriptionLen) {
 					descriptionLen = _saveLoadCurrentDescriptionLen;
 					ui_drawCurrentGameStateDescription();


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