@thenick775/mgba-wasm
TypeScript icon, indicating that this package has built-in type declarations

1.0.20 • Public • Published

mGBA-wasm

This package is a bundled version of my mGBA fork compiled to webassembly.

This core currently powers gbajs3!

To instantiate the emulator using react:

import mGBA, { type mGBAEmulator } from '@thenick775/mgba-wasm';
import { useEffect, useState } from 'react';

export const useEmulator = (canvas: HTMLCanvasElement | null) => {
  const [emulator, setEmulator] = useState<mGBAEmulator | null>(null);

  useEffect(() => {
    const initialize = async () => {
      if (canvas) {
        const Module = await mGBA({ canvas });

        const mGBAVersion =
          Module.version.projectName + ' ' + Module.version.projectVersion;
        console.log(mGBAVersion);

        await Module.FSInit();

        setEmulator(Module);
      }
    };

    initialize();
  }, [canvas]);

  return emulator;
};

See the feature/wasm README for further details such as:

  • available emulator interface methods
  • building from source
  • embedding and usage in vanilla javascript

Package Sidebar

Install

npm i @thenick775/mgba-wasm

Weekly Downloads

107

Version

1.0.20

License

MPL-2.0

Unpacked Size

1.98 MB

Total Files

5

Last publish

Collaborators

  • thenick775