public void Execute(int arg) { try { // Interrupt prüfung-------------------------- int INTCON = readRegister(0x0b); if ((INTCON & 0b1000_0000) == 0b1000_0000)//Global interrupt bit { if ((INTCON & 0b0010_0100) == 0b0010_0100) { //Timer interrupt Stack.Push(pc); pc = 4; INTCON &= ~(1 << 7); writeRegister(0x0b, INTCON); arg = intArg; Console.WriteLine("Timer interrupt"); } else if ((INTCON & 0b0001_0010) == 0b0001_0010) { Stack.Push(pc); pc = 4; INTCON &= ~(1 << 7); writeRegister(0x0b, INTCON); arg = intArg; Console.WriteLine("RB0 Interrupt"); }
public void AddToUndoStack(IUndoRedoItem item) { if (!_isChanging) { _undoStack.Push(item); _redoStack.Clear(); } }
private void PerformRedo() { if (m_redoStack.IsEmpty()) { // nothing to do return; } m_undoStack.Push(m_code); m_code = m_redoStack.Pop(); PerformUndoRedo(m_code); }
internal void MeasureTime() { if (timerStartFrame < 0) { return; } if (startTime == 0) { GL.GetQueryObject(glqueryStart, GetQueryObjectParam.QueryResultNoWait, out startTime); } if (endTime == 0) { GL.GetQueryObject(glqueryEnd, GetQueryObjectParam.QueryResultNoWait, out endTime); } if (startTime > 0 && endTime > 0) { timings.Push((float)((endTime - startTime) * 0.000000001)); frames.Push(timerStartFrame); timerStartFrame = -1; startTime = 0; endTime = 0; } }
/// <summary> /// Log a message to the console (can be multi-line) /// </summary> /// <param name="type">Type of log <see cref="LogType"/></param> /// <param name="msg">Message to log</param> public static void Log(LogType type, object msg) { if (msg == null) { return; } if (!Initialized) { EntryQueue.Enqueue(new KeyValuePair <LogType, object>(type, msg)); return; } string m = WordWrap(msg.ToString(), (int)(Screen.width / Style.CalcSize(new GUIContent("A")).x)); foreach (string line in m.Split('\n')) { var logEntry = new LogEntry(type, line); CmdLog.Push(logEntry); } #if DEBUG var stack = new StackTrace(); var calling = stack.GetFrame(1).GetMethod(); if (calling.DeclaringType == typeof(IGConsole)) { calling = stack.GetFrame(2).GetMethod(); } MDebug.WriteLine($"[IGCONSOLE] {calling}: {msg}"); #endif }
private DropOutStack <char> Initialize(int capacity) { var stackTest = new DropOutStack <char>(capacity); foreach (var ch in DigitsAlphabetsUpper) { stackTest.Push(ch); } return(stackTest); }
public void Undo() { _isChanging = true; IUndoRedoItem item = _undoStack.Pop(); if (item != null) { item.Undo(); _redoStack.Push(item); } _isChanging = false; }
private static void ReadInput() { foreach (char c in Input.inputString) { if (c == '\b') // has backspace/delete been pressed? { if (CurrentCmd.Length != 0) { string firstHalf = CurrentCmd.Substring(0, EditLocation - 1); string secondHalf = CurrentCmd.Substring(EditLocation, CurrentCmd.Length - EditLocation); CurrentCmd = firstHalf + secondHalf; EditLocation--; } } else if (c == 0x7F) // Ctrl + Backspace (erase word) { if (CurrentCmd.Length != 0) { int index = EditLocation; while (index > 0 && Char.IsLetterOrDigit(CurrentCmd.ElementAt(index - 1))) { index--; } if (index == EditLocation && EditLocation > 0) // Delete at least 1 character { index--; } int length = EditLocation - index; string firstHalf = CurrentCmd.Substring(0, index); string secondHalf = CurrentCmd.Substring(EditLocation, CurrentCmd.Length - EditLocation); CurrentCmd = firstHalf + secondHalf; EditLocation -= length; } } else if ((c == '\n') || (c == '\r')) // enter/return { if (!string.IsNullOrEmpty(CurrentCmd.Trim())) { Log(LogType.USERINPUT, "> " + CurrentCmd); History.Push(CurrentCmd); Shell.ExecuteCommand(CurrentCmd); } CurrentCmd = ""; EditLocation = 0; } else if ((KeyCode)c != ModInput.GetBindingKey("ToggleConsole")) { CurrentCmd = CurrentCmd.Insert(EditLocation, c.ToString()); EditLocation++; } } }
private void TryUpdateCurrentPitch() { if (_isRecording) { var pitch = AverageOfNonZeroPitches(); if (IsValidPitch(pitch)) { _detectedPitches.Push(pitch); _gameContext.ReplaceCurrentPitch(pitch); } _pitchesThisUpdate.Clear(); } }
public void DropoutTest2() { var stack = new DropOutStack <string>(3); Assert.IsNull(stack.Pop()); stack.Push("A"); stack.Push("B"); stack.Push("C"); stack.Push("D"); Assert.AreEqual("D", stack.Pop()); Assert.AreEqual("C", stack.Pop()); Assert.AreEqual("B", stack.Pop()); Assert.IsNull(stack.Pop()); stack.Push("A"); stack.Push("B"); stack.Push("C"); stack.Push("D"); Assert.AreEqual("D", stack.Pop()); Assert.AreEqual("C", stack.Pop()); Assert.AreEqual("B", stack.Pop()); }
public void AddLastMove(Move move) { _moves.Push(move); }
/// <summary> /// draws the main graph section /// </summary> private void DrawGraph(DrawingContext drawingContext) { if (NetworkFrames.Count <= 1) { return; } RenderOptions.SetEdgeMode(this, EdgeMode.Unspecified); int x = (int)ActualWidth - 1; double yMin = ActualHeight - 1; double yRange = yMin - 3; DesiredNetworkBufferSize = x; NetworkFrame[] frames = NetworkFrames.Take(x).ToArray(); double[] up = new double[Math.Min(x, frames.Length)]; double[] down = new double[Math.Min(x, frames.Length)]; double range = 0; if (RenderMode == RenderingMode.Average && up.Length > c_rollingAveragingRange) { int i = 0; DropOutStack <double> upStack = new DropOutStack <double>(c_rollingAveragingRange); DropOutStack <double> downStack = new DropOutStack <double>(c_rollingAveragingRange); foreach (NetworkFrame frame in frames) { if (i > up.Length) { break; } upStack.Push(frame.Upload); downStack.Push(frame.Download); up[i] = Math.Max(frame.Upload, CalculateRollingAverage(upStack)); down[i] = Math.Max(frame.Download, CalculateRollingAverage(downStack)); range = Math.Max(up[i], Math.Max(down[i], range)); i++; } } else if (RenderMode == RenderingMode.AverageMoving && up.Length > c_movingAveragingRange) { int i = 0; DropOutStack <double> upStack = new DropOutStack <double>(c_movingAveragingRange); DropOutStack <double> downStack = new DropOutStack <double>(c_movingAveragingRange); foreach (NetworkFrame frame in frames) { if (i > up.Length) { break; } upStack.Push(frame.Upload); downStack.Push(frame.Download); up[i] = Math.Max(frame.Upload, CalculateMovingAverage(upStack)); down[i] = Math.Max(frame.Download, CalculateMovingAverage(downStack)); range = Math.Max(up[i], Math.Max(down[i], range)); i++; } } else if (RenderMode == RenderingMode.Smart && up.Length > c_movingAveragingRange && up.Length > c_rollingAveragingRange) { // Combine both average and moving average int i = 0; DropOutStack <double> upStack = new DropOutStack <double>(Math.Max(c_movingAveragingRange, c_rollingAveragingRange)); DropOutStack <double> downStack = new DropOutStack <double>(Math.Max(c_movingAveragingRange, c_rollingAveragingRange)); foreach (NetworkFrame frame in frames) { if (i > up.Length) { break; } upStack.Push(frame.Upload); downStack.Push(frame.Download); up[i] = Math.Max(CalculateRollingAverage(upStack), CalculateMovingAverage(upStack)); down[i] = Math.Max(CalculateRollingAverage(downStack), CalculateMovingAverage(downStack)); range = Math.Max(up[i], Math.Max(down[i], range)); i++; } } else if (RenderMode == RenderingMode.Thick && up.Length > c_maxedAveragingRange) { int i = 0; DropOutStack <double> upStack = new DropOutStack <double>(c_maxedAveragingRange); DropOutStack <double> downStack = new DropOutStack <double>(c_maxedAveragingRange); foreach (NetworkFrame frame in frames) { if (i >= up.Length) { break; } upStack.Push(frame.Upload); downStack.Push(frame.Download); up[i] = upStack.Max(); down[i] = downStack.Max(); range = Math.Max(up[i], Math.Max(down[i], range)); i++; } } else // RenderMode == RenderingMode.Direct { int i = 0; foreach (NetworkFrame frame in frames) { if (i > up.Length) { break; } up[i] = frame.Upload; down[i] = frame.Download; range = Math.Max(up[i], Math.Max(down[i], range)); i++; } } for (int i = 0; i < up.Length - 1; i++) { double barRange = down[i] / range; drawingContext.DrawLine(m_downloadPen, new Point(x, yMin), new Point(x, yMin - (yRange * barRange))); barRange = up[i] / range; drawingContext.DrawLine(m_uploadPen, new Point(x, yMin), new Point(x, yMin - (yRange * barRange))); x -= 1; } RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); }
public void Update() { UndoStack.Push(Program.Test.Copy()); RedoStack.Clear(); }
private void UpdateHistory() { history.Push(BuildSaveState()); }