about summary refs log tree commit diff stats
path: root/shell
Commit message (Collapse)AuthorAgeFilesLines
* reimplement pixel graphicsKartik K. Agaram2021-04-191-24/+46
| | | | | | | | | | | Before: we always drew pixels atop characters, and we only drew pixels that were explicitly requested. After: we always draw pixels atop characters, and we only draw pixels that don't have color 0. Both semantics should be identical as long as pixels are never drawn atop characters.
* start cleaning up pixel graphicsKartik K. Agaram2021-04-195-51/+51
| | | | | | Filling pixels isn't a rare corner case. I'm going to switch to a dense rather than sparse representation for pixels, but callers will have to explicitly request the additional memory.
* .Kartik K. Agaram2021-04-181-0/+7
|
* some primitives for monitoring code integrityKartik K. Agaram2021-04-181-0/+3
|
* .Kartik K. Agaram2021-04-172-0/+258
|
* shell: ctrl-r runs on real screen without a traceKartik K. Agaram2021-04-176-24/+90
| | | | | We run out of memory fairly early in the course of drawing a chessboard on the whole screen.
* .Kartik K. Agaram2021-04-172-6/+6
|
* bump up the token limit againKartik K. Agaram2021-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current state of code in the Mu computer: ( (globals . ( (hline1 . (fn () (screen y lo hi color) (if (>= lo hi) () ((fn () (pixel screen lo y color) (hline1 screen y (+ lo 1) hi color)))))) (vline1 . (fn () (screen x lo hi color) (if (>= lo hi) () ((fn () (pixel screen x lo color) (vline1 screen x (+ lo 1) hi color)))))) (hline . (fn () (screen y color) (hline1 screen y 0 (width screen) color))) (vline . (fn () (screen y color) (vline1 screen y 0 (height screen) color))) (andf . (fn () (a b) (if a (if b 1 ()) ()))) (brline . (fn () (screen x0 y0 x1 y1 color) ((fn (dx dy sx sy) ((fn (err) (brline1 screen x0 y0 x1 y1 dx dy sx sy err color)) (+ 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 color) (pixel screen x y color) (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))) color)) (* err 2))))) (read_line_2 . (fn () (keyboard stream) ((fn (c) (if (= c 10) stream (if (= c 0) stream (read_line_2 keyboard (write stream c))))) (key keyboard)))) (read_line . (fn () (keyboard) (read_line_2 keyboard (stream)))) (fill_rect . (fn () (screen x1 y1 x2 y2 fill_color) (if (>= y1 y2) () ((fn () (hline1 screen y1 x1 x2 fill_color) (fill_rect screen x1 (+ y1 1) x2 y2 fill_color)))))) (chessboard . (fn () (screen px) (chessboard1 screen px 0 15))) (chessboard1 . (fn () (screen px y color) (if (>= y (height screen)) () ((fn () (chessboard2 screen px y 0 color) (chessboard1 screen px (+ y px) (- 15 color))))))) (chessboard2 . (fn () (screen px y x color) (if (>= x (width screen)) () ((fn () (fill_rect screen x y (+ x px) (+ y px) color) (chessboard2 screen px y (+ x px) (- 15 color))))))) )) (sandbox . (chessboard screen 8)) )
* shell: reenable the traceKartik K. Agaram2021-04-173-1/+22
| | | | | | | | | | | | | | We now have a couple of protections: - if we get close to running out of space in the trace we drop in an error - if we run out of space in the trace we stop trying to append - if there are errors we cancel future evaluations This is already much nicer. You can't do much on the Mu computer, but at least it gracefully gives up and shows its limitations. On my computer the Mu shell tries to run computations for about 20s before giving up. That seems at the outer limit of what interactivity supports. If things take too long, test smaller chunks.
* evaluating fns is too similar to its inputKartik K. Agaram2021-04-171-1/+1
| | | | | When I edit disk images directly, it's easy to forget a pair of parens. Then the first expression of the body never executes.
* load sandbox even if there are no globalsKartik K. Agaram2021-04-171-11/+9
|
* heh, the current state actually overflows 2KBKartik K. Agaram2021-04-171-4/+4
| | | | | | It only works because the part that's truncated is cleanly the sandbox. I need better error-checking in `read`.
* Bresenham line-drawing now workingKartik K. Agaram2021-04-171-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I can't run tests right now, and the trace is disabled. Still, progress. https://merveilles.town/@akkartik/106081486035689980 Current state of the disk image: ( (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)) )
* tmp: debugging why brline prints no pixelsKartik K. Agaram2021-04-171-1/+1
| | | | | | | | | | | | | | | | | Among other things, we turned off the trace to significantly speed up the debug cycle. State as of https://merveilles.town/@akkartik/106079258606146213 Ohhh, as I save the commit I notice a big problem: I've been editing the disk image directly because writes to the Mu disk lose indentation. But I've been forgetting that the state in the Mu disk needs to be pre-evaluated. So function bindings need extra parens for the environment. The `pixel` calls in the previous commit message are the first statement in the body, and they aren't actually considered part of the body right now. No wonder they don't run. There are lots of other problems, but this will clarify a lot.
* loosening a few more buffersKartik K. Agaram2021-04-174-9/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)) )
* .Kartik K. Agaram2021-04-171-1/+1
|
* new primitives: abs, sgnKartik K. Agaram2021-04-161-1/+100
|
* .Kartik K. Agaram2021-04-161-3/+3
|
* handle drawing 16*4 = 64 pixelsKartik K. Agaram2021-04-161-1/+1
| | | | | | | | | | | | | | | Previously we'd only drawn 8*5 = 40 pixels. Current contents of data.img: ( (globals . ( (hline . (fn () (screen y) (hline1 screen y 0 (width screen)))) (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)))))) )) (sandbox . (vline1 screen 5 0 (height screen))) )
* data.img now has more than one sector of dataKartik K. Agaram2021-04-162-5/+6
|
* open question: animations in the fake screenKartik K. Agaram2021-04-151-0/+38
| | | | Right now we just render the state of the screen at the end of an evaluation.
* .Kartik K. Agaram2021-04-151-17/+17
|
* .Kartik K. Agaram2021-04-151-2/+6
|
* .Kartik K. Agaram2021-04-151-1/+2
|
* first session programming _within_ the Mu computerKartik K. Agaram2021-04-152-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* shell: primitives for screen sizeKartik K. Agaram2021-04-151-2/+180
|
* shell: restore bindings after restartKartik K. Agaram2021-04-152-0/+52
|
* shell: start persisting global bindingsKartik K. Agaram2021-04-152-2/+39
|
* .Kartik K. Agaram2021-04-153-5/+17
|
* .Kartik K. Agaram2021-04-152-1/+8
|
* .Kartik K. Agaram2021-04-152-5/+9
|
* .Kartik K. Agaram2021-04-152-11/+9
|
* add some structure to the serialization formatKartik K. Agaram2021-04-152-2/+24
|
* parse dotted listsKartik K. Agaram2021-04-152-0/+191
|
* .Kartik K. Agaram2021-04-151-14/+25
|
* .Kartik K. Agaram2021-04-151-6/+4
|
* .Kartik K. Agaram2021-04-151-4/+7
|
* .Kartik K. Agaram2021-04-151-0/+7
|
* .Kartik K. Agaram2021-04-151-0/+1
|
* shell: starting to parse dotted listsKartik K. Agaram2021-04-151-10/+20
|
* shell: dot tokenKartik K. Agaram2021-04-151-0/+58
|
* .Kartik K. Agaram2021-04-151-5/+9
|
* .Kartik K. Agaram2021-04-151-16/+17
|
* shell: load data disk as s-expr rather than stringKartik K. Agaram2021-04-142-13/+29
|
* shell: starting to work on persistent globalsKartik K. Agaram2021-04-141-2/+8
|
* .Kartik K. Agaram2021-04-142-10/+18
|
* shell: primitives for comparison, cursor movementKartik K. Agaram2021-04-141-10/+439
|
* shell: more detailed description of primitivesKartik K. Agaram2021-04-141-12/+44
|
* shell: word/line navigationKartik K. Agaram2021-04-142-2/+228
|
* .Kartik K. Agaram2021-04-141-6/+6
|