using SharpTools; using System.Collections.Generic; using System.Windows.Forms; using System; namespace PPUPlayer { public partial class FormMain : Form { Dictionary> waves = new(); /// /// Snatch Waves /// /// /// private void toolStripButton5_Click(object sender, EventArgs e) { if (Paused && SimulationStarted) { if (wavesControl1.IsSelectedSomething()) { long bias; ValueChangeData[] data = wavesControl1.SnatchSelection(out bias); wavesControl1.ClearSelection(); FormSnatchWaves snatch = new FormSnatchWaves(data); snatch.Show(); } else { MessageBox.Show("Select something first with the left mouse button. A box will appear, then click on Snatch.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { if (backgroundWorker1.IsBusy) { MessageBox.Show("I can't while the worker is running. Pause it first", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Simulation not started", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } private void ResetWaves() { ValueChangeData[] vcd = new ValueChangeData[0]; wavesControl1.PlotWaves(vcd, 0); waves = new(); } private void UpdateWaves() { // Update dump var info = BreaksCore.GetDebugInfo(BreaksCore.DebugInfoType.DebugInfoType_PPU); foreach (var entry in info) { if (SignalFilter(entry)) { if (!waves.ContainsKey(entry.name)) { waves.Add(entry.name, new List()); } waves[entry.name].Add(ToLogicValue((byte)entry.value)); } } // Update waves control ValueChangeData[] vcd = new ValueChangeData[waves.Count]; int i = 0; foreach (var signal in waves.Keys) { vcd[i] = new ValueChangeData(); vcd[i].name = signal; vcd[i].values = waves[signal].ToArray(); i++; } wavesControl1.PlotWaves(vcd, 0); } private LogicValue ToLogicValue(byte val) { if (val == 0) return LogicValue.Zero; else if (val == 1) return LogicValue.One; else if (val == 0xff) return LogicValue.Z; else return LogicValue.X; } private void toolStripButton6_Click(object sender, EventArgs e) { ResetWaves(); } bool SignalFilter (BreaksCore.DebugInfoEntry entry) { if (entry.bits != 1) return false; if (entry.category == BreaksCore.PPU_CLKS_CATEGORY && toolStripButton7.Checked) return true; if (entry.category == BreaksCore.PPU_CPU_CATEGORY && toolStripButton8.Checked) return true; if (entry.category == BreaksCore.PPU_CTRL_CATEGORY && toolStripButton9.Checked) return true; if (entry.category == BreaksCore.PPU_HV_CATEGORY && toolStripButton10.Checked) return true; if (entry.category == BreaksCore.PPU_MUX_CATEGORY && toolStripButton11.Checked) return true; if (entry.category == BreaksCore.PPU_SPG_CATEGORY && toolStripButton12.Checked) return true; if (entry.category == BreaksCore.PPU_CRAM_CATEGORY && toolStripButton13.Checked) return true; if (entry.category == BreaksCore.PPU_VRAM_CATEGORY && toolStripButton14.Checked) return true; if (entry.category == BreaksCore.PPU_FSM_CATEGORY && toolStripButton15.Checked) return true; if (entry.category == BreaksCore.PPU_EVAL_CATEGORY && toolStripButton16.Checked) return true; if (entry.category == BreaksCore.PPU_WIRES_CATEGORY && toolStripButton17.Checked) return true; return false; } private void toolStripButton7_Click(object sender, EventArgs e) { toolStripButton7.Checked = !toolStripButton7.Checked; } private void toolStripButton8_Click(object sender, EventArgs e) { toolStripButton8.Checked = !toolStripButton8.Checked; } private void toolStripButton9_Click(object sender, EventArgs e) { toolStripButton9.Checked = !toolStripButton9.Checked; } private void toolStripButton10_Click(object sender, EventArgs e) { toolStripButton10.Checked = !toolStripButton10.Checked; } private void toolStripButton11_Click(object sender, EventArgs e) { toolStripButton11.Checked = !toolStripButton11.Checked; } private void toolStripButton12_Click(object sender, EventArgs e) { toolStripButton12.Checked = !toolStripButton12.Checked; } private void toolStripButton13_Click(object sender, EventArgs e) { toolStripButton13.Checked = !toolStripButton13.Checked; } private void toolStripButton14_Click(object sender, EventArgs e) { toolStripButton14.Checked = !toolStripButton14.Checked; } private void toolStripButton15_Click(object sender, EventArgs e) { toolStripButton15.Checked = !toolStripButton15.Checked; } private void toolStripButton16_Click(object sender, EventArgs e) { toolStripButton16.Checked = !toolStripButton16.Checked; } private void toolStripButton17_Click(object sender, EventArgs e) { toolStripButton17.Checked = !toolStripButton17.Checked; } } }