mirror of
https://github.com/Interlisp/maiko.git
synced 2026-03-03 18:06:23 +00:00
Merge pull request #488 from Interlisp/incorporate-wasm-changes
Incorporate wasm changes
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -19,6 +19,8 @@ cmake-build-*/**
|
||||
*.x86_64-x/**
|
||||
*.x86_64-sdl/**
|
||||
*.x86_64/**
|
||||
*.wasm/**
|
||||
*.wasm-wasm/**
|
||||
*.armv7l-x/**
|
||||
*.armv7l/**
|
||||
*.aarch64-x/**
|
||||
|
||||
34
bin/makefile-emscripten.wasm-wasm
Normal file
34
bin/makefile-emscripten.wasm-wasm
Normal file
@@ -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
|
||||
@@ -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
|
||||
;;
|
||||
|
||||
@@ -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
|
||||
|
||||
24
src/lde.html
Normal file
24
src/lde.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!doctype html>
|
||||
<!-- Based on https://github.com/timhutton/sdl-canvas-wasm/blob/main/index.html -->
|
||||
<!-- html to set up WebAssembly module for Medley running in a browser -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align: center;">
|
||||
<canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var width = 32*Math.trunc(Math.min(Math.max(window.innerWidth, 512), 1664)/32);
|
||||
var height = Math.min(Math.max(window.innerHeight, 512), 1260);
|
||||
var Module = {
|
||||
preRun: [ function() {ENV.MEDLEYDIR = "{DSK}<medley>";} ],
|
||||
arguments: ["medley/loadups/full.sysout","-sc", width+"x"+height, "-nh-host", "127.0.0.1"],
|
||||
canvas: (function() { return document.getElementById('canvas'); })()
|
||||
};
|
||||
</script>
|
||||
<script src="ldesdl.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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;
|
||||
|
||||
6
src/xc.c
6
src/xc.c
@@ -20,6 +20,9 @@
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef MAIKO_OS_EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -286,6 +289,9 @@ nextopcode:
|
||||
Irq_Stk_End = 0;
|
||||
#if defined(MAIKO_EMULATE_ASYNC_INTERRUPTS)
|
||||
IO_Signalled = TRUE;
|
||||
#endif
|
||||
#ifdef MAIKO_OS_EMSCRIPTEN
|
||||
emscripten_sleep(1);
|
||||
#endif
|
||||
pseudoTimerAsyncCountdown = insnsCountdownForTimerAsyncEmulation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user