let wasm; const heap = new Array(32).fill(undefined); heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } let heap_next = heap.length; function dropObject(idx) { if (idx < 36) return; heap[idx] = heap_next; heap_next = idx; } function takeObject(idx) { const ret = getObject(idx); dropObject(idx); return ret; } function addHeapObject(obj) { if (heap_next === heap.length) heap.push(heap.length + 1); const idx = heap_next; heap_next = heap[idx]; heap[idx] = obj; return idx; } const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); let cachegetUint8Memory0 = null; function getUint8Memory0() { if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); } return cachegetUint8Memory0; } function getStringFromWasm0(ptr, len) { return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); } let WASM_VECTOR_LEN = 0; function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1); getUint8Memory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { wasm.__wbindgen_exn_store(addHeapObject(e)); } } function getArrayU8FromWasm0(ptr, len) { return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); } /** */ export class Chip8Classic { static __wrap(ptr) { const obj = Object.create(Chip8Classic.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_chip8classic_free(ptr); } /** */ constructor() { const ret = wasm.chip8classic_new(); return Chip8Classic.__wrap(ret); } } /** */ export class Chip8Neo { static __wrap(ptr) { const obj = Object.create(Chip8Neo.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_chip8neo_free(ptr); } /** */ constructor() { const ret = wasm.chip8neo_new(); return Chip8Neo.__wrap(ret); } /** * @param {Uint8Array} rom */ load_rom_ws(rom) { const ptr0 = passArray8ToWasm0(rom, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; wasm.chip8neo_load_rom_ws(this.ptr, ptr0, len0); } /** */ reset_ws() { wasm.chip8neo_reset_ws(this.ptr); } /** */ reset_hard_ws() { wasm.chip8neo_reset_hard_ws(this.ptr); } /** */ clock_ws() { wasm.chip8neo_clock_ws(this.ptr); } } async function load(module, imports) { if (typeof Response === 'function' && module instanceof Response) { if (typeof WebAssembly.instantiateStreaming === 'function') { try { return await WebAssembly.instantiateStreaming(module, imports); } catch (e) { if (module.headers.get('Content-Type') != 'application/wasm') { 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); } else { throw e; } } } const bytes = await module.arrayBuffer(); return await WebAssembly.instantiate(bytes, imports); } else { const instance = await WebAssembly.instantiate(module, imports); if (instance instanceof WebAssembly.Instance) { return { instance, module }; } else { return instance; } } } async function init(input) { if (typeof input === 'undefined') { input = new URL('chip_ahoyto_bg.wasm', import.meta.url); } const imports = {}; imports.wbg = {}; imports.wbg.__wbg_process_e56fd54cf6319b6c = function(arg0) { const ret = getObject(arg0).process; return addHeapObject(ret); }; imports.wbg.__wbindgen_is_object = function(arg0) { const val = getObject(arg0); const ret = typeof(val) === 'object' && val !== null; return ret; }; imports.wbg.__wbg_versions_77e21455908dad33 = function(arg0) { const ret = getObject(arg0).versions; return addHeapObject(ret); }; imports.wbg.__wbindgen_object_drop_ref = function(arg0) { takeObject(arg0); }; imports.wbg.__wbg_node_0dd25d832e4785d5 = function(arg0) { const ret = getObject(arg0).node; return addHeapObject(ret); }; imports.wbg.__wbindgen_is_string = function(arg0) { const ret = typeof(getObject(arg0)) === 'string'; return ret; }; imports.wbg.__wbg_static_accessor_NODE_MODULE_26b231378c1be7dd = function() { const ret = module; return addHeapObject(ret); }; imports.wbg.__wbg_require_0db1598d9ccecb30 = function() { return handleError(function (arg0, arg1, arg2) { const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2)); return addHeapObject(ret); }, arguments) }; imports.wbg.__wbg_crypto_b95d7173266618a9 = function(arg0) { const ret = getObject(arg0).crypto; return addHeapObject(ret); }; imports.wbg.__wbg_msCrypto_5a86d77a66230f81 = function(arg0) { const ret = getObject(arg0).msCrypto; return addHeapObject(ret); }; imports.wbg.__wbg_getRandomValues_b14734aa289bc356 = function() { return handleError(function (arg0, arg1) { getObject(arg0).getRandomValues(getObject(arg1)); }, arguments) }; imports.wbg.__wbg_randomFillSync_91e2b39becca6147 = function() { return handleError(function (arg0, arg1, arg2) { getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); }, arguments) }; imports.wbg.__wbg_newnoargs_e23b458e372830de = function(arg0, arg1) { const ret = new Function(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; imports.wbg.__wbg_call_ae78342adc33730a = function() { return handleError(function (arg0, arg1) { const ret = getObject(arg0).call(getObject(arg1)); return addHeapObject(ret); }, arguments) }; imports.wbg.__wbindgen_object_clone_ref = function(arg0) { const ret = getObject(arg0); return addHeapObject(ret); }; imports.wbg.__wbg_self_99737b4dcdf6f0d8 = function() { return handleError(function () { const ret = self.self; return addHeapObject(ret); }, arguments) }; imports.wbg.__wbg_window_9b61fbbf3564c4fb = function() { return handleError(function () { const ret = window.window; return addHeapObject(ret); }, arguments) }; imports.wbg.__wbg_globalThis_8e275ef40caea3a3 = function() { return handleError(function () { const ret = globalThis.globalThis; return addHeapObject(ret); }, arguments) }; imports.wbg.__wbg_global_5de1e0f82bddcd27 = function() { return handleError(function () { const ret = global.global; return addHeapObject(ret); }, arguments) }; imports.wbg.__wbindgen_is_undefined = function(arg0) { const ret = getObject(arg0) === undefined; return ret; }; imports.wbg.__wbg_buffer_7af23f65f6c64548 = function(arg0) { const ret = getObject(arg0).buffer; return addHeapObject(ret); }; imports.wbg.__wbg_new_cc9018bd6f283b6f = function(arg0) { const ret = new Uint8Array(getObject(arg0)); return addHeapObject(ret); }; imports.wbg.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) { getObject(arg0).set(getObject(arg1), arg2 >>> 0); }; imports.wbg.__wbg_length_0acb1cf9bbaf8519 = function(arg0) { const ret = getObject(arg0).length; return ret; }; imports.wbg.__wbg_newwithlength_8f0657faca9f1422 = function(arg0) { const ret = new Uint8Array(arg0 >>> 0); return addHeapObject(ret); }; imports.wbg.__wbg_subarray_da527dbd24eafb6b = function(arg0, arg1, arg2) { const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; imports.wbg.__wbindgen_throw = function(arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; imports.wbg.__wbindgen_memory = function() { const ret = wasm.memory; return addHeapObject(ret); }; if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { input = fetch(input); } const { instance, module } = await load(await input, imports); wasm = instance.exports; init.__wbindgen_wasm_module = module; return wasm; } export default init;