libraryextensions/blender/demos/HexRun.xtl

HexRun.xtl -- HEX1000-UART computing C0DE+BEEF=, a video made with the explainer kit (Video.xtl) from a simulation of its board: the text sent over the serial line bit by bit, the board queuing each key, the machine scanning its key matrix, its program counter hopping through a ROM page, A, the status, the ALU and the RAM changing, and the digits strobed out to a calculator's display. Everything moving is a signal of the simulation's waveform (scripts/hex1000-sim.sh: the board's Verilog from X_eTaL-fpga at FPGA_COMMIT under iverilog; Vcd.xtl reads it), sampled once a frame; X_eTaL-fpga's Hex1000.xtl replays the same clocks from the K inputs the circuit saw and must agree with its registers at every one, and the display it ends with must be the evaluator's (hx:c_alc) -- else no script is written. Beside the calculator at the end, the browser calculator's screen (scripts/hex1000-browser.py). Shared by the demo (demos/hex-run.xtl) and its test. Import: "hr:" u_se< "HexRun"

source · imports hx: work/fpga/libs/Hex1000/src/Hex1000.xtl; vc: extensions/blender/demos/Vcd.xtl; vd: extensions/blender/lib/Video.xtl; s: work/libraries/libs/Strings/src/Strings.xtl

The run

ˡtext : Char

value · line 26

text: what is typed at the board, over its serial line

ˡtext ← "C0DE+BEEF="

ˡbit : Int

value · line 29

bit: the serial line's bit time in the simulation (ps; 115200 baud)

ˡbit ← 8680000

ʰa̲t : Any a => ((Box Char, Int), Char, Int) -> a -> Int

function (private) · line 32
ʰa̲t ← { (v, name, ts) z → (v, name, ts) ᵛᶜa̲t 0 }

ʰu̲s : Num a => a -> Float

function (private) · line 35
ʰu̲s ← { ps → (f̲loat ps) ÷ 1000000.0 }
Used in: ʰv̲ideo

ˡc̲locks : (Box Char, Int) -> Int

function · line 40

hr:c_locks v: when the waveform v's count of machine clocks became each value, 0 (reset) 1 2 ... (ps): a state is the circuit's after that many instructions

ˡc̲locks ← { v → 1 s̲elect₂ (v, "cycle") ᵛᶜc̲hanges 0 }

ˡl̲ine : (Box Char, Int) -> (Int, Int)

function · line 47

hr:l_ine v: the serial line decoded from the waveform: (starts, bits) -- when each character's start bit began (ps; the testbench sends them back to back) and its ten bits as the line had them at their middles, a row a character: start (0), the data bits from the lowest, stop (1)

ˡl̲ine ← { v →
  c ← (v, "uart_rx") ᵛᶜc̲hanges 0
  first ← f̲irst ((0 = 2 s̲elect₂ c) ∧ 0 < 1 s̲elect₂ c) r̲eplicate 1 s̲elect₂ c
  n ← t̲ally ˡtext
  starts ← first + 10 × ˡbit × (r̲ange n) − 1
  ts ← (n c̲at 10) r̲eshape r̲avel starts 'l̲eft t̲able 0 1 2 3 4 5 6 7 8 9
  at ← ts + (ˡbit d̲iv 2) + ˡbit × (n c̲at 10) r̲eshape 0 1 2 3 4 5 6 7 8 9
  (starts, (n c̲at 10) r̲eshape (v, "uart_rx", r̲avel at) ʰa̲t 0)
}

ˡr̲eceived : (Box Char, Int) -> (Int, Int)

function · line 59

hr:r_eceived v: the bytes the board's UART core handed on, (times, bytes): when its valid flag rose (ps), and the byte

ˡr̲eceived ← { v →
  c ← (v, "valid") ᵛᶜc̲hanges 0
  ts ← (1 = 2 s̲elect₂ c) r̲eplicate 1 s̲elect₂ c
  (ts, (v, "rxb", ts) ʰa̲t 0)
}

ˡsegments : Int

value · line 70

the seven segments a b c d e f g of each hexadecimal digit, a bit each from the lowest

      "hr:" u̲se< "HexRun"
      4 t̲ake ʰʳsegments
63 6 91 79
ˡsegments ← 63 6 91 79 102 109 125 7 127 111 119 124 57 94 121 113
Used in: ˡs̲cene

ˡs̲creen : Int -> Char

function · line 78

hr:s_creen shown: the display's eight digit latches (5 bits each, digit 0 the lowest: a digit shown when its bit 4 is set) as the text a terminal shows, digit 7 first, blank where not shown

      "hr:" u̲se< "HexRun"
      ʰʳs̲creen 18612125
   17FCD
ˡs̲creen ← { d →
  ds ← (8 r̲eshape 32) e̲ncode d
  (1 + (ds ≥ 16) × 1 + ds m̲od 16) s̲elect " 0123456789ABCDEF"
}

ˡc̲heck : Any a => ((Box Char, Int), Char) -> a -> Char

function · line 89

hr:c_heck (v, browser): the checks a video is made after, as lines of text, or a panic naming the one that failed: the line carries the text, the board's UART receives it, Hex1000.xtl replaying the clocks from the K inputs the circuit saw has its A, S, PC and PA at every one, and the display at the end is the evaluator's (hx:c_alc) and the browser's (its screen's text; "" skips that check)

ˡc̲heck ← { (v, browser) z →
  (starts, bits) ← ˡl̲ine v
  codes ← ⎕U̲CS ˡtext
  ok1 ← (0 = '+ r̲/ 1 s̲elect₂ bits) ∧ ('×  r̲/ 10 s̲elect₂ bits) ∧ codes m̲atch 2 d̲ecode r̲ev 2 1 t̲ranspose 8 t̲ake₂ 1 d̲rop₂ bits
  n̲ot ok1 ? ⎕P̲ANIC "hex-run: the serial line does not carry " c̲at ˡtext
  (ts, bytes) ← ˡr̲eceived v
  n̲ot codes m̲atch bytes ? ⎕P̲ANIC "hex-run: the board received " c̲at ⎕U̲CHAR bytes
  t ← ˡc̲locks v
  n ← t̲ally t
  mid ← t + 518000
  ks ← (v, "k", mid) ʰa̲t 0
  rom ← ʰˣCalcRom
  (last, i, rows) ← (n − 1) '{ (st, i, m) → s1 ← (rom ʰˣs̲tep st) i s̲elect ks
    (s1, i + 1, m c̲at 1 4 5 6 s̲elect ʰˣr̲egs s1) } p̲ower (ʰˣReset, 1, 0 r̲eshape 0)
  m ← ((n − 1) c̲at 4) r̲eshape rows
  vcd ← 2 1 t̲ranspose (4 c̲at n − 1) r̲eshape (1 d̲rop (v, "a", mid) ʰa̲t 0) c̲at (1 d̲rop (v, "s", mid) ʰa̲t 0) c̲at (1 d̲rop (v, "pc", mid) ʰa̲t 0) c̲at 1 d̲rop (v, "pa", mid) ʰa̲t 0
  bad ← '+ r̲/ r̲avel n̲ot m = vcd
  bad > 0 ? ⎕P̲ANIC "hex-run: Hex1000.xtl and the circuit differ at " c̲at (f̲ormat bad) c̲at " register values"
  shown ← ˡs̲creen f̲irst (v, "shown", 1 r̲eshape f̲irst -1 t̲ake 1 s̲elect₂ (v, "shown") ᵛᶜc̲hanges 0) ʰa̲t 0
  want ← ʰˣc̲alc ˡtext
  n̲ot want m̲atch shown ? ⎕P̲ANIC "hex-run: the display ends " c̲at shown c̲at ", the evaluator's " c̲at want
  inb ← ("| " c̲at want c̲at " |") ˢi̲nfix? browser
  ((t̲ally browser) > 0) ∧ n̲ot inb ? ⎕P̲ANIC "hex-run: the browser's screen is not " c̲at want
  also ← "\nthe browser calculator shows it too"
  b ← (((t̲ally browser) > 0) × t̲ally also) t̲ake also
  "the line carries " c̲at ˡtext c̲at " (" c̲at (f̲ormat t̲ally bits) c̲at " characters of 10 bits)\nthe board's UART received " c̲at (⎕U̲CHAR bytes) c̲at "\nHex1000.xtl replayed " c̲at (f̲ormat n − 1) c̲at " clocks from the circuit's K: A, S, PC and PA agree at every one\nthe display ends showing " c̲at (ˢt̲rim shown) c̲at ", the evaluator's (hx:c_alc)" c̲at b
}

Time

ˡmap : Float

value · line 123

map: the simulation's microseconds as the video's seconds (vd:r_etime): a title card; the first character's ten bits in slow motion; the machine finding that key, slower still; the other nine keys a time-lapse; one addition in slow motion; then the display

ˡmap ← 6 2 r̲eshape 290.0 3.4  387.0 10.4  413.0 16.4  2975.0 25.4  3055.0 35.4  3175.0 37.6

ˡlength : Float

value · line 126

length: the video's seconds

ˡlength ← 42.0

ˡframes : Float

value · line 132

frames: each frame's second in the video (30 a second)

      "hr:" u̲se< "HexRun"
      3 t̲ake ʰʳframes
0.0 0.03333333333333333 0.06666666666666667
ˡframes ← ((f̲loat r̲ange 1 + f̲loor 0.5 + 30.0 × ˡlength) − 1.0) ÷ 30.0

ˡframePs : Int

value · line 135

framePs: the simulation's time at each frame (ps)

ˡframePs ← f̲loor 1000000.0 × ((2 1 s̲elect₂ ˡmap), ˡframes) ᵛᵈr̲etime 0
Used in: ʰf̲rames

ʰv̲ideo : Num a => a -> Float

function (private) · line 138
ʰv̲ideo ← { ps → (ˡmap, ʰu̲s ps) ᵛᵈr̲etime 0 }
Used in: ˡs̲cene

ʰf̲rames : Any a => ((Box Char, Int), Char) -> a -> Int

function (private) · line 141
ʰf̲rames ← { (v, name) z → (v, name, ˡframePs) ᵛᶜa̲t 0 }
Used in: ˡs̲cene, ʰr̲am

ʰs̲tepRows : (Num a, Num b, Any c) => (a, b) -> c -> Float

function (private) · line 146
ʰs̲tepRows ← { (g, ts) z →
  n ← 1 s̲elect s̲hape g
  m ← 2 s̲elect s̲hape g
  keep ← r̲avel 2 1 t̲ranspose ((1 c̲at m) r̲eshape 1 = 1) c̲at n̲ot (1 d̲rop g) = -1 d̲rop g
  obj ← r̲avel 2 1 t̲ranspose (n c̲at m) r̲eshape f̲loat r̲ange m
  at ← r̲avel (m c̲at n) r̲eshape f̲loat ts
  val ← r̲avel 2 1 t̲ranspose f̲loat g
  k ← '+ r̲/ keep
  2 1 t̲ranspose (3 c̲at k) r̲eshape (keep r̲eplicate obj) c̲at (keep r̲eplicate at) c̲at keep r̲eplicate val
}
Used in: ˡs̲cene

ʰp̲laceRows : (Num a, Any b) => (a, a) -> b -> a

function (private) · line 159
ʰp̲laceRows ← { (rows, p) z →
  i ← 1 + f̲loor 3 s̲elect₂ rows
  (2 t̲ake₂ rows) c̲at₂ 2 1 t̲ranspose (3 c̲at t̲ally i) r̲eshape (i s̲elect 1 s̲elect₂ p) c̲at (i s̲elect 2 s̲elect₂ p) c̲at i s̲elect 3 s̲elect₂ p
}
Used in: ˡs̲cene

Where things are

ˡuart : Float

value · line 168

the four areas' middles: the serial line, the key matrix, the machine, the display

ˡuart ← -7.0 0.0 4.5
Used in: ˡs̲cene

ˡkeys : Float

value · line 170

the key matrix's

ˡkeys ← 7.0 0.0 4.5
Used in: ˡs̲cene

ˡcpu : Float

value · line 172

the machine's

ˡcpu ← 7.0 0.0 -5.5
Used in: ˡs̲cene

ˡdisplay : Float

value · line 174

the display's

ˡdisplay ← -7.0 0.0 -5.5
Used in: ˡs̲cene

ʰp̲os : (Num a, Any b) => (a, a, a) -> b -> a

function (private) · line 178
ʰp̲os ← { (c, xs, zs) z →
  n ← t̲ally xs
  2 1 t̲ranspose (3 c̲at n) r̲eshape (xs + 1 s̲elect c) c̲at (n r̲eshape 2 s̲elect c) c̲at zs + 3 s̲elect c
}
Used in: ˡs̲cene

ʰb̲oxes : (Num a, Num b) => (Float, a, b, Float) -> Float

function (private) · line 184
ʰb̲oxes ← { (p, size, rgb, g) →
  n ← 1 s̲elect s̲hape p
  p c̲at₂ (n c̲at 7) r̲eshape (f̲loat size) c̲at (f̲loat rgb) c̲at g
}
Used in: ˡs̲cene

ʰb̲ars : Char -> Char

function (private) · line 190
ʰb̲ars ← { t → -1 d̲rop r̲avel 2 1 t̲ranspose (2 c̲at t̲ally t) r̲eshape t c̲at (t̲ally t) r̲eshape "|" }
Used in: ˡs̲cene

ʰbitJ : Float

value (private) · line 193
ʰbitJ ← f̲loat (r̲ange 10 × t̲ally ˡtext) − 1

ʰbitX : Float

value (private) · line 194
ʰbitX ← -4.4 + 0.86 × ʰbitJ − 10.0 × f̲loat f̲loor ʰbitJ ÷ 10.0
Used in: ˡs̲cene

ʰbitZ : Float

value (private) · line 195
ʰbitZ ← 2.6 − 0.62 × f̲loat f̲loor ʰbitJ ÷ 10.0
Used in: ˡs̲cene

ʰcodes : Float

value (private) · line 199
ʰcodes ← f̲loat (r̲ange 21) − 1
Used in: ʰkeyX, ʰkeyZ

ʰkeyX : Float

value (private) · line 200
ʰkeyX ← -3.5 + 1.25 × f̲loat f̲loor ʰcodes ÷ 4.0
Used in: ˡs̲cene

ʰkeyZ : Float

value (private) · line 201
ʰkeyZ ← -2.3 + 1.25 × ʰcodes − 4.0 × f̲loat f̲loor ʰcodes ÷ 4.0
Used in: ˡs̲cene

ˡkeyNames : Char

value · line 203

keyNames: the keys' labels, by code

ˡkeyNames ← "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|+|-|*|=|X"
Used in: ˡs̲cene

ʰaddr : Float

value (private) · line 206
ʰaddr ← f̲loat (r̲ange 64) − 1
Used in: ʰromX, ʰromZ

ʰromX : Float

value (private) · line 207
ʰromX ← -5.6 + 0.62 × ʰaddr − 8.0 × f̲loat f̲loor ʰaddr ÷ 8.0
Used in: ˡs̲cene

ʰromZ : Float

value (private) · line 208
ʰromZ ← 2.9 − 0.62 × f̲loat f̲loor ʰaddr ÷ 8.0
Used in: ˡs̲cene

ʰword : Float

value (private) · line 211
ʰword ← f̲loat (r̲ange 64) − 1

ʰramX : Float

value (private) · line 212
ʰramX ← 1.0 + 0.24 × ʰword − 16.0 × f̲loat f̲loor ʰword ÷ 16.0
Used in: ˡs̲cene

ʰramFloor : Float

value (private) · line 213
ʰramFloor ← -0.2 − 1.05 × f̲loat f̲loor ʰword ÷ 16.0
Used in: ˡs̲cene

ʰseg : Float

value (private) · line 216
ʰseg ← f̲loat (r̲ange 56) − 1
Used in: ʰsegP, ʰsegS

ʰsegP : Float

value (private) · line 217
ʰsegP ← f̲loat f̲loor ʰseg ÷ 7.0
Used in: ʰsegS, ˡs̲cene

ʰsegS : Float

value (private) · line 218
ʰsegS ← ʰseg − 7.0 × ʰsegP

ʰsegDx : Float

value (private) · line 219
ʰsegDx ← (1 + f̲loor ʰsegS) s̲elect 0.0 0.3 0.3 0.0 -0.3 -0.3 0.0
Used in: ˡs̲cene

ʰsegDz : Float

value (private) · line 220
ʰsegDz ← (1 + f̲loor ʰsegS) s̲elect 0.6 0.3 -0.3 -0.6 -0.3 0.3 0.0
Used in: ˡs̲cene

ʰsegFlat : Int

value (private) · line 221
ʰsegFlat ← (1 + f̲loor ʰsegS) s̲elect 1 0 0 1 0 0 1
Used in: ˡs̲cene

ʰaluKinds : Int

value (private) · line 224
ʰaluKinds ← 10 11 12 13 14 15 16 17 18 19 20 36 37
Used in: ˡs̲cene

Words

ˡtitle : Char

value · line 229

the title card's title and subtitle

ˡtitle ← "HEX1000-UART"

ˡsubtitle : Char

value · line 231

the subtitle

ˡsubtitle ← "C0DE+BEEF= over UART on a Tang Nano 9K, simulated clock by clock"

ˡcaptionTable : Float

value · line 234

captionTable: each caption's from and to (video seconds), white

ˡcaptionTable ← 5 5 r̲eshape 3.8 10.0 255 255 255  10.8 16.2 255 255 255  17.8 24.8 255 255 255  25.8 35.2 255 255 255  36.8 42.0 255 255 255

ʰcardTable : Float

value (private) · line 237
ʰcardTable ← 1 8 r̲eshape 0.0 3.2 255 255 255 18 22 44

ˡc̲aptions : (Box Char, Int) -> Char

function · line 241

hr:c_aptions v: the captions, | between them, their numbers from the run

ˡc̲aptions ← { v →
  t ← ˡc̲locks v
  done ← f̲irst -1 t̲ake 1 s̲elect₂ (v, "shown") ᵛᶜc̲hanges 0
  clocks ← '+ r̲/ t ≤ done
  shown ← ˢt̲rim ˡs̲creen f̲irst (v, "shown", 1 r̲eshape done) ʰa̲t 0
  "slow motion: each key arrives on the serial line as 10 bits, a start bit, 8 data bits from the lowest, a stop bit" c̲at "|the board queues it; the machine selects the key columns one by one (R8 to R13) and finds its row on K" c̲at "|time-lapse: the other " c̲at (f̲ormat (t̲ally ˡtext) − 1) c̲at " keys wait in the queue, a few hundred clocks each, and the display shows them" c̲at "|slow motion: the sum, a digit at a time with its carry (AMAAC), the RAM's bars changing" c̲at "|" c̲at shown c̲at " after " c̲at (f̲ormat clocks) c̲at " clocks: the circuit's display, the evaluator's and the browser's agree"
}

ˡc̲ues : (Box Char, Int) -> Char

function · line 251

hr:c_ues v: the title card's and the captions' texts, for vd:c_ues and vd:s_rt

ˡc̲ues ← { v → ˡtitle c̲at ": " c̲at ˡsubtitle c̲at "|" c̲at ˡc̲aptions v }
Used in: _

ˡcueTable : Float

value · line 253

cueTable: their from and to (video seconds)

ˡcueTable ← (2 t̲ake₂ ʰcardTable) c̲at 2 t̲ake₂ ˡcaptionTable
Used in: _

The scene

ʰsky : Int

value (private) · line 258
ʰsky ← 8 10 18
Used in: ˡs̲cene

ʰcamTimes : Float

value (private) · line 263
ʰcamTimes ← 0.0 10.0 11.0 16.4 17.6 24.8 25.8 35.2 36.6 42.0
Used in: ˡs̲cene

ʰcamAims : Float

value (private) · line 264
ʰcamAims ← 10 3 r̲eshape -7.0 0.0 4.5  -7.0 0.0 4.5  7.0 0.0 4.5  7.0 0.0 4.5  0.0 0.0 -0.5  0.0 0.0 -0.5  7.0 0.0 -5.5  7.0 0.0 -5.5  -7.0 0.0 -5.5  -7.0 0.0 -5.5
Used in: ˡs̲cene

ʰcamWide : Int

value (private) · line 265
ʰcamWide ← 0 0 0 0 1 1 0 0 0 0
Used in: ˡs̲cene

ʰcamSide : Float

value (private) · line 266
ʰcamSide ← 0.06 -0.04 0.05 -0.05 0.0 0.03 -0.05 0.05 0.04 -0.04
Used in: ˡs̲cene

ˡs̲cene : (Num a, Any b) => (a, (Box Char, Int), Char) -> b -> Char

function · line 275

(size, v, picture) hr:s_cene 0: the whole script Blender runs, before its stills or video: the stage at that size (vd:landscape or vd:shorts); the serial line, the key matrix, the machine and the display, every lamp, bar, marker and segment keyed in steps from the waveform v sampled once a frame; a clock count and the instruction in front of the camera; the browser's screen (a PNG; "" for none) under the display; the camera, the title card, the captions

ˡs̲cene ← { (size, v, picture) z →
  w ← 1 s̲elect size
  h ← 2 s̲elect size
  d ← (w, h, 35, 14.0, 13.0) ᵛᵈf̲it 0
  dw ← (w, h, 35, 28.5, 21.0) ᵛᵈf̲it 0
  n ← t̲ally ˡframes
  ts ← ˡframes
  ⍝ the stage, the areas' names, the wires between them
  middles ← 4 3 r̲eshape ˡuart c̲at ˡkeys c̲at ˡcpu c̲at ˡdisplay
  names ← (middles + 4 3 r̲eshape 0.0 0.0 4.2) c̲at₂ 4 4 r̲eshape 0.6 200 205 230
  ⍝ the serial line: the line itself, high bright and low dark, and each
  ⍝ bit lit as it arrives, a 1 bright and a 0 dim; the bytes received
  (starts, bits) ← ˡl̲ine v
  nb ← 10 × t̲ally ˡtext
  rx ← (n c̲at 1) r̲eshape 0.15 + 2.35 × f̲loat (v, "uart_rx") ʰf̲rames 0
  p ← (ˡuart, ʰbitX, ʰbitZ) ʰp̲os 0
  edge ← f̲loat (0.0 = ʰbitJ − 10.0 × f̲loat f̲loor ʰbitJ ÷ 10.0) ∨ 9.0 = ʰbitJ − 10.0 × f̲loat f̲loor ʰbitJ ÷ 10.0
  rgb ← 2 1 t̲ranspose (3 c̲at nb) r̲eshape (255.0 − 135.0 × edge) c̲at (216.0 − 76.0 × edge) c̲at 77.0 + 143.0 × edge
  arrive ← ʰv̲ideo r̲avel (r̲avel starts) '+ t̲able (ˡbit d̲iv 2) + ˡbit × 0 1 2 3 4 5 6 7 8 9
  lit ← 0.3 + 1.9 × f̲loat r̲avel bits
  (got, bytes) ← ˡr̲eceived v
  nc ← t̲ally bytes
  ⍝ the key matrix: the keys, the held one framed, the columns R8 to R13
  ⍝ and the rows K as lamps, the board's queue
  kp ← (ˡkeys, ʰkeyX, ʰkeyZ) ʰp̲os 0
  active ← (v, "key_active") ʰf̲rames 0
  cols ← (ˡkeys, -3.5 -2.25 -1.0 0.25 1.5 2.75, 6 r̲eshape 2.75) ʰp̲os 0
  r ← (v, "r") ʰf̲rames 0
  rows ← (ˡkeys, 4 r̲eshape -4.75, -2.3 -1.05 0.2 1.45) ʰp̲os 0
  k ← (v, "k") ʰf̲rames 0
  qp ← (ˡkeys, 10 r̲eshape 4.6, -2.6 + 0.5 × f̲loat (r̲ange 10) − 1) ʰp̲os 0
  q ← (v, "queued") ʰf̲rames 0
  ⍝ the machine: the ROM page with the program counter's marker, the
  ⍝ page lamps, A's bits, the status, the adder, the RAM's bars
  rp ← (ˡcpu, ʰromX, ʰromZ) ʰp̲os 0
  pc ← (v, "pc") ʰf̲rames 0
  pa ← (v, "pa") ʰf̲rames 0
  pp ← (ˡcpu, -5.6 + 0.29 × f̲loat (r̲ange 16) − 1, 16 r̲eshape 3.55) ʰp̲os 0
  ap ← (ˡcpu, 2.8 2.2 1.6 1.0, 4 r̲eshape 2.7) ʰp̲os 0
  kind ← ʰˣk̲ind (1 + pc + 64 × pa) s̲elect ʰˣCalcRom
  ram ← (v, n) ʰr̲am 0
  bars ← (ˡcpu, ʰramX, ʰramFloor) ʰp̲os 0
  file ← f̲loor ʰword ÷ 16.0
  hs ← 0.06 + 0.055 × f̲loat ram
  first ← 1 s̲elect hs
  steps ← (hs, ts) ʰs̲tepRows 0
  o ← 1 s̲elect₂ steps
  i ← f̲loor o
  ns ← t̲ally o
  hv ← 3 s̲elect₂ steps
  ⍝ the labels of the machine's parts
  at ← (((6 3 r̲eshape ˡcpu) + 6 3 r̲eshape -3.43 0.0 -2.15  0.3 0.0 2.7  4.0 0.0 2.7  0.6 0.0 1.5  0.3 0.0 -1.8  -3.43 0.0 3.95) c̲at₂
    (6 1 r̲eshape 0.4 0.5 0.5 0.45 0.45 0.3) c̲at₂ 6 3 r̲eshape 200 205 230)
  ⍝ the display: a calculator, its eight digits' segments lit from the
  ⍝ digit latches, the browser's screen under it
  body ← ((2 3 r̲eshape ˡdisplay) + 2 3 r̲eshape 0.0 0.1 2.0  0.0 -0.22 2.0) c̲at₂ 2 7 r̲eshape 10.5 0.6 3.0 40 44 56 1.0  9.6 0.05 2.0 16 28 16 1.0
  sx ← 3.85 − (1.1 × ʰsegP) − ʰsegDx
  sp ← (ˡdisplay, sx, 2.0 + ʰsegDz) ʰp̲os 0
  flat ← f̲loat ʰsegFlat
  shown ← (v, "shown") ʰf̲rames 0
  dg ← (shown 'd̲iv t̲able 32 ^ f̲loor ʰsegP) m̲od 32
  on ← (dg ≥ 16) × ((((1 + dg m̲od 16) s̲elect ˡsegments) d̲iv (n c̲at 56) r̲eshape 2 ^ f̲loor ʰsegS) m̲od 2)
  pt ← ("browser", picture, (ˡdisplay + 0.0 0.0 -2.3) c̲at 7.0) ᵛᵈp̲icture 0
  t ← ((ᵛᵈhead c̲at ((w, h, 30, ˡlength, ʰsky, 35) ᵛᵈs̲tage 0)) c̲at
    (("areas", "serial line|key matrix|HEX1000|display", names) ᵛᵈl̲abels 0) c̲at
    (("wires", 3 10 r̲eshape -0.6 0.3 4.5 0.6 0.3 4.5 90 100 140 0.06  7.0 0.3 -0.3 7.0 0.3 -0.7 90 100 140 0.06  0.6 0.3 -5.5 -0.6 0.3 -5.5 90 100 140 0.06) ᵛᵈl̲ines 0) c̲at
    (("line", ʰb̲oxes ((ˡuart, 1 r̲eshape -0.4, 1 r̲eshape 3.45) ʰp̲os 0, 8.6 0.2 0.16, 47 183 214, 1.0)) ᵛᵈb̲oxes 0) c̲at
    (("line", "glow", (rx, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("bit page", ʰb̲oxes (p, 0.74 0.24 0.54, 70 76 96, 1.0)) ᵛᵈo̲utlines 0) c̲at
    (("bits", p c̲at₂ ((nb c̲at 3) r̲eshape 0.7 0.2 0.5) c̲at₂ rgb c̲at₂ (nb c̲at 1) r̲eshape 0.0) ᵛᵈb̲oxes 0) c̲at
    (("bits", 2 1 t̲ranspose (3 c̲at nb) r̲eshape (nb r̲eshape 0.0) c̲at (arrive − 1.0 ÷ 30.0) c̲at arrive, 2 1 t̲ranspose (3 c̲at nb) r̲eshape (nb r̲eshape 0.0) c̲at (nb r̲eshape 0.0) c̲at lit) ᵛᵈg̲lows 0) c̲at
    (("bytes", ʰb̲ars ⎕U̲CHAR bytes, ((ˡuart, nc r̲eshape 4.6, 2.6 − 0.62 × f̲loat (r̲ange nc) − 1) ʰp̲os 0) c̲at₂ (nc c̲at 4) r̲eshape 0.6 255 255 255) ᵛᵈl̲abels 0) c̲at
    (("bytes", 2 1 t̲ranspose (2 c̲at nc) r̲eshape (ʰv̲ideo got) c̲at nc r̲eshape ˡlength) ᵛᵈs̲hown 0) c̲at
    (("keys", ʰb̲oxes (kp, 1.0 0.3 1.0, 64 72 104, 1.0)) ᵛᵈb̲oxes 0) c̲at
    (("key names", ˡkeyNames, (kp + (21 3 r̲eshape 0.0 -0.35 0.0)) c̲at₂ (21 4 r̲eshape 0.55 255 255 255)) ᵛᵈl̲abels 0) c̲at
    (("held", ʰb̲oxes (1 3 r̲eshape kp, 1.25 0.45 1.25, 255 122 61, 0.0)) ᵛᵈo̲utlines 0) c̲at
    (("held", "glow", ((n c̲at 1) r̲eshape 3.0 × f̲loat active, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("held", "location", (((n c̲at 1) r̲eshape (v, "key_code") ʰf̲rames 0, ts) ʰs̲tepRows 0, kp) ʰp̲laceRows 0) ᵛᵈs̲teps 0) c̲at
    (("columns", ʰb̲oxes (cols, 0.9 0.2 0.25, 120 230 120, 0.1)) ᵛᵈb̲oxes 0) c̲at
    (("columns", "glow", (0.1 + 2.4 × f̲loat (r 'd̲iv t̲able 256 512 1024 2048 4096 8192) m̲od 2, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("rows", ʰb̲oxes (rows, 0.25 0.2 0.9, 47 183 214, 0.1)) ᵛᵈb̲oxes 0) c̲at
    (("rows", "glow", (0.1 + 2.4 × f̲loat (k 'd̲iv t̲able 1 2 4 8) m̲od 2, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("queue", ʰb̲oxes (qp, 0.6 0.2 0.35, 255 122 61, 0.08)) ᵛᵈb̲oxes 0) c̲at
    (("queue", "glow", (0.08 + 1.9 × f̲loat 0 m̲ax 1 m̲in 1 + q '− t̲able r̲ange 10, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("rom page", ʰb̲oxes (rp, 0.5 0.2 0.5, 70 76 96, 1.0)) ᵛᵈo̲utlines 0) c̲at
    (("pc", ʰb̲oxes (1 3 r̲eshape rp, 0.42 0.25 0.42, 240 240 255, 2.0)) ᵛᵈb̲oxes 0) c̲at
    (("pc", "location", (((n c̲at 1) r̲eshape pc, ts) ʰs̲tepRows 0, rp + 64 3 r̲eshape 0.0 -0.05 0.0) ʰp̲laceRows 0) ᵛᵈs̲teps 0) c̲at
    (("pages", ʰb̲oxes (pp, 0.22 0.2 0.22, 255 216 77, 0.1)) ᵛᵈb̲oxes 0) c̲at
    (("pages", "glow", (0.1 + 2.4 × f̲loat 0 m̲ax 1 − a̲bs pa '− t̲able (r̲ange 16) − 1, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("a", ʰb̲oxes (ap, 0.45 0.2 0.45, 47 183 214, 0.1)) ᵛᵈb̲oxes 0) c̲at
    (("a", "glow", (0.1 + 2.4 × f̲loat (((v, "a") ʰf̲rames 0) 'd̲iv t̲able 1 2 4 8) m̲od 2, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("s", ʰb̲oxes ((ˡcpu, 1 r̲eshape 4.6, 1 r̲eshape 2.7) ʰp̲os 0, 0.45 0.2 0.45, 255 122 61, 0.1)) ᵛᵈb̲oxes 0) c̲at
    (("s", "glow", ((n c̲at 1) r̲eshape 0.1 + 2.4 × f̲loat (v, "s") ʰf̲rames 0, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("alu", ʰb̲oxes ((ˡcpu, 1 r̲eshape 2.6, 1 r̲eshape 1.5) ʰp̲os 0, 2.4 0.3 0.6, 255 216 77, 0.1)) ᵛᵈb̲oxes 0) c̲at
    (("alu", "glow", ((n c̲at 1) r̲eshape 0.1 + 2.4 × f̲loat kind m̲ember? ʰaluKinds, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    (("ram", (bars + 2 1 t̲ranspose (3 c̲at 64) r̲eshape (128 r̲eshape 0.0) c̲at 0.5 × first) c̲at₂ ((64 c̲at 2) r̲eshape 0.18 0.2) c̲at₂ (first c̲at₂ (file, 0.0, 3.0) ᵛᵈt̲one 0) c̲at₂ (64 c̲at 1) r̲eshape 1.0) ᵛᵈb̲oxes 0) c̲at
    (("ram", "location", 2 1 t̲ranspose (5 c̲at ns) r̲eshape o c̲at (2 s̲elect₂ steps) c̲at (i s̲elect 1 s̲elect₂ bars) c̲at (ns r̲eshape 2 s̲elect ˡcpu) c̲at (i s̲elect 3 s̲elect₂ bars) + 0.5 × hv) ᵛᵈs̲teps 0) c̲at
    (("ram", "scale", 2 1 t̲ranspose (5 c̲at ns) r̲eshape o c̲at (2 s̲elect₂ steps) c̲at (ns r̲eshape 0.18) c̲at (ns r̲eshape 0.2) c̲at hv) ᵛᵈs̲teps 0) c̲at
    (("parts", "ROM page|A|S|ALU|RAM|pages", at) ᵛᵈl̲abels 0) c̲at
    (("calculator", body) ᵛᵈb̲oxes 0) c̲at
    (("segments", (sp + 56 3 r̲eshape 0.0 -0.3 0.0) c̲at₂ (2 1 t̲ranspose (3 c̲at 56) r̲eshape (0.12 + 0.38 × flat) c̲at (56 r̲eshape 0.06) c̲at 0.5 − 0.38 × flat) c̲at₂ (56 4 r̲eshape 156 245 154 0.03)) ᵛᵈb̲oxes 0) c̲at
    (("segments", "glow", (0.03 + 2.97 × f̲loat on, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at
    ((0 < t̲ally picture) × t̲ally pt) t̲ake pt)
  ⍝ in front of the camera: the clock count, and the instruction while
  ⍝ slow
  cy ← (v, "cycle") ʰf̲rames 0
  ch ← 1 c̲at n̲ot (1 d̲rop cy) = -1 d̲rop cy
  clockAt ← (ch ∧ ts ≥ 3.4) r̲eplicate ts
  clockTexts ← '{ "clock " c̲at f̲ormat ⍵ } m̲ap (ch ∧ ts ≥ 3.4) r̲eplicate cy
  withClock ← t c̲at ("clock", -0.7 0.84 0.09 255 255 255, d̲isclose '{ a b → e̲nclose (d̲isclose a) c̲at "|" c̲at d̲isclose b } r̲/ clockTexts, clockAt) ᵛᵈr̲eadout 0
  slow ← ((ts ≥ 10.4) ∧ ts < 16.4) ∨ (ts ≥ 25.4) ∧ ts < 35.4
  ⍝ NOP (code 0) is blank, as is everything while fast
  blank ← (e̲nclose " ") c̲at 1 d̲rop ʰˣNames
  slowNames ← '{ d̲isclose (1 + ⍵) s̲elect blank } m̲ap kind × slow
  ⍝ the camera, the title card, the captions
  ⍝ close up, the camera looks a little low, the area above the captions
  dist ← (f̲loat ʰcamWide) × dw − d
  aims ← ʰcamAims + 2 1 t̲ranspose (3 c̲at 10) r̲eshape (20 r̲eshape 0.0) c̲at -1.5 × 1.0 − f̲loat ʰcamWide
  eyes ← aims + 2 1 t̲ranspose (3 c̲at 10) r̲eshape (ʰcamSide × dist + d) c̲at (n̲eg dist + d) c̲at 0.08 × dist + d
  ((withClock c̲at ("instruction", 0.7 0.84 0.09 255 216 77, d̲isclose '{ a b → e̲nclose (d̲isclose a) c̲at "|" c̲at d̲isclose b } r̲/ slowNames, ts) ᵛᵈr̲eadout 0) c̲at
    ((ʰcamTimes, eyes, aims) ᵛᵈc̲amera 0) c̲at
    ((ˡtitle, ˡsubtitle, ʰcardTable) ᵛᵈc̲ards 0) c̲at (ˡc̲aptions v, ˡcaptionTable) ᵛᵈc̲aptions 0)
}
Used in: _

ʰr̲am : Num a => ((Box Char, Int), Int) -> a -> Int

function (private) · line 401
ʰr̲am ← { (v, n) z →
  all ← d̲isclose '{ a b → e̲nclose (d̲isclose a) c̲at d̲isclose b } r̲/ '{ (v, "ram" c̲at f̲ormat ⍵) ʰf̲rames 0 } m̲ap (r̲ange 16) − 1
  m ← r̲avel 2 1 t̲ranspose (16 c̲at n) r̲eshape all
  w ← (r̲ange 64) − 1
  i ← (16 × (r̲ange n) − 1) '+ t̲able w d̲iv 4
  (((1 + i) s̲elect m) d̲iv (n c̲at 64) r̲eshape 16 ^ w m̲od 4) m̲od 16
}
Used in: ˡs̲cene