@thenick775/mgba-wasm 2.2.2 → 2.3.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/dist/mgba.d.ts CHANGED
@@ -22,6 +22,8 @@ declare namespace mGBA {
22
22
  saveDataUpdatedCallback?: (() => void) | null;
23
23
  videoFrameEndedCallback?: (() => void) | null;
24
24
  videoFrameStartedCallback?: (() => void) | null;
25
+ autoSaveStateCapturedCallback?: (() => void) | null;
26
+ autoSaveStateLoadedCallback?: (() => void) | null;
25
27
  };
26
28
 
27
29
  export type coreSettings = {
@@ -31,6 +33,7 @@ declare namespace mGBA {
31
33
  rewindBufferInterval?: number;
32
34
  audioSampleRate?: number;
33
35
  audioBufferSize?: number;
36
+ autoSaveStateTimerIntervalSeconds?: number;
34
37
  allowOpposingDirections?: boolean;
35
38
  videoSync?: boolean;
36
39
  audioSync?: boolean;
@@ -38,6 +41,8 @@ declare namespace mGBA {
38
41
  rewindEnable?: boolean;
39
42
  timestepSync?: boolean;
40
43
  showFpsCounter?: boolean;
44
+ autoSaveStateEnable?: boolean;
45
+ restoreAutoSaveStateOnLoad?: boolean;
41
46
  };
42
47
 
43
48
  export interface mGBAEmulator extends EmscriptenModule {
@@ -57,6 +62,13 @@ declare namespace mGBA {
57
62
  listSaves(): string[];
58
63
  loadGame(romPath: string, savePathOverride?: string): boolean;
59
64
  loadState(slot: number): boolean;
65
+ forceAutoSaveState(): boolean;
66
+ loadAutoSaveState(): boolean;
67
+ getAutoSaveState(): { autoSaveStateName: string; data: Uint8Array };
68
+ uploadAutoSaveState(
69
+ autoSaveStateName: string,
70
+ data: Uint8Array
71
+ ): Promise<void>;
60
72
  pauseAudio(): void;
61
73
  pauseGame(): void;
62
74
  quickReload(): void;
@@ -76,7 +88,7 @@ declare namespace mGBA {
76
88
  uploadSaveOrSaveState(file: File, callback?: () => void): void;
77
89
  addCoreCallbacks(coreCallbacks: coreCallbacks): void;
78
90
  toggleRewind(enabled: boolean): void;
79
- setCoreSettings(coreSettings: CoreSettings): void;
91
+ setCoreSettings(coreSettings: coreSettings): void;
80
92
  // custom variables
81
93
  version: {
82
94
  projectName: string;
@@ -85,6 +97,7 @@ declare namespace mGBA {
85
97
  filePaths(): filePaths;
86
98
  gameName?: string;
87
99
  saveName?: string;
100
+ autoSaveStateName?: string;
88
101
  // extra exported runtime methods
89
102
  FS: typeof FS;
90
103
  // SDL2
package/dist/mgba.js CHANGED
@@ -65,10 +65,15 @@ Module.loadGame = (romPath, savePathOverride) => {
65
65
  arr.pop();
66
66
 
67
67
  const saveName = arr.join('.') + '.sav';
68
+ const autoSaveStateName = arr.join('.') + '_auto.ss';
68
69
 
69
70
  Module.gameName = romPath;
70
71
  Module.saveName =
71
72
  savePathOverride ?? saveName.replace('/data/games/', '/data/saves/');
73
+ Module.autoSaveStateName = autoSaveStateName.replace(
74
+ '/data/games/',
75
+ '/autosave/'
76
+ );
72
77
  return true;
73
78
  }
74
79
 
@@ -87,12 +92,15 @@ Module.listSaves = () => {
87
92
  return FS.readdir('/data/saves/');
88
93
  };
89
94
 
90
- // yanked from main.c for ease of use
91
95
  Module.FSInit = () => {
92
96
  return new Promise((resolve, reject) => {
93
97
  FS.mkdir('/data');
94
98
  FS.mount(FS.filesystems.IDBFS, {}, '/data');
95
99
 
100
+ // mount auto save directory, this should auto persist, while the data mount should not
101
+ FS.mkdir('/autosave');
102
+ FS.mount(FS.filesystems.IDBFS, { autoPersist: true }, '/autosave');
103
+
96
104
  // load data from IDBFS
97
105
  FS.syncfs(true, (err) => {
98
106
  if (err) {
@@ -373,6 +381,46 @@ Module.loadState = (slot) => {
373
381
  return loadState(slot);
374
382
  };
375
383
 
384
+ Module.forceAutoSaveState = () => {
385
+ const autoSaveState = cwrap('autoSaveState', 'boolean', []);
386
+ return autoSaveState();
387
+ };
388
+
389
+ Module.loadAutoSaveState = () => {
390
+ const loadAutoSaveState = cwrap('loadAutoSaveState', 'boolean', []);
391
+ return loadAutoSaveState();
392
+ };
393
+
394
+ Module.getAutoSaveState = () => {
395
+ return {
396
+ autoSaveStateName: Module.autoSaveStateName,
397
+ data: FS.readFile(Module.autoSaveStateName),
398
+ };
399
+ };
400
+
401
+ Module.uploadAutoSaveState = async (autoSaveStateName, data) => {
402
+ return new Promise((resolve, reject) => {
403
+ try {
404
+ if (!(data instanceof Uint8Array)) {
405
+ console.warn('Auto save state data must be a Uint8Array');
406
+ return;
407
+ }
408
+
409
+ if (!autoSaveStateName.length) {
410
+ console.warn('Auto save state file name invalid');
411
+ return;
412
+ }
413
+
414
+ const path = `${autoSaveStateName}`;
415
+ FS.writeFile(path, data);
416
+
417
+ resolve();
418
+ } catch (err) {
419
+ reject(err);
420
+ }
421
+ });
422
+ };
423
+
376
424
  Module.saveStateSlot = (slot, flags) => {
377
425
  var saveStateSlot = cwrap('saveStateSlot', 'number', ['number', 'number']);
378
426
  Module.saveStateSlot = (slot, flags) => {
@@ -424,6 +472,8 @@ const coreCallbackStore = {
424
472
  saveDataUpdatedCallbackPtr: null,
425
473
  videoFrameEndedCallbackPtr: null,
426
474
  videoFrameStartedCallbackPtr: null,
475
+ autoSaveStateCapturedCallbackPtr: null,
476
+ autoSaveStateLoadedCallbackPtr: null,
427
477
  };
428
478
 
429
479
  // adds user callbacks to the callback store, and makes function(s) available to the core in c
@@ -453,7 +503,9 @@ Module.addCoreCallbacks = (callbacks) => {
453
503
  coreCallbackStore.keysReadCallbackPtr,
454
504
  coreCallbackStore.saveDataUpdatedCallbackPtr,
455
505
  coreCallbackStore.videoFrameEndedCallbackPtr,
456
- coreCallbackStore.videoFrameStartedCallbackPtr
506
+ coreCallbackStore.videoFrameStartedCallbackPtr,
507
+ coreCallbackStore.autoSaveStateCapturedCallbackPtr,
508
+ coreCallbackStore.autoSaveStateLoadedCallbackPtr
457
509
  );
458
510
  };
459
511
 
@@ -516,6 +568,24 @@ Module.setCoreSettings = (coreSettings) => {
516
568
 
517
569
  if (coreSettings.showFpsCounter !== undefined)
518
570
  setIntegerCoreSetting('showFpsCounter', coreSettings.showFpsCounter);
571
+
572
+ if (coreSettings.autoSaveStateTimerIntervalSeconds !== undefined)
573
+ setIntegerCoreSetting(
574
+ 'autoSaveStateTimerIntervalSeconds',
575
+ coreSettings.autoSaveStateTimerIntervalSeconds
576
+ );
577
+
578
+ if (coreSettings.autoSaveStateEnable !== undefined)
579
+ setIntegerCoreSetting(
580
+ 'autoSaveStateEnable',
581
+ coreSettings.autoSaveStateEnable
582
+ );
583
+
584
+ if (coreSettings.restoreAutoSaveStateOnLoad !== undefined)
585
+ setIntegerCoreSetting(
586
+ 'restoreAutoSaveStateOnLoad',
587
+ coreSettings.restoreAutoSaveStateOnLoad
588
+ );
519
589
  };
520
590
  // end include: /home/mgba/src/src/platform/wasm/pre.js
521
591
 
@@ -1135,32 +1205,32 @@ async function createWasm() {
1135
1205
  // === Body ===
1136
1206
 
1137
1207
  var ASM_CONSTS = {
1138
- 310256: () => { console.error("thread instantiation failed") },
1139
- 310305: ($0, $1) => { Module.canvas.width = $0; Module.canvas.height = $1; },
1140
- 310362: ($0, $1, $2, $3, $4, $5, $6) => { Module.version = { gitCommit : UTF8ToString($0), gitShort : UTF8ToString($1), gitBranch : UTF8ToString($2), gitRevision : $3, binaryName : UTF8ToString($4), projectName : UTF8ToString($5), projectVersion : UTF8ToString($6) }; },
1141
- 310594: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1142
- 310692: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1143
- 310790: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1144
- 310888: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1145
- 310986: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1146
- 311084: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1147
- 311182: () => { FS.syncfs(function (err) { assert(!err); }) },
1148
- 311226: ($0) => { var str = UTF8ToString($0) + '\n\n' + 'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :'; var reply = window.prompt(str, "i"); if (reply === null) { reply = "i"; } return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL); },
1149
- 311451: () => { if (typeof(AudioContext) !== 'undefined') { return true; } else if (typeof(webkitAudioContext) !== 'undefined') { return true; } return false; },
1150
- 311598: () => { if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) { return true; } else if (typeof(navigator.webkitGetUserMedia) !== 'undefined') { return true; } return false; },
1151
- 311832: ($0) => { if(typeof(Module['SDL2']) === 'undefined') { Module['SDL2'] = {}; } var SDL2 = Module['SDL2']; if (!$0) { SDL2.audio = {}; } else { SDL2.capture = {}; } if (!SDL2.audioContext) { if (typeof(AudioContext) !== 'undefined') { SDL2.audioContext = new AudioContext(); } else if (typeof(webkitAudioContext) !== 'undefined') { SDL2.audioContext = new webkitAudioContext(); } if (SDL2.audioContext) { if ((typeof navigator.userActivation) === 'undefined') { autoResumeAudioContext(SDL2.audioContext); } } } return SDL2.audioContext === undefined ? -1 : 0; },
1152
- 312384: () => { var SDL2 = Module['SDL2']; return SDL2.audioContext.sampleRate; },
1153
- 312452: ($0, $1, $2, $3) => { var SDL2 = Module['SDL2']; var have_microphone = function(stream) { if (SDL2.capture.silenceTimer !== undefined) { clearInterval(SDL2.capture.silenceTimer); SDL2.capture.silenceTimer = undefined; SDL2.capture.silenceBuffer = undefined } SDL2.capture.mediaStreamNode = SDL2.audioContext.createMediaStreamSource(stream); SDL2.capture.scriptProcessorNode = SDL2.audioContext.createScriptProcessor($1, $0, 1); SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) { if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; } audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0); SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer; dynCall('vi', $2, [$3]); }; SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode); SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination); SDL2.capture.stream = stream; }; var no_microphone = function(error) { }; SDL2.capture.silenceBuffer = SDL2.audioContext.createBuffer($0, $1, SDL2.audioContext.sampleRate); SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0); var silence_callback = function() { SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer; dynCall('vi', $2, [$3]); }; SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); if ((navigator.mediaDevices !== undefined) && (navigator.mediaDevices.getUserMedia !== undefined)) { navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(have_microphone).catch(no_microphone); } else if (navigator.webkitGetUserMedia !== undefined) { navigator.webkitGetUserMedia({ audio: true, video: false }, have_microphone, no_microphone); } },
1154
- 314145: ($0, $1, $2, $3) => { var SDL2 = Module['SDL2']; SDL2.audio.scriptProcessorNode = SDL2.audioContext['createScriptProcessor']($1, 0, $0); SDL2.audio.scriptProcessorNode['onaudioprocess'] = function (e) { if ((SDL2 === undefined) || (SDL2.audio === undefined)) { return; } if (SDL2.audio.silenceTimer !== undefined) { clearInterval(SDL2.audio.silenceTimer); SDL2.audio.silenceTimer = undefined; SDL2.audio.silenceBuffer = undefined; } SDL2.audio.currentOutputBuffer = e['outputBuffer']; dynCall('vi', $2, [$3]); }; SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']); if (SDL2.audioContext.state === 'suspended') { SDL2.audio.silenceBuffer = SDL2.audioContext.createBuffer($0, $1, SDL2.audioContext.sampleRate); SDL2.audio.silenceBuffer.getChannelData(0).fill(0.0); var silence_callback = function() { if ((typeof navigator.userActivation) !== 'undefined') { if (navigator.userActivation.hasBeenActive) { SDL2.audioContext.resume(); } } SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer; dynCall('vi', $2, [$3]); SDL2.audio.currentOutputBuffer = undefined; }; SDL2.audio.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); } },
1155
- 315320: ($0, $1) => { var SDL2 = Module['SDL2']; var numChannels = SDL2.capture.currentCaptureBuffer.numberOfChannels; for (var c = 0; c < numChannels; ++c) { var channelData = SDL2.capture.currentCaptureBuffer.getChannelData(c); if (channelData.length != $1) { throw 'Web Audio capture buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!'; } if (numChannels == 1) { for (var j = 0; j < $1; ++j) { setValue($0 + (j * 4), channelData[j], 'float'); } } else { for (var j = 0; j < $1; ++j) { setValue($0 + (((j * numChannels) + c) * 4), channelData[j], 'float'); } } } },
1156
- 315925: ($0, $1) => { var SDL2 = Module['SDL2']; var buf = $0 >>> 2; var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels']; for (var c = 0; c < numChannels; ++c) { var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c); if (channelData.length != $1) { throw 'Web Audio output buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!'; } for (var j = 0; j < $1; ++j) { channelData[j] = HEAPF32[buf + (j*numChannels + c)]; } } },
1157
- 316414: ($0) => { var SDL2 = Module['SDL2']; if ($0) { if (SDL2.capture.silenceTimer !== undefined) { clearInterval(SDL2.capture.silenceTimer); } if (SDL2.capture.stream !== undefined) { var tracks = SDL2.capture.stream.getAudioTracks(); for (var i = 0; i < tracks.length; i++) { SDL2.capture.stream.removeTrack(tracks[i]); } } if (SDL2.capture.scriptProcessorNode !== undefined) { SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) {}; SDL2.capture.scriptProcessorNode.disconnect(); } if (SDL2.capture.mediaStreamNode !== undefined) { SDL2.capture.mediaStreamNode.disconnect(); } SDL2.capture = undefined; } else { if (SDL2.audio.scriptProcessorNode != undefined) { SDL2.audio.scriptProcessorNode.disconnect(); } if (SDL2.audio.silenceTimer !== undefined) { clearInterval(SDL2.audio.silenceTimer); } SDL2.audio = undefined; } if ((SDL2.audioContext !== undefined) && (SDL2.audio === undefined) && (SDL2.capture === undefined)) { SDL2.audioContext.close(); SDL2.audioContext = undefined; } },
1158
- 317420: ($0, $1, $2) => { var w = $0; var h = $1; var pixels = $2; if (!Module['SDL2']) Module['SDL2'] = {}; var SDL2 = Module['SDL2']; if (SDL2.ctxCanvas !== Module['canvas']) { SDL2.ctx = Module['createContext'](Module['canvas'], false, true); SDL2.ctxCanvas = Module['canvas']; } if (SDL2.w !== w || SDL2.h !== h || SDL2.imageCtx !== SDL2.ctx) { SDL2.image = SDL2.ctx.createImageData(w, h); SDL2.w = w; SDL2.h = h; SDL2.imageCtx = SDL2.ctx; } var data = SDL2.image.data; var src = pixels / 4; var dst = 0; var num; if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) { num = data.length; while (dst < num) { var val = HEAP32[src]; data[dst ] = val & 0xff; data[dst+1] = (val >> 8) & 0xff; data[dst+2] = (val >> 16) & 0xff; data[dst+3] = 0xff; src++; dst += 4; } } else { if (SDL2.data32Data !== data) { SDL2.data32 = new Int32Array(data.buffer); SDL2.data8 = new Uint8Array(data.buffer); SDL2.data32Data = data; } var data32 = SDL2.data32; num = data32.length; data32.set(HEAP32.subarray(src, src + num)); var data8 = SDL2.data8; var i = 3; var j = i + 4*num; if (num % 8 == 0) { while (i < j) { data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; } } else { while (i < j) { data8[i] = 0xff; i = i + 4 | 0; } } } SDL2.ctx.putImageData(SDL2.image, 0, 0); },
1159
- 318888: ($0, $1, $2, $3, $4) => { var w = $0; var h = $1; var hot_x = $2; var hot_y = $3; var pixels = $4; var canvas = document.createElement("canvas"); canvas.width = w; canvas.height = h; var ctx = canvas.getContext("2d"); var image = ctx.createImageData(w, h); var data = image.data; var src = pixels / 4; var dst = 0; var num; if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) { num = data.length; while (dst < num) { var val = HEAP32[src]; data[dst ] = val & 0xff; data[dst+1] = (val >> 8) & 0xff; data[dst+2] = (val >> 16) & 0xff; data[dst+3] = (val >> 24) & 0xff; src++; dst += 4; } } else { var data32 = new Int32Array(data.buffer); num = data32.length; data32.set(HEAP32.subarray(src, src + num)); } ctx.putImageData(image, 0, 0); var url = hot_x === 0 && hot_y === 0 ? "url(" + canvas.toDataURL() + "), auto" : "url(" + canvas.toDataURL() + ") " + hot_x + " " + hot_y + ", auto"; var urlBuf = _malloc(url.length + 1); stringToUTF8(url, urlBuf, url.length + 1); return urlBuf; },
1160
- 319876: ($0) => { if (Module['canvas']) { Module['canvas'].style['cursor'] = UTF8ToString($0); } },
1161
- 319959: () => { if (Module['canvas']) { Module['canvas'].style['cursor'] = 'none'; } },
1162
- 320028: () => { return window.innerWidth; },
1163
- 320058: () => { return window.innerHeight; }
1208
+ 310384: ($0, $1) => { Module.canvas.width = $0; Module.canvas.height = $1; },
1209
+ 310441: () => { console.error("thread instantiation failed") },
1210
+ 310490: ($0, $1, $2, $3, $4, $5, $6) => { Module.version = { gitCommit : UTF8ToString($0), gitShort : UTF8ToString($1), gitBranch : UTF8ToString($2), gitRevision : $3, binaryName : UTF8ToString($4), projectName : UTF8ToString($5), projectVersion : UTF8ToString($6) }; },
1211
+ 310722: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1212
+ 310820: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1213
+ 310918: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1214
+ 311016: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1215
+ 311114: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1216
+ 311212: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1217
+ 311310: () => { FS.syncfs(function (err) { assert(!err); }) },
1218
+ 311354: ($0) => { var str = UTF8ToString($0) + '\n\n' + 'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :'; var reply = window.prompt(str, "i"); if (reply === null) { reply = "i"; } return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL); },
1219
+ 311579: () => { if (typeof(AudioContext) !== 'undefined') { return true; } else if (typeof(webkitAudioContext) !== 'undefined') { return true; } return false; },
1220
+ 311726: () => { if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) { return true; } else if (typeof(navigator.webkitGetUserMedia) !== 'undefined') { return true; } return false; },
1221
+ 311960: ($0) => { if(typeof(Module['SDL2']) === 'undefined') { Module['SDL2'] = {}; } var SDL2 = Module['SDL2']; if (!$0) { SDL2.audio = {}; } else { SDL2.capture = {}; } if (!SDL2.audioContext) { if (typeof(AudioContext) !== 'undefined') { SDL2.audioContext = new AudioContext(); } else if (typeof(webkitAudioContext) !== 'undefined') { SDL2.audioContext = new webkitAudioContext(); } if (SDL2.audioContext) { if ((typeof navigator.userActivation) === 'undefined') { autoResumeAudioContext(SDL2.audioContext); } } } return SDL2.audioContext === undefined ? -1 : 0; },
1222
+ 312512: () => { var SDL2 = Module['SDL2']; return SDL2.audioContext.sampleRate; },
1223
+ 312580: ($0, $1, $2, $3) => { var SDL2 = Module['SDL2']; var have_microphone = function(stream) { if (SDL2.capture.silenceTimer !== undefined) { clearInterval(SDL2.capture.silenceTimer); SDL2.capture.silenceTimer = undefined; SDL2.capture.silenceBuffer = undefined } SDL2.capture.mediaStreamNode = SDL2.audioContext.createMediaStreamSource(stream); SDL2.capture.scriptProcessorNode = SDL2.audioContext.createScriptProcessor($1, $0, 1); SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) { if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; } audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0); SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer; dynCall('vi', $2, [$3]); }; SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode); SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination); SDL2.capture.stream = stream; }; var no_microphone = function(error) { }; SDL2.capture.silenceBuffer = SDL2.audioContext.createBuffer($0, $1, SDL2.audioContext.sampleRate); SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0); var silence_callback = function() { SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer; dynCall('vi', $2, [$3]); }; SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); if ((navigator.mediaDevices !== undefined) && (navigator.mediaDevices.getUserMedia !== undefined)) { navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(have_microphone).catch(no_microphone); } else if (navigator.webkitGetUserMedia !== undefined) { navigator.webkitGetUserMedia({ audio: true, video: false }, have_microphone, no_microphone); } },
1224
+ 314273: ($0, $1, $2, $3) => { var SDL2 = Module['SDL2']; SDL2.audio.scriptProcessorNode = SDL2.audioContext['createScriptProcessor']($1, 0, $0); SDL2.audio.scriptProcessorNode['onaudioprocess'] = function (e) { if ((SDL2 === undefined) || (SDL2.audio === undefined)) { return; } if (SDL2.audio.silenceTimer !== undefined) { clearInterval(SDL2.audio.silenceTimer); SDL2.audio.silenceTimer = undefined; SDL2.audio.silenceBuffer = undefined; } SDL2.audio.currentOutputBuffer = e['outputBuffer']; dynCall('vi', $2, [$3]); }; SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']); if (SDL2.audioContext.state === 'suspended') { SDL2.audio.silenceBuffer = SDL2.audioContext.createBuffer($0, $1, SDL2.audioContext.sampleRate); SDL2.audio.silenceBuffer.getChannelData(0).fill(0.0); var silence_callback = function() { if ((typeof navigator.userActivation) !== 'undefined') { if (navigator.userActivation.hasBeenActive) { SDL2.audioContext.resume(); } } SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer; dynCall('vi', $2, [$3]); SDL2.audio.currentOutputBuffer = undefined; }; SDL2.audio.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); } },
1225
+ 315448: ($0, $1) => { var SDL2 = Module['SDL2']; var numChannels = SDL2.capture.currentCaptureBuffer.numberOfChannels; for (var c = 0; c < numChannels; ++c) { var channelData = SDL2.capture.currentCaptureBuffer.getChannelData(c); if (channelData.length != $1) { throw 'Web Audio capture buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!'; } if (numChannels == 1) { for (var j = 0; j < $1; ++j) { setValue($0 + (j * 4), channelData[j], 'float'); } } else { for (var j = 0; j < $1; ++j) { setValue($0 + (((j * numChannels) + c) * 4), channelData[j], 'float'); } } } },
1226
+ 316053: ($0, $1) => { var SDL2 = Module['SDL2']; var buf = $0 >>> 2; var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels']; for (var c = 0; c < numChannels; ++c) { var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c); if (channelData.length != $1) { throw 'Web Audio output buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!'; } for (var j = 0; j < $1; ++j) { channelData[j] = HEAPF32[buf + (j*numChannels + c)]; } } },
1227
+ 316542: ($0) => { var SDL2 = Module['SDL2']; if ($0) { if (SDL2.capture.silenceTimer !== undefined) { clearInterval(SDL2.capture.silenceTimer); } if (SDL2.capture.stream !== undefined) { var tracks = SDL2.capture.stream.getAudioTracks(); for (var i = 0; i < tracks.length; i++) { SDL2.capture.stream.removeTrack(tracks[i]); } } if (SDL2.capture.scriptProcessorNode !== undefined) { SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) {}; SDL2.capture.scriptProcessorNode.disconnect(); } if (SDL2.capture.mediaStreamNode !== undefined) { SDL2.capture.mediaStreamNode.disconnect(); } SDL2.capture = undefined; } else { if (SDL2.audio.scriptProcessorNode != undefined) { SDL2.audio.scriptProcessorNode.disconnect(); } if (SDL2.audio.silenceTimer !== undefined) { clearInterval(SDL2.audio.silenceTimer); } SDL2.audio = undefined; } if ((SDL2.audioContext !== undefined) && (SDL2.audio === undefined) && (SDL2.capture === undefined)) { SDL2.audioContext.close(); SDL2.audioContext = undefined; } },
1228
+ 317548: ($0, $1, $2) => { var w = $0; var h = $1; var pixels = $2; if (!Module['SDL2']) Module['SDL2'] = {}; var SDL2 = Module['SDL2']; if (SDL2.ctxCanvas !== Module['canvas']) { SDL2.ctx = Module['createContext'](Module['canvas'], false, true); SDL2.ctxCanvas = Module['canvas']; } if (SDL2.w !== w || SDL2.h !== h || SDL2.imageCtx !== SDL2.ctx) { SDL2.image = SDL2.ctx.createImageData(w, h); SDL2.w = w; SDL2.h = h; SDL2.imageCtx = SDL2.ctx; } var data = SDL2.image.data; var src = pixels / 4; var dst = 0; var num; if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) { num = data.length; while (dst < num) { var val = HEAP32[src]; data[dst ] = val & 0xff; data[dst+1] = (val >> 8) & 0xff; data[dst+2] = (val >> 16) & 0xff; data[dst+3] = 0xff; src++; dst += 4; } } else { if (SDL2.data32Data !== data) { SDL2.data32 = new Int32Array(data.buffer); SDL2.data8 = new Uint8Array(data.buffer); SDL2.data32Data = data; } var data32 = SDL2.data32; num = data32.length; data32.set(HEAP32.subarray(src, src + num)); var data8 = SDL2.data8; var i = 3; var j = i + 4*num; if (num % 8 == 0) { while (i < j) { data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; data8[i] = 0xff; i = i + 4 | 0; } } else { while (i < j) { data8[i] = 0xff; i = i + 4 | 0; } } } SDL2.ctx.putImageData(SDL2.image, 0, 0); },
1229
+ 319016: ($0, $1, $2, $3, $4) => { var w = $0; var h = $1; var hot_x = $2; var hot_y = $3; var pixels = $4; var canvas = document.createElement("canvas"); canvas.width = w; canvas.height = h; var ctx = canvas.getContext("2d"); var image = ctx.createImageData(w, h); var data = image.data; var src = pixels / 4; var dst = 0; var num; if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) { num = data.length; while (dst < num) { var val = HEAP32[src]; data[dst ] = val & 0xff; data[dst+1] = (val >> 8) & 0xff; data[dst+2] = (val >> 16) & 0xff; data[dst+3] = (val >> 24) & 0xff; src++; dst += 4; } } else { var data32 = new Int32Array(data.buffer); num = data32.length; data32.set(HEAP32.subarray(src, src + num)); } ctx.putImageData(image, 0, 0); var url = hot_x === 0 && hot_y === 0 ? "url(" + canvas.toDataURL() + "), auto" : "url(" + canvas.toDataURL() + ") " + hot_x + " " + hot_y + ", auto"; var urlBuf = _malloc(url.length + 1); stringToUTF8(url, urlBuf, url.length + 1); return urlBuf; },
1230
+ 320004: ($0) => { if (Module['canvas']) { Module['canvas'].style['cursor'] = UTF8ToString($0); } },
1231
+ 320087: () => { if (Module['canvas']) { Module['canvas'].style['cursor'] = 'none'; } },
1232
+ 320156: () => { return window.innerWidth; },
1233
+ 320186: () => { return window.innerHeight; }
1164
1234
  };
1165
1235
 
1166
1236
  // end include: preamble.js
@@ -12892,6 +12962,8 @@ var _getFastForwardMultiplier = Module['_getFastForwardMultiplier'] = () => (_ge
12892
12962
  var _quitGame = Module['_quitGame'] = () => (_quitGame = Module['_quitGame'] = wasmExports['quitGame'])();
12893
12963
  var _free = (a0) => (_free = wasmExports['free'])(a0);
12894
12964
  var _quitMgba = Module['_quitMgba'] = () => (_quitMgba = Module['_quitMgba'] = wasmExports['quitMgba'])();
12965
+ var _autoSaveState = Module['_autoSaveState'] = () => (_autoSaveState = Module['_autoSaveState'] = wasmExports['autoSaveState'])();
12966
+ var _loadAutoSaveState = Module['_loadAutoSaveState'] = () => (_loadAutoSaveState = Module['_loadAutoSaveState'] = wasmExports['loadAutoSaveState'])();
12895
12967
  var _quickReload = Module['_quickReload'] = () => (_quickReload = Module['_quickReload'] = wasmExports['quickReload'])();
12896
12968
  var _pauseGame = Module['_pauseGame'] = () => (_pauseGame = Module['_pauseGame'] = wasmExports['pauseGame'])();
12897
12969
  var _resumeGame = Module['_resumeGame'] = () => (_resumeGame = Module['_resumeGame'] = wasmExports['resumeGame'])();
@@ -12905,7 +12977,7 @@ var _autoLoadCheats = Module['_autoLoadCheats'] = () => (_autoLoadCheats = Modul
12905
12977
  var _loadGame = Module['_loadGame'] = (a0, a1) => (_loadGame = Module['_loadGame'] = wasmExports['loadGame'])(a0, a1);
12906
12978
  var _saveStateSlot = Module['_saveStateSlot'] = (a0, a1) => (_saveStateSlot = Module['_saveStateSlot'] = wasmExports['saveStateSlot'])(a0, a1);
12907
12979
  var _loadStateSlot = Module['_loadStateSlot'] = (a0, a1) => (_loadStateSlot = Module['_loadStateSlot'] = wasmExports['loadStateSlot'])(a0, a1);
12908
- var _addCoreCallbacks = Module['_addCoreCallbacks'] = (a0, a1, a2, a3, a4, a5) => (_addCoreCallbacks = Module['_addCoreCallbacks'] = wasmExports['addCoreCallbacks'])(a0, a1, a2, a3, a4, a5);
12980
+ var _addCoreCallbacks = Module['_addCoreCallbacks'] = (a0, a1, a2, a3, a4, a5, a6, a7) => (_addCoreCallbacks = Module['_addCoreCallbacks'] = wasmExports['addCoreCallbacks'])(a0, a1, a2, a3, a4, a5, a6, a7);
12909
12981
  var _setIntegerCoreSetting = Module['_setIntegerCoreSetting'] = (a0, a1) => (_setIntegerCoreSetting = Module['_setIntegerCoreSetting'] = wasmExports['setIntegerCoreSetting'])(a0, a1);
12910
12982
  var _setupConstants = Module['_setupConstants'] = () => (_setupConstants = Module['_setupConstants'] = wasmExports['setupConstants'])();
12911
12983
  var _main = Module['_main'] = (a0, a1) => (_main = Module['_main'] = wasmExports['main'])(a0, a1);
@@ -12925,21 +12997,21 @@ var _emscripten_stack_set_limits = (a0, a1) => (_emscripten_stack_set_limits = w
12925
12997
  var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
12926
12998
  var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
12927
12999
  var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
12928
- var _GBAInputInfo = Module['_GBAInputInfo'] = 122336;
12929
- var _binaryName = Module['_binaryName'] = 198368;
12930
- var _projectName = Module['_projectName'] = 198372;
12931
- var _projectVersion = Module['_projectVersion'] = 198376;
12932
- var _gitCommit = Module['_gitCommit'] = 198352;
12933
- var _gitCommitShort = Module['_gitCommitShort'] = 198356;
12934
- var _gitBranch = Module['_gitBranch'] = 198360;
12935
- var _gitRevision = Module['_gitRevision'] = 198364;
12936
- var _GBIORegisterNames = Module['_GBIORegisterNames'] = 60704;
12937
- var _GBSavestateMagic = Module['_GBSavestateMagic'] = 75968;
12938
- var _GBSavestateVersion = Module['_GBSavestateVersion'] = 75972;
12939
- var _GBA_LUX_LEVELS = Module['_GBA_LUX_LEVELS'] = 105440;
12940
- var _GBAVideoObjSizes = Module['_GBAVideoObjSizes'] = 149776;
12941
- var _GBASavestateMagic = Module['_GBASavestateMagic'] = 149552;
12942
- var _GBASavestateVersion = Module['_GBASavestateVersion'] = 149556;
13000
+ var _GBAInputInfo = Module['_GBAInputInfo'] = 122464;
13001
+ var _binaryName = Module['_binaryName'] = 198496;
13002
+ var _projectName = Module['_projectName'] = 198500;
13003
+ var _projectVersion = Module['_projectVersion'] = 198504;
13004
+ var _gitCommit = Module['_gitCommit'] = 198480;
13005
+ var _gitCommitShort = Module['_gitCommitShort'] = 198484;
13006
+ var _gitBranch = Module['_gitBranch'] = 198488;
13007
+ var _gitRevision = Module['_gitRevision'] = 198492;
13008
+ var _GBIORegisterNames = Module['_GBIORegisterNames'] = 60832;
13009
+ var _GBSavestateMagic = Module['_GBSavestateMagic'] = 76096;
13010
+ var _GBSavestateVersion = Module['_GBSavestateVersion'] = 76100;
13011
+ var _GBA_LUX_LEVELS = Module['_GBA_LUX_LEVELS'] = 105568;
13012
+ var _GBAVideoObjSizes = Module['_GBAVideoObjSizes'] = 149904;
13013
+ var _GBASavestateMagic = Module['_GBASavestateMagic'] = 149680;
13014
+ var _GBASavestateVersion = Module['_GBASavestateVersion'] = 149684;
12943
13015
  function invoke_iiiii(index,a1,a2,a3,a4) {
12944
13016
  var sp = stackSave();
12945
13017
  try {
package/dist/mgba.wasm CHANGED
Binary file