-
Notifications
You must be signed in to change notification settings - Fork 0
/
binjgb.js
943 lines (865 loc) · 41.5 KB
/
binjgb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
var Binjgb = (function () {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
return (
function (Binjgb) {
Binjgb = Binjgb || {};
var Module = typeof Binjgb !== "undefined" ? Binjgb : {};
var readyPromiseResolve, readyPromiseReject;
Module["ready"] = new Promise(function (resolve, reject) {
readyPromiseResolve = resolve;
readyPromiseReject = reject
});
var moduleOverrides = {};
var key;
for (key in Module) {
if (Module.hasOwnProperty(key)) {
moduleOverrides[key] = Module[key]
}
}
var arguments_ = [];
var thisProgram = "./this.program";
var quit_ = function (status, toThrow) {
throw toThrow
};
var ENVIRONMENT_IS_WEB = true;
var ENVIRONMENT_IS_WORKER = false;
var scriptDirectory = "";
function locateFile(path) {
if (Module["locateFile"]) {
return Module["locateFile"](path, scriptDirectory)
}
return scriptDirectory + path
}
var read_, readAsync, readBinary, setWindowTitle;
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = self.location.href
} else if (typeof document !== "undefined" && document.currentScript) {
scriptDirectory = document.currentScript.src
}
if (_scriptDir) {
scriptDirectory = _scriptDir
}
if (scriptDirectory.indexOf("blob:") !== 0) {
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1)
} else {
scriptDirectory = ""
}
{
read_ = function shell_read(url) {
var xhr = new XMLHttpRequest;
xhr.open("GET", url, false);
xhr.send(null);
return xhr.responseText
};
if (ENVIRONMENT_IS_WORKER) {
readBinary = function readBinary(url) {
var xhr = new XMLHttpRequest;
xhr.open("GET", url, false);
xhr.responseType = "arraybuffer";
xhr.send(null);
return new Uint8Array(xhr.response)
}
}
readAsync = function readAsync(url, onload, onerror) {
var xhr = new XMLHttpRequest;
xhr.open("GET", url, true);
xhr.responseType = "arraybuffer";
xhr.onload = function xhr_onload() {
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
onload(xhr.response);
return
}
onerror()
};
xhr.onerror = onerror;
xhr.send(null)
}
}
setWindowTitle = function (title) {
document.title = title
}
} else {
}
var out = Module["print"] || console.log.bind(console);
var err = Module["printErr"] || console.warn.bind(console);
for (key in moduleOverrides) {
if (moduleOverrides.hasOwnProperty(key)) {
Module[key] = moduleOverrides[key]
}
}
moduleOverrides = null;
if (Module["arguments"]) arguments_ = Module["arguments"];
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
if (Module["quit"]) quit_ = Module["quit"];
var STACK_ALIGN = 16;
function warnOnce(text) {
if (!warnOnce.shown) warnOnce.shown = {};
if (!warnOnce.shown[text]) {
warnOnce.shown[text] = 1;
err(text)
}
}
function convertJsFunctionToWasm(func, sig) {
if (typeof WebAssembly.Function === "function") {
var typeNames = {"i": "i32", "j": "i64", "f": "f32", "d": "f64"};
var type = {parameters: [], results: sig[0] == "v" ? [] : [typeNames[sig[0]]]};
for (var i = 1; i < sig.length; ++i) {
type.parameters.push(typeNames[sig[i]])
}
return new WebAssembly.Function(type, func)
}
var typeSection = [1, 0, 1, 96];
var sigRet = sig.slice(0, 1);
var sigParam = sig.slice(1);
var typeCodes = {"i": 127, "j": 126, "f": 125, "d": 124};
typeSection.push(sigParam.length);
for (var i = 0; i < sigParam.length; ++i) {
typeSection.push(typeCodes[sigParam[i]])
}
if (sigRet == "v") {
typeSection.push(0)
} else {
typeSection = typeSection.concat([1, typeCodes[sigRet]])
}
typeSection[1] = typeSection.length - 2;
var bytes = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(typeSection, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0]));
var module = new WebAssembly.Module(bytes);
var instance = new WebAssembly.Instance(module, {"e": {"f": func}});
var wrappedFunc = instance.exports["f"];
return wrappedFunc
}
var freeTableIndexes = [];
var functionsInTableMap;
function getEmptyTableSlot() {
if (freeTableIndexes.length) {
return freeTableIndexes.pop()
}
try {
wasmTable.grow(1)
} catch (err) {
if (!(err instanceof RangeError)) {
throw err
}
throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."
}
return wasmTable.length - 1
}
function addFunctionWasm(func, sig) {
if (!functionsInTableMap) {
functionsInTableMap = new WeakMap;
for (var i = 0; i < wasmTable.length; i++) {
var item = wasmTable.get(i);
if (item) {
functionsInTableMap.set(item, i)
}
}
}
if (functionsInTableMap.has(func)) {
return functionsInTableMap.get(func)
}
var ret = getEmptyTableSlot();
try {
wasmTable.set(ret, func)
} catch (err) {
if (!(err instanceof TypeError)) {
throw err
}
var wrapped = convertJsFunctionToWasm(func, sig);
wasmTable.set(ret, wrapped)
}
functionsInTableMap.set(func, ret);
return ret
}
var tempRet0 = 0;
var setTempRet0 = function (value) {
tempRet0 = value
};
var wasmBinary;
if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
var noExitRuntime;
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
if (typeof WebAssembly !== "object") {
abort("no native wasm support detected")
}
var wasmMemory;
var ABORT = false;
var EXITSTATUS = 0;
function assert(condition, text) {
if (!condition) {
abort("Assertion failed: " + text)
}
}
function getCFunc(ident) {
var func = Module["_" + ident];
assert(func, "Cannot call unknown function " + ident + ", make sure it is exported");
return func
}
function ccall(ident, returnType, argTypes, args, opts) {
var toC = {
"string": function (str) {
var ret = 0;
if (str !== null && str !== undefined && str !== 0) {
var len = (str.length << 2) + 1;
ret = stackAlloc(len);
stringToUTF8(str, ret, len)
}
return ret
}, "array": function (arr) {
var ret = stackAlloc(arr.length);
writeArrayToMemory(arr, ret);
return ret
}
};
function convertReturnValue(ret) {
if (returnType === "string") return UTF8ToString(ret);
if (returnType === "boolean") return Boolean(ret);
return ret
}
var func = getCFunc(ident);
var cArgs = [];
var stack = 0;
if (args) {
for (var i = 0; i < args.length; i++) {
var converter = toC[argTypes[i]];
if (converter) {
if (stack === 0) stack = stackSave();
cArgs[i] = converter(args[i])
} else {
cArgs[i] = args[i]
}
}
}
var ret = func.apply(null, cArgs);
ret = convertReturnValue(ret);
if (stack !== 0) stackRestore(stack);
return ret
}
var ALLOC_STACK = 1;
var UTF8Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf8") : undefined;
function UTF8ArrayToString(heap, idx, maxBytesToRead) {
var endIdx = idx + maxBytesToRead;
var endPtr = idx;
while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
return UTF8Decoder.decode(heap.subarray(idx, endPtr))
} else {
var str = "";
while (idx < endPtr) {
var u0 = heap[idx++];
if (!(u0 & 128)) {
str += String.fromCharCode(u0);
continue
}
var u1 = heap[idx++] & 63;
if ((u0 & 224) == 192) {
str += String.fromCharCode((u0 & 31) << 6 | u1);
continue
}
var u2 = heap[idx++] & 63;
if ((u0 & 240) == 224) {
u0 = (u0 & 15) << 12 | u1 << 6 | u2
} else {
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heap[idx++] & 63
}
if (u0 < 65536) {
str += String.fromCharCode(u0)
} else {
var ch = u0 - 65536;
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023)
}
}
}
return str
}
function UTF8ToString(ptr, maxBytesToRead) {
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""
}
function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
if (!(maxBytesToWrite > 0)) return 0;
var startIdx = outIdx;
var endIdx = outIdx + maxBytesToWrite - 1;
for (var i = 0; i < str.length; ++i) {
var u = str.charCodeAt(i);
if (u >= 55296 && u <= 57343) {
var u1 = str.charCodeAt(++i);
u = 65536 + ((u & 1023) << 10) | u1 & 1023
}
if (u <= 127) {
if (outIdx >= endIdx) break;
heap[outIdx++] = u
} else if (u <= 2047) {
if (outIdx + 1 >= endIdx) break;
heap[outIdx++] = 192 | u >> 6;
heap[outIdx++] = 128 | u & 63
} else if (u <= 65535) {
if (outIdx + 2 >= endIdx) break;
heap[outIdx++] = 224 | u >> 12;
heap[outIdx++] = 128 | u >> 6 & 63;
heap[outIdx++] = 128 | u & 63
} else {
if (outIdx + 3 >= endIdx) break;
heap[outIdx++] = 240 | u >> 18;
heap[outIdx++] = 128 | u >> 12 & 63;
heap[outIdx++] = 128 | u >> 6 & 63;
heap[outIdx++] = 128 | u & 63
}
}
heap[outIdx] = 0;
return outIdx - startIdx
}
function stringToUTF8(str, outPtr, maxBytesToWrite) {
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite)
}
function lengthBytesUTF8(str) {
var len = 0;
for (var i = 0; i < str.length; ++i) {
var u = str.charCodeAt(i);
if (u >= 55296 && u <= 57343) u = 65536 + ((u & 1023) << 10) | str.charCodeAt(++i) & 1023;
if (u <= 127) ++len; else if (u <= 2047) len += 2; else if (u <= 65535) len += 3; else len += 4
}
return len
}
var UTF16Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-16le") : undefined;
function writeArrayToMemory(array, buffer) {
HEAP8.set(array, buffer)
}
function writeAsciiToMemory(str, buffer, dontAddNull) {
for (var i = 0; i < str.length; ++i) {
HEAP8[buffer++ >> 0] = str.charCodeAt(i)
}
if (!dontAddNull) HEAP8[buffer >> 0] = 0
}
var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
function updateGlobalBufferAndViews(buf) {
buffer = buf;
Module["HEAP8"] = HEAP8 = new Int8Array(buf);
Module["HEAP16"] = HEAP16 = new Int16Array(buf);
Module["HEAP32"] = HEAP32 = new Int32Array(buf);
Module["HEAPU8"] = HEAPU8 = new Uint8Array(buf);
Module["HEAPU16"] = HEAPU16 = new Uint16Array(buf);
Module["HEAPU32"] = HEAPU32 = new Uint32Array(buf);
Module["HEAPF32"] = HEAPF32 = new Float32Array(buf);
Module["HEAPF64"] = HEAPF64 = new Float64Array(buf)
}
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 16777216;
if (Module["wasmMemory"]) {
wasmMemory = Module["wasmMemory"]
} else {
wasmMemory = new WebAssembly.Memory({
"initial": INITIAL_MEMORY / 65536,
"maximum": INITIAL_MEMORY / 65536
})
}
if (wasmMemory) {
buffer = wasmMemory.buffer
}
INITIAL_MEMORY = buffer.byteLength;
updateGlobalBufferAndViews(buffer);
var wasmTable;
var __ATPRERUN__ = [];
var __ATINIT__ = [];
var __ATMAIN__ = [];
var __ATPOSTRUN__ = [];
var runtimeInitialized = false;
var runtimeExited = false;
function preRun() {
if (Module["preRun"]) {
if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
while (Module["preRun"].length) {
addOnPreRun(Module["preRun"].shift())
}
}
callRuntimeCallbacks(__ATPRERUN__)
}
function initRuntime() {
runtimeInitialized = true;
callRuntimeCallbacks(__ATINIT__)
}
function preMain() {
callRuntimeCallbacks(__ATMAIN__)
}
function exitRuntime() {
runtimeExited = true
}
function postRun() {
if (Module["postRun"]) {
if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
while (Module["postRun"].length) {
addOnPostRun(Module["postRun"].shift())
}
}
callRuntimeCallbacks(__ATPOSTRUN__)
}
function addOnPreRun(cb) {
__ATPRERUN__.unshift(cb)
}
function addOnPostRun(cb) {
__ATPOSTRUN__.unshift(cb)
}
var runDependencies = 0;
var runDependencyWatcher = null;
var dependenciesFulfilled = null;
function addRunDependency(id) {
runDependencies++;
if (Module["monitorRunDependencies"]) {
Module["monitorRunDependencies"](runDependencies)
}
}
function removeRunDependency(id) {
runDependencies--;
if (Module["monitorRunDependencies"]) {
Module["monitorRunDependencies"](runDependencies)
}
if (runDependencies == 0) {
if (runDependencyWatcher !== null) {
clearInterval(runDependencyWatcher);
runDependencyWatcher = null
}
if (dependenciesFulfilled) {
var callback = dependenciesFulfilled;
dependenciesFulfilled = null;
callback()
}
}
}
Module["preloadedImages"] = {};
Module["preloadedAudios"] = {};
function abort(what) {
if (Module["onAbort"]) {
Module["onAbort"](what)
}
what += "";
err(what);
ABORT = true;
EXITSTATUS = 1;
what = "abort(" + what + "). Build with -s ASSERTIONS=1 for more info.";
var e = new WebAssembly.RuntimeError(what);
readyPromiseReject(e);
throw e
}
function hasPrefix(str, prefix) {
return String.prototype.startsWith ? str.startsWith(prefix) : str.indexOf(prefix) === 0
}
var dataURIPrefix = "data:application/octet-stream;base64,";
function isDataURI(filename) {
return hasPrefix(filename, dataURIPrefix)
}
var fileURIPrefix = "file://";
var wasmBinaryFile = "binjgb.wasm";
if (!isDataURI(wasmBinaryFile)) {
wasmBinaryFile = locateFile(wasmBinaryFile)
}
function getBinary() {
try {
if (wasmBinary) {
return new Uint8Array(wasmBinary)
}
if (readBinary) {
return readBinary(wasmBinaryFile)
} else {
throw"both async and sync fetching of the wasm failed"
}
} catch (err) {
abort(err)
}
}
function getBinaryPromise() {
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch === "function") {
return fetch(wasmBinaryFile, {credentials: "same-origin"}).then(function (response) {
if (!response["ok"]) {
throw"failed to load wasm binary file at '" + wasmBinaryFile + "'"
}
return response["arrayBuffer"]()
}).catch(function () {
return getBinary()
})
}
return Promise.resolve().then(getBinary)
}
function createWasm() {
var info = {"env": asmLibraryArg, "wasi_snapshot_preview1": asmLibraryArg};
function receiveInstance(instance, module) {
var exports = instance.exports;
Module["asm"] = exports;
wasmTable = Module["asm"]["__indirect_function_table"];
removeRunDependency("wasm-instantiate")
}
addRunDependency("wasm-instantiate");
function receiveInstantiatedSource(output) {
receiveInstance(output["instance"])
}
function instantiateArrayBuffer(receiver) {
return getBinaryPromise().then(function (binary) {
return WebAssembly.instantiate(binary, info)
}).then(receiver, function (reason) {
err("failed to asynchronously prepare wasm: " + reason);
abort(reason)
})
}
function instantiateAsync() {
if (!wasmBinary && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && typeof fetch === "function") {
return fetch(wasmBinaryFile, {credentials: "same-origin"}).then(function (response) {
var result = WebAssembly.instantiateStreaming(response, info);
return result.then(receiveInstantiatedSource, function (reason) {
err("wasm streaming compile failed: " + reason);
err("falling back to ArrayBuffer instantiation");
return instantiateArrayBuffer(receiveInstantiatedSource)
})
})
} else {
return instantiateArrayBuffer(receiveInstantiatedSource)
}
}
if (Module["instantiateWasm"]) {
try {
var exports = Module["instantiateWasm"](info, receiveInstance);
return exports
} catch (e) {
err("Module.instantiateWasm callback failed with error: " + e);
return false
}
}
instantiateAsync().catch(readyPromiseReject);
return {}
}
var tempDouble;
var tempI64;
function callRuntimeCallbacks(callbacks) {
while (callbacks.length > 0) {
var callback = callbacks.shift();
if (typeof callback == "function") {
callback(Module);
continue
}
var func = callback.func;
if (typeof func === "number") {
if (callback.arg === undefined) {
wasmTable.get(func)()
} else {
wasmTable.get(func)(callback.arg)
}
} else {
func(callback.arg === undefined ? null : callback.arg)
}
}
}
function demangle(func) {
return func
}
function demangleAll(text) {
var regex = /\b_Z[\w\d_]+/g;
return text.replace(regex, function (x) {
var y = demangle(x);
return x === y ? x : y + " [" + x + "]"
})
}
function dynCallLegacy(sig, ptr, args) {
if (args && args.length) {
return Module["dynCall_" + sig].apply(null, [ptr].concat(args))
}
return Module["dynCall_" + sig].call(null, ptr)
}
function jsStackTrace() {
var error = new Error;
if (!error.stack) {
try {
throw new Error
} catch (e) {
error = e
}
if (!error.stack) {
return "(no stack trace available)"
}
}
return error.stack.toString()
}
function _emscripten_memcpy_big(dest, src, num) {
HEAPU8.copyWithin(dest, src, src + num)
}
function abortOnCannotGrowMemory(requestedSize) {
abort("OOM")
}
function _emscripten_resize_heap(requestedSize) {
requestedSize = requestedSize >>> 0;
abortOnCannotGrowMemory(requestedSize)
}
function _exit(status) {
exit(status)
}
var SYSCALLS = {
mappings: {}, buffers: [null, [], []], printChar: function (stream, curr) {
var buffer = SYSCALLS.buffers[stream];
if (curr === 0 || curr === 10) {
(stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
buffer.length = 0
} else {
buffer.push(curr)
}
}, varargs: undefined, get: function () {
SYSCALLS.varargs += 4;
var ret = HEAP32[SYSCALLS.varargs - 4 >> 2];
return ret
}, getStr: function (ptr) {
var ret = UTF8ToString(ptr);
return ret
}, get64: function (low, high) {
return low
}
};
function _fd_close(fd) {
return 0
}
function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
}
function _fd_write(fd, iov, iovcnt, pnum) {
var num = 0;
for (var i = 0; i < iovcnt; i++) {
var ptr = HEAP32[iov + i * 8 >> 2];
var len = HEAP32[iov + (i * 8 + 4) >> 2];
for (var j = 0; j < len; j++) {
SYSCALLS.printChar(fd, HEAPU8[ptr + j])
}
num += len
}
HEAP32[pnum >> 2] = num;
return 0
}
function _setTempRet0($i) {
setTempRet0($i | 0)
}
var ASSERTIONS = false;
__ATINIT__.push({
func: function () {
___wasm_call_ctors()
}
});
var asmLibraryArg = {
"emscripten_memcpy_big": _emscripten_memcpy_big,
"emscripten_resize_heap": _emscripten_resize_heap,
"exit": _exit,
"fd_close": _fd_close,
"fd_seek": _fd_seek,
"fd_write": _fd_write,
"memory": wasmMemory,
"setTempRet0": _setTempRet0
};
var asm = createWasm();
var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function () {
return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments)
};
var _malloc = Module["_malloc"] = function () {
return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments)
};
var _emulator_set_builtin_palette = Module["_emulator_set_builtin_palette"] = function () {
return (_emulator_set_builtin_palette = Module["_emulator_set_builtin_palette"] = Module["asm"]["emulator_set_builtin_palette"]).apply(null, arguments)
};
var _emulator_was_ext_ram_updated = Module["_emulator_was_ext_ram_updated"] = function () {
return (_emulator_was_ext_ram_updated = Module["_emulator_was_ext_ram_updated"] = Module["asm"]["emulator_was_ext_ram_updated"]).apply(null, arguments)
};
var _emulator_read_ext_ram = Module["_emulator_read_ext_ram"] = function () {
return (_emulator_read_ext_ram = Module["_emulator_read_ext_ram"] = Module["asm"]["emulator_read_ext_ram"]).apply(null, arguments)
};
var _emulator_write_ext_ram = Module["_emulator_write_ext_ram"] = function () {
return (_emulator_write_ext_ram = Module["_emulator_write_ext_ram"] = Module["asm"]["emulator_write_ext_ram"]).apply(null, arguments)
};
var _file_data_delete = Module["_file_data_delete"] = function () {
return (_file_data_delete = Module["_file_data_delete"] = Module["asm"]["file_data_delete"]).apply(null, arguments)
};
var _free = Module["_free"] = function () {
return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments)
};
var _emulator_delete = Module["_emulator_delete"] = function () {
return (_emulator_delete = Module["_emulator_delete"] = Module["asm"]["emulator_delete"]).apply(null, arguments)
};
var _joypad_new = Module["_joypad_new"] = function () {
return (_joypad_new = Module["_joypad_new"] = Module["asm"]["joypad_new"]).apply(null, arguments)
};
var _joypad_delete = Module["_joypad_delete"] = function () {
return (_joypad_delete = Module["_joypad_delete"] = Module["asm"]["joypad_delete"]).apply(null, arguments)
};
var _rewind_append = Module["_rewind_append"] = function () {
return (_rewind_append = Module["_rewind_append"] = Module["asm"]["rewind_append"]).apply(null, arguments)
};
var _rewind_delete = Module["_rewind_delete"] = function () {
return (_rewind_delete = Module["_rewind_delete"] = Module["asm"]["rewind_delete"]).apply(null, arguments)
};
var _emulator_new_simple = Module["_emulator_new_simple"] = function () {
return (_emulator_new_simple = Module["_emulator_new_simple"] = Module["asm"]["emulator_new_simple"]).apply(null, arguments)
};
var _emulator_get_ticks_f64 = Module["_emulator_get_ticks_f64"] = function () {
return (_emulator_get_ticks_f64 = Module["_emulator_get_ticks_f64"] = Module["asm"]["emulator_get_ticks_f64"]).apply(null, arguments)
};
var _emulator_run_until_f64 = Module["_emulator_run_until_f64"] = function () {
return (_emulator_run_until_f64 = Module["_emulator_run_until_f64"] = Module["asm"]["emulator_run_until_f64"]).apply(null, arguments)
};
var _rewind_get_newest_ticks_f64 = Module["_rewind_get_newest_ticks_f64"] = function () {
return (_rewind_get_newest_ticks_f64 = Module["_rewind_get_newest_ticks_f64"] = Module["asm"]["rewind_get_newest_ticks_f64"]).apply(null, arguments)
};
var _rewind_get_oldest_ticks_f64 = Module["_rewind_get_oldest_ticks_f64"] = function () {
return (_rewind_get_oldest_ticks_f64 = Module["_rewind_get_oldest_ticks_f64"] = Module["asm"]["rewind_get_oldest_ticks_f64"]).apply(null, arguments)
};
var _emulator_set_default_joypad_callback = Module["_emulator_set_default_joypad_callback"] = function () {
return (_emulator_set_default_joypad_callback = Module["_emulator_set_default_joypad_callback"] = Module["asm"]["emulator_set_default_joypad_callback"]).apply(null, arguments)
};
var _emulator_set_bw_palette_simple = Module["_emulator_set_bw_palette_simple"] = function () {
return (_emulator_set_bw_palette_simple = Module["_emulator_set_bw_palette_simple"] = Module["asm"]["emulator_set_bw_palette_simple"]).apply(null, arguments)
};
var _rewind_new_simple = Module["_rewind_new_simple"] = function () {
return (_rewind_new_simple = Module["_rewind_new_simple"] = Module["asm"]["rewind_new_simple"]).apply(null, arguments)
};
var _rewind_begin = Module["_rewind_begin"] = function () {
return (_rewind_begin = Module["_rewind_begin"] = Module["asm"]["rewind_begin"]).apply(null, arguments)
};
var _emulator_set_rewind_joypad_callback = Module["_emulator_set_rewind_joypad_callback"] = function () {
return (_emulator_set_rewind_joypad_callback = Module["_emulator_set_rewind_joypad_callback"] = Module["asm"]["emulator_set_rewind_joypad_callback"]).apply(null, arguments)
};
var _rewind_to_ticks_wrapper = Module["_rewind_to_ticks_wrapper"] = function () {
return (_rewind_to_ticks_wrapper = Module["_rewind_to_ticks_wrapper"] = Module["asm"]["rewind_to_ticks_wrapper"]).apply(null, arguments)
};
var _rewind_end = Module["_rewind_end"] = function () {
return (_rewind_end = Module["_rewind_end"] = Module["asm"]["rewind_end"]).apply(null, arguments)
};
var _set_joyp_up = Module["_set_joyp_up"] = function () {
return (_set_joyp_up = Module["_set_joyp_up"] = Module["asm"]["set_joyp_up"]).apply(null, arguments)
};
var _set_joyp_down = Module["_set_joyp_down"] = function () {
return (_set_joyp_down = Module["_set_joyp_down"] = Module["asm"]["set_joyp_down"]).apply(null, arguments)
};
var _set_joyp_left = Module["_set_joyp_left"] = function () {
return (_set_joyp_left = Module["_set_joyp_left"] = Module["asm"]["set_joyp_left"]).apply(null, arguments)
};
var _set_joyp_right = Module["_set_joyp_right"] = function () {
return (_set_joyp_right = Module["_set_joyp_right"] = Module["asm"]["set_joyp_right"]).apply(null, arguments)
};
var _set_joyp_B = Module["_set_joyp_B"] = function () {
return (_set_joyp_B = Module["_set_joyp_B"] = Module["asm"]["set_joyp_B"]).apply(null, arguments)
};
var _set_joyp_A = Module["_set_joyp_A"] = function () {
return (_set_joyp_A = Module["_set_joyp_A"] = Module["asm"]["set_joyp_A"]).apply(null, arguments)
};
var _set_joyp_start = Module["_set_joyp_start"] = function () {
return (_set_joyp_start = Module["_set_joyp_start"] = Module["asm"]["set_joyp_start"]).apply(null, arguments)
};
var _set_joyp_select = Module["_set_joyp_select"] = function () {
return (_set_joyp_select = Module["_set_joyp_select"] = Module["asm"]["set_joyp_select"]).apply(null, arguments)
};
var _get_frame_buffer_ptr = Module["_get_frame_buffer_ptr"] = function () {
return (_get_frame_buffer_ptr = Module["_get_frame_buffer_ptr"] = Module["asm"]["get_frame_buffer_ptr"]).apply(null, arguments)
};
var _get_frame_buffer_size = Module["_get_frame_buffer_size"] = function () {
return (_get_frame_buffer_size = Module["_get_frame_buffer_size"] = Module["asm"]["get_frame_buffer_size"]).apply(null, arguments)
};
var _get_sgb_frame_buffer_ptr = Module["_get_sgb_frame_buffer_ptr"] = function () {
return (_get_sgb_frame_buffer_ptr = Module["_get_sgb_frame_buffer_ptr"] = Module["asm"]["get_sgb_frame_buffer_ptr"]).apply(null, arguments)
};
var _get_sgb_frame_buffer_size = Module["_get_sgb_frame_buffer_size"] = function () {
return (_get_sgb_frame_buffer_size = Module["_get_sgb_frame_buffer_size"] = Module["asm"]["get_sgb_frame_buffer_size"]).apply(null, arguments)
};
var _get_audio_buffer_ptr = Module["_get_audio_buffer_ptr"] = function () {
return (_get_audio_buffer_ptr = Module["_get_audio_buffer_ptr"] = Module["asm"]["get_audio_buffer_ptr"]).apply(null, arguments)
};
var _get_audio_buffer_capacity = Module["_get_audio_buffer_capacity"] = function () {
return (_get_audio_buffer_capacity = Module["_get_audio_buffer_capacity"] = Module["asm"]["get_audio_buffer_capacity"]).apply(null, arguments)
};
var _ext_ram_file_data_new = Module["_ext_ram_file_data_new"] = function () {
return (_ext_ram_file_data_new = Module["_ext_ram_file_data_new"] = Module["asm"]["ext_ram_file_data_new"]).apply(null, arguments)
};
var _get_file_data_ptr = Module["_get_file_data_ptr"] = function () {
return (_get_file_data_ptr = Module["_get_file_data_ptr"] = Module["asm"]["get_file_data_ptr"]).apply(null, arguments)
};
var _get_file_data_size = Module["_get_file_data_size"] = function () {
return (_get_file_data_size = Module["_get_file_data_size"] = Module["asm"]["get_file_data_size"]).apply(null, arguments)
};
var ___errno_location = Module["___errno_location"] = function () {
return (___errno_location = Module["___errno_location"] = Module["asm"]["__errno_location"]).apply(null, arguments)
};
var stackSave = Module["stackSave"] = function () {
return (stackSave = Module["stackSave"] = Module["asm"]["stackSave"]).apply(null, arguments)
};
var stackRestore = Module["stackRestore"] = function () {
return (stackRestore = Module["stackRestore"] = Module["asm"]["stackRestore"]).apply(null, arguments)
};
var stackAlloc = Module["stackAlloc"] = function () {
return (stackAlloc = Module["stackAlloc"] = Module["asm"]["stackAlloc"]).apply(null, arguments)
};
var _sbrk = Module["_sbrk"] = function () {
return (_sbrk = Module["_sbrk"] = Module["asm"]["sbrk"]).apply(null, arguments)
};
var dynCall_jiji = Module["dynCall_jiji"] = function () {
return (dynCall_jiji = Module["dynCall_jiji"] = Module["asm"]["dynCall_jiji"]).apply(null, arguments)
};
var calledRun;
function ExitStatus(status) {
this.name = "ExitStatus";
this.message = "Program terminated with exit(" + status + ")";
this.status = status
}
dependenciesFulfilled = function runCaller() {
if (!calledRun) run();
if (!calledRun) dependenciesFulfilled = runCaller
};
function run(args) {
args = args || arguments_;
if (runDependencies > 0) {
return
}
preRun();
if (runDependencies > 0) return;
function doRun() {
if (calledRun) return;
calledRun = true;
Module["calledRun"] = true;
if (ABORT) return;
initRuntime();
preMain();
readyPromiseResolve(Module);
if (Module["onRuntimeInitialized"]) Module["onRuntimeInitialized"]();
postRun()
}
if (Module["setStatus"]) {
Module["setStatus"]("Running...");
setTimeout(function () {
setTimeout(function () {
Module["setStatus"]("")
}, 1);
doRun()
}, 1)
} else {
doRun()
}
}
Module["run"] = run;
function exit(status, implicit) {
if (implicit && noExitRuntime && status === 0) {
return
}
if (noExitRuntime) {
} else {
EXITSTATUS = status;
exitRuntime();
if (Module["onExit"]) Module["onExit"](status);
ABORT = true
}
quit_(status, new ExitStatus(status))
}
if (Module["preInit"]) {
if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
while (Module["preInit"].length > 0) {
Module["preInit"].pop()()
}
}
noExitRuntime = true;
run();
return Binjgb.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = Binjgb;
else if (typeof define === 'function' && define['amd'])
define([], function () {
return Binjgb;
});
else if (typeof exports === 'object')
exports["Binjgb"] = Binjgb;