Refactor: Rename `framerate` to `clockSpeed` and add jsdoc annotation

This commit is contained in:
n loewen 2023-08-16 12:58:51 +01:00
parent 1d88d0b5b6
commit 344257a322
1 changed files with 5 additions and 4 deletions

5
cpu.js
View File

@ -300,14 +300,15 @@ async function stepCPU(debug = false) {
/** /**
* @param {Uint8Array} code - Machine code to run * @param {Uint8Array} code - Machine code to run
* @param {Boolean} [debug] - Enable/disable debugging printouts * @param {Boolean} [debug] - Enable/disable debugging printouts
* @param {Number} [clockSpeed] - CPU clock speed in milliseconds
**/ **/
exports.runProgram = (code, debug = false, framerate = 10) => { exports.runProgram = (code, debug = false, clockSpeed = 10) => {
startCPU(code); startCPU(code);
// Animate the output by pausing between steps // Animate the output by pausing between steps
const loop = setInterval(async () => { const loop = setInterval(async () => {
stepCPU(debug); stepCPU(debug);
if (!CPU.running) clearInterval(loop); if (!CPU.running) clearInterval(loop);
}, framerate); }, clockSpeed);
} }