mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-04-26 08:18:18 -05:00
bugfixes from discord
This commit is contained in:
parent
f0a1d4420f
commit
1937ea2684
|
|
@ -1,10 +1,10 @@
|
||||||
using HavenSoft.HexManiac.Core.Models.Runs;
|
using HavenSoft.HexManiac.Core.Models.Runs;
|
||||||
using HavenSoft.HexManiac.Core.ViewModels;
|
using HavenSoft.HexManiac.Core.ViewModels;
|
||||||
|
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
|
|
||||||
|
|
||||||
namespace HavenSoft.HexManiac.Core.Models.Code {
|
namespace HavenSoft.HexManiac.Core.Models.Code {
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
|
||||||
if (Type == ArgType.Byte) {
|
if (Type == ArgType.Byte) {
|
||||||
var error = Convert(model, token, out value);
|
var error = Convert(model, token, out value);
|
||||||
if (error != null) return error;
|
if (error != null) return error;
|
||||||
results.Add((byte)(value>>shift));
|
results.Add((byte)(value >> shift));
|
||||||
} else if (Type == ArgType.Short) {
|
} else if (Type == ArgType.Short) {
|
||||||
var error = Convert(model, token, out value);
|
var error = Convert(model, token, out value);
|
||||||
if (error != null) return error;
|
if (error != null) return error;
|
||||||
|
|
@ -242,7 +242,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
|
||||||
labels.AddUnresolvedLabel(token, address);
|
labels.AddUnresolvedLabel(token, address);
|
||||||
value = Pointer.NULL;
|
value = Pointer.NULL;
|
||||||
}
|
}
|
||||||
value -= Pointer.NULL;
|
if (value < 0x02000000) value -= Pointer.NULL;
|
||||||
results.Add((byte)value);
|
results.Add((byte)value);
|
||||||
results.Add((byte)(value >> 0x8));
|
results.Add((byte)(value >> 0x8));
|
||||||
results.Add((byte)(value >> 0x10));
|
results.Add((byte)(value >> 0x10));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using HavenSoft.HexManiac.Core.Models.Code;
|
using HavenSoft.HexManiac.Core.Models.Code;
|
||||||
using HavenSoft.HexManiac.Core.Models.Runs.Factory;
|
|
||||||
using HavenSoft.HexManiac.Core.Models.Runs.Sprites;
|
using HavenSoft.HexManiac.Core.Models.Runs.Sprites;
|
||||||
using HavenSoft.HexManiac.Core.ViewModels;
|
using HavenSoft.HexManiac.Core.ViewModels;
|
||||||
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
|
using HavenSoft.HexManiac.Core.ViewModels.DataFormats;
|
||||||
|
|
@ -380,6 +379,7 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
||||||
for (int j = 0; j < self.ElementCount; j++) {
|
for (int j = 0; j < self.ElementCount; j++) {
|
||||||
var segmentStart = self.Start + j * self.ElementLength + segmentOffset;
|
var segmentStart = self.Start + j * self.ElementLength + segmentOffset;
|
||||||
if (recordSeg.CreateConcrete(model, segmentStart) is not ArrayRunEnumSegment enumSeg || enumSeg.EnumName != baseName) continue;
|
if (recordSeg.CreateConcrete(model, segmentStart) is not ArrayRunEnumSegment enumSeg || enumSeg.EnumName != baseName) continue;
|
||||||
|
if (model.Count < segmentStart + recordSeg.Length) continue;
|
||||||
if (model.ReadMultiByteValue(segmentStart, recordSeg.Length) != index) continue;
|
if (model.ReadMultiByteValue(segmentStart, recordSeg.Length) != index) continue;
|
||||||
yield return (segmentStart, segmentStart + recordSeg.Length - 1);
|
yield return (segmentStart, segmentStart + recordSeg.Length - 1);
|
||||||
}
|
}
|
||||||
|
|
@ -387,6 +387,7 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
||||||
if (self.ElementContent[i] is ArrayRunEnumSegment segment && segment.EnumName == baseName) {
|
if (self.ElementContent[i] is ArrayRunEnumSegment segment && segment.EnumName == baseName) {
|
||||||
for (int j = 0; j < self.ElementCount; j++) {
|
for (int j = 0; j < self.ElementCount; j++) {
|
||||||
var segmentStart = self.Start + j * self.ElementLength + segmentOffset;
|
var segmentStart = self.Start + j * self.ElementLength + segmentOffset;
|
||||||
|
if (model.Count < segmentStart + segment.Length) continue;
|
||||||
if (model.ReadMultiByteValue(segmentStart, segment.Length) != index + segment.ValueOffset) continue;
|
if (model.ReadMultiByteValue(segmentStart, segment.Length) != index + segment.ValueOffset) continue;
|
||||||
yield return (segmentStart, segmentStart + segment.Length - 1);
|
yield return (segmentStart, segmentStart + segment.Length - 1);
|
||||||
}
|
}
|
||||||
|
|
@ -1439,7 +1440,7 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (ElementContentType format, int formatLength, int segmentLength) ExtractSingleFormat(ReadOnlySpan<char> segments,IDataModel model) {
|
private static (ElementContentType format, int formatLength, int segmentLength) ExtractSingleFormat(ReadOnlySpan<char> segments, IDataModel model) {
|
||||||
if (segments.Length >= 2 && MemoryExtensions.Equals(segments.Slice(0, 2), PCSRun.SharedFormatString, StringComparison.Ordinal)) {
|
if (segments.Length >= 2 && MemoryExtensions.Equals(segments.Slice(0, 2), PCSRun.SharedFormatString, StringComparison.Ordinal)) {
|
||||||
var format = ElementContentType.PCS;
|
var format = ElementContentType.PCS;
|
||||||
var formatLength = 2;
|
var formatLength = 2;
|
||||||
|
|
|
||||||
|
|
@ -315,7 +315,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||||
HasMultiplePalettePages &&
|
HasMultiplePalettePages &&
|
||||||
model.GetNextRun(spriteAddress) is ITilemapRun tilemap &&
|
model.GetNextRun(spriteAddress) is ITilemapRun tilemap &&
|
||||||
tilemap.Start == spriteAddress &&
|
tilemap.Start == spriteAddress &&
|
||||||
model.GetNextRun( tilemap.FindMatchingTileset(model)) is ITilesetRun tileset &&
|
model.GetNextRun(tilemap.FindMatchingTileset(model)) is ITilesetRun tileset &&
|
||||||
tileset.TilesetFormat.BitsPerPixel == 4 &&
|
tileset.TilesetFormat.BitsPerPixel == 4 &&
|
||||||
tilemap.BytesPerTile == 2;
|
tilemap.BytesPerTile == 2;
|
||||||
}
|
}
|
||||||
|
|
@ -540,7 +540,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||||
var (x, y) = (point.X, point.Y);
|
var (x, y) = (point.X, point.Y);
|
||||||
xOffset -= x;
|
xOffset -= x;
|
||||||
yOffset -= y;
|
yOffset -= y;
|
||||||
var xPartial = xOffset / SpriteScale;
|
var xPartial = xOffset / SpriteScale;
|
||||||
var yPartial = yOffset / SpriteScale;
|
var yPartial = yOffset / SpriteScale;
|
||||||
SpriteScale += 1;
|
SpriteScale += 1;
|
||||||
var xRange = (int)(PixelWidth * SpriteScale / 2);
|
var xRange = (int)(PixelWidth * SpriteScale / 2);
|
||||||
|
|
@ -790,7 +790,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||||
|
|
||||||
private bool SpriteOnlyExpects16Colors() {
|
private bool SpriteOnlyExpects16Colors() {
|
||||||
var spriteAddress = model.ReadPointer(SpritePointer);
|
var spriteAddress = model.ReadPointer(SpritePointer);
|
||||||
var spriteRun = (ISpriteRun)model.GetNextRun(spriteAddress);
|
var run = model.GetNextRun(spriteAddress);
|
||||||
|
if (run is not ISpriteRun spriteRun) return false;
|
||||||
if (spriteRun is ITilesetRun tileset && tileset.TilesetFormat.BitsPerPixel == 4) return true;
|
if (spriteRun is ITilesetRun tileset && tileset.TilesetFormat.BitsPerPixel == 4) return true;
|
||||||
if (spriteRun is ITilemapRun) return false;
|
if (spriteRun is ITilemapRun) return false;
|
||||||
if (spriteRun.SpriteFormat.BitsPerPixel < 8 && spriteRun.Pages == 1) return true;
|
if (spriteRun.SpriteFormat.BitsPerPixel < 8 && spriteRun.Pages == 1) return true;
|
||||||
|
|
@ -850,7 +851,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||||
drawPoint = new Point(point.X - point.X % drawWidth, point.Y - point.Y % drawHeight);
|
drawPoint = new Point(point.X - point.X % drawWidth, point.Y - point.Y % drawHeight);
|
||||||
|
|
||||||
// allow editing the selected palette to match the tile if a tile is selected
|
// allow editing the selected palette to match the tile if a tile is selected
|
||||||
var pageChange = (int)Math.Floor((float) parent.PaletteIndex(tile[0, 0]) / parent.Palette.Elements.Count);
|
var pageChange = (int)Math.Floor((float)parent.PaletteIndex(tile[0, 0]) / parent.Palette.Elements.Count);
|
||||||
if (!spriteOnlyExpects16Colors && drawWidth == 8 && drawHeight == 8 && pageChange != 0) {
|
if (!spriteOnlyExpects16Colors && drawWidth == 8 && drawHeight == 8 && pageChange != 0) {
|
||||||
parent.PalettePage += pageChange;
|
parent.PalettePage += pageChange;
|
||||||
pageChange = 0;
|
pageChange = 0;
|
||||||
|
|
@ -1399,8 +1400,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||||
} else {
|
} else {
|
||||||
underPixels = new int[selectionWidth, selectionHeight];
|
underPixels = new int[selectionWidth, selectionHeight];
|
||||||
for (int x = 0; x < selectionWidth; x++) for (int y = 0; y < selectionHeight; y++) {
|
for (int x = 0; x < selectionWidth; x++) for (int y = 0; y < selectionHeight; y++) {
|
||||||
underPixels[x, y] = parent.pixels[selectionStart.X + x, selectionStart.Y + y];
|
underPixels[x, y] = parent.pixels[selectionStart.X + x, selectionStart.Y + y];
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.BlockPreview.Set(parent.PixelData, parent.PixelWidth, selectionStart, selectionWidth, selectionHeight);
|
parent.BlockPreview.Set(parent.PixelData, parent.PixelWidth, selectionStart, selectionWidth, selectionHeight);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -902,7 +902,9 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||||
var canvas = new CanvasPixelViewModel(9 * 16, 9 * 16);
|
var canvas = new CanvasPixelViewModel(9 * 16, 9 * 16);
|
||||||
for (int y = 0; y < 9; y++) {
|
for (int y = 0; y < 9; y++) {
|
||||||
for (int x = 0; x < 9; x++) {
|
for (int x = 0; x < 9; x++) {
|
||||||
canvas.Draw(viewModel.BlockRenders[blockMap[x, y] & 0x3FF], x * 16, y * 16);
|
var blockIndex = blockMap[x, y] & 0x3FF;
|
||||||
|
var blockRender = blockIndex < viewModel.BlockRenders.Count ? viewModel.BlockRenders[0] : null;
|
||||||
|
canvas.Draw(blockRender, x * 16, y * 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var spot in GetAllScriptSpots(model, parser, GetAllTopLevelScripts(model), 0x29, 0x2A, 0x2B)) {
|
foreach (var spot in GetAllScriptSpots(model, parser, GetAllTopLevelScripts(model), 0x29, 0x2A, 0x2B)) {
|
||||||
usedFlags.Add(model.ReadMultiByteValue(spot.Address + 1, 2));
|
usedFlags.Add(model.ReadMultiByteValue(spot.Address + 1, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
return usedFlags;
|
return usedFlags;
|
||||||
|
|
@ -241,7 +241,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||||
foreach (var spot in GetAllScriptSpots(model, parser, new[] { start }, 0x8A)) {
|
foreach (var spot in GetAllScriptSpots(model, parser, new[] { start }, 0x8A)) {
|
||||||
var plantID = model[spot.Address + 1];
|
var plantID = model[spot.Address + 1];
|
||||||
var berryID = model[spot.Address + 2];
|
var berryID = model[spot.Address + 2];
|
||||||
results[plantID] = new(spot.Address, berryID - 1);
|
results[plantID] = new(spot.Address, berryID - 1);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
@ -258,7 +258,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||||
// check rematch table
|
// check rematch table
|
||||||
var rematches = model.GetTableModel(HardcodeTablesModel.RematchTable);
|
var rematches = model.GetTableModel(HardcodeTablesModel.RematchTable);
|
||||||
if (rematches != null) {
|
if (rematches != null) {
|
||||||
foreach(var rematch in rematches) {
|
foreach (var rematch in rematches) {
|
||||||
if (!trainerFlags.Contains(rematch.GetValue("match1"))) continue;
|
if (!trainerFlags.Contains(rematch.GetValue("match1"))) continue;
|
||||||
foreach (var match in new[] { "match2", "match3", "match4", "match5", "match6" }.Select(rematch.GetValue)) trainerFlags.Add(match);
|
foreach (var match in new[] { "match2", "match3", "match4", "match5", "match6" }.Select(rematch.GetValue)) trainerFlags.Add(match);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user