Kartik K. Agaram
1496548287
start progressively increasing trace depth
...
The goal: the sandbox initially maintains a shallow trace. As you expand
into the trace, the environment reruns the sandbox at greater depth as
needed.
The challenge: expanding happens within edit-trace, which doesn't have
the whole sandbox needed to re-run the sandbox. We'll either need to expand
the trace's capabilities to include the whole sandbox, or duplicate some
logic to decide when to run the sandbox.
2021-05-30 08:51:58 -07:00
Kartik K. Agaram
9062eeb554
.
2021-05-29 21:45:33 -07:00
Kartik K. Agaram
10e41d00d8
.
2021-05-29 21:39:18 -07:00
Kartik K. Agaram
1eb74e2d5d
shell: scrolling the trace
2021-05-29 20:52:57 -07:00
Kartik K. Agaram
9516dfa0b0
shell: skeleton for scrolling
2021-05-29 17:23:04 -07:00
Kartik K. Agaram
d85529f3fa
cache visibility for all lines in trace
...
So far we were only doing so for the first few lines, just enough to render
one page's worth of lines. We'd have probably noticed if we collapsed some
lines after re-evaluating.
2021-05-29 17:13:06 -07:00
Kartik K. Agaram
fde296ca3c
.
2021-05-29 17:03:22 -07:00
Kartik K. Agaram
58c801db0f
.
2021-05-29 16:49:36 -07:00
Kartik K. Agaram
af46771821
.
2021-05-29 16:42:15 -07:00
Kartik K. Agaram
91ddc3a82d
.
2021-05-29 16:41:47 -07:00
Kartik K. Agaram
c8b2424f45
shell: start implementing scrolling in the trace
...
I've been stymied for a week wondering how to reliably compute trace-line
identity. A trace can have multiple identical lines. Only some of them
may be visible at any point. How to remember which is which across re-evaluations?
There's no easy answer. I'm just going to keep things ad hoc. When you
re-evaluate, new lines can currently pop into visibility. However we guarantee
that just moving around the trace will be stable, thanks to the visible
bit being cached within each trace-line. Scrolling will be similar. Reevaluating
may cause the trace to be perturbed up or down. However, just scrolling
around will work reliably.
2021-05-29 16:37:32 -07:00
Kartik K. Agaram
4de6f80334
.
2021-05-29 16:25:38 -07:00
Kartik K. Agaram
9b131ce02b
.
2021-05-29 16:22:08 -07:00
Kartik K. Agaram
7b84872380
shell: non-stream tokens are now small
2021-05-29 16:07:39 -07:00
Kartik K. Agaram
0bba6ccfc2
.
2021-05-29 16:04:30 -07:00
Kartik K. Agaram
aceb526b50
.
2021-05-29 16:01:50 -07:00
Kartik K. Agaram
c2e59bbf9d
.
2021-05-29 16:00:59 -07:00
Kartik K. Agaram
6b212ed6e7
.
2021-05-29 15:54:41 -07:00
Kartik K. Agaram
d8f306c30c
.
2021-05-29 15:53:31 -07:00
Kartik K. Agaram
2ad0a98f94
.
2021-05-29 15:53:21 -07:00
Kartik K. Agaram
56c621b6f1
shell: start reducing the waste in tokenize
2021-05-29 15:49:58 -07:00
Kartik K. Agaram
210553ac68
.
...
slightly improve colors
2021-05-23 22:53:54 -07:00
Kartik K. Agaram
bda55a3eec
ctrl-s in trace: show entire current line
2021-05-23 22:47:40 -07:00
Kartik K. Agaram
f32e8035c7
.
2021-05-23 22:26:49 -07:00
Kartik K. Agaram
7fa0163941
disable ctrl-s when browsing trace
...
We're soon going to be dynamically rerunning the sandbox in other ways
when browsing the trace.
2021-05-23 22:18:51 -07:00
Kartik K. Agaram
d3103378c5
.
2021-05-23 22:17:05 -07:00
Kartik K. Agaram
d474128db1
shrink trace menu
2021-05-23 22:07:50 -07:00
Kartik K. Agaram
b2dd7e6a91
start truncating trace lines
2021-05-23 22:04:31 -07:00
Kartik K. Agaram
7a04c8104d
shell: reduce trace depth in sandbox
...
We'll gradually make this more dynamic.
2021-05-22 10:28:21 -07:00
Kartik K. Agaram
6934f78e97
.
2021-05-22 09:30:11 -07:00
Kartik K. Agaram
64d3e8e2e0
.
2021-05-19 23:32:16 -07:00
Kartik K. Agaram
119e661f20
a second place with lousy storage management
2021-05-19 23:23:49 -07:00
Kartik K. Agaram
4b57c101b7
more robust print-cell
...
It is used to print to the trace, and we shouldn't crash the whole computer
just because the trace ran out of space.
2021-05-19 23:14:27 -07:00
Kartik K. Agaram
e2ab1b30b1
disallow null traces
...
We now use traces everywhere for error-checking. Null traces introduce
the possibility of changing a functions error response, and therefore its
semantics.
2021-05-19 20:56:37 -07:00
Kartik K. Agaram
6bbeadecaa
.
2021-05-19 19:55:29 -07:00
Kartik K. Agaram
f8c28e3a36
.
2021-05-19 17:30:25 -07:00
Kartik K. Agaram
831e2e0d64
.
2021-05-19 17:29:17 -07:00
Kartik K. Agaram
ec2dab7801
shell: traces track a maximum depth to record
2021-05-19 01:26:25 -07:00
Kartik K. Agaram
9831a8cef9
shell: depth 0 as the check for errors
2021-05-19 01:21:02 -07:00
Kartik K. Agaram
3fc03a98e5
shell: start traces at depth 1 rather than 0
...
We're going to carve out depth 0 for errors.
2021-05-19 01:15:35 -07:00
Kartik K. Agaram
91b7b0be73
shell: clean up trace for macroexpand
2021-05-18 20:01:11 -07:00
Kartik K. Agaram
837926751a
shell: add a lot of error-checking
2021-05-18 20:01:11 -07:00
Kartik K. Agaram
c4475d83b7
shell: roll back a change to the 'when' macro
...
Introduced in commit 1adc904ef3
from a week ago, but it turns out brcircle
has been consistently broken ever since.
2021-05-15 12:43:35 -07:00
Kartik K. Agaram
183010779c
A 'bowboard', a chessboard of rainbow circles
...
Compare with (chessboard screen 256)
2021-05-08 08:33:22 -07:00
Kartik K. Agaram
665b1e8f07
a full-circle rainbow
2021-05-08 07:58:56 -07:00
Kartik K. Agaram
1adc904ef3
new shell macro: do
2021-05-07 21:13:24 -07:00
Kartik K. Agaram
61a68452ae
all apps working again after null get check
2021-05-07 20:40:42 -07:00
Kartik K. Agaram
19dd573a92
.
2021-05-07 20:02:01 -07:00
Kartik K. Agaram
d3f17627d8
an often-overflowing stream when running brcircle
...
We really need to systematically check our trace streams.
2021-05-07 15:12:56 -07:00
Kartik K. Agaram
c5f50f05b7
.
2021-05-07 12:46:41 -07:00
Kartik K. Agaram
150db8d56a
some boot-time heartbeat messages
...
This will help us with some common debug scenarios.
2021-05-07 12:27:20 -07:00
Kartik K. Agaram
dd192dd52c
.
2021-05-07 12:11:59 -07:00
Kartik K. Agaram
e42ae8219e
clean up all definitions
2021-05-07 12:08:07 -07:00
Kartik K. Agaram
d605ba1f9a
clean up chessboard
...
We still benefit from some helpers here because of the unrolling and multiple
calls to helpers.
2021-05-07 11:56:43 -07:00
Kartik K. Agaram
d8298d1a2a
clean up read_line
2021-05-07 11:37:48 -07:00
Kartik K. Agaram
91f76e6b22
clean up Bresenham line-drawing
2021-05-07 11:28:59 -07:00
Kartik K. Agaram
25eb9c580e
.
2021-05-07 11:02:55 -07:00
Kartik K. Agaram
92fb55d50f
no, we need hline1 for fill_rect
2021-05-07 10:14:51 -07:00
Kartik K. Agaram
c651bbeffc
clean up hline and vline
2021-05-07 10:05:20 -07:00
Kartik K. Agaram
74be534e2b
starting to implement first macros
...
Another commit, another bugfix.
Some snippets from my currently exploding todo list:
- always investigate lookup errors immediately. Beyond the root cause, they should never happen at the moment, while we aren't reclaiming memory.
we should always return a more precise error message. Usually involving null pointer checks.
- on abort, print out stack trace
- emit mapping of labels to addresses during survey
- store a mapping of symbols somewhere in the code image
- stop allocating 1KB per token; expand space for tokens as needed
2021-05-07 09:49:16 -07:00
Kartik K. Agaram
7105b73fd3
give up on nested backquotes for now
2021-05-07 09:22:54 -07:00
Kartik K. Agaram
f791cd9da9
macros almost done
...
Just one case left: macros within unquote.
2021-05-06 22:09:30 -07:00
Kartik K. Agaram
57fd40d500
some more cases
2021-05-06 21:41:03 -07:00
Kartik K. Agaram
a1cfadc749
first passing test for macroexpand
...
In the process I spent a long time tracking down a stray TODO in 108write.subx
that I thought would abort but didn't since the switch to baremetal.
Then after I reintroduced that assertion I had to go track down a bunch
of buffer sizes. Stream sizes continue to be a huge mess.
2021-05-06 21:38:02 -07:00
Kartik K. Agaram
7c8ad5a419
more paranoia in shell/globals.mu
2021-05-06 19:38:54 -07:00
Kartik K. Agaram
edae464db5
shell: macroexpand outermost call
2021-05-06 18:13:27 -07:00
Kartik K. Agaram
1648a04cc0
literal macros
...
Current plan:
- some way to define macros. For now:
(def f (litmac litfn () (a b) `(+ ,a , b)))
- macroexpand will expand calls by passing them through the cdr
(f 3 4)
macroexpand: ((litfn () (a b) `(+ ,a ,b)) 3 4)
=> (+ 3 4)
eval: (+ 3 4) => 7
2021-05-06 17:29:51 -07:00
Kartik K. Agaram
e9981404da
.
2021-05-06 17:27:17 -07:00
Kartik K. Agaram
6df53d463c
back to macros; switch macroexpand to operate in place
2021-05-06 17:00:18 -07:00
Kartik K. Agaram
a54c6f2ee7
belatedly migrate stale example definitions
...
Also bare-bones syntax highlighting for .limg files. Doesn't work when
.limg file is first file opened with Vim.
2021-05-06 16:42:08 -07:00
Kartik K. Agaram
effbe423a7
.
2021-05-06 15:10:56 -07:00
Kartik K. Agaram
ba5f556543
.
2021-05-04 20:20:03 -07:00
Kartik K. Agaram
5e0f459848
.
2021-05-04 20:09:07 -07:00
Kartik K. Agaram
0069028dae
.
2021-05-04 20:00:03 -07:00
Kartik K. Agaram
9156823c5d
shell: start implementing macros
2021-05-04 19:49:21 -07:00
Kartik K. Agaram
7465fbb19f
.
2021-05-04 19:46:49 -07:00
Kartik K. Agaram
66c18fda1d
shell: unquote splice
2021-05-04 04:28:04 -07:00
Kartik K. Agaram
bb9f4e4e1d
shell: unquote
2021-05-04 03:53:00 -07:00
Kartik K. Agaram
de94891356
shell: start evaluating backquote
2021-05-03 21:01:50 -07:00
Kartik K. Agaram
1c69a13a88
.
2021-05-03 20:31:57 -07:00
Kartik K. Agaram
a08658f218
.
2021-05-03 18:16:15 -07:00
Kartik K. Agaram
1048729a6e
.
2021-05-03 17:31:19 -07:00
Kartik K. Agaram
93f1bee02c
reading and printing backquotes and unquotes
2021-05-03 12:02:12 -07:00
Kartik K. Agaram
71a04056a8
printing quoted expressions
2021-05-02 22:31:19 -07:00
Kartik K. Agaram
27691024c4
.
2021-05-02 22:25:47 -07:00
Kartik K. Agaram
83847e9f0a
.
...
Clean up menus.
2021-05-01 16:20:44 -07:00
Kartik K. Agaram
d0e2d093f7
cleaner rendering of fake screens and keyboards
...
I don't understand why a second line in the keyboard is visible now where
it wasn't before. That whole aspect has unclear desires. What exactly do
I want to happen on newlines?
2021-05-01 16:12:49 -07:00
Kartik K. Agaram
719b6acf3d
.
...
Use sandbox background in the top line on the right.
2021-05-01 15:54:02 -07:00
Kartik K. Agaram
c426cc0327
.
...
Clean up trace colors.
2021-05-01 15:49:48 -07:00
Kartik K. Agaram
2b616894fd
move color scheme closer to Solarized dark
...
sed -i 's,0x12/bg=almost-black,0xdc/bg=green-bg,g' shell/*.mu
sed -i 's, 0/bg, 0xc5/bg=blue-bg,g' shell/*.mu
sed -i 's, 7/fg=trace, 0x38/fg=trace,g' shell/*.mu
sed -i 's, 7/bg=grey, 0x5c/bg=black,g' shell/*.mu
Still a few issues.
Thanks Adrian Cochrane and Zach DeCook.
https://floss.social/@alcinnz/106152068473019933
https://social.librem.one/@zachdecook/106159988837603417
2021-05-01 15:37:55 -07:00
Kartik K. Agaram
bf4c19f053
shell: squeeze menu
2021-04-30 00:00:55 -07:00
Kartik K. Agaram
3385febc11
shell: allow 'def' to overwrite
2021-04-29 23:53:28 -07:00
Kartik K. Agaram
d46c4b06b2
shell: comments
2021-04-29 23:48:36 -07:00
Kartik K. Agaram
24883b04f5
.
2021-04-29 23:43:17 -07:00
Kartik K. Agaram
772b7b6585
adjust fake screen aspect ratio for verisimilitude
2021-04-29 23:38:37 -07:00
Kartik K. Agaram
ca47215a6b
keep the temporary progress screen off the keyboard
2021-04-29 20:38:18 -07:00
Kartik K. Agaram
24222b1735
make pixel borders of screen clear
2021-04-29 20:35:50 -07:00
Kartik K. Agaram
26eae87d3f
make matching parens pop again
2021-04-29 16:47:26 -07:00
Kartik K. Agaram
c811754807
render definitions in 2 columns
2021-04-29 16:43:40 -07:00
Kartik K. Agaram
6503529627
white text everywhere by default
2021-04-29 16:27:43 -07:00
Kartik K. Agaram
5124feb31e
tweak colors for definitions
2021-04-29 16:14:47 -07:00
Kartik K. Agaram
e13fd3e0a1
render in a narrow column
2021-04-29 16:11:23 -07:00
Kartik K. Agaram
05879d4f99
load large definitions
2021-04-29 16:10:30 -07:00
Kartik K. Agaram
b860f108f7
adjust some colors and padding
2021-04-29 15:10:17 -07:00
Kartik K. Agaram
dcb6a21a91
bugfix: initialize gap buffers before using them
...
I keep running into one hole in Mu's memory-safety since dropping the Linux
dependency: null pointers no longer error when dereferenced. Here the problem
manifests as aliasing: lots of gap buffers share the same exact data near
address 0, because it was never initialized.
2021-04-28 22:03:58 -07:00
Kartik K. Agaram
7fa356abef
fix rendering
2021-04-28 17:54:02 -07:00
Kartik K. Agaram
b9c59a5f5b
shell: load/store from/to disk with indent
...
Once I came up with the right approach, this worked on the first try once
I got the types and registers to line up!
2021-04-28 17:49:55 -07:00
Kartik K. Agaram
ef8dc999ca
.
2021-04-28 17:08:15 -07:00
Kartik K. Agaram
d5d3e02ad4
shell: bugfix for stream literals
...
I was forgetting that callers sometimes reuse outputs between successive
tokens.
2021-04-28 16:34:40 -07:00
Kartik K. Agaram
9269234e46
start rendering definitions with indentation
2021-04-28 14:47:41 -07:00
Kartik K. Agaram
5b7f938733
start stashing and clearing sandbox after definitions
2021-04-28 13:55:10 -07:00
Kartik K. Agaram
e73f1a3b41
.
2021-04-28 12:21:51 -07:00
Kartik K. Agaram
a71ff2383a
.
2021-04-28 09:45:39 -07:00
Kartik K. Agaram
55cde01edf
shell: stream literals
2021-04-27 23:10:30 -07:00
Kartik K. Agaram
9e9e40c05a
.
2021-04-27 23:04:20 -07:00
Kartik K. Agaram
409d26ca87
.
2021-04-27 23:03:23 -07:00
Kartik K. Agaram
6ecd9920ca
shell: tokenizing stream (string) literals
...
We're calling them streams since they support appending.
2021-04-27 22:48:16 -07:00
Kartik K. Agaram
16f51dd76d
.
2021-04-27 22:14:08 -07:00
Kartik Agaram
865f37aa9c
.
2021-04-26 09:42:05 -07:00
Kartik K. Agaram
606c5681b7
bresenham circles
...
Known issue: circles of radius 9 crash. (Multiples of 9 overflow the trace.)
2021-04-25 22:33:26 -07:00
Kartik K. Agaram
7148f1222e
bug in bresenham lines
2021-04-25 22:20:57 -07:00
Kartik K. Agaram
891083c44d
shell: primitives 'and' and 'or'
2021-04-25 22:19:00 -07:00
Kartik K. Agaram
bd9c1e6a79
shell: primitive 'not'
2021-04-25 22:09:51 -07:00
Kartik K. Agaram
24a6f99107
failing tests not printing since show-stack-state
2021-04-25 22:08:00 -07:00
Kartik K. Agaram
6e0f0bdf50
.
2021-04-25 22:00:00 -07:00
Kartik K. Agaram
ffe36c4050
.
2021-04-25 21:45:27 -07:00
Kartik K. Agaram
1a18c9e24b
.
2021-04-25 21:35:14 -07:00
Kartik K. Agaram
a68ecc0184
.
2021-04-25 21:32:15 -07:00
Kartik K. Agaram
6bb70a236c
shell: tab inserts two spaces
2021-04-25 21:03:14 -07:00
Kartik K. Agaram
cbebd548ca
shell: use ctrl-m rather than tab to bounce to trace
...
We'll save tab for inserting graphemes.
2021-04-25 21:03:05 -07:00
Kartik K. Agaram
1323a6bb3a
.
...
Show all builtins now that we have more space.
2021-04-25 17:57:19 -07:00
Kartik K. Agaram
8e89dd5a78
devote 2/3rds of screen to definitions
2021-04-25 17:55:17 -07:00
Kartik K. Agaram
35a6f3cc99
add some padding to the sandbox
2021-04-25 17:49:39 -07:00
Kartik K. Agaram
a761d0e4ef
a troubleshooting note
2021-04-25 16:02:30 -07:00
Kartik K. Agaram
d56153d004
.
2021-04-25 15:58:03 -07:00
Kartik K. Agaram
22a95bd813
expand memory to 2GB
...
It requires more than 1GB to fill the screen with a chessboard pattern
using the definition in shell/iterative-definitions.limg.
I also speed up the chessboard program by clearing the screen up front
and then only rendering the white pixels.
2021-04-25 15:56:34 -07:00
Kartik Agaram
9c3e2821c1
.
...
Get rid of my experiment adding Game of Life to the shell.
2021-04-24 07:18:15 -07:00
Kartik Agaram
cb464c9378
bugfix; thanks Max Bernstein
2021-04-24 07:16:34 -07:00
Kartik Agaram
b7224ab44e
.
2021-04-23 21:49:28 -07:00
Kartik Agaram
fa8d337d90
shell: some example definitions
2021-04-23 21:36:48 -07:00
Kartik K. Agaram
2ff86d9162
better error message on trace overflow
2021-04-22 10:13:19 -07:00
Kartik K. Agaram
8a66b59940
faster emulation
...
Thanks Maxwell Bernstein for pointing this out 🤦♂️
2021-04-22 09:16:48 -07:00
Kartik K. Agaram
7a7191cc3e
clean up with the final bugfix
2021-04-22 09:09:23 -07:00
Kartik K. Agaram
bd0410c993
snapshot
...
It took me _way_ too long to realize that I'm not checking for errors within
the loop, and that will cause it to manifest as an infinite loop as inner
evaluations fail to run.
Debugging notes, for posterity:
printing one row of a chessboard pattern over fake screen (chessboard screen 4 0 0 15) gets stuck in an infinite loop halfway through
debug pattern during infinite loop: VWEX. It's still in the loop but it's not executing the body
raw (fill_rect screen 16 0 20 4 15) works fine
same number of calls to fill_rect work fine
replacing calls to fill_rect with pixel inside chessboard2 works fine
at the point of the infinite loop it's repeatedly going through the hline loop
-- BUT it never executes the check of the loop (< lo hi) with lo=20, hi=20. Something is returning 1, but it's not inside <
stream optimization is not implicated
simple test case with a single loop
(
(globals . (
(foo . (fn () (screen i n)
(while (< i n)
(pixel screen 4 4 i)
(pixel screen 5 4 i)
(pixel screen 6 4 i)
(pixel screen 7 4 i)
(set i (+ i 1)))))
))
(sandbox . (foo screen 0 100))
)
simpler (if you reset cursor position before every print):
(
(globals . (
(foo . (fn () (screen i n)
(while (< i n)
(print screen i)
(set i (+ i 1)))))
))
(sandbox . (foo screen 0 210))
)
I now believe it has nothing to do with the check. The check always works.
Sometimes no body is evaluated. And so the set has no effect.
2021-04-22 09:05:11 -07:00
Kartik K. Agaram
6842dddd68
.
2021-04-22 07:56:49 -07:00
Kartik K. Agaram
4afe53d834
shell: non-recursive 'while'
2021-04-21 21:34:55 -07:00
Kartik K. Agaram
a5e1a220fd
shell: refuse to 'def' duplicate names
2021-04-21 20:54:18 -07:00
Kartik K. Agaram
c54b7e9630
shell: separate 'def' from 'set'
...
'def' creates new bindings (only in globals)
'set' only modifies existing bindings (either in env or globals)
2021-04-21 20:53:38 -07:00
Kartik K. Agaram
bfc6fa1876
slightly more responsive animation
2021-04-21 20:12:16 -07:00
Kartik K. Agaram
bcd37c381a
clear old output when new run is in progress
...
I'm currently doing this extremely naively/slowly/uglily. Not a bottleneck.
2021-04-21 20:06:46 -07:00
Kartik K. Agaram
bc4b6021de
.
2021-04-21 19:56:32 -07:00
Kartik K. Agaram
5daa1f06d4
.
2021-04-21 19:45:02 -07:00
Kartik K. Agaram
9a5e94ce1f
.
2021-04-21 19:44:06 -07:00
Kartik K. Agaram
d27994a9d7
shell: show screen state during evaluation
...
All highly experimental. Current constraints:
* No tail recursion elimination
* No heap reuse
* Keep implementation simple
So it's slow, and I don't want to complicate it to speed it up. So I'm
investing in affordances to help deal with the slowness. However, in the
process I've taken the clean abstraction of a trace ("all you need to do
is add to the trace") and bolted on call counts and debug-prints as independent
mechanisms.
2021-04-21 00:25:06 -07:00
Kartik K. Agaram
7b2d39b8d4
an interface approximating stack traces
2021-04-20 23:27:13 -07:00
Kartik K. Agaram
fb34909b4e
get bresenham line drawing working with a trace
...
(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)))))
sandbox: (brline screen 1 1 5 5 12)
There are two ideas stemming from this commit:
- I need an extremely compact on-screen trace to underlie the trace UX
- perhaps we should start truncating trace lines
2021-04-20 19:47:57 -07:00
Kartik K. Agaram
fb3967876c
deemphasize fn arg evaluation slightly
2021-04-19 21:19:56 -07:00
Kartik K. Agaram
34596b6ee9
reimplement pixel graphics
...
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.
2021-04-19 21:05:57 -07:00
Kartik K. Agaram
f5ece0451b
start cleaning up pixel graphics
...
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.
2021-04-19 10:47:30 -07:00
Kartik K. Agaram
ad46997f95
.
2021-04-18 23:10:01 -07:00
Kartik K. Agaram
d94821d301
some primitives for monitoring code integrity
2021-04-18 11:56:10 -07:00
Kartik K. Agaram
e5adb2239c
.
2021-04-17 23:59:30 -07:00
Kartik K. Agaram
97df52bf2f
shell: ctrl-r runs on real screen without a trace
...
We run out of memory fairly early in the course of drawing a chessboard
on the whole screen.
2021-04-17 23:52:52 -07:00
Kartik K. Agaram
c11ea74442
.
2021-04-17 22:53:45 -07:00
Kartik K. Agaram
8be6fe2485
bump up the token limit again
...
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))
)
2021-04-17 22:35:35 -07:00
Kartik K. Agaram
c026dba006
shell: reenable the trace
...
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.
2021-04-17 22:33:28 -07:00
Kartik K. Agaram
60cab88ace
evaluating fns is too similar to its input
...
When I edit disk images directly, it's easy to forget a pair of parens.
Then the first expression of the body never executes.
2021-04-17 20:58:36 -07:00
Kartik K. Agaram
1154db7a74
load sandbox even if there are no globals
2021-04-17 19:35:02 -07:00
Kartik K. Agaram
412ec38f30
heh, the current state actually overflows 2KB
...
It only works because the part that's truncated is cleanly the sandbox.
I need better error-checking in `read`.
2021-04-17 09:09:32 -07:00
Kartik K. Agaram
5908943f47
Bresenham line-drawing now working
...
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))
)
2021-04-17 09:01:22 -07:00
Kartik K. Agaram
1354161a36
tmp: debugging why brline prints no pixels
...
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.
2021-04-17 08:34:48 -07:00
Kartik K. Agaram
1a74c3a1e6
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))
)
2021-04-17 08:29:43 -07:00
Kartik K. Agaram
6d9a1e6abc
.
2021-04-17 08:23:55 -07:00
Kartik K. Agaram
33f5eb632a
new primitives: abs, sgn
2021-04-16 20:40:02 -07:00
Kartik K. Agaram
f774677854
.
2021-04-16 20:26:56 -07:00
Kartik K. Agaram
f66de61392
handle drawing 16*4 = 64 pixels
...
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)))
)
2021-04-16 20:26:56 -07:00
Kartik K. Agaram
21a6f5539b
data.img now has more than one sector of data
2021-04-16 20:26:56 -07:00
Kartik K. Agaram
cec0d9553b
open question: animations in the fake screen
...
Right now we just render the state of the screen at the end of an evaluation.
2021-04-15 23:20:00 -07:00
Kartik K. Agaram
6aedf5dc59
.
2021-04-15 23:17:15 -07:00
Kartik K. Agaram
735636c7da
.
2021-04-15 23:15:47 -07:00
Kartik K. Agaram
c975f29a0c
.
2021-04-15 23:12:46 -07:00
Kartik K. Agaram
6392f1fde9
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.
2021-04-15 22:56:59 -07:00
Kartik K. Agaram
de993bc0cd
shell: primitives for screen size
2021-04-15 22:00:03 -07:00
Kartik K. Agaram
5b20f177b6
shell: restore bindings after restart
2021-04-15 21:40:48 -07:00
Kartik K. Agaram
9d367ec2ed
shell: start persisting global bindings
2021-04-15 21:05:55 -07:00
Kartik K. Agaram
0f760bd60c
.
2021-04-15 20:56:52 -07:00
Kartik K. Agaram
b2e0ce69ef
.
2021-04-15 20:15:22 -07:00
Kartik K. Agaram
0192e2031f
.
2021-04-15 20:12:36 -07:00
Kartik K. Agaram
91e30acbd8
.
2021-04-15 20:07:07 -07:00
Kartik K. Agaram
04da8ff8b0
add some structure to the serialization format
2021-04-15 19:56:16 -07:00
Kartik K. Agaram
613b1d5734
parse dotted lists
2021-04-15 19:47:01 -07:00
Kartik K. Agaram
2e06991834
.
2021-04-15 19:17:13 -07:00
Kartik K. Agaram
c414b9626f
.
2021-04-15 19:13:01 -07:00
Kartik K. Agaram
d41917290a
.
2021-04-15 19:12:07 -07:00
Kartik K. Agaram
849f80ac22
.
2021-04-15 18:42:14 -07:00
Kartik K. Agaram
fced134f8f
.
2021-04-15 17:41:55 -07:00
Kartik K. Agaram
60ef3caa4d
shell: starting to parse dotted lists
2021-04-15 17:38:14 -07:00
Kartik K. Agaram
d0578257cd
shell: dot token
2021-04-15 08:48:53 -07:00
Kartik K. Agaram
126a0390f5
.
2021-04-15 08:47:58 -07:00
Kartik K. Agaram
262290a4e8
.
2021-04-15 08:45:09 -07:00