From: <sv...@op...> - 2025-05-27 18:25:13
|
Author: sagamusix Date: Tue May 27 20:25:06 2025 New Revision: 23219 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=23219 Log: [Imp] libopenmpt: Always render volume effect letter correctly, also for imported formats (https://bugs.openmpt.org/view.php?id=1860). Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/soundlib/mod_specifications.cpp trunk/OpenMPT/soundlib/mod_specifications.h Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp ============================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp Tue May 27 20:21:51 2025 (r23218) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp Tue May 27 20:25:06 2025 (r23219) @@ -1615,7 +1615,7 @@ break; case module::command_volumeffect: return std::make_pair( - cell.IsPcNote() ? std::string(" ") : cell.volcmd != OpenMPT::VOLCMD_NONE ? std::string( 1, m_sndFile->GetModSpecifications().GetVolEffectLetter( cell.volcmd ) ) : std::string(" ") + cell.IsPcNote() ? std::string(" ") : std::string( 1, OpenMPT::CModSpecifications::GetGenericVolEffectLetter( cell.volcmd ) ) , cell.IsPcNote() ? std::string(" ") : cell.volcmd != OpenMPT::VOLCMD_NONE ? std::string("u") : std::string(" ") ); @@ -1681,7 +1681,7 @@ high += cell.instr ? std::string("ii") : std::string(".."); } if ( ( width == 0 ) || ( width >= 9 ) ) { - text += cell.IsPcNote() ? std::string(" ") + OpenMPT::mpt::afmt::HEX0<2>( cell.GetValueVolCol() & 0xff ) : cell.volcmd != OpenMPT::VOLCMD_NONE ? std::string( 1, m_sndFile->GetModSpecifications().GetVolEffectLetter( cell.volcmd ) ) + OpenMPT::mpt::afmt::HEX0<2>( cell.vol ) : std::string(" .."); + text += cell.IsPcNote() ? std::string(" ") + OpenMPT::mpt::afmt::HEX0<2>( cell.GetValueVolCol() & 0xff ) : cell.volcmd != OpenMPT::VOLCMD_NONE ? std::string( 1, OpenMPT::CModSpecifications::GetGenericVolEffectLetter( cell.volcmd ) ) + OpenMPT::mpt::afmt::HEX0<2>( cell.vol ) : std::string(" .."); high += cell.IsPcNote() ? std::string(" vv") : cell.volcmd != OpenMPT::VOLCMD_NONE ? std::string("uvv") : std::string(" .."); } if ( ( width == 0 ) || ( width >= 13 ) ) { Modified: trunk/OpenMPT/soundlib/mod_specifications.cpp ============================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.cpp Tue May 27 20:21:51 2025 (r23218) +++ trunk/OpenMPT/soundlib/mod_specifications.cpp Tue May 27 20:25:06 2025 (r23219) @@ -466,29 +466,40 @@ bool CModSpecifications::HasVolCommand(ModCommand::VOLCMD volcmd) const { if(volcmd >= MAX_VOLCMDS) return false; - if(volcommands[volcmd] == '?') return false; - return true; + return volcommands[volcmd] != '?'; } bool CModSpecifications::HasCommand(ModCommand::COMMAND cmd) const { if(cmd >= MAX_EFFECTS) return false; - if(commands[cmd] == '?') return false; - return true; + return commands[cmd] != '?'; } char CModSpecifications::GetVolEffectLetter(ModCommand::VOLCMD volcmd) const { - if(volcmd >= MAX_VOLCMDS) return '?'; + if(volcmd >= MAX_VOLCMDS) + return '?'; return volcommands[volcmd]; } +char CModSpecifications::GetGenericVolEffectLetter(ModCommand::VOLCMD volcmd) +{ + // Note: Remove this function if volume effect letter display is ever going to differ between formats, and update users to GetVolEffectLetter instead. + static constexpr char VolCommands[] = " vpcdabuhlrgfe:o"; + static_assert(std::size(VolCommands) == MAX_VOLCMDS + 1); + if(volcmd >= MAX_VOLCMDS) + return '?'; + return VolCommands[volcmd]; +} + + char CModSpecifications::GetEffectLetter(ModCommand::COMMAND cmd) const { - if(cmd >= MAX_EFFECTS) return '?'; + if(cmd >= MAX_EFFECTS) + return '?'; return commands[cmd]; } Modified: trunk/OpenMPT/soundlib/mod_specifications.h ============================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h Tue May 27 20:21:51 2025 (r23218) +++ trunk/OpenMPT/soundlib/mod_specifications.h Tue May 27 20:25:06 2025 (r23219) @@ -33,7 +33,8 @@ bool HasCommand(ModCommand::COMMAND cmd) const; // Return corresponding effect letter for this format char GetEffectLetter(ModCommand::COMMAND cmd) const; - char GetVolEffectLetter(ModCommand::VOLCMD cmd) const; + char GetVolEffectLetter(ModCommand::VOLCMD volcmd) const; + static char GetGenericVolEffectLetter(ModCommand::VOLCMD volcmd); // NOTE: If changing order, update all initializations in .cpp file. MODTYPE internalType; // Internal MODTYPE value |