BGSHADE.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Microsoft.Xna.Framework;
  2. namespace OpenVIII.Fields.Scripts.Instructions
  3. {
  4. /// <summary>
  5. /// Shade between two colors
  6. /// </summary>
  7. /// <see cref="http://wiki.ffrtt.ru/index.php?title=FF8/Field/Script/Opcodes/0D0_BGSHADE&action=edit&redlink=1"/>
  8. public sealed class BGSHADE : JsmInstruction
  9. {
  10. #region Fields
  11. private readonly Color _c0;
  12. private readonly Color _c1;
  13. private readonly int _fadeFrames;
  14. #endregion Fields
  15. #region Constructors
  16. public BGSHADE(int fadeFrames, byte red0, byte green0, byte blue0, byte red1, byte green1, byte blue1)
  17. {
  18. _fadeFrames = fadeFrames; //I think it's fade duration
  19. (_c0.R, _c0.G, _c0.B, _c0.A) = (red0, green0, blue0, 0xFF); //red and blue could be reversed.
  20. (_c1.R, _c1.G, _c1.B, _c1.A) = (red1, green1, blue1, 0xFF); //red and blue could be reversed.
  21. }
  22. public BGSHADE(int parameter, IStack<IJsmExpression> stack)
  23. : this(
  24. blue1: ((IConstExpression)stack.Pop()).Byte(),
  25. green1: ((IConstExpression)stack.Pop()).Byte(),
  26. red1: ((IConstExpression)stack.Pop()).Byte(),
  27. blue0: ((IConstExpression)stack.Pop()).Byte(),
  28. green0: ((IConstExpression)stack.Pop()).Byte(),
  29. red0: ((IConstExpression)stack.Pop()).Byte(),
  30. fadeFrames: ((IConstExpression)stack.Pop()).Int32())
  31. {
  32. }
  33. #endregion Constructors
  34. #region Properties
  35. public Color C0 => _c0;
  36. public Color C1 => _c1;
  37. public int FadeFrames => _fadeFrames;
  38. #endregion Properties
  39. #region Methods
  40. public override string ToString() => $"{nameof(BGSHADE)}({nameof(_fadeFrames)}: {_fadeFrames}, {nameof(_c0)}: {_c0}, {nameof(_c1)}: {_c1})";
  41. #endregion Methods
  42. }
  43. }