aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sfx
diff options
context:
space:
mode:
authorFilippos Karapetis2009-11-04 16:11:46 +0000
committerFilippos Karapetis2009-11-04 16:11:46 +0000
commit5910e32b36d99a7b417f58a98b6399815aff724b (patch)
tree4011c1b4b507e4680a2c55d4f34562efce661567 /engines/sci/sfx
parenta53fda32bb0a90dc945a2e921513e8cd3aaa774e (diff)
downloadscummvm-rg350-5910e32b36d99a7b417f58a98b6399815aff724b.tar.gz
scummvm-rg350-5910e32b36d99a7b417f58a98b6399815aff724b.tar.bz2
scummvm-rg350-5910e32b36d99a7b417f58a98b6399815aff724b.zip
Applied patch #2891232 - "SCI sfx: Let each SongIterator remap its own channels"
svn-id: r45672
Diffstat (limited to 'engines/sci/sfx')
-rw-r--r--engines/sci/sfx/iterator.cpp46
-rw-r--r--engines/sci/sfx/iterator.h2
-rw-r--r--engines/sci/sfx/iterator_internal.h4
3 files changed, 25 insertions, 27 deletions
diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp
index 69fedbd456..53d4de23c5 100644
--- a/engines/sci/sfx/iterator.cpp
+++ b/engines/sci/sfx/iterator.cpp
@@ -376,6 +376,18 @@ int BaseSongIterator::parseMidiCommand(byte *buf, int *result, SongIteratorChann
if ((cmd & 0xf0) == 0x90) /* note on? */
channel->notes_played++;
+#if 0
+ /* Perform remapping, if neccessary */
+ if (cmd != SCI_MIDI_SET_SIGNAL
+ && cmd < 0xf0) { /* Not a generic command */
+ int chan = cmd & 0xf;
+ int op = cmd & 0xf0;
+
+ chan = channel_remap[chan];
+ buf[0] = chan | op;
+ }
+#endif
+
/* Process as normal MIDI operation */
return 0;
}
@@ -1364,12 +1376,6 @@ TeeSongIterator::TeeSongIterator(SongIterator *left, SongIterator *right) {
_children[TEE_LEFT].it = left;
_children[TEE_RIGHT].it = right;
- // By default, don't remap
- for (i = 0; i < 16; i++) {
- _children[TEE_LEFT].channel_remap[i] = i;
- _children[TEE_RIGHT].channel_remap[i] = i;
- }
-
/* Default to lhs channels */
channel_mask = left->channel_mask;
for (i = 0; i < 16; i++)
@@ -1386,7 +1392,7 @@ TeeSongIterator::TeeSongIterator(SongIterator *left, SongIterator *right) {
//warning("[songit-tee <%08lx,%08lx>] Could not remap right channel #%d: Out of channels",
// left->ID, right->ID, i);
} else {
- _children[TEE_RIGHT].channel_remap[i] = firstfree;
+ _children[TEE_RIGHT].it->channel_remap[i] = firstfree;
channel_mask |= (1 << firstfree);
}
@@ -1402,7 +1408,7 @@ TeeSongIterator::TeeSongIterator(SongIterator *left, SongIterator *right) {
for (c = 0 ; c < 2; c++)
for (i = 0 ; i < 16; i++)
fprintf(stderr, " map [%d][%d] -> %d\n",
- c, i, _children[c].channel_remap[i]);
+ c, i, _children[c].it->channel_remap[i]);
}
#endif
@@ -1514,21 +1520,6 @@ int TeeSongIterator::nextCommand(byte *buf, int *result) {
fprintf(stderr, "\tl:%d / r:%d / chose %d\n",
_children[TEE_LEFT].retval, _children[TEE_RIGHT].retval, retid);
#endif
-#if 0
- if (_children[retid].retval == 0) {
- /* Perform remapping, if neccessary */
- byte *buf = _children[retid].buf;
- if (*buf != SCI_MIDI_SET_SIGNAL
- && *buf < 0xf0) { /* Not a generic command */
- int chan = *buf & 0xf;
- int op = *buf & 0xf0;
-
- chan = _children[retid].channel_remap[chan];
-
- *buf = chan | op;
- }
- }
-#endif
/* Adjust delta times */
if (_children[retid].retval > 0
@@ -1660,6 +1651,8 @@ int songit_next(SongIterator **it, byte *buf, int *result, int mask) {
SongIterator *old_it = *it;
*it = new CleanupSongIterator(channel_mask);
+ for(uint i = 0; i < MIDI_CHANNELS; i++)
+ (*it)->channel_remap[i] = old_it->channel_remap[i];
song_iterator_transfer_death_listeners(*it, old_it);
if (mask & IT_READER_MAY_FREE)
delete old_it;
@@ -1691,6 +1684,10 @@ SongIterator::SongIterator() {
fade.action = FADE_ACTION_NONE;
priority = 0;
memset(_deathListeners, 0, sizeof(_deathListeners));
+
+ // By default, don't remap
+ for (uint i = 0; i < 16; i++)
+ channel_remap[i] = i;
}
SongIterator::SongIterator(const SongIterator &si) {
@@ -1699,6 +1696,9 @@ SongIterator::SongIterator(const SongIterator &si) {
fade = si.fade;
priority = si.priority;
memset(_deathListeners, 0, sizeof(_deathListeners));
+
+ for (uint i = 0; i < 16; i++)
+ channel_remap[i] = si.channel_remap[i];
}
diff --git a/engines/sci/sfx/iterator.h b/engines/sci/sfx/iterator.h
index 4e6df367c9..d66faa1b2d 100644
--- a/engines/sci/sfx/iterator.h
+++ b/engines/sci/sfx/iterator.h
@@ -29,6 +29,7 @@
#define SCI_SFX_SFX_ITERATOR_H
#include "sci/sfx/sfx_pcm.h"
+#include "sci/sfx/sci_midi.h"
namespace Audio {
class AudioStream;
@@ -156,6 +157,7 @@ public:
/* See songit_* for the constructor and non-virtual member functions */
+ byte channel_remap[MIDI_CHANNELS]; ///< Remapping for channels
public:
SongIterator();
diff --git a/engines/sci/sfx/iterator_internal.h b/engines/sci/sfx/iterator_internal.h
index faf06726b0..15b15ed308 100644
--- a/engines/sci/sfx/iterator_internal.h
+++ b/engines/sci/sfx/iterator_internal.h
@@ -256,10 +256,6 @@ public:
byte buf[4];
int result;
int retval;
-
- /* Remapping for channels */
- byte channel_remap[MIDI_CHANNELS];
-
} _children[2];
public: