private void SaveButton_OnClick(object sender, RoutedEventArgs e) { var save = new Save { Fakty = Memory.Text, Pravidla = Rules.Text, Vystup = Output.Text }; var dialog = new SaveFileDialog { OverwritePrompt = true, CreatePrompt = false, AddExtension = true, DefaultExt = "xml" }; if (dialog.ShowDialog(this) == true) { using (var stream = File.Create(dialog.FileName)) { try { var serializer = new XmlSerializer(typeof(Save)); serializer.Serialize(stream, save); } catch (Exception ex) { DebugOutput.AppendText(ex + Environment.NewLine); } } } }
private void LoadButton_OnClick(object sender, RoutedEventArgs e) { var dialog = new OpenFileDialog { Multiselect = false, ReadOnlyChecked = true, ShowReadOnly = false, DefaultExt = "xml" }; if (dialog.ShowDialog(this) == true) { using (var stream = File.OpenRead(dialog.FileName)) { var serializer = new XmlSerializer(typeof(Save)); try { var save = serializer.Deserialize(stream) as Save; if (save == null) { return; } Memory.Text = save.Fakty; Rules.Text = save.Pravidla; Output.Text = save.Vystup; DebugOutput.Text = "Uspesne Nacitanie suboru: " + dialog.FileName; } catch (Exception ex) { DebugOutput.AppendText(ex + Environment.NewLine); } } } }
private void SystemTimer_Tick(object sender, EventArgs e) { byte value; value = 0; if (!SingleStep.Checked || allowStep) { computer.cycle(); } if (SingleStep.Checked) { allowStep = false; } if (computer.debugMode) { DebugOutput.AppendText(computer.debug); computer.debug = ""; RegA.Text = computer.memory[0x00].ToString("X2"); RegB.Text = computer.memory[0x01].ToString("X2"); RegX.Text = computer.memory[0x02].ToString("X2"); RegP.Text = computer.memory[0x03].ToString("X2"); RegAF.Text = computer.memory[0x81].ToString("X2"); RegBF.Text = computer.memory[0x82].ToString("X2"); RegXF.Text = computer.memory[0x83].ToString("X2"); } if (computer.running) { value = computer.memory[0x80]; } else { switch (computer.lampMode) { case Cpu.LAMPS_INPUT: value = computer.memory[0xff]; break; case Cpu.LAMPS_ADDRESS: value = computer.addressRegister; break; case Cpu.LAMPS_MEMORY: value = computer.memoryValue; break; default: value = computer.memory[0x80]; break; } } if (value != lastDataLamps) { DataLamp7.Image = ((value & 0x80) != 0) ? images30x30.Images[1] : images30x30.Images[0]; DataLamp6.Image = ((value & 0x40) != 0) ? images30x30.Images[1] : images30x30.Images[0]; DataLamp5.Image = ((value & 0x20) != 0) ? images30x30.Images[1] : images30x30.Images[0]; DataLamp4.Image = ((value & 0x10) != 0) ? images30x30.Images[1] : images30x30.Images[0]; DataLamp3.Image = ((value & 0x08) != 0) ? images30x30.Images[1] : images30x30.Images[0]; DataLamp2.Image = ((value & 0x04) != 0) ? images30x30.Images[1] : images30x30.Images[0]; DataLamp1.Image = ((value & 0x02) != 0) ? images30x30.Images[1] : images30x30.Images[0]; DataLamp0.Image = ((value & 0x01) != 0) ? images30x30.Images[1] : images30x30.Images[0]; lastDataLamps = value; } InputLamp.Image = (computer.lampMode == Cpu.LAMPS_INPUT) ? images30x30.Images[3] : images30x30.Images[2]; AddressLamp.Image = (computer.lampMode == Cpu.LAMPS_ADDRESS) ? images30x30.Images[3] : images30x30.Images[2]; MemoryLamp.Image = (computer.lampMode == Cpu.LAMPS_MEMORY) ? images30x30.Images[3] : images30x30.Images[2]; RunningLamp.Image = (computer.running) ? images30x30.Images[3] : images30x30.Images[2]; }
public void DAdd(string[] data, bool forceFocus = true) { string buff = ""; for (int i = 0; i < data.Length; i++) { buff += $"{i}. {data[i]} "; } DebugOutput.AppendText($"DebugAdd() called ({total}):\r\n{buff}\r\n"); if (forceFocus) Focus(); total++; }
private void SystemTimer_Tick(object sender, EventArgs e) { byte chr; int value; Address4.Value(Computer.Address[3]); Address3.Value(Computer.Address[2]); Address2.Value(Computer.Address[1]); Address1.Value(Computer.Address[0]); Data2.Value(Computer.Data[1]); Data1.Value(Computer.Data[0]); TapeCounter.Text = Computer.TapeDeck.TapeCounter().ToString(); chr = Computer.TeleType.NextPrintByte(); while (chr != 0) { TeleType.AppendText(((char)chr).ToString()); if (tapePunch.Running) { tapePunch.Punch(chr); } chr = Computer.TeleType.NextPrintByte(); } if (tapeReader.Running) { value = tapeReader.Next(); if (value >= 0) { Computer.TeleType.Send((byte)value); } } if (Computer.cpu.Debug && !Computer.cpu.NextStep && !singleStepRead) { DebugA.Text = Computer.cpu.ac.ToString("X2"); DebugX.Text = Computer.cpu.x.ToString("X2"); DebugY.Text = Computer.cpu.y.ToString("X2"); DebugPC.Text = Computer.cpu.pc.ToString("X2"); DebugS.Text = Computer.cpu.sp.ToString("X2"); FlagN.Visible = ((Computer.cpu.flags & 0x80) == 0x80); FlagV.Visible = ((Computer.cpu.flags & 0x40) == 0x40); FlagB.Visible = ((Computer.cpu.flags & 0x10) == 0x10); FlagD.Visible = ((Computer.cpu.flags & 0x08) == 0x08); FlagI.Visible = ((Computer.cpu.flags & 0x04) == 0x04); FlagZ.Visible = ((Computer.cpu.flags & 0x02) == 0x02); FlagC.Visible = ((Computer.cpu.flags & 0x01) == 0x01); DebugOutput.AppendText(Computer.cpu.DebugOutput + "\r\n"); singleStepRead = true; } }
private void WorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs) { Dispatcher.Invoke(() => { Buttons.IsEnabled = false; Memory.IsReadOnly = true; Rules.IsReadOnly = true; }); // Nastala zmena tuto iteraciu? var change = true; // Posledne pouzite pravidlo v predchadzajucej iteracii var lastUsed = _rules.Count; var pocitadlo = 1447; var spravy = new List <string>(2); while (change) { if (pocitadlo-- == 0) { DebugOutput.Dispatcher.Invoke( () => { DebugOutput.AppendText( $"Spracovanie bolo prerušené (Priveľa iterácií).{Environment.NewLine}"); }); return; } change = false; Debug.WriteLine(@"========================================"); for (var i = 0; i < _rules.Count; i++) { if (!change && i > lastUsed) { break; } var rule = _rules[i]; Debug.WriteLine(@"----------------------------------------"); Debug.WriteLine($@"# Spracovavam pravidlo {rule.Name}"); foreach (var @params in rule.Check(GetFakty)) { spravy.Clear(); DebugOutput.Dispatcher.Invoke(() => { DebugOutput.AppendText($@"Pravidlo '{rule.Name}': "); foreach (var param in @params) { DebugOutput.AppendText($@"[{param.Key}]{param.Value} "); } DebugOutput.AppendText(Environment.NewLine); }); var zmena = false; foreach (var action in rule.Actions) { try { if (action.DoWork(@params)) { zmena = true; lastUsed = i; Debug.WriteLine(@"Upravili sa fakty, nastav nutnost dalsej iteracie po aktualne pravidlo (vratane)"); } if (action is Eval eval) { @params.Add(eval.Premenna, eval.Vysledok); } if (action is Sprava sprava) { spravy.Add(sprava.Value); } } catch (Exception ex) { DebugOutput.Dispatcher.Invoke( () => { DebugOutput.AppendText($"Exception: '{ex}'{Environment.NewLine}"); }); return; } } change |= zmena; if (zmena) { foreach (var sprava in spravy) { Output.Dispatcher.Invoke(() => { Output.AppendText(sprava); }); } } } } } }
public void Debug(String msg) { DebugOutput.AppendText(msg + "\r\n"); }