commit 91697f28e2e64cb9ea3533bc9fc99eb9e06fce69
parent 2f55dd0a2a4cd26eb9aaba985c7387a2ae535c31
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 17 Dec 2022 14:21:26 -0500
emul/uxn: consolidation
Diffstat:
6 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/fs/emul/uxn/screen.fs b/fs/emul/uxn/screen.fs
@@ -51,3 +51,6 @@ create _fgmask FGMASKSZ allot
$112 vesamode! ;
: screen_deinit vgatext! ;
+
+: uxn_gui ( -- )
+ uxn_init varvara_init screen_init $100 uxn_exec key drop screen_deinit ;
diff --git a/fs/emul/uxn/varvara.fs b/fs/emul/uxn/varvara.fs
@@ -77,7 +77,8 @@ create _fpos 8 allot0 \ current file position
endcase ;
: varvara_init
- uxn_init
$1 ['] consoledei ['] consoledeo uxn_set_dev
$a ['] filedei ['] filedeo uxn_set_dev
$b ['] filedei ['] filedeo uxn_set_dev ;
+
+: uxn_cli ( -- ) uxn_init varvara_init $100 uxn_exec ;
diff --git a/fs/emul/uxn/vm.c b/fs/emul/uxn/vm.c
@@ -174,8 +174,9 @@ static VMOP ops[$20] = {
LDZ, STZ, LDR, STR, LDA, STA, DEI, DEO,
ADD, SUB, MUL, DIV, AND, ORA, EOR, SFT};
-void uxn_exec() {
+void uxn_exec(ushort frompc) {
uchar op;
+ pc = frompc;
while (op = ram[pc++]) {
bs = (op >> 5) & 1;
if(op & $40) {
@@ -196,7 +197,6 @@ void uxn_exec() {
void uxn_init() {
int i;
- pc = $100;
wst.ptr = 0;
rst.ptr = 0;
src = &wst;
diff --git a/fs/tests/emul/uxn/vm.fs b/fs/tests/emul/uxn/vm.fs
@@ -6,29 +6,24 @@
testbegin
\ Testing uxn VM
S" /tests/emul/uxn/hello.tal" tal>vm 0 #eq
-varvara_init
-capture uxn_exec
+capture uxn_cli
S" Hello World!" #s=
S" /tests/emul/uxn/fib.tal" tal>vm 0 #eq
-varvara_init
create expected 47 nc,
46 $00 $01 $00 $02 $00 $03 $00 $05 $00 $08 $00 $0d $00 $15 $00 $22 $00 $37
$00 $59 $00 $90 $00 $e9 $01 $79 $02 $62 $03 $db $06 $3d $0a $18 $10 $55
$1a $6d $2a $c2 $45 $2f $6f $f1 $b5 $20
-capture uxn_exec expected 47 []= #
+capture uxn_cli expected 47 []= #
S" /tests/emul/uxn/hexfmt.tal" tal>vm 0 #eq
-varvara_init
-capture uxn_exec S" 1234abcd" #s=
+capture uxn_cli S" 1234abcd" #s=
S" /tests/emul/uxn/tests.tal" tal>vm 0 #eq
-varvara_init
-capture uxn_exec S" X" #s=
+capture uxn_cli S" X" #s=
S" /tests/emul/uxn/deideo.tal" tal>vm 0 #eq
-varvara_init
-capture uxn_exec Z S" Z" #s=
+capture uxn_cli Z S" Z" #s=
\ For this test, we need a writable filesystem. Let's use a BlobFS in drive B:
\ mounted on top of a RAMDrive.
@@ -37,8 +32,7 @@ capture uxn_exec Z S" Z" #s=
mydrv BlobFS :mount value myfs
myfs filesystems CELLSZ + ! \ register it as "B:"
S" /tests/emul/uxn/file.tal" tal>vm 0 #eq
-varvara_init
-capture uxn_exec
+capture uxn_cli
S" 0011 HELLO.TXT\n" #s=
create expected ," Hello from File!\n"
mydrv RAMDrive :buf( expected 17 []= #
diff --git a/fs/tests/manual/uxn/mandel.fs b/fs/tests/manual/uxn/mandel.fs
@@ -3,8 +3,4 @@
?f<< /emul/uxn/screen.fs
S" /tests/manual/uxn/mandel.tal" tal>vm drop
-varvara_init
-screen_init
-uxn_exec
-key drop
-screen_deinit
+uxn_gui
diff --git a/fs/tests/manual/uxn/rect.fs b/fs/tests/manual/uxn/rect.fs
@@ -3,6 +3,7 @@
?f<< /emul/uxn/screen.fs
S" /tests/manual/uxn/rect.tal" tal>vm drop
+uxn_gui
varvara_init
screen_init
uxn_exec