From 9abf253900a75ff2377e3afcc1139ff4a16e6a0f Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 4 Aug 2019 09:38:12 +0900 Subject: [PATCH] Get rid of library.js --- emscripten/library.js | 14 -------------- src/CMakeLists.txt | 2 -- src/font.c | 12 ++++++++++++ src/sdl_core.h | 5 ----- src/sdl_draw.c | 10 ++++++++++ 5 files changed, 22 insertions(+), 21 deletions(-) delete mode 100644 emscripten/library.js diff --git a/emscripten/library.js b/emscripten/library.js deleted file mode 100644 index a6fe241..0000000 --- a/emscripten/library.js +++ /dev/null @@ -1,14 +0,0 @@ -mergeInto(LibraryManager.library, { - wait_vsync: function() { - Asyncify.handleSleep(function(wakeUp) { - window.requestAnimationFrame(function() { - wakeUp(); - }); - }); - }, - load_mincho_font: function() { - return Asyncify.handleSleep(function(wakeUp) { - xsystem35.load_mincho_font().then(wakeUp); - }); - }, -}); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 688ed69..40693be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,8 +71,6 @@ if (EMSCRIPTEN) "SHELL:-s EXPORTED_FUNCTIONS=\"['_main','_ags_setAntialiasedStringMode', '_ald_getdata', '_ald_freedata', '_va_alarm_handler']\"" "SHELL:-s EXTRA_EXPORTED_RUNTIME_METHODS=\"['getValue','getMemory','addRunDependency','removeRunDependency']\"") - em_link_js_library(xsystem35 ../emscripten/library.js) - target_link_options(xsystem35 PRIVATE ${LINK_OPTS}) else() # non-emscripten diff --git a/src/font.c b/src/font.c index 9e3b798..030143e 100644 --- a/src/font.c +++ b/src/font.c @@ -21,6 +21,10 @@ */ /* $Id: font.c,v 1.1 2002/09/18 13:16:22 chikama Exp $ */ +#ifdef __EMSCRIPTEN__ +#include +#endif + #include "config.h" #include "portab.h" @@ -47,3 +51,11 @@ void font_init(int dev) { break; } } + +#ifdef __EMSCRIPTEN__ +EM_JS(int, load_mincho_font, (void), { + return Asyncify.handleSleep(function(wakeUp) { + xsystem35.load_mincho_font().then(wakeUp); + }); +}); +#endif diff --git a/src/sdl_core.h b/src/sdl_core.h index b91f1a1..2a3b003 100644 --- a/src/sdl_core.h +++ b/src/sdl_core.h @@ -175,9 +175,4 @@ extern void sdl_sync(); #define Sleep(ms) sdl_sleep(ms) #define WaitVsync() sdl_wait_vsync() -#ifdef __EMSCRIPTEN__ -// library.js -void wait_vsync(void); -#endif - #endif /* !__SDL_CORE__ */ diff --git a/src/sdl_draw.c b/src/sdl_draw.c index 313a77b..6ae8a78 100644 --- a/src/sdl_draw.c +++ b/src/sdl_draw.c @@ -84,6 +84,16 @@ void sdl_sleep(int msec) { #endif } +#ifdef __EMSCRIPTEN__ +EM_JS(void, wait_vsync, (void), { + Asyncify.handleSleep(function(wakeUp) { + window.requestAnimationFrame(function() { + wakeUp(); + }); + }); +}); +#endif + void sdl_wait_vsync() { sdl_updateScreen(); #ifdef __EMSCRIPTEN__