@thenick775/mgba-wasm 2.6.0 → 2.7.0-beta.1
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 +5 -3
- package/dist/mgba.d.ts +121 -33
- package/dist/mgba.data +3645 -0
- package/dist/mgba.js +1 -1
- package/dist/mgba.wasm +0 -0
- package/dist/mgba.wasm.map +1 -1
- package/dist/mgba.wrapper.js +14 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -59,6 +59,8 @@ Extract these files from `package/dist/` and serve them from the same origin as
|
|
|
59
59
|
|
|
60
60
|
- `mgba.js`
|
|
61
61
|
- `mgba.wasm`
|
|
62
|
+
- `mgba.data`
|
|
63
|
+
- `mgba.wrapper.js`
|
|
62
64
|
|
|
63
65
|
Then instantiate the emulator as follows:
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ Then instantiate the emulator as follows:
|
|
|
66
68
|
<canvas id="canvas" width="240" height="160"></canvas>
|
|
67
69
|
|
|
68
70
|
<script type="module">
|
|
69
|
-
import mGBA from "./mgba.js";
|
|
71
|
+
import mGBA from "./mgba.wrapper.js";
|
|
70
72
|
|
|
71
73
|
const canvas = document.getElementById("canvas");
|
|
72
74
|
const Module = await mGBA({ canvas });
|
|
@@ -87,7 +89,7 @@ Cross-Origin-Opener-Policy: same-origin
|
|
|
87
89
|
Cross-Origin-Embedder-Policy: require-corp
|
|
88
90
|
```
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
All four files must be same-origin with the page because the threaded runtime starts its pthread worker from `mgba.js`.
|
|
91
93
|
|
|
92
94
|
## API
|
|
93
95
|
|
|
@@ -155,7 +157,7 @@ Callbacks and core settings:
|
|
|
155
157
|
- `setCoreSettings(coreSettings)`
|
|
156
158
|
- `toggleRewind(toggle)`
|
|
157
159
|
|
|
158
|
-
Local link play:
|
|
160
|
+
Local link cable play:
|
|
159
161
|
|
|
160
162
|
- `linkLocalStartSession(options)`
|
|
161
163
|
- `linkLocalStopSession()`
|
package/dist/mgba.d.ts
CHANGED
|
@@ -8,14 +8,15 @@ declare namespace mGBA {
|
|
|
8
8
|
* these are needed for building paths when you’re reading/writing files via `Module.FS`.
|
|
9
9
|
*/
|
|
10
10
|
export interface filePaths {
|
|
11
|
-
root: string;
|
|
12
|
-
cheatsPath: string;
|
|
13
|
-
gamePath: string;
|
|
14
|
-
savePath: string;
|
|
15
|
-
saveStatePath: string;
|
|
16
|
-
screenshotsPath: string;
|
|
17
|
-
patchPath: string;
|
|
18
|
-
autosave: string;
|
|
11
|
+
readonly root: string;
|
|
12
|
+
readonly cheatsPath: string;
|
|
13
|
+
readonly gamePath: string;
|
|
14
|
+
readonly savePath: string;
|
|
15
|
+
readonly saveStatePath: string;
|
|
16
|
+
readonly screenshotsPath: string;
|
|
17
|
+
readonly patchPath: string;
|
|
18
|
+
readonly autosave: string;
|
|
19
|
+
readonly shaderPath: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export type coreCallbacks = {
|
|
@@ -78,7 +79,9 @@ declare namespace mGBA {
|
|
|
78
79
|
export type LinkPlayer = 1 | 2; // TODO: more than 2 player support
|
|
79
80
|
|
|
80
81
|
export type LinkLocalPlayerConfig = {
|
|
82
|
+
/** The file path for the link cable player's ROM */
|
|
81
83
|
romPath: string;
|
|
84
|
+
/** The file path for the link cable player's save data */
|
|
82
85
|
savePath?: string;
|
|
83
86
|
};
|
|
84
87
|
|
|
@@ -88,7 +91,9 @@ declare namespace mGBA {
|
|
|
88
91
|
};
|
|
89
92
|
|
|
90
93
|
export type LinkLocalStatus = {
|
|
94
|
+
/** Whether the local link cable session is currently running. */
|
|
91
95
|
running: boolean;
|
|
96
|
+
/** The current active player in the local link cable session. */
|
|
92
97
|
activePlayer?: LinkPlayer;
|
|
93
98
|
};
|
|
94
99
|
|
|
@@ -133,6 +138,17 @@ declare namespace mGBA {
|
|
|
133
138
|
*/
|
|
134
139
|
rewindBufferInterval?: number;
|
|
135
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Controls the pixel density of the screen allowing for sharper texture rendering.
|
|
143
|
+
*
|
|
144
|
+
* Note: this is _not_ true high resolution upscaling yet, but does facilitate proper pixel scaling.
|
|
145
|
+
*
|
|
146
|
+
* Typical values: `1..16`
|
|
147
|
+
*
|
|
148
|
+
* Default: 1
|
|
149
|
+
*/
|
|
150
|
+
highResolutionScale?: number;
|
|
151
|
+
|
|
136
152
|
/**
|
|
137
153
|
* Requested audio sample rate in Hz for the audio output.
|
|
138
154
|
* The core will attempt to use this rate, actual output depends on
|
|
@@ -231,6 +247,56 @@ declare namespace mGBA {
|
|
|
231
247
|
restoreAutoSaveStateOnLoad?: boolean;
|
|
232
248
|
};
|
|
233
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Options applied while creating an mGBA emulator instance. Only the canvas is required.
|
|
252
|
+
*/
|
|
253
|
+
export interface mGBAInitOptions {
|
|
254
|
+
/**
|
|
255
|
+
* WebGL 2 canvas used by mGBA for video output.
|
|
256
|
+
*/
|
|
257
|
+
canvas: mGBAEmulator["canvas"];
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Resolves URLs for the Wasm binary and other Emscripten runtime assets.
|
|
261
|
+
*/
|
|
262
|
+
locateFile?: EmscriptenModule["locateFile"];
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Runs before C/C++ global initializers, for early filesystem setup.
|
|
266
|
+
*/
|
|
267
|
+
preInit?: EmscriptenModule["preInit"];
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Runs after runtime setup and before mGBA's `main()`.
|
|
271
|
+
*/
|
|
272
|
+
preRun?: EmscriptenModule["preRun"];
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Runs if mGBA's `main()` returns.
|
|
276
|
+
*/
|
|
277
|
+
postRun?: EmscriptenModule["postRun"];
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Receives the reason when the Emscripten runtime aborts.
|
|
281
|
+
*/
|
|
282
|
+
onAbort?: EmscriptenModule["onAbort"];
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Runs after asynchronous runtime initialization has completed.
|
|
286
|
+
*/
|
|
287
|
+
onRuntimeInitialized?: EmscriptenModule["onRuntimeInitialized"];
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Receives standard output from the emulator runtime.
|
|
291
|
+
*/
|
|
292
|
+
print?: EmscriptenModule["print"];
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Receives standard error from the emulator runtime.
|
|
296
|
+
*/
|
|
297
|
+
printErr?: EmscriptenModule["printErr"];
|
|
298
|
+
}
|
|
299
|
+
|
|
234
300
|
export interface mGBAEmulator extends EmscriptenModule {
|
|
235
301
|
// custom methods from preamble
|
|
236
302
|
/**
|
|
@@ -329,21 +395,21 @@ declare namespace mGBA {
|
|
|
329
395
|
listSaves(): string[];
|
|
330
396
|
|
|
331
397
|
/**
|
|
332
|
-
* Loads a
|
|
398
|
+
* Loads a ROM into the emulator and runs the game, optionally overriding the save path used.
|
|
333
399
|
*
|
|
334
|
-
* @param romPath - Path to the
|
|
400
|
+
* @param romPath - Path to the ROM file within the emulated filesystem.
|
|
335
401
|
* @param savePathOverride - Optional override for the save path.
|
|
336
402
|
* @returns True if the game loaded successfully, otherwise false.
|
|
337
403
|
*/
|
|
338
404
|
loadGame(romPath: string, savePathOverride?: string): boolean;
|
|
339
405
|
|
|
340
406
|
/**
|
|
341
|
-
* Starts a local
|
|
407
|
+
* Starts a local link cable session, currently supports two players.
|
|
342
408
|
*/
|
|
343
409
|
linkLocalStartSession(options: LinkLocalStartSessionConfig): boolean;
|
|
344
410
|
|
|
345
411
|
/**
|
|
346
|
-
* Stops the active local
|
|
412
|
+
* Stops the active local link cable session, tears down the local link cable and running games.
|
|
347
413
|
*/
|
|
348
414
|
linkLocalStopSession(): void;
|
|
349
415
|
|
|
@@ -353,7 +419,7 @@ declare namespace mGBA {
|
|
|
353
419
|
linkLocalSetActivePlayer(player: LinkPlayer): void;
|
|
354
420
|
|
|
355
421
|
/**
|
|
356
|
-
* Gets the current local
|
|
422
|
+
* Gets the current local link cable session status, contains the active player and whether a local link cable session is currently running.
|
|
357
423
|
*/
|
|
358
424
|
linkLocalGetStatus(): LinkLocalStatus;
|
|
359
425
|
|
|
@@ -588,40 +654,62 @@ declare namespace mGBA {
|
|
|
588
654
|
*/
|
|
589
655
|
setCoreSettings(coreSettings: coreSettings): void;
|
|
590
656
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
657
|
+
/**
|
|
658
|
+
* Returns a list of available shader paths in the in-memory file system.
|
|
659
|
+
*/
|
|
660
|
+
listShaders(): string[];
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Loads the shader from the specified path.
|
|
664
|
+
*
|
|
665
|
+
* @param shaderPath - Path of shader to load from the in-memory file system.
|
|
666
|
+
*/
|
|
667
|
+
loadShader(shaderPath: string): void;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Unloads the currently active shader.
|
|
671
|
+
*/
|
|
672
|
+
unloadShader(): void;
|
|
596
673
|
|
|
597
674
|
/**
|
|
598
675
|
* Returns common filesystem path strings used by this build.
|
|
599
676
|
*/
|
|
600
677
|
filePaths(): filePaths;
|
|
601
678
|
|
|
679
|
+
// custom variables
|
|
680
|
+
readonly version: {
|
|
681
|
+
readonly projectName: string;
|
|
682
|
+
readonly projectVersion: string;
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* WebGL 2 canvas used by mGBA for video output.
|
|
687
|
+
*/
|
|
688
|
+
readonly canvas: HTMLCanvasElement;
|
|
689
|
+
|
|
602
690
|
/**
|
|
603
691
|
* Last loaded ROM path set after `loadGame` succeeds.
|
|
604
692
|
*/
|
|
605
|
-
gameName?: string;
|
|
693
|
+
readonly gameName?: string;
|
|
606
694
|
|
|
607
695
|
/**
|
|
608
696
|
* Save path used for the current game set after `loadGame` succeeds.
|
|
609
697
|
*/
|
|
610
|
-
saveName?: string;
|
|
698
|
+
readonly saveName?: string;
|
|
611
699
|
|
|
612
700
|
/**
|
|
613
701
|
* Auto save state path and file name used for the current game set after `loadGame` succeeds.
|
|
614
702
|
*/
|
|
615
|
-
autoSaveStateName?: string;
|
|
703
|
+
readonly autoSaveStateName?: string;
|
|
616
704
|
// extra exported runtime methods
|
|
617
|
-
FS: typeof FS;
|
|
705
|
+
readonly FS: typeof FS;
|
|
618
706
|
// SDL2
|
|
619
|
-
SDL2: {
|
|
620
|
-
audio: {
|
|
621
|
-
currentOutputBuffer: AudioBuffer;
|
|
622
|
-
scriptProcessorNode: ScriptProcessorNode;
|
|
707
|
+
readonly SDL2: {
|
|
708
|
+
readonly audio: {
|
|
709
|
+
readonly currentOutputBuffer: AudioBuffer;
|
|
710
|
+
readonly scriptProcessorNode: ScriptProcessorNode;
|
|
623
711
|
};
|
|
624
|
-
audioContext: AudioContext;
|
|
712
|
+
readonly audioContext: AudioContext;
|
|
625
713
|
};
|
|
626
714
|
}
|
|
627
715
|
|
|
@@ -644,14 +732,14 @@ declare namespace mGBA {
|
|
|
644
732
|
* This core uses threads, your app must be served with cross-origin isolation enabled
|
|
645
733
|
* (`COOP: same-origin` + `COEP: require-corp`), otherwise it will not run correctly.
|
|
646
734
|
*
|
|
647
|
-
* @param
|
|
648
|
-
* @param
|
|
649
|
-
* @returns The initialized emulator `Module`.
|
|
735
|
+
* @param moduleOverrides - Emscripten Module overrides.
|
|
736
|
+
* @param moduleOverrides.canvas - Required WebGL 2 canvas element used by mGBA for video output, no webgl initialization needed.
|
|
737
|
+
* @returns The initialized mGBA emulator `Module`.
|
|
650
738
|
*/
|
|
651
739
|
// eslint-disable-next-line import/no-default-export
|
|
652
|
-
export default function mGBA(
|
|
653
|
-
|
|
654
|
-
|
|
740
|
+
export default function mGBA(
|
|
741
|
+
moduleOverrides: mGBAInitOptions,
|
|
742
|
+
): Promise<mGBAEmulator>;
|
|
655
743
|
}
|
|
656
744
|
|
|
657
745
|
export = mGBA;
|