diff --git a/OpenDiablo2.Common/Models/ImageSet.cs b/OpenDiablo2.Common/Models/ImageSet.cs index 686924a1..a51b419a 100644 --- a/OpenDiablo2.Common/Models/ImageSet.cs +++ b/OpenDiablo2.Common/Models/ImageSet.cs @@ -32,9 +32,7 @@ namespace OpenDiablo2.Common.Models if (index == -1) return 0; - var color = palette.Colors[index]; - - return ((UInt32)255 << 24) + ((UInt32)color.R << 16) + ((UInt32)color.G << 8) + (UInt32)color.B; + return palette.Colors[index]; } } diff --git a/OpenDiablo2.Common/Models/MPQDT1.cs b/OpenDiablo2.Common/Models/MPQDT1.cs index e19673f8..2ea3e460 100644 --- a/OpenDiablo2.Common/Models/MPQDT1.cs +++ b/OpenDiablo2.Common/Models/MPQDT1.cs @@ -154,15 +154,12 @@ namespace OpenDiablo2.Common.Models else { // RLE block - /* var length = block.Length; byte b1; byte b2; int x = 0; int y = 0; - int width = (block.Format >> 8); - int height = (block.Format & 0xFF); - block.PixelData = new Int16[256 * 256]; + block.PixelData = new Int16[32 * 32]; while (length > 0) { b1 = br.ReadByte(); @@ -180,12 +177,10 @@ namespace OpenDiablo2.Common.Models while (b2 > 0) { block.PixelData[x + (y * 32)] = br.ReadByte(); - br.ReadByte(); x++; b2--; } } - */ } } } diff --git a/OpenDiablo2.Common/Models/Palette.cs b/OpenDiablo2.Common/Models/Palette.cs index be391996..d9198ecc 100644 --- a/OpenDiablo2.Common/Models/Palette.cs +++ b/OpenDiablo2.Common/Models/Palette.cs @@ -7,34 +7,27 @@ using System.Threading.Tasks; namespace OpenDiablo2.Common.Models { - public struct PaletteEntry - { - public int R; - public int G; - public int B; - } - public struct Palette { public string Name { get; set; } - public PaletteEntry[] Colors; + public UInt32[] Colors; public static Palette LoadFromStream(Stream stream, string paletteName) { var result = new Palette { Name = paletteName, - Colors = new PaletteEntry[256] + Colors = new UInt32[256] }; var br = new BinaryReader(stream); for (var i = 0; i <= 255; i++) - result.Colors[i] = new PaletteEntry - { - B = br.ReadByte(), - G = br.ReadByte(), - R = br.ReadByte() - }; + { + var b = br.ReadByte(); + var g = br.ReadByte(); + var r = br.ReadByte(); + result.Colors[i] = ((UInt32)255 << 24) + ((UInt32)r << 16) + ((UInt32)g << 8) + (UInt32)b; + } return result; } diff --git a/OpenDiablo2.SDL2/SDL2Sprite.cs b/OpenDiablo2.SDL2/SDL2Sprite.cs index 85a09c2a..9b555d16 100644 --- a/OpenDiablo2.SDL2/SDL2Sprite.cs +++ b/OpenDiablo2.SDL2/SDL2Sprite.cs @@ -118,12 +118,17 @@ namespace OpenDiablo2.SDL2_ for (var i = 0; i < FrameSize.Width * FrameSize.Height; i++) data[i] = 0; - for (var subtileX = 0; subtileX < 5; subtileX++) - { - for (var subtileY = 0; subtileY < 5; subtileY++) - { - var subtileFlags = tile.SubTileFlags[subtileX + (subtileY * 5)]; + foreach (var block in tile.Blocks) + { + var px = block.PositionX; + var py = FrameSize.Height + block.PositionY; + for (int yy = 0; yy < 32; yy++) + { + for (int xx = 0; xx < 32; xx++) + { + data[px + xx + ((py + yy) * pitch / 4)] = palette.Colors[block.PixelData[xx + (yy * 32)]]; + } } } diff --git a/OpenDiablo2.Scenes/MainMenu.cs b/OpenDiablo2.Scenes/MainMenu.cs index 11882404..abe932a8 100644 --- a/OpenDiablo2.Scenes/MainMenu.cs +++ b/OpenDiablo2.Scenes/MainMenu.cs @@ -49,9 +49,7 @@ namespace OpenDiablo2.Scenes this.mpqProvider = mpqProvider; this.mouseInfoProvider = mouseInfoProvider; this.sceneManager = sceneManager; - - resourceManager.GetMPQDS1(ResourcePaths.MapAct1TownE1, -1, 1); - + backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky); diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120)); diabloLogoLeft.Blend = true;