@thenick775/mgba-wasm 2.3.3 → 2.3.5-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
@@ -12,10 +12,6 @@ declare namespace mGBA {
12
12
  autosave: string;
13
13
  }
14
14
 
15
- // see: https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/state
16
- // interrupted is a valid property on iOS
17
- type ExtendedAudioContextState = AudioContextState | 'interrupted';
18
-
19
15
  export type coreCallbacks = {
20
16
  alarmCallback?: (() => void) | null;
21
17
  coreCrashedCallback?: (() => void) | null;
@@ -28,22 +24,131 @@ declare namespace mGBA {
28
24
  };
29
25
 
30
26
  export type coreSettings = {
27
+ /**
28
+ * Number of frames to skip rendering between screen paints.
29
+ * Typical values: 0..10
30
+ * Default: 0
31
+ */
31
32
  frameSkip?: number;
33
+
34
+ /**
35
+ * Target base frames-per-second for the emulation core. Used by timing
36
+ * and frame-rate calculations.
37
+ * Typical values: 59.7275 (native), 60, 30
38
+ * Default: Native 59.7275
39
+ */
32
40
  baseFpsTarget?: number;
41
+
42
+ /**
43
+ * Maximum number of rewind states to keep in memory. Larger values allow
44
+ * longer rewind history at the cost of consumed memory. Value is a count of
45
+ * historical entries in the buffer.
46
+ * Typical values: 100..10000 is reasonable depending on memory pressure and
47
+ * the rewind interval.
48
+ * Default: 600
49
+ */
33
50
  rewindBufferCapacity?: number;
51
+
52
+ /**
53
+ * The speed at which rewind snapshots are taken. Larger numbers mean rewind happens faster.
54
+ * Example: 200 (ms) for 5 snapshots/second
55
+ * Default: 1
56
+ */
34
57
  rewindBufferInterval?: number;
58
+
59
+ /**
60
+ * Requested audio sample rate in Hz for the audio output.
61
+ * The core will attempt to use this rate, actual output depends on
62
+ * the host audio device (best effort).
63
+ * Typical values: 22050, 32000, 44100, 48000
64
+ * Default: 48000
65
+ */
35
66
  audioSampleRate?: number;
67
+
68
+ /**
69
+ * Preferred size, in samples, of the audio buffer. Smaller buffers reduce
70
+ * latency but increase the chance of underruns, larger buffers increase
71
+ * latency but are more stable.
72
+ * Typical values: 256..4096
73
+ * Default: 1024
74
+ */
36
75
  audioBufferSize?: number;
76
+
77
+ /**
78
+ * Interval, in seconds, between periodic autosave-state captures. A value
79
+ * of 0 disables the timer-based autosave.
80
+ * Typical values: 10..300
81
+ * Default: 30
82
+ */
37
83
  autoSaveStateTimerIntervalSeconds?: number;
84
+
85
+ /**
86
+ * If true, allows opposing directional inputs (ex. left + right) to be
87
+ * accepted simultaneously. When false, only a single directional input
88
+ * is accepted at a time.
89
+ * Default: true
90
+ */
38
91
  allowOpposingDirections?: boolean;
92
+
93
+ /**
94
+ * If true, synchronize the video frame rate to the host display refresh rate (vsync).
95
+ * Default: false
96
+ */
39
97
  videoSync?: boolean;
98
+
99
+ /**
100
+ * If true, synchronizes the frame rate to the audio output speed.
101
+ * Default: false
102
+ */
40
103
  audioSync?: boolean;
104
+
105
+ /**
106
+ * If true, render video on a separate thread (if supported).
107
+ * Can provide speedup on multi-core systems but is platform dependent.
108
+ * Default: false
109
+ */
41
110
  threadedVideo?: boolean;
111
+
112
+ /**
113
+ * Enable/disable rewind. When true, rewind is available, when false rewind is disabled.
114
+ * Default: true
115
+ */
42
116
  rewindEnable?: boolean;
117
+
118
+ /**
119
+ * If true, the core will sync using discrete timestep increments based on
120
+ * the baseFpsTarget value rather than variable-step delta timing (audio/video).
121
+ * Default: true
122
+ */
43
123
  timestepSync?: boolean;
124
+
125
+ /**
126
+ * Show an on-screen FPS counter overlay when set to true.
127
+ * Default: false
128
+ */
44
129
  showFpsCounter?: boolean;
130
+
131
+ /**
132
+ * Enable/disable periodic auto-save-state captures. When false, no autosave-states are created.
133
+ * Default: true
134
+ */
45
135
  autoSaveStateEnable?: boolean;
136
+
137
+ /**
138
+ * If true, attempt to automatically restore the most recent autosave
139
+ * state when a game is loaded. If false, autosave states are ignored on
140
+ * load and must be applied manually.
141
+ * Default: true
142
+ */
46
143
  restoreAutoSaveStateOnLoad?: boolean;
144
+
145
+ /**
146
+ * If true, use the platform-native precise framerate value for the
147
+ * target FPS of 59.7275... for GBC/GB native. When true this
148
+ * overrides `baseFpsTarget` to the native value.
149
+ * Default: true
150
+ */
151
+ useNativeFps?: boolean;
47
152
  };
48
153
 
49
154
  export interface mGBAEmulator extends EmscriptenModule {
@@ -87,6 +192,7 @@ declare namespace mGBA {
87
192
  uploadPatch(file: File, callback?: () => void): void;
88
193
  uploadRom(file: File, callback?: () => void): void;
89
194
  uploadSaveOrSaveState(file: File, callback?: () => void): void;
195
+ uploadScreenshot(file: File, callback?: () => void): void;
90
196
  addCoreCallbacks(coreCallbacks: coreCallbacks): void;
91
197
  toggleRewind(enabled: boolean): void;
92
198
  setCoreSettings(coreSettings: coreSettings): void;
@@ -107,9 +213,7 @@ declare namespace mGBA {
107
213
  currentOutputBuffer: AudioBuffer;
108
214
  scriptProcessorNode: ScriptProcessorNode;
109
215
  };
110
- audioContext: Omit<AudioContext, 'state'> & {
111
- readonly state: ExtendedAudioContextState;
112
- };
216
+ audioContext: AudioContext;
113
217
  };
114
218
  }
115
219
 
package/dist/mgba.js CHANGED
@@ -244,6 +244,33 @@ Module.uploadCheats = (file, callback) => {
244
244
  reader.readAsArrayBuffer(file);
245
245
  };
246
246
 
247
+ Module.uploadScreenshot = (file, callback) => {
248
+ const split = file.name.split('.');
249
+ if (split.length < 2) {
250
+ console.warn('unrecognized file extension: ' + file.name);
251
+ return;
252
+ }
253
+ const extension = split[split.length - 1].toLowerCase();
254
+
255
+ let dir = null;
256
+ if (extension == 'png') {
257
+ dir = '/data/screenshots/';
258
+ } else {
259
+ console.warn('unrecognized file extension: ' + extension);
260
+ return;
261
+ }
262
+
263
+ const reader = new FileReader();
264
+ reader.onload = (e) => {
265
+ FS.writeFile(dir + file.name, new Uint8Array(e.target.result));
266
+ if (callback) {
267
+ callback();
268
+ }
269
+ };
270
+
271
+ reader.readAsArrayBuffer(file);
272
+ };
273
+
247
274
  Module.uploadPatch = (file, callback) => {
248
275
  const split = file.name.split('.');
249
276
  if (split.length < 2) {
@@ -593,6 +620,10 @@ Module.setCoreSettings = (coreSettings) => {
593
620
  'restoreAutoSaveStateOnLoad',
594
621
  coreSettings.restoreAutoSaveStateOnLoad
595
622
  );
623
+
624
+ // should explicitly be set after baseFpsTarget
625
+ if (coreSettings.useNativeFps !== undefined)
626
+ setIntegerCoreSetting('useNativeFps', coreSettings.useNativeFps);
596
627
  };
597
628
  // end include: /home/mgba/src/src/platform/wasm/pre.js
598
629
 
@@ -1212,32 +1243,32 @@ async function createWasm() {
1212
1243
  // === Body ===
1213
1244
 
1214
1245
  var ASM_CONSTS = {
1215
- 310352: ($0, $1) => { Module.canvas.width = $0; Module.canvas.height = $1; },
1216
- 310409: () => { console.error("thread instantiation failed") },
1217
- 310458: ($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) }; },
1218
- 310690: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1219
- 310788: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1220
- 310886: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1221
- 310984: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1222
- 311082: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1223
- 311180: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1224
- 311278: () => { FS.syncfs(function (err) { assert(!err); }) },
1225
- 311322: ($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); },
1226
- 311547: () => { if (typeof(AudioContext) !== 'undefined') { return true; } else if (typeof(webkitAudioContext) !== 'undefined') { return true; } return false; },
1227
- 311694: () => { if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) { return true; } else if (typeof(navigator.webkitGetUserMedia) !== 'undefined') { return true; } return false; },
1228
- 311928: ($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; },
1229
- 312480: () => { var SDL2 = Module['SDL2']; return SDL2.audioContext.sampleRate; },
1230
- 312548: ($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); } },
1231
- 314241: ($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); } },
1232
- 315416: ($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'); } } } },
1233
- 316021: ($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)]; } } },
1234
- 316510: ($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; } },
1235
- 317516: ($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); },
1236
- 318984: ($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; },
1237
- 319972: ($0) => { if (Module['canvas']) { Module['canvas'].style['cursor'] = UTF8ToString($0); } },
1238
- 320055: () => { if (Module['canvas']) { Module['canvas'].style['cursor'] = 'none'; } },
1239
- 320124: () => { return window.innerWidth; },
1240
- 320154: () => { return window.innerHeight; }
1246
+ 310400: ($0, $1) => { Module.canvas.width = $0; Module.canvas.height = $1; },
1247
+ 310457: () => { console.error("thread instantiation failed") },
1248
+ 310506: ($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) }; },
1249
+ 310738: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1250
+ 310836: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1251
+ 310934: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1252
+ 311032: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1253
+ 311130: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1254
+ 311228: ($0, $1) => { const funcPtr = $0; const ctx = $1; const func = wasmTable.get(funcPtr); if (func) func(ctx); },
1255
+ 311326: () => { FS.syncfs(function (err) { assert(!err); }) },
1256
+ 311370: ($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); },
1257
+ 311595: () => { if (typeof(AudioContext) !== 'undefined') { return true; } else if (typeof(webkitAudioContext) !== 'undefined') { return true; } return false; },
1258
+ 311742: () => { if ((typeof(navigator.mediaDevices) !== 'undefined') && (typeof(navigator.mediaDevices.getUserMedia) !== 'undefined')) { return true; } else if (typeof(navigator.webkitGetUserMedia) !== 'undefined') { return true; } return false; },
1259
+ 311976: ($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; },
1260
+ 312528: () => { var SDL2 = Module['SDL2']; return SDL2.audioContext.sampleRate; },
1261
+ 312596: ($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); } },
1262
+ 314289: ($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); } },
1263
+ 315464: ($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'); } } } },
1264
+ 316069: ($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)]; } } },
1265
+ 316558: ($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; } },
1266
+ 317564: ($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); },
1267
+ 319032: ($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; },
1268
+ 320020: ($0) => { if (Module['canvas']) { Module['canvas'].style['cursor'] = UTF8ToString($0); } },
1269
+ 320103: () => { if (Module['canvas']) { Module['canvas'].style['cursor'] = 'none'; } },
1270
+ 320172: () => { return window.innerWidth; },
1271
+ 320202: () => { return window.innerHeight; }
1241
1272
  };
1242
1273
 
1243
1274
  // end include: preamble.js
@@ -13004,21 +13035,21 @@ var _emscripten_stack_set_limits = (a0, a1) => (_emscripten_stack_set_limits = w
13004
13035
  var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
13005
13036
  var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
13006
13037
  var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
13007
- var _GBAInputInfo = Module['_GBAInputInfo'] = 122432;
13008
- var _binaryName = Module['_binaryName'] = 198464;
13009
- var _projectName = Module['_projectName'] = 198468;
13010
- var _projectVersion = Module['_projectVersion'] = 198472;
13011
- var _gitCommit = Module['_gitCommit'] = 198448;
13012
- var _gitCommitShort = Module['_gitCommitShort'] = 198452;
13013
- var _gitBranch = Module['_gitBranch'] = 198456;
13014
- var _gitRevision = Module['_gitRevision'] = 198460;
13015
- var _GBIORegisterNames = Module['_GBIORegisterNames'] = 60800;
13016
- var _GBSavestateMagic = Module['_GBSavestateMagic'] = 76064;
13017
- var _GBSavestateVersion = Module['_GBSavestateVersion'] = 76068;
13018
- var _GBA_LUX_LEVELS = Module['_GBA_LUX_LEVELS'] = 105536;
13019
- var _GBAVideoObjSizes = Module['_GBAVideoObjSizes'] = 149872;
13020
- var _GBASavestateMagic = Module['_GBASavestateMagic'] = 149648;
13021
- var _GBASavestateVersion = Module['_GBASavestateVersion'] = 149652;
13038
+ var _GBAInputInfo = Module['_GBAInputInfo'] = 122480;
13039
+ var _binaryName = Module['_binaryName'] = 198512;
13040
+ var _projectName = Module['_projectName'] = 198516;
13041
+ var _projectVersion = Module['_projectVersion'] = 198520;
13042
+ var _gitCommit = Module['_gitCommit'] = 198496;
13043
+ var _gitCommitShort = Module['_gitCommitShort'] = 198500;
13044
+ var _gitBranch = Module['_gitBranch'] = 198504;
13045
+ var _gitRevision = Module['_gitRevision'] = 198508;
13046
+ var _GBIORegisterNames = Module['_GBIORegisterNames'] = 60848;
13047
+ var _GBSavestateMagic = Module['_GBSavestateMagic'] = 76112;
13048
+ var _GBSavestateVersion = Module['_GBSavestateVersion'] = 76116;
13049
+ var _GBA_LUX_LEVELS = Module['_GBA_LUX_LEVELS'] = 105584;
13050
+ var _GBAVideoObjSizes = Module['_GBAVideoObjSizes'] = 149920;
13051
+ var _GBASavestateMagic = Module['_GBASavestateMagic'] = 149696;
13052
+ var _GBASavestateVersion = Module['_GBASavestateVersion'] = 149700;
13022
13053
  function invoke_iiiii(index,a1,a2,a3,a4) {
13023
13054
  var sp = stackSave();
13024
13055
  try {
package/dist/mgba.wasm CHANGED
Binary file