aboutsummaryrefslogtreecommitdiff
path: root/engines/cge
diff options
context:
space:
mode:
authorStrangerke2011-09-06 19:56:47 +0200
committerStrangerke2011-09-06 19:56:47 +0200
commite46c613e9a06828ede0001b8e4e7db1bef65d433 (patch)
tree451994e84dde79e2463d7717f704fb44fff6ace0 /engines/cge
parent5bad1a7c7fc14caaa8af7d51addc70c94804e435 (diff)
downloadscummvm-rg350-e46c613e9a06828ede0001b8e4e7db1bef65d433.tar.gz
scummvm-rg350-e46c613e9a06828ede0001b8e4e7db1bef65d433.tar.bz2
scummvm-rg350-e46c613e9a06828ede0001b8e4e7db1bef65d433.zip
CGE: Remove 'count' static variable from snail
Thanks LordHoto for pointing it out
Diffstat (limited to 'engines/cge')
-rw-r--r--engines/cge/cge.h2
-rw-r--r--engines/cge/snail.cpp20
-rw-r--r--engines/cge/sound.cpp14
-rw-r--r--engines/cge/sound.h5
4 files changed, 28 insertions, 13 deletions
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index 1d38b6a59b..40ea682ebc 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -249,7 +249,7 @@ public:
void snSetY0(int cav, int y0);
void snSetZ(Sprite *spr, int z);
void snSlave(Sprite *spr, int ref);
- void snSound(Sprite *spr, int wav, int cnt);
+ void snSound(Sprite *spr, int wav);
void snSwap(Sprite *spr, int xref);
void snTNext(Sprite *spr, int p);
void snTrans(Sprite *spr, int trans);
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index b1fc7629b0..ccdcac3578 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -771,13 +771,15 @@ void CGEEngine::snKill(Sprite *spr) {
}
}
-void CGEEngine::snSound(Sprite *spr, int wav, int cnt) {
- debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt);
+void CGEEngine::snSound(Sprite *spr, int wav) {
+ debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d)", wav);
if (wav == -1)
_sound->stop();
else
- _sound->play((*_fx)[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt);
+ _sound->play((*_fx)[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8);
+
+ _sound->setRepeat(1);
}
void CGEEngine::snKeep(Sprite *spr, int stp) {
@@ -785,7 +787,10 @@ void CGEEngine::snKeep(Sprite *spr, int stp) {
selectPocket(-1);
if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) {
- snSound(spr, 3, 1);
+ int16 oldRepeat = _sound->getRepeat();
+ _sound->setRepeat(1);
+ snSound(spr, 3);
+ _sound->setRepeat(oldRepeat);
_pocket[_pocPtr] = spr;
spr->_cave = 0;
spr->_flags._kept = true;
@@ -926,8 +931,6 @@ void CGEEngine::snMouse(bool on) {
}
void Snail::runCom() {
- static int count = 1;
-
if (_busy)
return;
@@ -1122,11 +1125,10 @@ void Snail::runCom() {
_vm->snReach(spr, snc->_val);
break;
case kSnSound:
- _vm->snSound(spr, snc->_val, count);
- count = 1;
+ _vm->snSound(spr, snc->_val);
break;
case kSnCount:
- count = snc->_val;
+ _sound->setRepeat(snc->_val);
break;
case kSnExec:
switch (snc->_cbType) {
diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp
index 7a080f3405..340a6c644c 100644
--- a/engines/cge/sound.cpp
+++ b/engines/cge/sound.cpp
@@ -37,6 +37,7 @@ namespace CGE {
Sound::Sound(CGEEngine *vm) : _vm(vm) {
_audioStream = NULL;
+ _soundRepeatCount = 1;
open();
}
@@ -49,16 +50,25 @@ void Sound::close() {
}
void Sound::open() {
+ setRepeat(1);
play((*_fx)[30000], 8);
}
-void Sound::play(DataCk *wav, int pan, int cnt) {
+void Sound::setRepeat(int16 count) {
+ _soundRepeatCount = count;
+}
+
+int16 Sound::getRepeat() {
+ return _soundRepeatCount;
+}
+
+void Sound::play(DataCk *wav, int pan) {
if (wav) {
stop();
_smpinf._saddr = &*(wav->addr());
_smpinf._slen = (uint16)wav->size();
_smpinf._span = pan;
- _smpinf._sflag = cnt;
+ _smpinf._sflag = getRepeat();
sndDigiStart(&_smpinf);
}
}
diff --git a/engines/cge/sound.h b/engines/cge/sound.h
index 1474b78c28..7cb4f33969 100644
--- a/engines/cge/sound.h
+++ b/engines/cge/sound.h
@@ -66,9 +66,12 @@ public:
~Sound();
void open();
void close();
- void play(DataCk *wav, int pan, int cnt = 1);
+ void play(DataCk *wav, int pan);
+ int16 getRepeat();
+ void setRepeat(int16 count);
void stop();
private:
+ int _soundRepeatCount;
CGEEngine *_vm;
Audio::SoundHandle _soundHandle;
Audio::RewindableAudioStream *_audioStream;