aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2007-05-16 05:57:26 +0000
committerTravis Howell2007-05-16 05:57:26 +0000
commitbdb18c60d8c582ac8bd555ac8d573a3f8de9e1a4 (patch)
treea33d9914dcc82d7fb072532bb2a81cad184b1190
parentada3424d8a88b905ab153d84a6f1de12cd4b8e59 (diff)
downloadscummvm-rg350-bdb18c60d8c582ac8bd555ac8d573a3f8de9e1a4.tar.gz
scummvm-rg350-bdb18c60d8c582ac8bd555ac8d573a3f8de9e1a4.tar.bz2
scummvm-rg350-bdb18c60d8c582ac8bd555ac8d573a3f8de9e1a4.zip
Add idle code for DIMP.
svn-id: r26848
-rw-r--r--engines/agos/agos.cpp8
-rw-r--r--engines/agos/agos.h7
-rw-r--r--engines/agos/event.cpp103
-rw-r--r--engines/agos/res_snd.cpp16
4 files changed, 133 insertions, 1 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index d48503c443..b77d1d0b01 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -349,6 +349,14 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_timer5 = 0;
_timer4 = 0;
+ _iconToggleCount = 0;
+ _voiceCount = 0;
+
+ _lastTickCount = 0;
+ _thisTickCount = 0;
+ _startSecondCount = 0;
+ _tSecondCount = 0;
+
_frameCount = 0;
_zoneNumber = 0;
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index f2445d3680..d865719e39 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -421,6 +421,10 @@ protected:
uint16 _syncCount, _timer5, _timer4;
+ int16 _iconToggleCount, _voiceCount;
+ uint32 _lastTickCount, _thisTickCount;
+ uint32 _startSecondCount, _tSecondCount;
+
uint16 _frameCount;
uint16 _zoneNumber;
@@ -564,6 +568,8 @@ protected:
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 @@ protected:
void openGameFile();
void readGameFile(void *dst, uint32 offs, uint32 size);
+ void dimp_idle();
void timer_callback();
virtual void timer_proc1();
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index b2636d2a48..3297e1182e 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -42,6 +42,10 @@ void AGOSEngine::addTimeEvent(uint timeout, uint subroutine_id) {
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::delay(uint amount) {
}
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 @@ void AGOSEngine::timer_proc1() {
_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
diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp
index 9dd869915d..41c3dce075 100644
--- a/engines/agos/res_snd.cpp
+++ b/engines/agos/res_snd.cpp
@@ -381,6 +381,22 @@ static const char *dimpSoundList[32] = {
};
+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;