diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-04-15 20:07:07 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-04-15 20:07:07 -0700 |
commit | 91e30acbd890a10d70d0c08e4f63ecd342b4b00d (patch) | |
tree | 2e35db3c255f7443036f9fc2280b8fb230855313 /shell | |
parent | 04da8ff8b0f3941f98123f821156ff445bfdb153 (diff) | |
download | mu-91e30acbd890a10d70d0c08e4f63ecd342b4b00d.tar.gz |
.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/main.mu | 18 | ||||
-rw-r--r-- | shell/sandbox.mu | 2 |
2 files changed, 9 insertions, 11 deletions
diff --git a/shell/main.mu b/shell/main.mu index 47028035..e0aac0ad 100644 --- a/shell/main.mu +++ b/shell/main.mu @@ -8,7 +8,7 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) var sandbox-storage: sandbox var sandbox/esi: (addr sandbox) <- address sandbox-storage initialize-sandbox sandbox, 1/with-screen - load-sandbox data-disk, sandbox + load-state data-disk, sandbox, globals { render-globals screen, globals, 0/x, 0/y, 0x40/xmax, 0x2f/screen-height-without-menu render-sandbox screen, sandbox, 0x40/x, 0/y, 0x80/screen-width, 0x2f/screen-height-without-menu, globals @@ -23,12 +23,10 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) } } -# Read an s-expression from data-disk to sandbox. -# Gotcha: saved state with syntax errors may not load, and may need to be -# edited as a disk image to get it to load. -fn load-sandbox data-disk: (addr disk), _self: (addr sandbox) { - var self/eax: (addr sandbox) <- copy _self - var data-ah/eax: (addr handle gap-buffer) <- get self, data +# Gotcha: some saved state may not load. +fn load-state data-disk: (addr disk), _sandbox: (addr sandbox), globals: (addr global-table) { + var sandbox/eax: (addr sandbox) <- copy _sandbox + var data-ah/eax: (addr handle gap-buffer) <- get sandbox, data var _data/eax: (addr gap-buffer) <- lookup *data-ah var data/esi: (addr gap-buffer) <- copy _data # data-disk -> stream @@ -68,14 +66,14 @@ fn load-sandbox data-disk: (addr disk), _self: (addr sandbox) { # ((globals . ((a . (fn ...)) # ...)) # (sandbox . ...)) -fn store-sandbox data-disk: (addr disk), _self: (addr sandbox) { +fn store-state data-disk: (addr disk), _sandbox: (addr sandbox), _globals: (addr global-table) { compare data-disk, 0/no-disk { break-if-!= return } - var self/eax: (addr sandbox) <- copy _self - var data-ah/eax: (addr handle gap-buffer) <- get self, data + var sandbox/eax: (addr sandbox) <- copy _sandbox + var data-ah/eax: (addr handle gap-buffer) <- get sandbox, data var data/eax: (addr gap-buffer) <- lookup *data-ah var stream-storage: (stream byte 0x200) var stream/edi: (addr stream byte) <- address stream-storage diff --git a/shell/sandbox.mu b/shell/sandbox.mu index 0a34eb49..1a82f52a 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -507,7 +507,7 @@ fn edit-sandbox _self: (addr sandbox), key: byte, globals: (addr global-table), compare g, 0x13/ctrl-s break-if-!= # - store-sandbox data-disk, self + store-state data-disk, self, globals # run sandbox var data-ah/eax: (addr handle gap-buffer) <- get self, data var _data/eax: (addr gap-buffer) <- lookup *data-ah |