mirror of
https://github.com/lscharen/iigs-sprite-compiler.git
synced 2024-08-31 18:29:06 +00:00
Found and fixed search bugs. Path cost is still not being calculated correctly.
This commit is contained in:
parent
e00ae24ab0
commit
b20b85e7bc
@ -27,6 +27,8 @@ namespace SpriteCompiler.Test
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestSingleByteSprite()
|
public void TestSingleByteSprite()
|
||||||
{
|
{
|
||||||
|
Trace.WriteLine("Testing a sprite with just one byte");
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
var problem = SpriteGeneratorSearchProblem.CreateSearchProblem();
|
var problem = SpriteGeneratorSearchProblem.CreateSearchProblem();
|
||||||
var search = SpriteGeneratorSearchProblem.Create();
|
var search = SpriteGeneratorSearchProblem.Create();
|
||||||
|
@ -70,7 +70,7 @@ namespace SpriteCompiler.Problem
|
|||||||
|
|
||||||
public override SpriteGeneratorState Apply(SpriteGeneratorState state)
|
public override SpriteGeneratorState Apply(SpriteGeneratorState state)
|
||||||
{
|
{
|
||||||
return state.Clone(_ => _.P |= 0x10);
|
return state.Clone(_ => _.P &= 0xEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -85,7 +85,7 @@ namespace SpriteCompiler.Problem
|
|||||||
|
|
||||||
public override SpriteGeneratorState Apply(SpriteGeneratorState state)
|
public override SpriteGeneratorState Apply(SpriteGeneratorState state)
|
||||||
{
|
{
|
||||||
return state.Clone(_ => _.P &= 0xEF);
|
return state.Clone(_ => _.P |= 0x10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -40,6 +40,11 @@ namespace SpriteCompiler.Problem
|
|||||||
{
|
{
|
||||||
return value.CompareTo(other.value);
|
return value.CompareTo(other.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return value.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SpriteGeneratorState
|
public class SpriteGeneratorState
|
||||||
@ -141,7 +146,7 @@ namespace SpriteCompiler.Problem
|
|||||||
{
|
{
|
||||||
if (IsUninitialized)
|
if (IsUninitialized)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Cannot add valued to uninitialized registers");
|
throw new ArgumentException("Cannot add value to uninitialized registers");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding a value does not change the tag
|
// Adding a value does not change the tag
|
||||||
@ -178,8 +183,9 @@ namespace SpriteCompiler.Problem
|
|||||||
{
|
{
|
||||||
public bool IsGoal(SpriteGeneratorState state)
|
public bool IsGoal(SpriteGeneratorState state)
|
||||||
{
|
{
|
||||||
// We have reached our goal when there is no data left to display
|
// We have reached our goal when there is no data left to display and we are back in
|
||||||
return state.IsEmpty;
|
// 16-bit mode
|
||||||
|
return state.IsEmpty && state.LongA && state.LongI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,8 +195,7 @@ namespace SpriteCompiler.Problem
|
|||||||
{
|
{
|
||||||
var actions = new List<CodeSequence>();
|
var actions = new List<CodeSequence>();
|
||||||
|
|
||||||
// If the accumulator holds an offset then we could move to any byte position. We do
|
// If the accumulator holds an offset then we could move to any byte position.
|
||||||
// not allow two consecutive MOVE_STACK operations
|
|
||||||
if (state.A.IsScreenOffset && !state.S.IsScreenOffset)
|
if (state.A.IsScreenOffset && !state.S.IsScreenOffset)
|
||||||
{
|
{
|
||||||
foreach (var datum in state.Bytes)
|
foreach (var datum in state.Bytes)
|
||||||
@ -200,7 +205,7 @@ namespace SpriteCompiler.Problem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the accumulator and stack are both initialized, only propose moves to locations
|
// If the accumulator and stack are both initialized, only propose moves to locations
|
||||||
// before and after the current 256 byte window
|
// before and after the current 256 byte stack-relative window
|
||||||
if (state.A.IsScreenOffset && state.S.IsScreenOffset)
|
if (state.A.IsScreenOffset && state.S.IsScreenOffset)
|
||||||
{
|
{
|
||||||
var addr = state.S.Value;
|
var addr = state.S.Value;
|
||||||
@ -230,7 +235,7 @@ namespace SpriteCompiler.Problem
|
|||||||
foreach (var datum in state.Bytes.Where(x => (x.Offset - addr) < 255))
|
foreach (var datum in state.Bytes.Where(x => (x.Offset - addr) < 255))
|
||||||
{
|
{
|
||||||
var offset = datum.Offset - addr;
|
var offset = datum.Offset - addr;
|
||||||
actions.Add(new STACK_REL_8_BIT_IMMEDIATE_STORE((byte)offset, datum.Data));
|
actions.Add(new STACK_REL_8_BIT_IMMEDIATE_STORE(datum.Data, (byte)offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user