Example #1
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.A = _.S;
     }));
 }
Example #2
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.RemoveWord((ushort)(offset + _.S.Value));
     }));
 }
Example #3
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.RemoveByte((ushort)(_.S.Value));
         _.S = _.S.Add(-1);
     }));
 }
Example #4
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.A = _.A.LoadConstant((_.A.Value & 0xFF00) | value);
         _.RemoveByte((ushort)(offset + _.S.Value));
     }));
 }
Example #5
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.A = Register.UNINITIALIZED;
         _.RemoveByte((ushort)(offset + _.S.Value));
     }));
 }
Example #6
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.P |= 0x10;
         _.AllowModeChange = false;
     }));
 }
Example #7
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.A = _.A.Add(offset);
         _.S = _.A;
         _.AllowModeChange = true;
     }));
 }
Example #8
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.A = _.A.LoadConstant(value);      // Need to be able to track high / low bytes independently...
         _.RemoveByte((ushort)(_.S.Value));
         _.S = _.S.Add(-1);
     }));
 }
Example #9
0
 public override SpriteGeneratorState Apply(SpriteGeneratorState state)
 {
     return(state.Clone(_ =>
     {
         _.A = _.A.LoadConstant(value);
         _.RemoveWord((ushort)(_.S.Value - 1));
         _.S = _.S.Add(-2);
     }));
 }
Example #10
0
        public static SpriteByte?TryGetStackByte(this SpriteGeneratorState state, IDictionary <ushort, SpriteByte> data)
        {
            SpriteByte top;

            if (state.S.IsScreenOffset && data.TryGetValue((ushort)state.S.Value, out top))
            {
                return(top);
            }

            return(null);
        }
Example #11
0
        public static SpriteWord?TryGetStackWord(this SpriteGeneratorState state, IDictionary <ushort, SpriteByte> data, int offset)
        {
            // When we get a word, it's permissible for either the high or low byte to not exist, but not both
            SpriteByte high;
            SpriteByte low;

            // Make sure the range is within bounds
            if (state.S.IsScreenOffset && (state.S.Value + offset) > 0)
            {
                // Try to get the high byte
                byte   high_data   = 0x00;
                byte   high_mask   = 0xFF;
                ushort high_offset = (ushort)(state.S.Value + offset);

                if (data.TryGetValue(high_offset, out high))
                {
                    high_data = high.Data;
                    high_mask = high.Mask;
                }

                // Try to get the low byte
                byte   low_data   = 0x00;
                byte   low_mask   = 0xFF;
                ushort low_offset = (ushort)(state.S.Value + offset - 1);

                if (data.TryGetValue(low_offset, out low))
                {
                    low_data = low.Data;
                    low_mask = low.Mask;
                }

                // At least some data need to be visible
                if (high_mask != 0xFF || low_mask != 0xFF)
                {
                    var word_data = (ushort)(low_data + (high_data << 8));
                    var word_mask = (ushort)(low_mask + (high_mask << 8));

                    return(new SpriteWord(word_data, word_mask, low_offset));
                }
            }

            return(null);
        }
Example #12
0
 // Function to generate a new state based on the code's operation
 public abstract SpriteGeneratorState Apply(SpriteGeneratorState state);
Example #13
0
 public static SpriteWord?TryGetStackWord(this SpriteGeneratorState state, IDictionary <ushort, SpriteByte> data)
 {
     return(TryGetStackWord(state, data, 0));
 }
Example #14
0
 public static Tuple <CodeSequence, SpriteGeneratorState> Apply(this SpriteGeneratorState state, CodeSequence code)
 {
     return(Tuple.Create(code, code.Apply(state)));
 }