Refactor: Rename `framerate` to `clockSpeed` and add jsdoc annotation
This commit is contained in:
parent
1d88d0b5b6
commit
344257a322
9
cpu.js
9
cpu.js
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue