diff --git a/.gitignore b/.gitignore index 0111213f..306defa9 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ cmake-build-*/** *.x86_64-x/** *.x86_64-sdl/** *.x86_64/** +*.wasm/** +*.wasm-wasm/** *.armv7l-x/** *.armv7l/** *.aarch64-x/** diff --git a/bin/makefile-emscripten.wasm-wasm b/bin/makefile-emscripten.wasm-wasm new file mode 100644 index 00000000..8d884231 --- /dev/null +++ b/bin/makefile-emscripten.wasm-wasm @@ -0,0 +1,34 @@ +# Options for Emscripten, WASM and SDL + +CC = emcc $(CLANG_CFLAGS) + +XFILES = $(OBJECTDIR)sdl.o + +XFLAGS = -DSDL -sUSE_SDL=2 + +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 +DFLAGS = $(XFLAGS) -DRELEASE=351 -DMAIKO_ENABLE_NETHUB + +MEDLEY?=../../medley +SYSOUT?=$(MEDLEY)/loadups/full.sysout + +LD = emcc +LDFLAGS = -sUSE_SDL=2 -sASYNCIFY -sALLOW_MEMORY_GROWTH -sEXIT_RUNTIME=1 \ + --preload-file $(SYSOUT)@medley/loadups/full.sysout \ + --preload-file $(MEDLEY)/loadups/whereis.hash@medley/loadups/whereis.hash \ + --preload-file $(MEDLEY)/greetfiles/MEDLEYDIR-INIT.LCOM@usr/local/lde/site-init.lisp \ + --preload-file $(MEDLEY)/docs/@medley/docs \ + --preload-file $(MEDLEY)/doctools/@medley/doctools \ + --preload-file $(MEDLEY)/greetfiles/@medley/greetfiles \ + --preload-file $(MEDLEY)/internal/@medley/internal \ + --preload-file $(MEDLEY)/sources/@medley/sources \ + --preload-file $(MEDLEY)/library/@medley/library \ + --preload-file $(MEDLEY)/lispusers/@medley/lispusers \ + --preload-file $(MEDLEY)/fonts/@medley/fonts + +LDELDFLAGS = + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/ldesdl.js diff --git a/bin/makeright b/bin/makeright index 1fde522a..156685c4 100755 --- a/bin/makeright +++ b/bin/makeright @@ -74,6 +74,11 @@ case "$display" in sdl) releasename=${osversion}.${architecture}-${display} ldename=ldesdl ;; + wasm) osversion=emscripten + architecture=wasm + releasename=${osversion}.${architecture}-${display} + ldename=ldesdl.js + ;; *) echo "display-option: $display is not supported." exit ;; diff --git a/inc/maiko/platform.h b/inc/maiko/platform.h index 2fa747e9..a69b21fe 100644 --- a/inc/maiko/platform.h +++ b/inc/maiko/platform.h @@ -83,6 +83,19 @@ # define MAIKO_OS_DETECTED 1 #endif +#ifdef __EMSCRIPTEN__ +# define MAIKO_OS_LINUX 1 +# define MAIKO_OS_EMSCRIPTEN 1 +# define MAIKO_OS_NAME "Emscripten" +# define MAIKO_EMULATE_TIMER_INTERRUPTS 1 +# define MAIKO_EMULATE_ASYNC_INTERRUPTS 1 +# define MAIKO_OS_UNIX_LIKE 1 +# define MAIKO_OS_DETECTED +# define MAIKO_ARCH_NAME "WebAssembly" +# define MAIKO_ARCH_WORD_BITS 32 +# define MAIKO_ARCH_DETECTED 1 +#endif + /* __x86_64__: GNU C, __x86_64: Sun Studio, _M_AMD64: Visual Studio */ #if defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64) # define MAIKO_ARCH_X86_64 1 diff --git a/src/lde.html b/src/lde.html new file mode 100644 index 00000000..d429eb41 --- /dev/null +++ b/src/lde.html @@ -0,0 +1,24 @@ + + + + + + + + + +
+ +
+ + + + diff --git a/src/timer.c b/src/timer.c index 5d75bb2c..08a58740 100644 --- a/src/timer.c +++ b/src/timer.c @@ -288,6 +288,8 @@ void subr_settime(LispPTR args[]) dosday.year = uxtime.tm_year; dosday.dayofweek = uxtime.tm_wday; _dos_setdate(&dosday); +#elif defined(MAIKO_OS_EMSCRIPTEN) + (void)args[0]; #else struct timeval timev; timev.tv_sec = *((int *)NativeAligned4FromLAddr(args[0])) - UNIX_ALTO_TIME_DIFF; diff --git a/src/xc.c b/src/xc.c index 51400420..907b16b2 100644 --- a/src/xc.c +++ b/src/xc.c @@ -20,6 +20,9 @@ /* */ /************************************************************************/ +#ifdef MAIKO_OS_EMSCRIPTEN +#include +#endif #include #include #include @@ -286,6 +289,9 @@ op_ufn : { Irq_Stk_End = 0; #if defined(MAIKO_EMULATE_ASYNC_INTERRUPTS) IO_Signalled = TRUE; +#endif +#ifdef MAIKO_OS_EMSCRIPTEN + emscripten_sleep(1); #endif pseudoTimerAsyncCountdown = insnsCountdownForTimerAsyncEmulation; }