@thenick775/mgba-wasm 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# mGBA-wasm
|
|
2
|
+
|
|
3
|
+
This package is a bundled version of my [mGBA fork](https://github.com/thenick775/mgba/tree/feature/wasm) compiled to webassembly.
|
|
4
|
+
|
|
5
|
+
This core currently powers [gbajs3](https://gba.nicholas-vancise.dev)!
|
|
6
|
+
|
|
7
|
+
To instantiate the emulator using react:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
import mGBA, { type mGBAEmulator } from '@thenick775/mgba-wasm';
|
|
11
|
+
import { useEffect, useState } from 'react';
|
|
12
|
+
|
|
13
|
+
export const useEmulator = (canvas: HTMLCanvasElement | null) => {
|
|
14
|
+
const [emulator, setEmulator] = useState<mGBAEmulator | null>(null);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const initialize = async () => {
|
|
18
|
+
if (canvas) {
|
|
19
|
+
const Module = await mGBA({ canvas });
|
|
20
|
+
|
|
21
|
+
const mGBAVersion =
|
|
22
|
+
Module.version.projectName + ' ' + Module.version.projectVersion;
|
|
23
|
+
console.log(mGBAVersion);
|
|
24
|
+
|
|
25
|
+
await Module.FSInit();
|
|
26
|
+
|
|
27
|
+
setEmulator(Module);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
initialize();
|
|
32
|
+
}, [canvas]);
|
|
33
|
+
|
|
34
|
+
return emulator;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
See the feature/wasm [README](https://github.com/thenick775/mgba/tree/feature/wasm#readme) for further details such as:
|
|
40
|
+
|
|
41
|
+
- available emulator interface methods
|
|
42
|
+
- building from source
|
|
43
|
+
- embedding and usage in vanilla javascript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thenick775/mgba-wasm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "mGBA emulator compiled to webassembly",
|
|
5
5
|
"main": "./dist/mgba.js",
|
|
6
6
|
"types": "./dist/mgba.d.ts",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/thenick775/mgba/issues"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/thenick775/mgba#readme"
|
|
33
|
+
"homepage": "https://github.com/thenick775/mgba/tree/feature/wasm#readme"
|
|
34
34
|
}
|