Exemple #1
0
 public static void VARI(Game _assets, BinaryReader _reader, Chunk _chunk)
 {
     _assets.LocalVariables    = _reader.ReadInt32();
     _assets.InstanceVariables = _reader.ReadInt32();
     _assets.GlobalVariables   = _reader.ReadInt32();
     while (_reader.BaseStream.Position < _chunk.Base + _chunk.Length)
     {
         LVariable _varGet = new LVariable(_assets, _reader);
         if (_varGet.Count > 0)
         {
             _assets.VariableMapping[_varGet.Offset] = _assets.Variables.Count;
             for (Int32 i = 0; i < _varGet.Count; i++)
             {
                 if (i > 0)
                 {
                     _assets.VariableMapping[_varGet.Offset] = _assets.Variables.Count;
                 }
                 _reader.BaseStream.Seek(_varGet.Offset + 4, SeekOrigin.Begin);
                 _varGet.Offset += _reader.ReadInt32() & 0xFFFF;
             }
         }
         _assets.Variables.Add(_varGet);
         _reader.BaseStream.Seek(_varGet.Base, SeekOrigin.Begin);
         if ((_chunk.Base + _chunk.Length) - _reader.BaseStream.Position < LVariable.Length)
         {
             break;
         }
     }
 }
Exemple #2
0
        public Pop(Int32 _instruction, Game _game, LCode _code, BinaryReader _reader) : base(_instruction)
        {
            this.ArgTo   = (LArgumentType)(this.Argument & 0xF);
            this.ArgFrom = (LArgumentType)((this.Argument >> 4) & 0xF);
            switch (this.ArgTo)
            {
            case LArgumentType.Variable: {
                Int32 _varOffset = (int)((_code.Base + _reader.BaseStream.Position)) - 4;
                this.Variable = _game.Variables[_game.VariableMapping[_varOffset]];
                _reader.ReadInt32();
                break;
            }

            default: {
                throw new Exception(String.Format("Could not pop from {0} to {1}", this.ArgTo, this.ArgFrom));
            }
            }
        }
Exemple #3
0
        public Push(Int32 _instruction, Game _game, LCode _code, BinaryReader _reader) : base(_instruction)
        {
            this.IsArray = false;
            this.Type    = (LArgumentType)this.Argument;
            switch (this.Type)
            {
            case LArgumentType.Error: {
                this.Value = new LValue(LType.Number, (double)this.Data);
                break;
            }

            case LArgumentType.Integer: {
                this.Value = new LValue(LType.Number, (double)_reader.ReadInt32());
                break;
            }

            case LArgumentType.Long: {
                this.Value = new LValue(LType.Number, (double)_reader.ReadInt64());
                break;
            }

            case LArgumentType.Double: {
                this.Value = new LValue(LType.Number, (double)_reader.ReadDouble());
                break;
            }

            case LArgumentType.String: {
                this.Value = new LValue(LType.String, (string)_game.StringMapping[_reader.ReadInt32()].Value);
                break;
            }

            case LArgumentType.Variable: {
                this.Variable = _game.Variables[_game.VariableMapping[(int)((_code.Base + _reader.BaseStream.Position)) - 4]];
                _reader.ReadInt32();
                break;
            }

            default: {
                throw new Exception(String.Format("Could not parse unimplemented push type {0}", this.Type));
            }
            }
        }