Skip to content
Snippets Groups Projects
Verified Commit 7510dac1 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: more engine info fps set to zero

parent ebe421c1
No related branches found
No related tags found
No related merge requests found
Pipeline #680 passed
......@@ -21,7 +21,7 @@
<div id="section-diag" class="section">
<dl class="diag">
<dt>Engine</dt>
<dd>NEO</dd>
<dd id="engine">-</dd>
<dt>ROM</dt>
<dd id="rom-name">-</dd>
<dt>ROM Size</dt>
......@@ -32,7 +32,7 @@
<span id="logic-frequency">-</span> Hz
<span id="logic-frequency-plus" class="tiny-button tiny-button-right">+</span></dd>
<dt>Framerate</dt>
<dd><span id="fps-count">60</span> fps</dd>
<dd><span id="fps-count">-</span> fps</dd>
</dl>
</div>
<div id="separator-diag" class="separator"></div>
......
......@@ -82,7 +82,7 @@ const state: State = {
paused: false,
background_index: 0,
nextTickTime: 0,
fps: VISUAL_HZ,
fps: 0,
frameStart: new Date().getTime(),
frameCount: 0,
romName: null,
......@@ -187,11 +187,6 @@ const start = async ({ romPath = ROM_PATH, engine = "neo" } = {} ) => {
const arrayBuffer = await blob.arrayBuffer();
const data = new Uint8Array(arrayBuffer);
// updates the ROM information on display
setRom(romName, data.length);
setLogicFrequency(state.logicFrequency);
setFps(state.fps);
// selects the proper engine for execution
// and builds a new instance of it
switch(engine) {
......@@ -208,6 +203,13 @@ const start = async ({ romPath = ROM_PATH, engine = "neo" } = {} ) => {
// a valid state ready to be used
state.chip8.reset_hard_ws();
state.chip8.load_rom_ws(data);
// updates the complete set of global information that
// is going to be displayed
setEngine(engine);
setRom(romName, data.length);
setLogicFrequency(state.logicFrequency);
setFps(state.fps);
}
const register = async () => {
......@@ -413,6 +415,11 @@ const showToast = async (message: string, error = false, timeout = 3500) => {
}, timeout);
}
const setEngine = (name: string, upper = true) => {
name = upper ? name.toUpperCase() : name;
document.getElementById("engine").textContent = name;
};
const setRom = (name: string, size: number) => {
state.romName = name;
state.romSize = size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment