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

9
cpu.js
View File

@ -298,16 +298,17 @@ async function stepCPU(debug = false) {
}
/**
* @param {Uint8Array} code - Machine code to run
* @param {Boolean} [debug] - Enable/disable debugging printouts
* @param {Uint8Array} code - Machine code to run
* @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);
// Animate the output by pausing between steps
const loop = setInterval(async () => {
stepCPU(debug);
if (!CPU.running) clearInterval(loop);
}, framerate);
}, clockSpeed);
}