Docs: Add an abandoned interval-timer-based refactor of the main CPU loop to dev notes

This commit is contained in:
n loewen 2023-08-15 17:01:51 +01:00
parent c415056194
commit 1baa0ded32
1 changed files with 16 additions and 1 deletions

View File

@ -34,4 +34,19 @@ Ken Shirriff, [The 6502 overflow flag explained mathematically](https://www.righ
- `23-2F` - reserved for future use / variable storage
- `30 ` - initial value for IP
- `30-80` - free
- `80-FF` - free, can be bank-switched
- `80-FF` - free, can be bank-switched
## Looping using an interval timer
const loop = setInterval(async () => {
step = step + 1;
// Temporary limit as a lazy way to halt infinite loops:
if (CYCLE_LIMIT && (step > CYCLE_LIMIT)) {
console.log('SIMULATION HALTING - reached cycle limit');
clearInterval(loop);
}
if (!CPU.running) clearInterval(loop);
if (CPU.IP >= CPU.memory.length) clearInterval(loop);
stepCPU();
await logCPUState(debug);
}, frameRate);