diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-11-02 00:00:35 +0100 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-11-02 00:00:35 +0100 |
commit | 48c5d9b83afd1cd56e73449aebaf461cb48360d9 (patch) | |
tree | 41127704d20b1ee53fa1034e53339c22ca4c820d /index.htm | |
parent | 2afdeaedbfb488f20cdc1cca7ce01a915df4d53a (diff) | |
download | reduced_system_layer-48c5d9b83afd1cd56e73449aebaf461cb48360d9.zip |
wasm: Fix memcpy, memset
Diffstat (limited to 'index.htm')
-rw-r--r-- | index.htm | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -9,13 +9,11 @@ <body style="margin: 0; height: 100%; overflow: hidden; overflow-x: hidden;"> <canvas style="margin: 0; width: 100%; height: 100%;" id="frame" oncontextmenu="event.preventDefault()"></canvas> <script type="text/javascript"> - function string_from_memory(memory, offset) { + function string_from_memory(bytes, offset) { let len = 0; - console.log(memory); - while (memory[offset + len] != 0) { + while (bytes[offset + len] != 0) ++len; - } - return new TextDecoder().decode(memory.subarray(offset, offset + len)); + return new TextDecoder("utf8").decode(bytes.subarray(offset, offset + len)); } async function run(attrs) { @@ -78,18 +76,16 @@ floor : Math.floor, ceil : Math.ceil, memset : (dst, val, num) => { - for (let i = 0; i < num; ++i) - dst[i] = val; + program.instance.exports.js_memset(dst, val, num); }, memcpy : (dst, src, num) => { - for (let i = 0; i < num; ++i) - dst[i] = src[i]; + program.instance.exports.js_memcpy(dst, src, num); }, }, } ); - program.instance.exports.js_main(); + program.instance.exports.js_main(document.location.href); animation_frame = (time) => { if (attrs.fit_window) { |