diff --git a/build-emscripten-sdl2 b/build-emscripten-sdl2 index 659e04042..ad52e9b02 100755 --- a/build-emscripten-sdl2 +++ b/build-emscripten-sdl2 @@ -7,14 +7,32 @@ # and just autoregen. ./autogen.sh || exit 1 +# for sdl2-config and sdl-config +export PATH=$EMSDK/upstream/emscripten/system/bin:$PATH + +export CC="emcc" +export CXX="em++" +export LD="emcc" +export LD_CXX="em++" +export CFLAGS="-DEMTERPRETER_SYNC" +export CXXFLAGS="-DEMSCRIPTEN=1 -DEMTERPRETER_SYNC -s USE_ZLIB=1 -s TOTAL_MEMORY=47775744 -s ASYNCIFY -s ERROR_ON_UNDEFINED_SYMBOLS=0" + +# where are we? +top=`pwd` +if test -z "$top" ; then exit 1; fi + +# fix +chmod +x vs2015/sdl/build-scripts/strip_fPIC.sh + echo Compiling DOSBox-X chmod +x configure -# for sdl2-config and sdl-config -export PATH=/opt/emsdk/emscripten/incoming/system/bin:$PATH - # build command borrowed from Yksoft1 vanilla DOSBox-X port with modifications -CC="emcc" CXX="em++" LD="emcc" LD_CXX="em++" CFLAGS="-DEMTERPRETER_SYNC" CXXFLAGS="-DEMSCRIPTEN=1 -DEMTERPRETER_SYNC" ./configure --host=x86_64-linux --disable-dynamic-x86 --enable-sdl2 --with-sdl-prefix=/opt/emsdk/emscripten/incoming/system --disable-opengl --disable-mt32 --enable-emscripten --enable-force-menu-sdldraw --disable-x11 "$@" +./configure \ + --host=x86_64-linux --disable-dynamic-x86 --disable-fpu-x86 \ + --enable-sdl2 --with-sdl-prefix=$EMSDK/upstream/emscripten/system \ + --disable-opengl --disable-mt32 --enable-emscripten --enable-force-menu-sdldraw --disable-x11 \ + --disable-directserial "$@" make -j3 || exit 1 #emcc -O1 -s USE_SDL=2 -s TOTAL_MEMORY=104857600 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s EMTERPRETIFY_WHITELIST=@d3.txt dosbox-x.bc --memory-init-file 0 -o th5e.html --preload-file d:/tmpp/th5x@/ diff --git a/configure.ac b/configure.ac index a29cb150b..b73337548 100644 --- a/configure.ac +++ b/configure.ac @@ -194,6 +194,7 @@ fi if test x$enable_emscripten = xyes; then AC_DEFINE(C_EMSCRIPTEN,1,[Targeting Emscripten]) + AC_DEFINE(C_DIRECTSERIAL, 0, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).]) fi dnl Some stuff for the icon. diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index b4cca587b..b13de1719 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -5986,7 +5986,7 @@ bool AUTOTYPE::ReadDoubleArg(const std::string &name, if (cmd->FindString(flag, str_value, true)) { // Can the user's value be parsed? const double user_value = to_finite(str_value); -#if defined(MACOSX) +#if defined(MACOSX) || defined(EMSCRIPTEN) if (isfinite(user_value)) { /* *sigh* Really, clang, really? */ #else if (std::isfinite(user_value)) { diff --git a/src/fpu/fpu_instructions_longdouble.h b/src/fpu/fpu_instructions_longdouble.h index f2e7cc5e3..bd4c5e760 100644 --- a/src/fpu/fpu_instructions_longdouble.h +++ b/src/fpu/fpu_instructions_longdouble.h @@ -22,7 +22,7 @@ #ifdef __GNUC__ # if defined(__MINGW32__) || (defined(MACOSX) && !defined(__arm64__)) # include "fpu_control_x86.h" -# elif defined(MACOSX) && defined(__arm64__) +# elif (defined(MACOSX) && defined(__arm64__)) || defined(EMSCRIPTEN) /* ? */ # define _FPU_SETCW(x) /* dummy */ # else diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 9f95325c2..376590c4e 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -4019,12 +4019,12 @@ void BIND_MappingEvents(void) { MAPPER_UpdateJoysticks(); #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); #endif while (SDL_PollEvent(&event)) { #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); #endif switch (event.type) { @@ -4424,7 +4424,7 @@ void MAPPER_RunInternal() { #endif while (!mapper.exit) { #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); #endif if (mapper.redraw) { diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 555874db4..a0c43526b 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -1510,7 +1510,7 @@ void PauseDOSBoxLoop(Bitu /*unused*/) { } #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); SDL_PollEvent(&event); #else SDL_WaitEvent(&event); // since we're not polling, cpu usage drops to 0. @@ -4233,7 +4233,7 @@ void GFX_EndTextLines(bool force=false) { extern uint8_t rendererCache[]; void GFX_EndUpdate(const uint16_t *changedLines) { #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); #endif /* don't present our output if 3Dfx is in OpenGL mode */ @@ -5893,7 +5893,7 @@ static void HandleMouseButton(SDL_MouseButtonEvent * button, SDL_MouseMotionEven /* fall into another loop to process the menu */ while (runloop) { #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); if (!SDL_PollEvent(&event)) continue; #else if (!SDL_WaitEvent(&event)) break; @@ -6681,7 +6681,7 @@ void GFX_Events() { GFX_EventsMouse(); #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); #endif while (SDL_PollEvent(&event)) { @@ -6803,7 +6803,7 @@ void GFX_Events() { while (paused) { #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); SDL_PollEvent(&ev); #else // WaitEvent waits for an event rather than polling, so CPU usage drops to zero @@ -6952,7 +6952,7 @@ void GFX_Events() { GFX_EventsMouse(); #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); #endif while (SDL_PollEvent(&event)) { @@ -7129,7 +7129,7 @@ void GFX_Events() { while (paused) { #if C_EMSCRIPTEN - emscripten_sleep_with_yield(0); + emscripten_sleep(0); SDL_PollEvent(&ev); #else // WaitEvent waits for an event rather than polling, so CPU usage drops to zero diff --git a/src/gui/whereami.c b/src/gui/whereami.c index 11f4ac6b0..9dcfe7b83 100644 --- a/src/gui/whereami.c +++ b/src/gui/whereami.c @@ -160,7 +160,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) return length; } -#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(WAI_USE_PROC_SELF_EXE) +#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(EMSCRIPTEN) || defined(WAI_USE_PROC_SELF_EXE) #include #include diff --git a/src/ints/bios.cpp b/src/ints/bios.cpp index 7966a38a3..5a72f189d 100644 --- a/src/ints/bios.cpp +++ b/src/ints/bios.cpp @@ -8485,7 +8485,7 @@ private: while ((GetTicks()-lasttick)<1000) { void CALLBACK_Idle(void); CALLBACK_Idle(); - emscripten_sleep_with_yield(100); + emscripten_sleep(100); } #else bool fastbioslogo=static_cast(control->GetSection("dosbox"))->Get_bool("fastbioslogo")||control->opt_fastbioslogo||control->opt_fastlaunch;