summaryrefslogtreecommitdiff
path: root/index.htm
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2025-02-22 00:23:06 +0100
committerMitya Selivanov <automainint@guattari.tech>2025-02-22 00:23:06 +0100
commit2e193910ca6de4486eb39e9a7decf162cfa1f160 (patch)
treec3e76de0e0eaf8325dc05b1b99fc41863ac5d6fb /index.htm
parent7d92468a5d298ec6dd6455482ff0521efecf9541 (diff)
downloadreduced_system_layer-2e193910ca6de4486eb39e9a7decf162cfa1f160.zip
Fix web pixel buffer access
Diffstat (limited to 'index.htm')
-rw-r--r--index.htm19
1 files changed, 11 insertions, 8 deletions
diff --git a/index.htm b/index.htm
index f94bdca..ce6a2a9 100644
--- a/index.htm
+++ b/index.htm
@@ -34,6 +34,12 @@
fd_seek : () => { throw new Error("Unexpected fd_seek call"); },
},
env : {
+ log_error_impl : (file_len, file, line, func_len, func, text_len, text) => {
+ let s_file = String.fromCharCode.apply(null, new Uint8Array(this.memory_buffer, file, file_len));
+ let s_func = String.fromCharCode.apply(null, new Uint8Array(this.memory_buffer, func, func_len));
+ let s_text = String.fromCharCode.apply(null, new Uint8Array(this.memory_buffer, text, text_len));
+ console.error(`${s_file}:${line}, ${s_func}: ${s_text}`);
+ },
write_clipboard_text_impl : (size, text) => {
let text_buffer = new ArrayBuffer(size);
new Uint8Array(text_buffer).set(new Uint8Array(this.memory_buffer, text, size));
@@ -75,7 +81,6 @@
program.exports.js_main();
this.sound_buffer_address = program.exports.js_sound_buffer();
- this.pixels_address = program.exports.js_pixels();
this.frames = new Float32Array(
this.memory_buffer,
@@ -187,10 +192,8 @@
for (let f of ev.files) {
let ok = this.program.exports.js_drop(f.name.byteLength + 1, f.data.byteLength);
- if (ok == 0) {
- console.error("File too big");
+ if (ok == 0)
break;
- }
let name_address = this.program.exports.js_drop_name();
let data_address = this.program.exports.js_drop_data();
@@ -228,10 +231,9 @@
let num_samples = output[0][0].length;
let num_frames = num_samples * num_channels;
- this.program.exports.js_frame(this.frame_width, this.frame_height, num_samples);
-
- let pixels_buffer = new ArrayBuffer(this.pixels_size);
- new Uint8Array(pixels_buffer).set(new Uint8Array(this.memory_buffer, this.pixels_address, this.pixels_size));
+ let pixels_address = this.program.exports.js_frame(this.frame_width, this.frame_height, num_samples);
+ let pixels_buffer = new ArrayBuffer(this.pixels_size);
+ new Uint8Array(pixels_buffer).set(new Uint8Array(this.memory_buffer, pixels_address, this.pixels_size));
this.port.postMessage({
id : "frame",
@@ -276,6 +278,7 @@
wasm,
{
env : {
+ log_error_impl : () => {},
write_clipboard_impl : () => {},
current_utc_time_in_milliseconds : () => {},