[Scummvm-cvs-logs] SF.net SVN: scummvm: [26848] scummvm/trunk/engines/agos

kirben at users.sourceforge.net kirben at users.sourceforge.net
Wed May 16 07:57:27 CEST 2007


Revision: 26848
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26848&view=rev
Author:   kirben
Date:     2007-05-15 22:57:26 -0700 (Tue, 15 May 2007)

Log Message:
-----------
Add idle code for DIMP.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/event.cpp
    scummvm/trunk/engines/agos/res_snd.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2007-05-15 20:07:07 UTC (rev 26847)
+++ scummvm/trunk/engines/agos/agos.cpp	2007-05-16 05:57:26 UTC (rev 26848)
@@ -349,6 +349,14 @@
 	_timer5 = 0;
 	_timer4 = 0;
 
+ 	_iconToggleCount = 0;
+ 	_voiceCount = 0;
+ 
+	_lastTickCount = 0;
+	_thisTickCount = 0;
+	_startSecondCount = 0;
+	_tSecondCount = 0;
+
 	_frameCount = 0;
 
 	_zoneNumber = 0;

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-05-15 20:07:07 UTC (rev 26847)
+++ scummvm/trunk/engines/agos/agos.h	2007-05-16 05:57:26 UTC (rev 26848)
@@ -421,6 +421,10 @@
 
 	uint16 _syncCount, _timer5, _timer4;
 
+	int16 _iconToggleCount, _voiceCount;
+	uint32 _lastTickCount, _thisTickCount;
+	uint32 _startSecondCount, _tSecondCount;
+
 	uint16 _frameCount;
 
 	uint16 _zoneNumber;
@@ -564,6 +568,8 @@
 	void loadSound(uint sound, int pan, int vol, uint type);
 	void loadVoice(uint speechId);
 
+	void loadSoundFile(const char *filename);
+
 	int getUserFlag(Item *item, int a);
 	int getUserFlag1(Item *item, int a);
 	int getUserItem(Item *item, int n);
@@ -1121,6 +1127,7 @@
 	void openGameFile();
 	void readGameFile(void *dst, uint32 offs, uint32 size);
 
+	void dimp_idle();
 	void timer_callback();
 	virtual void timer_proc1();
 

Modified: scummvm/trunk/engines/agos/event.cpp
===================================================================
--- scummvm/trunk/engines/agos/event.cpp	2007-05-15 20:07:07 UTC (rev 26847)
+++ scummvm/trunk/engines/agos/event.cpp	2007-05-16 05:57:26 UTC (rev 26848)
@@ -42,6 +42,10 @@
 
 	time(&cur_time);
 
+	if (getGameId() == GID_DIMP) {
+		timeout /= 2;
+	}
+
 	te->time = cur_time + timeout - _gameStoppedClock;
 	if (getGameType() == GType_FF && _clockStopped)
 		te->time -= ((uint32)time(NULL) - _clockStopped);
@@ -440,11 +444,26 @@
 }
 
 void AGOSEngine::timer_callback() {
+	// FIXME: _timer5 is never set
 	if (_timer5) {
 		_syncFlag2 = true;
 		_timer5--;
 	} else {
-		timer_proc1();
+		if (getGameId() == GID_DIMP) {
+			_thisTickCount = _system->getMillis();
+			if (_thisTickCount < _lastTickCount)
+				_lastTickCount = 0;
+
+			if ((_thisTickCount - _lastTickCount) <= 35)
+				return;
+
+			_lastTickCount = _thisTickCount;
+
+			timer_proc1();
+			dimp_idle();
+		} else {
+			timer_proc1();
+		}
 	}
 }
 
@@ -536,4 +555,86 @@
 	_lockWord &= ~2;
 }
 
+void AGOSEngine::dimp_idle() {
+	int z, n;
+
+	_iconToggleCount++;
+	if (_iconToggleCount == 30) {
+		if ((_variableArray[110] < 3) || (_variableArray[111] < 3) || (_variableArray[112] < 3)) {
+			_voiceCount++;
+			if (_voiceCount == 50) {
+				if (!getBitFlag(14) && !getBitFlag(11) && !getBitFlag(13)) {
+					loadSoundFile("Whistle.WAV");
+					z = 0;
+					while (z == 0) {
+						n = _rnd.getRandomNumber(2);
+						switch (n) {
+							case(0): 
+								if (_variableArray[110] > 2)
+									break;
+								n = _rnd.getRandomNumber(6);
+								switch(n) {
+									case(0): loadSoundFile("And01.wav");break;
+									case(1): loadSoundFile("And02.wav");break;
+									case(2): loadSoundFile("And03.wav");break;
+									case(3): loadSoundFile("And04.wav");break;
+									case(4): loadSoundFile("And05.wav");break;
+									case(5): loadSoundFile("And06.wav");break;
+									case(6): loadSoundFile("And07.wav");break;
+								}
+								z = 1;
+								break;
+							case(1):
+								if (_variableArray[111] > 2)
+									break;
+								n = _rnd.getRandomNumber(6);
+								switch(n) {
+									case(0): loadSoundFile("And08.wav");break;
+									case(1): loadSoundFile("And09.wav");break;
+									case(2): loadSoundFile("And0a.wav");break;
+									case(3): loadSoundFile("And0b.wav");break;
+									case(4): loadSoundFile("And0c.wav");break;
+									case(5): loadSoundFile("And0d.wav");break;
+									case(6): loadSoundFile("And0e.wav");break;
+								}
+								z = 1;
+								break;
+							case(2):
+								if (_variableArray[112] > 2)
+									break;
+								n = _rnd.getRandomNumber(4);
+								switch(n) {
+									case(0): loadSoundFile("And0f.wav");break;
+									case(1): loadSoundFile("And0g.wav");break;
+									case(2): loadSoundFile("And0h.wav");break;
+									case(3): loadSoundFile("And0i.wav");break;
+									case(4): loadSoundFile("And0j.wav");break;
+								}
+								z = 1;
+								break;
+						}
+					}
+				}
+				_voiceCount = 0;
+			}
+		} else {
+			_voiceCount = 48;
+		}
+		_iconToggleCount = 0;
+	}
+
+	if (_variableArray[121] == 0) {
+		_variableArray[121]++;
+		_startSecondCount = _lastTickCount;
+	}
+	if (((_lastTickCount - _startSecondCount) / 1000) != _tSecondCount) {
+		if (_startSecondCount != 0) {
+			uint32 x = (_variableArray[123] * 65536) + _variableArray[122] + ((_lastTickCount - _startSecondCount) / 1000) - _tSecondCount;
+			_variableArray[122] = (uint16)(x % 65536);
+			_variableArray[123] = (uint16)(x / 65536);
+			_tSecondCount = (_lastTickCount - _startSecondCount) / 1000;
+		}
+	}
+}
+
 } // End of namespace AGOS

Modified: scummvm/trunk/engines/agos/res_snd.cpp
===================================================================
--- scummvm/trunk/engines/agos/res_snd.cpp	2007-05-15 20:07:07 UTC (rev 26847)
+++ scummvm/trunk/engines/agos/res_snd.cpp	2007-05-16 05:57:26 UTC (rev 26848)
@@ -381,6 +381,22 @@
 };
 
 
+void AGOSEngine::loadSoundFile(const char* filename) {
+	File in;
+
+	in.open(filename);
+	if (in.isOpen() == false)
+		error("loadSound: Can't load %s", filename);
+
+	uint32 dstSize = in.size();
+	byte *dst = (byte *)malloc(dstSize);
+	if (in.read(dst, dstSize) != dstSize)
+		error("loadSound: Read failed");
+	in.close();
+
+	_sound->playSfxData(dst, 0, 0, 0);
+}
+
 void AGOSEngine::loadSound(uint sound, int pan, int vol, uint type) {
 	byte *dst;
 


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