Ticket #8564: pool-of-sorrow.diff
File pool-of-sorrow.diff, 3.6 KB (added by , 18 years ago) |
---|
-
engines/kyra/sound_adlib.cpp
73 73 bool endOfData() const { return false; } 74 74 int getRate() const { return _mixer->getOutputRate(); } 75 75 76 void setSyncJumpMask(uint16 mask) { _syncJumpMask = mask; } 77 76 78 private: 77 79 struct OpcodeEntry { 78 80 typedef int (AdlibDriver::*DriverOpcode)(va_list &list); … … 127 129 // unk41 - Sound-effect. Used for primaryEffect2() 128 130 129 131 struct Channel { 132 bool lock; // New to ScummVM 130 133 uint8 opExtraLevel2; 131 134 uint8 *dataptr; 132 135 uint8 duration; … … 361 364 uint8 _soundIdTable[0x10]; 362 365 Channel _channels[10]; 363 366 367 bool _channelLock[10]; 368 364 369 uint8 _vibratoAndAMDepthBits; 365 370 uint8 _rhythmSectionBits; 366 371 … … 378 383 static const uint8 _unkTable2_3[]; 379 384 static const uint8 _unkTables[][32]; 380 385 386 uint16 _syncJumpMask; 387 381 388 Common::Mutex _mutex; 382 389 Audio::Mixer *_mixer; 383 390 … … 421 428 _samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND; 422 429 _samplesTillCallback = 0; 423 430 _samplesTillCallbackRemainder = 0; 431 432 _syncJumpMask = 0; 424 433 } 425 434 426 435 AdlibDriver::~AdlibDriver() { … … 628 637 unkOutput2(chan); 629 638 } 630 639 640 // What we have set up now is, probably, the controlling 641 // channel for the sound. It is assumed that this program will 642 // set up all the other channels it needs, clearing their locks 643 // along the way. 644 631 645 ++_lastProcessed; 632 646 _lastProcessed &= 0x0F; 633 647 } … … 670 684 void AdlibDriver::executePrograms() { 671 685 // Each channel runs its own program. There are ten channels: One for 672 686 // each Adlib channel (0-8), plus one "control channel" (9) which is 673 // the one that tells the other channels what to do. 687 // the one that tells the other channels what to do. 674 688 689 // This is where we ensure that channels that are made to jump "in 690 // sync" do so. 691 692 if (_syncJumpMask) { 693 bool forceUnlock = true; 694 695 for (_curChannel = 9; _curChannel >= 0; --_curChannel) { 696 if ((_syncJumpMask & (1 << _curChannel)) == 0) 697 continue; 698 699 if (_channels[_curChannel].dataptr && !_channels[_curChannel].lock) { 700 forceUnlock = false; 701 } 702 } 703 704 if (forceUnlock) { 705 for (_curChannel = 9; _curChannel >= 0; --_curChannel) 706 if (_syncJumpMask & (1 << _curChannel)) 707 _channels[_curChannel].lock = false; 708 } 709 } 710 675 711 for (_curChannel = 9; _curChannel >= 0; --_curChannel) { 676 712 int result = 1; 677 713 678 714 if (!_channels[_curChannel].dataptr) { 679 715 continue; 680 716 } 717 718 if (_channels[_curChannel].lock && (_syncJumpMask & (1 << _curChannel))) { 719 continue; 720 } 681 721 682 722 Channel &channel = _channels[_curChannel]; 683 723 _curRegOffset = _regOffset[_curChannel]; … … 784 824 channel.primaryEffect = 0; 785 825 channel.secondaryEffect = 0; 786 826 channel.spacing1 = 1; 827 channel.lock = false; 787 828 } 788 829 789 830 void AdlibDriver::noteOff(Channel &channel) { … … 1246 1287 --dataptr; 1247 1288 int16 add = READ_LE_UINT16(dataptr); dataptr += 2; 1248 1289 dataptr += add; 1290 if (_syncJumpMask & (1 << (&channel - _channels))) 1291 channel.lock = true; 1249 1292 return 0; 1250 1293 } 1251 1294 … … 2195 2238 } 2196 2239 2197 2240 void SoundAdlibPC::playTrack(uint8 track) { 2198 if (_musicEnabled) 2241 if (_musicEnabled) { 2242 // WORKAROUND: There is a bug in the Kyra 1 "Pool of Sorrow" 2243 // music which causes the channels to get progressively out of 2244 // sync for each loop. To avoid that, we declare that all four 2245 // of the song channels have to jump "in sync". 2246 2247 if (track == 4 && _soundFileLoaded == "KYRA1B") 2248 _driver->setSyncJumpMask(0x000F); 2249 else 2250 _driver->setSyncJumpMask(0); 2199 2251 play(track); 2252 } 2200 2253 } 2201 2254 2202 2255 void SoundAdlibPC::haltTrack() {