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