From 05964280c838b2ca53fd7c099048929c0f31080a Mon Sep 17 00:00:00 2001 From: Pyrdacor Date: Wed, 23 Mar 2022 17:44:48 +0100 Subject: [PATCH] Fixed some UI gfx loading --- Ambermoon.Core/Battle.cs | 2 +- .../Enumerations/UIGraphic.cs | 8 ++-- .../ExecutableData/ExecutableData.cs | 3 ++ .../ExecutableData/UIGraphics.cs | 46 ++++++++++++++----- ToDo.md | 3 ++ 5 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Ambermoon.Core/Battle.cs b/Ambermoon.Core/Battle.cs index fc50615c..076a60fa 100644 --- a/Ambermoon.Core/Battle.cs +++ b/Ambermoon.Core/Battle.cs @@ -1598,7 +1598,7 @@ void EffectApplied() { // We have to wait until the monster hurt animation finishes. // Otherwise the animation reset might not happen. - if (currentBattleAnimation == null) + if (currentBattleAnimation == null && currentlyAnimatedMonster == null) finishAction?.Invoke(); else game.AddTimedEvent(TimeSpan.FromMilliseconds(25), EffectApplied); diff --git a/Ambermoon.Data.Common/Enumerations/UIGraphic.cs b/Ambermoon.Data.Common/Enumerations/UIGraphic.cs index a6947c64..ddc39745 100644 --- a/Ambermoon.Data.Common/Enumerations/UIGraphic.cs +++ b/Ambermoon.Data.Common/Enumerations/UIGraphic.cs @@ -59,15 +59,15 @@ public enum UIGraphic Dawn, ButtonFrame, ButtonFramePressed, - ButtonDisabledOverlay, // 30x4 + ButtonDisabledOverlay, // 32x11 (1-bit) Compass, Attack, // 16x9 Defense, // 16x9 Skull, EmptyCharacterSlot, ItemConsume, // 11 frames with 16x16 pixels - Talisman, // golden symbol / talisman - UnknownChain, // unsure what this is - BorderWithTriangles // two 8x42 border-like images with triangles in it + Talisman, // healer's golden symbol / talisman + Unused, // seems to be unused in original code, 26 bytes + BrokenItemOverlay // 16x16 (1-bit) is colored with color index 26 } } diff --git a/Ambermoon.Data.Legacy/ExecutableData/ExecutableData.cs b/Ambermoon.Data.Legacy/ExecutableData/ExecutableData.cs index 4a4742de..93c8b8b8 100644 --- a/Ambermoon.Data.Legacy/ExecutableData/ExecutableData.cs +++ b/Ambermoon.Data.Legacy/ExecutableData/ExecutableData.cs @@ -144,6 +144,9 @@ public ExecutableData(List hunks) dataHunkIndex = 0; UIGraphics = Read(dataHunkReaders, ref dataHunkIndex); + // Here follows the note period table for Sonic Arranger (110 words) + // Then the vibrato table (258 bytes) + // Then track data and many more SA tables dataHunkIndex = 1; var reader = dataHunkReaders[1]; diff --git a/Ambermoon.Data.Legacy/ExecutableData/UIGraphics.cs b/Ambermoon.Data.Legacy/ExecutableData/UIGraphics.cs index b94f779d..48a91eea 100644 --- a/Ambermoon.Data.Legacy/ExecutableData/UIGraphics.cs +++ b/Ambermoon.Data.Legacy/ExecutableData/UIGraphics.cs @@ -94,10 +94,16 @@ Graphic ReadOpaqueGraphic(IDataReader dataReader) graphicInfo.GraphicFormat = GraphicFormat.Palette3Bit; graphicInfo.PaletteOffset = 24; entries.Add(UIGraphic.Ouch, ReadGraphic(dataReader)); - graphicInfo.Width = 16; - graphicInfo.Height = 60; - entries.Add(UIGraphic.StarBlinkAnimation, ReadGraphic(dataReader)); + graphicInfo.Height = 9; + graphicInfo.GraphicFormat = GraphicFormat.Palette5Bit; + graphicInfo.PaletteOffset = 0; + var frames = new Graphic(64, 9, 0); + for (uint i = 0; i < 4; ++i) + frames.AddOverlay(i * 16u, 0u, ReadGraphic(dataReader), false); + entries.Add(UIGraphic.StarBlinkAnimation, frames); + graphicInfo.GraphicFormat = GraphicFormat.Palette3Bit; + graphicInfo.PaletteOffset = 24; graphicInfo.Height = 40; entries.Add(UIGraphic.PlusBlinkAnimation, ReadGraphic(dataReader)); graphicInfo.Height = 36; @@ -166,14 +172,32 @@ Graphic ReadOpaqueGraphic(IDataReader dataReader) graphicInfo.GraphicFormat = GraphicFormat.Palette5Bit; graphicInfo.PaletteOffset = 0; entries.Add(UIGraphic.Talisman, ReadGraphic(dataReader)); - graphicInfo.Width = 16; - graphicInfo.Height = 47; - graphicInfo.GraphicFormat = GraphicFormat.Palette3Bit; - graphicInfo.PaletteOffset = 24; - entries.Add(UIGraphic.UnknownChain, ReadGraphic(dataReader)); - graphicInfo.Width = 8; - graphicInfo.Height = 84; - entries.Add(UIGraphic.BorderWithTriangles, ReadGraphic(dataReader)); + var unused = new Graphic(16, 13, 0); + for (int y = 0; y < 13; ++y) + { + var bits = dataReader.ReadWord(); + + for (int x = 0; x < 16; ++x) + { + if ((bits & 0x8000) != 0) + unused.Data[y * 16 + x] = 28; + bits <<= 1; + } + } + entries.Add(UIGraphic.Unused, unused); + var brokenOverlay = new Graphic(16, 16, 0); + for (int y = 0; y < 16; ++y) + { + var bits = dataReader.ReadWord(); + + for (int x = 0; x < 16; ++x) + { + if ((bits & 0x8000) != 0) + brokenOverlay.Data[y * 16 + x] = 26; + bits <<= 1; + } + } + entries.Add(UIGraphic.BrokenItemOverlay, brokenOverlay); // TODO: use it } } } diff --git a/ToDo.md b/ToDo.md index 57bdd4bf..e4ffc335 100644 --- a/ToDo.md +++ b/ToDo.md @@ -1,5 +1,8 @@ ## Battle +- The default monster sprite should not be set to frame 0 but to the first movement animation index instead +- Use animation alternate bits for monsters +- More flames when being hit by fire spells - Vanishing of wind spells looks odd in some cases - Initial scale of dissolve victim has bad anchor behavior if in front row. - While a monster is hurt and moved (wind spells) it shortly changes the frame index back to normal which looks strange