diff --git a/SpriteCompiler/Problem/CodeSequence.cs b/SpriteCompiler/Problem/CodeSequence.cs index a4857ce..87d359f 100644 --- a/SpriteCompiler/Problem/CodeSequence.cs +++ b/SpriteCompiler/Problem/CodeSequence.cs @@ -48,6 +48,7 @@ namespace SpriteCompiler.Problem { _.A = _.A.Add(offset); _.S = _.A; + _.AllowModeChange = true; }); } diff --git a/SpriteCompiler/Problem/SpriteGeneratorState.cs b/SpriteCompiler/Problem/SpriteGeneratorState.cs index 3b0cc3b..399473b 100644 --- a/SpriteCompiler/Problem/SpriteGeneratorState.cs +++ b/SpriteCompiler/Problem/SpriteGeneratorState.cs @@ -82,7 +82,7 @@ public override string ToString() { - return String.Format("A = {0:X4}, X = {1}, Y = {2}, S = {3}, D = {4}, P = {5:X2}", A, X, Y, S, D, P); + return String.Format("A = {0:X4}, X = {1}, Y = {2}, S = {3}, D = {4}, P = {5:X2}, Change? = {6}", A, X, Y, S, D, P, AllowModeChange); } public void RemoveWord(ushort offset) diff --git a/SpriteCompiler/Problem/SpriteGeneratorSuccessorFunction.cs b/SpriteCompiler/Problem/SpriteGeneratorSuccessorFunction.cs index 3d9e701..f13bb16 100644 --- a/SpriteCompiler/Problem/SpriteGeneratorSuccessorFunction.cs +++ b/SpriteCompiler/Problem/SpriteGeneratorSuccessorFunction.cs @@ -108,7 +108,7 @@ // a second stack adjustment. // // 3. Set the stack to the first, right-most offset that end a sequence of solid bytes - if (!state.S.IsScreenOffset && state.A.IsScreenOffset) + if (!state.S.IsScreenOffset && state.A.IsScreenOffset && state.LongA) { // If the first byte is within 255 bytes of the accumulator, propose setting // the stack to the accumulator value @@ -136,7 +136,7 @@ // If the first byte is 256 bytes or more ahead of the current stack location, // then we need to advance var firstByteDistance = firstByte.Offset - state.S.Value; - if (state.S.IsScreenOffset && firstByteDistance >= 256) + if (state.S.IsScreenOffset && firstByteDistance >= 256 && state.LongA) { // Go to the next byte, or the first solid edge yield return state.Apply(new MOVE_STACK(firstByteDistance)); @@ -297,9 +297,6 @@ yield return state.Apply(new SHORT_M()); } } - - Done: - var z = 0; z += 1; } private static bool IsSolidPair(Tuple pair) @@ -340,7 +337,7 @@ trigger = true; } - if (item.Mask != 0x00 && trigger) + if ((item.Mask != 0x00 || (item.Offset - last.Offset) > 1) && trigger) { return new SolidRun(first, last); }