SDL_LIBS = -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_NET=2 -s USE_ZLIB=1
SDL_FMTS = -s SDL2_IMAGE_FORMATS='["bmp","png","pcx","xpm"]'
EXTRA_CFLAGS = $(SDL_LIBS)
-EXTRA_LDFLAGS = $(SDL_FMTS) -s INITIAL_MEMORY=81920000 -s ALLOW_MEMORY_GROWTH=1 --preload-file ../graphics/ --preload-file ../sounds/ --preload-file ../levels/ --preload-file ../music/ -s NO_EXIT_RUNTIME=0 -s ASYNCIFY -O2
+EXTRA_LDFLAGS = $(SDL_FMTS) -s INITIAL_MEMORY=81920000 -s ALLOW_MEMORY_GROWTH=1 --preload-file ../graphics/ --preload-file ../sounds/ --preload-file ../levels/ --preload-file ../music/ -s NO_EXIT_RUNTIME=0 -s ASYNCIFY -O2 -lidbfs.js
else
SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net
endif
if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, dir)))
strcpy(dir, ".");
}
+#elif defined(PLATFORM_EMSCRIPTEN)
+ dir = "/persistent";
#elif defined(PLATFORM_UNIX)
if (dir == NULL)
{
program.log_file[LOG_ERR_ID] = program.log_file_default[LOG_ERR_ID] = stderr;
program.headless = FALSE;
+
+#if defined(PLATFORM_EMSCRIPTEN)
+ EM_ASM
+ (
+ Module.sync_done = 0;
+
+ FS.mkdir('/persistent'); // create persistent data directory
+ FS.mount(IDBFS, {}, '/persistent'); // mount with IDBFS filesystem type
+ FS.syncfs(true, function(err) // sync persistent data into memory
+ {
+ assert(!err);
+ Module.sync_done = 1;
+ });
+ );
+
+ // wait for persistent data to be synchronized to memory
+ while (emscripten_run_script_int("Module.sync_done") == 0)
+ Delay(20);
+#endif
}
void InitNetworkInfo(boolean enabled, boolean connected, boolean serveronly,
#include "windows.h"
#elif defined(PLATFORM_ANDROID)
#include "android.h"
+#elif defined(PLATFORM_EMSCRIPTEN)
+#include "emscripten.h"
#endif
#include "sdl.h"
SetMouseCursor(CURSOR_DEFAULT);
OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
+
+#if defined(PLATFORM_EMSCRIPTEN)
+ EM_ASM
+ (
+ FS.syncfs(function(err)
+ {
+ assert(!err);
+ });
+ );
+#endif
}
static void gotoTopLevelDir(void)