SaturnRingLibrary 0.9.2
SGL wrapper
Loading...
Searching...
No Matches

◆ SetHandler()

template<typename Func>
bool SRL::Interrupt::SetHandler ( Vector vector,
Func && handler )
inlinestaticnoexcept

Register an interrupt handler function.

Template Parameters
FuncCallable type (function pointer or stateless lambda)
Parameters
vectorInterrupt vector to set handler for
handlerFunction to call when the interrupt occurs
Returns
true if the handler was set successfully, false if the vector is out of range

Routes to System::SetInterruptHandler() for SCU vectors (0x40-0x4F) or System::SetInterruptVector() for CPU/TRAP vectors (0x60-0x8F). Compile-time checks ensure the callable has the correct signature (void()) and has no captures.

Handler Requirements:
Vector Range Type Lambda? Attribute Required Return
0x40-0x4F SCU Interrupts No Mandatory __attribute__((interrupt_handler)) rte
0x60-0x8F CPU / TRAP Yes (stateless) Not required rts
Warning
SCU interrupts (0x40-0x4F): handlers must be functions (not lambdas) with __attribute__((interrupt_handler)). Lambdas are not allowed for SCU because they cannot have the interrupt attribute and will crash on return. CPU/TRAP handlers (0x60-0x8F) can use lambdas or regular functions.
Example:
// SCU interrupt handler - MANDATORY attribute, NO lambdas
void __attribute__((interrupt_handler)) myVBlankHandler() {
// Handle V-Blank
}
// CPU/TRAP handler - lambdas OK, no attribute needed
// Handle TRAP
});
@ Trap0
TRAP #0 instruction vector (0x80).
Definition srl_interrupt.hpp:354
@ VBlankIn
V-Blank In interrupt vector (0x40).
Definition srl_interrupt.hpp:253
static bool SetHandler(Vector vector, Func &&handler) noexcept
Register an interrupt handler function.
Definition srl_interrupt.hpp:549
See also
System::SetInterruptHandler(), System::SetInterruptVector()