From 73106d1c66b0a172a3ec4b251a70cf119ae1dbdd Mon Sep 17 00:00:00 2001 From: Apexo Date: Fri, 3 Apr 2026 19:32:36 +0200 Subject: onBeforeInterrupt callback --- src/cpu/cpu.ts | 7 +++++++ 1 file changed, 7 insertions(+) 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 @@ -93,6 +93,12 @@ export class CPU { /* empty by default */ }; + /** + * This function is called before handling an interrupt. Useful for clearing sleep + * states. + */ + onBeforeInterrupt = () => {}; + /** * Program counter */ @@ -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); -- cgit v1.2.3