@orkosinha/gb-emu-devtools 0.2.0

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/gb_emu.js ADDED
@@ -0,0 +1,1369 @@
1
+ /* @ts-self-types="./gb_emu.d.ts" */
2
+
3
+ /**
4
+ * Game Boy joypad buttons.
5
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
6
+ */
7
+ export const Button = Object.freeze({
8
+ A: 0, "0": "A",
9
+ B: 1, "1": "B",
10
+ Select: 2, "2": "Select",
11
+ Start: 3, "3": "Start",
12
+ Right: 4, "4": "Right",
13
+ Left: 5, "5": "Left",
14
+ Up: 6, "6": "Up",
15
+ Down: 7, "7": "Down",
16
+ });
17
+
18
+ export class GameBoy {
19
+ __destroy_into_raw() {
20
+ const ptr = this.__wbg_ptr;
21
+ this.__wbg_ptr = 0;
22
+ GameBoyFinalization.unregister(this);
23
+ return ptr;
24
+ }
25
+ free() {
26
+ const ptr = this.__destroy_into_raw();
27
+ wasm.__wbg_gameboy_free(ptr, 0);
28
+ }
29
+ /**
30
+ * @returns {boolean}
31
+ */
32
+ apu_ch1_dac() {
33
+ const ret = wasm.gameboy_apu_ch1_dac(this.__wbg_ptr);
34
+ return ret !== 0;
35
+ }
36
+ /**
37
+ * @returns {number}
38
+ */
39
+ apu_ch1_duty() {
40
+ const ret = wasm.gameboy_apu_ch1_duty(this.__wbg_ptr);
41
+ return ret;
42
+ }
43
+ /**
44
+ * @returns {number}
45
+ */
46
+ apu_ch1_duty_pos() {
47
+ const ret = wasm.gameboy_apu_ch1_duty_pos(this.__wbg_ptr);
48
+ return ret;
49
+ }
50
+ /**
51
+ * @returns {boolean}
52
+ */
53
+ apu_ch1_enabled() {
54
+ const ret = wasm.gameboy_apu_ch1_enabled(this.__wbg_ptr);
55
+ return ret !== 0;
56
+ }
57
+ /**
58
+ * @returns {boolean}
59
+ */
60
+ apu_ch1_env_add() {
61
+ const ret = wasm.gameboy_apu_ch1_env_add(this.__wbg_ptr);
62
+ return ret !== 0;
63
+ }
64
+ /**
65
+ * @returns {number}
66
+ */
67
+ apu_ch1_env_period() {
68
+ const ret = wasm.gameboy_apu_ch1_env_period(this.__wbg_ptr);
69
+ return ret;
70
+ }
71
+ /**
72
+ * @returns {number}
73
+ */
74
+ apu_ch1_freq_hz() {
75
+ const ret = wasm.gameboy_apu_ch1_freq_hz(this.__wbg_ptr);
76
+ return ret;
77
+ }
78
+ /**
79
+ * @returns {number}
80
+ */
81
+ apu_ch1_freq_reg() {
82
+ const ret = wasm.gameboy_apu_ch1_freq_reg(this.__wbg_ptr);
83
+ return ret;
84
+ }
85
+ /**
86
+ * @returns {boolean}
87
+ */
88
+ apu_ch1_len_en() {
89
+ const ret = wasm.gameboy_apu_ch1_len_en(this.__wbg_ptr);
90
+ return ret !== 0;
91
+ }
92
+ /**
93
+ * @returns {number}
94
+ */
95
+ apu_ch1_length() {
96
+ const ret = wasm.gameboy_apu_ch1_length(this.__wbg_ptr);
97
+ return ret;
98
+ }
99
+ /**
100
+ * @returns {number}
101
+ */
102
+ apu_ch1_midi_note() {
103
+ const ret = wasm.gameboy_apu_ch1_midi_note(this.__wbg_ptr);
104
+ return ret;
105
+ }
106
+ /**
107
+ * CH1 shadow frequency register (internal sweep calculation state).
108
+ * @returns {number}
109
+ */
110
+ apu_ch1_shadow_freq() {
111
+ const ret = wasm.gameboy_apu_ch1_shadow_freq(this.__wbg_ptr);
112
+ return ret;
113
+ }
114
+ /**
115
+ * @returns {boolean}
116
+ */
117
+ apu_ch1_sweep_neg() {
118
+ const ret = wasm.gameboy_apu_ch1_sweep_neg(this.__wbg_ptr);
119
+ return ret !== 0;
120
+ }
121
+ /**
122
+ * @returns {number}
123
+ */
124
+ apu_ch1_sweep_period() {
125
+ const ret = wasm.gameboy_apu_ch1_sweep_period(this.__wbg_ptr);
126
+ return ret;
127
+ }
128
+ /**
129
+ * @returns {number}
130
+ */
131
+ apu_ch1_sweep_shift() {
132
+ const ret = wasm.gameboy_apu_ch1_sweep_shift(this.__wbg_ptr);
133
+ return ret;
134
+ }
135
+ /**
136
+ * @returns {number}
137
+ */
138
+ apu_ch1_volume() {
139
+ const ret = wasm.gameboy_apu_ch1_volume(this.__wbg_ptr);
140
+ return ret;
141
+ }
142
+ /**
143
+ * @returns {boolean}
144
+ */
145
+ apu_ch2_dac() {
146
+ const ret = wasm.gameboy_apu_ch2_dac(this.__wbg_ptr);
147
+ return ret !== 0;
148
+ }
149
+ /**
150
+ * @returns {number}
151
+ */
152
+ apu_ch2_duty() {
153
+ const ret = wasm.gameboy_apu_ch2_duty(this.__wbg_ptr);
154
+ return ret;
155
+ }
156
+ /**
157
+ * @returns {number}
158
+ */
159
+ apu_ch2_duty_pos() {
160
+ const ret = wasm.gameboy_apu_ch2_duty_pos(this.__wbg_ptr);
161
+ return ret;
162
+ }
163
+ /**
164
+ * @returns {boolean}
165
+ */
166
+ apu_ch2_enabled() {
167
+ const ret = wasm.gameboy_apu_ch2_enabled(this.__wbg_ptr);
168
+ return ret !== 0;
169
+ }
170
+ /**
171
+ * @returns {boolean}
172
+ */
173
+ apu_ch2_env_add() {
174
+ const ret = wasm.gameboy_apu_ch2_env_add(this.__wbg_ptr);
175
+ return ret !== 0;
176
+ }
177
+ /**
178
+ * @returns {number}
179
+ */
180
+ apu_ch2_env_period() {
181
+ const ret = wasm.gameboy_apu_ch2_env_period(this.__wbg_ptr);
182
+ return ret;
183
+ }
184
+ /**
185
+ * @returns {number}
186
+ */
187
+ apu_ch2_freq_hz() {
188
+ const ret = wasm.gameboy_apu_ch2_freq_hz(this.__wbg_ptr);
189
+ return ret;
190
+ }
191
+ /**
192
+ * @returns {number}
193
+ */
194
+ apu_ch2_freq_reg() {
195
+ const ret = wasm.gameboy_apu_ch2_freq_reg(this.__wbg_ptr);
196
+ return ret;
197
+ }
198
+ /**
199
+ * @returns {boolean}
200
+ */
201
+ apu_ch2_len_en() {
202
+ const ret = wasm.gameboy_apu_ch2_len_en(this.__wbg_ptr);
203
+ return ret !== 0;
204
+ }
205
+ /**
206
+ * @returns {number}
207
+ */
208
+ apu_ch2_length() {
209
+ const ret = wasm.gameboy_apu_ch2_length(this.__wbg_ptr);
210
+ return ret;
211
+ }
212
+ /**
213
+ * @returns {number}
214
+ */
215
+ apu_ch2_midi_note() {
216
+ const ret = wasm.gameboy_apu_ch2_midi_note(this.__wbg_ptr);
217
+ return ret;
218
+ }
219
+ /**
220
+ * @returns {number}
221
+ */
222
+ apu_ch2_volume() {
223
+ const ret = wasm.gameboy_apu_ch2_volume(this.__wbg_ptr);
224
+ return ret;
225
+ }
226
+ /**
227
+ * @returns {boolean}
228
+ */
229
+ apu_ch3_dac() {
230
+ const ret = wasm.gameboy_apu_ch3_dac(this.__wbg_ptr);
231
+ return ret !== 0;
232
+ }
233
+ /**
234
+ * @returns {boolean}
235
+ */
236
+ apu_ch3_enabled() {
237
+ const ret = wasm.gameboy_apu_ch3_enabled(this.__wbg_ptr);
238
+ return ret !== 0;
239
+ }
240
+ /**
241
+ * @returns {number}
242
+ */
243
+ apu_ch3_freq_hz() {
244
+ const ret = wasm.gameboy_apu_ch3_freq_hz(this.__wbg_ptr);
245
+ return ret;
246
+ }
247
+ /**
248
+ * @returns {number}
249
+ */
250
+ apu_ch3_freq_reg() {
251
+ const ret = wasm.gameboy_apu_ch3_freq_reg(this.__wbg_ptr);
252
+ return ret;
253
+ }
254
+ /**
255
+ * @returns {boolean}
256
+ */
257
+ apu_ch3_len_en() {
258
+ const ret = wasm.gameboy_apu_ch3_len_en(this.__wbg_ptr);
259
+ return ret !== 0;
260
+ }
261
+ /**
262
+ * @returns {number}
263
+ */
264
+ apu_ch3_length() {
265
+ const ret = wasm.gameboy_apu_ch3_length(this.__wbg_ptr);
266
+ return ret;
267
+ }
268
+ /**
269
+ * @returns {number}
270
+ */
271
+ apu_ch3_midi_note() {
272
+ const ret = wasm.gameboy_apu_ch3_midi_note(this.__wbg_ptr);
273
+ return ret;
274
+ }
275
+ /**
276
+ * @returns {number}
277
+ */
278
+ apu_ch3_vol_code() {
279
+ const ret = wasm.gameboy_apu_ch3_vol_code(this.__wbg_ptr);
280
+ return ret;
281
+ }
282
+ /**
283
+ * @returns {number}
284
+ */
285
+ apu_ch3_wave_pos() {
286
+ const ret = wasm.gameboy_apu_ch3_wave_pos(this.__wbg_ptr);
287
+ return ret;
288
+ }
289
+ /**
290
+ * Raw wave RAM as 16 bytes (32 × 4-bit nibbles).
291
+ * @returns {Uint8Array}
292
+ */
293
+ apu_ch3_wave_ram() {
294
+ const ret = wasm.gameboy_apu_ch3_wave_ram(this.__wbg_ptr);
295
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
296
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
297
+ return v1;
298
+ }
299
+ /**
300
+ * @returns {number}
301
+ */
302
+ apu_ch4_clock_div() {
303
+ const ret = wasm.gameboy_apu_ch4_clock_div(this.__wbg_ptr);
304
+ return ret;
305
+ }
306
+ /**
307
+ * @returns {number}
308
+ */
309
+ apu_ch4_clock_shift() {
310
+ const ret = wasm.gameboy_apu_ch4_clock_shift(this.__wbg_ptr);
311
+ return ret;
312
+ }
313
+ /**
314
+ * @returns {boolean}
315
+ */
316
+ apu_ch4_dac() {
317
+ const ret = wasm.gameboy_apu_ch4_dac(this.__wbg_ptr);
318
+ return ret !== 0;
319
+ }
320
+ /**
321
+ * @returns {boolean}
322
+ */
323
+ apu_ch4_enabled() {
324
+ const ret = wasm.gameboy_apu_ch4_enabled(this.__wbg_ptr);
325
+ return ret !== 0;
326
+ }
327
+ /**
328
+ * @returns {boolean}
329
+ */
330
+ apu_ch4_env_add() {
331
+ const ret = wasm.gameboy_apu_ch4_env_add(this.__wbg_ptr);
332
+ return ret !== 0;
333
+ }
334
+ /**
335
+ * @returns {number}
336
+ */
337
+ apu_ch4_env_period() {
338
+ const ret = wasm.gameboy_apu_ch4_env_period(this.__wbg_ptr);
339
+ return ret;
340
+ }
341
+ /**
342
+ * @returns {number}
343
+ */
344
+ apu_ch4_freq_hz() {
345
+ const ret = wasm.gameboy_apu_ch4_freq_hz(this.__wbg_ptr);
346
+ return ret;
347
+ }
348
+ /**
349
+ * @returns {boolean}
350
+ */
351
+ apu_ch4_len_en() {
352
+ const ret = wasm.gameboy_apu_ch4_len_en(this.__wbg_ptr);
353
+ return ret !== 0;
354
+ }
355
+ /**
356
+ * @returns {number}
357
+ */
358
+ apu_ch4_length() {
359
+ const ret = wasm.gameboy_apu_ch4_length(this.__wbg_ptr);
360
+ return ret;
361
+ }
362
+ /**
363
+ * @returns {number}
364
+ */
365
+ apu_ch4_lfsr() {
366
+ const ret = wasm.gameboy_apu_ch4_lfsr(this.__wbg_ptr);
367
+ return ret;
368
+ }
369
+ /**
370
+ * @returns {boolean}
371
+ */
372
+ apu_ch4_lfsr_short() {
373
+ const ret = wasm.gameboy_apu_ch4_lfsr_short(this.__wbg_ptr);
374
+ return ret !== 0;
375
+ }
376
+ /**
377
+ * @returns {number}
378
+ */
379
+ apu_ch4_volume() {
380
+ const ret = wasm.gameboy_apu_ch4_volume(this.__wbg_ptr);
381
+ return ret;
382
+ }
383
+ /**
384
+ * @returns {number}
385
+ */
386
+ apu_frame_seq_step() {
387
+ const ret = wasm.gameboy_apu_frame_seq_step(this.__wbg_ptr);
388
+ return ret;
389
+ }
390
+ /**
391
+ * NR50: master volume and VIN panning register.
392
+ * @returns {number}
393
+ */
394
+ apu_nr50() {
395
+ const ret = wasm.gameboy_apu_nr50(this.__wbg_ptr);
396
+ return ret;
397
+ }
398
+ /**
399
+ * NR51: left/right channel output routing mask.
400
+ * @returns {number}
401
+ */
402
+ apu_nr51() {
403
+ const ret = wasm.gameboy_apu_nr51(this.__wbg_ptr);
404
+ return ret;
405
+ }
406
+ /**
407
+ * NR52: APU power and channel-active status bits.
408
+ * @returns {number}
409
+ */
410
+ apu_nr52() {
411
+ const ret = wasm.gameboy_apu_nr52(this.__wbg_ptr);
412
+ return ret;
413
+ }
414
+ /**
415
+ * @returns {boolean}
416
+ */
417
+ apu_powered() {
418
+ const ret = wasm.gameboy_apu_powered(this.__wbg_ptr);
419
+ return ret !== 0;
420
+ }
421
+ /**
422
+ * Pointer to the per-channel visualization ring buffer.
423
+ * Layout: 4 channels × 512 bytes; channel c starts at byte c × 512.
424
+ * @returns {number}
425
+ */
426
+ apu_viz_ptr() {
427
+ const ret = wasm.gameboy_apu_viz_ptr(this.__wbg_ptr);
428
+ return ret >>> 0;
429
+ }
430
+ /**
431
+ * Current write index within each channel's 512-byte slot (0–511).
432
+ * @returns {number}
433
+ */
434
+ apu_viz_wp() {
435
+ const ret = wasm.gameboy_apu_viz_wp(this.__wbg_ptr);
436
+ return ret >>> 0;
437
+ }
438
+ /**
439
+ * Discard all samples from the buffer. Call once per frame after consuming.
440
+ */
441
+ audio_clear_samples() {
442
+ wasm.gameboy_audio_clear_samples(this.__wbg_ptr);
443
+ }
444
+ /**
445
+ * Number of f32 values in the sample buffer (pairs × 2).
446
+ * @returns {number}
447
+ */
448
+ audio_sample_buffer_len() {
449
+ const ret = wasm.gameboy_audio_sample_buffer_len(this.__wbg_ptr);
450
+ return ret >>> 0;
451
+ }
452
+ /**
453
+ * Pointer to the interleaved stereo f32 sample buffer (L, R, L, R, …).
454
+ * Valid until the next `step_frame` or `step_samples` call.
455
+ * @returns {number}
456
+ */
457
+ audio_sample_buffer_ptr() {
458
+ const ret = wasm.gameboy_audio_sample_buffer_ptr(this.__wbg_ptr);
459
+ return ret >>> 0;
460
+ }
461
+ /**
462
+ * Target sample rate in Hz (44 100).
463
+ * @returns {number}
464
+ */
465
+ audio_sample_rate() {
466
+ const ret = wasm.gameboy_audio_sample_rate(this.__wbg_ptr);
467
+ return ret >>> 0;
468
+ }
469
+ /**
470
+ * Current contrast level derived from the dither matrix (0–15, or −1 if unknown).
471
+ * @returns {number}
472
+ */
473
+ camera_contrast() {
474
+ const ret = wasm.gameboy_camera_contrast(this.__wbg_ptr);
475
+ return ret;
476
+ }
477
+ /**
478
+ * @returns {number}
479
+ */
480
+ camera_live_len() {
481
+ const ret = wasm.gameboy_camera_live_len(this.__wbg_ptr);
482
+ return ret >>> 0;
483
+ }
484
+ /**
485
+ * Pointer to the camera live-view RGBA buffer (128×112×4 bytes).
486
+ * @returns {number}
487
+ */
488
+ camera_live_ptr() {
489
+ const ret = wasm.gameboy_camera_live_ptr(this.__wbg_ptr);
490
+ return ret >>> 0;
491
+ }
492
+ /**
493
+ * Read a camera hardware register (index 0x00–0x7F → addresses 0xA000–0xA07F).
494
+ * @param {number} index
495
+ * @returns {number}
496
+ */
497
+ camera_reg(index) {
498
+ const ret = wasm.gameboy_camera_reg(this.__wbg_ptr, index);
499
+ return ret;
500
+ }
501
+ clear_serial_output() {
502
+ wasm.gameboy_clear_serial_output(this.__wbg_ptr);
503
+ }
504
+ /**
505
+ * @returns {number}
506
+ */
507
+ cpu_a() {
508
+ const ret = wasm.gameboy_cpu_a(this.__wbg_ptr);
509
+ return ret;
510
+ }
511
+ /**
512
+ * @returns {number}
513
+ */
514
+ cpu_bc() {
515
+ const ret = wasm.gameboy_cpu_bc(this.__wbg_ptr);
516
+ return ret;
517
+ }
518
+ /**
519
+ * @returns {number}
520
+ */
521
+ cpu_de() {
522
+ const ret = wasm.gameboy_cpu_de(this.__wbg_ptr);
523
+ return ret;
524
+ }
525
+ /**
526
+ * @returns {number}
527
+ */
528
+ cpu_f() {
529
+ const ret = wasm.gameboy_cpu_f(this.__wbg_ptr);
530
+ return ret;
531
+ }
532
+ /**
533
+ * @returns {boolean}
534
+ */
535
+ cpu_halted() {
536
+ const ret = wasm.gameboy_cpu_halted(this.__wbg_ptr);
537
+ return ret !== 0;
538
+ }
539
+ /**
540
+ * @returns {number}
541
+ */
542
+ cpu_hl() {
543
+ const ret = wasm.gameboy_cpu_hl(this.__wbg_ptr);
544
+ return ret;
545
+ }
546
+ /**
547
+ * @returns {boolean}
548
+ */
549
+ cpu_ime() {
550
+ const ret = wasm.gameboy_cpu_ime(this.__wbg_ptr);
551
+ return ret !== 0;
552
+ }
553
+ /**
554
+ * @returns {number}
555
+ */
556
+ cpu_pc() {
557
+ const ret = wasm.gameboy_cpu_pc(this.__wbg_ptr);
558
+ return ret;
559
+ }
560
+ /**
561
+ * @returns {number}
562
+ */
563
+ cpu_sp() {
564
+ const ret = wasm.gameboy_cpu_sp(this.__wbg_ptr);
565
+ return ret;
566
+ }
567
+ /**
568
+ * Decode a saved photo slot (1–30) to RGBA. Returns empty if unoccupied.
569
+ * @param {number} slot
570
+ * @returns {Uint8Array}
571
+ */
572
+ decode_camera_photo(slot) {
573
+ const ret = wasm.gameboy_decode_camera_photo(this.__wbg_ptr, slot);
574
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
575
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
576
+ return v1;
577
+ }
578
+ /**
579
+ * @returns {number}
580
+ */
581
+ frame_buffer_len() {
582
+ const ret = wasm.gameboy_frame_buffer_len(this.__wbg_ptr);
583
+ return ret >>> 0;
584
+ }
585
+ /**
586
+ * Pointer to the front frame buffer (160×144 RGBA pixels).
587
+ * Valid until the next `step_frame` call.
588
+ * @returns {number}
589
+ */
590
+ frame_buffer_ptr() {
591
+ const ret = wasm.gameboy_frame_buffer_ptr(this.__wbg_ptr);
592
+ return ret >>> 0;
593
+ }
594
+ /**
595
+ * Colour of `color` (0–3) in BG palette `palette` (0–7) as 0xRRGGBB.
596
+ * @param {number} palette
597
+ * @param {number} color
598
+ * @returns {number}
599
+ */
600
+ get_bg_palette_color(palette, color) {
601
+ const ret = wasm.gameboy_get_bg_palette_color(this.__wbg_ptr, palette, color);
602
+ return ret >>> 0;
603
+ }
604
+ /**
605
+ * @returns {Uint8Array}
606
+ */
607
+ get_cartridge_ram() {
608
+ const ret = wasm.gameboy_get_cartridge_ram(this.__wbg_ptr);
609
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
610
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
611
+ return v1;
612
+ }
613
+ /**
614
+ * @returns {number}
615
+ */
616
+ get_cartridge_ram_len() {
617
+ const ret = wasm.gameboy_get_cartridge_ram_len(this.__wbg_ptr);
618
+ return ret >>> 0;
619
+ }
620
+ /**
621
+ * @returns {number}
622
+ */
623
+ get_cartridge_ram_ptr() {
624
+ const ret = wasm.gameboy_get_cartridge_ram_ptr(this.__wbg_ptr);
625
+ return ret >>> 0;
626
+ }
627
+ /**
628
+ * Lightweight status string: MBC type, ROM banks, LCDC, LY.
629
+ * @returns {string}
630
+ */
631
+ get_debug_info() {
632
+ let deferred1_0;
633
+ let deferred1_1;
634
+ try {
635
+ const ret = wasm.gameboy_get_debug_info(this.__wbg_ptr);
636
+ deferred1_0 = ret[0];
637
+ deferred1_1 = ret[1];
638
+ return getStringFromWasm0(ret[0], ret[1]);
639
+ } finally {
640
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
641
+ }
642
+ }
643
+ /**
644
+ * @returns {number}
645
+ */
646
+ get_frame_count() {
647
+ const ret = wasm.gameboy_get_frame_count(this.__wbg_ptr);
648
+ return ret >>> 0;
649
+ }
650
+ /**
651
+ * @returns {bigint}
652
+ */
653
+ get_instruction_count() {
654
+ const ret = wasm.gameboy_get_instruction_count(this.__wbg_ptr);
655
+ return BigInt.asUintN(64, ret);
656
+ }
657
+ /**
658
+ * Colour of `color` (0–3) in OBJ palette `palette` (0–7) as 0xRRGGBB.
659
+ * @param {number} palette
660
+ * @param {number} color
661
+ * @returns {number}
662
+ */
663
+ get_obj_palette_color(palette, color) {
664
+ const ret = wasm.gameboy_get_obj_palette_color(this.__wbg_ptr, palette, color);
665
+ return ret >>> 0;
666
+ }
667
+ /**
668
+ * Serial output as a string (useful for test ROM output on 0xFF01/0xFF02).
669
+ * @returns {string}
670
+ */
671
+ get_serial_output() {
672
+ let deferred1_0;
673
+ let deferred1_1;
674
+ try {
675
+ const ret = wasm.gameboy_get_serial_output(this.__wbg_ptr);
676
+ deferred1_0 = ret[0];
677
+ deferred1_1 = ret[1];
678
+ return getStringFromWasm0(ret[0], ret[1]);
679
+ } finally {
680
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
681
+ }
682
+ }
683
+ /**
684
+ * BCPS: BG palette index (bit 7 = auto-increment, bits 5–0 = byte address).
685
+ * @returns {number}
686
+ */
687
+ io_bcps() {
688
+ const ret = wasm.gameboy_io_bcps(this.__wbg_ptr);
689
+ return ret;
690
+ }
691
+ /**
692
+ * @returns {number}
693
+ */
694
+ io_bgp() {
695
+ const ret = wasm.gameboy_io_bgp(this.__wbg_ptr);
696
+ return ret;
697
+ }
698
+ /**
699
+ * @returns {number}
700
+ */
701
+ io_div() {
702
+ const ret = wasm.gameboy_io_div(this.__wbg_ptr);
703
+ return ret;
704
+ }
705
+ /**
706
+ * HDMA5: 0xFF = idle; otherwise H-blank DMA active, bits 6–0 = remaining blocks − 1.
707
+ * @returns {number}
708
+ */
709
+ io_hdma5() {
710
+ const ret = wasm.gameboy_io_hdma5(this.__wbg_ptr);
711
+ return ret;
712
+ }
713
+ /**
714
+ * @returns {number}
715
+ */
716
+ io_ie() {
717
+ const ret = wasm.gameboy_io_ie(this.__wbg_ptr);
718
+ return ret;
719
+ }
720
+ /**
721
+ * @returns {number}
722
+ */
723
+ io_if() {
724
+ const ret = wasm.gameboy_io_if(this.__wbg_ptr);
725
+ return ret;
726
+ }
727
+ /**
728
+ * @returns {number}
729
+ */
730
+ io_joypad() {
731
+ const ret = wasm.gameboy_io_joypad(this.__wbg_ptr);
732
+ return ret;
733
+ }
734
+ /**
735
+ * KEY1: speed-switch (bit 7 = current speed, bit 0 = armed).
736
+ * @returns {number}
737
+ */
738
+ io_key1() {
739
+ const ret = wasm.gameboy_io_key1(this.__wbg_ptr);
740
+ return ret;
741
+ }
742
+ /**
743
+ * @returns {number}
744
+ */
745
+ io_lcdc() {
746
+ const ret = wasm.gameboy_io_lcdc(this.__wbg_ptr);
747
+ return ret;
748
+ }
749
+ /**
750
+ * @returns {number}
751
+ */
752
+ io_ly() {
753
+ const ret = wasm.gameboy_io_ly(this.__wbg_ptr);
754
+ return ret;
755
+ }
756
+ /**
757
+ * @returns {number}
758
+ */
759
+ io_lyc() {
760
+ const ret = wasm.gameboy_io_lyc(this.__wbg_ptr);
761
+ return ret;
762
+ }
763
+ /**
764
+ * @returns {number}
765
+ */
766
+ io_obp0() {
767
+ const ret = wasm.gameboy_io_obp0(this.__wbg_ptr);
768
+ return ret;
769
+ }
770
+ /**
771
+ * @returns {number}
772
+ */
773
+ io_obp1() {
774
+ const ret = wasm.gameboy_io_obp1(this.__wbg_ptr);
775
+ return ret;
776
+ }
777
+ /**
778
+ * OCPS: OBJ palette index (same layout as BCPS).
779
+ * @returns {number}
780
+ */
781
+ io_ocps() {
782
+ const ret = wasm.gameboy_io_ocps(this.__wbg_ptr);
783
+ return ret;
784
+ }
785
+ /**
786
+ * OPRI: Object priority mode (bit 0: 0 = CGB coordinate, 1 = DMG OAM order).
787
+ * @returns {number}
788
+ */
789
+ io_opri() {
790
+ const ret = wasm.gameboy_io_opri(this.__wbg_ptr);
791
+ return ret;
792
+ }
793
+ /**
794
+ * @returns {number}
795
+ */
796
+ io_scx() {
797
+ const ret = wasm.gameboy_io_scx(this.__wbg_ptr);
798
+ return ret;
799
+ }
800
+ /**
801
+ * @returns {number}
802
+ */
803
+ io_scy() {
804
+ const ret = wasm.gameboy_io_scy(this.__wbg_ptr);
805
+ return ret;
806
+ }
807
+ /**
808
+ * @returns {number}
809
+ */
810
+ io_stat() {
811
+ const ret = wasm.gameboy_io_stat(this.__wbg_ptr);
812
+ return ret;
813
+ }
814
+ /**
815
+ * SVBK: current WRAM bank (1–7; 0 maps to 1).
816
+ * @returns {number}
817
+ */
818
+ io_svbk() {
819
+ const ret = wasm.gameboy_io_svbk(this.__wbg_ptr);
820
+ return ret;
821
+ }
822
+ /**
823
+ * @returns {number}
824
+ */
825
+ io_tac() {
826
+ const ret = wasm.gameboy_io_tac(this.__wbg_ptr);
827
+ return ret;
828
+ }
829
+ /**
830
+ * @returns {number}
831
+ */
832
+ io_tima() {
833
+ const ret = wasm.gameboy_io_tima(this.__wbg_ptr);
834
+ return ret;
835
+ }
836
+ /**
837
+ * @returns {number}
838
+ */
839
+ io_tma() {
840
+ const ret = wasm.gameboy_io_tma(this.__wbg_ptr);
841
+ return ret;
842
+ }
843
+ /**
844
+ * VBK: current VRAM bank (0 or 1).
845
+ * @returns {number}
846
+ */
847
+ io_vbk() {
848
+ const ret = wasm.gameboy_io_vbk(this.__wbg_ptr);
849
+ return ret;
850
+ }
851
+ /**
852
+ * @returns {number}
853
+ */
854
+ io_wx() {
855
+ const ret = wasm.gameboy_io_wx(this.__wbg_ptr);
856
+ return ret;
857
+ }
858
+ /**
859
+ * @returns {number}
860
+ */
861
+ io_wy() {
862
+ const ret = wasm.gameboy_io_wy(this.__wbg_ptr);
863
+ return ret;
864
+ }
865
+ /**
866
+ * @returns {boolean}
867
+ */
868
+ is_camera() {
869
+ const ret = wasm.gameboy_is_camera(this.__wbg_ptr);
870
+ return ret !== 0;
871
+ }
872
+ /**
873
+ * @returns {boolean}
874
+ */
875
+ is_camera_ready() {
876
+ const ret = wasm.gameboy_is_camera_ready(this.__wbg_ptr);
877
+ return ret !== 0;
878
+ }
879
+ /**
880
+ * @returns {boolean}
881
+ */
882
+ is_cgb_mode() {
883
+ const ret = wasm.gameboy_is_cgb_mode(this.__wbg_ptr);
884
+ return ret !== 0;
885
+ }
886
+ /**
887
+ * @returns {boolean}
888
+ */
889
+ is_mbc7() {
890
+ const ret = wasm.gameboy_is_mbc7(this.__wbg_ptr);
891
+ return ret !== 0;
892
+ }
893
+ /**
894
+ * @param {Uint8Array} data
895
+ */
896
+ load_cartridge_ram(data) {
897
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
898
+ const len0 = WASM_VECTOR_LEN;
899
+ wasm.gameboy_load_cartridge_ram(this.__wbg_ptr, ptr0, len0);
900
+ }
901
+ /**
902
+ * @param {Uint8Array} rom_data
903
+ * @param {boolean} cgb_mode
904
+ */
905
+ load_rom(rom_data, cgb_mode) {
906
+ const ptr0 = passArray8ToWasm0(rom_data, wasm.__wbindgen_malloc);
907
+ const len0 = WASM_VECTOR_LEN;
908
+ const ret = wasm.gameboy_load_rom(this.__wbg_ptr, ptr0, len0, cgb_mode);
909
+ if (ret[1]) {
910
+ throw takeFromExternrefTable0(ret[0]);
911
+ }
912
+ }
913
+ /**
914
+ * @param {string} msg
915
+ */
916
+ log(msg) {
917
+ const ptr0 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
918
+ const len0 = WASM_VECTOR_LEN;
919
+ wasm.gameboy_log(this.__wbg_ptr, ptr0, len0);
920
+ }
921
+ log_vram_info() {
922
+ wasm.gameboy_log_vram_info(this.__wbg_ptr);
923
+ }
924
+ /**
925
+ * Convert a MIDI note number (0–127) to a name string like "C-4" or "A#3".
926
+ * @param {number} note
927
+ * @returns {string}
928
+ */
929
+ static midi_to_note_name(note) {
930
+ let deferred1_0;
931
+ let deferred1_1;
932
+ try {
933
+ const ret = wasm.gameboy_midi_to_note_name(note);
934
+ deferred1_0 = ret[0];
935
+ deferred1_1 = ret[1];
936
+ return getStringFromWasm0(ret[0], ret[1]);
937
+ } finally {
938
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
939
+ }
940
+ }
941
+ constructor() {
942
+ const ret = wasm.gameboy_new();
943
+ this.__wbg_ptr = ret >>> 0;
944
+ GameBoyFinalization.register(this, this.__wbg_ptr, this);
945
+ return this;
946
+ }
947
+ /**
948
+ * @returns {number}
949
+ */
950
+ ppu_cycles() {
951
+ const ret = wasm.gameboy_ppu_cycles(this.__wbg_ptr);
952
+ return ret >>> 0;
953
+ }
954
+ /**
955
+ * @returns {number}
956
+ */
957
+ ppu_line() {
958
+ const ret = wasm.gameboy_ppu_line(this.__wbg_ptr);
959
+ return ret;
960
+ }
961
+ /**
962
+ * @returns {number}
963
+ */
964
+ ppu_mode() {
965
+ const ret = wasm.gameboy_ppu_mode(this.__wbg_ptr);
966
+ return ret;
967
+ }
968
+ /**
969
+ * @param {number} addr
970
+ * @returns {number}
971
+ */
972
+ read_byte(addr) {
973
+ const ret = wasm.gameboy_read_byte(this.__wbg_ptr, addr);
974
+ return ret;
975
+ }
976
+ /**
977
+ * @param {number} addr
978
+ * @param {number} len
979
+ * @returns {Uint8Array}
980
+ */
981
+ read_range(addr, len) {
982
+ const ret = wasm.gameboy_read_range(this.__wbg_ptr, addr, len);
983
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
984
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
985
+ return v1;
986
+ }
987
+ /**
988
+ * Read `len` bytes from VRAM bank `bank` (0 or 1) at `addr` (0x8000–0x9FFF).
989
+ * Does not modify VBK — safe to call at any time.
990
+ * @param {number} bank
991
+ * @param {number} addr
992
+ * @param {number} len
993
+ * @returns {Uint8Array}
994
+ */
995
+ read_vram_bank(bank, addr, len) {
996
+ const ret = wasm.gameboy_read_vram_bank(this.__wbg_ptr, bank, addr, len);
997
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
998
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
999
+ return v1;
1000
+ }
1001
+ /**
1002
+ * Power-cycle: resets CPU, PPU, APU, timer, and MBC banking state.
1003
+ * Save RAM is cleared; call `load_cartridge_ram` afterwards to restore it.
1004
+ */
1005
+ reset() {
1006
+ wasm.gameboy_reset(this.__wbg_ptr);
1007
+ }
1008
+ /**
1009
+ * Deliver one byte as if sent by an external device on the serial link.
1010
+ * Fires the serial interrupt (IF bit 3).
1011
+ * @param {number} byte
1012
+ */
1013
+ serial_receive(byte) {
1014
+ wasm.gameboy_serial_receive(this.__wbg_ptr, byte);
1015
+ }
1016
+ /**
1017
+ * Return and consume the oldest byte transmitted on the serial port,
1018
+ * or `undefined` if nothing was sent.
1019
+ * @returns {number | undefined}
1020
+ */
1021
+ serial_take_output() {
1022
+ const ret = wasm.gameboy_serial_take_output(this.__wbg_ptr);
1023
+ return ret === 0xFFFFFF ? undefined : ret;
1024
+ }
1025
+ /**
1026
+ * Feed a tilt reading to the MBC7 accelerometer.
1027
+ * `x`/`y` are signed offsets from flat; ±0x1000 ≈ ±1g.
1028
+ * @param {number} x
1029
+ * @param {number} y
1030
+ */
1031
+ set_accelerometer(x, y) {
1032
+ wasm.gameboy_set_accelerometer(this.__wbg_ptr, x, y);
1033
+ }
1034
+ /**
1035
+ * @param {Button} button
1036
+ * @param {boolean} pressed
1037
+ */
1038
+ set_button(button, pressed) {
1039
+ wasm.gameboy_set_button(this.__wbg_ptr, button, pressed);
1040
+ }
1041
+ /**
1042
+ * Set camera image data from a live capture source.
1043
+ * Expects 128×112 pixels as raw 8-bit grayscale (0 = black, 255 = white).
1044
+ * @param {Uint8Array} data
1045
+ */
1046
+ set_camera_image(data) {
1047
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
1048
+ const len0 = WASM_VECTOR_LEN;
1049
+ wasm.gameboy_set_camera_image(this.__wbg_ptr, ptr0, len0);
1050
+ }
1051
+ /**
1052
+ * Run one full frame of emulation (~16.74 ms of Game Boy time).
1053
+ */
1054
+ step_frame() {
1055
+ wasm.gameboy_step_frame(this.__wbg_ptr);
1056
+ }
1057
+ /**
1058
+ * Execute a single CPU instruction. Returns T-cycles consumed.
1059
+ * @returns {number}
1060
+ */
1061
+ step_instruction() {
1062
+ const ret = wasm.gameboy_step_instruction(this.__wbg_ptr);
1063
+ return ret >>> 0;
1064
+ }
1065
+ /**
1066
+ * Run until at least `n` stereo sample pairs are in the audio buffer.
1067
+ * Returns the number of pairs actually generated.
1068
+ * @param {number} n
1069
+ * @returns {number}
1070
+ */
1071
+ step_samples(n) {
1072
+ const ret = wasm.gameboy_step_samples(this.__wbg_ptr, n);
1073
+ return ret >>> 0;
1074
+ }
1075
+ /**
1076
+ * Update the camera live-view buffer. Returns true if the buffer changed.
1077
+ * @returns {boolean}
1078
+ */
1079
+ update_camera_live() {
1080
+ const ret = wasm.gameboy_update_camera_live(this.__wbg_ptr);
1081
+ return ret !== 0;
1082
+ }
1083
+ /**
1084
+ * Write one byte to cartridge SRAM at flat `.sav` offset `offset`,
1085
+ * bypassing MBC bank selection.
1086
+ * @param {number} offset
1087
+ * @param {number} value
1088
+ */
1089
+ write_cartridge_ram(offset, value) {
1090
+ wasm.gameboy_write_cartridge_ram(this.__wbg_ptr, offset, value);
1091
+ }
1092
+ /**
1093
+ * Write a contiguous slice to cartridge SRAM starting at flat offset `offset`.
1094
+ * @param {number} offset
1095
+ * @param {Uint8Array} data
1096
+ */
1097
+ write_cartridge_ram_range(offset, data) {
1098
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
1099
+ const len0 = WASM_VECTOR_LEN;
1100
+ wasm.gameboy_write_cartridge_ram_range(this.__wbg_ptr, offset, ptr0, len0);
1101
+ }
1102
+ }
1103
+ if (Symbol.dispose) GameBoy.prototype[Symbol.dispose] = GameBoy.prototype.free;
1104
+
1105
+ /**
1106
+ * Initialize panic hook for better error messages in WASM.
1107
+ * Called automatically when the WASM module is instantiated.
1108
+ */
1109
+ export function init_panic_hook() {
1110
+ wasm.init_panic_hook();
1111
+ }
1112
+
1113
+ function __wbg_get_imports() {
1114
+ const import0 = {
1115
+ __proto__: null,
1116
+ __wbg___wbindgen_throw_5549492daedad139: function(arg0, arg1) {
1117
+ throw new Error(getStringFromWasm0(arg0, arg1));
1118
+ },
1119
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
1120
+ let deferred0_0;
1121
+ let deferred0_1;
1122
+ try {
1123
+ deferred0_0 = arg0;
1124
+ deferred0_1 = arg1;
1125
+ console.error(getStringFromWasm0(arg0, arg1));
1126
+ } finally {
1127
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1128
+ }
1129
+ },
1130
+ __wbg_log_6a75b71d6316e935: function(arg0) {
1131
+ console.log(arg0);
1132
+ },
1133
+ __wbg_new_227d7c05414eb861: function() {
1134
+ const ret = new Error();
1135
+ return ret;
1136
+ },
1137
+ __wbg_now_46736a527d2e74e7: function() {
1138
+ const ret = Date.now();
1139
+ return ret;
1140
+ },
1141
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
1142
+ const ret = arg1.stack;
1143
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1144
+ const len1 = WASM_VECTOR_LEN;
1145
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1146
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1147
+ },
1148
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1149
+ // Cast intrinsic for `Ref(String) -> Externref`.
1150
+ const ret = getStringFromWasm0(arg0, arg1);
1151
+ return ret;
1152
+ },
1153
+ __wbindgen_init_externref_table: function() {
1154
+ const table = wasm.__wbindgen_externrefs;
1155
+ const offset = table.grow(4);
1156
+ table.set(0, undefined);
1157
+ table.set(offset + 0, undefined);
1158
+ table.set(offset + 1, null);
1159
+ table.set(offset + 2, true);
1160
+ table.set(offset + 3, false);
1161
+ },
1162
+ };
1163
+ return {
1164
+ __proto__: null,
1165
+ "./gb_emu_bg.js": import0,
1166
+ };
1167
+ }
1168
+
1169
+ const GameBoyFinalization = (typeof FinalizationRegistry === 'undefined')
1170
+ ? { register: () => {}, unregister: () => {} }
1171
+ : new FinalizationRegistry(ptr => wasm.__wbg_gameboy_free(ptr >>> 0, 1));
1172
+
1173
+ function getArrayU8FromWasm0(ptr, len) {
1174
+ ptr = ptr >>> 0;
1175
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1176
+ }
1177
+
1178
+ let cachedDataViewMemory0 = null;
1179
+ function getDataViewMemory0() {
1180
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1181
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1182
+ }
1183
+ return cachedDataViewMemory0;
1184
+ }
1185
+
1186
+ function getStringFromWasm0(ptr, len) {
1187
+ ptr = ptr >>> 0;
1188
+ return decodeText(ptr, len);
1189
+ }
1190
+
1191
+ let cachedUint8ArrayMemory0 = null;
1192
+ function getUint8ArrayMemory0() {
1193
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1194
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1195
+ }
1196
+ return cachedUint8ArrayMemory0;
1197
+ }
1198
+
1199
+ function passArray8ToWasm0(arg, malloc) {
1200
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1201
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1202
+ WASM_VECTOR_LEN = arg.length;
1203
+ return ptr;
1204
+ }
1205
+
1206
+ function passStringToWasm0(arg, malloc, realloc) {
1207
+ if (realloc === undefined) {
1208
+ const buf = cachedTextEncoder.encode(arg);
1209
+ const ptr = malloc(buf.length, 1) >>> 0;
1210
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1211
+ WASM_VECTOR_LEN = buf.length;
1212
+ return ptr;
1213
+ }
1214
+
1215
+ let len = arg.length;
1216
+ let ptr = malloc(len, 1) >>> 0;
1217
+
1218
+ const mem = getUint8ArrayMemory0();
1219
+
1220
+ let offset = 0;
1221
+
1222
+ for (; offset < len; offset++) {
1223
+ const code = arg.charCodeAt(offset);
1224
+ if (code > 0x7F) break;
1225
+ mem[ptr + offset] = code;
1226
+ }
1227
+ if (offset !== len) {
1228
+ if (offset !== 0) {
1229
+ arg = arg.slice(offset);
1230
+ }
1231
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1232
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1233
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1234
+
1235
+ offset += ret.written;
1236
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1237
+ }
1238
+
1239
+ WASM_VECTOR_LEN = offset;
1240
+ return ptr;
1241
+ }
1242
+
1243
+ function takeFromExternrefTable0(idx) {
1244
+ const value = wasm.__wbindgen_externrefs.get(idx);
1245
+ wasm.__externref_table_dealloc(idx);
1246
+ return value;
1247
+ }
1248
+
1249
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1250
+ cachedTextDecoder.decode();
1251
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1252
+ let numBytesDecoded = 0;
1253
+ function decodeText(ptr, len) {
1254
+ numBytesDecoded += len;
1255
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1256
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1257
+ cachedTextDecoder.decode();
1258
+ numBytesDecoded = len;
1259
+ }
1260
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1261
+ }
1262
+
1263
+ const cachedTextEncoder = new TextEncoder();
1264
+
1265
+ if (!('encodeInto' in cachedTextEncoder)) {
1266
+ cachedTextEncoder.encodeInto = function (arg, view) {
1267
+ const buf = cachedTextEncoder.encode(arg);
1268
+ view.set(buf);
1269
+ return {
1270
+ read: arg.length,
1271
+ written: buf.length
1272
+ };
1273
+ };
1274
+ }
1275
+
1276
+ let WASM_VECTOR_LEN = 0;
1277
+
1278
+ let wasmModule, wasm;
1279
+ function __wbg_finalize_init(instance, module) {
1280
+ wasm = instance.exports;
1281
+ wasmModule = module;
1282
+ cachedDataViewMemory0 = null;
1283
+ cachedUint8ArrayMemory0 = null;
1284
+ wasm.__wbindgen_start();
1285
+ return wasm;
1286
+ }
1287
+
1288
+ async function __wbg_load(module, imports) {
1289
+ if (typeof Response === 'function' && module instanceof Response) {
1290
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1291
+ try {
1292
+ return await WebAssembly.instantiateStreaming(module, imports);
1293
+ } catch (e) {
1294
+ const validResponse = module.ok && expectedResponseType(module.type);
1295
+
1296
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1297
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1298
+
1299
+ } else { throw e; }
1300
+ }
1301
+ }
1302
+
1303
+ const bytes = await module.arrayBuffer();
1304
+ return await WebAssembly.instantiate(bytes, imports);
1305
+ } else {
1306
+ const instance = await WebAssembly.instantiate(module, imports);
1307
+
1308
+ if (instance instanceof WebAssembly.Instance) {
1309
+ return { instance, module };
1310
+ } else {
1311
+ return instance;
1312
+ }
1313
+ }
1314
+
1315
+ function expectedResponseType(type) {
1316
+ switch (type) {
1317
+ case 'basic': case 'cors': case 'default': return true;
1318
+ }
1319
+ return false;
1320
+ }
1321
+ }
1322
+
1323
+ function initSync(module) {
1324
+ if (wasm !== undefined) return wasm;
1325
+
1326
+
1327
+ if (module !== undefined) {
1328
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1329
+ ({module} = module)
1330
+ } else {
1331
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1332
+ }
1333
+ }
1334
+
1335
+ const imports = __wbg_get_imports();
1336
+ if (!(module instanceof WebAssembly.Module)) {
1337
+ module = new WebAssembly.Module(module);
1338
+ }
1339
+ const instance = new WebAssembly.Instance(module, imports);
1340
+ return __wbg_finalize_init(instance, module);
1341
+ }
1342
+
1343
+ async function __wbg_init(module_or_path) {
1344
+ if (wasm !== undefined) return wasm;
1345
+
1346
+
1347
+ if (module_or_path !== undefined) {
1348
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1349
+ ({module_or_path} = module_or_path)
1350
+ } else {
1351
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1352
+ }
1353
+ }
1354
+
1355
+ if (module_or_path === undefined) {
1356
+ module_or_path = new URL('gb_emu_bg.wasm', import.meta.url);
1357
+ }
1358
+ const imports = __wbg_get_imports();
1359
+
1360
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1361
+ module_or_path = fetch(module_or_path);
1362
+ }
1363
+
1364
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1365
+
1366
+ return __wbg_finalize_init(instance, module);
1367
+ }
1368
+
1369
+ export { initSync, __wbg_init as default };