From 22e04b2cb9853c4490d2bb2fe026dec27be3f238 Mon Sep 17 00:00:00 2001 From: MatCat Date: Sun, 14 Mar 2021 13:39:17 -0700 Subject: [PATCH] 0.4.14: WireNodes, uS speed in FPS display --- README.md | 15 +++++++++++++-- js/elements/BasicElements.js | 25 +++++++++++++++++++++++++ js/logicengine.js | 6 ++++-- js/main.js | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b16d587..104cdd0 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,30 @@ # MatCat BrowserLogic -MatCat BrowserLogic https://www.logic.parts/ is a logic simulator written purely in HTML5 / Javascript using 2D Canvas. +MatCat BrowserLogic https://www.logic.parts/ is a logic simulator written purely in HTML5 / Javascript using 2D Canvas. This code will always work standalone, just download and browse to index.html with your favorite browser. + +The goal of this project is to offer a logic simulator that is full featured conceptual simulation of logic. It does not aim to be an electrical simulator, so realistic propagation delays and such are not simulated, however that is not to say that there aren't (as some elements such as clocks and buffers and IC I/O do have delayed buffers). + +I designed this to design CPU's in, I am sure someone with some imagination could design nearly anything in it :). ## Status -This simulator is in extremely early stages, it is not even Alpha at this point but early development. Outside contribution is welcome, please contact me in #LogicParts on Freenode IRC network. +Currently, in pre-alpha early dev stage; however the simulator is about to enter the alpha stage, this means that the simulator core functionality is mostly in place. The Alpha stage will be dedicated to polishing the simulator itself, finding and fixing bugs, introduction of local storage for saves, introduction of server storage, and development of the website including adding integration features. Outside contribution is welcome, please contact me (MatCat) in #LogicParts on Freenode IRC network. ## License To be decided, but at this moment this code is open source and free to use for non-commercial uses. +Copyright (c) 2021, MatCat + LZ-String, Copyright 2013 pieroxy under MIT license https://github.com/pieroxy/lz-string/blob/master/LICENSE ## Changelog +### 0.4.14 + +* Added WireNode element, allows you to better manage wires. Please note that signals only flow in the direction of connection! It is NOT a bidirectional element +* Added draw speed to FPS display (in uS) + ### 0.4.13 * Clicking on an element on the toolbar no longer spawns an element to the work area directly, but rather lets the user place it. diff --git a/js/elements/BasicElements.js b/js/elements/BasicElements.js index 89249a7..52de653 100644 --- a/js/elements/BasicElements.js +++ b/js/elements/BasicElements.js @@ -1,3 +1,28 @@ +class LogicWireNode extends Element { + constructor(_Container, RestoreData = null, logicengine) { + super(_Container, RestoreData,logicengine,1); + this.removeProperty("Inputs"); + this.Name = "WireNode"; + this.Width = 20; + this.Height = 20; + } + getOutput(Output = 0) { + if (Output > 0) return false; + return this.Inputs[0]; + } + drawElement(x,y,ctx) { + if (this.LogicEngine.ActiveContainer !== this._Container) return; // No point if we aren't visible + this.StaticCanvas.width = this.Width; + this.StaticCanvas.height = this.Height; + + this.drawInputs(ctx,x,y,undefined,undefined,undefined,undefined,true); + this.drawOutputs(ctx,x,y,undefined,undefined,undefined,undefined,true); + } +} +let ElementCatalog_WireNode = new ElementCatalog_Element("WireNode","A simple compact wire node for organizing wiring","-O-",LogicWireNode,[]); +ElementReferenceTable.push(ElementCatalog_WireNode); +ElementCategory_Other.addElement(ElementCatalog_WireNode); + class LogicAND extends Element { constructor(_Container, RestoreData = null, logicengine,Inputs) { super(_Container, RestoreData,logicengine,Inputs); diff --git a/js/logicengine.js b/js/logicengine.js index 78d9dda..3d7e615 100644 --- a/js/logicengine.js +++ b/js/logicengine.js @@ -203,7 +203,7 @@ class LogicEngineSettings { if (restoresettings) { let othis = this; Object.keys(restoresettings).forEach(function(key) { - othis[key] = restoresettings[key]; + if (key != "Keybindings") othis[key] = restoresettings[key]; //TODO: Iterate keybindings as well }); } } @@ -653,13 +653,15 @@ class LogicEngine { let FPSOffset = 5 - this.Panning.OffsetX; if (this.Settings.ShowFPS) { ct.drawText(this.Ctx, FPSOffset, 15 - this.Panning.OffsetY, "FPS: " + this.FPS, "12px console", "#00ff00"); - ct.drawText(this.Ctx, FPSOffset, 29 - this.Panning.OffsetY, "Potential FPS: " + Math.floor(this.PotentialFPS), "12px console", "#00ff00"); + ct.drawText(this.Ctx, FPSOffset, 29 - this.Panning.OffsetY, "Draw Speed: " + Math.floor(this.frameTimeUS) + "uS", "12px console", "#00ff00"); + ct.drawText(this.Ctx, FPSOffset, 43 - this.Panning.OffsetY, "Potential FPS: " + Math.floor(this.PotentialFPS), "12px console", "#00ff00"); } let timeCheck = performance.now(); this.FPSCounter++; if (!(Math.round(timeCheck - this.LastFPSCheck) % 50)) { let frameTimeUS = (performance.now() - startLoop) * 1000; + this.frameTimeUS = frameTimeUS; let potentialFPS = 1000000 / frameTimeUS; this.PotentialFPSAVGs[this.PotentialFPSAVGLoc] = Math.round(potentialFPS); this.PotentialFPSAVGLoc++; diff --git a/js/main.js b/js/main.js index af0e06d..5f651b6 100644 --- a/js/main.js +++ b/js/main.js @@ -2,7 +2,7 @@ MatCat BrowserLogic Simulator */ -let Version = "0.4.13"; +let Version = "0.4.14"; let spanVersion = document.getElementById("version"); spanVersion.innerText = Version;