API Docs
    Preparing search index...

    Interface mGBAEmulator

    interface mGBAEmulator {
        arguments: string[];
        autoSaveStateName?: string;
        environment: EnvironmentType;
        FAST_MEMORY: number;
        FHEAP: Float64Array;
        filePackagePrefixURL: string;
        FS: typeof FS;
        gameName?: string;
        HEAP: Int32Array;
        HEAP16: Int16Array;
        HEAP32: Int32Array;
        HEAP64: BigInt64Array;
        HEAP8: Int8Array;
        HEAPF32: Float32Array;
        HEAPF64: Float64Array;
        HEAPU16: Uint16Array;
        HEAPU32: Uint32Array;
        HEAPU64: BigUint64Array;
        HEAPU8: Uint8Array;
        IHEAP: Int32Array;
        logReadFiles: boolean;
        noExitRuntime: boolean;
        noInitialRun: boolean;
        onAbort: (what: any) => void;
        onRuntimeInitialized: () => void;
        postRun: (() => void)[];
        preInit: (() => void)[];
        preinitializedWebGLContext: WebGLRenderingContext;
        preinitializedWebGPUDevice: GPUDevice;
        preloadedAudios: any;
        preloadedImages: any;
        preRun: (() => void)[];
        saveName?: string;
        SDL2: {
            audio: {
                currentOutputBuffer: AudioBuffer;
                scriptProcessorNode: ScriptProcessorNode;
            };
            audioContext: AudioContext;
        };
        TOTAL_MEMORY: number;
        TOTAL_STACK: number;
        version: { projectName: string; projectVersion: string };
        wasmBinary: ArrayBuffer;
        _free(ptr: number): void;
        _malloc(size: number): number;
        addCoreCallbacks(coreCallbacks: coreCallbacks): void;
        addOnExit(cb: () => any): void;
        addOnInit(cb: () => any): void;
        addOnPostRun(cb: () => any): void;
        addOnPreMain(cb: () => any): void;
        addOnPreRun(cb: () => any): void;
        autoLoadCheats(): boolean;
        bindKey(bindingName: string, inputName: string): void;
        buttonPress(name: string): void;
        buttonUnpress(name: string): void;
        destroy(object: object): void;
        filePaths(): filePaths;
        forceAutoSaveState(): boolean;
        FSInit(): Promise<void>;
        FSSync(): Promise<void>;
        getAutoSaveState(): { autoSaveStateName: string; data: Uint8Array } | null;
        getFastForwardMultiplier(): number;
        getMainLoopTimingMode(): number;
        getMainLoopTimingValue(): number;
        getPreloadedPackage(
            remotePackageName: string,
            remotePackageSize: number,
        ): ArrayBuffer;
        getSave(): Uint8Array<ArrayBufferLike> | null;
        getVolume(): number;
        instantiateWasm(
            imports: WebAssembly.Imports,
            successCallback: (module: Instance) => void,
        ): Exports | undefined;
        linkLocalGetStatus(): LinkLocalStatus;
        linkLocalSetActivePlayer(player: LinkPlayer): void;
        linkLocalStartSession(options: LinkLocalStartSessionConfig): boolean;
        linkLocalStopSession(): void;
        listRoms(): string[];
        listSaves(): string[];
        loadAutoSaveState(): boolean;
        loadGame(romPath: string, savePathOverride?: string): boolean;
        loadState(slot: number): boolean;
        loadStateSlot(slot: number, flags?: number): boolean;
        locateFile(url: string, scriptDirectory: string): string;
        onCustomMessage(event: MessageEvent): void;
        pauseAudio(): void;
        pauseGame(): void;
        print(str: string): void;
        printErr(str: string): void;
        quickReload(): void;
        quitGame(): void;
        quitMgba(): void;
        resumeAudio(): void;
        resumeGame(): void;
        saveState(slot: number): boolean;
        saveStateSlot(slot: number, flags?: number): boolean;
        screenshot(fileName?: string): boolean;
        setCoreSettings(coreSettings: coreSettings): void;
        setFastForwardMultiplier(multiplier: number): void;
        setLogger(callback: ((entry: LogEntry) => void) | null): void;
        setMainLoopTiming(mode: number, value: number): void;
        setVolume(percent: number): void;
        toggleInput(enabled: boolean): void;
        toggleRewind(enabled: boolean): void;
        uploadAutoSaveState(
            autoSaveStateName: string,
            data: Uint8Array,
        ): Promise<void>;
        uploadCheats(file: File, callback?: () => void): void;
        uploadPatch(file: File, callback?: () => void): void;
        uploadRom(file: File, callback?: () => void): void;
        uploadSaveOrSaveState(file: File, callback?: () => void): void;
        uploadScreenshot(file: File, callback?: () => void): void;
    }

    Hierarchy

    • EmscriptenModule
      • mGBAEmulator
    Index
    arguments: string[]
    autoSaveStateName?: string

    Auto save state path and file name used for the current game set after loadGame succeeds.

    environment: EnvironmentType
    FAST_MEMORY: number
    FHEAP: Float64Array
    filePackagePrefixURL: string
    FS: typeof FS
    gameName?: string

    Last loaded ROM path set after loadGame succeeds.

    HEAP: Int32Array
    HEAP16: Int16Array
    HEAP32: Int32Array
    HEAP64: BigInt64Array
    HEAP8: Int8Array
    HEAPF32: Float32Array
    HEAPF64: Float64Array
    HEAPU16: Uint16Array
    HEAPU32: Uint32Array
    HEAPU64: BigUint64Array
    HEAPU8: Uint8Array
    IHEAP: Int32Array
    logReadFiles: boolean
    noExitRuntime: boolean
    noInitialRun: boolean
    onAbort: (what: any) => void
    onRuntimeInitialized: () => void
    postRun: (() => void)[]
    preInit: (() => void)[]
    preinitializedWebGLContext: WebGLRenderingContext
    preinitializedWebGPUDevice: GPUDevice
    preloadedAudios: any
    preloadedImages: any
    preRun: (() => void)[]
    saveName?: string

    Save path used for the current game set after loadGame succeeds.

    SDL2: {
        audio: {
            currentOutputBuffer: AudioBuffer;
            scriptProcessorNode: ScriptProcessorNode;
        };
        audioContext: AudioContext;
    }
    TOTAL_MEMORY: number
    TOTAL_STACK: number
    version: { projectName: string; projectVersion: string }
    wasmBinary: ArrayBuffer
    • Parameters

      • ptr: number

      Returns void

    • Parameters

      • size: number

      Returns number

    • Registers core callbacks for emulator lifecycle and custom events.

      Parameters

      Returns void

    • Parameters

      • cb: () => any

      Returns void

    • Parameters

      • cb: () => any

      Returns void

    • Parameters

      • cb: () => any

      Returns void

    • Parameters

      • cb: () => any

      Returns void

    • Parameters

      • cb: () => any

      Returns void

    • Attempts to automatically load cheats for the currently loaded game.

      Returns boolean

      True if cheats were loaded successfully, otherwise false.

    • Binds a physical key (SDL key name) to a GBA input action.

      Parameters

      • bindingName: string

        SDL key name (ex. "Return", "Left", "Keypad X").

      • inputName: string

        GBA input/action (ex. "A", "B", "Start", "Up").

      Returns void

    • Presses a named emulated button.

      Parameters

      • name: string

        Button name to press (ex. "A", "B", "Start", "Select", "Up").

      Returns void

    • Releases (unpress) a named emulated button.

      Parameters

      • name: string

        Button name to release (ex. "A", "B", "Start", "Select", "Up").

      Returns void

    • Parameters

      • object: object

      Returns void

    • Forces an auto save state capture immediately.

      Returns boolean

      True if the auto save state was captured successfully, otherwise false.

    • Initializes the Emscripten filesystem and any runtime FS mounts needed by the emulator.

      Returns Promise<void>

    • Synchronizes filesystem state to the backing store (IDBFS).

      Returns Promise<void>

    • Reads the current auto save state from the filesystem (if present).

      Returns { autoSaveStateName: string; data: Uint8Array } | null

      The auto save state name and bytes, or null if none exists.

    • Gets the current fast forward multiplier.

      • multiplier = 1 = normal speed
      • multiplier > 1 = fast forward (xN)
      • multiplier < 0 = slow down (1/abs(N))

      Returns number

      Current fast forward multiplier.

    • Gets the current main loop timing mode.

      Returns number

      Current timing mode value.

    • Gets the current main loop timing value for the current mode.

      Returns number

      Current timing value.

    • Parameters

      • remotePackageName: string
      • remotePackageSize: number

      Returns ArrayBuffer

    • Reads the currently loaded game save data.

      Returns Uint8Array<ArrayBufferLike> | null

      Save data as bytes, or null if no save exists.

    • Gets the current audio volume multiplier.

      • 1.0 = 100%
      • Range is 0.0..2.0 (0%..200%)

      Returns number

      Current volume multiplier.

    • Parameters

      • imports: WebAssembly.Imports
      • successCallback: (module: Instance) => void

      Returns Exports | undefined

    • Selects which linked player is rendered and controlled by normal input APIs.

      Parameters

      Returns void

    • Stops the active local linked session, tears down the local link and running games.

      Returns void

    • Lists ROM file names under the game directory.

      Returns string[]

      Directory entries from filePaths().gamePath.

    • Lists save file names under the save directory.

      Returns string[]

      Directory entries from filePaths().savePath.

    • Loads the current auto save state (if present).

      Returns boolean

      True if the auto save state loaded successfully, otherwise false.

    • Loads a rom into the emulator and runs the game, optionally overriding the save path used.

      Parameters

      • romPath: string

        Path to the rom file within the emulated filesystem.

      • OptionalsavePathOverride: string

        Optional override for the save path.

      Returns boolean

      True if the game loaded successfully, otherwise false.

    • Loads a save state from a given slot.

      Parameters

      • slot: number

        State slot index.

      Returns boolean

      True if the state loaded successfully, otherwise false.

    • Loads a save state from a given slot using explicit binary literal flags.

      Parameters

      • slot: number

        State slot index.

      • Optionalflags: number

        Bitmask controlling which save state sections are restored.

      Returns boolean

      True if the state loaded successfully, otherwise false.

      Prefer loadState(slot). This is an old/raw API and may be removed in a future major version.

      If flags is omitted, the runtime uses its default load mask.

    • Parameters

      • url: string
      • scriptDirectory: string

      Returns string

    • Parameters

      • event: MessageEvent

      Returns void

    • Pauses audio output without pausing emulation.

      Returns void

    • Pauses the game emulation.

      Returns void

    • Parameters

      • str: string

      Returns void

    • Parameters

      • str: string

      Returns void

    • Performs a quick reload of the current ROM file.

      Returns void

    • Quits the currently running game session.

      Returns void

    • Exits the emulator runtime.

      Returns void

    • Resumes audio output.

      Returns void

    • Resumes game emulation and audio.

      Returns void

    • Saves a save state to a given slot.

      Parameters

      • slot: number

        State slot index.

      Returns boolean

      True if the state saved successfully, otherwise false.

    • Saves a save state to a given slot using explicit binary literal flags.

      Parameters

      • slot: number

        State slot index.

      • Optionalflags: number

        Bitmask controlling which save state sections are written.

      Returns boolean

      True if the state saved successfully, otherwise false.

      Prefer saveState(slot). This is an old/raw API and may be removed in a future major version.

      If flags is omitted, the runtime uses its default save mask.

    • Captures a screenshot and writes it to the screenshots directory.

      Parameters

      • OptionalfileName: string

        Optional custom screenshot file name.

      Returns boolean

      True if screenshot was captured successfully, otherwise false.

    • Applies core settings to the emulator runtime.

      Parameters

      Returns void

    • Sets the current fast forward multiplier.

      • multiplier = 1 = normal speed
      • multiplier > 1 = fast forward (xN)
      • multiplier < 0 = slow down (1/abs(N))

      Parameters

      • multiplier: number

        The fast forward multiplier to apply.

      Returns void

    • Registers a callback for mGBA core log output.

      Use this to capture emulator logs in your application UI, such as a log panel, instead of relying on browser console output alone.

      Passing null removes the custom logger and restores default console logging.

      Parameters

      • callback: ((entry: LogEntry) => void) | null

        Log handler, or null to clear it.

      Returns void

    • Sets the main loop timing mode and value.

      See: emscripten_set_main_loop_timing

      Parameters

      • mode: number

        Timing mode identifier.

      • value: number

        Timing value associated with the mode.

      Returns void

    • Sets the audio volume multiplier.

      • 1.0 = 100%
      • Range is 0.0..2.0 (0%..200%)

      Parameters

      • percent: number

        Volume multiplier to apply.

      Returns void

    • Enables or disables keyboard input handling.

      Parameters

      • enabled: boolean

        If true input is accepted, if false input is ignored.

      Returns void

    • Enables/disables active rewinding while the core is running.

      Parameters

      • enabled: boolean

        If true the core rewinds, if false rewind stops.

      Returns void

    • Uploads auto save state data into the emulator filesystem.

      Parameters

      • autoSaveStateName: string

        Full auto save path to write to.

      • data: Uint8Array

        Raw auto save state bytes.

      Returns Promise<void>

    • Uploads a cheats file into the emulator filesystem.

      Parameters

      • file: File

        Cheats file to upload.

      • Optionalcallback: () => void

        Optional callback fired after upload completes.

      Returns void

    • Uploads a patch file into the emulator filesystem.

      Parameters

      • file: File

        Patch file to upload.

      • Optionalcallback: () => void

        Optional callback fired after upload completes.

      Returns void

    • Uploads a ROM file into the emulator filesystem.

      Parameters

      • file: File

        ROM file to upload.

      • Optionalcallback: () => void

        Optional callback fired after upload completes.

      Returns void

    • Uploads a save or save state file into the emulator filesystem.

      Parameters

      • file: File

        Save or state file to upload.

      • Optionalcallback: () => void

        Optional callback fired after upload completes.

      Returns void

    • Uploads a screenshot file into the emulator filesystem.

      Parameters

      • file: File

        Screenshot file to upload.

      • Optionalcallback: () => void

        Optional callback fired after upload completes.

      Returns void