aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNorbert Lange2009-06-14 19:40:24 +0000
committerNorbert Lange2009-06-14 19:40:24 +0000
commit1fcd6bff086585adec47ccdefdd9efce0ebea27a (patch)
tree7730e985c7bc3fdb3de3a4fbd3d8d2f640f4030e /engines
parent32d31928eef8365551411c82fb101b827b25453e (diff)
downloadscummvm-rg350-1fcd6bff086585adec47ccdefdd9efce0ebea27a.tar.gz
scummvm-rg350-1fcd6bff086585adec47ccdefdd9efce0ebea27a.tar.bz2
scummvm-rg350-1fcd6bff086585adec47ccdefdd9efce0ebea27a.zip
player_v4a:
Made musictimer work a bit better, merged the 2 tables into 1 svn-id: r41526
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/player_v4a.cpp41
-rw-r--r--engines/scumm/player_v4a.h3
2 files changed, 23 insertions, 21 deletions
diff --git a/engines/scumm/player_v4a.cpp b/engines/scumm/player_v4a.cpp
index 69c071e08e..ea3c2c9eb9 100644
--- a/engines/scumm/player_v4a.cpp
+++ b/engines/scumm/player_v4a.cpp
@@ -48,12 +48,12 @@ bool Player_V4A::init() {
if (mdatExists && sampleExists) {
Audio::Tfmx *play = new Audio::Tfmx(_mixer->getOutputRate(), true);
- if (play->load(fileMdat, fileSample))
+ if (play->load(fileMdat, fileSample)) {
_tfmxPlay = play;
- else
+ } else
delete play;
}
- return true;
+ return _tfmxPlay != 0;
}
Player_V4A::~Player_V4A() {
@@ -98,26 +98,23 @@ void Player_V4A::startSound(int nr) {
debug("%s", buf);
- static const uint8 monkeyCommands[52] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 18, 17,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 16, 34, 0, 1, 2, 3, 7, 8, 10, 11, 4, 5, 14, 15, 12,
- 6, 13, 9, 19 };
-
- static const uint8 monkeyTypes[52] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0 };
+ static const int8 monkeyCommands[52] = {
+ -1, -2, -3, -4, -5, -6, -7, -8,
+ -9, -10, -11, -12, -13, -14, 18, 17,
+ -17, -18, -19, -20, -21, -22, -23, -24,
+ -25, -26, -27, -28, -29, -30, -31, -32,
+ -33, 16, -35, 0, 1, 2, 3, 7,
+ 8, 10, 11, 4, 5, 14, 15, 12,
+ 6, 13, 9, 19
+ };
int val = ptr[9];
- if (val < 0 || val >= ARRAYSIZE(monkeyTypes))
+ if (val < 0 || val >= ARRAYSIZE(monkeyCommands))
debug("Tfmx: illegal Songnumber %i", val);
- bool soundFX = monkeyTypes[val] == 1;
int index = monkeyCommands[val];
- if (soundFX) {
+ if (index < 0) {
// SoundFX
- debug("Tfmx: Soundpattern %i", index);
+ debug("Tfmx: Soundpattern %i", -index - 1);
} else {
// Song
@@ -127,6 +124,7 @@ void Player_V4A::startSound(int nr) {
_tfmxPlay->doSong(index);
_musicId = nr;
+ _musicLastTicks = _tfmxPlay->getTicks();
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxPlay, -1, Audio::Mixer::kMaxChannelVolume, 0, false, false);
}
@@ -134,9 +132,10 @@ void Player_V4A::startSound(int nr) {
int Player_V4A::getMusicTimer() const {
- static int t = 0;
- t += 300;
- return t;
+ if (_musicId) {
+ return (_tfmxPlay->getTicks() - _musicLastTicks) / 25;
+ } else
+ return 0;
}
int Player_V4A::getSoundStatus(int nr) const {
diff --git a/engines/scumm/player_v4a.h b/engines/scumm/player_v4a.h
index 4eb881c656..6f7f6bc99f 100644
--- a/engines/scumm/player_v4a.h
+++ b/engines/scumm/player_v4a.h
@@ -54,10 +54,13 @@ public:
private:
ScummEngine *_vm;
+
Audio::Tfmx *_tfmxPlay;
Audio::Mixer *_mixer;
Audio::SoundHandle _musicHandle;
+ int _musicLastTicks;
+
enum {V4A_MAXSFX = 8};
struct SoundSlot {