Skip to content

Commit

Permalink
[Fix] S3M: Saving note-less instrument broke in r22093 (see #28).
Browse files Browse the repository at this point in the history
[Imp] Improve S3M saving tests.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22129 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 9, 2024
1 parent 0921a91 commit acac87c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 3 additions & 4 deletions soundlib/Load_s3m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,16 +973,15 @@ bool CSoundFile::SaveS3M(std::ostream &f) const
{
// Note Cut
note = s3mNoteOff;
} else if(note < NOTE_MIN + 12)
} else if(note >= NOTE_MIN && note < NOTE_MIN + 12)
{
// Too low
note = 0;
} else if(note <= NOTE_MIN + 107)
} else if(note >= NOTE_MIN && note <= NOTE_MIN + 107)
{
note -= (12 + NOTE_MIN);
note = static_cast<uint8>((note % 12) + ((note / 12) << 4));
}
else
} else
{
note = s3mNoteNone;
}
Expand Down
8 changes: 7 additions & 1 deletion test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3296,7 +3296,8 @@ static void TestLoadS3MFile(const CSoundFile &sndFile, bool resaved)
VERIFY_EQUAL_NONCONT(sndFile.m_SongFlags, SONG_FASTVOLSLIDES);
VERIFY_EQUAL_NONCONT(sndFile.GetMixLevels(), MixLevels::Compatible);
VERIFY_EQUAL_NONCONT(sndFile.m_nTempoMode, TempoMode::Classic);
VERIFY_EQUAL_NONCONT(sndFile.m_dwLastSavedWithVersion, resaved ? Version::Current() : MPT_V("1.27.00.00"));
VERIFY_EQUAL_NONCONT(sndFile.m_dwLastSavedWithVersion, resaved ? Version::Current() : MPT_V("1.32.00.32"));
VERIFY_EQUAL_NONCONT(sndFile.GetFileHistory().size(), 1);

// Channels
VERIFY_EQUAL_NONCONT(sndFile.GetNumChannels(), 4);
Expand Down Expand Up @@ -3397,6 +3398,7 @@ static void TestLoadS3MFile(const CSoundFile &sndFile, bool resaved)
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetOverrideSignature(), false);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(0, 0)->note, NOTE_MIN + 12);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(1, 0)->note, NOTE_MIN + 107);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(2, 0)->note, NOTE_NOTECUT);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(0, 1)->volcmd, VOLCMD_VOLUME);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(0, 1)->vol, 0);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(1, 1)->volcmd, VOLCMD_VOLUME);
Expand All @@ -3407,6 +3409,10 @@ static void TestLoadS3MFile(const CSoundFile &sndFile, bool resaved)
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(3, 1)->vol, 64);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(0, 3)->command, CMD_SPEED);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(0, 3)->param, 0x11);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(3, 0)->IsEmpty(), false);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(3, 0)->note, NOTE_NONE);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(3, 0)->instr, 99);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(4, 0)->IsEmpty(), true);

VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetNumRows(), 64);
VERIFY_EQUAL_NONCONT(sndFile.Patterns.IsPatternEmpty(1), false);
Expand Down
Binary file modified test/test.s3m
Binary file not shown.

0 comments on commit acac87c

Please sign in to comment.