Beispiel #1
0
 public VM(VMContext context)
 {
     context.VM = this;
     ThreadLock = this;
     this.Context = context;
 }
Beispiel #2
0
        public virtual void Init(VMContext context)
        {
            GenerateTreeByName(context);
            this.Thread = new VMThread(context, this, this.Object.OBJ.StackSize);

            ExecuteEntryPoint(0, context);
            if (Object.OBJ.GUID == 0x98E0F8BD || Object.OBJ.GUID == 0x5D7B6688) //let aquarium & flowers run main
            {
                ExecuteEntryPoint(1, context);
            }
        }
Beispiel #3
0
        public void ExecuteEntryPoint(int entry, VMContext context)
        {
            if (EntryPoints[entry].ActionFunction > 0)
            {
                BHAV bhav;
                GameIffResource CodeOwner;
                ushort ActionID = EntryPoints[entry].ActionFunction;
                if (ActionID < 4096)
                { //global

                    bhav = context.Globals.Resource.Get<BHAV>(ActionID);
                    CodeOwner = context.Globals.Resource;
                }
                else if (ActionID < 8192)
                { //local
                    bhav = Object.Resource.Get<BHAV>(ActionID);
                    CodeOwner = Object.Resource;
                }
                else
                { //semi-global
                    bhav = SemiGlobal.Resource.Get<BHAV>(ActionID);
                    CodeOwner = SemiGlobal.Resource;
                }

                if (bhav == null) throw new Exception("Invalid BHAV call!");

                this.Thread.EnqueueAction(new tso.simantics.engine.VMQueuedAction
                {
                    Callee = this,
                    CodeOwner = CodeOwner,
                    /** Main function **/
                    Routine = context.VM.Assemble(bhav)
                });
            }
        }
Beispiel #4
0
        public void GenerateTreeByName(VMContext context)
        {
            TreeByName = new Dictionary<string, VMTreeByNameTableEntry>();

            var bhavs = Object.Resource.List<BHAV>();
            if (bhavs != null)
            {
                foreach (var bhav in bhavs)
                {
                    TreeByName.Add(bhav.ChunkLabel, new VMTreeByNameTableEntry(bhav, Object.Resource));
                }
            }

            /*bhavs = SemiGlobal.Resource.List<BHAV>();    //Globals and semiglobals not included?
            if (bhavs != null)
            {
                foreach (var bhav in bhavs)
                {
                    TreeByName.Add(bhav.ChunkLabel, new VMTreeByNameTableEntry(bhav, SemiGlobal.Resource));
                }
            }

            bhavs = context.Globals.Resource.List<BHAV>();
            if (bhavs != null)
            {
                foreach (var bhav in bhavs)
                {
                    TreeByName.Add(bhav.ChunkLabel, new VMTreeByNameTableEntry(bhav, context.Globals.Resource));
                }
            }*/
        }
Beispiel #5
0
 public virtual void Init(VMContext context)
 {
     this.Thread = new VMThread(context, this, this.Object.OBJ.StackSize);
 }