Ticket #8088: imuse.imsettrigger.diff

File imuse.imsettrigger.diff, 4.9 KB (added by SF/jamieson630, 22 years ago)

Patch against imuse.cpp 1.45 (October 9)

  • scummvm/scumm/imuse.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
    retrieving revision 1.45
    diff -u -r1.45 imuse.cpp
     
    116116        bool _abort;
    117117
    118118        HookDatas _hook;
     119        byte _def_do_command_trigger;
     120        byte _deferred_do_command [4];
    119121
    120122        bool _mt32emulate;
    121123        bool _isGM;
     
    14101415
    14111416int32 IMuseInternal::do_command(int a, int b, int c, int d, int e, int f, int g, int h)
    14121417{
     1418        int i;
    14131419        byte cmd = a & 0xFF;
    14141420        byte param = a >> 8;
    14151421        Player *player = NULL;
     
    14331440                        return stop_all_sounds();
    14341441                case 13:
    14351442                        return get_sound_status(b);
    1436                 case 14:{                                                                       // FIXME: Sam and Max command - Total guess
    1437                                 int i;                                                                  //      Seems to work as a volume fader
    1438                                 Player *player;
    1439 
    1440                                 for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) {
    1441                                         if (player->_active && player->_id == (uint16)b) {
    1442                                                 player->fade_vol(e, f);
    1443                                                 return 0;
    1444                                         }
     1443                case 14:
     1444                        // FIXME: Sam and Max command - Total guess
     1445                        //        Seems to work as a volume fader
     1446                        for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) {
     1447                                if (player->_active && player->_id == (uint16)b) {
     1448                                        player->fade_vol(e, f);
     1449                                        return 0;
     1450                                }
     1451                        }
     1452                        return -1;
     1453                case 15:
     1454                        // FIXME: Sam and Max command - Total guess
     1455                        //        Something to do with position?
     1456                        for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) {
     1457                                if (player->_active && player->_id == (uint16)b) {
     1458                                        player->jump(player->_track_index + 1, 0, 0);
     1459                                        return 0;
    14451460                                }
    14461461                        }
    1447                 case 15:{                                                                       // FIXME: Sam and Max command - Total guess
    1448                                 int i;                                                                  //      Something to do with position?
    1449                                 Player *player;
     1462                        return -1;
     1463                case 16:
     1464                        return set_volchan(b, c);
     1465                case 17:
     1466                        if (g_scumm->_features & GID_SAMNMAX) {
     1467                                // Sam & Max: ImSetTrigger.
     1468                                // Sets a trigger for a particular player and
     1469                                // marker ID, along with do_command parameters
     1470                                // to invoke at the marker. The marker is
     1471                                // represented by MIDI SysEx block 00 xx (F7)
     1472                                // where "xx" is the marker ID.
    14501473                                for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) {
    14511474                                        if (player->_active && player->_id == (uint16)b) {
    1452                                                 player->jump(player->_track_index + 1, 0, 0);
     1475                                                player->_def_do_command_trigger = d;
     1476                                                player->_deferred_do_command [0] = e;
     1477                                                player->_deferred_do_command [1] = f;
     1478                                                player->_deferred_do_command [2] = g;
     1479                                                player->_deferred_do_command [3] = h;
    14531480                                                return 0;
    14541481                                        }
    14551482                                }
     1483                                return -1;
    14561484                        }
    1457 
    1458                 case 16:
    1459                         return set_volchan(b, c);
    1460                 case 17:
    1461                         return set_channel_volume(b, c);
     1485                        else
     1486                                return set_channel_volume(b, c);
    14621487                case 18:
    14631488                        return set_volchan_entry(b, c);
    14641489                case 19:
     
    14891514                case 0:
    14901515                        return player->get_param(c, d);
    14911516                case 1:
    1492                         player->set_priority(c);
     1517                        if (g_scumm->_features & GID_SAMNMAX) // Jamieson630: Nasty
     1518                                player->jump (d - 1, (e - 1) * 4 + f, ((g * player->_ticks_per_beat) >> 2) + h);
     1519                        else
     1520                                player->set_priority(c);
    14931521                        return 0;
    14941522                case 2:
    14951523                        return player->set_vol(c);
     
    20972127        len -= 2;
    20982128
    20992129        switch (code = *p++) {
    2100         case 0:                                                                                         /* part on/off? */
    2101                 // This seems to do the right thing for Monkey 2, at least.
    2102                 a = *p++ & 0x0F;
    2103                 part = get_part(a);
    2104                 if (part) {
    2105                         debug(2, "%d => turning %s part %d", p[1], (p[1] == 2) ? "OFF" : "ON", a);
    2106                         part->set_onoff(p[1] != 2);
    2107                 }
     2130        case 0:
     2131                if (len > 2) {
     2132                        // Part on/off?
     2133                        // This seems to do the right thing for Monkey 2, at least.
     2134                        a = *p++ & 0x0F;
     2135                        part = get_part(a);
     2136                        if (part) {
     2137                                debug(2, "%d => turning %s part %d", p[1], (p[1] == 2) ? "OFF" : "ON", a);
     2138                                part->set_onoff(p[1] != 2);
     2139                        }
     2140                } else {
     2141                        // Jamieson630: Sam & Max seems to use this as a marker for
     2142                        // ImSetTrigger. When a marker is encountered whose sound
     2143                        // ID and (presumably) marker ID match what was set by
     2144                        // ImSetTrigger, something magical is supposed to happen....
     2145                        if (_def_do_command_trigger && *p == _def_do_command_trigger) {
     2146                                _def_do_command_trigger = 0;
     2147                                _se->do_command (_deferred_do_command [0],
     2148                                            _deferred_do_command [1],
     2149                                            _deferred_do_command [2],
     2150                                            _deferred_do_command [3],
     2151                                            0, 0, 0, 0);
     2152                        } // end if
     2153                } // end if
     2154                break;
     2155
     2156        case 1:
     2157                // This SysEx is used in Sam & Max to provide loop (and
     2158                // possibly marker) information. Presently, only the
     2159                // loop information is implemented.
     2160                if (_scanning)
     2161                        break;
     2162                maybe_jump (p[0], p[1] - 1, (read_word (p + 2) - 1) * 4 + p[4], ((p[5] * _ticks_per_beat) >> 2) + p[6]);
    21082163                break;
    21092164               
    21102165        case 16:                                                                                        /* set instrument in part */