King's Quest 4 SCI MT-32 problem

Ask for help with ScummVM problems

Moderator: ScummVM Team

Sven
Posts: 25
Joined: Tue Nov 16, 2010 2:46 pm

Post by Sven »

The more I look at this, the less sense it makes.

I was wrong before: when running KQ5 in DOSBox it does send a reverb sysex. The data it sends is 00 04 04. This value is not among the reverb configurations that ScummVM reads from the patch data.

I rechecked KQ4, and reverb isn't handled properly there either. KQ4 in DOSBox sends a reverb sysex just before it starts playing music with values 01 04 06, whereas ScummVM doesn't send one at all (it also sends a master volume change and part MIDI channel assignments, which ScummVM doesn't send either).

It seems that reverb handling in the SCI engine is just completely wrong.
Sven
Posts: 25
Joined: Tue Nov 16, 2010 2:46 pm

Post by Sven »

Ok, I've figured out another piece of this puzzle (I'm sorry for the multiple posts).

The MidiPlayer_Midi::readMt32Patch (engines/sci/sound/driver/midi.cpp) function doesn't read the reverb configs correctly. It reads the values in the wrong order.

The code was:

Code: Select all

for &#40;int i = 0; i < kReverbConfigNr; i++&#41; &#123;
  _reverbConfig&#91;i&#93;&#91;0&#93; = str->readByte&#40;&#41;;
  _reverbConfig&#91;i&#93;&#91;1&#93; = str->readByte&#40;&#41;;
  _reverbConfig&#91;i&#93;&#91;2&#93; = str->readByte&#40;&#41;;
&#125;
But should be:

Code: Select all

for &#40;int j = 0; j < 3; ++j&#41; &#123;
  for &#40;int i = 0; i < kReverbConfigNr; i++&#41; &#123;
    _reverbConfig&#91;i&#93;&#91;j&#93; = str->readByte&#40;&#41;;
  &#125;
&#125;
This puts the reverb config data in the proper order.

The reverb data I see from DOSBox for KQ4 (01 04 06) and KQ5 (00 04 04) is now in _reverbConfig[0] for both those games. However, the problem remains that this reverb isn't sent by ScummVM. The real SCI seems to send it just before it starts playing the first piece of music. I tried sending it from MidiParser_SCI::sendInitCommands but that sends it before every piece of music, more often than the real SCI does (doesn't appear to be harmful though). You might also just send it from MidiPlayer_Midi::readMt32Patch after all the other sysex messages.

This makes the music in ScummVM finally sound like it does in DOSBox.

Note that this doesn't address the issue of the weird reverb change in KQ5, which is actually part of the song data. I've modified my working copy to ignore reverb parameters >10 for the time being, which seems to work for now, but honestly, considering how much else was wrong here I wonder if ScummVM is parsing that BF 50 7f message correctly at all.

EDIT: I filed a separate bug report for this issue (with patch), because it's separate from envisagedOne's KQ5 issue.
Sven
Posts: 25
Joined: Tue Nov 16, 2010 2:46 pm

Post by Sven »

Okay, looks like this patch was accepted (though the fact that it needs to send the default reverb to the MT-32 is still left as TODO; note that this also doesn't fix envisagedOne's KQ5 issue).

Meanwhile, I've submitted another patch for an issue with the MT-32 when paused music is resumed.

We'll get this thing working properly with the MT-32 yet. :P
waltervn
ScummVM Developer
Posts: 19
Joined: Mon Apr 14, 2008 12:02 am

Post by waltervn »

Sven, current findings are as follows:

The default reverb setting in the MT-32 patch is not handled the same in all versions of SCI, even for the versions that have the same MT-32 patch format. An old comment of mine in the code suggests that SCI1 doesn't use the default reverb setting at all. I will have another look at the different SCI versions to see what we need to do.

We also looked at the issue with reverb setting 127 in the songs. It seems that this is supposed to switch a song back to "global" reverb. As the MT-32 driver knows nothing about songs this requires some extra work on the interpreter music code.

Thanks for your help!
Sven
Posts: 25
Joined: Tue Nov 16, 2010 2:46 pm

Post by Sven »

Thanks for looking into this. It seems that at least KQ1, KQ4 and KQ5 send the default reverb to the MT-32. Maybe the reverb 127 has something to do with that in KQ5, but looking from the trace I took it sends the reverb sysex before it starts playing the song that contains that event.

In KQ1 and KQ4 (both late SCI) there is no trace of any reverb events in the songs, so they seem to need it sent separately. They definitely don't sound right without it compared to DOSBox, and my crude "just send the default reverb in sendInitCommands" approach at least gets them to sound right, but of course I haven't tested this to see if it covers all scenarios.

Thanks again, and if I can help with anything else, just let me know. :)
waltervn
ScummVM Developer
Posts: 19
Joined: Mon Apr 14, 2008 12:02 am

Post by waltervn »

Sven, could you try changing the default reverb setting in the KQ5 patch.1, and see if you actually get the corresponding sysex anywhere? (In DOSBox, that is).

My initial impression is that in SCI1 the default is always reverb 0, no matter what the patch says. But I might be missing something somewhere.
Sven
Posts: 25
Joined: Tue Nov 16, 2010 2:46 pm

Post by Sven »

Is there a better option to do that than trying to manually locate patch.1 in the file with a hex editor?
waltervn
ScummVM Developer
Posts: 19
Joined: Mon Apr 14, 2008 12:02 am

Post by waltervn »

Sven, in ScummVM, start up KQ5. Then press CTRL-D to enter the debugger, and type "diskdump patch 1".

I think it's written to the current directory (not sure...). Put that file into the KQ5 directory. Then edit it with a hex editor and change the byte that indicates the default reverb. I don't know off the top of my head what the offset is. Note: the patch file starts with a 2 byte header before the actual resource starts.

Note 2: If you're using KQ5CD, you'll have to rename PATCH.001 to 1.PAT.
Sven
Posts: 25
Joined: Tue Nov 16, 2010 2:46 pm

Post by Sven »

My tests seem to confirm that KQ5 (CD) always sends reverb config 0 to the MT-32, regardless of the default reverb value in the patch. Just to make sure, I also modified the actual values of the first reverb config entry, and that did show up in the capture.

I also tried this with KQ4 (newer version, so late SCI0) and it did obey the default reverb value in the patch.
waltervn
ScummVM Developer
Posts: 19
Joined: Mon Apr 14, 2008 12:02 am

Post by waltervn »

Thanks!
Sven
Posts: 25
Joined: Tue Nov 16, 2010 2:46 pm

Post by Sven »

No problem. Please let me know when you've fixed this issue so I can test it. :)
User avatar
Raziel
ScummVM Porter
Posts: 1522
Joined: Tue Oct 25, 2005 8:27 am
Location: a dying planet

Post by Raziel »

@Sven

May i ask if you have The Legend of Robin Hood: Conquests for the Longbow?
There seem to be a problem with MIDI and MT-32 hardware aswell

See alo this bug report

Thank you
User avatar
envisaged0ne
Posts: 159
Joined: Mon Nov 01, 2010 9:17 am
Location: United States

Post by envisaged0ne »

It seems that there is now 2 options for the Win version of KQ5. The DOS CD version and the WIN CD version. I can play the MIDI music through the DOS CD one and it sounds great. But I can't seem to get any MIDI sounds at all through the WIN CD one.

EDIT: I'm using revision 54469
User avatar
md5
ScummVM Developer
Posts: 2250
Joined: Thu Nov 03, 2005 9:31 pm
Location: Athens, Greece

Post by md5 »

envisaged0ne wrote:It seems that there is now 2 options for the Win version of KQ5. The DOS CD version and the WIN CD version. I can play the MIDI music through the DOS CD one and it sounds great. But I can't seem to get any MIDI sounds at all through the WIN CD one.

EDIT: I'm using revision 54469
The Windows version is using GM music, so the sound driver selected in ScummVM's options must be GM. I'll add an appropriate warning
User avatar
envisaged0ne
Posts: 159
Joined: Mon Nov 01, 2010 9:17 am
Location: United States

Post by envisaged0ne »

Gotcha. Finally got it to work :) I actually had to choose the GM from the audio drop list, then put a check next to Overide Global MT-32 Settings under the MT-32 tab
Post Reply