Skip to content

Commit

Permalink
last preparations for 0.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
exoticorn committed Jan 13, 2022
1 parent 179b3ea commit c9ae04e
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target
.cargo/
.vscode/
/examples/**/*.wasm
/examples/**/*.uw8
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
See [here](https://exoticorn.github.io/microw8/).
# MicroW8

MicroW8 is a WebAssembly based fantasy console inspired by the likes of [TIC-80](https://tic80.com/), [WASM-4](https://wasm4.org/) and [PICO-8](https://www.lexaloffle.com/pico-8.php).

The initial motivation behind MicroW8 was to explore whether there was a way to make WebAssembly viable for size-coding. (Size coding being the art of creating tiny (often <= 256 bytes) graphical effects and games.) The available examples so far are all in this space, however, I very carefully made sure that all design decisions make sense from the point of view of bigger projects as well.

See [here](https://exoticorn.github.io/microw8/) for more information and docs.

## Specs

* Screen: 320x240, 256 colors, 60Hz
* Modules: Up to 256KB (WASM)
* Memory: 256KB
* Gamepad input (D-Pad + 4 Buttons)

## Download

The download includes

* `microw8.html`: The web runtime, a small, self-contained html file that can be opened in any modern browser to load and run MicroW8 carts.
* `uw8`/`uw8.exe`: The MicroW8 dev tool, including a native runtime.
* `examples`: Example source code in CurlyWas and Wat (WebAssembly text format).
* `carts`: The examples compiled to `.uw8` carts.

## uw8 dev tool

```
uw8 run [<options>] <file>
Runs <file> which can be a binary WebAssembly module, an `.uw8` cart, a wat (WebAssembly text format) source file or a CurlyWas source file.
Options:
-w, --watch : Reloads the given file every time it changes on disk.
-p, --pack : Pack the file into an .uw8 cart before running it and print the resulting size.
-u, --uncompressed : Use the uncompressed uw8 format for packing.
-l LEVEL, --level LEVEL : Compression level (0-9). Higher compression levels are really slow.
-o FILE, --output FILE : Write the loaded and optionally packed cart back to disk.
uw8 pack [<options>] <infile> <outfile>
Packs the WebAssembly module or text file, or CurlyWas source file into a .uw8 cart.
Options:
-u, --uncompressed : Use the uncompressed uw8 format for packing.
-l LEVEL, --level LEVEL : Compression level (0-9). Higher compression levels are really slow.
uw8 filter-exports <infile> <outfile>
Reads a binary WebAssembly module, removes all exports not used by the MicroW8 platform + everything that is unreachable without those exports and writes the resulting module to <outfile>.
```

## Examples

* [Fireworks](https://exoticorn.github.io/microw8/v0.1pre5#AgwvgP+M59snqjl4CMKw5sqm1Zw9yJCbSviMjeLUdHus2a3yl/a99+uiBeqZgP/2jqSjrLjRk73COMM6OSLpsxK8ugT1kuk/q4hQUqqPpGozHoa0laulzGGcahzdfdJsYaK1sIdeIYS9M5PnJx/Wk9H+PvWEPy2Zvv7I6IW7Fg==) (127 bytes): Some fireworks to welcome 2022.
* [Skip Ahead](https://exoticorn.github.io/microw8/v0.1pre5#AgyfpZ80wkW28kiUZ9VIK4v+RPnVxqjK1dz2BcDoNyQPsS2g4OgEzkTe6jyoAfFOmqKrS8SM2aRljBal9mjNn8i4fP9eBK+RehQKxxGtJa9FqftvqEnh3ez1YaYxqj7jgTdzJ/WAYVmKMovBT1myrX3FamqKSOgMsNedLhVTLAhQup3sNcYEjGNo8b0HZ5+AgMgCwYRGCe//XQOMAaAAzqDILgmpEZ/43RKHcQpHEQwbURfNQJpadJe2sz3q5FlQnTGXQ9oSMokidhlC+aR/IpNHieuBGLhFZ2GfnwVQ0geBbQpTPA==) (229 bytes): A port of my [TIC-80 256byte game](http://tic80.com/play?cart=1735) from LoveByte'21
* [OhNoAnotherTunnel](https://exoticorn.github.io/microw8/v0.1pre4#Ag95rdCB5Ww5NofyQaKF4P1mrNRso4azgiem4hK99Gh8OMzSpFq3NsNDo7O7pqln10D11l9uXr/ritw7OEzKwbEfCdvaRnS2Z0Kz0iDEZt/gIqOdvFmxsL1MjPQ4XInPbUJpQUonhQq29oP2omFabnQxn0bzoK7mZjcwc5GetHG+hGajkJcRr8oOnjfCol8RD+ha33GYtPnut+GLe4ktzf5UxZwGs6oT9qqC61lRDakN) (177 bytes): A port of my [entry](http://tic80.com/play?cart=1871) in the Outline'21 bytebattle final
* [Technotunnel](https://exoticorn.github.io/microw8/v0.1pre4#AqL8HeK1M9dn2nWNIF5vaq/Vh64pMt5nJIFoFKpBMPUsGtDtpqjo1JbT9LzPhAxCqJ7Yh4TA6oTGd4xhLowf+cWZMY73+7AZmfXJJsBi4cej/hH+4wlAgxFIrnOYnr/18IpnZbsHf0eGm1BhahX74+cVR0TRmNQmYC7GhCNS3mv/3MJn74lCj7t28aBJPjEZhP9fGXdG2u5Egh/Tjdg=) (158 bytes): A port of my [entry](https://tic80.com/play?cart=1873) in the Outline'21 bytebattle quater final
2 changes: 2 additions & 0 deletions release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/binaries
/build
54 changes: 54 additions & 0 deletions release/make-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

set -e

cd $(dirname $0)

# build web runtime
pushd ../web
rm -rf .parcel-cache
yarn parcel build src/index.html
popd

rm -rf build
mkdir -p build/microw8-linux
mkdir build/microw8-macos
mkdir build/microw8-windows

# unzip binaries build by github actions
pushd binaries
unzip -o uw8-linux.zip
chmod +x uw8
mv uw8 ../build/microw8-linux
unzip -o uw8-macos.zip
chmod +x uw8
mv uw8 ../build/microw8-macos
unzip -o uw8-windows.zip
mv uw8.exe ../build/microw8-windows
popd

for dir in build/*; do
mkdir $dir/examples
for example in ../examples/curlywas/*.cwa; do
cp $example $dir/examples
done
for example in ../examples/wat/*.wat; do
cp $example $dir/examples
done

mkdir $dir/carts
for example in $dir/examples/*; do
build/microw8-linux/uw8 pack -l 9 $example $dir/carts/$(basename ${example%.*}).uw8
done

cp ../web/dist/index.html $dir/microw8.html
cp ../README.md $dir
cp ../UNLICENSE $dir
done

VERSION=$(build/microw8-linux/uw8 version)

cd build
tar czf microw8-$VERSION-linux.tgz microw8-linux
tar czf microw8-$VERSION-macos.tgz microw8-macos
zip -r -9 microw8-$VERSION-windows.zip microw8-windows
Empty file added site/.SRCINFO
Empty file.
1 change: 1 addition & 0 deletions site/static/v0.1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html><head><meta charset="utf8"><title>MicroW8</title><link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@500&display=swap" rel="stylesheet"><style>body,canvas,html{margin:0;padding:0}html{background-color:#202024;color:#808070;font-family:Josefin Sans,Verdana,Arial Black,sans-serif}body,html{height:100%}body{display:grid;grid-template-rows:1fr 0fr}#uw8{position:absolute}#uw8 a{font-size:130%}#centered{align-self:center;justify-self:center}a{color:#303630}a:hover{color:#405040}#screen{background-color:#202428;border:4px solid #303040;box-shadow:5px 5px 20px #000;cursor:none;height:240px;image-rendering:pixelated;width:320px}#message,#screen{margin-bottom:8px}.error{color:#e04030}button{background-color:#303440;border:1px solid #404040;border-radius:4px;color:#808070;font-family:inherit;padding:4px}button:hover{background-color:#202010}button:active{background-color:#504450}@media (min-width:680px) and (min-height:620px){#screen{height:480px;width:640px}}@media (min-width:1000px) and (min-height:800px){#screen{height:720px;width:960px}}@media (width:640px) and (height:480px){#screen{border:0;height:480px;margin:0;width:640px}body{overflow:hidden}}</style></head><body> <div id="uw8"> <a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.1.0 </div> <div id="centered"> <canvas id="screen" width="320" height="240"></canvas> <div id="message"></div> <button id="cartButton" style="visibility:hidden">Load cart...</button> </div> <div id="footer"> <a href="http://unlicense.org/" ref="license">Unlicense</a> </div> </body><script type="module">function A(A){return A&&A.__esModule?A.default:A}function e(A,e){let t=A?`${A} bytes`:"Insert cart";e&&(t+=` - <span class="error">${e.replaceAll("<","&lt;")}</span>`),document.getElementById("message").innerHTML=t}let t,B,a=document.getElementById("screen"),r=a.getContext("2d"),n=r.createImageData(320,240),s=A=>new Uint8Array(A),i=A=>new Uint32Array(A),o=0,F=A=>{let e,t="keydown"==A.type;switch(A.code){case"ArrowUp":e=1;break;case"ArrowDown":e=2;break;case"ArrowLeft":e=4;break;case"ArrowRight":e=8;break;case"KeyZ":e=16;break;case"KeyX":e=32;break;case"KeyA":e=64;break;case"KeyS":e=128;break;case"KeyR":t&&l(B)}t?o|=e:o&=~e};async function l(F,c){t&&(t(),t=null);let Q=F.byteLength;if(e(Q),0==Q)return;B=F;let E=window.location.pathname;if(Q<=1024&&!c){let A="";for(let e of s(F))A+=String.fromCharCode(e);E+="#"+btoa(A),E!=window.location.pathname+window.location.hash&&history.pushState(null,null,E)}a.width=a.width;try{let a,c=new WebAssembly.Memory({initial:4,maximum:4}),E=s(c.buffer),g={env:{memory:c}},I=A=>{if(0!=s(A)[0]){E.set(s(A));let e=a.exports.load_uw8(A.byteLength);A=new ArrayBuffer(e),s(A).set(E.slice(0,e))}return A},f=async A=>(await WebAssembly.instantiate(A,g)).instance,w=async A=>f(I(await(await fetch(A)).arrayBuffer()));a=await w(A("data:application/wasm;base64,AGFzbQEAAAABFQRgAX8Bf2ACf38Bf2ADf39%2FAGAAAAIPAQNlbnYGbWVtb3J5AgAEAwkIAAABAgEAAAMGEAN%2FAUEAC38BQQALfwFBAAsHGQIIbG9hZF91dzgAAAp1bmNvbXByZXNzAAQIAQcKngUIxwEBB39BAC0AAEEBayIBQQBIBEAgAA8LQYDAByAAaiECIAFBAXEEQEEBQYHABxAEIQIFQYDAB0EAIAAQAwtBAEGAhA9BCBADQYiEDyEDQQghBEGBwAchBQNAIAUgAkggAyMATiAFLQAAIAMtAABMcnEEQCAEIAQgBRACIgZqIQQgAyMASCAFLQAAIAMtAABGcQRAIAMgAxABaiEDCyAFIAZqIQUMAQsgAyMASARAIAQgBCADEAIiB2ohBCADIAdqIQMMAQsLIAQLPAEEfyAAIQEDQCACIAFBAWoiAS0AACIEQf8AcSADdHIhAiADQQdqIQMgBEEHdQ0ACyABQQFqIABrIAJqCxIBAX8gACABIAEQASICEAMgAgskAANAIAJBAEoEQCAAIAJBAWsiAmogASACai0AADoAAAwBCws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CRmGCkYt5vQiaDM%2F6Ya1SMp%2B0hSKoL1CaVam1YNyC2eUiph32Ag6cicueJ5xp%2Bg%3D%3D"));for(let A of["acos","asin","atan","atan2","cos","exp","log","sin","tan","pow"])g.env[A]=Math[A];for(let A=9;A<64;++A)g.env["reserved"+A]=()=>{};for(let A=0;A<16;++A)g.env["g_reserved"+A]=0;F=I(F);let h=await w(A("data:;base64,AnevpqDvapimRNPOGhqee07n%2Bv1yTm1n5XES6y7%2BqPUQFqw5livsDo%2Fkram7E1zzZg6qmLzXsUswfnD9AZjEuJOrUjm2TzbQ%2BWO1hv6bvL0OA5NLPFH8ZGmL%2BQuU9%2BzJKrrbrtlCG5CF9XtS0qCkoIio9oeYfmSVxOA0y%2FJSfYQk40bvdrHXrFnxJFiottxFT%2FLepVgrZE1lBV2uUHz%2Fm8jczeF0kKEUpYn4qQfne4XupG2DSs0kLa3WXNHBwG0ViOo4f1B4B4X%2F1rf9O1yJZwLAqxFM1w2EeBreIqf9raWm6MMcuP8Q%2Bs5SmF1qu1YfCCyRNpKXp%2F3s3pdHfSBqlRkEL4jCiZWjXvWtvWJtnL6gyrjr4ZA2KREn7GNxZzPYPI6FOSKGyvRH2UrubtDjfOlsq42cAfBhf3WA8FxMBdfo1gr7naubzcVCFebQCSoCrdMrFnB4nKdoZ7FRc4rUeNTfhuqN82XawKi3Sii2EsRJxPNvd8MwX%2BcgKnSrLcg00iVly%2Fc9Kv%2BVzmQgXqpzHKxT5OqydhJdO3Xg%2FWkYDSoLk2KM5iTxh2BsvdgqQYSsbbSjcrMgR2CSm3m1h2T7tulpQznvIN%2BOz7wP6uvYF7iIWFWQoNjf3RtRA%2F4WQmfvG5r0KHuTofQKbt2ULV7%2Fv8V1j1Ki5Y8KEcPDyglKFVMcPSG%2Bv%2FkK0syRPFWYo7moohpMPgUGQQeYGebuzfVEZrdE54zGwZvRChYaJieWHBxY1%2B0mkjdisfDIkrbL9bRlZOb1JzZBlGELw%2FdErHCkreGFlqCuI9B1arfx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pQohkHDbtk0GtRJCLPqBsgui9AGmGYJfXk6LEx5337BYI9vMdM4U8XzQ7pwNa0%2BgErrO2SdDTrv%2B2lZxOM3OyHqq1ruAB0ARMjPEqt8fsE1oqPk%2FDDF4wghDrNUlQIAP9YOXsv%2BHrAWSlxakt9LrL5%2BsMVoN%2FQyh7c85MGYXK5PnCJhgGs0Jfy7yKpdNuX%2BO65VszAvhl22ID0UXCA1FWNHvLId6chZX1blmXpTOgtBUy99lbUS41K39a78NYED8HmWBSGkZNPKthJdzBw2pJEa5u1EP8xNOwxpE5f4lpjfxkcrgrh3LxYdurdfDTx76Y8s3zjzmohBd0JE25jxCe%2FoKDm5emvsQERvzu8YqhscSJKbNMq%2Fa1b10%2Fmq4qZwx7dGuSCIj7CPJ6GinhEE6r1QF4ss3%2BgsNlCYmDAQW%2FOZpNnFAlVIDrKi89JRYZThfouw7WqBMufS1SZ8zlOuFr97dw6LVbvegFc7vDyPL7q3f5hdUp4w7crB1qIma7kpbyKIlUU4wKB%2B1ZLtts0S8fD4zYvVwwtK%2BMZHkwYZUOptdlqHvlFdWBcl%2Fal8ZJXyt5v187hfgaQGFVrdLYOAnXynXsx4WC8MkkGOIcAsf5%2FUUzhGIDXXtI0JSrDhkE1uqMLOLQK6YRtA4aQJazIGSlpEgIJwb9XxHoqMigPYgUYJQ%2F30KEUceT8BQOKjOWR4o8QgCvwcogh5qnALJZSibKp5n%2Fqpn1CaOnXrtP3hrueDICnjj7nNzCkdeH662dvcVCwowydP8yXL1ao0nwMA%3D%3D"));for(let A in h.exports)g.env[A]=h.exports[A];let y=await f(F),C=i(n.data.buffer),d=Date.now(),u=!0;t=()=>u=!1;const k=1e3/60;let b=d;!function A(){if(u)try{let e=Date.now(),t=!1;if(e>=b){let A=navigator.getGamepads(),B=0;for(let e=0;e<4;++e){let a=A[e];if(a){for(let A=0;A<8;++A){let t=(A+12)%16;a.buttons.length>t&&a.buttons[t].pressed&&(B|=1<<8*e+A)}if(a.axes.length>1)for(let A=0;A<4;++A){let t=a.axes[1-(A>>1)];(1&A?t:-t)>.5&&(B|=1<<8*e+A)}a.buttons.length>9&&a.buttons[9].pressed&&(t=!0)}}let a=i(c.buffer);a[16]=e-d,a[17]=o|B,y.exports.upd(),h.exports.endFrame();let s=i(c.buffer.slice(77824,78848));for(let A=0;A<76800;++A)C[A]=4278190080|s[E[A+120]];r.putImageData(n,0,0),b=Math.max(b+k,e)}t?l(B):window.requestAnimationFrame(A)}catch(A){e(Q,A.toString())}}()}catch(A){e(Q,A.toString())}}async function c(A,e){let t=await fetch(A),B=t.headers.get("Content-Type");if(B&&B.includes("html"))throw!1;l(await t.arrayBuffer(),e)}function Q(){let A=window.location.hash.slice(1);A.length>0?A.startsWith("url=")?c(A.slice(4),!0):c("data:;base64,"+A):l(new ArrayBuffer(0))}window.onkeydown=F,window.onkeyup=F,window.onhashchange=Q;let E=()=>{let A=document.getElementById("cartButton");A.style="",A.onclick=()=>{let A=document.createElement("input");A.type="file",A.accept=".wasm,.uw8,application/wasm",A.onchange=()=>{A.files.length>0&&c(URL.createObjectURL(A.files[0]))},A.click()},a.ondragover=A=>{A.preventDefault()},a.ondrop=A=>{let e=A.dataTransfer&&A.dataTransfer.files;e&&1==e.length&&(A.preventDefault(),c(URL.createObjectURL(A.dataTransfer.files[0])))},Q()},g=window.location;0!=g.hash.length?E():(async()=>{let A=g.href;A.endsWith(".html")?A=A.slice(0,A.length-4)+"uw8":(A.endsWith("/")||(A+="/"),A+="cart.uw8");try{await c(A,!0)}catch(A){E()}})();</script></html>
3 changes: 3 additions & 0 deletions web/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</style>
</head>
<body>
<div id="uw8">
<a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.1.0
</div>
<div id="centered">
<canvas id="screen" width="320" height="240"></canvas>
<div id="message"></div>
Expand Down
14 changes: 9 additions & 5 deletions web/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ body {
grid-template-rows: 1fr 0fr;
}

#uw8 {
position: absolute;
}

#uw8 a {
font-size: 130%;
}

#centered {
align-self: center;
justify-self: center;
}

.footer {
color: #202420;
}

a {
color: #303630;
}
Expand Down Expand Up @@ -69,7 +73,7 @@ button:active {
background-color: #504450;
}

@media (min-width: 680px) and (min-height: 560px) {
@media (min-width: 680px) and (min-height: 620px) {
#screen {
width: 640px;
height: 480px;
Expand Down

0 comments on commit c9ae04e

Please sign in to comment.