protected void ApplySimpleEffects(RowFxData fx, Pattern pattern, int n, Dictionary <Pattern, byte> patternLengths, bool allowSongEffects) { Note note = null; switch (fx.fx) { case Effect_None: return; case Effect_Jump: // Ignore if there was a Dxx or Bxx before. if (allowSongEffects && !patternLengths.ContainsKey(pattern)) { pattern.Song.SetLoopPoint(fx.param); patternLengths[pattern] = (byte)(n + 1); } return; case Effect_Skip: // Ignore if there was a Dxx or Bxx before. if (!patternLengths.ContainsKey(pattern)) { patternLengths[pattern] = (byte)(n + 1); } return; case Effect_Speed: if (pattern.Channel.SupportsEffect(Note.EffectSpeed)) { if (fx.param <= 0x1f) // We only support speed change for now. { pattern.GetOrCreateNoteAt(n).Speed = Math.Max((byte)1, (byte)fx.param); } else { Log.LogMessage(LogSeverity.Warning, $"Only speed changes are supported, not tempo. Will be ignored. {GetPatternString(pattern, n)}"); } } return; case Effect_Pitch: if (pattern.Channel.SupportsEffect(Note.EffectFinePitch)) { pattern.GetOrCreateNoteAt(n).FinePitch = (sbyte)(0x80 - fx.param); } return; case Effect_Vibrato: if (pattern.Channel.SupportsEffect(Note.EffectVibratoDepth)) { note = pattern.GetOrCreateNoteAt(n); note.VibratoDepth = (byte)(fx.param & 0x0f); note.VibratoSpeed = (byte)VibratoSpeedImportLookup[fx.param >> 4]; if (note.VibratoDepth == 0 || note.VibratoSpeed == 0) { note.RawVibrato = 0; } } return; case Effect_FdsModSpeedHi: if (pattern.Channel.SupportsEffect(Note.EffectFdsModSpeed)) { // TODO: If both hi/lo effects arent in a pair, this is likely not going to work. note = pattern.GetOrCreateNoteAt(n); if (!note.HasFdsModSpeed) { note.FdsModSpeed = 0; } note.FdsModSpeed = (ushort)(((note.FdsModSpeed) & 0x00ff) | (fx.param << 8)); } return; case Effect_FdsModSpeedLo: if (pattern.Channel.SupportsEffect(Note.EffectFdsModSpeed)) { // TODO: If both hi/lo effects arent in a pair, this is likely not going to work. note = pattern.GetOrCreateNoteAt(n); if (!note.HasFdsModSpeed) { note.FdsModSpeed = 0; } note.FdsModSpeed = (ushort)(((note.FdsModSpeed) & 0xff00) | (fx.param << 0)); } return; case Effect_FdsModDepth: if (pattern.Channel.SupportsEffect(Note.EffectFdsModDepth)) { pattern.GetOrCreateNoteAt(n).FdsModDepth = fx.param; } return; case Effect_DutyCycle: if (pattern.Channel.SupportsEffect(Note.EffectDutyCycle)) { pattern.GetOrCreateNoteAt(n).DutyCycle = fx.param; } return; case Effect_Delay: if (pattern.Channel.SupportsEffect(Note.EffectNoteDelay)) { pattern.GetOrCreateNoteAt(n).NoteDelay = Math.Min((byte)31, fx.param); } return; case Effect_NoteCut: if (pattern.Channel.SupportsEffect(Note.EffectCutDelay)) { pattern.GetOrCreateNoteAt(n).CutDelay = Math.Min((byte)31, fx.param); } return; case Effect_Halt: case Effect_PortaUp: case Effect_PortaDown: case Effect_Portamento: case Effect_SlideUp: case Effect_SlideDown: case Effect_Arpeggio: // These will be applied later. return; } if (EffectToTextLookup.ContainsKey(fx.fx)) { Log.LogMessage(LogSeverity.Warning, $"Effect '{EffectToTextLookup[fx.fx]}' is not supported and will be ignored. {GetPatternString(pattern, n)}"); } else { Log.LogMessage(LogSeverity.Warning, $"Unknown effect code ({fx.fx}) and will be ignored. {GetPatternString(pattern, n)}"); } }
protected void ApplySimpleEffects(RowFxData fx, Pattern pattern, int n, Dictionary <Pattern, byte> patternLengths) { Note note = null; switch (fx.fx) { case Effect_Jump: pattern.Song.SetLoopPoint(fx.param); break; case Effect_Skip: patternLengths[pattern] = (byte)(n + 1); break; case Effect_Speed: if (fx.param <= 0x1f) // We only support speed change for now. { pattern.GetOrCreateNoteAt(n).Speed = Math.Max((byte)1, (byte)fx.param); } break; case Effect_Pitch: pattern.GetOrCreateNoteAt(n).FinePitch = (sbyte)(0x80 - fx.param); break; case Effect_Vibrato: note = pattern.GetOrCreateNoteAt(n); note.VibratoDepth = (byte)(fx.param & 0x0f); note.VibratoSpeed = (byte)VibratoSpeedImportLookup[fx.param >> 4]; if (note.VibratoDepth == 0 || note.VibratoSpeed == 0) { note.RawVibrato = 0; } break; case Effect_FdsModSpeedHi: // TODO: If both hi/lo effects arent in a pair, this is likely not going to work. note = pattern.GetOrCreateNoteAt(n); if (!note.HasFdsModSpeed) { note.FdsModSpeed = 0; } note.FdsModSpeed = (ushort)(((note.FdsModSpeed) & 0x00ff) | (fx.param << 8)); break; case Effect_FdsModSpeedLo: // TODO: If both hi/lo effects arent in a pair, this is likely not going to work. note = pattern.GetOrCreateNoteAt(n); if (!note.HasFdsModSpeed) { note.FdsModSpeed = 0; } note.FdsModSpeed = (ushort)(((note.FdsModSpeed) & 0xff00) | (fx.param << 0)); break; case Effect_FdsModDepth: pattern.GetOrCreateNoteAt(n).FdsModDepth = fx.param; break; } }