diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-04-15 22:51:08 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-04-15 22:56:59 -0700 |
commit | 6392f1fde9a1177085954e42b9517f73acac88fe (patch) | |
tree | f00df23728ed5f2789930a183084d6f777ed2d75 | |
parent | de993bc0cdb7202390c9ed1d0c4e0a5b33d1d0ee (diff) | |
download | mu-6392f1fde9a1177085954e42b9517f73acac88fe.tar.gz |
first session programming _within_ the Mu computer
I tried building a function to draw a horizontal line across the screen. Here's what I have in data.txt: ( (globals . ( (horline . (fn () (screen y) (horline_1 screen y 0 (width screen)))) (horline_1 . (fn () (screen y lo hi) (if (>= lo hi) () ((fn () (pixel screen lo y 12) (horline_1 screen y (+ lo 1) hi)))))) )) (sandbox . (horline_1 screen 0 0 20)) ) $ dd if=/dev/zero of=data.img count=20160 $ cat data.txt |dd of=data.img conv=notrunc $ ./translate shell/*.mu && qemu-system-i386 -hda disk.img -hdb data.img Result: I can't call (horline screen 0) over a fake screen of width 40. Some stream overflows somewhere after all the tweaks to various fixed-size buffers scattered throughout the app. Calling horline_1 gets to a 'hi' column of 20, but not to 30.
-rw-r--r-- | shell/evaluate.mu | 22 | ||||
-rw-r--r-- | shell/sandbox.mu | 2 |
2 files changed, 16 insertions, 8 deletions
diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 3aedb7c7..ebdbe486 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -27,6 +27,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel var nil?/eax: boolean <- nil? in-addr compare nil?, 0/false break-if-= +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "nil|", 7/fg, 0/bg # nil is a literal trace-text trace, "eval", "nil" copy-object _in, out @@ -38,6 +39,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel { break-if-!= # numbers are literals +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "number|", 7/fg, 0/bg trace-text trace, "eval", "number" copy-object _in, out trace-higher trace @@ -47,7 +49,9 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel { break-if-!= trace-text trace, "eval", "symbol" +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "syma|", 7/fg, 0/bg lookup-symbol in-addr, out, env-h, globals, trace, screen-cell, keyboard-cell +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "symz|", 7/fg, 0/bg trace-higher trace return } @@ -90,6 +94,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel break-if-= # trace-text trace, "eval", "quote" +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "quote|", 7/fg, 0/bg copy-object rest-ah, out trace-higher trace return @@ -110,6 +115,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel compare set?, 0/false break-if-= # +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "set|", 7/fg, 0/bg trace-text trace, "eval", "set" trace-text trace, "eval", "evaluating second arg" var rest/eax: (addr cell) <- lookup *rest-ah @@ -208,13 +214,13 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel var evaluated-list/eax: (addr cell) <- lookup *evaluated-list-ah var function-ah/ecx: (addr handle cell) <- get evaluated-list, left var args-ah/edx: (addr handle cell) <- get evaluated-list, right -#? dump-cell args-ah -#? abort "aaa" +#? set-cursor-position 0/screen, 0, 0 +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "a", 7/fg, 0/bg apply function-ah, args-ah, out, globals, trace, screen-cell, keyboard-cell trace-higher trace # trace "=> " out {{{ { - var stream-storage: (stream byte 0x40) + var stream-storage: (stream byte 0x100) var stream/ecx: (addr stream byte) <- address stream-storage write stream, "=> " print-cell out, stream, 0/no-trace @@ -290,7 +296,9 @@ fn apply-function params-ah: (addr handle cell), args-ah: (addr handle cell), _b # evaluate each expression, writing result to `out` { var curr-ah/eax: (addr handle cell) <- get body, left +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "before call|", 7/fg, 0/bg evaluate curr-ah, out, *new-env-ah, globals, trace, screen-cell, keyboard-cell +#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "y", 7/fg, 0/bg } # body-ah <- get body, right @@ -386,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 0x40) + var stream-storage: (stream byte 0x100) var stream/ecx: (addr stream byte) <- address stream-storage write stream, "look up " var sym2/eax: (addr cell) <- copy sym @@ -423,7 +431,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 0x40) + var stream-storage: (stream byte 0x100) var stream/ecx: (addr stream byte) <- address stream-storage write stream, "=> " print-cell out, stream, 0/no-trace @@ -473,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 0x40) + var stream-storage: (stream byte 0x200) var stream/ecx: (addr stream byte) <- address stream-storage write stream, "=> " print-cell out, stream, 0/no-trace @@ -495,7 +503,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 0x40) + var stream-storage: (stream byte 0x100) var stream/ecx: (addr stream byte) <- address stream-storage write stream, "=> " print-cell out, stream, 0/no-trace diff --git a/shell/sandbox.mu b/shell/sandbox.mu index 6355baa8..b1b8c7e3 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -31,7 +31,7 @@ fn initialize-sandbox _self: (addr sandbox), screen-and-keyboard?: boolean { var trace-ah/eax: (addr handle trace) <- get self, trace allocate trace-ah var trace/eax: (addr trace) <- lookup *trace-ah - initialize-trace trace, 0x1000/lines, 0x80/visible-lines + initialize-trace trace, 0x4000/lines, 0x80/visible-lines var cursor-in-data?/eax: (addr boolean) <- get self, cursor-in-data? copy-to *cursor-in-data?, 1/true } |