public CircularStack <T> Copy() { CircularStack <T> copy = new CircularStack <T>(_capacity); copy._usedSize = _usedSize; copy._front = _front; for (int i = 0; i < _capacity; i++) { copy._arr[i] = _arr[i]; } return(copy); }
public AssemblerModel() { _size = 256; // Leave this at 256 (many of our attributes are 8 bit) _memory = new Bit12[_size]; for (int i = 0; i < _size; i++) { _memory[i] = new Bit12(0); } _memoryStack = new MyStack <Bit12>(_memory); _undoStack = new CircularStack <UndoStorage>(1000); _instructionPtr = 0; _workingRegister = new Bit12(0); _input = new Bit12(0); _output = new Bit12(0); _labels = new Dictionary <string, byte>(); resetMemory(); }
public MainWindow() { InitializeComponent(); _assemblerModel = new AssemblerModel(); _assemblerModel.SelfTest(); showMemoryRowNumbers(); _currentTextBox = TextBox_Assembler; updateGUIMemory(0, 255, _currentTextBox); _inputTimerAssembly = new System.Windows.Threading.DispatcherTimer(); _inputTimerMK = new System.Windows.Threading.DispatcherTimer(); _runTimer = new System.Windows.Threading.DispatcherTimer(); _commandWindow = new Commands(); _aboutWin = new About(); Closing += OnClosing; _assemblySaved = true; _mkSaved = true; _keyPressStack = new CircularStack <Key>(20); _password = "******"; _inputTimerAssembly.Interval = new TimeSpan(0, 0, 0, 0, 500); _inputTimerAssembly.Tick += OnInputTimerAssemblyElapsed; _inputTimerMK.Interval = new TimeSpan(0, 0, 0, 0, 500); _inputTimerMK.Tick += OnInputTimerMKElapsed; _runTimer.Interval = new TimeSpan(0, 0, 0, 0, (int)Slider_FastForward.Value); _runTimer.Tick += OnInputTimerRunElapsed; markRow(getMMRowOfPosition(255 - _assemblerModel.instructionPtr())); // Mark current row Slider_FastForward.Value = 200; // Can't be specified in the XAML file, bug ValueRow_WorkingRegister.ShowMemoryAdress(_assemblerModel.workingRegister()); ValueRow_Output.ShowMemoryAdress(_assemblerModel.output()); ValueRow_Input.ShowMemoryAdress(_assemblerModel.input()); ValueRow_InstructionPointer.ShowMemoryAdress(new Bit12(_assemblerModel.instructionPtr())); ValueRow_InstructionPointer.HideChildElements(); EventManager.RegisterClassHandler(typeof(Window), Keyboard.KeyDownEvent, new KeyEventHandler(keyDown), true); }
private void keyDown(object sender, KeyEventArgs e) { _keyPressStack.push(e.Key); CircularStack <Key> stackCopy = _keyPressStack.Copy(); string str = ""; for (int i = 0; i < _password.Length && stackCopy.size() > 0; i++) { str += GetCharFromKey(stackCopy.top()); stackCopy.pop(); } str = new string(str.Reverse().ToArray()); if (str == _password) { MenuItem_Secret.Visibility = Visibility.Visible; MenuItem_Default.IsChecked = false; MenuItem_Visual.IsChecked = false; MenuItem_Dark.IsChecked = false; MenuItem_Secret.IsChecked = true; changeSkin(Skins.Secret); userMsg("Secret skin unlocked!"); } }