0.4.14: WireNodes, uS speed in FPS display

This commit is contained in:
MatCat 2021-03-14 13:39:17 -07:00
parent 6bf4c9873f
commit 22e04b2cb9
4 changed files with 43 additions and 5 deletions

View File

@ -1,19 +1,30 @@
# MatCat BrowserLogic # 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 ## 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 ## License
To be decided, but at this moment this code is open source and free to use for non-commercial uses. 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 LZ-String, Copyright 2013 pieroxy under MIT license https://github.com/pieroxy/lz-string/blob/master/LICENSE
## Changelog ## 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 ### 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. * Clicking on an element on the toolbar no longer spawns an element to the work area directly, but rather lets the user place it.

View File

@ -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 { class LogicAND extends Element {
constructor(_Container, RestoreData = null, logicengine,Inputs) { constructor(_Container, RestoreData = null, logicengine,Inputs) {
super(_Container, RestoreData,logicengine,Inputs); super(_Container, RestoreData,logicengine,Inputs);

View File

@ -203,7 +203,7 @@ class LogicEngineSettings {
if (restoresettings) { if (restoresettings) {
let othis = this; let othis = this;
Object.keys(restoresettings).forEach(function(key) { 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; let FPSOffset = 5 - this.Panning.OffsetX;
if (this.Settings.ShowFPS) { if (this.Settings.ShowFPS) {
ct.drawText(this.Ctx, FPSOffset, 15 - this.Panning.OffsetY, "FPS: " + this.FPS, "12px console", "#00ff00"); 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(); let timeCheck = performance.now();
this.FPSCounter++; this.FPSCounter++;
if (!(Math.round(timeCheck - this.LastFPSCheck) % 50)) { if (!(Math.round(timeCheck - this.LastFPSCheck) % 50)) {
let frameTimeUS = (performance.now() - startLoop) * 1000; let frameTimeUS = (performance.now() - startLoop) * 1000;
this.frameTimeUS = frameTimeUS;
let potentialFPS = 1000000 / frameTimeUS; let potentialFPS = 1000000 / frameTimeUS;
this.PotentialFPSAVGs[this.PotentialFPSAVGLoc] = Math.round(potentialFPS); this.PotentialFPSAVGs[this.PotentialFPSAVGLoc] = Math.round(potentialFPS);
this.PotentialFPSAVGLoc++; this.PotentialFPSAVGLoc++;

View File

@ -2,7 +2,7 @@
MatCat BrowserLogic Simulator MatCat BrowserLogic Simulator
*/ */
let Version = "0.4.13"; let Version = "0.4.14";
let spanVersion = document.getElementById("version"); let spanVersion = document.getElementById("version");
spanVersion.innerText = Version; spanVersion.innerText = Version;