sourceextensions/blender/demos/HexRun.xtl

1⍝│ HexRun.xtl -- HEX1000-UART computing C0DE+BEEF=, a video made with the 2⍝│ explainer kit (Video.xtl) from a simulation of its board: the text 3⍝│ sent over the serial line bit by bit, the board queuing each key, the 4⍝│ machine scanning its key matrix, its program counter hopping through 5⍝│ a ROM page, A, the status, the ALU and the RAM changing, and the 6⍝│ digits strobed out to a calculator's display. Everything moving is a 7⍝│ signal of the simulation's waveform (scripts/hex1000-sim.sh: the 8⍝│ board's Verilog from X_eTaL-fpga at FPGA_COMMIT under iverilog; Vcd.xtl 9⍝│ reads it), sampled once a frame; X_eTaL-fpga's Hex1000.xtl replays 10⍝│ the same clocks from the K inputs the circuit saw and must agree with 11⍝│ its registers at every one, and the display it ends with must be the 12⍝│ evaluator's (hx:c_alc) -- else no script is written. Beside the 13⍝│ calculator at the end, the browser calculator's screen 14⍝│ (scripts/hex1000-browser.py). Shared by the demo (demos/hex-run.xtl) 15⍝│ and its test. 16⍝│ Import: "hr:" u_se< "HexRun" 17 18"hx:" u̲se< "Hex1000" 19"vc:" u̲se< "Vcd" 20"vd:" u̲se< "Video" 21"s:" u̲se< "Strings" 22 23⍝━━ The run 24 25⍝│ text: what is typed at the board, over its serial line 26ˡtext ← "C0DE+BEEF=" 27 28⍝│ bit: the serial line's bit time in the simulation (ps; 115200 baud) 29ˡbit ← 8680000 30 31⍝ a signal of the waveform at times (ps) 32ʰa̲t ← { (v, name, ts) z → (v, name, ts) ᵛᶜa̲t 0 } 33 34⍝ a time in ps as microseconds 35ʰu̲s ← { ps → (f̲loat ps) ÷ 1000000.0 } 36 37⍝│ hr:c_locks v: when the waveform v's count of machine clocks became 38⍝│ each value, 0 (reset) 1 2 ... (ps): a state is the circuit's after 39⍝│ that many instructions 40ˡc̲locks ← { v → 1 s̲elect₂ (v, "cycle") ᵛᶜc̲hanges 0 } 41 42⍝│ hr:l_ine v: the serial line decoded from the waveform: (starts, bits) 43⍝│ -- when each character's start bit began (ps; the testbench sends 44⍝│ them back to back) and its ten bits as the line had them at their 45⍝│ middles, a row a character: start (0), the data bits from the lowest, 46⍝│ stop (1) 47ˡl̲ine ← { v → 48 c ← (v, "uart_rx") ᵛᶜc̲hanges 0 49 first ← f̲irst ((0 = 2 s̲elect₂ c) ∧ 0 < 1 s̲elect₂ c) r̲eplicate 1 s̲elect₂ c 50 n ← t̲ally ˡtext 51 starts ← first + 10 × ˡbit × (r̲ange n) − 1 52 ts ← (n c̲at 10) r̲eshape r̲avel starts 'l̲eft t̲able 0 1 2 3 4 5 6 7 8 9 53 at ← ts + (ˡbit d̲iv 2) + ˡbit × (n c̲at 10) r̲eshape 0 1 2 3 4 5 6 7 8 9 54 (starts, (n c̲at 10) r̲eshape (v, "uart_rx", r̲avel at) ʰa̲t 0) 55} 56 57⍝│ hr:r_eceived v: the bytes the board's UART core handed on, (times, 58⍝│ bytes): when its valid flag rose (ps), and the byte 59ˡr̲eceived ← { v → 60 c ← (v, "valid") ᵛᶜc̲hanges 0 61 ts ← (1 = 2 s̲elect₂ c) r̲eplicate 1 s̲elect₂ c 62 (ts, (v, "rxb", ts) ʰa̲t 0) 63} 64 65⍝│ the seven segments a b c d e f g of each hexadecimal digit, a bit 66⍝│ each from the lowest 67⍝│ >> "hr:" u_se< "HexRun" 68⍝│ >> 4 t_ake hr:segments 69⍝│ 63 6 91 79 70ˡsegments ← 63 6 91 79 102 109 125 7 127 111 119 124 57 94 121 113 71 72⍝│ hr:s_creen shown: the display's eight digit latches (5 bits each, 73⍝│ digit 0 the lowest: a digit shown when its bit 4 is set) as the text 74⍝│ a terminal shows, digit 7 first, blank where not shown 75⍝│ >> "hr:" u_se< "HexRun" 76⍝│ >> hr:s_creen 18612125 77⍝│ 17FCD 78ˡs̲creen ← { d → 79 ds ← (8 r̲eshape 32) e̲ncode d 80 (1 + (ds ≥ 16) × 1 + ds m̲od 16) s̲elect " 0123456789ABCDEF" 81} 82 83⍝│ hr:c_heck (v, browser): the checks a video is made after, as lines of 84⍝│ text, or a panic naming the one that failed: the line carries the 85⍝│ text, the board's UART receives it, Hex1000.xtl replaying the clocks 86⍝│ from the K inputs the circuit saw has its A, S, PC and PA at every 87⍝│ one, and the display at the end is the evaluator's (hx:c_alc) and 88⍝│ the browser's (its screen's text; "" skips that check) 89ˡc̲heck ← { (v, browser) z → 90 (starts, bits) ← ˡl̲ine v 91 codes ← ⎕U̲CS ˡtext 92 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 93 n̲ot ok1 ? ⎕P̲ANIC "hex-run: the serial line does not carry " c̲at ˡtext 94 (ts, bytes) ← ˡr̲eceived v 95 n̲ot codes m̲atch bytes ? ⎕P̲ANIC "hex-run: the board received " c̲at ⎕U̲CHAR bytes 96 t ← ˡc̲locks v 97 n ← t̲ally t 98 mid ← t + 518000 99 ks ← (v, "k", mid) ʰa̲t 0 100 rom ← ʰˣCalcRom 101 (last, i, rows) ← (n − 1) '{ (st, i, m) → s1 ← (rom ʰˣs̲tep st) i s̲elect ks 102 (s1, i + 1, m c̲at 1 4 5 6 s̲elect ʰˣr̲egs s1) } p̲ower (ʰˣReset, 1, 0 r̲eshape 0) 103 m ← ((n − 1) c̲at 4) r̲eshape rows 104 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 105 bad ← '+ r̲/ r̲avel n̲ot m = vcd 106 bad > 0 ? ⎕P̲ANIC "hex-run: Hex1000.xtl and the circuit differ at " c̲at (f̲ormat bad) c̲at " register values" 107 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 108 want ← ʰˣc̲alc ˡtext 109 n̲ot want m̲atch shown ? ⎕P̲ANIC "hex-run: the display ends " c̲at shown c̲at ", the evaluator's " c̲at want 110 inb ← ("| " c̲at want c̲at " |") ˢi̲nfix? browser 111 ((t̲ally browser) > 0) ∧ n̲ot inb ? ⎕P̲ANIC "hex-run: the browser's screen is not " c̲at want 112 also ← "\nthe browser calculator shows it too" 113 b ← (((t̲ally browser) > 0) × t̲ally also) t̲ake also 114 "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 115} 116 117⍝━━ Time 118 119⍝│ map: the simulation's microseconds as the video's seconds 120⍝│ (vd:r_etime): a title card; the first character's ten bits in slow 121⍝│ motion; the machine finding that key, slower still; the other nine 122⍝│ keys a time-lapse; one addition in slow motion; then the display 123ˡ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 124 125⍝│ length: the video's seconds 126ˡlength ← 42.0 127 128⍝│ frames: each frame's second in the video (30 a second) 129⍝│ >> "hr:" u_se< "HexRun" 130⍝│ >> 3 t_ake hr:frames 131⍝│ 0.0 0.03333333333333333 0.06666666666666667 132ˡframes ← ((f̲loat r̲ange 1 + f̲loor 0.5 + 30.0 × ˡlength) − 1.0) ÷ 30.0 133 134⍝│ framePs: the simulation's time at each frame (ps) 135ˡframePs ← f̲loor 1000000.0 × ((2 1 s̲elect₂ ˡmap), ˡframes) ᵛᵈr̲etime 0 136 137⍝ simulation times (ps) as the video's seconds 138ʰv̲ideo ← { ps → (ˡmap, ʰu̲s ps) ᵛᵈr̲etime 0 } 139 140⍝ a signal at every frame 141ʰf̲rames ← { (v, name) z → (v, name, ˡframePs) ᵛᶜa̲t 0 } 142 143⍝ (values, times) h:s_tepRows 0: vd:s_teps rows (object, second, value) 144⍝ for a frames by objects matrix: each object's first frame and every 145⍝ frame where its value changed, object by object 146ʰs̲tepRows ← { (g, ts) z → 147 n ← 1 s̲elect s̲hape g 148 m ← 2 s̲elect s̲hape g 149 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 150 obj ← r̲avel 2 1 t̲ranspose (n c̲at m) r̲eshape f̲loat r̲ange m 151 at ← r̲avel (m c̲at n) r̲eshape f̲loat ts 152 val ← r̲avel 2 1 t̲ranspose f̲loat g 153 k ← '+ r̲/ keep 154 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 155} 156 157⍝ (rows, places) h:p_laceRows 0: step rows whose value is a place's 158⍝ number (from 0) as location rows (object, second, x y z) 159ʰp̲laceRows ← { (rows, p) z → 160 i ← 1 + f̲loor 3 s̲elect₂ rows 161 (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 162} 163 164⍝━━ Where things are 165 166⍝│ the four areas' middles: the serial line, the key matrix, the 167⍝│ machine, the display 168ˡuart ← -7.0 0.0 4.5 169⍝│ the key matrix's 170ˡkeys ← 7.0 0.0 4.5 171⍝│ the machine's 172ˡcpu ← 7.0 0.0 -5.5 173⍝│ the display's 174ˡdisplay ← -7.0 0.0 -5.5 175 176⍝ (middle, xs, zs) h:p_os 0: places (n by 3) at xs and zs from a middle, 177⍝ in its plane 178ʰp̲os ← { (c, xs, zs) z → 179 n ← t̲ally xs 180 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 181} 182 183⍝ (places, size, rgb, strength) h:b_oxes 0: vd:b_oxes rows 184ʰb̲oxes ← { (p, size, rgb, g) → 185 n ← 1 s̲elect s̲hape p 186 p c̲at₂ (n c̲at 7) r̲eshape (f̲loat size) c̲at (f̲loat rgb) c̲at g 187} 188 189⍝ texts as one text, | between 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 "|" } 191 192⍝ the serial line: column j, row k of the bits 193ʰbitJ ← f̲loat (r̲ange 10 × t̲ally ˡtext) − 1 194ʰbitX ← -4.4 + 0.86 × ʰbitJ − 10.0 × f̲loat f̲loor ʰbitJ ÷ 10.0 195ʰbitZ ← 2.6 − 0.62 × f̲loat f̲loor ʰbitJ ÷ 10.0 196 197⍝ the keys: code c in column c / 4 (selected by R8 to R13), row c mod 4 198⍝ (its K bit), row 0 at the bottom 199ʰcodes ← f̲loat (r̲ange 21) − 1 200ʰkeyX ← -3.5 + 1.25 × f̲loat f̲loor ʰcodes ÷ 4.0 201ʰkeyZ ← -2.3 + 1.25 × ʰcodes − 4.0 × f̲loat f̲loor ʰcodes ÷ 4.0 202⍝│ keyNames: the keys' labels, by code 203ˡkeyNames ← "0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|+|-|*|=|X" 204 205⍝ the ROM page: address a at reading order, 8 a row 206ʰaddr ← f̲loat (r̲ange 64) − 1 207ʰromX ← -5.6 + 0.62 × ʰaddr − 8.0 × f̲loat f̲loor ʰaddr ÷ 8.0 208ʰromZ ← 2.9 − 0.62 × f̲loat f̲loor ʰaddr ÷ 8.0 209 210⍝ the RAM: word w of file f, a bar standing on its file's floor 211ʰword ← f̲loat (r̲ange 64) − 1 212ʰramX ← 1.0 + 0.24 × ʰword − 16.0 × f̲loat f̲loor ʰword ÷ 16.0 213ʰramFloor ← -0.2 − 1.05 × f̲loat f̲loor ʰword ÷ 16.0 214 215⍝ the display's segments: digit p (0 on the right), segment s (a to g) 216ʰseg ← f̲loat (r̲ange 56) − 1 217ʰsegP ← f̲loat f̲loor ʰseg ÷ 7.0 218ʰsegS ← ʰseg − 7.0 × ʰsegP 219ʰsegDx ← (1 + f̲loor ʰsegS) s̲elect 0.0 0.3 0.3 0.0 -0.3 -0.3 0.0 220ʰsegDz ← (1 + f̲loor ʰsegS) s̲elect 0.6 0.3 -0.3 -0.6 -0.3 0.3 0.0 221ʰsegFlat ← (1 + f̲loor ʰsegS) s̲elect 1 0 0 1 0 0 1 222 223⍝ the instructions that use the adder, by kind (hx:Names, from 0) 224ʰaluKinds ← 10 11 12 13 14 15 16 17 18 19 20 36 37 225 226⍝━━ Words 227 228⍝│ the title card's title and subtitle 229ˡtitle ← "HEX1000-UART" 230⍝│ the subtitle 231ˡsubtitle ← "C0DE+BEEF= over UART on a Tang Nano 9K, simulated clock by clock" 232 233⍝│ captionTable: each caption's from and to (video seconds), white 234ˡ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 235 236⍝ the card: from, to, the words' color, the card's 237ʰcardTable ← 1 8 r̲eshape 0.0 3.2 255 255 255 18 22 44 238 239⍝│ hr:c_aptions v: the captions, | between them, their numbers from 240⍝│ the run 241ˡc̲aptions ← { v → 242 t ← ˡc̲locks v 243 done ← f̲irst -1 t̲ake 1 s̲elect₂ (v, "shown") ᵛᶜc̲hanges 0 244 clocks ← '+ r̲/ t ≤ done 245 shown ← ˢt̲rim ˡs̲creen f̲irst (v, "shown", 1 r̲eshape done) ʰa̲t 0 246 "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" 247} 248 249⍝│ hr:c_ues v: the title card's and the captions' texts, for vd:c_ues 250⍝│ and vd:s_rt 251ˡc̲ues ← { v → ˡtitle c̲at ": " c̲at ˡsubtitle c̲at "|" c̲at ˡc̲aptions v } 252⍝│ cueTable: their from and to (video seconds) 253ˡcueTable ← (2 t̲ake₂ ʰcardTable) c̲at 2 t̲ake₂ ˡcaptionTable 254 255⍝━━ The scene 256 257⍝ the sky: near black 258ʰsky ← 8 10 18 259 260⍝ the camera: where it looks at each key (video seconds) -- the line, 261⍝ the keys, all four areas, the machine, the display -- and whether it 262⍝ stands back for all of them (1) 263ʰcamTimes ← 0.0 10.0 11.0 16.4 17.6 24.8 25.8 35.2 36.6 42.0 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 265ʰcamWide ← 0 0 0 0 1 1 0 0 0 0 266ʰcamSide ← 0.06 -0.04 0.05 -0.05 0.0 0.03 -0.05 0.05 0.04 -0.04 267 268⍝│ (size, v, picture) hr:s_cene 0: the whole script Blender runs, before 269⍝│ its stills or video: the stage at that size (vd:landscape or 270⍝│ vd:shorts); the serial line, the key matrix, the machine and the 271⍝│ display, every lamp, bar, marker and segment keyed in steps from the 272⍝│ waveform v sampled once a frame; a clock count and the instruction in 273⍝│ front of the camera; the browser's screen (a PNG; "" for none) under 274⍝│ the display; the camera, the title card, the captions 275ˡs̲cene ← { (size, v, picture) z → 276 w ← 1 s̲elect size 277 h ← 2 s̲elect size 278 d ← (w, h, 35, 14.0, 13.0) ᵛᵈf̲it 0 279 dw ← (w, h, 35, 28.5, 21.0) ᵛᵈf̲it 0 280 n ← t̲ally ˡframes 281 ts ← ˡframes 282 ⍝ the stage, the areas' names, the wires between them 283 middles ← 4 3 r̲eshape ˡuart c̲at ˡkeys c̲at ˡcpu c̲at ˡdisplay 284 names ← (middles + 4 3 r̲eshape 0.0 0.0 4.2) c̲at₂ 4 4 r̲eshape 0.6 200 205 230 285 ⍝ the serial line: the line itself, high bright and low dark, and each 286 ⍝ bit lit as it arrives, a 1 bright and a 0 dim; the bytes received 287 (starts, bits) ← ˡl̲ine v 288 nb ← 10 × t̲ally ˡtext 289 rx ← (n c̲at 1) r̲eshape 0.15 + 2.35 × f̲loat (v, "uart_rx") ʰf̲rames 0 290 p ← (ˡuart, ʰbitX, ʰbitZ) ʰp̲os 0 291 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 292 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 293 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 294 lit ← 0.3 + 1.9 × f̲loat r̲avel bits 295 (got, bytes) ← ˡr̲eceived v 296 nc ← t̲ally bytes 297 ⍝ the key matrix: the keys, the held one framed, the columns R8 to R13 298 ⍝ and the rows K as lamps, the board's queue 299 kp ← (ˡkeys, ʰkeyX, ʰkeyZ) ʰp̲os 0 300 active ← (v, "key_active") ʰf̲rames 0 301 cols ← (ˡkeys, -3.5 -2.25 -1.0 0.25 1.5 2.75, 6 r̲eshape 2.75) ʰp̲os 0 302 r ← (v, "r") ʰf̲rames 0 303 rows ← (ˡkeys, 4 r̲eshape -4.75, -2.3 -1.05 0.2 1.45) ʰp̲os 0 304 k ← (v, "k") ʰf̲rames 0 305 qp ← (ˡkeys, 10 r̲eshape 4.6, -2.6 + 0.5 × f̲loat (r̲ange 10) − 1) ʰp̲os 0 306 q ← (v, "queued") ʰf̲rames 0 307 ⍝ the machine: the ROM page with the program counter's marker, the 308 ⍝ page lamps, A's bits, the status, the adder, the RAM's bars 309 rp ← (ˡcpu, ʰromX, ʰromZ) ʰp̲os 0 310 pc ← (v, "pc") ʰf̲rames 0 311 pa ← (v, "pa") ʰf̲rames 0 312 pp ← (ˡcpu, -5.6 + 0.29 × f̲loat (r̲ange 16) − 1, 16 r̲eshape 3.55) ʰp̲os 0 313 ap ← (ˡcpu, 2.8 2.2 1.6 1.0, 4 r̲eshape 2.7) ʰp̲os 0 314 kind ← ʰˣk̲ind (1 + pc + 64 × pa) s̲elect ʰˣCalcRom 315 ram ← (v, n) ʰr̲am 0 316 bars ← (ˡcpu, ʰramX, ʰramFloor) ʰp̲os 0 317 file ← f̲loor ʰword ÷ 16.0 318 hs ← 0.06 + 0.055 × f̲loat ram 319 first ← 1 s̲elect hs 320 steps ← (hs, ts) ʰs̲tepRows 0 321 o ← 1 s̲elect₂ steps 322 i ← f̲loor o 323 ns ← t̲ally o 324 hv ← 3 s̲elect₂ steps 325 ⍝ the labels of the machine's parts 326 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₂ 327 (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) 328 ⍝ the display: a calculator, its eight digits' segments lit from the 329 ⍝ digit latches, the browser's screen under it 330 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 331 sx ← 3.85 − (1.1 × ʰsegP) − ʰsegDx 332 sp ← (ˡdisplay, sx, 2.0 + ʰsegDz) ʰp̲os 0 333 flat ← f̲loat ʰsegFlat 334 shown ← (v, "shown") ʰf̲rames 0 335 dg ← (shown 'd̲iv t̲able 32 ^ f̲loor ʰsegP) m̲od 32 336 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) 337 pt ← ("browser", picture, (ˡdisplay + 0.0 0.0 -2.3) c̲at 7.0) ᵛᵈp̲icture 0 338 t ← ((ᵛᵈhead c̲at ((w, h, 30, ˡlength, ʰsky, 35) ᵛᵈs̲tage 0)) c̲at 339 (("areas", "serial line|key matrix|HEX1000|display", names) ᵛᵈl̲abels 0) c̲at 340 (("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 341 (("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 342 (("line", "glow", (rx, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at 343 (("bit page", ʰb̲oxes (p, 0.74 0.24 0.54, 70 76 96, 1.0)) ᵛᵈo̲utlines 0) c̲at 344 (("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 345 (("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 346 (("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 347 (("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 348 (("keys", ʰb̲oxes (kp, 1.0 0.3 1.0, 64 72 104, 1.0)) ᵛᵈb̲oxes 0) c̲at 349 (("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 350 (("held", ʰb̲oxes (1 3 r̲eshape kp, 1.25 0.45 1.25, 255 122 61, 0.0)) ᵛᵈo̲utlines 0) c̲at 351 (("held", "glow", ((n c̲at 1) r̲eshape 3.0 × f̲loat active, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at 352 (("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 353 (("columns", ʰb̲oxes (cols, 0.9 0.2 0.25, 120 230 120, 0.1)) ᵛᵈb̲oxes 0) c̲at 354 (("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 355 (("rows", ʰb̲oxes (rows, 0.25 0.2 0.9, 47 183 214, 0.1)) ᵛᵈb̲oxes 0) c̲at 356 (("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 357 (("queue", ʰb̲oxes (qp, 0.6 0.2 0.35, 255 122 61, 0.08)) ᵛᵈb̲oxes 0) c̲at 358 (("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 359 (("rom page", ʰb̲oxes (rp, 0.5 0.2 0.5, 70 76 96, 1.0)) ᵛᵈo̲utlines 0) c̲at 360 (("pc", ʰb̲oxes (1 3 r̲eshape rp, 0.42 0.25 0.42, 240 240 255, 2.0)) ᵛᵈb̲oxes 0) c̲at 361 (("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 362 (("pages", ʰb̲oxes (pp, 0.22 0.2 0.22, 255 216 77, 0.1)) ᵛᵈb̲oxes 0) c̲at 363 (("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 364 (("a", ʰb̲oxes (ap, 0.45 0.2 0.45, 47 183 214, 0.1)) ᵛᵈb̲oxes 0) c̲at 365 (("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 366 (("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 367 (("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 368 (("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 369 (("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 370 (("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 371 (("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 372 (("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 373 (("parts", "ROM page|A|S|ALU|RAM|pages", at) ᵛᵈl̲abels 0) c̲at 374 (("calculator", body) ᵛᵈb̲oxes 0) c̲at 375 (("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 376 (("segments", "glow", (0.03 + 2.97 × f̲loat on, ts) ʰs̲tepRows 0) ᵛᵈs̲teps 0) c̲at 377 ((0 < t̲ally picture) × t̲ally pt) t̲ake pt) 378 ⍝ in front of the camera: the clock count, and the instruction while 379 ⍝ slow 380 cy ← (v, "cycle") ʰf̲rames 0 381 ch ← 1 c̲at n̲ot (1 d̲rop cy) = -1 d̲rop cy 382 clockAt ← (ch ∧ ts ≥ 3.4) r̲eplicate ts 383 clockTexts ← '{ "clock " c̲at f̲ormat ⍵ } m̲ap (ch ∧ ts ≥ 3.4) r̲eplicate cy 384 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 385 slow ← ((ts ≥ 10.4) ∧ ts < 16.4) ∨ (ts ≥ 25.4) ∧ ts < 35.4 386 ⍝ NOP (code 0) is blank, as is everything while fast 387 blank ← (e̲nclose " ") c̲at 1 d̲rop ʰˣNames 388 slowNames ← '{ d̲isclose (1 + ⍵) s̲elect blank } m̲ap kind × slow 389 ⍝ the camera, the title card, the captions 390 ⍝ close up, the camera looks a little low, the area above the captions 391 dist ← (f̲loat ʰcamWide) × dw − d 392 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 393 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 394 ((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 395 ((ʰcamTimes, eyes, aims) ᵛᵈc̲amera 0) c̲at 396 ((ˡtitle, ˡsubtitle, ʰcardTable) ᵛᵈc̲ards 0) c̲at (ˡc̲aptions v, ˡcaptionTable) ᵛᵈc̲aptions 0) 397} 398 399⍝ (v, n) h:r_am 0: the RAM's 64 words at every frame (n by 64), from 400⍝ the waveform's 16 signals of 4 words each 401ʰr̲am ← { (v, n) z → 402 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 403 m ← r̲avel 2 1 t̲ranspose (16 c̲at n) r̲eshape all 404 w ← (r̲ange 64) − 1 405 i ← (16 × (r̲ange n) − 1) '+ t̲able w d̲iv 4 406 (((1 + i) s̲elect m) d̲iv (n c̲at 64) r̲eshape 16 ^ w m̲od 4) m̲od 16 407}