@thenick775/mgba-wasm 2.7.0 → 2.7.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/dist/mgba.d.ts +745 -0
- package/dist/mgba.data +3645 -0
- package/dist/mgba.js +2 -0
- package/dist/mgba.wasm +0 -0
- package/dist/mgba.wasm.map +1 -0
- package/dist/mgba.wrapper.js +14 -0
- package/package.json +1 -1
package/dist/mgba.d.ts
ADDED
|
@@ -0,0 +1,745 @@
|
|
|
1
|
+
/// <reference types="emscripten" />
|
|
2
|
+
|
|
3
|
+
declare namespace mGBA {
|
|
4
|
+
/**
|
|
5
|
+
* Common filesystem paths for the embedded virtual file system (IDBFS).
|
|
6
|
+
*
|
|
7
|
+
* These are the mount points/directories created by `FSInit` (ex. `/data/*`, `/autosave`, etc),
|
|
8
|
+
* these are needed for building paths when you’re reading/writing files via `Module.FS`.
|
|
9
|
+
*/
|
|
10
|
+
export interface filePaths {
|
|
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;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type coreCallbacks = {
|
|
23
|
+
/**
|
|
24
|
+
* Callback fired when the emulation core has triggered an alarm.
|
|
25
|
+
*/
|
|
26
|
+
alarmCallback?: (() => void) | null;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Callback fired when the emulation core has crashed.
|
|
30
|
+
*/
|
|
31
|
+
coreCrashedCallback?: (() => void) | null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Callback fired when the emulation core has read input keys.
|
|
35
|
+
*/
|
|
36
|
+
keysReadCallback?: (() => void) | null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Callback fired when the emulation core has updated its save data.
|
|
40
|
+
*/
|
|
41
|
+
saveDataUpdatedCallback?: (() => void) | null;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Callback fired when the emulation core has finished rendering a video frame.
|
|
45
|
+
*/
|
|
46
|
+
videoFrameEndedCallback?: (() => void) | null;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Callback fired when the emulation core has started rendering a video frame.
|
|
50
|
+
*/
|
|
51
|
+
videoFrameStartedCallback?: (() => void) | null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Callback fired when the emulation core has captured an auto save state.
|
|
55
|
+
*/
|
|
56
|
+
autoSaveStateCapturedCallback?: (() => void) | null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Callback fired when the emulation core has finished loading an auto save state.
|
|
60
|
+
*/
|
|
61
|
+
autoSaveStateLoadedCallback?: (() => void) | null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type LogLevel =
|
|
65
|
+
| "FATAL"
|
|
66
|
+
| "ERROR"
|
|
67
|
+
| "WARN"
|
|
68
|
+
| "INFO"
|
|
69
|
+
| "DEBUG"
|
|
70
|
+
| "STUB"
|
|
71
|
+
| "GAME ERROR";
|
|
72
|
+
|
|
73
|
+
export type LogEntry = {
|
|
74
|
+
level: LogLevel;
|
|
75
|
+
category: string;
|
|
76
|
+
message: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type LinkPlayer = 1 | 2; // TODO: more than 2 player support
|
|
80
|
+
|
|
81
|
+
export type LinkLocalPlayerConfig = {
|
|
82
|
+
/** The file path for the link cable player's ROM */
|
|
83
|
+
romPath: string;
|
|
84
|
+
/** The file path for the link cable player's save data */
|
|
85
|
+
savePath?: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type LinkLocalStartSessionConfig = {
|
|
89
|
+
player1: LinkLocalPlayerConfig;
|
|
90
|
+
player2: LinkLocalPlayerConfig;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type LinkLocalStatus = {
|
|
94
|
+
/** Whether the local link cable session is currently running. */
|
|
95
|
+
running: boolean;
|
|
96
|
+
/** The current active player in the local link cable session. */
|
|
97
|
+
activePlayer?: LinkPlayer;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type coreSettings = {
|
|
101
|
+
/**
|
|
102
|
+
* Number of frames to skip rendering between screen paints.
|
|
103
|
+
*
|
|
104
|
+
* Typical values: `0..10`
|
|
105
|
+
*
|
|
106
|
+
* Default: 0
|
|
107
|
+
*/
|
|
108
|
+
frameSkip?: number;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Target base frames-per-second for the emulation core. Used by timing
|
|
112
|
+
* and frame-rate calculations.
|
|
113
|
+
*
|
|
114
|
+
* Typical values: 60, 30
|
|
115
|
+
*
|
|
116
|
+
* Default: 60
|
|
117
|
+
*/
|
|
118
|
+
baseFpsTarget?: number;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Maximum number of rewind states to keep in memory. Larger values allow
|
|
122
|
+
* longer rewind history at the cost of consumed memory. Value is a count of
|
|
123
|
+
* historical entries in the buffer.
|
|
124
|
+
*
|
|
125
|
+
* Typical values: `100..10000` is reasonable depending on memory pressure and
|
|
126
|
+
* the rewind interval.
|
|
127
|
+
*
|
|
128
|
+
* Default: 600
|
|
129
|
+
*/
|
|
130
|
+
rewindBufferCapacity?: number;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The speed at which rewind snapshots are taken. Larger numbers mean rewind happens faster.
|
|
134
|
+
*
|
|
135
|
+
* Typical values: `1..10`
|
|
136
|
+
*
|
|
137
|
+
* Default: 1
|
|
138
|
+
*/
|
|
139
|
+
rewindBufferInterval?: number;
|
|
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
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Requested audio sample rate in Hz for the audio output.
|
|
154
|
+
* The core will attempt to use this rate, actual output depends on
|
|
155
|
+
* the host audio device (best effort).
|
|
156
|
+
*
|
|
157
|
+
* Typical values: 22050, 32000, 44100, 48000
|
|
158
|
+
*
|
|
159
|
+
* Default: 48000
|
|
160
|
+
*/
|
|
161
|
+
audioSampleRate?: number;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Preferred size, in samples, of the audio buffer. Smaller buffers reduce
|
|
165
|
+
* latency but increase the chance of underruns, larger buffers increase
|
|
166
|
+
* latency but are more stable.
|
|
167
|
+
*
|
|
168
|
+
* Typical values: `256..4096`
|
|
169
|
+
*
|
|
170
|
+
* Default: 1024
|
|
171
|
+
*/
|
|
172
|
+
audioBufferSize?: number;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Interval in seconds between periodic auto save state captures.
|
|
176
|
+
*
|
|
177
|
+
* Typical values: `10..30`
|
|
178
|
+
*
|
|
179
|
+
* Default: 30
|
|
180
|
+
*/
|
|
181
|
+
autoSaveStateTimerIntervalSeconds?: number;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* If true, allows opposing directional inputs (ex. left + right) to be
|
|
185
|
+
* accepted simultaneously. When false, only a single directional input
|
|
186
|
+
* is accepted at a time.
|
|
187
|
+
*
|
|
188
|
+
* Default: true
|
|
189
|
+
*/
|
|
190
|
+
allowOpposingDirections?: boolean;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* If true, synchronize the video frame rate to the host display refresh rate (vsync).
|
|
194
|
+
*
|
|
195
|
+
* Default: false
|
|
196
|
+
*/
|
|
197
|
+
videoSync?: boolean;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* If true, synchronizes the video frame rate to the audio output speed.
|
|
201
|
+
*
|
|
202
|
+
* Default: false
|
|
203
|
+
*/
|
|
204
|
+
audioSync?: boolean;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* If true, render video on a separate thread (if supported).
|
|
208
|
+
*
|
|
209
|
+
* Default: false
|
|
210
|
+
*/
|
|
211
|
+
threadedVideo?: boolean;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Enable/disable rewind support.
|
|
215
|
+
*
|
|
216
|
+
* Default: true
|
|
217
|
+
*/
|
|
218
|
+
rewindEnable?: boolean;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* If true, the core will sync using discrete timestep increments based on
|
|
222
|
+
* the baseFpsTarget value rather than variable-step delta timing (audio/video).
|
|
223
|
+
*
|
|
224
|
+
* Default: true
|
|
225
|
+
*/
|
|
226
|
+
timestepSync?: boolean;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* If true, show an on-screen true FPS counter overlay.
|
|
230
|
+
*
|
|
231
|
+
* Default: false
|
|
232
|
+
*/
|
|
233
|
+
showFpsCounter?: boolean;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Enable/disable periodic auto save state capture.
|
|
237
|
+
*
|
|
238
|
+
* Default: true
|
|
239
|
+
*/
|
|
240
|
+
autoSaveStateEnable?: boolean;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* If true, attempts to load the latest auto save state after a game load/reset.
|
|
244
|
+
*
|
|
245
|
+
* Default: true
|
|
246
|
+
*/
|
|
247
|
+
restoreAutoSaveStateOnLoad?: boolean;
|
|
248
|
+
};
|
|
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
|
+
|
|
300
|
+
export interface mGBAEmulator extends EmscriptenModule {
|
|
301
|
+
// custom methods from preamble
|
|
302
|
+
/**
|
|
303
|
+
* Attempts to automatically load cheats for the currently loaded game.
|
|
304
|
+
*
|
|
305
|
+
* @returns True if cheats were loaded successfully, otherwise false.
|
|
306
|
+
*/
|
|
307
|
+
autoLoadCheats(): boolean;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Binds a physical key (SDL key name) to a GBA input action.
|
|
311
|
+
*
|
|
312
|
+
* @param bindingName - SDL key name (ex. "Return", "Left", "Keypad X").
|
|
313
|
+
* @param inputName - GBA input/action (ex. "A", "B", "Start", "Up").
|
|
314
|
+
*/
|
|
315
|
+
bindKey(bindingName: string, inputName: string): void;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Presses a named emulated button.
|
|
319
|
+
*
|
|
320
|
+
* @param name - Button name to press (ex. "A", "B", "Start", "Select", "Up").
|
|
321
|
+
*/
|
|
322
|
+
buttonPress(name: string): void;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Releases (unpress) a named emulated button.
|
|
326
|
+
*
|
|
327
|
+
* @param name - Button name to release (ex. "A", "B", "Start", "Select", "Up").
|
|
328
|
+
*/
|
|
329
|
+
buttonUnpress(name: string): void;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Initializes the Emscripten filesystem and any runtime FS mounts needed by the emulator.
|
|
333
|
+
*/
|
|
334
|
+
FSInit(): Promise<void>;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Synchronizes filesystem state to the backing store (IDBFS).
|
|
338
|
+
*/
|
|
339
|
+
FSSync(): Promise<void>;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Gets the current fast forward multiplier.
|
|
343
|
+
*
|
|
344
|
+
* - `multiplier = 1` = normal speed
|
|
345
|
+
* - `multiplier > 1` = fast forward (`xN`)
|
|
346
|
+
* - `multiplier < 0` = slow down (`1/abs(N)`)
|
|
347
|
+
*
|
|
348
|
+
* @returns Current fast forward multiplier.
|
|
349
|
+
*/
|
|
350
|
+
getFastForwardMultiplier(): number;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Gets the current main loop timing mode.
|
|
354
|
+
*
|
|
355
|
+
* @returns Current timing mode value.
|
|
356
|
+
*/
|
|
357
|
+
getMainLoopTimingMode(): number;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Gets the current main loop timing value for the current mode.
|
|
361
|
+
*
|
|
362
|
+
* @returns Current timing value.
|
|
363
|
+
*/
|
|
364
|
+
getMainLoopTimingValue(): number;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Reads the currently loaded game save data.
|
|
368
|
+
*
|
|
369
|
+
* @returns Save data as bytes, or null if no save exists.
|
|
370
|
+
*/
|
|
371
|
+
getSave(): Uint8Array | null;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Gets the current audio volume multiplier.
|
|
375
|
+
*
|
|
376
|
+
* - `1.0` = 100%
|
|
377
|
+
* - Range is `0.0..2.0` (0%..200%)
|
|
378
|
+
*
|
|
379
|
+
* @returns Current volume multiplier.
|
|
380
|
+
*/
|
|
381
|
+
getVolume(): number;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Lists ROM file names under the game directory.
|
|
385
|
+
*
|
|
386
|
+
* @returns Directory entries from `filePaths().gamePath`.
|
|
387
|
+
*/
|
|
388
|
+
listRoms(): string[];
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Lists save file names under the save directory.
|
|
392
|
+
*
|
|
393
|
+
* @returns Directory entries from `filePaths().savePath`.
|
|
394
|
+
*/
|
|
395
|
+
listSaves(): string[];
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Loads a ROM into the emulator and runs the game, optionally overriding the save path used.
|
|
399
|
+
*
|
|
400
|
+
* @param romPath - Path to the ROM file within the emulated filesystem.
|
|
401
|
+
* @param savePathOverride - Optional override for the save path.
|
|
402
|
+
* @returns True if the game loaded successfully, otherwise false.
|
|
403
|
+
*/
|
|
404
|
+
loadGame(romPath: string, savePathOverride?: string): boolean;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Starts a local link cable session, currently supports two players.
|
|
408
|
+
*/
|
|
409
|
+
linkLocalStartSession(options: LinkLocalStartSessionConfig): boolean;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Stops the active local link cable session, tears down the local link cable and running games.
|
|
413
|
+
*/
|
|
414
|
+
linkLocalStopSession(): void;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Selects which linked player is rendered and controlled by normal input APIs.
|
|
418
|
+
*/
|
|
419
|
+
linkLocalSetActivePlayer(player: LinkPlayer): void;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Gets the current local link cable session status, contains the active player and whether a local link cable session is currently running.
|
|
423
|
+
*/
|
|
424
|
+
linkLocalGetStatus(): LinkLocalStatus;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Loads a save state from a given slot.
|
|
428
|
+
*
|
|
429
|
+
* @param slot - State slot index.
|
|
430
|
+
* @returns True if the state loaded successfully, otherwise false.
|
|
431
|
+
*/
|
|
432
|
+
loadState(slot: number): boolean;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Loads a save state from a given slot using explicit binary literal flags.
|
|
436
|
+
*
|
|
437
|
+
* @deprecated Prefer `loadState(slot)`. This is an old/raw API and may be
|
|
438
|
+
* removed in a future major version.
|
|
439
|
+
*
|
|
440
|
+
* If `flags` is omitted, the runtime uses its default load mask.
|
|
441
|
+
*
|
|
442
|
+
* @param slot - State slot index.
|
|
443
|
+
* @param flags - Bitmask controlling which save state sections are restored.
|
|
444
|
+
* @returns True if the state loaded successfully, otherwise false.
|
|
445
|
+
*/
|
|
446
|
+
loadStateSlot(slot: number, flags?: number): boolean;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Forces an auto save state capture immediately.
|
|
450
|
+
*
|
|
451
|
+
* @returns True if the auto save state was captured successfully, otherwise false.
|
|
452
|
+
*/
|
|
453
|
+
forceAutoSaveState(): boolean;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Loads the current auto save state (if present).
|
|
457
|
+
*
|
|
458
|
+
* @returns True if the auto save state loaded successfully, otherwise false.
|
|
459
|
+
*/
|
|
460
|
+
loadAutoSaveState(): boolean;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Reads the current auto save state from the filesystem (if present).
|
|
464
|
+
*
|
|
465
|
+
* @returns The auto save state name and bytes, or null if none exists.
|
|
466
|
+
*/
|
|
467
|
+
getAutoSaveState(): { autoSaveStateName: string; data: Uint8Array } | null;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Uploads auto save state data into the emulator filesystem.
|
|
471
|
+
*
|
|
472
|
+
* @param autoSaveStateName - Full auto save path to write to.
|
|
473
|
+
* @param data - Raw auto save state bytes.
|
|
474
|
+
*/
|
|
475
|
+
uploadAutoSaveState(
|
|
476
|
+
autoSaveStateName: string,
|
|
477
|
+
data: Uint8Array,
|
|
478
|
+
): Promise<void>;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Pauses audio output without pausing emulation.
|
|
482
|
+
*/
|
|
483
|
+
pauseAudio(): void;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Pauses the game emulation.
|
|
487
|
+
*/
|
|
488
|
+
pauseGame(): void;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Performs a quick reload of the current ROM file.
|
|
492
|
+
*/
|
|
493
|
+
quickReload(): void;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Quits the currently running game session.
|
|
497
|
+
*/
|
|
498
|
+
quitGame(): void;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Exits the emulator runtime.
|
|
502
|
+
*/
|
|
503
|
+
quitMgba(): void;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Resumes audio output.
|
|
507
|
+
*/
|
|
508
|
+
resumeAudio(): void;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Resumes game emulation and audio.
|
|
512
|
+
*/
|
|
513
|
+
resumeGame(): void;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Saves a save state to a given slot.
|
|
517
|
+
*
|
|
518
|
+
* @param slot - State slot index.
|
|
519
|
+
* @returns True if the state saved successfully, otherwise false.
|
|
520
|
+
*/
|
|
521
|
+
saveState(slot: number): boolean;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Saves a save state to a given slot using explicit binary literal flags.
|
|
525
|
+
*
|
|
526
|
+
* @deprecated Prefer `saveState(slot)`. This is an old/raw API and may be
|
|
527
|
+
* removed in a future major version.
|
|
528
|
+
*
|
|
529
|
+
* If `flags` is omitted, the runtime uses its default save mask.
|
|
530
|
+
*
|
|
531
|
+
* @param slot - State slot index.
|
|
532
|
+
* @param flags - Bitmask controlling which save state sections are written.
|
|
533
|
+
* @returns True if the state saved successfully, otherwise false.
|
|
534
|
+
*/
|
|
535
|
+
saveStateSlot(slot: number, flags?: number): boolean;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Captures a screenshot and writes it to the screenshots directory.
|
|
539
|
+
*
|
|
540
|
+
* @param fileName - Optional custom screenshot file name.
|
|
541
|
+
* @returns True if screenshot was captured successfully, otherwise false.
|
|
542
|
+
*/
|
|
543
|
+
screenshot(fileName?: string): boolean;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Sets the current fast forward multiplier.
|
|
547
|
+
*
|
|
548
|
+
* - `multiplier = 1` = normal speed
|
|
549
|
+
* - `multiplier > 1` = fast forward (`xN`)
|
|
550
|
+
* - `multiplier < 0` = slow down (`1/abs(N)`)
|
|
551
|
+
*
|
|
552
|
+
* @param multiplier - The fast forward multiplier to apply.
|
|
553
|
+
*/
|
|
554
|
+
setFastForwardMultiplier(multiplier: number): void;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Sets the main loop timing mode and value.
|
|
558
|
+
*
|
|
559
|
+
* See: [emscripten_set_main_loop_timing](https://emscripten.org/docs/api_reference/emscripten.h.html#c.emscripten_set_main_loop_timing)
|
|
560
|
+
*
|
|
561
|
+
* @param mode - Timing mode identifier.
|
|
562
|
+
* @param value - Timing value associated with the mode.
|
|
563
|
+
*/
|
|
564
|
+
setMainLoopTiming(mode: number, value: number): void;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Sets the audio volume multiplier.
|
|
568
|
+
*
|
|
569
|
+
* - `1.0` = 100%
|
|
570
|
+
* - Range is `0.0..2.0` (0%..200%)
|
|
571
|
+
*
|
|
572
|
+
* @param percent - Volume multiplier to apply.
|
|
573
|
+
*/
|
|
574
|
+
setVolume(percent: number): void;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Enables or disables keyboard input handling.
|
|
578
|
+
*
|
|
579
|
+
* @param enabled - If true input is accepted, if false input is ignored.
|
|
580
|
+
*/
|
|
581
|
+
toggleInput(enabled: boolean): void;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Uploads a cheats file into the emulator filesystem.
|
|
585
|
+
*
|
|
586
|
+
* @param file - Cheats file to upload.
|
|
587
|
+
* @param callback - Optional callback fired after upload completes.
|
|
588
|
+
*/
|
|
589
|
+
uploadCheats(file: File, callback?: () => void): void;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Uploads a patch file into the emulator filesystem.
|
|
593
|
+
*
|
|
594
|
+
* @param file - Patch file to upload.
|
|
595
|
+
* @param callback - Optional callback fired after upload completes.
|
|
596
|
+
*/
|
|
597
|
+
uploadPatch(file: File, callback?: () => void): void;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Uploads a ROM file into the emulator filesystem.
|
|
601
|
+
*
|
|
602
|
+
* @param file - ROM file to upload.
|
|
603
|
+
* @param callback - Optional callback fired after upload completes.
|
|
604
|
+
*/
|
|
605
|
+
uploadRom(file: File, callback?: () => void): void;
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Uploads a save or save state file into the emulator filesystem.
|
|
609
|
+
*
|
|
610
|
+
* @param file - Save or state file to upload.
|
|
611
|
+
* @param callback - Optional callback fired after upload completes.
|
|
612
|
+
*/
|
|
613
|
+
uploadSaveOrSaveState(file: File, callback?: () => void): void;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Uploads a screenshot file into the emulator filesystem.
|
|
617
|
+
*
|
|
618
|
+
* @param file - Screenshot file to upload.
|
|
619
|
+
* @param callback - Optional callback fired after upload completes.
|
|
620
|
+
*/
|
|
621
|
+
uploadScreenshot(file: File, callback?: () => void): void;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Registers core callbacks for emulator lifecycle and custom events.
|
|
625
|
+
*
|
|
626
|
+
* @param coreCallbacks - Callback object to register.
|
|
627
|
+
*/
|
|
628
|
+
addCoreCallbacks(coreCallbacks: coreCallbacks): void;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Registers a callback for mGBA core log output.
|
|
632
|
+
*
|
|
633
|
+
* Use this to capture emulator logs in your application UI, such as a log
|
|
634
|
+
* panel, instead of relying on browser console output alone.
|
|
635
|
+
*
|
|
636
|
+
* Passing `null` removes the custom logger and restores default console
|
|
637
|
+
* logging.
|
|
638
|
+
*
|
|
639
|
+
* @param callback - Log handler, or `null` to clear it.
|
|
640
|
+
*/
|
|
641
|
+
setLogger(callback: ((entry: LogEntry) => void) | null): void;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Enables/disables active rewinding while the core is running.
|
|
645
|
+
*
|
|
646
|
+
* @param enabled - If true the core rewinds, if false rewind stops.
|
|
647
|
+
*/
|
|
648
|
+
toggleRewind(enabled: boolean): void;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Applies core settings to the emulator runtime.
|
|
652
|
+
*
|
|
653
|
+
* @param coreSettings - Settings object to apply.
|
|
654
|
+
*/
|
|
655
|
+
setCoreSettings(coreSettings: coreSettings): void;
|
|
656
|
+
|
|
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;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Returns common filesystem path strings used by this build.
|
|
676
|
+
*/
|
|
677
|
+
filePaths(): filePaths;
|
|
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
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Last loaded ROM path set after `loadGame` succeeds.
|
|
692
|
+
*/
|
|
693
|
+
readonly gameName?: string;
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Save path used for the current game set after `loadGame` succeeds.
|
|
697
|
+
*/
|
|
698
|
+
readonly saveName?: string;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Auto save state path and file name used for the current game set after `loadGame` succeeds.
|
|
702
|
+
*/
|
|
703
|
+
readonly autoSaveStateName?: string;
|
|
704
|
+
// extra exported runtime methods
|
|
705
|
+
readonly FS: typeof FS;
|
|
706
|
+
// SDL2
|
|
707
|
+
readonly SDL2: {
|
|
708
|
+
readonly audio: {
|
|
709
|
+
readonly currentOutputBuffer: AudioBuffer;
|
|
710
|
+
readonly scriptProcessorNode: ScriptProcessorNode;
|
|
711
|
+
};
|
|
712
|
+
readonly audioContext: AudioContext;
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Generates a web assembly mGBA module for the browser.
|
|
718
|
+
*
|
|
719
|
+
* This emulator core is meant to be used like a controlled frontend component:
|
|
720
|
+
* it bootstraps the emulator runtime, canvas wiring, keyboard events, and other autonomous
|
|
721
|
+
* functions using emscripten, exposing an imperative API used to control the core.
|
|
722
|
+
*
|
|
723
|
+
* The consuming UI then drives all actions after initialization using the API above, such as
|
|
724
|
+
* loading ROM/save files, pausing/resuming, settings, saves, etc.
|
|
725
|
+
*
|
|
726
|
+
* **Initialization flow:**
|
|
727
|
+
* - create a `<canvas />`
|
|
728
|
+
* - call `mGBA({ canvas })` to get the `Module`
|
|
729
|
+
* - call `await Module.FSInit()` once to mount + load persisted file system data
|
|
730
|
+
* - keep the `Module` accessible and call methods on it from your UI
|
|
731
|
+
*
|
|
732
|
+
* This core uses threads, your app must be served with cross-origin isolation enabled
|
|
733
|
+
* (`COOP: same-origin` + `COEP: require-corp`), otherwise it will not run correctly.
|
|
734
|
+
*
|
|
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`.
|
|
738
|
+
*/
|
|
739
|
+
// eslint-disable-next-line import/no-default-export
|
|
740
|
+
export default function mGBA(
|
|
741
|
+
moduleOverrides: mGBAInitOptions,
|
|
742
|
+
): Promise<mGBAEmulator>;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export = mGBA;
|