From: <sv...@op...> - 2024-09-22 23:29:16
|
Author: sagamusix Date: Mon Sep 23 01:29:09 2024 New Revision: 21688 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21688 Log: [Imp] ULT: Try to preserve global commands if there's e.g. both a speed and tempo command in the same cell. Fixes trance mission.ult (https://www.un4seen.com/forum/?topic=15448.msg143764#msg143764). Modified: trunk/OpenMPT/soundlib/Load_ult.cpp Modified: trunk/OpenMPT/soundlib/Load_ult.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_ult.cpp Mon Sep 23 00:37:23 2024 (r21687) +++ trunk/OpenMPT/soundlib/Load_ult.cpp Mon Sep 23 01:29:09 2024 (r21688) @@ -197,7 +197,9 @@ } -static uint8 ReadULTEvent(ModCommand &m, FileReader &file, uint8 version) +struct ULTEventResult { uint8 repeat = 0; ModCommand::COMMAND lostCommand = CMD_NONE; ModCommand::PARAM lostParam = 0; }; + +static ULTEventResult ReadULTEvent(ModCommand &m, FileReader &file, uint8 version) { uint8 repeat = 1; uint8 b = file.ReadUint8(); @@ -222,7 +224,7 @@ m.SetEffectCommand(CMD_OFFSET, static_cast<ModCommand::PARAM>(offset)); if(offset > 0xFF) m.SetVolumeCommand(VOLCMD_OFFSET, static_cast<ModCommand::VOL>(offset >> 8)); - return repeat; + return {repeat}; } else if(cmd1 == CMD_OFFSET) { uint32 offset = param1 * 4; @@ -231,7 +233,7 @@ { m.SetEffectCommand(CMD_OFFSET, static_cast<ModCommand::PARAM>(offset)); m.SetVolumeCommand(VOLCMD_OFFSET, static_cast<ModCommand::VOL>(offset >> 8)); - return repeat; + return {repeat}; } } else if(cmd2 == CMD_OFFSET) { @@ -241,7 +243,7 @@ { m.SetEffectCommand(CMD_OFFSET, static_cast<ModCommand::PARAM>(offset)); m.SetVolumeCommand(VOLCMD_OFFSET, static_cast<ModCommand::VOL>(offset >> 8)); - return repeat; + return {repeat}; } } else if(cmd1 == cmd2) { @@ -257,9 +259,8 @@ // Combine slide commands, if possible ModCommand::CombineEffects(cmd2, param2, cmd1, param1); - m.FillInTwoCommands(cmd1, param1, cmd2, param2); - - return repeat; + const auto lostCommand = m.FillInTwoCommands(cmd1, param1, cmd2, param2); + return {repeat, lostCommand.first, lostCommand.second}; } @@ -378,7 +379,10 @@ ROWINDEX row = 0; while(row < 64) { - int repeat = ReadULTEvent(evnote, file, fileHeader.version); + const ULTEventResult eventResult = ReadULTEvent(evnote, file, fileHeader.version); + if(eventResult.lostCommand != CMD_NONE && ModCommand::IsGlobalCommand(eventResult.lostCommand, eventResult.lostParam)) + Patterns[pat].WriteEffect(EffectWriter(eventResult.lostCommand, eventResult.lostParam).Row(row).RetryNextRow()); + int repeat = eventResult.repeat; if(repeat + row > 64) repeat = 64 - row; if(repeat == 0) |