From cbb40d0b675da60559bb9b3952f23d707b4e8efe Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 17 Jan 2021 13:53:01 +0900 Subject: [PATCH] emscripten: minor refactoring - Remove the use of EXPORTED_FUNCTIONS in favor of EMSCRIPTEN_KEEPALIVE - SDL_Delay is no longer aliased to emscripten_sleep --- src/CMakeLists.txt | 1 - src/common.h | 5 +++-- src/sdlmain.cpp | 4 ---- src/sys/ags_text.cpp | 2 +- src/sys/nact.cpp | 4 ++++ src/sys/nact.h | 2 ++ 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7b8287..d9e77a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,6 @@ elseif (EMSCRIPTEN) "SHELL:-s ALLOW_MEMORY_GROWTH=1" "SHELL:-s NO_EXIT_RUNTIME=1" "SHELL:-s ASYNCIFY_ADD=\"['NACT::execute()']\"" - "SHELL:-s EXPORTED_FUNCTIONS=\"['_main','_ags_setAntialiasedStringMode']\"" "SHELL:-s EXTRA_EXPORTED_RUNTIME_METHODS=\"['getValue','addRunDependency','removeRunDependency']\"") else() # NOT (ANDROID OR EMSCRIPTEN) diff --git a/src/common.h b/src/common.h index 1bc168f..61beccc 100644 --- a/src/common.h +++ b/src/common.h @@ -12,9 +12,10 @@ #include #include -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ #include -#define SDL_Delay emscripten_sleep +#else +#define EMSCRIPTEN_KEEPALIVE #endif #define FONT_RESOURCE_NAME "MTLc3m.ttf" diff --git a/src/sdlmain.cpp b/src/sdlmain.cpp index 8583dbd..81c0a1e 100644 --- a/src/sdlmain.cpp +++ b/src/sdlmain.cpp @@ -13,10 +13,6 @@ #include #endif -extern "C" { - void ags_setAntialiasedStringMode(int on); -} - SDL_Window* g_window; int main(int argc, char *argv[]) diff --git a/src/sys/ags_text.cpp b/src/sys/ags_text.cpp index 4a4bd15..3a895ab 100644 --- a/src/sys/ags_text.cpp +++ b/src/sys/ags_text.cpp @@ -543,7 +543,7 @@ uint16 AGS::convert_hankaku(uint16 code) extern "C" { -void ags_setAntialiasedStringMode(int on) { +void EMSCRIPTEN_KEEPALIVE ags_setAntialiasedStringMode(int on) { antialias = on != 0; } diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index 62b07d2..572bd2e 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -489,7 +489,11 @@ void NACT::wait_after_open_menu() void NACT::sys_sleep(int ms) { pump_events(); ags->update_screen(); +#ifdef __EMSCRIPTEN__ + emscripten_sleep(ms); +#else SDL_Delay(ms); +#endif } // WinMainとのインターフェース diff --git a/src/sys/nact.h b/src/sys/nact.h index f48c9e6..e2860fd 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -418,4 +418,6 @@ protected: uint16 cali2() override; }; +extern "C" void ags_setAntialiasedStringMode(int on); + #endif // _NACT_H_