Esempio n. 1
0
        /// <summary>
        /// Ticks the current thread by popping one instruction off the execution stack.
        /// </summary>
        public void Tick()
        {
            if (m_CurrentState != VThreadState.Sleeping && m_CurrentState != VThreadState.IdleForInput)
            {
                IFFDecode P = m_ExecutionStack.Pop();
                int       Op = P.Operand(0); //Operation code.
                int       Param1, Param2 = 0;

                switch (Op)
                {
                case 0:     //Sleep
                    m_SleepCounter = P.Operand(4);
                    m_LastState    = m_CurrentState;
                    m_CurrentState = VThreadState.Sleeping;
                    HasBeenChecked = false;
                    break;

                case 17:     //Idle for input
                    Param1 = P.Operand(4);
                    Param2 = P.Operand(6);

                    if (Param2 != 0)
                    {
                        m_LastState    = m_CurrentState;
                        m_CurrentState = VThreadState.IdleForInput;
                        HasBeenChecked = false;
                    }
                    else
                    {
                        if (m_CurrentState != VThreadState.Sleeping)
                        {
                            m_SleepCounter = Param1;
                            m_LastState    = m_CurrentState;
                            m_CurrentState = VThreadState.Sleeping;
                            HasBeenChecked = false;
                        }
                        else
                        {
                            m_SleepCounter += Param1;
                        }
                    }
                    break;
                }
            }
            else
            {
                if (m_SleepCounter != 0)
                {
                    m_SleepCounter--;
                }
                else
                {
                    m_CurrentState = m_LastState;
                }
            }
        }
Esempio n. 2
0
        public BHAVEdit(Iff IffFile, BHAV CurrentBHAV)
        {
            InitializeComponent();

            m_CurrentBHAV = CurrentBHAV;
            m_Analyzer    = new BHAVAnalyzer(IffFile);

            foreach (byte[] Instruction in m_CurrentBHAV.Instructions)
            {
                IFFDecode DecodedInstruction = new IFFDecode(Instruction);
                m_Analyzer.DecodeInstruction(ref DecodedInstruction);

                m_DecodedInstructions.Add(DecodedInstruction);
                LstInstructions.Items.Add(DecodedInstruction.OutStream.ToString());
            }
        }