public CPU(int id, CPUMode cpuMode, Router router) { Id = id; _alu = new ALU(); _cpuMode = cpuMode; _router = router; }
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; } }
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; } }
/// <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
public void Boot() { Mode = CPUMode.READY; Push(new InterpreterBootup(this)); SelectedVolume = Volumes.Count > 1 ? Volumes[1] : Volumes[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
public void Initialize() { Debug.Log("Game Setting Initializer called"); GameStartSettingValues settingValues = FindObjectOfType <GameStartSettingValues>(); if (settingValues != null) { cpuDifficulty = settingValues.difficulty; } gameTextManager = new GameTextManager(gameTextComponents); }
public bool IsAlive() { var partState = ((IProcessorModule)parent).part.State; if (partState == PartStates.DEAD) { Mode = CPUMode.OFF; return(false); } return(true); }
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; } }
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; } }
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; }
/// <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
public void Initialize() { Debug.Log("Game Setting Initializer called"); GameStartSettingValues settingValues = FindObjectOfType<GameStartSettingValues>(); if(settingValues!= null) { cpuDifficulty = settingValues.difficulty; } gameTextManager = new GameTextManager(gameTextComponents); }