diff --git a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs index 16f0b67d39..ae2a280816 100755 --- a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs +++ b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs @@ -31,7 +31,7 @@ namespace OpenRA.FileFormats.Graphics IGraphicsDevice Create( Size size, WindowMode windowMode ); } - public enum BlendMode { None, Alpha, Additive, Subtractive } + public enum BlendMode { None, Alpha, Additive, Subtractive, Multiply } public interface IGraphicsDevice { diff --git a/OpenRA.Mods.D2k/PaletteFromR8.cs b/OpenRA.Mods.D2k/PaletteFromR8.cs index 901fef682c..b60a26330b 100644 --- a/OpenRA.Mods.D2k/PaletteFromR8.cs +++ b/OpenRA.Mods.D2k/PaletteFromR8.cs @@ -10,8 +10,8 @@ using System.IO; using OpenRA.FileFormats; -using OpenRA.Traits; using OpenRA.Graphics; +using OpenRA.Traits; namespace OpenRA.Mods.RA { @@ -24,6 +24,7 @@ namespace OpenRA.Mods.RA [Desc("Palette byte offset")] public readonly long Offset = 0; public readonly bool AllowModifiers = true; + public readonly bool InvertColor = false; public object Create(ActorInitializer init) { return new PaletteFromR8(this); } } @@ -42,10 +43,11 @@ namespace OpenRA.Mods.RA for (var i = 0; i < 256; i++) { - // The custom palette is scaled into the range 0-128. - // This makes the move-flash match the original game, but may not be correct in other cases. var packed = s.ReadUInt16(); - colors[i] = (uint)((255 << 24) | ((packed & 0xF800) << 7) | ((packed & 0x7E0) << 4) | ((packed & 0x1f) << 2)); + colors[i] = (uint)((255 << 24) | ((packed & 0xF800) << 8) | ((packed & 0x7E0) << 5) | ((packed & 0x1f) << 3)); + + if (info.InvertColor) + colors[i] ^= 0x00FFFFFF; } } diff --git a/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs b/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs index ad5805f44f..5d49dccfa4 100755 --- a/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs +++ b/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs @@ -177,6 +177,12 @@ namespace OpenRA.Renderer.Sdl2 ErrorHandler.CheckGlError(); Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT); break; + case BlendMode.Multiply: + Gl.glEnable(Gl.GL_BLEND); + ErrorHandler.CheckGlError(); + Gl.glBlendFuncSeparate(Gl.GL_DST_COLOR, Gl.GL_ZERO, Gl.GL_ONE, Gl.GL_ONE_MINUS_SRC_ALPHA); + ErrorHandler.CheckGlError(); + break; } ErrorHandler.CheckGlError(); diff --git a/OpenRA.Renderer.SdlCommon/SdlGraphics.cs b/OpenRA.Renderer.SdlCommon/SdlGraphics.cs index 8c8de209e3..ec87e0f8d9 100644 --- a/OpenRA.Renderer.SdlCommon/SdlGraphics.cs +++ b/OpenRA.Renderer.SdlCommon/SdlGraphics.cs @@ -179,6 +179,12 @@ namespace OpenRA.Renderer.SdlCommon ErrorHandler.CheckGlError(); Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT); break; + case BlendMode.Multiply: + Gl.glEnable(Gl.GL_BLEND); + ErrorHandler.CheckGlError(); + Gl.glBlendFuncSeparate(Gl.GL_DST_COLOR, Gl.GL_ZERO, Gl.GL_ONE, Gl.GL_ONE_MINUS_SRC_ALPHA); + ErrorHandler.CheckGlError(); + break; } ErrorHandler.CheckGlError(); } diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index 2dcf67d748..7b4a68f1ae 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -414,7 +414,7 @@ World: Name: moveflash Filename: DATA.R8 Offset: 2572352 - A: 64 + InvertColor: true PaletteFromRGBA@disabled: Name: disabled R: 0 diff --git a/mods/d2k/sequences/misc.yaml b/mods/d2k/sequences/misc.yaml index 5774d04056..df39400d6c 100644 --- a/mods/d2k/sequences/misc.yaml +++ b/mods/d2k/sequences/misc.yaml @@ -304,7 +304,7 @@ moveflsh: Start: 3621 Length: 5 Tick: 80 - BlendMode: Subtractive + BlendMode: Multiply resources: spice: BLOXBASE