Skip to content

Commit

Permalink
[Fix] IT compatibility: When triggering an empty instrument note slot…
Browse files Browse the repository at this point in the history
…, completely ignore the pattern cell - do not reset the currently playing instrument's envelopes (fixes wayfinder's Jet Rider), and also don't process any effects - including global ones.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@20790 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed May 11, 2024
1 parent a659078 commit afd9a20
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions mptrack/dlg_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ void CLegacyPlaybackSettingsDlg::OnFilterStringChanged()
case kITInitialNoteMemory: desc = _T("Initial Last Note Memory of each channel is C-0 instead of No Note"); break;
case kPluginDefaultProgramAndBank1: desc = _T("Assume initial plugin MIDI program and bank number is 1"); break;
case kITNoSustainOnPortamento: desc = _T("Portamento after note-off does not re-enable sample sustain loop"); break;
case kITEmptyNoteMapSlotIgnoreCell: desc = _T("Ignore pattern cell completely when trying to play unmapped instrument note"); break;

default: MPT_ASSERT_NOTREACHED();
}
Expand Down
1 change: 1 addition & 0 deletions soundlib/Snd_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ enum PlayBehaviour
kITInitialNoteMemory, // Initial "last note memory" for each channel is C-0 and not "no note"
kPluginDefaultProgramAndBank1, // Default program and bank is set to 1 for plugins, so if an instrument is set to either of those, the program / bank change event is not sent to the plugin
kITNoSustainOnPortamento, // Do not re-enable sustain loop on portamento, even when switching between samples
kITEmptyNoteMapSlotIgnoreCell, // IT ignores the entire pattern cell when trying to play an unmapped note of an instrument

// Add new play behaviours here.

Expand Down
18 changes: 18 additions & 0 deletions soundlib/Snd_fx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2889,7 +2889,25 @@ bool CSoundFile::ProcessEffects()
if(ModCommand::IsNote(note))
{
chn.nNewNote = chn.nLastNote = note;
}

// IT compatibility: Empty sample mapping
// This is probably the single biggest WTF replayer bug in Impulse Tracker.
// In instrument mode, when an note + instrument is triggered that does not map to any sample, the entire cell (including potentially present global effects!)
// is ignored. Even better, if on a following row another instrument number (this time without a note) is encountered, we end up in the same situation!
// Test cases: NoMap.it, NoMapEffects.it
if(m_playBehaviour[kITEmptyNoteMapSlotIgnoreCell] && instr > 0 && instr <= GetNumInstruments()
&& Instruments[instr] != nullptr
&& ModCommand::IsNote(chn.nNewNote) && Instruments[instr]->Keyboard[chn.nNewNote - NOTE_MIN] == 0
&& !Instruments[instr]->HasValidMIDIChannel())
{
chn.nNewIns = static_cast<ModCommand::INSTR>(instr);
chn.ClearRowCmd();
continue;
}

if(ModCommand::IsNote(note))
{
// New Note Action ?
if(!bPorta)
{
Expand Down
1 change: 1 addition & 0 deletions soundlib/Sndfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ PlayBehaviourSet CSoundFile::GetSupportedPlaybackBehaviour(MODTYPE type)
playBehaviour.set(kITResetFilterOnPortaSmpChange);
playBehaviour.set(kITInitialNoteMemory);
playBehaviour.set(kITNoSustainOnPortamento);
playBehaviour.set(kITEmptyNoteMapSlotIgnoreCell);
break;

case MOD_TYPE_XM:
Expand Down
1 change: 1 addition & 0 deletions soundlib/UpgradeModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ void CSoundFile::UpgradeModule()
{ kITResetFilterOnPortaSmpChange, MPT_V("1.30.08.02") },
{ kITInitialNoteMemory, MPT_V("1.31.00.25") },
{ kITNoSustainOnPortamento, MPT_V("1.32.00.13") },
{ kITEmptyNoteMapSlotIgnoreCell, MPT_V("1.32.00.13") },
};

for(const auto &b : behaviours)
Expand Down

0 comments on commit afd9a20

Please sign in to comment.