diff --git a/apple2js.html b/apple2js.html index 6ee1947..1efc2e2 100644 --- a/apple2js.html +++ b/apple2js.html @@ -83,7 +83,7 @@
-
0KHz
+
0 kHz
diff --git a/apple2jse.html b/apple2jse.html index 005c4ae..ecd6fd2 100644 --- a/apple2jse.html +++ b/apple2jse.html @@ -86,7 +86,7 @@
-
0KHz
+
0 kHz
diff --git a/js/apple2.js b/js/apple2.js index ad68106..dc7956e 100644 --- a/js/apple2.js +++ b/js/apple2.js @@ -9,6 +9,7 @@ import SYMBOLS from './symbols'; export function Apple2(options) { var stats = { + frames: 0, renderedFrames: 0 }; @@ -115,6 +116,7 @@ export function Apple2(options) { stats.renderedFrames++; } } + stats.frames++; io.tick(); options.tick(); diff --git a/js/ui/apple2.js b/js/ui/apple2.js index 3309e81..c399d08 100644 --- a/js/ui/apple2.js +++ b/js/ui/apple2.js @@ -17,6 +17,7 @@ var focused = false; var startTime = Date.now(); var lastCycles = 0; var lastFrames = 0; +var lastRenderedFrames = 0; var hashtag; @@ -267,31 +268,44 @@ function openManage() { } var prefs = new Prefs(); -var showFPS = false; +var showStats = 0; export function updateKHz() { var now = Date.now(); var ms = now - startTime; var cycles = cpu.cycles(); var delta; + var fps; + var khz; - if (showFPS) { - delta = stats.renderedFrames - lastFrames; - var fps = parseInt(delta/(ms/1000), 10); - document.querySelector('#khz').innerText = fps + 'fps'; - } else { + switch (showStats) { + case 0: { delta = cycles - lastCycles; - var khz = parseInt(delta/ms); - document.querySelector('#khz').innerText = khz + 'KHz'; + khz = parseInt(delta/ms); + document.querySelector('#khz').innerText = khz + ' kHz'; + break; + } + case 1: { + delta = stats.renderedFrames - lastRenderedFrames; + fps = parseInt(delta/(ms/1000), 10); + document.querySelector('#khz').innerText = fps + ' rps'; + break; + } + default: { + delta = stats.frames - lastFrames; + fps = parseInt(delta/(ms/1000), 10); + document.querySelector('#khz').innerText = fps + ' fps'; + } } startTime = now; lastCycles = cycles; - lastFrames = stats.renderedFrames; + lastRenderedFrames = stats.renderedFrames; + lastFrames = stats.frames; } export function toggleShowFPS() { - showFPS = !showFPS; + showStats = ++showStats % 3; } export function updateSound() {