From 165bb6c1344b98de7bef1d3c2b72147b4a40797a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 16:05:20 -0300 Subject: canim: the renderer speaks the design language The blocks, their states and the tokens carry the catalogue's names: atoms in ui, chain/reg/slot in rows, insn with its line column, jump lane and annotations (read, write, taken or not, a call with its arguments, a return, a syscall) in disasm, bytes and hexdump with field paper and the reading column, the three splits and relayout in stage, the ties (thread, link and pin, projection, echo). A lens is a band over the whole context, its drawing left and its bytes right. Frames' spans on the stack, each instruction's line and a callee's parameter count come from the tracer. A gallery scene draws every block; the test compares six of its pages with pictures kept in test/gallery, drawn from a recording kept there too. The scenes are ported; the motion checks report no pop and no metronome in any of them. Co-Authored-By: Claude Fable 5.2 --- anim/scenes/fib.zig | 10 +- anim/scenes/gallery.zig | 301 +++++++++++++++++++++++++++++++++++++++++++++++ anim/scenes/list.zig | 8 +- anim/scenes/sort.zig | 10 +- anim/scenes/syscalls.zig | 10 +- anim/scenes/zoom.zig | 6 +- 6 files changed, 322 insertions(+), 23 deletions(-) create mode 100644 anim/scenes/gallery.zig (limited to 'anim/scenes') diff --git a/anim/scenes/fib.zig b/anim/scenes/fib.zig index e98727d..27d959f 100644 --- a/anim/scenes/fib.zig +++ b/anim/scenes/fib.zig @@ -24,19 +24,19 @@ fn frame(s: *anim.Frame) void { return r.call("fib", nth); } }.of; - const split = canim.layout.split.beside; + const split = canim.layout.split.subject; // From main's line, about to call fib(5), to where fib(5) has returned to it. var at = canim.cursor(s, rec, rec.lineMoment(10, rec.call("main", 0).enter)); - at.levels = .{ .idea = .calls, .source_rows = 8 }; + at.levels = .{ .idea = .calls, .source_rows = 10 }; at.journey(.line, call(rec, 0).exit.?); const ctx = canim.context(s, at, .{ .split = split }); // The lens: every call of fib as a tree, beside the frames they are on the stack. - const tree = canim.callTree(s, .{ .cursor = at, .box = split.lens, .function = "fib", .focus = true }); + const tree = canim.callTree(s, .{ .cursor = at, .stage = ctx.stage, .function = "fib", .focus = true }); var says: canim.Narrator = .{}; // Staging: the whole picture, still, before a word; the words, before a step. - const joins = canim.ties(s, .{ .cursor = at }); - canim.establish(s, .{ ctx.clock, ctx.source, ctx.disasm, ctx.registers, ctx.stack, ctx.backtrace, tree, joins }); + const joins = ctx.ties(s); + canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, tree, joins }); says.line(s, "`fib` calls itself. A call is a frame on the stack and a node\nin the tree; its argument arrives in `rdi`."); // The call, once, in full; and the two lines that lead to the next one. at.walk(s, .line, rec.lineMoment(6, call(rec, 0).enter)); diff --git a/anim/scenes/gallery.zig b/anim/scenes/gallery.zig new file mode 100644 index 0000000..12a592f --- /dev/null +++ b/anim/scenes/gallery.zig @@ -0,0 +1,301 @@ +//! 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 +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 }; + if (at.t < 1) atoms(u, p) else if (at.t < 2) 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 = .{ .level = 1, .solid = 1 }; + const cell: canim.Rect = .{ .x = x, .y = y, .w = 6 * 12, .h = row }; + _ = u.written(cell, struck, 9); + _ = u.address(x, rows.baseline(y), 0x407050, .{ .ink = ui.rgb(t.ink), .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, 9); + _ = 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"); + 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 }); + + // 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 = 344; + title(u, 64, y, "byte"); + note(u, 200, y, "number, pointer, allocator, 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 = .allocator } }, region.heap, 4, false, 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, 9); + _ = 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; under; a count after three names"); + y += 12; + u.pinRow(64, y, &.{ "rsp", "rbp" }, region.stack); + u.pinRow(64, y + row, &.{ "rax", "rdi", "rsi", "r8" }, region.heap); + u.fill(.{ .x = 400, .y = y - 20, .w = 116, .h = 20 }, theme.color.raised); + u.pinUnder(458, 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 = .{ .level = 1, .solid = 1 } }); + _ = 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); + + y = 380; + title(u, 64, y, "slot"); + note(u, 140, y, "its pins in the lane; the chain from 122; `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, if (i == 0) &.{ "rsp", "rbp" } else &.{}, 1, .{ .lead = ui.shared(&.{ regs.rsp, regs.rsp + 24 }), .first = if (i == 2) .ember else .none }); + } + 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", "", 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, plain, styles[0..plain.len], .{ .current = 0 }); + rows.line(panel, row, 880, 21, " node *next = cur->next;", styles[0..31], .{ .trail = 0 }); + rows.line(panel, 2 * row, 880, 20, " 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, long, styles[0..long.len], .plain); + + y = 750; + title(u, 64, y, "bytes"); + note(u, 160, y, "runs from the types; marks per run: struck, read, held"); + 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 = .{ .level = 1, .solid = 1 } } }, 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); +} + +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 }); + + const at = canim.cursor(s, rec, 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 }); + 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(2); + 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 3 s, its strikes and ties at about 3.6. + s.wait(3 - s.cursor); + at.walk(s, .line, rec.next(.line, rest)); + s.wait(5 - s.cursor); + ctx.stage.relayout(s, canim.layout.split.subject); + s.wait(7 - s.cursor); + ctx.stage.relayout(s, canim.layout.split.none); + s.wait(9 - s.cursor); +} diff --git a/anim/scenes/list.zig b/anim/scenes/list.zig index 5f2c843..53df4d5 100644 --- a/anim/scenes/list.zig +++ b/anim/scenes/list.zig @@ -31,13 +31,11 @@ fn frame(s: *anim.Frame) void { // The idea is the subject: the lens a size up, the nodes over the bytes they are. const split = canim.layout.split.subject; const ctx = canim.context(s, at, .{ .split = split, .quiet = true }); - const lens = split.lens; - const list = canim.nodes(s, .{ .cursor = at, .box = .{ .x = lens.x, .y = lens.y, .w = lens.w, .h = 192 }, .root = "head", .track = &tracked, .focus = true }); - const bytes = canim.hexdump(s, .{ .cursor = at, .box = .{ .x = lens.x, .y = lens.y + 204, .w = lens.w, .h = lens.h - 204 }, .base = rec.allocations[0].ptr - 16 }); + const list = canim.nodes(s, .{ .cursor = at, .stage = ctx.stage, .root = "head", .track = &tracked, .quiet = true }); var says: canim.Narrator = .{}; - const joins = canim.ties(s, .{ .cursor = at }); - canim.establish(s, .{ ctx.clock, ctx.source, ctx.disasm, ctx.registers, ctx.stack, ctx.backtrace, list, bytes, joins }); + const joins = ctx.ties(s); + canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, list, joins }); says.line(s, "A list is nodes on the heap, each holding the address of the next.\nReversing it moves no node: it rewrites every `next`."); // Three names are set up, then the first trip round the loop, in full. at.walk(s, .line, rec.lineMoment(20, rec.lineMoment(24, reverse.enter))); diff --git a/anim/scenes/sort.zig b/anim/scenes/sort.zig index 0f14269..6ad41f9 100644 --- a/anim/scenes/sort.zig +++ b/anim/scenes/sort.zig @@ -22,16 +22,16 @@ fn frame(s: *anim.Frame) void { while (rec.next(.over, rec.next(.over, start)) < rec.call("swap", 0).enter) start = rec.next(.over, start); var at = canim.cursor(s, rec, start); // The array is the idea; `i` and `j` are memory, and strike a beat before their tags slide. - at.levels = .{ .cpu = false, .idea = .data, .follow = t.quick, .source_rows = 8 }; + at.levels = .{ .cpu = false, .idea = .data, .follow = t.quick, .source_rows = 10 }; // Its last compare: nothing larger is left of 20. const last = rec.call("swap", 9); const end = rec.next(.over, rec.next(.over, last.exit.?)); at.journey(.over, end); // The context is the instrumented program's: its registers are unmarked. - const split = canim.layout.split.beside; + const split = canim.layout.split.subject; const ctx = canim.context(s, at, .{ .split = split, .quiet = true }); // The lens: the array as cells, and the two indices that walk it. - const cells = canim.array(s, .{ .cursor = at, .box = split.lens, .variable = "a", .indices = &.{ "i", "j" }, .focus = true }); + const cells = canim.array(s, .{ .cursor = at, .stage = ctx.stage, .variable = "a", .indices = &.{ "i", "j" }, .focus = true }); var says: canim.Narrator = .{}; // A swap, start to finish, as one step of sort(): over the call. const swap = struct { @@ -40,8 +40,8 @@ fn frame(s: *anim.Frame) void { } }.step; - const joins = canim.ties(s, .{ .cursor = at }); - canim.establish(s, .{ ctx.clock, ctx.source, ctx.disasm, ctx.registers, ctx.stack, ctx.backtrace, cells, joins }); + const joins = ctx.ties(s); + canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, cells, joins }); says.line(s, "`i` walks right. Everything left of it is in order,\nand 12 is not yet in its place."); // The compare: both cells framed. It is the swap's anticipation. at.walk(s, .over, rec.next(.over, start)); diff --git a/anim/scenes/syscalls.zig b/anim/scenes/syscalls.zig index 1516251..c981e58 100644 --- a/anim/scenes/syscalls.zig +++ b/anim/scenes/syscalls.zig @@ -27,16 +27,16 @@ fn frame(s: *anim.Frame) void { // From main's first call to its last line. var at = canim.cursor(s, rec, rec.lineMoment(6, rec.call("main", 0).enter)); at.journey(.line, rec.lineMoment(10, at.first)); - const split = canim.layout.split.beside; - at.levels = .{ .source_rows = 8 }; + const split = canim.layout.split.subject; + at.levels = .{ .source_rows = 10 }; const ctx = canim.context(s, at, .{ .split = split, .syscalls = true }); // The lens: the kernel's side of each call. - const kernel = canim.crossing(s, .{ .cursor = at, .box = split.lens, .focus = true }); + const kernel = canim.crossing(s, .{ .cursor = at, .stage = ctx.stage, .focus = true }); var says: canim.Narrator = .{}; const t = canim.theme.time; - const joins = canim.ties(s, .{ .cursor = at }); - canim.establish(s, .{ ctx.clock, ctx.source, ctx.disasm, ctx.registers, ctx.stack, ctx.backtrace, kernel, joins }); + const joins = ctx.ties(s); + canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, kernel, joins }); says.line(s, "A program cannot open a file or reach the screen itself.\nIt asks the kernel, and waits."); // One call a phrase: its caption while nothing moves, then the crossing. diff --git a/anim/scenes/zoom.zig b/anim/scenes/zoom.zig index 6eb3248..5ea2346 100644 --- a/anim/scenes/zoom.zig +++ b/anim/scenes/zoom.zig @@ -31,15 +31,15 @@ fn frame(s: *anim.Frame) void { var cam: canim.Camera = .{}; var says: canim.Narrator = .{}; - const joins = canim.ties(s, .{ .cursor = at }); - canim.establish(s, .{ ctx.clock, ctx.source, ctx.disasm, ctx.registers, ctx.stack, ctx.backtrace, joins }); + const joins = ctx.ties(s); + canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.backtrace, ctx.source, ctx.disasm, joins }); says.line(s, "A line of C is a handful of instructions.\nThis one calls `fib(n-1)`: follow it down."); // The CPU's level: an instruction a step. The argument is worked out in `rdi`. at.walk(s, .moment, call.enter - 1); says.line(s, "`call` writes eight bytes on the stack: the way back.\nThe new frame saves `rbp` under them, then its own `n`."); // Nearer, for the bytes: the stack alone, twice the size. - cam.go(s, canim.layout.stack, 2, .{ ctx.source, ctx.disasm, ctx.registers, ctx.backtrace }); + cam.go(s, split.stack, 2, .{ ctx.source, ctx.disasm, ctx.registers, ctx.backtrace }); at.walk(s, .moment, call.enter + 4); cam.back(s, .{ ctx.source, ctx.disasm, ctx.registers, ctx.backtrace }); -- cgit v1.3