예제 #1
0
 public CPU(int id, CPUMode cpuMode, Router router)
 {
     Id       = id;
     _alu     = new ALU();
     _cpuMode = cpuMode;
     _router  = router;
 }
예제 #2
0
    public SmartCPUBehaviour(IGrid grid, ISetting setting, CPUMode difficulty)
    {
        _grid = grid;
        _gridSimulator = new GridSimulator(grid, setting);
        _outputter = new OutputBestMovement(_gridSimulator);
        _grid.OnGroupAdd += new OnGroupAddEventHandler(OnGroupAddEvent);

        Debug.Log("difficulty " + difficulty + "set");
        switch(difficulty)
        {
            case CPUMode.Easy:
                timeBeforeAction = 0.5f;
                timeBetweenActions = 0.5f;
                break;
            case CPUMode.Normal:
                timeBeforeAction = 0.5f;
                timeBetweenActions = 0.3f;
                break;
            case CPUMode.Hard:
                timeBeforeAction = 0.2f;
                timeBetweenActions = 0.1f;
                break;
            case CPUMode.Kusotuyo:
                timeBeforeAction = 0f;
                timeBetweenActions = 0f;
                break;
        }
    }
예제 #3
0
    public SmartCPUBehaviour(IGrid grid, ISetting setting, CPUMode difficulty)
    {
        _grid             = grid;
        _gridSimulator    = new GridSimulator(grid, setting);
        _outputter        = new OutputBestMovement(_gridSimulator);
        _grid.OnGroupAdd += new OnGroupAddEventHandler(OnGroupAddEvent);

        Debug.Log("difficulty " + difficulty + "set");
        switch (difficulty)
        {
        case CPUMode.Easy:
            timeBeforeAction   = 0.5f;
            timeBetweenActions = 0.5f;
            break;

        case CPUMode.Normal:
            timeBeforeAction   = 0.5f;
            timeBetweenActions = 0.3f;
            break;

        case CPUMode.Hard:
            timeBeforeAction   = 0.2f;
            timeBetweenActions = 0.1f;
            break;

        case CPUMode.Kusotuyo:
            timeBeforeAction   = 0f;
            timeBetweenActions = 0f;
            break;
        }
    }
예제 #4
0
        /// <summary>
        /// Switches the CPU into one of 7 modes. Save the cspr to the spsr, switch to the new mode.
        /// </summary>
        /// <param name="cpuMode"></param>
        public void SwitchCPUMode(CPSR.CPUModeEnum cpuMode)
        {
            //save the current cspr register into the spsr table based on the current mode
            _spsr[(int)cpuMode] = Flags;

            //switch cpu to the new mode
            mCPUMode = new CPUMode(cpuMode);
        }//SetCPUMode
예제 #5
0
파일: CPU.cs 프로젝트: vosechu/KOS
        public void Boot()
        {
            Mode = CPUMode.READY;

            Push(new InterpreterBootup(this));

            SelectedVolume = Volumes.Count > 1 ? Volumes[1] : Volumes[0];
        }
예제 #6
0
        }//SetCPUMode

        /// <summary>
        /// Restore the cpu back to its original mode before the interrupt occurred.
        /// Retrieve the cpsr back from the spsr table based on the current cpu mode and restore cpsr.
        /// Based on the mode in the cpsr, switch the cpu back to that mode.
        /// </summary>
        public void RestoreCPUMode()
        {
            //retrieve the original cpsr back from the spsr table
            uint cpsr = _spsr[(int)mCPUMode.Mode];

            Flags = cpsr;

            //switch the cpu back to the original mode from the mode bits in the cpsr
            mCPUMode = CPUMode.bitsTocpuMode(cpsr);
        } //SetCPUModeReturn
예제 #7
0
    public void Initialize()
    {
        Debug.Log("Game Setting Initializer called");
        GameStartSettingValues settingValues = FindObjectOfType <GameStartSettingValues>();

        if (settingValues != null)
        {
            cpuDifficulty = settingValues.difficulty;
        }
        gameTextManager = new GameTextManager(gameTextComponents);
    }
예제 #8
0
파일: CPU.cs 프로젝트: vosechu/KOS
        public bool IsAlive()
        {
            var partState = ((IProcessorModule)parent).part.State;

            if (partState == PartStates.DEAD)
            {
                Mode = CPUMode.OFF;
                return(false);
            }

            return(true);
        }
예제 #9
0
 public void ChangeCPUMode(CPUMode mode)
 {
     switch (mode)
     {
         case CPUMode.None:
             _behaviour = new NullBehaviour();
             break;
         case CPUMode.Easy:
         case CPUMode.Normal:
         case CPUMode.Hard:
         case CPUMode.Kusotuyo:
             _behaviour = new SmartCPUBehaviour(_grid, _setting, mode);
             break;
     }
 }
예제 #10
0
    public void ChangeCPUMode(CPUMode mode)
    {
        switch (mode)
        {
        case CPUMode.None:
            _behaviour = new NullBehaviour();
            break;

        case CPUMode.Easy:
        case CPUMode.Normal:
        case CPUMode.Hard:
        case CPUMode.Kusotuyo:
            _behaviour = new SmartCPUBehaviour(_grid, _setting, mode);
            break;
        }
    }
예제 #11
0
파일: CPU.cs 프로젝트: vosechu/KOS
        public override void SendMessage(SystemMessage message)
        {
            switch (message)
            {
            case SystemMessage.SHUTDOWN:
                ChildContext = null;
                Mode         = CPUMode.OFF;
                break;

            case SystemMessage.RESTART:
                ChildContext = null;
                Boot();
                break;

            default:
                base.SendMessage(message);
                break;
            }
        }
예제 #12
0
파일: CPU.cs 프로젝트: vosechu/KOS
        public void ProcessElectricity(Part part, float time)
        {
            if (Mode == CPUMode.OFF)
            {
                return;
            }

            var electricReq = time * selectedVolume.RequiredPower();
            var result      = part.RequestResource("ElectricCharge", electricReq) / electricReq;

            var newMode = (result < 0.5f) ? CPUMode.STARVED : CPUMode.READY;

            if (newMode == CPUMode.READY && Mode == CPUMode.STARVED)
            {
                Boot();
            }

            Mode = newMode;
        }
예제 #13
0
        /// <summary>
        /// Perform a reset operation. Put CPSR into a default state
        /// </summary>
        public void Reset()
        {
            //all CPSR flags to false
            _negative.State = false;
            _zero.State     = false;
            _carry.State    = false;
            _overflow.State = false;

            //disable all interrupts
            _irqDisable.State = true;
            _fiqDisable.State = true;

            //ARM (non-Thumb) mode of execution
            _thumb.State = false;

            //cpu mode to system
            mCPUMode = new CPUMode(DefaultMode);

            //clear out spsr registers to 0
            Array.Clear(_spsr, 0, _spsr.Length);
        }//Reset
예제 #14
0
 public void Initialize()
 {
     Debug.Log("Game Setting Initializer called");
     GameStartSettingValues settingValues = FindObjectOfType<GameStartSettingValues>();
     if(settingValues!= null)
     {
         cpuDifficulty = settingValues.difficulty;
     }
     gameTextManager = new GameTextManager(gameTextComponents);
 }