diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2025-01-06 13:12:18 +0100 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2025-01-06 13:12:18 +0100 |
commit | 3359f068dc9e8ac036f0f709aeccf11dfba3cf03 (patch) | |
tree | 2a392e893e819a7ef7ea01e953bbddc9dad185f0 | |
parent | 820298fa61835c53694c4ec58d6c5328947ad4ca (diff) | |
download | reduced_system_layer-3359f068dc9e8ac036f0f709aeccf11dfba3cf03.zip |
No buildin
-rw-r--r-- | Dockerfile | 3 | ||||
-rw-r--r-- | index.htm | 202 | ||||
-rwxr-xr-x | reduced_system_layer.c | 16 |
3 files changed, 106 insertions, 115 deletions
@@ -5,12 +5,11 @@ RUN apk add clang lld COPY examples /usr/examples COPY reduced_system_layer.c /usr/reduced_system_layer.c COPY graphics.c /usr/graphics.c -RUN clang --target=wasm32 -nostdlib -Wl,--no-entry,--allow-undefined -o /usr/index.wasm /usr/examples/sinewave.c +RUN clang --target=wasm32 -nostdlib -fno-builtin -Wl,--no-entry,--allow-undefined -o /usr/index.wasm /usr/examples/graph.c FROM nginx:alpine EXPOSE 80 COPY --from=build /usr/index.wasm /srv/index.wasm COPY index.htm /srv/index.htm COPY nginx.conf /etc/nginx/nginx.conf -RUN ls -la /srv/ ENTRYPOINT [ "nginx" ] @@ -56,105 +56,108 @@ ); </script> <script type="text/javascript"> + let key_map = { + "Backspace" : 8, + "Tab" : 9, + "Enter" : 10, + "ControlLeft" : 11, + "ControlRight" : 12, + "ShiftLeft" : 13, + "ShiftRight" : 14, + "AltLeft" : 15, + "AltRight" : 16, + "ArrowLeft" : 17, + "ArrowRight" : 18, + "ArrowUp" : 19, + "ArrowDown" : 20, + "Pause" : 21, + "Insert" : 22, + "Home" : 23, + "End" : 24, + "PageUp" : 25, + "PageDown" : 26, + "Escape" : 27, + "PrintScreen" : 28, + "Space" : 32, + "MetaLeft" : 33, + "MetaRight" : 34, + "Quote" : 39, + "Comma" : 44, + "Minus" : 45, + "Period" : 46, + "Slash" : 47, + "Digit0" : 48, + "Digit1" : 49, + "Digit2" : 50, + "Digit3" : 51, + "Digit4" : 52, + "Digit5" : 53, + "Digit6" : 54, + "Digit7" : 55, + "Digit8" : 56, + "Digit9" : 57, + "Semicolon" : 59, + "Equal" : 61, + "BracketLeft" : 91, + "Backslash" : 92, + "BracketRight" : 93, + "Backquote" : 96, + "KeyA" : 97, + "KeyB" : 98, + "KeyC" : 99, + "KeyD" : 100, + "KeyE" : 101, + "KeyF" : 102, + "KeyG" : 103, + "KeyH" : 104, + "KeyI" : 105, + "KeyJ" : 106, + "KeyK" : 107, + "KeyL" : 108, + "KeyM" : 109, + "KeyN" : 110, + "KeyO" : 111, + "KeyP" : 112, + "KeyQ" : 113, + "KeyR" : 114, + "KeyS" : 115, + "KeyT" : 116, + "KeyU" : 117, + "KeyV" : 118, + "KeyW" : 119, + "KeyX" : 120, + "KeyY" : 121, + "KeyZ" : 122, + "Delete" : 127, + "F1" : 145, + "F2" : 146, + "F3" : 147, + "F4" : 148, + "F5" : 149, + "F6" : 150, + "F7" : 151, + "F8" : 152, + "F9" : 153, + "F10" : 154, + "F11" : 155, + "F12" : 156, + "F13" : 157, + "F14" : 158, + "F15" : 159, + "F16" : 160, + "F17" : 161, + "F18" : 162, + "F19" : 163, + "F20" : 164, + "F21" : 165, + "F22" : 166, + "F23" : 167, + "F24" : 168, + }; + function key_from_code(code) { - switch (code) { - case "Backspace": return 8; - case "Tab": return 9; - case "Enter": return 10; - case "ControlLeft": return 11; - case "ControlRight": return 12; - case "ShiftLeft": return 13; - case "ShiftRight": return 14; - case "AltLeft": return 15; - case "AltRight": return 16; - case "ArrowLeft": return 17; - case "ArrowRight": return 18; - case "ArrowUp": return 19; - case "ArrowDown": return 20; - case "Pause": return 21; - case "Insert": return 22; - case "Home": return 23; - case "End": return 24; - case "PageUp": return 25; - case "PageDown": return 26; - case "Escape": return 27; - case "PrintScreen": return 28; - case "Space": return 32; - case "MetaLeft": return 33; - case "MetaRight": return 34; - case "Quote": return 39; - case "Comma": return 44; - case "Minus": return 45; - case "Period": return 46; - case "Slash": return 47; - case "Digit0": return 48; - case "Digit1": return 49; - case "Digit2": return 50; - case "Digit3": return 51; - case "Digit4": return 52; - case "Digit5": return 53; - case "Digit6": return 54; - case "Digit7": return 55; - case "Digit8": return 56; - case "Digit9": return 57; - case "Semicolon": return 59; - case "Equal": return 61; - case "BracketLeft": return 91; - case "Backslash": return 92; - case "BracketRight": return 93; - case "Backquote": return 96; - case "KeyA": return 97; - case "KeyB": return 98; - case "KeyC": return 99; - case "KeyD": return 100; - case "KeyE": return 101; - case "KeyF": return 102; - case "KeyG": return 103; - case "KeyH": return 104; - case "KeyI": return 105; - case "KeyJ": return 106; - case "KeyK": return 107; - case "KeyL": return 108; - case "KeyM": return 109; - case "KeyN": return 110; - case "KeyO": return 111; - case "KeyP": return 112; - case "KeyQ": return 113; - case "KeyR": return 114; - case "KeyS": return 115; - case "KeyT": return 116; - case "KeyU": return 117; - case "KeyV": return 118; - case "KeyW": return 119; - case "KeyX": return 120; - case "KeyY": return 121; - case "KeyZ": return 122; - case "Delete": return 127; - case "F1": return 145; - case "F2": return 146; - case "F3": return 147; - case "F4": return 148; - case "F5": return 149; - case "F6": return 150; - case "F7": return 151; - case "F8": return 152; - case "F9": return 153; - case "F10": return 154; - case "F11": return 155; - case "F12": return 156; - case "F13": return 157; - case "F14": return 158; - case "F15": return 159; - case "F16": return 160; - case "F17": return 161; - case "F18": return 162; - case "F19": return 163; - case "F20": return 164; - case "F21": return 165; - case "F22": return 166; - case "F23": return 167; - case "F24": return 168; - } + if (code in key_map) + return key_map[code]; return 0; }; @@ -330,9 +333,6 @@ acos : Math.acos, atan : Math.atan, atan2 : Math.atan2, - - memset : (dst, val, num) => { program.instance.exports.js_memset(dst, val, num); }, - memcpy : (dst, src, num) => { program.instance.exports.js_memcpy(dst, src, num); }, }, } ); diff --git a/reduced_system_layer.c b/reduced_system_layer.c index 64b7cfb..a5e63e0 100755 --- a/reduced_system_layer.c +++ b/reduced_system_layer.c @@ -1613,18 +1613,6 @@ void p_render_frame(void) { p_render_frame_impl(); } - __attribute__((export_name("js_memset"))) void js_memset(void *dst, i32 val, u32 num) { - if (dst == NULL) return; - for (u32 i = 0; i < num; ++i) - ((u8 *) dst)[i] = (u8) val; -} - -__attribute__((export_name("js_memcpy"))) void js_memcpy(void *dst, void const *src, u32 num) { - if (dst == NULL || src == NULL) return; - for (u32 i = 0; i < num; ++i) - ((u8 *) dst)[i] = ((u8 const *) src)[i]; -} - __attribute__((export_name("js_main"))) void js_main(c8 *href) { main(1, &href); } @@ -1703,6 +1691,10 @@ __attribute__((export_name("js_keyup"))) void js_keyup(u32 key, u32 mod) { // // Web audio // +// TODO: Shared memory buffer +// https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Memory +// https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletNode/port +// // ================================================================ #ifdef __wasm__ |