From 160afba8b0a14b99e3f604b6b3b563730d73d4ea Mon Sep 17 00:00:00 2001 From: Dennis Ranke Date: Wed, 3 Nov 2021 22:06:04 +0100 Subject: [PATCH] added unlicense, more style, started math imports --- UNLICENSE | 24 ++++++++++++++++ platform/.gitignore | 1 + platform/base.cwa | 3 ++ platform/loader.cwa | 64 +++++++++++++++++++++++++++++++++++++++++ platform/makefile | 7 +++++ web/package.json | 1 + web/src/index.html | 6 +++- web/src/main.js | 15 +++++++--- web/src/style.css | 58 ++++++++++++++++++++++++++++++++----- web/src/uw8loader.wasm | Bin 385 -> 0 bytes 10 files changed, 167 insertions(+), 12 deletions(-) create mode 100644 UNLICENSE create mode 100644 platform/.gitignore create mode 100644 platform/base.cwa create mode 100644 platform/loader.cwa create mode 100644 platform/makefile delete mode 100644 web/src/uw8loader.wasm diff --git a/UNLICENSE b/UNLICENSE new file mode 100644 index 0000000..00d2e13 --- /dev/null +++ b/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to \ No newline at end of file diff --git a/platform/.gitignore b/platform/.gitignore new file mode 100644 index 0000000..917660a --- /dev/null +++ b/platform/.gitignore @@ -0,0 +1 @@ +*.wasm \ No newline at end of file diff --git a/platform/base.cwa b/platform/base.cwa new file mode 100644 index 0000000..449cff2 --- /dev/null +++ b/platform/base.cwa @@ -0,0 +1,3 @@ +import "env.memory" memory(2); + +export fn tic(time: i32) {} diff --git a/platform/loader.cwa b/platform/loader.cwa new file mode 100644 index 0000000..cc8b56b --- /dev/null +++ b/platform/loader.cwa @@ -0,0 +1,64 @@ +import "env.memory" memory(8); + +export fn load_uw8(module_start: i32, module_end: i32, base_start: i32, base_end: i32) -> i32 { + if ?module_start == 0 { + let defer length = module_end - module_start; + copy(base_end, module_start, length); + return base_end + length; + } + + copy(base_end, base_start, 8); + base_start = base_start + 8; + let dest = base_end + 8; + let src = module_start + 1; + + loop sections { + if src < module_end & (base_start >= base_end | ?src <= ?base_start) { + let defer length2 = copy_section(dest, src); + dest = dest + length2; + if base_start < base_end & ?src == ?base_start { + base_start = base_start + section_size(base_start); + } + src = src + length2; + branch sections; + } + + if base_start < base_end { + let defer length3 = copy_section(dest, base_start); + dest = dest + length3; + base_start = base_start + length3; + branch sections; + } + } + + dest +} + +fn section_size(ptr: i32) -> i32 { + let p = ptr + 1; + let l = 0; + let shift = 0; + loop size { + let defer b = ?p; + l = l | ((b & 127) << shift); + shift = shift + 7; + p = p + 1; + branch_if b & 128: size; + } + p - ptr + l +} + +fn copy_section(dest: i32, src: i32) -> i32 { + let defer length = section_size(src); + copy(dest, src, length); + length +} + +fn copy(dest: i32, src: i32, len: i32) { + if len > 0 { + loop bytes { + ?(dest + (len := len - 1)) = ?(src + len); + branch_if len: bytes + } + } +} \ No newline at end of file diff --git a/platform/makefile b/platform/makefile new file mode 100644 index 0000000..fcda944 --- /dev/null +++ b/platform/makefile @@ -0,0 +1,7 @@ +all: loader.wasm base.wasm + +loader.wasm: loader.cwa + curlywas loader.cwa + +base.wasm: base.cwa + curlywas base.cwa diff --git a/web/package.json b/web/package.json index ff40956..1235458 100644 --- a/web/package.json +++ b/web/package.json @@ -1,4 +1,5 @@ { + "license": "Unlicense", "devDependencies": { "@parcel/optimizer-data-url": "^2.0.0", "@parcel/transformer-inline-string": "^2.0.0", diff --git a/web/src/index.html b/web/src/index.html index 4fff53f..357a6ca 100644 --- a/web/src/index.html +++ b/web/src/index.html @@ -12,7 +12,11 @@
- + + +
+