Skip to content

Commit

Permalink
Merged revision(s) 22056, 22377 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Imp] Warn when Startrekker AM companion file for synthesized instruments is most likely missing.
........
[Imp] Allow Startrekker AM external sample check to also work for libopenmpt.
........
Merged revision(s) 22377 from trunk/OpenMPT:
[Imp] Allow Startrekker AM external sample check to also work for libopenmpt.
........



git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.28@22385 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Dec 1, 2024
1 parent a3a705a commit 3dc3e8a
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion soundlib/Load_mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)

// Reading patterns
Patterns.ResizeArray(numPatterns);
std::bitset<32> referencedSamples;
for(PATTERNINDEX pat = 0; pat < numPatterns; pat++)
{
ModCommand *rowBase = nullptr;
Expand Down Expand Up @@ -1091,6 +1092,8 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)
if(m.instr != 0)
{
lastInstrument[chn] = m.instr;
if(isStartrekker)
referencedSamples.set(m.instr & 0x1F);
}
}
if(hasSpeedOnRow && hasTempoOnRow) definitelyCIA = true;
Expand Down Expand Up @@ -1212,7 +1215,7 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)
m_nInstruments = 31;
#endif

for(SAMPLEINDEX smp = 1; smp <= m_nInstruments; smp++)
for(SAMPLEINDEX smp = 1; smp <= GetNumInstruments(); smp++)
{
// For Startrekker AM synthesis, we need instrument envelopes.
ModInstrument *ins = AllocateInstrument(smp, smp);
Expand All @@ -1233,6 +1236,33 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)
amData.Skip(120 - sizeof(AMInstrument));
}
}
#endif // MPT_EXTERNAL_SAMPLES || MPT_BUILD_FUZZER

if((loadFlags & loadSampleData) && isStartrekker && !m_nInstruments)
{
uint8 emptySampleReferences = 0;
for(SAMPLEINDEX smp = 1; smp <= 31; smp++)
{
if(referencedSamples[smp] && !Samples[smp].nLength)
{
if(++emptySampleReferences > 1)
{
#ifdef MPT_EXTERNAL_SAMPLES
mpt::ustring filenameHint;
if(file.GetOptionalFileName())
{
const auto filename = file.GetOptionalFileName()->GetFilename().ToUnicode();
filenameHint = mpt::format(U_(" ({}.nt or {}.as)"))(filename, filename);
}
AddToLog(LogWarning, mpt::format(U_("This Startrekker AM file is most likely missing its companion file{}. Synthesized instruments will not play."))(filenameHint));
#else
AddToLog(LogWarning, U_("This appears to be a Startrekker AM file with external synthesizes instruments. External instruments are currently not supported."));
#endif // MPT_EXTERNAL_SAMPLES
break;
}
}
}
}
#endif // MPT_EXTERNAL_SAMPLES || MPT_BUILD_FUZZER

// Fix VBlank MODs. Arbitrary threshold: 8 minutes (enough for "frame of mind" by Dascon...).
Expand Down

0 comments on commit 3dc3e8a

Please sign in to comment.