Initial emscripten

This commit is contained in:
Ross Squires
2020-12-07 09:11:51 -05:00
parent 9e9d7acd93
commit 008cb7e568
8 changed files with 37 additions and 18 deletions

View File

@@ -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@/

View File

@@ -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.

View File

@@ -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<double>(str_value);
#if defined(MACOSX)
#if defined(MACOSX) || defined(EMSCRIPTEN)
if (isfinite(user_value)) { /* *sigh* Really, clang, really? */
#else
if (std::isfinite(user_value)) {

View File

@@ -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

View File

@@ -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) {

View File

@@ -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

View File

@@ -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 <stdio.h>
#include <stdlib.h>

View File

@@ -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<Section_prop *>(control->GetSection("dosbox"))->Get_bool("fastbioslogo")||control->opt_fastbioslogo||control->opt_fastlaunch;