1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
|
//! The gallery: every block of the design language (design/README.md, the
//! vocabulary) drawn in its states, a page at a time, under the
//! catalogue's names. The test of the catalogue is that this shows what it
//! says; `test/gallery.script` compares its pages with the pictures in
//! `test/gallery/`.
//!
//! 0 s atoms: address, value, arrow, byte, mark, plaque, pin, bracket, tag
//! 1 s rows: chain, reg (rip with the flags), slot, line, bytes, call
//! 2 s the frame at rest, `beside`: every panel, the thread (mock 9)
//! 3.6 s a step, mid-way: struck, read, projection, echo (mock 10)
//! 6 s `subject` (mock 11); 8 s `none`, with the backtrace
//! 10.8 s two loupes in depth, from rax and its node's `next` (mock 21)
//! 21 s the `blocks` lens in its two forms: sort in rings at rest (blocks
//! reached and not yet, the trail, the turns), `leave` round the
//! ring mid-way, `turn` just struck; libc's `open` in layers, folded
//! 24 s a first time: `reach` (sort's first swap) landing, `unfold` (open
//! past its syscall) making room; sort in layers; the unfold at rest
const std = @import("std");
const sk = @import("sketch");
const anim = @import("anim");
const canim = @import("canim");
const recordings = @import("recordings");
pub const background = canim.background;
pub const scene = anim.Live(frame, struct {});
const ui = canim.ui;
const rows = canim.rows;
const theme = canim.theme;
const t = theme.color.text;
const region = theme.color.region;
/// The pages of atoms and rows, drawn from a moment of the list's recording.
const Pages = struct {
rec: *canim.Recording,
moment: u64,
box: canim.Rect = .{ .x = 0, .y = 0, .w = 1920, .h = 1080 },
pub fn draw(p: *const Pages, f: *sk.Frame, at: anim.Placed) void {
const u: ui.Ui = .{ .f = f, .at = at };
// Each page 3 s: long enough to be looked at.
if (at.t < 3) atoms(u, p) else if (at.t < 6) rowsPage(u, p);
}
};
fn title(u: ui.Ui, x: f32, y: f32, name: []const u8) void {
u.text(.sans_medium, theme.size.sans.tag, x, y, name, t.primary);
}
fn note(u: ui.Ui, x: f32, y: f32, words: []const u8) void {
u.text(.sans, theme.size.sans.micro, x, y, words, t.faint);
}
fn atoms(u: ui.Ui, p: *const Pages) void {
const m = p.rec.moment(p.moment);
const regs = (m.regs(p.rec.tid) catch null).?;
const row = theme.metric.context.row;
title(u, 64, 40, "1 atoms");
// address
var y: f32 = 80;
title(u, 64, y, "address");
note(u, 200, y, "plain, lead, name, rwx; struck, read, held");
y += 12;
var x: f32 = 64;
x = u.address(x, rows.baseline(y), 0x407010, .{ .ink = ui.rgb(region.heap) }) + 40;
for ([_]u64{ 0x402470, 0x402481, 0x402495 }, 0..) |a, i| _ = u.address(x, rows.baseline(y + @as(f32, @floatFromInt(i)) * row), a, .{ .ink = ui.rgb(region.code_), .lead = ui.shared(&.{ 0x402470, 0x402495 }) });
x += 120;
x = u.address(x, rows.baseline(y), regs.rip, .{ .ink = ui.rgb(region.code_), .name = p.rec.strings.get(regs.rip) orelse "" }) + 40;
x = u.address(x, rows.baseline(y), 0x7ffff7ff0000, .{ .ink = ui.rgb(region.data), .rwx = true }) + 40;
const struck: ui.Heat = .struck;
const cell: canim.Rect = .{ .x = x, .y = y, .w = 6 * 12, .h = row };
_ = u.written(cell, struck);
_ = u.address(x, rows.baseline(y), 0x407050, .{ .ink = ui.rgb(t.bright), .face = .mono_bold });
x += 112;
u.read(.{ .x = x, .y = y, .w = 72, .h = row }, 1);
_ = u.address(x, rows.baseline(y), 0x407058, .{ .ink = ui.rgb(region.heap) });
x += 112;
_ = u.written(.{ .x = x, .y = y, .w = 72, .h = row }, .ember);
_ = u.address(x, rows.baseline(y), 0x407030, .{ .ink = ui.rgb(region.heap) });
// value
y = 196;
title(u, 64, y, "value");
note(u, 200, y, "digit, small number, large number, small negative, string, unknown; by a signature or a type: fd, bool, char");
y += 12;
x = 64;
for ([_]u64{ 4, 0x21, 0x8dea2ff80214, std.math.maxInt(u64) }) |v| x = u.value(x, rows.baseline(y), v, false, .{}) + 60;
u.text(.mono, theme.size.mono.context, x, rows.baseline(y), "\"./list\"", theme.color.string);
x += 140;
u.unknown(.{ .x = x, .y = y, .w = 24, .h = row });
x += 84;
x = u.typed(x, rows.baseline(y), 3, .{ .fd = "\"note\"" }, .{}) + 60;
x = u.typed(x, rows.baseline(y), 1, .boolean, .{}) + 60;
_ = u.typed(x, rows.baseline(y), 'A', .character, .{});
// arrow
y = 270;
title(u, 64, y, "arrow, hop");
note(u, 240, y, "points, holds, more");
y += 12;
_ = u.arrow(64, y + row / 2, .points);
_ = u.arrow(130, y + row / 2, .holds);
_ = u.arrow(196, y + row / 2, .more);
_ = u.arrow(320, y + row / 2, .points);
_ = u.address(350, rows.baseline(y), 0x407030, .{ .ink = ui.rgb(region.heap) });
// byte
y = 330;
title(u, 64, y, "byte");
note(u, 200, y, "number, pointer, text, loose, unread; pad");
y += 12;
{
var values: [16]u8 = .{ 9, 0, 0, 0, 0, 0, 0, 0, 0x30, 0x70, 0x40, 0, 0, 0, 0, 0 };
var known: [16]bool = @splat(true);
rows.bytes(u, y, 0x407050, &values, &known, &.{ .{ .first = 0, .len = 8, .kind = .number }, .{ .first = 8, .len = 8, .kind = .pointer } }, region.heap, 4, true, m);
values = .{ 0, 0, 0, 0, 0, 0, 0, 0, 0x21, 0, 0, 0, 0, 0, 0, 0 };
rows.bytes(u, y + row, 0x407060, &values, &known, &.{ .{ .first = 0, .len = 8, .kind = .unread }, .{ .first = 8, .len = 8, .kind = .loose } }, region.heap, 4, false, m);
values = .{ '.', '/', 'l', 'i', 's', 't', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
rows.bytes(u, y + 2 * row, 0x407070, &values, &known, &.{ .{ .first = 0, .len = 7, .kind = .text }, .{ .first = 7, .len = 9, .kind = .loose } }, region.heap, 4, true, m);
}
// mark, in the context and in a lens's cell
y = 442;
title(u, 64, y, "mark");
note(u, 200, y, "in the context: current, armed, struck, held, read, trail, unknown");
y += 12;
u.current(.{ .x = 64, .y = y, .w = 200, .h = row }, theme.metric.plaque.line, 0);
u.text(.mono_bold, theme.size.mono.context, 64 + 46 - 24, rows.baseline(y), "21", t.ink);
x = 300;
for ([_]ui.Heat{ .{ .arm = 1 }, struck, .ember }) |h| {
const ink = u.written(.{ .x = x, .y = y, .w = 72, .h = row }, h);
_ = u.address(x, rows.baseline(y), 0x407070, .{ .ink = if (ink) |i| i.ink else ui.rgb(region.heap), .face = if (ink) |i| i.face else .mono });
x += 120;
}
u.read(.{ .x = x, .y = y, .w = 72, .h = row }, 1);
_ = u.address(x, rows.baseline(y), 0x407098, .{ .ink = ui.rgb(region.heap) });
x += 120;
for (0..3) |k| u.trail(x + @as(f32, @floatFromInt(k)) * 16, y, k);
x += 70;
u.unknown(.{ .x = x, .y = y, .w = 24, .h = row });
y += 40;
note(u, 64, y, "in a lens's cell: armed, struck, held, read, allocated, freed, fault, attention, kernel");
y += 12;
x = 64;
const cell_size = [2]f32{ 72, 44 };
for ([_]ui.Heat{ .{ .arm = 1 }, struck, .ember }, [_][]const u8{ "4", "9", "16" }) |h, digits| {
const r: canim.Rect = .{ .x = x, .y = y, .w = cell_size[0], .h = cell_size[1] };
const ink = u.cellWritten(r, h, theme.color.raised);
u.label(ink.face, theme.size.mono.small, r, .center, digits, ink.ink);
x += 100;
}
{
const r: canim.Rect = .{ .x = x, .y = y, .w = cell_size[0], .h = cell_size[1] };
u.fill(r, theme.color.raised);
u.cellRead(r, 1);
u.label(.mono, theme.size.mono.small, r, .center, "25", t.primary);
x += 100;
const a: canim.Rect = .{ .x = x, .y = y, .w = cell_size[0], .h = cell_size[1] };
u.fill(a, theme.mark(.allocated).ember);
u.frame(a, theme.mark(.allocated).solid, theme.stroke.line);
x += 100;
u.dashedFrame(.{ .x = x, .y = y, .w = cell_size[0], .h = cell_size[1] }, theme.mark(.freed).solid, theme.stroke.line);
x += 100;
const fault: canim.Rect = .{ .x = x, .y = y, .w = 120, .h = cell_size[1] };
u.fill(fault, theme.mark(.fault).solid);
u.fill(.{ .x = fault.x + 8, .y = fault.y + 8, .w = fault.w - 16, .h = fault.h - 16 }, t.ink);
u.label(.mono_bold, theme.size.mono.context, fault, .center, "SIGSEGV", t.bright);
x += 148;
u.frame(.{ .x = x, .y = y, .w = cell_size[0], .h = cell_size[1] }, theme.mark(.attention).solid, theme.stroke.line);
x += 100;
const k: canim.Rect = .{ .x = x, .y = y, .w = 120, .h = cell_size[1] };
u.fill(k, theme.color.kernel);
u.label(.mono_bold, theme.size.mono.context, k, .center, "read", theme.color.on_kernel.ink);
}
// plaque, pin, bracket
y = 624;
title(u, 64, y, "plaque");
note(u, 200, y, "gold: rip 54, a line 50, the pc 24; chip");
y += 12;
u.fill(.{ .x = 64, .y = y, .w = theme.metric.plaque.rip, .h = row }, theme.mark(.current).solid);
u.text(.mono_bold, theme.size.mono.context, 74, rows.baseline(y), "rip", t.ink);
u.fill(.{ .x = 140, .y = y, .w = theme.metric.plaque.line, .h = row }, theme.mark(.current).solid);
u.text(.mono_bold, theme.size.mono.context, 140 + 46 - 24, rows.baseline(y), "21", t.ink);
u.fill(.{ .x = 212, .y = y, .w = theme.metric.plaque.pc, .h = row }, theme.mark(.current).solid);
sk.draw.polygon(u.f, &.{ .{ 230, y + 12 }, .{ 220, y + 6 }, .{ 220, y + 18 } }, u.at.pen(.{ .fill = ui.rgb(t.ink) }));
u.chip(.{ .x = 260, .y = y + 2, .w = 32, .h = 20 });
u.text(.mono_bold, theme.size.mono.context, 264, rows.baseline(y), "PF", t.bright);
y = 698;
title(u, 64, y, "pin");
note(u, 140, y, "row, end; under; a count after three names");
y += 12;
u.pinRow(64, y, &.{ "rsp", "rbp" }, region.stack);
// At a view's row's end (a dump has no lane before its addresses).
_ = u.pinEnd(440, y, &.{"rsi"}, region.stack);
u.pinRow(64, y + row, &.{ "rax", "rdi", "rsi", "r8" }, region.heap);
// Clear of the note over it.
u.fill(.{ .x = 520, .y = y - 20, .w = 116, .h = 20 }, theme.color.raised);
u.pinUnder(578, y, &.{ "rax", "rdi" }, region.heap, theme.size.mono.context);
y = 698;
title(u, 700, y, "bracket");
note(u, 800, y, "quiet, tie, thread");
y += 12;
u.bracket(712, y, y + 2 * row, ui.mix(region.heap, theme.color.page, 0.6), theme.metric.bracket.quiet, 1, false);
u.bracket(762, y, y + 2 * row, theme.mark(.read).solid, theme.metric.bracket.tie, 1, false);
u.bracket(812, y, y + 2 * row, theme.mark(.current).solid, theme.metric.bracket.thread, 1, false);
// tag
y = 800;
title(u, 64, y, "tag");
note(u, 120, y, "focus; a note; a legend");
y += 12;
_ = (u.moved(64, y)).panel(560, 56, "the list", .{ .focus = true, .note = "a note, ranged right" });
_ = (u.moved(660, y)).panel(880, 56, "registers", .{ .legend = &canim.contextLegend });
}
fn rowsPage(u: ui.Ui, p: *const Pages) void {
const m = p.rec.moment(p.moment);
const regs = (m.regs(p.rec.tid) catch null).?;
const row = theme.metric.context.row;
title(u, 64, 40, "2 rows");
var y: f32 = 80;
title(u, 64, y, "chain");
note(u, 160, y, "as far as it points; cut where its room ends: a string first, then `more`");
y += 12;
_ = rows.chain(u, 64, y, m, regs.rbp, 880, .{});
_ = rows.chain(u, 64, y + row, m, regs.rbp, 420, .{});
_ = rows.chain(u, 64, y + 2 * row, m, regs.r12, 880, .{});
_ = rows.chain(u, 64, y + 3 * row, m, regs.r12, 320, .{});
y = 214;
title(u, 64, y, "reg");
note(u, 140, y, "plain, struck, held, read; rip with the flags");
y += 12;
var panel = u.moved(64, y);
_ = rows.reg(panel, 0, 880, "rsi", m, regs.rsi, .{});
_ = rows.reg(panel, row, 880, "rdi", m, regs.rdi, .{ .first = .struck });
_ = rows.reg(panel, 2 * row, 880, "rax", m, regs.rax, .{ .first = .ember });
_ = rows.reg(panel, 3 * row, 880, "rbp", m, regs.rbp, .{ .read = 1, .read_shows = 1 });
rows.rip(panel, 4 * row, 880, m, regs.rip, regs.eflags, 1 << 6, 1, 0, 1 << 6, 1, null);
y = 380;
title(u, 64, y, "slot");
note(u, 140, y, "its pins in the lane; the offset from rsp; the address from 184 and its chain; a role; `call` spans at the right");
y += 12;
panel = u.moved(64, y);
for (0..4) |i| {
const addr = regs.rsp + 8 * i;
_ = rows.slot(panel, @as(f32, @floatFromInt(i)) * row, 880, m, addr, @intCast(8 * i), if (i == 0) &.{ "rsp", "rbp" } else &.{}, 1, .{ .lead = ui.shared(&.{ regs.rsp, regs.rsp + 24 }), .first = if (i == 2) .ember else .none }, if (i == 0) "saved rbp" else if (i == 1) "cur" else "", i == 1, null);
}
rows.span(panel, 880, 0, 2 * row, "reverse", true, false);
rows.span(panel, 880, 2 * row, 4 * row, "main", false, true);
y = 520;
title(u, 64, y, "call");
note(u, 140, y, "row, in a backtrace");
y += 12;
panel = u.moved(64, y);
rows.callRow(panel, 0, 880, 0, "reverse+225", "", "list.c:22", true);
rows.callRow(panel, row, 880, 1, "main+42", "", "list.c:40", false);
y = 600;
title(u, 64, y, "line");
note(u, 140, y, "current, trail, plain; cut at 67 characters");
y += 12;
panel = u.moved(64, y);
const plain = " cur->next = prev;";
const styles: [128]u8 = @splat(0);
rows.line(panel, 0, 880, 22, 0, plain, styles[0..plain.len], .{ .current = 0 });
rows.line(panel, row, 880, 21, 0, " node *next = cur->next;", styles[0..31], .{ .trail = 0 });
rows.line(panel, 2 * row, 880, 20, 0, " while (cur) {", styles[0..17], .{ .trail = 1 });
const long = " a line of source longer than the panel has room for, which is cut at its end";
rows.line(panel, 3 * row, 880, 9, 0, long, styles[0..long.len], .plain);
y = 860;
title(u, 64, y, "insn");
note(u, 140, y, "operands without size words; a width where no register says it; padding faint");
y += 12;
panel = u.moved(64, y);
const Insn = canim.Disasm.Row;
for ([_]Insn{
.{ .addr = 0x100191b, .len = 5, .text = "nop dword ptr [rax + rax]" },
.{ .addr = 0x100192a, .len = 4, .text = "mov qword ptr [rax + 8], rcx" },
.{ .addr = 0x7ffff7d10f0e, .len = 7, .text = "cmp byte ptr [rip + 0x11018b], 0" },
.{ .addr = 0x7ffff7d10f94, .len = 7, .text = "mov dword ptr [rbp - 0x60], 0x10" },
.{ .addr = 0x7ffff7d10f9b, .len = 4, .text = "movsxd r10, dword ptr [rbp - 0x30]" },
}, 0..) |one, i| canim.disasm.plainRow(panel, one, @as(f32, @floatFromInt(i)) * row);
y = 750;
title(u, 64, y, "bytes");
note(u, 160, y, "runs from the types; marks per run: struck, read, held; read as their types: a char, a bool, an int, a pointer");
y += 12;
panel = u.moved(976, y);
var values: [16]u8 = .{ 12, 0, 0, 0, 0, 0, 0, 0, 0x10, 0x70, 0x40, 0, 0, 0, 0, 0 };
var known: [16]bool = @splat(true);
rows.bytes(panel, 0, 0x407030, &values, &known, &.{ .{ .first = 0, .len = 8, .kind = .number, .read = 1 }, .{ .first = 8, .len = 8, .kind = .pointer, .heat = .struck } }, region.heap, 4, true, m);
values[8] = 0x50;
rows.bytes(panel, row, 0x407050, &values, &known, &.{ .{ .first = 0, .len = 8, .kind = .number }, .{ .first = 8, .len = 8, .kind = .pointer, .heat = .ember } }, region.heap, 4, true, m);
known = @splat(false);
rows.bytes(panel, 2 * row, 0x407060, &values, &known, &.{ .{ .first = 0, .len = 8, .kind = .unread }, .{ .first = 8, .len = 8, .kind = .unread } }, region.heap, 4, false, m);
// A struct of a char, a bool, padding, an int and a pointer: each read as its type says.
values = .{ 'A', 1, 0, 0, 0xfd, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0 };
known = @splat(true);
const types = canim.Recording.types;
const char: types.Type = .{ .scalar = .{ .kind = .char, .bits = 8 } };
const boolean: types.Type = .{ .scalar = .{ .kind = .bool, .bits = 8 } };
const int: types.Type = .{ .scalar = .{ .kind = .int, .bits = 32 } };
rows.bytes(panel, 3 * row, 0x407080, &values, &known, &.{ .{ .first = 0, .len = 1, .kind = .number }, .{ .first = 1, .len = 1, .kind = .number }, .{ .first = 2, .len = 2, .kind = .loose }, .{ .first = 4, .len = 4, .kind = .number }, .{ .first = 8, .len = 8, .kind = .pointer } }, region.heap, 4, true, m);
_ = canim.hexdump.reading(panel, 3 * row, 0, m, &values, &known, &.{ .{ .at = 0, .len = 1, .type = char }, .{ .at = 1, .len = 1, .type = boolean }, .{ .at = 4, .len = 4, .type = int }, .{ .at = 8, .len = 8, .reads = .pointer } });
}
/// The graph pages' names, over their drawings.
const GraphPages = struct {
box: canim.Rect = .{ .x = 0, .y = 0, .w = 1920, .h = 1080 },
pub fn draw(_: *const GraphPages, f: *sk.Frame, at: anim.Placed) void {
const u: ui.Ui = .{ .f = f, .at = at };
const spots = [_][2]f32{ .{ 64, 72 }, .{ 976, 72 }, .{ 64, 488 }, .{ 976, 488 } };
if (at.t >= 21 and at.t < 24) {
title(u, 64, 40, "graph: the blocks lens, its two forms");
for (spots, [_][]const u8{ "rings: sort at rest, reached and not yet, the trail, the turns", "leave: the edge drawn gold, the mark round the ring", "turn: landed, the ring's count struck", "layers: libc's open at its syscall, what it has not reached folded" }) |p, words| note(u, p[0], p[1], words);
} else if (at.t >= 24 and at.t < 27) {
title(u, 64, 40, "graph: a first time, reach and unfold");
for (spots, [_][]const u8{ "reach: the first swap, its pill filling as the mark lands", "unfold: open past its syscall, the way back from the kernel opening", "layers: sort, panned to the pc", "unfold, at rest: the fold open, the pane panned" }) |p, words| note(u, p[0], p[1], words);
}
}
};
/// The graph pages, each four panes of the `blocks` lens (880 by 344): at
/// 21 s sort in rings at rest, a `leave` round the ring mid-way, a `turn`
/// just landed, libc's `open` in layers, folded; at 24 s a `reach` (the
/// first swap) and an `unfold` (open past its syscall) caught in their
/// moves, sort in layers, and the unfold at rest.
fn graphPages(s: *anim.Frame) [9]anim.Obj {
const graph = canim.graph;
const sort = canim.open(recordings.gallery_sort);
const hello = canim.open(recordings.gallery_hello);
const sort0 = sort.register(sort.call("sort", 0).enter, "rip");
// Where the opening of the sort scene is: the inner loop's test, about to compare 31 with 12.
var start = sort.call("sort", 0).enter;
while (sort.next(.over, sort.next(.over, start)) < sort.call("swap", 0).enter) start = sort.next(.over, start);
// The first `jne` to the swap, and the first jump back to the test.
var jne = start;
while (!(sort.insn_branches[jne] != null and sort.insn_branches[jne].?.taken and sort.insn_branches[jne].?.to == sort0 + 0xc5)) jne += 1;
var back = jne;
while (!(sort.insn_branches[back] != null and sort.insn_branches[back].?.to == sort0 + 0x8a)) back += 1;
var syscall_at: u64 = 0;
var buf: [256]u8 = undefined;
for (hello.registers, 0..) |r, k| if (hello.strings.get(r.rip)) |name| if (std.mem.startsWith(u8, name, "libc.so.6!open+") and std.mem.eql(u8, (hello.instruction(k, r.rip, &buf) orelse continue).text, "syscall")) {
syscall_at = k;
break;
};
const place = struct {
fn stage(s_: *anim.Frame, band: canim.Rect) *canim.Stage {
var split = canim.layout.split.blocks;
split.band = band;
return canim.Stage.init(s_, split);
}
}.stage;
const at = [_]canim.Rect{ .{ .x = 64, .y = 84, .w = 880, .h = 344 }, .{ .x = 976, .y = 84, .w = 880, .h = 344 }, .{ .x = 64, .y = 500, .w = 880, .h = 344 }, .{ .x = 976, .y = 500, .w = 880, .h = 344 } };
const rest = canim.cursor(s, sort, start);
// The scene's first leave: the inner test's `jle` not taken, round the ring's top to the compare.
const leaving = canim.cursor(s, sort, graph.blockEnd(sort, start));
const turning = canim.cursor(s, sort, back);
const open_at = canim.cursor(s, hello, syscall_at);
const reaching = canim.cursor(s, sort, jne);
// Open from its syscall: the fold of the way back from the kernel opens as the run gets there.
const unfolding = canim.cursor(s, hello, syscall_at);
const unfolded = canim.cursor(s, hello, syscall_at);
const first = .{
canim.add(s, graph.Blocks{ .cursor = rest, .stage = place(s, at[0]) }),
canim.add(s, graph.Blocks{ .cursor = leaving, .stage = place(s, at[1]) }),
canim.add(s, graph.Blocks{ .cursor = turning, .stage = place(s, at[2]) }),
canim.add(s, graph.Blocks{ .cursor = open_at, .stage = place(s, at[3]) }),
};
const second = .{
canim.add(s, graph.Blocks{ .cursor = reaching, .stage = place(s, at[0]) }),
canim.add(s, graph.Blocks{ .cursor = unfolding, .stage = place(s, at[1]) }),
canim.add(s, graph.Blocks{ .cursor = rest, .stage = place(s, at[2]), .form = .layers }),
canim.add(s, graph.Blocks{ .cursor = unfolded, .stage = place(s, at[3]) }),
};
// Each step played so that its page shows it mid-move: the leave with its
// mark half-way, the turn just struck; the reach landed and filling, the
// unfold making room.
const l = canim.theme.time.leave;
s.cursor = 0;
unfolding.jump(s, graph.blockEnd(hello, syscall_at));
unfolded.jump(s, graph.blockEnd(hello, syscall_at));
s.cursor = 21.8 - l.sets_off - 0.11;
graph.leave(leaving, s);
s.cursor = 21.8 - l.sets_off - 0.22 - 0.12;
graph.leave(turning, s);
s.cursor = 25.5 - l.sets_off - 0.24 - 0.10;
graph.leave(reaching, s);
s.cursor = 25.5 - l.sets_off - 0.18;
graph.leave(unfolding, s);
s.cursor = 23;
graph.leave(unfolded, s);
const pages = canim.add(s, GraphPages{});
var all: [first.len]anim.Animation = undefined;
s.cursor = 21;
s.play(.{pages.fadeIn()}, .{ .seconds = 0 });
inline for (first, 0..) |o, i| all[i] = o.fadeIn();
s.play(all, .{ .seconds = 0 });
s.cursor = 24;
inline for (first, 0..) |o, i| all[i] = o.fadeOut();
s.play(all, .{ .seconds = 0 });
inline for (second, 0..) |o, i| all[i] = o.fadeIn();
s.play(all, .{ .seconds = 0 });
s.cursor = 27;
return .{ pages, first[0], first[1], first[2], first[3], second[0], second[1], second[2], second[3] };
}
fn frame(s: *anim.Frame) void {
const rec = canim.open(recordings.gallery);
const reverse = rec.call("reverse", 0);
// In the loop, about to read `cur->next`.
const rest = rec.lineMoment(21, rec.lineMoment(24, reverse.enter));
const pages = canim.add(s, Pages{ .rec = rec, .moment = rest });
s.play(.{pages.fadeIn()}, .{ .seconds = 0 });
var at = canim.cursor(s, rec, rest);
// Its way, the one step it takes: the registers that step does not change are folded.
at.journey(.line, rec.next(.line, rest));
const ctx = canim.context(s, at, .{ .split = canim.layout.split.beside, .quiet = true });
const list = canim.nodes(s, .{ .cursor = at, .stage = ctx.stage, .root = "head", .track = &.{ "prev", "cur", "next" }, .quiet = true });
ctx.map.add(s, canim.Nodes{ .cursor = at, .stage = ctx.map.stage, .root = "head", .track = &.{ "prev", "cur", "next" }, .quiet = true });
// A loupe from rax (the last node, whose `next` is NULL by then), and
// one from the `next` of the node before it in the first's rows: two in depth.
const rax = rec.register(rec.next(.line, rest), "rax");
const near = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .register = "rax" } });
const deeper = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .field = .{ .loupe = near, .at = rax - 0x20 + 8 } } });
const joins = ctx.ties(s);
const says = canim.caption(s, "The gallery: the frame, at rest. Every panel, the thread,\nthe lens beside it: the list and the bytes it is drawn from.");
const panels = .{ ctx.clock, ctx.registers, ctx.stack, ctx.backtrace, ctx.source, ctx.disasm, list, joins, says };
s.wait(6);
var all: [panels.len]anim.Animation = undefined;
inline for (panels, 0..) |o, i| all[i] = o.fadeIn();
s.play(all, .{ .seconds = 0 });
// A step at 9 s, its strikes and ties at about 9.6; each state 3 s.
s.wait(9 - s.cursor);
at.walk(s, .line, rec.next(.line, rest));
s.wait(12 - s.cursor);
ctx.stage.relayout(s, canim.layout.split.subject);
s.wait(15 - s.cursor);
ctx.stage.relayout(s, canim.layout.split.none);
s.wait(18 - s.cursor);
near.open(s);
s.wait(18.8 - s.cursor);
deeper.open(s);
s.wait(20.6 - s.cursor);
deeper.close(s);
near.close(s);
s.wait(21 - s.cursor);
// The graph's pages: the context stands aside.
inline for (panels, 0..) |o, i| all[i] = o.fadeOut();
s.play(all, .{ .seconds = 0 });
_ = graphPages(s);
}
|