Commit Graph

36 Commits

Author SHA1 Message Date
Kartik K. Agaram d253a31828 rename grapheme to code-point-utf8
Longer name, but it doesn't lie. We have no data structure right now for
combining multiple code points. And it makes no sense for the notion of
a grapheme to conflate its Unicode encoding.
2021-11-09 08:12:11 -08:00
Kartik K. Agaram 6e05a8fa27 fix bad terminology: grapheme -> code point
Unix text-mode terminals transparently support utf-8 these days, and so
I treat utf-8 sequences (which I call graphemes in Mu) as fundamental.

I then blindly carried over this state of affairs to bare-metal Mu,
where it makes no sense. If you don't have a terminal handling
font-rendering for you, fonts are most often indexed by code points and
not utf-8 sequences.
2021-08-29 22:20:09 -07:00
Kartik K. Agaram 267c74b59a shell: render image from pbm data stream 2021-07-27 22:38:26 -07:00
Kartik K. Agaram 46441d7204 .
Smoked out some issues by rendering a single frame of Game of Life.
Incredibly slow.
2021-07-26 02:27:32 -07:00
Kartik K. Agaram ef637b6bab . 2021-07-26 01:12:04 -07:00
Kartik K. Agaram 3e76e0540b shell primitive: initialize array of some size 2021-07-26 00:56:30 -07:00
Kartik K. Agaram 4c224c5375 shell primitive: iset to mutate array at index 2021-07-25 16:46:12 -07:00
Kartik K. Agaram f7a890d435 shell primitive: array index 2021-07-25 16:35:21 -07:00
Kartik K. Agaram 17e50d27d4 shell: array type 2021-07-25 16:24:45 -07:00
Kartik K. Agaram 251f317c38 . 2021-07-25 16:24:45 -07:00
Kartik K. Agaram 170b6787c5 shell: starting to implement arrays 2021-07-25 16:24:45 -07:00
Kartik K. Agaram 492f7bd0b7 . 2021-07-25 12:36:18 -07:00
Kartik K. Agaram 1eb1ac81ea . 2021-07-19 20:08:30 -07:00
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 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 bd538804db reorg primitives on screen 2021-07-02 19:31:15 -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 fa26249931 new macro: with 2021-06-20 22:32:03 -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 286819685e eliminate some implicit writes to real screen 2021-06-12 16:24:27 -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 3bdf3b1a7f shell: remainder operation 2021-06-06 12:11:14 -07:00
Kartik K. Agaram d555a71cb3 . 2021-06-06 11:53:25 -07:00
Kartik K. Agaram d00f8dc6ca . 2021-06-03 20:37:51 -07:00