summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile6
-rw-r--r--minshell.html58
3 files changed, 62 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index bfc050d..90a296f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ domino-dungeon.html
domino-dungeon.js
domino-dungeon.wasm
src_build/domino_assets
+index.*
diff --git a/Makefile b/Makefile
index 1ea3545..8dccdf8 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ LDFLAGS = -lglfw -lm -lGL -I./glad/include
SOURCES = main.c game.c game.h glad/src/glad.c assets/white_and_blue_dominoes.h assets/red_and_peach_dominoes.h domino.c domino.h
domino-dungeon: ${SOURCES}
- $(CC) ${CFLAGS} -o $@ $^ ${LDFLAGS}
+ $(CC) ${CFLAGS} -o $@ $^ ${LDFLAGS}
assets/%.h: src_build/domino_assets
$< assets/1bit_dominoes_asset_pack/$*.png $* > $@
@@ -14,6 +14,6 @@ src_build/domino_assets: src_build/domino_assets.c
$(CC) -o $@ $^ -lm
# https://gist.github.com/ousttrue/0f3a11d5d28e365b129fe08f18f4e141
-domino-dungeon.html: ${SOURCES}
- emcc -sUSE_WEBGL2=1 -sUSE_GLFW=3 -sWASM=1 -I./glad/include $(filter %.c,$^) -o $@
+index.html: ${SOURCES}
+ emcc -sUSE_WEBGL2=1 -sUSE_GLFW=3 -sWASM=1 --shell-file=minshell.html -I./glad/include $(filter %.c,$^) -o $@
diff --git a/minshell.html b/minshell.html
new file mode 100644
index 0000000..b370ada
--- /dev/null
+++ b/minshell.html
@@ -0,0 +1,58 @@
+<!doctype html>
+<html lang="EN-us">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+ <title>domino dungeon</title>
+
+ <style>
+ body { margin: 0px; overflow: hidden; background-color: black; }
+ canvas.emscripten { width: 100%; border: 0px none; background-color: black; }
+ </style>
+ <script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
+ <script type='text/javascript'>
+ function saveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
+ {
+ var isSafari = false; // Not supported, navigator.userAgent access is being restricted
+ //var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+ var data = FS.readFile(memoryFSname);
+ var blob;
+
+ if (isSafari) blob = new Blob([data.buffer], { type: "application/octet-stream" });
+ else blob = new Blob([data.buffer], { type: "application/octet-binary" });
+
+ // NOTE: SaveAsDialog is a browser setting. For example, in Google Chrome,
+ // in Settings/Advanced/Downloads section you have a setting:
+ // 'Ask where to save each file before downloading' - which you can set true/false.
+ // If you enable this setting it would always ask you and bring the SaveAsDialog
+ saveAs(blob, localFSname);
+ }
+ </script>
+ </head>
+ <body>
+ <canvas class=emscripten id=canvas oncontextmenu=event.preventDefault() tabindex=-1></canvas>
+ <p id="output" />
+ <script>
+ var Module = {
+ print: (function() {
+ var element = document.getElementById('output');
+ if (element) element.value = ''; // clear browser cache
+ return function(text) {
+ if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ console.log(text);
+ if (element) {
+ element.value += text + "\n";
+ element.scrollTop = element.scrollHeight; // focus on bottom
+ }
+ };
+ })(),
+ canvas: (function() {
+ var canvas = document.getElementById('canvas');
+ return canvas;
+ })()
+ };
+ </script>
+ {{{ SCRIPT }}}
+ </body>
+</html>