Commit Graph

548 Commits

Author SHA1 Message Date
Kartik K. Agaram 13ef6b6202 . 2021-07-08 16:20:17 -07:00
Kartik K. Agaram cbf22e7ab2 primitives for double-buffering
I thought I needed these for this bouncing-ball demo:

  def (bounce screen)
    with (w (width screen)
          h (height screen)
          cx 16
          cy 16
          dx 12
          dy 19)
      while 1
        clear screen
        ring screen cx cy 16 3 5
        cx += dx
        cy += dy
        when (or (cx > w) (cx < 0))
          set dx 0-dx
        when (or (cy > h) (cy < 0))
          set dy 0-dy
        for _ 0 (< _ 100) ++_         # delay

No matter how I adjusted the delay I couldn't get rid of the jitter. So
I built a double-buffered version:

    (bounce2 . [def (bounce2 screen)
  with (w (width screen)
        h (height screen)
        cx 16
        cy 16
        dx 12
        dy 19
        screen2 (new_screen (columns screen)
                            (lines screen)))
      while 1
        clear screen2
        ring screen2 cx cy 16 3 5
        cx += dx
        cy += dy
        when (or (cx > w) (cx < 0))
          set dx 0-dx
        when (or (cy > h) (cy < 0))
          set dy 0-dy
        blit screen2 screen
        for _ 0 (< _ 100) ++_])       # delay

But it didn't make a difference! Turns out nothing will help you when
successive frames are too far apart. This is the correct tweak to
`bounce`:

  -       dx 12
  -       dy 19)
  +       dx 1
  +       dy (/ 19 12))

Still, we'll keep double-buffering around for the future.
2021-07-05 23:18:30 -07:00
Kartik K. Agaram 468b0d979f shell: fix clear on screens
Broken since commit c95648c96 on Jul 3.

Unclear what test to write for this. Should clear-stream check for NULL?
Should apply-clear?
2021-07-05 22:06:37 -07:00
Kartik K. Agaram 5d614af955 expose Mu implementation of 'bezier'
Still no support for acute-angled control points.
2021-07-05 18:31:07 -07:00
Kartik K. Agaram 493aabf79a replace 'circle' with Mu implementation 2021-07-05 18:21:02 -07:00
Kartik K. Agaram c7bedaf49b replace 'vline' with Mu implementation 2021-07-05 18:12:07 -07:00
Kartik K. Agaram 5d8a858a6f replace 'hline' with Mu implementation 2021-07-05 18:08:40 -07:00
Kartik K. Agaram 0b07a43367 replace 'line' with Mu implementation 2021-07-05 18:08:33 -07:00
Kartik K. Agaram ac1d702cdc . 2021-07-05 17:36:25 -07:00
Kartik K. Agaram 1ac1fe1fff . 2021-07-05 17:35:38 -07:00
Kartik K. Agaram c95648c960 reading from streams
The Mu shell has no string literals, only streams. No random access,
only sequential access. But I've been playing fast and loose with its
read pointer until now. Hopefully things are cleaned up now.
2021-07-03 18:27:01 -07:00
Kartik K. Agaram 7ced4e44dd alists 2021-07-03 16:28:15 -07:00
Kartik K. Agaram d986404ff0 new primitive: cons? 2021-07-03 16:16:03 -07:00
Kartik K. Agaram 810d9a26f5 . 2021-07-03 10:57:36 -07:00
Kartik K. Agaram a745749382 . 2021-07-03 10:44:05 -07:00
Kartik K. Agaram bd538804db reorg primitives on screen 2021-07-02 19:31:15 -07:00
Kartik K. Agaram c8fb6d6aca clean up final abort in macroexpand 2021-06-30 20:43:34 -07:00
Kartik Agaram 49d60aa575 delete a known issue
I can't reproduce the issue with the keyboard handler anymore :/
2021-06-30 09:44:20 -07:00
Kartik K. Agaram 0237be29aa . 2021-06-27 08:32:44 -07:00
Kartik K. Agaram efecaa99d5 simplify Qemu instructions
Turns out we don't need a special case for KVM.
  https://qemu.readthedocs.io/en/latest/system/invocation.html
2021-06-27 08:05:18 -07:00
Kartik Agaram 6f6f6384f1 . 2021-06-24 14:33:22 -07:00
Kartik Agaram 1684e3e10c . 2021-06-24 13:30:35 -07:00
Kartik Agaram eee222f14c . 2021-06-24 09:18:59 -07:00
Kartik Agaram 65077b46b4 . 2021-06-23 18:14:57 -07:00
Kartik Agaram 2c1770a349 . 2021-06-23 16:59:38 -07:00
Kartik Agaram 709902d34a . 2021-06-23 16:28:41 -07:00
Kartik Agaram e4b6665aee . 2021-06-23 16:24:56 -07:00
Kartik Agaram a25e4c1ac2 . 2021-06-23 11:05:57 -07:00
Kartik Agaram f13e3cdfb1 . 2021-06-23 11:05:53 -07:00
Kartik K. Agaram 6a65f6f233 one more bug, and documentation for infix
One error message gets a bit worse.
2021-06-23 10:06:57 -07:00
Kartik K. Agaram ba0c41673b . 2021-06-23 01:01:42 -07:00
Kartik K. Agaram cfa1bac8bb . 2021-06-23 00:59:14 -07:00
Kartik K. Agaram 577123e975 one more bug 2021-06-23 00:56:39 -07:00
Kartik K. Agaram f174695400 start using infix in data disk
Still some gaps to track down.
2021-06-23 00:03:07 -07:00
Kartik K. Agaram 76ef912eb2 all tests passing again; infix seems done 2021-06-22 23:39:54 -07:00
Kartik K. Agaram 2eae06ebda infix tests passing but something's still broken 2021-06-22 23:31:51 -07:00
Kartik K. Agaram 10e9a9a8d4 2 failing tests remaining
We just need to support unary operators.
2021-06-22 23:11:55 -07:00
Kartik K. Agaram 156b74c759 almost there; this is encouraging
The at-head-of-list? is a really ugly hack, though.
2021-06-22 23:02:09 -07:00
Kartik K. Agaram aebcfd1bfb beginnings of tokenization within symbols
We're now down to 4 failing tests. But these will require surgery.
2021-06-22 22:32:20 -07:00
Kartik K. Agaram f5e55cbbdb . 2021-06-22 21:57:47 -07:00
Kartik K. Agaram 0436ab71ea clean up lexical categories 2021-06-22 21:43:44 -07:00
Kartik K. Agaram 59d904b4df snapshot
Still a couple of failing tests before I switch gears to breaking down
symbols containing infix.
2021-06-22 21:25:04 -07:00
Kartik K. Agaram 5997eafd46 . 2021-06-22 21:24:06 -07:00
Kartik K. Agaram 26e9387df6 snapshot: infix
Like parenthesize, I'm copying tests over from https://github.com/akkartik/wart
Unlike parenthesize, though, I can't just transliterate the code itself.
Wart was operating on an intermediate AST representation. Here I'm all
the way down to cells. That seemed like a good idea when I embarked, but
now I'm not so sure. Operating with the right AST data structure allowed
me to more easily iterate over the elements of a list. The natural recursion
for cells is not a good fit.

This patch and the next couple is an interesting case study in what makes
Unix so effective. Yes, you have to play computer, and yes it gets verbose
and ugly. But just diff and patch go surprisingly far in helping build a
picture of the state space in my brain.

Then again, there's a steep gradient of skills here. There are people who
can visualize state spaces using diff and patch far better than me, and
people who can't do it as well as me. Nature, nurture, having different
priorities, whatever the reason. Giving some people just the right crutch
excludes others.
2021-06-22 21:23:40 -07:00
Kartik K. Agaram 74d6a4d382 . 2021-06-21 22:02:47 -07:00
Kartik K. Agaram 6669133bcf start implementing infix
First step: undo operator support in tokenization.
2021-06-21 22:00:55 -07:00
Kartik K. Agaram 0f071ae99b . 2021-06-20 23:09:50 -07:00
Kartik K. Agaram 77f347c181 shell: now no definitions with long lines 2021-06-20 23:07:23 -07:00
Kartik K. Agaram b195921b5f shell: shrink definition widths in a few places
The only remaining long lines now are in 'pair' and 'with'.
2021-06-20 23:07:23 -07:00
Kartik K. Agaram 3fd3f3a1c7 this is how we create aliases 2021-06-20 23:07:23 -07:00
Kartik K. Agaram 9ae724e1ec preserve indentation of the sandbox 2021-06-20 23:07:23 -07:00
Kartik K. Agaram 7045af7a4e 'with' lets us drop a few more parens 2021-06-20 22:33:05 -07:00
Kartik K. Agaram fa26249931 new macro: with 2021-06-20 22:32:03 -07:00
Kartik K. Agaram ecc763f092 new macro: ret
http://arclanguage.org/item?id=11068
2021-06-20 22:32:03 -07:00
Kartik K. Agaram deb610367f start dropping parens everywhere 2021-06-20 21:29:33 -07:00
Kartik K. Agaram 6e1aa99a00 start guessing parentheses based on indentation 2021-06-20 21:18:38 -07:00
Kartik K. Agaram 9d7d99fe6c snapshot
This is going better than expected; just 3 failing tests among the new
ones.
2021-06-20 20:36:47 -07:00
Kartik K. Agaram 29795a0db4 start emitting indent tokens 2021-06-18 21:42:01 -07:00
Kartik K. Agaram e5cf570890 redo next-token in more high-level terms 2021-06-18 20:39:33 -07:00
Kartik K. Agaram 80fb9ca9f4 . 2021-06-18 20:12:32 -07:00
Kartik K. Agaram c6cb360544 . 2021-06-18 20:08:19 -07:00
Kartik K. Agaram 93e2e3f934 start emitting token for newline 2021-06-18 20:00:29 -07:00
Kartik K. Agaram 24275c3828 newlines are now a token 2021-06-18 19:54:01 -07:00
Kartik K. Agaram dd133c2a09 start implementing indent-sensitivity
General plan:
  stop skipping newlines during tokenization
  introduce a new indent token, initially skip it transparently
  start doing cleverer things
2021-06-18 19:52:54 -07:00
Kartik K. Agaram b5306cabd3 . 2021-06-18 19:40:35 -07:00
Kartik K. Agaram 2acc00f9b9 . 2021-06-18 07:54:24 -07:00
Kartik K. Agaram c22dbbea39 make code in Readme easier to copy
Thanks Sumeet Agarwal for the suggestion.
2021-06-18 07:11:36 -07:00
Kartik K. Agaram 0f2d0d6abe shell: stop punning tokens as cells 2021-06-18 06:53:55 -07:00
Sumeet Agarwal f36f022b08 change precision when loading sandbox code 2021-06-17 21:24:41 -07:00
Kartik Agaram 3a3fe4addb shell: better screenshot 2021-06-15 15:54:56 -07:00
Kartik K. Agaram 6280749410 always print black pixels when rendering screens
This is an old 'optimization' that turns out to not actually matter.
2021-06-15 15:37:37 -07:00
Kartik Agaram 0138b000a1 shell: improve docs 2021-06-15 14:48:52 -07:00
Kartik Agaram 88378503c4 . 2021-06-15 14:46:27 -07:00
Kartik K. Agaram bc21fe0baf document responsiveness trade-off 2021-06-15 13:02:15 -07:00
Kartik K. Agaram 2bf7cb83ba do more work per fake-screen refresh
Refreshing the fake screen is still a heavyweight operation. Double-buffering
makes it less obvious but doesn't actually reduce the amount of work. We
need to ensure that we do enough work between refreshes to make them economic.
2021-06-15 12:36:38 -07:00
Kartik K. Agaram 8068b8450f more precisely track count of calls to eval
Before I only separately counted calls at each stack depth. I don't remember
if that seemed good enough or was just an oversight.
2021-06-15 12:28:52 -07:00
Kartik K. Agaram c2c6f4c7ab flickerlessly render fake screens in environment
Font rendering now happens off the real screen, which provides the effect
of double-buffering.

Apps can now also use convert-graphemes-to-pixels for more traditional
double-buffering.
2021-06-15 10:33:18 -07:00
Kartik K. Agaram f99cd767a4 periodic run of misc_checks
I should really stop using /disp8 jumps at the top-level given how inconvenient
it is to check for overly large offsets.
2021-06-12 22:34:22 -07:00
Kartik K. Agaram 0dda332ce3 .
Roll back to commit 70919b45f0. Recent commits add lots of extra function
args for dubious benefit.
2021-06-12 21:11:22 -07:00
Kartik K. Agaram 82fdf176c1 snapshot
Looks like what's slowing down screen rendering is in fact _font_ rendering.
2021-06-12 21:11:03 -07:00
Kartik K. Agaram 85bcf050e7 . 2021-06-12 17:50:30 -07:00
Kartik K. Agaram 9b5b3bccd1 trying to eliminate flicker when rendering screen
Two interesting things:
- We don't really need double-buffering for rendering the screen on the
  sandbox as a progress indicator. Everything else is untouched, and render-screen
  should be doing that as well.

- Rendering just pixels of the fake screen is buttery smooth. It's the
  _graphemes_ that are slowing things down. Even though there's so many
  fewer of them!

As a result, drawing the fake screen less frequently in `evaluate` doesn't
actually help with flicker. Even though it'll make the debug cycle shorter.
So my current plan is to attack flicker in isolation before I mess with
the render frequency.

In this commit I optimized away the cursor handling. Still doesn't seem
to be helping. In fact it actually seems _worse_.
2021-06-12 17:40:53 -07:00
Kartik K. Agaram 286819685e eliminate some implicit writes to real screen 2021-06-12 16:24:27 -07:00
Kartik K. Agaram 70919b45f0 .
Rename cells containing screens to screen vars because of the ambiguity
that each grapheme in fake screens is represented by a type screen-cell.
While we're at it, we also analogously rename keyboard vars.
2021-06-12 15:16:50 -07:00
Kartik K. Agaram 4bd1785c86 shell: larger fake screen 2021-06-12 10:46:28 -07:00
Kartik Agaram 662e6b7177 . 2021-06-11 23:02:12 -07:00
Kartik K. Agaram d4968adbc9 . 2021-06-11 23:00:00 -07:00
Kartik K. Agaram af2e837787 try to abolish NULL from primitives 2021-06-11 22:48:14 -07:00
Kartik K. Agaram 952fb9a677 car/cdr of nil is now nil 2021-06-11 21:46:59 -07:00
Kartik K. Agaram 0dc4f9c62b hacky bugfix: support floats in nth
Needed because we don't yet have a primitive in the shell to truncate/round
non-integers to integers.

Before:
  (nth (/ 31 10)    # we don't have float literals yet
       '(1 2 3 4))
  => NULL

..with an unpleasant abort likely later on.

Really the correct thing to do is ensure none of my primitives ever returns
NULL. Start with car/cdr.
2021-06-11 21:36:12 -07:00
Kartik K. Agaram 3191861242 better name 2021-06-11 20:11:16 -07:00
Kartik K. Agaram ef29fcdc91 cancel pending test
After all that, I'm not sure this is the desired behavior. If a function
defines multiple bindings, we shouldn't rename all their keys. So how to
choose?

Perhaps it's not so bad to have "symlinks" in this "file system". To unlink
two bindings you now need to define one of them in the sandbox.

All the refactoring is still useful, though.
2021-06-11 19:33:08 -07:00
Kartik K. Agaram cbf3de0f08 back to the pending test
I'm ready again to take on commit 6169ec59c after lots of refactoring.
2021-06-11 19:26:20 -07:00
Kartik K. Agaram 040b60bc6e .
Save a single trace to potentially multiple globals just like a gap buffer
(if say we have a single let binding defining multiple functions).

I don't have a strong use for this yet, but it seems cleaner. Maybe it's
redundant or wrong.
2021-06-11 19:17:08 -07:00
Kartik K. Agaram 6f64f5d3b6 . 2021-06-11 18:20:47 -07:00
Kartik K. Agaram 8257825468 . 2021-06-11 18:20:30 -07:00
Kartik K. Agaram c1e5ddfa54 . 2021-06-11 18:20:25 -07:00
Kartik K. Agaram 18c8e8c82f . 2021-06-11 17:54:04 -07:00
Kartik K. Agaram 4de136fb85 . 2021-06-11 17:50:34 -07:00
Kartik K. Agaram 177fa96a93 . 2021-06-11 17:48:12 -07:00