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

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun Dec 10 01:41:47 CET 2006


Revision: 24830
          http://scummvm.svn.sourceforge.net/scummvm/?rev=24830&view=rev
Author:   cyx
Date:     2006-12-09 16:41:45 -0800 (Sat, 09 Dec 2006)

Log Message:
-----------
cleanup (added a few more constants, renamed some opcodes) and reverted my previous change to op_sleep.

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

Modified: scummvm/trunk/engines/touche/opcodes.cpp
===================================================================
--- scummvm/trunk/engines/touche/opcodes.cpp	2006-12-09 19:23:06 UTC (rev 24829)
+++ scummvm/trunk/engines/touche/opcodes.cpp	2006-12-10 00:41:45 UTC (rev 24830)
@@ -175,7 +175,7 @@
 		&ToucheEngine::op_sleep,
 		0,
 		/* 0x74 */
-		&ToucheEngine::op_delay,
+		&ToucheEngine::op_setKeyCharDelay,
 		&ToucheEngine::op_lockHitBox,
 		&ToucheEngine::op_removeItemFromInventory,
 		&ToucheEngine::op_unlockHitBox,
@@ -192,7 +192,7 @@
 		/* 0x80 */
 		&ToucheEngine::op_unsetKeyCharFlags,
 		&ToucheEngine::op_drawSpriteOnBackdrop,
-		&ToucheEngine::op_loadVoice,
+		&ToucheEngine::op_loadSpeechSegment,
 		0,
 		/* 0x84 */
 		&ToucheEngine::op_startPaletteFadeIn,
@@ -868,12 +868,18 @@
 
 void ToucheEngine::op_sleep() {
 	debugC(9, kDebugOpcodes, "ToucheEngine::op_sleep()");
-	int16 cycles = _script.readNextWord();
-	_sleepCycles = cycles * 2;
+	// this should probably be turned into a no-op/debug-op...
+	int cycles = _script.readNextWord() * 2;
+	if (!_fastMode) {
+		for (; cycles > 0; --cycles) {
+			_system->delayMillis(kCycleDelay);
+			_system->updateScreen();
+		}
+	}
 }
 
-void ToucheEngine::op_delay() {
-	debugC(9, kDebugOpcodes, "ToucheEngine::op_delay()");
+void ToucheEngine::op_setKeyCharDelay() {
+	debugC(9, kDebugOpcodes, "ToucheEngine::op_setKeyCharDelay()");
 	int16 delay = _script.readNextWord();
 	_keyCharsTable[_script.keyCharNum].delay = delay;
 	_script.quitFlag = 3;
@@ -927,8 +933,8 @@
 	_keyCharsTable[keyChar].flags &= ~flags;
 }
 
-void ToucheEngine::op_loadVoice() {
-	debugC(9, kDebugOpcodes, "ToucheEngine::op_loadVoice()");
+void ToucheEngine::op_loadSpeechSegment() {
+	debugC(9, kDebugOpcodes, "ToucheEngine::op_loadSpeechSegment()");
 	int16 num = _script.readNextWord();
 	res_loadSpeech(num);
 }

Modified: scummvm/trunk/engines/touche/resource.cpp
===================================================================
--- scummvm/trunk/engines/touche/resource.cpp	2006-12-09 19:23:06 UTC (rev 24829)
+++ scummvm/trunk/engines/touche/resource.cpp	2006-12-10 00:41:45 UTC (rev 24830)
@@ -120,12 +120,12 @@
 		error("Unable to allocate memory for program data");
 	}
 
-	_mouseData = (uint8 *)malloc(58 * 42);
+	_mouseData = (uint8 *)malloc(kCursorWidth * kCursorHeight);
 	if (!_mouseData) {
 		error("Unable to allocate memory for mouse data");
 	}
 
-	_iconData = (uint8 *)malloc(58 * 42);
+	_iconData = (uint8 *)malloc(kIconWidth * kIconHeight);
 	if (!_iconData) {
 		error("Unable to allocate memory for object data");
 	}

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2006-12-09 19:23:06 UTC (rev 24829)
+++ scummvm/trunk/engines/touche/touche.cpp	2006-12-10 00:41:45 UTC (rev 24830)
@@ -245,25 +245,18 @@
 	_inp_rightMouseButtonPressed = false;
 	showCursor(_newEpisodeNum != kStartupEpisode);
 
-	const int cycleDelay = 1000 / (1193180 / 32768);
 	uint32 frameTimeStamp = _system->getMillis();
-	_sleepCycles = 0;
-	uint32 cycleCounter = 0;
-	while (_flagsTable[611] == 0) {
-		if (_sleepCycles) {
-			--_sleepCycles;
-		} else {
-			if ((cycleCounter % 3) == 0) {
-				runCycle();
-			}
-			if ((cycleCounter % 2) == 0) {
-				fadePaletteFromFlags();
-			}
- 			++cycleCounter;
- 		}
+	for (uint32 cycleCounter = 0; _flagsTable[611] == 0; ++cycleCounter) {
+		if ((cycleCounter % 3) == 0) {
+			runCycle();
+		}
+		if ((cycleCounter % 2) == 0) {
+			fadePaletteFromFlags();
+		}
+
 		_system->updateScreen();
 		int delay = _system->getMillis() - frameTimeStamp;
-		delay = (_fastMode ? 10 : cycleDelay) - delay;
+		delay = (_fastMode ? 10 : kCycleDelay) - delay;
 		if (delay < 1) {
 			delay = 1;
 		}
@@ -787,8 +780,8 @@
 
 	// horizontal scrolling
 	int prevRoomDx = _flagsTable[614];
-	if (key->xPos > prevRoomDx + 480) {
-		int dx = key->xPos - (prevRoomDx + 480);
+	if (key->xPos > prevRoomDx + kScreenWidth - 160) {
+		int dx = key->xPos - (prevRoomDx + kScreenWidth - 160);
 		prevRoomDx += dx;
 	} else if (key->xPos < prevRoomDx + 160) {
 		int dx = prevRoomDx + 160 - key->xPos;
@@ -822,8 +815,8 @@
 void ToucheEngine::drawIcon(int x, int y, int num) {
 	res_loadImage(num, _iconData);
 	Graphics::copyRect(_offscreenBuffer, kScreenWidth, x, y,
-	  _iconData, 58, 0, 0,
-	  58, 42,
+	  _iconData, kIconWidth, 0, 0,
+	  kIconWidth, kIconHeight,
 	  Graphics::kTransparent);
 }
 
@@ -1394,10 +1387,8 @@
 void ToucheEngine::setCursor(int num) {
 	debugC(9, kDebugEngine, "ToucheEngine::setCursor(%d)", num);
 	_currentCursorObject = num;
-	const int cursorW = 58;
-	const int cursorH = 42;
 	res_loadImage(num, _mouseData);
-	_system->setMouseCursor(_mouseData, cursorW, cursorH, cursorW / 2, cursorH / 2, 0);
+	_system->setMouseCursor(_mouseData, kCursorWidth, kCursorHeight, kCursorWidth / 2, kCursorHeight / 2, 0);
 }
 
 void ToucheEngine::setDefaultCursor(int num) {
@@ -1745,7 +1736,6 @@
 }
 
 void ToucheEngine::startNewMusic() {
-//	_midiPlayer->setLooping(_flagsTable[619] != 0);
 	if (_newMusicNum != 0 && _newMusicNum != _currentMusicNum) {
 		res_loadMusic(_newMusicNum);
 		_currentMusicNum = _newMusicNum;
@@ -2425,7 +2415,7 @@
 	for (int i = 0; i < 4; ++i) {
 		drawString(214, 42, 328 + i * 16, _conversationChoicesTable[_scrollConversationChoiceOffset + i].msg);
 	}
-	updateScreenArea(0, 320, kScreenWidth, 80);
+	updateScreenArea(0, 320, kScreenWidth, kScreenHeight - 320);
 	_conversationAreaCleared = false;
 }
 
@@ -3111,12 +3101,12 @@
 	if (copyRegion.clip(_screenRect)) {
 		if (fillColor != -1) {
 			Graphics::copyMask(_offscreenBuffer, kScreenWidth, copyRegion.r.left, copyRegion.r.top,
-			  src, 58, copyRegion.srcX, copyRegion.srcY,
+			  src, kIconWidth, copyRegion.srcX, copyRegion.srcY,
 			  copyRegion.r.width(), copyRegion.r.height(),
 			  (uint8)fillColor);
 		} else {
 			Graphics::copyRect(_offscreenBuffer, kScreenWidth, copyRegion.r.left, copyRegion.r.top,
-			  src, 58, copyRegion.srcX, copyRegion.srcY,
+			  src, kIconWidth, copyRegion.srcX, copyRegion.srcY,
 			  copyRegion.r.width(), copyRegion.r.height(),
 			  Graphics::kTransparent);
 		}
@@ -3151,7 +3141,7 @@
 		if (i == 5) {
 			color = -1;
 		}
-		copyAnimationImage(x, y, 58, 42, _iconData, 0, 0, color);
+		copyAnimationImage(x, y, kIconWidth, kIconHeight, _iconData, 0, 0, color);
 		--color;
 		displayRectX1 = MIN(x, displayRectX1);
 		displayRectX2 = MAX(x, displayRectX2);
@@ -3160,7 +3150,7 @@
 		x += dx;
 		y += dy;
 	}
-	anim->displayRect = Common::Rect(displayRectX1, displayRectY1, displayRectX2 + 58, displayRectY2 + 42);
+	anim->displayRect = Common::Rect(displayRectX1, displayRectY1, displayRectX2 + kIconWidth, displayRectY2 + kIconHeight);
 	addToDirtyRect(anim->displayRect);
 }
 

Modified: scummvm/trunk/engines/touche/touche.h
===================================================================
--- scummvm/trunk/engines/touche/touche.h	2006-12-09 19:23:06 UTC (rev 24829)
+++ scummvm/trunk/engines/touche/touche.h	2006-12-10 00:41:45 UTC (rev 24830)
@@ -317,7 +317,12 @@
 	kScreenWidth = 640,
 	kScreenHeight = 400,
 	kRoomHeight = 352,
-	kStartupEpisode = 90
+	kStartupEpisode = 90,
+	kCycleDelay = 1000 / (1193180 / 32768),
+	kIconWidth = 58,
+	kIconHeight = 42,
+	kCursorWidth = 58,
+	kCursorHeight = 42
 };
 
 class MidiPlayer;
@@ -555,14 +560,14 @@
 	void op_setKeyCharTextColor();
 	void op_startMusic();
 	void op_sleep();
-	void op_delay();
+	void op_setKeyCharDelay();
 	void op_lockHitBox();
 	void op_removeItemFromInventory();
 	void op_unlockHitBox();
 	void op_addRoomArea();
 	void op_setKeyCharFlags();
 	void op_unsetKeyCharFlags();
-	void op_loadVoice();
+	void op_loadSpeechSegment();
 	void op_drawSpriteOnBackdrop();
 	void op_startPaletteFadeIn();
 	void op_startPaletteFadeOut();
@@ -614,8 +619,6 @@
 	int _disabledInputCounter;
 	bool _hideInventoryTexts;
 
-	int _sleepCycles;
-
 	bool _displayQuitDialog;
 	int _saveLoadCurrentPage;
 	int _saveLoadCurrentSlot;


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