~vdupras/dusk-wasm

a30dff6c40a9096897b208adbb82df48a0600b00 — Virgil Dupras 3 months ago 2f29a63
Target Dusk v7
6 files changed, 32 insertions(+), 31 deletions(-)

M Makefile
M files/SHA512
M glue.fs
M initpre.fs
M kernel.ts
M wasmvm.fs
M Makefile => Makefile +7 -6
@@ 1,12 1,13 @@
DUSKURL = http://duskos.org
DUSKVER = v6
DUSKVER = v7
DUSKDIR ?= dusk$(DUSKVER)
DUSK = $(DUSKDIR)/dusk
FS = $(DUSKDIR)/fs
BOOTFILES = $(FS)/xcomp/boot.fs $(FS)/lib/bm.fs $(FS)/lib/ns.fs \
	$(FS)/sys/io.fs $(FS)/sys/file.fs \
	$(FS)/lib/drive.fs $(FS)/lib/str.fs $(FS)/mem/endian.fs \
	$(FS)/fs/fat.fs glue.fs
BOOTFILES = $(FS)/xcomp/boot.fs $(FS)/lib/bm.fs \
	$(FS)/io/stream.fs $(FS)/fs/core.fs \
	$(FS)/lib/str.fs $(FS)/mem/endian.fs \
	$(FS)/io/drive.fs $(FS)/io/secwin.fs $(FS)/fs/fat.fs \
	glue.fs

.PHONY:all
all: kernel.wasm wasm.img


@@ 24,7 25,7 @@ $(DUSK): $(DUSKDIR)
kernel.wasm: kernel.ts
	asc $< -o $@ --sourceMap=kernel.map -O -t kernel.wat

wasm.img: $(DUSK)
wasm.img: $(DUSK) initpre.fs wasmvm.fs
	dd if=/dev/zero of=$@ bs=512 count=16384 # 8M
	echo ' 100 4 "$@"' | cat - $(DUSKDIR)/makefat.fs | $(DUSK)
	cat $(BOOTFILES) | dd of=$@ seek=512 bs=1 conv=notrunc

M files/SHA512 => files/SHA512 +1 -1
@@ 1,1 1,1 @@
SHA512 (duskv6.tar.gz) = 2b9c62dba1f27292011f05a51e8c8fccff6fc972cd481899947c4faab65236789812208e24efb49d0e666468db9fed869d901a9878d55accfe43cfdb5249837c
SHA512 (duskv7.tar.gz) = c4a53601bb1a4980246d9b0f2450258920a90b6b27643a7e932a35ede0123a373a238e260b79856a1e9679cf7d882a2cbce3f0d809de019a0b508209b9614abd

M glue.fs => glue.fs +1 -2
@@ 3,7 3,6 @@ create WASMDrive
  ' _drv@ ,
  ' _drv! ,

WASMDrive FAT :mountvolume bootfs!
4 bootfloads, /lib/drive.fs /lib/str.fs /mem/endian.fs /fs/fat.fs
WASMDrive newfatfs bootfs!
f<< /init.fs
init

M initpre.fs => initpre.fs +12 -13
@@ 18,12 18,9 @@ f<< /sys/loop.fs
current loopadd
3 _load_anim

f<< /sys/screen.fs
f<< /sys/mouse.fs
f<< /drv/wasmvm.fs
needs drv/wasmvm
4 _load_anim
f<< /sys/grid.fs
f<< /drv/fbgrid/fbgrid.fs
needs io/fbgrid
fbgrid$
5 _load_anim



@@ 33,16 30,18 @@ msg_buffer _set_msg_buffer
:realias msg-abort
  msg_buffer begin dup c@ ?dup while emit 1+ repeat abort ;

: transferout ( f"srcfile" "dstname" -- )
  0 file :seek begin -1 file :readbuf ?dup while ( a n ) 1 (transfer) drop repeat
  dup 1+ swap c@ 3 (transfer) drop ;
: transferout ( srcpath dstname -- )
  swap bootfs openpath begin ( dstname file )
    -1 over readbuf ?dup while ( dstname file a n )
    1 (transfer) drop repeat ( dstname file )
  close c@+ 3 (transfer) drop ;

: transferin ( "srcname" dstid "dstname" -- )
  swap bootfs :newfile bootfs :open >file
  dup 1+ swap c@ 4 (transfer) not if begin 0 0 4 (transfer) until then
  begin msg_buffer 128 2 (transfer) ?dup while ( n )
    msg_buffer swap file :write# repeat
  0 >file ;
  bootfs newfile bootfs open ( srcname file )
  swap c@+ 4 (transfer) not if begin 0 0 4 (transfer) until then
  begin msg_buffer 128 2 (transfer) ?dup while ( file n )
    over msg_buffer rot rot write# repeat ( file )
  close ;

f<< /text/clip.fs


M kernel.ts => kernel.ts +1 -0
@@ 1443,6 1443,7 @@ function buildsysdict(): void {
	entry("&)"); wasmCompile_BinOp(binOp_OR, hbankset(OPHASDISP | OPMEM | OPDEREF, OPDEREF)); retwr();
	entry("i)"); callwr(find("m)")); callwr(find("&)")); retwr();
	entry("dup,"); callwr(find("PSP)")); callwr(find("<>)")); callwr(find("-@,")); retwr();
	entry("dropf,"); callwr(find("PSP)")); callwr(find("@+,")); retwr();
	entry("litn"); callwr(find("dup,")); callwr(find("i)")); callwr(find("@,")); retwr();
	sd(INPTR, 0xF00000); // where boot contents is loaded in memory
	sd(PARSEPTR, find("parse"));

M wasmvm.fs => wasmvm.fs +10 -9
@@ 1,13 1,14 @@
\ WASM VM drivers
require /sys/screen.fs
require /sys/mouse.fs
?f<< /gr/plane.fs
?f<< /lib/fmt.fs
needs sys/screen sys/mouse
unit drv/wasmvm

extends Screen ns[ WASMScreen
  : blt ( srcaddr dstaddr bytewidth height srcpitch dstpitch -- ) 1 (blt) ;
  : bltfill ( width height addr color pitch -- width height ) 2 (blt) ;
  : bltpixel ( col addr -- ) 3 (blt) ;
  : blt ( srcaddr dstaddr bytewidth height srcpitch dstpitch plane -- )
    drop 1 (blt) ;
  : bltfill ( width height addr color pitch plane -- width height )
    drop 2 (blt) ;
  : bltpixel ( col addr plane -- )
    drop 3 (blt) ;

  \ Here, we deal only with linear modes
  : activate ( self -- )


@@ 26,7 27,7 @@ WASMScreen :new screen' !
screen :activate

extends Mouse ns[ WASMMouse
  : mouse@ ( -- dx dy btnflags ) (mouse) 2drop ;
  : mouseabs@ ( -- ) (mouse) >r >r 2drop drop r> 1024 r> 512 ;
  : mouse@ ( mouse -- dx dy btnflags ) drop (mouse) 2drop ;
  : mouseabs@ ( mouse -- ) drop (mouse) >r >r 2drop drop r> 1024 r> 512 ;
  :override :new ~ W@A ['] mouse@ !{>:mouse@ A} ['] mouseabs@ !{>:mouseabs@ A} ;
]ns