/** * ARM7TDMI HLE BIOS — High-Level Emulation of GBA BIOS calls * * Instead of running real BIOS ROM, we intercept SWI instructions and * implement the behavior in TypeScript. This is faster and doesn't * require a BIOS dump. * * Reference: GBATEK - GBA BIOS Functions * http://problemkaputt.de/gbatek-gba-bios-functions.htm */ import type { MemoryBus } from '@gba-kit/arm-emulator'; /** * Interface for the CPU that BIOS calls need access to. * Uses duck typing to avoid circular imports with ArmCpu. */ interface BiosCpu { readonly registers: Uint32Array; readonly memory: MemoryBus; } /** * GBA Interrupt Controller memory layout: * 0x04000200 - IE (Interrupt Enable) * 0x04000202 - IF (Interrupt Flags) * 0x04000208 - IME (Interrupt Master Enable) * * BIOS IntrWait mechanics: * The BIOS IRQ handler acknowledges interrupts in IF and also sets bits * at 0x03007FF8 (IWRAM). The IntrWait SWI checks this location. * We implement Halt/IntrWait/VBlankIntrWait by writing to HALTCNT (0x04000301) * which the system bus handles by setting interrupts.halted = true. */ /** * What the HLE BIOS needs from the machine it runs in. Passed per call, so two * `Gba` instances in one process never share state through this module. */ export interface BiosEnv { /** IntrWait: tell the interrupt controller which flags end the halt. */ onIntrWait?(flags: number): void; } /** * Handle a Software Interrupt (SWI) call. * * On GBA, the SWI number is the comment field of the SWI instruction: * - Thumb: bits 7-0 of the instruction * - ARM: bits 23-16 of the instruction * * The caller is responsible for extracting the correct SWI number * before calling this function. * * @param cpu - The CPU instance * @param swiNumber - The SWI function number (0x00-0xFF) * @param env - Hooks back into the machine this call runs in */ export declare function handleSwi(cpu: BiosCpu, swiNumber: number, env?: BiosEnv): void; export {}; //# sourceMappingURL=bios.d.ts.map