Ticket #9105: 0002-SCI-sfx-Let-each-SongIterator-remap-its-own-channels.patch

File 0002-SCI-sfx-Let-each-SongIterator-remap-its-own-channels.patch, 4.7 KB (added by SF/lwalkera, 14 years ago)

The patch

  • engines/sci/sfx/iterator.cpp

    From 45458667e64624723a1a2046ac8180e1c50c96e4 Mon Sep 17 00:00:00 2001
    From: Laine Walker-Avina <lwalkera@ieee.org>
    Date: Tue, 3 Nov 2009 03:59:14 -0800
    Subject: [PATCH 2/2] SCI sfx: Let each SongIterator remap its own channels
    
    ---
     engines/sci/sfx/iterator.cpp        |   47 +++++++++++++++++------------------
     engines/sci/sfx/iterator.h          |    2 +
     engines/sci/sfx/iterator_internal.h |    4 ---
     3 files changed, 25 insertions(+), 28 deletions(-)
    
    diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp
    index 69fedbd..4ef4d87 100644
    a b int BaseSongIterator::parseMidiCommand(byte *buf, int *result, SongIteratorChann  
    375375        } else {
    376376                if ((cmd & 0xf0) == 0x90) /* note on? */
    377377                        channel->notes_played++;
     378#if 0
     379                /* Perform remapping, if neccessary */
     380                if (cmd != SCI_MIDI_SET_SIGNAL
     381                                && cmd < 0xf0) { /* Not a generic command */
     382                        int chan = cmd & 0xf;
     383                        int op = cmd & 0xf0;
    378384
     385                        chan = channel_remap[chan];
     386                        buf[0] = chan | op;
     387                }
     388#endif
    379389                /* Process as normal MIDI operation */
    380390                return 0;
    381391        }
    TeeSongIterator::TeeSongIterator(SongIterator *left, SongIterator *right) {  
    13641374        _children[TEE_LEFT].it = left;
    13651375        _children[TEE_RIGHT].it = right;
    13661376
    1367         // By default, don't remap
    1368         for (i = 0; i < 16; i++) {
    1369                 _children[TEE_LEFT].channel_remap[i] = i;
    1370                 _children[TEE_RIGHT].channel_remap[i] = i;
    1371         }
    1372 
    13731377        /* Default to lhs channels */
    13741378        channel_mask = left->channel_mask;
    13751379        for (i = 0; i < 16; i++)
    TeeSongIterator::TeeSongIterator(SongIterator *left, SongIterator *right) {  
    13861390                                //warning("[songit-tee <%08lx,%08lx>] Could not remap right channel #%d: Out of channels",
    13871391                                //        left->ID, right->ID, i);
    13881392                        } else {
    1389                                 _children[TEE_RIGHT].channel_remap[i] = firstfree;
     1393                                _children[TEE_RIGHT].it->channel_remap[i] = firstfree;
    13901394
    13911395                                channel_mask |= (1 << firstfree);
    13921396                        }
    TeeSongIterator::TeeSongIterator(SongIterator *left, SongIterator *right) {  
    14021406                for (c = 0 ; c < 2; c++)
    14031407                        for (i = 0 ; i < 16; i++)
    14041408                                fprintf(stderr, "  map [%d][%d] -> %d\n",
    1405                                         c, i, _children[c].channel_remap[i]);
     1409                                        c, i, _children[c].it->channel_remap[i]);
    14061410        }
    14071411#endif
    14081412
    int TeeSongIterator::nextCommand(byte *buf, int *result) {  
    15141518        fprintf(stderr, "\tl:%d / r:%d / chose %d\n",
    15151519                _children[TEE_LEFT].retval, _children[TEE_RIGHT].retval, retid);
    15161520#endif
    1517 #if 0
    1518         if (_children[retid].retval == 0) {
    1519                 /* Perform remapping, if neccessary */
    1520                 byte *buf = _children[retid].buf;
    1521                 if (*buf != SCI_MIDI_SET_SIGNAL
    1522                         && *buf < 0xf0) { /* Not a generic command */
    1523                         int chan = *buf & 0xf;
    1524                         int op = *buf & 0xf0;
    1525 
    1526                         chan = _children[retid].channel_remap[chan];
    1527 
    1528                         *buf = chan | op;
    1529                 }
    1530         }
    1531 #endif
    1532 
    15331521        /* Adjust delta times */
    15341522        if (_children[retid].retval > 0
    15351523                && _children[1-retid].retval > 0) {
    int songit_next(SongIterator **it, byte *buf, int *result, int mask) {  
    16601648
    16611649                        SongIterator *old_it = *it;
    16621650                        *it = new CleanupSongIterator(channel_mask);
     1651                        for(uint i = 0; i < MIDI_CHANNELS; i++)
     1652                                (*it)->channel_remap[i] = old_it->channel_remap[i];
    16631653                        song_iterator_transfer_death_listeners(*it, old_it);
    16641654                        if (mask & IT_READER_MAY_FREE)
    16651655                                delete old_it;
    SongIterator::SongIterator() {  
    16911681        fade.action = FADE_ACTION_NONE;
    16921682        priority = 0;
    16931683        memset(_deathListeners, 0, sizeof(_deathListeners));
     1684
     1685        // By default, don't remap
     1686        for (uint i = 0; i < 16; i++) {
     1687                channel_remap[i] = i;
     1688        }
    16941689}
    16951690
    16961691SongIterator::SongIterator(const SongIterator &si) {
    SongIterator::SongIterator(const SongIterator &si) {  
    16991694        fade = si.fade;
    17001695        priority = si.priority;
    17011696        memset(_deathListeners, 0, sizeof(_deathListeners));
     1697
     1698        for (uint i = 0; i < 16; i++) {
     1699                channel_remap[i] = si.channel_remap[i];
     1700        }
    17021701}
    17031702
    17041703
  • engines/sci/sfx/iterator.h

    diff --git a/engines/sci/sfx/iterator.h b/engines/sci/sfx/iterator.h
    index 4e6df36..d66faa1 100644
    a b  
    2929#define SCI_SFX_SFX_ITERATOR_H
    3030
    3131#include "sci/sfx/sfx_pcm.h"
     32#include "sci/sfx/sci_midi.h"
    3233
    3334namespace Audio {
    3435        class AudioStream;
    public:  
    156157
    157158        /* See songit_* for the constructor and non-virtual member functions */
    158159
     160        byte channel_remap[MIDI_CHANNELS]; ///< Remapping for channels
    159161
    160162public:
    161163        SongIterator();
  • engines/sci/sfx/iterator_internal.h

    diff --git a/engines/sci/sfx/iterator_internal.h b/engines/sci/sfx/iterator_internal.h
    index faf0672..15b15ed 100644
    a b public:  
    256256                byte buf[4];
    257257                int result;
    258258                int retval;
    259 
    260                 /* Remapping for channels */
    261                 byte channel_remap[MIDI_CHANNELS];
    262 
    263259        } _children[2];
    264260
    265261public: