From c2b56c8d3292bd741f56fdb729916ba6cc086c74 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 2 Feb 2021 20:58:43 -0800 Subject: [PATCH] modify to run "naked" --- xwords4/wasm/Makefile | 13 +++++--- xwords4/wasm/main.c | 9 ++++++ xwords4/wasm/main.html | 73 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 xwords4/wasm/main.html diff --git a/xwords4/wasm/Makefile b/xwords4/wasm/Makefile index 04597f392..5e3c0c9be 100644 --- a/xwords4/wasm/Makefile +++ b/xwords4/wasm/Makefile @@ -22,12 +22,17 @@ DEFINES += -DSTREAM_VERS_HASHSTREAM DEFINES += -DXWFEATURE_KNOWNPLAYERS DEFINES += -DXWFEATURE_DICTSANITY DEFINES += -DPOINTER_SUPPORT +DEFINES += -O2 -all: main.html +OUTPUTS = main.html main.js main.js.mem main.data -main.html: ${INPUTS} Makefile +all: main.js + +main.js: ${INPUTS} Makefile emcc $(DEFINES) -I . -I ../common -I ../relay -s USE_SDL=2 \ - --preload-file assets_dir \ + --preload-file assets_dir --memory-init-file 1 \ -s USE_SDL_TTF=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' \ + -s EXPORTED_FUNCTIONS='["_mainf"]' -s WASM=0 \ + -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall']" \ ${INPUTS} -o $@ - scp main.html main.js main.wasm main.data pi4:/tmp + scp ${OUTPUTS} pi4:/tmp diff --git a/xwords4/wasm/main.c b/xwords4/wasm/main.c index 65828b8ce..4371b08b5 100644 --- a/xwords4/wasm/main.c +++ b/xwords4/wasm/main.c @@ -25,6 +25,9 @@ #include #endif +/* Might want to pass this from the Makefile */ +#define NAKED_MODE 1 + #define WASM_BOARD_LEFT 0 #define WASM_HOR_SCORE_TOP 0 @@ -220,7 +223,11 @@ looper( void* closure ) } +#ifdef NAKED_MODE +void mainf() +#else int main( int argc, char** argv ) +#endif { LOG_FUNC(); Globals globals = {0}; @@ -251,5 +258,7 @@ int main( int argc, char** argv ) emscripten_set_main_loop_arg( looper, &globals, -1, 1 ); +#ifndef NAKED_MODE return 0; +#endif } diff --git a/xwords4/wasm/main.html b/xwords4/wasm/main.html new file mode 100644 index 000000000..7e33a46f6 --- /dev/null +++ b/xwords4/wasm/main.html @@ -0,0 +1,73 @@ + + + + + + + + + +
CrossWords is loading...
+ +
+

Click to start

+

Click for full-screen

+
+ + + + + + + +