diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-04-17 08:25:34 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-04-17 08:29:43 -0700 |
commit | 1a74c3a1e69ec87e901a2869a4777ad07dbfb176 (patch) | |
tree | 1cadb13445dc8c0bc03056713c8ccfed55155c04 | |
parent | 6d9a1e6abc067e6072137934c99e674cf2133533 (diff) | |
download | mu-1a74c3a1e69ec87e901a2869a4777ad07dbfb176.tar.gz |
loosening a few more buffers
Mu computer now has more code in it: ( (globals . ( (hline1 . (fn () (screen y lo hi) (if (>= lo hi) () ((fn () (pixel screen lo y 12) (hline1 screen y (+ lo 1) hi)))))) (vline1 . (fn () (screen x lo hi) (if (>= lo hi) () ((fn () (pixel screen x lo 12) (vline1 screen x (+ lo 1) hi)))))) (hline . (fn () (screen y) (hline1 screen y 0 (width screen)))) (vline . (fn () (screen y) (vline1 screen y 0 (height screen)))) (andf . (fn (a b) (if a (if b 1 ()) ()))) (brline . (fn (screen x0 y0 x1 y1) ((fn (dx dy sx sy) ((fn (err) (brline1 screen x0 y0 x1 y1 dx dy sx sy err)) (+ dx dy))) (abs (- x1 x0)) (- 0 (abs (- y1 y0))) (sgn (- x1 x0)) (sgn (- y1 y0))))) (brline1 . (fn (screen x y xmax ymax dx dy sx sy err) (pixel screen x y 12) (if (andf (= x xmax) (= y ymax)) () ((fn (e2) (brline1 screen (if (>= e2 dy) (+ x sx) x) (if (<= e2 dx) (+ y sy) y) xmax ymax dx dy sx sy (+ err (+ (if (>= e2 dy) dy 0) (if (<= e2 dx) dx 0))))) (* err 2))))) )) (sandbox . (brline screen 1 1 5 5)) )
-rw-r--r-- | shell/evaluate.mu | 6 | ||||
-rw-r--r-- | shell/global.mu | 14 | ||||
-rw-r--r-- | shell/main.mu | 8 | ||||
-rw-r--r-- | shell/read.mu | 2 |
4 files changed, 21 insertions, 9 deletions
diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 36662d42..6ecb6047 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -335,7 +335,7 @@ fn push-bindings _params-ah: (addr handle cell), _args-ah: (addr handle cell), o # Params can only be symbols or pairs. Args can be anything. # trace "pushing bindings from " params " to " args {{{ { - var stream-storage: (stream byte 0x100) + var stream-storage: (stream byte 0x200) var stream/ecx: (addr stream byte) <- address stream-storage write stream, "pushing bindings from " print-cell params-ah, stream, 0/no-trace @@ -394,7 +394,7 @@ fn push-bindings _params-ah: (addr handle cell), _args-ah: (addr handle cell), o fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), screen-cell: (addr handle cell), keyboard-cell: (addr handle cell) { # trace sym { - var stream-storage: (stream byte 0x200) # pessimistically sized just for the large alist loaded from disk in `main` + var stream-storage: (stream byte 0x800) # pessimistically sized just for the large alist loaded from disk in `main` var stream/ecx: (addr stream byte) <- address stream-storage write stream, "look up " var sym2/eax: (addr cell) <- copy sym @@ -481,7 +481,7 @@ fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell) var error?/eax: boolean <- has-errors? trace compare error?, 0/false break-if-!= - var stream-storage: (stream byte 0x200) + var stream-storage: (stream byte 0x800) var stream/ecx: (addr stream byte) <- address stream-storage write stream, "=> " print-cell out, stream, 0/no-trace diff --git a/shell/global.mu b/shell/global.mu index f6f24003..c3df463e 100644 --- a/shell/global.mu +++ b/shell/global.mu @@ -48,6 +48,7 @@ fn initialize-globals _self: (addr global-table) { # for streams append-primitive self, "stream" append-primitive self, "write" + append-primitive self, "abort" # keep sync'd with render-primitives } @@ -146,7 +147,7 @@ fn render-globals screen: (addr screen), _self: (addr global-table), xmin: int, x, y <- draw-text-wrapping-right-then-down screen, curr-name, xmin, ymin, xmax, ymax, x, y, 0x2a/fg=orange, 0x12/bg=almost-black x, y <- draw-text-wrapping-right-then-down screen, " <- ", xmin, ymin, xmax, ymax, x, y, 7/fg=grey, 0x12/bg=almost-black var curr-value/edx: (addr handle cell) <- get curr, value - var s-storage: (stream byte 0x100) + var s-storage: (stream byte 0x400) var s/ebx: (addr stream byte) <- address s-storage print-cell curr-value, s, 0/no-trace x, y <- draw-stream-wrapping-right-then-down screen, s, xmin, ymin, xmax, ymax, x, y, 3/fg=cyan, 0x12/bg=almost-black @@ -587,6 +588,13 @@ fn apply-primitive _f: (addr cell), args-ah: (addr handle cell), out: (addr hand apply-write args-ah, out, trace return } + { + var abort?/eax: boolean <- string-equal? f-name, "abort" + compare abort?, 0/false + break-if-= + apply-abort args-ah, out, trace + return + } abort "unknown primitive function" } @@ -1624,6 +1632,10 @@ fn apply-lines _args-ah: (addr handle cell), out: (addr handle cell), trace: (ad new-float out, result } +fn apply-abort _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) { + abort "aa" +} + fn apply-columns _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) { trace-text trace, "eval", "apply columns" var args-ah/eax: (addr handle cell) <- copy _args-ah diff --git a/shell/main.mu b/shell/main.mu index d8fa0963..ca1392d5 100644 --- a/shell/main.mu +++ b/shell/main.mu @@ -30,9 +30,9 @@ fn load-state data-disk: (addr disk), _sandbox: (addr sandbox), globals: (addr g var _data/eax: (addr gap-buffer) <- lookup *data-ah var data/esi: (addr gap-buffer) <- copy _data # data-disk -> stream - var s-storage: (stream byte 0x400) # space for 2/sectors + var s-storage: (stream byte 0x800) # space for 4/sectors var s/ebx: (addr stream byte) <- address s-storage - load-sectors data-disk, 0/lba, 2/sectors, s + load-sectors data-disk, 0/lba, 4/sectors, s #? draw-stream-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, s, 7/fg, 0/bg # stream -> gap-buffer load-gap-buffer-from-stream data, s @@ -94,11 +94,11 @@ fn store-state data-disk: (addr disk), sandbox: (addr sandbox), globals: (addr g break-if-!= return } - var stream-storage: (stream byte 0x400) # space enough for 2/sectors + var stream-storage: (stream byte 0x800) # space enough for 4/sectors var stream/edi: (addr stream byte) <- address stream-storage write stream, "(\n" write-globals stream, globals write-sandbox stream, sandbox write stream, ")\n" - store-sectors data-disk, 0/lba, 2/sectors, stream + store-sectors data-disk, 0/lba, 4/sectors, stream } diff --git a/shell/read.mu b/shell/read.mu index 96ec8d9f..7f8fd1a7 100644 --- a/shell/read.mu +++ b/shell/read.mu @@ -1,5 +1,5 @@ fn read-cell in: (addr gap-buffer), out: (addr handle cell), trace: (addr trace) { - var tokens-storage: (stream cell 0x100) + var tokens-storage: (stream cell 0x200) var tokens/ecx: (addr stream cell) <- address tokens-storage tokenize in, tokens, trace var error?/eax: boolean <- has-errors? trace |