Skip to content

Commit

Permalink
Fixed some UI gfx loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrdacor committed Mar 30, 2022
1 parent 3ade1bf commit 0596428
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Ambermoon.Core/Battle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions Ambermoon.Data.Common/Enumerations/UIGraphic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
3 changes: 3 additions & 0 deletions Ambermoon.Data.Legacy/ExecutableData/ExecutableData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ public ExecutableData(List<AmigaExecutable.IHunk> hunks)
dataHunkIndex = 0;

UIGraphics = Read<UIGraphics>(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];
Expand Down
46 changes: 35 additions & 11 deletions Ambermoon.Data.Legacy/ExecutableData/UIGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
}
}
3 changes: 3 additions & 0 deletions ToDo.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0596428

Please sign in to comment.