From bd8a903aec2d97526a6da266aff555ee600be27c Mon Sep 17 00:00:00 2001 From: MatCat Date: Wed, 3 Mar 2021 19:04:47 -0800 Subject: [PATCH] 0.3.6: Fixed bug with ~Q outputs on flip flops --- README.md | 4 ++++ js/elements.js | 12 ++++++++---- js/main.js | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b67792d..6fad769 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ To be decided, but at this moment this code is open source and free to use for n ## Changelog +### 0.3.6 + +* Fixed a bug where flip flops weren't firing output changes when only !Q changed. + ### 0.3.5 * Fixed a bug where newly linked objects weren't being polled to the proper output diff --git a/js/elements.js b/js/elements.js index 020f28c..1766427 100644 --- a/js/elements.js +++ b/js/elements.js @@ -1193,6 +1193,7 @@ class FlipFlopJK extends Element { setInput(Input, Value) { if (Input >= this.Inputs.length) return false; let oldOutput = this.Outputs[0]; + let oldOutput2 = this.Outputs[1]; this.Inputs[Input] = Value; if (this.Inputs[1]) { if (!this.Inputs[0] && this.Inputs[2]) { @@ -1209,7 +1210,7 @@ class FlipFlopJK extends Element { this.Outputs[1] = !this.Outputs[0]; } } - if (oldOutput != this.getOutput(0)) { + if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) { this.setConnections(); } } @@ -1254,6 +1255,7 @@ class FlipFlopSR extends Element { setInput(Input, Value) { if (Input >= this.Inputs.length) return false; let oldOutput = this.Outputs[0]; + let oldOutput2 = this.Outputs[1]; this.Inputs[Input] = Value; if (this.Inputs[1]) { if (!this.Inputs[0] && this.Inputs[2]) { @@ -1266,7 +1268,7 @@ class FlipFlopSR extends Element { this.Outputs[1] = false; } } - if (oldOutput != this.getOutput(0)) { + if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) { this.setConnections(); } } @@ -1311,12 +1313,13 @@ class FlipFlopT extends Element { setInput(Input, Value) { if (Input >= this.Inputs.length) return false; let oldOutput = this.Outputs[0]; + let oldOutput2 = this.Outputs[1]; this.Inputs[Input] = Value; if (this.Inputs[0] && this.Inputs[1]) { this.Outputs[0] = !this.Outputs[0]; this.Outputs[1] = !this.Outputs[0]; } - if (oldOutput != this.getOutput(0)) { + if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) { this.setConnections(); } } @@ -1361,13 +1364,14 @@ class FlipFlopD extends Element { setInput(Input, Value) { if (Input >= this.Inputs.length) return false; let oldOutput = this.Outputs[0]; + let oldOutput2 = this.Outputs[1]; let oldInput = this.Inputs[1]; this.Inputs[Input] = Value; if (this.Inputs[1] && !oldInput) { this.Outputs[0] = this.Inputs[0]; this.Outputs[1] = !this.Outputs[0]; } - if (oldOutput != this.getOutput(0)) { + if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) { this.setConnections(); } } diff --git a/js/main.js b/js/main.js index 57fff11..facb955 100644 --- a/js/main.js +++ b/js/main.js @@ -2,7 +2,7 @@ MatCat BrowserLogic Simulator */ -let Version = "0.3.5"; +let Version = "0.3.6"; let spanVersion = document.getElementById("version"); spanVersion.innerText = Version; // get the canvas and get the engine object going