From 9a8736491bcf0f8d97504ce1c9334e7546c735f2 Mon Sep 17 00:00:00 2001 From: MatCat Date: Sun, 7 Mar 2021 21:15:08 -0800 Subject: [PATCH] 0.4.1 Fixed propogation bug with IC's --- README.md | 4 ++++ js/elements.js | 13 ++++++++++++- js/main.js | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e7d6427..0118b43 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.4.1 + +* Fixed a signal propogation bug with IC's + ### 0.4.0 * You can now pan the work area, hold ctrl key while mouse dragging an empty area. diff --git a/js/elements.js b/js/elements.js index 4ebdd41..769f27d 100644 --- a/js/elements.js +++ b/js/elements.js @@ -551,6 +551,8 @@ class ICInput extends Element { if (value === false) this.Input = false; if (value !== false) this.Input = true; + console.log(this.Designator + " setInput " + this.Input + " = " + value); + this.Inputs[0] = this.Input; if (!this.Task.Enabled) { this.Task.LastCall = 0; @@ -630,7 +632,9 @@ class ICOutput extends Element { setInput(notused = 0,value) { if (notused > 0) return; + console.log(this.Designator + " setInput " + notused + " = " + value); value = this._Container.isHigh(this,0); + console.log("Actual " + value); if (value === false) this.Input = false; if (value !== false) this.Input = true; this.Inputs[0] = this.Input; @@ -648,6 +652,8 @@ class ICOutput extends Element { //console.log(this); for (let a = 0; a < this.OutputConnections.length; a++) { this.LogicEngine.RecursionCount = 0; + console.log(this.Designator + " clockTick: Set " + this.OutputConnections[a].Element.Designator + " I[" + this.OutputConnections[a].Input + "] = " + this.getOutput()); + console.log(this._Container); this.OutputConnections[a].Element.setInput(this.OutputConnections[a].Input, this.getOutput()); } } @@ -769,9 +775,13 @@ class ICElement extends Element { setInput(Input, Value) { if (this.InputConnections.length >= Input) { // No need to worry about recursion as this goes to an input element which is buffered + //console.log(this.Designator + " setInput " + Input + " = " + Value); + Value = this._Container.isHigh(this,Input); this.Inputs[Input] = (Value === false) ? false : true; + //console.log("Actual: " + this.Inputs[Input]); //console.log("Calling " + this.InputConnections[Input].toElement.Designator); - this.InputConnections[Input].toElement.setInput(this.InputConnections[Input].Input,Value); + //console.log("Setting " + this.InputConnections[Input].toElement.Designator); + this.InputConnections[Input].toElement.setInput(0,Value); } return false; } @@ -806,6 +816,7 @@ class ICElement extends Element { ctx.arc(x+10,firstY + (a*24),this.inputCircleRadius,0,2*Math.PI); ctx.strokeStyle = borderColor; ctx.fillStyle = circleColorFalse; + //console.log(this.Designator + ": I[" + a + "]: " + this.Inputs[a]); if (this.Inputs[a]) ctx.fillStyle = circleColorTrue; if ((mouseDist <= (this.inputCircleRadius)) && this.LogicEngine.ActiveLink) ctx.fillStyle = circleColorHover; ctx.fill(); diff --git a/js/main.js b/js/main.js index 2fd06f3..4e5cef0 100644 --- a/js/main.js +++ b/js/main.js @@ -2,7 +2,7 @@ MatCat BrowserLogic Simulator */ -let Version = "0.4.0"; +let Version = "0.4.1"; let spanVersion = document.getElementById("version"); spanVersion.innerText = Version; // get the canvas and get the engine object going