diff options
Diffstat (limited to 'scumm/smush')
-rw-r--r-- | scumm/smush/imuse_channel.cpp | 19 | ||||
-rw-r--r-- | scumm/smush/smush_player.cpp | 56 | ||||
-rw-r--r-- | scumm/smush/smush_player.h | 3 |
3 files changed, 42 insertions, 36 deletions
diff --git a/scumm/smush/imuse_channel.cpp b/scumm/smush/imuse_channel.cpp index c599191da1..2b14390393 100644 --- a/scumm/smush/imuse_channel.cpp +++ b/scumm/smush/imuse_channel.cpp @@ -52,17 +52,16 @@ bool ImuseChannel::isTerminated() const { } bool ImuseChannel::setParameters(int32 nb, int32 size, int32 flags, int32 unk1) { - // flags: 0 - 8 bits - // values: - // 1 - Voice - // 2 - Background music - // 0, 3-511 - SFX and volume - // FIXME: this should be better - if ((flags != 1) && (flags != 2) && ((flags / 4) != 0)) { - _volume = 300 - ((flags / 8) * 4); - } - else { + if ((flags == 1) || (flags == 2) || (flags == 3)) { _volume = 127; + } else if ((flags >= 100) && (flags <= 163)) { + _volume = flags * 2 - 200; + } else if ((flags >= 200) && (flags <= 263)) { + _volume = flags * 2 - 400; + } else if ((flags >= 300) && (flags <= 363)) { + _volume = flags * 2 - 600; + } else { + error("ImuseChannel::setParameters(): bad flags: %d", flags); } return true; } diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index 2dcaa75334..36396eb515 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -337,11 +337,9 @@ void SmushPlayer::handleSoundFrame(Chunk &b) { int32 flags = b.getWord(); int32 vol = b.getByte(); int32 bal = b.getChar(); -#ifdef DEBUG if (index == 0) { debug(5, "track_id == %d, max_frames == %d, %d, %d, %d", track_id, max_frames, flags, vol, bal); } -#endif int32 size = b.getSize() - 10; handleSoundBuffer(track_id, index, max_frames, flags, vol, bal, b, size); } @@ -371,28 +369,11 @@ void SmushPlayer::handleFetch(Chunk &b) { } } -void SmushPlayer::handleImuseBuffer(int32 track_id, int32 index, int32 nbframes, int32 size, int32 unk1, int32 track_flags, Chunk &b, int32 bsize) { - int32 track = (track_flags << 16) | track_id; - debug(6, "SmushPlayer::handleImuseBuffer(%d, %d)", track_id, index); - - SmushChannel *c = _smixer->findChannel(track); - if (c == 0) { - c = new ImuseChannel(track, _soundFrequency); - _smixer->addChannel(c); - } - if (index == 0) - c->setParameters(nbframes, size, track_flags, unk1); - else - c->checkParameters(index, nbframes, size, track_flags, unk1); - c->appendData(b, bsize); -} - -void SmushPlayer::handleImuseAction(Chunk &b) { +void SmushPlayer::handleIACT(Chunk &b) { checkBlock(b, TYPE_IACT, 8); debug(6, "SmushPlayer::handleImuseAction()"); - int code; - code = b.getWord(); + int code = b.getWord(); int flags = b.getWord(); int unknown = b.getShort(); int track_flags = b.getWord(); @@ -407,7 +388,34 @@ void SmushPlayer::handleImuseAction(Chunk &b) { int32 bsize = b.getSize() - 18; if (g_scumm->_gameId != GID_CMI) { - handleImuseBuffer(track_id, index, nbframes, size, unknown, track_flags, b, bsize); + int32 track = track_id; + if (track_flags == 1) { + track = track_id + 100; + } else if (track_flags == 2) { + track = track_id + 200; + } else if (track_flags == 3) { + track = track_id + 300; + } else if ((track_flags >= 100) && (track_flags <= 163)) { + track = track_id + 400; + } else if ((track_flags >= 200) && (track_flags <= 263)) { + track = track_id + 500; + } else if ((track_flags >= 300) && (track_flags <= 363)) { + track = track_id + 600; + } else { + error("ImuseChannel::handleIACT(): bad track_flags: %d", track_flags); + } + debug(6, "SmushPlayer::handleIACT(): %d, %d, %d", track, index, track_flags); + + SmushChannel *c = _smixer->findChannel(track); + if (c == 0) { + c = new ImuseChannel(track, _soundFrequency); + _smixer->addChannel(c); + } + if (index == 0) + c->setParameters(nbframes, size, track_flags, unknown); + else + c->checkParameters(index, nbframes, size, track_flags, unknown); + c->appendData(b, bsize); } else { byte output_data[4096]; byte *src = (byte *)malloc(bsize); @@ -769,9 +777,9 @@ void SmushPlayer::handleFrame(Chunk &b) { if (_insanity) _scumm->_insane->procIACT(_dst, 0, 0, 0, *sub, 0, 0); else - handleImuseAction(*sub); + handleIACT(*sub); #else - handleImuseAction(*sub); + handleIACT(*sub); #endif break; case TYPE_STOR: diff --git a/scumm/smush/smush_player.h b/scumm/smush/smush_player.h index 7d1c5dbcac..b119251552 100644 --- a/scumm/smush/smush_player.h +++ b/scumm/smush/smush_player.h @@ -95,12 +95,11 @@ private: void handleNewPalette(Chunk &); void handleFrameObject(Chunk &); void handleSoundBuffer(int32, int32, int32, int32, int32, int32, Chunk &, int32); - void handleImuseBuffer(int32, int32, int32, int32, int32, int32, Chunk &, int32); void handleSoundFrame(Chunk &); void handleSkip(Chunk &); void handleStore(Chunk &); void handleFetch(Chunk &); - void handleImuseAction(Chunk &); + void handleIACT(Chunk &); void handleTextResource(Chunk &); void handleDeltaPalette(Chunk &); void readPalette(byte *, Chunk &); |