mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
modify to run "naked"
This commit is contained in:
parent
656f433d57
commit
c2b56c8d32
3 changed files with 91 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <emscripten.h>
|
||||
#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
|
||||
}
|
||||
|
|
73
xwords4/wasm/main.html
Normal file
73
xwords4/wasm/main.html
Normal file
|
@ -0,0 +1,73 @@
|
|||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style>
|
||||
canvas.emscripten {
|
||||
border: 0px none;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
display:block;
|
||||
}
|
||||
p.startButton {
|
||||
text-align: center;
|
||||
background-color: #4c7aff;
|
||||
font-family: Sans-Serif;
|
||||
padding: 10px;
|
||||
}
|
||||
#loadingDiv {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="loadingDiv">CrossWords is loading...</div>
|
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||
<div style="width:200px; margin-left:auto; margin-right:auto">
|
||||
<p class="startButton" onclick="start_function(this)">Click to start</p>
|
||||
<p id="fullScreenButton" onclick="Module.requestFullScreen(true, false)">Click for full-screen</p>
|
||||
</div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
var Module = {
|
||||
onRuntimeInitialized: function() {
|
||||
var e = document.getElementById('loadingDiv');
|
||||
e.style.visibility = 'hidden';
|
||||
},
|
||||
canvas: (function() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
return canvas;
|
||||
})()
|
||||
};
|
||||
|
||||
var start_function = function(o) {
|
||||
o.style.visibility = "hidden";
|
||||
document.getElementById("fullScreenButton").style.visibility="visible";
|
||||
Module.ccall('mainf', null, null);
|
||||
};
|
||||
</script>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
var memoryInitializer = 'main.js.mem';
|
||||
if (typeof Module['locateFile'] === 'function') {
|
||||
memoryInitializer = Module['locateFile'](memoryInitializer);
|
||||
} else if (Module['memoryInitializerPrefixURL']) {
|
||||
memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer;
|
||||
}
|
||||
var xhr = Module['memoryInitializerRequest'] = new XMLHttpRequest();
|
||||
xhr.open('GET', memoryInitializer, true);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.send(null);
|
||||
})();
|
||||
|
||||
var script = document.createElement('script');
|
||||
script.src = "main.js";
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue