/// <summary> /// Creates selected command instance /// </summary> /// <param name="operation">Operation type</param> /// <param name="mathUnit">Math unit</param> /// <returns>Command instance</returns> public static Command Create(string operation, MathUnit mathUnit) { Command command = null; switch (operation) { case "+": command = new AdditionCommand(mathUnit); break; case "-": command = new SubtractCommand(mathUnit); break; case "*": command = new MultiplicationCommand(mathUnit); break; case "/": command = new DivisionCommand(mathUnit); break; case "pow": command = new PowCommand(mathUnit); break; case "extract": command = new ExtractCommand(mathUnit); break; case "round": command = new RoundCommand(mathUnit); break; case "exp": command = new ExpCommand(mathUnit); break; case "log": command = new LogCommand(mathUnit); break; } return(command); }
public Emulator(GraphicsBackend graphics, AudioBackend audio, InputBackend input) { GraphicsBackend = graphics; AudioBackend = audio; InputBackend = input; graphics.Emulator = this; audio.Emulator = this; input.Emulator = this; units.Add(Memory = new MemoryUnit(this)); units.Add(Graphics = new GraphicsUnit(this)); units.Add(Audio = new AudioUnit(this)); units.Add(Math = new MathUnit(this)); units.Add(Input = new InputUnit(this)); units.Add(CartridgeLoader = new CartridgeUnit(this)); foreach (var unit in units) { unit.Init(); } }
/// <summary> /// Executes command /// </summary> public override void Execute() { initialValue = MathUnit.Result; MathUnit.RunBinary("/", ParameterValue); }
/// <summary> /// Creates instance of the DivisionCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public DivisionCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }
/// <summary> /// Executes command /// </summary> public override void Execute() { initialValue = MathUnit.Result; MathUnit.RunUnary("exp"); }
/// <summary> /// Creates instance of the ExpCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public ExpCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }
/// <summary> /// Creates instance of the MultiplicationCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public MultiplicationCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }
/// <summary> /// Creates instance of the LogCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public LogCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }
/// <summary> /// Creates instance of the AdditionCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public AdditionCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }
/// <summary> /// Creates instance of the ExtractCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public ExtractCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }
/// <summary> /// Creates instance of the PowCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public PowCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }
/// <summary> /// Creates instance of the RoundCommand class /// </summary> /// <param name="mathUnit">Math unit</param> public RoundCommand(MathUnit mathUnit) { this.MathUnit = mathUnit; }