diff options
Diffstat (limited to 'src/cpu/cpu.ts')
| -rw-r--r-- | src/cpu/cpu.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cpu/cpu.ts b/src/cpu/cpu.ts index 6da0fee..1237f0a 100644 --- a/src/cpu/cpu.ts +++ b/src/cpu/cpu.ts @@ -94,6 +94,12 @@ export class CPU { }; /** + * This function is called before handling an interrupt. Useful for clearing sleep + * states. + */ + onBeforeInterrupt = () => {}; + + /** * Program counter */ pc: u32 = 0; @@ -291,6 +297,7 @@ export class CPU { const { nextInterrupt } = this; if (this.interruptsEnabled && nextInterrupt >= 0) { const interrupt = this.pendingInterrupts[nextInterrupt]!; + this.onBeforeInterrupt(); avrInterrupt(this, interrupt.address); if (!interrupt.constant) { this.clearInterrupt(interrupt); |
