SAM: ImSetTrigger implementation
|Reported by:||SF/jamieson630||Owned by:||SF/ender|
|Game:||Sam and Max|
The included patch implements the ImSetTrigger function (do_command param == 0, cmd == 17) for Sam & Max. This is the first observed correlation between Sam & Max script commands and SysEx blocks in the S&M MIDI resources.
ImSetTrigger provides a set of parameters with which to invoke do_command, at the time that a marker matching the specified marker ID is encountered in a MIDI music resource that is playing. The marker is identified using the following SysEx event: 00 xx (F7), where "xx" is the marker ID.
The use of do_command (0/17) has been observed in two locations in Sam & Max. The first is in the opening credits -- the following do_command call is made after all the credits have finished coming up on the screen:
IMuseInternal::do_command (17, 89, 0, 1, 8, 6, 0, 0);
At the end of the credits music (sound resource #89), the following SysEx event is encountered:
SysEx: 00 01 F7
The last four parameters of the do_command call actually map to the first four parameters of the do_command call that should occur once the marker is encountered.
The other location where do_command (0/17) is observed is at the Gator Golf entrance. A short intro music is played, which is then supposed to flow into a much longer main song. Upon entrance to the room, the following do_command call is made:
IMuseInternal::do_command (17, 31, 0, 1, 8, 30, 0, 0);
At the end of the short intro music (sound resource #31), the following SysEx event is encountered:
SysEx: 00 01 F7
This implementation properly transitions into the main Gator Golf music. However, its correctness of behavior has not been validated with the opening credit music (which should flow into the "walking into the office" music after the credits), possibly because the office scene is brought up (and at least one other music resource activated) long before the credits music finishes playing. This is an issue related to the use of do_command (param == 1, cmd == 0), which I am still investigating.
Note that other music resources include SysEx 00 xx (F7) events (including a whole glut of them during the credits music that seem to use marker IDs corresponding to measure numbers). However, there is no expected exceptional behavior at these points in the music, and since no calls to do_command (0/17) are ever made that relate to these markers, no action is taken by this implementation. I believe this is correct: for most music, the SysEx 00 01 (F7) seems to appear as a general-purpose end-of-song marker for most songs.
Regarding the implementation of ImSetTrigger, I have deviated slightly from the implementation notes that Mike provided to Ender in his disassembly efforts for the Sam & Max IMuse. In those notes, the 16 possible triggers are scoped at the IMuseInternal level, and include the player ID they are related to. In my implementation, I have put the trigger information into each of the players (16 max players, BTW) directly. This may not be the right thing to do; if certain calls to do_command (0/17) involve sound resources that have not started playing yet, this implementation would fail to set up the trigger. Maybe somebody more familiar with the scope of Mike's work could tell me if I'm taking his interpretation of the IMuse opcodes too literally.
Finally, the implementation of ImCheckTrigger and ImClearTrigger should follow easily from this implementation. I will submit a separate patch with those implementations, once this patch has been validated.
NOTE: Part of patch #620994 (do_command param == 1, cmd == 1) is included in this patch, just because the outstanding mods I have on imuse.cpp are starting to get extensive and intermingled. Sorry....
Ticket imported from: #621821. Ticket imported from: patches/193.