diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-11 20:08:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-11 21:45:12 -0300 |
| commit | 15de88cf82c187635c1989e91bfa639a10304066 (patch) | |
| tree | 16fa83854258c0c6aec1dff7f70ebabf5fd64c09 /anim/scenes/column_sort.zig | |
| parent | 0ec2376cae2fdfc50e90d930ebc86c7a5b7f5594 (diff) | |
| download | computeranim-15de88cf82c187635c1989e91bfa639a10304066.tar.gz computeranim-15de88cf82c187635c1989e91bfa639a10304066.zip | |
canim: a column of text as an experiment; the disassembly tied to the stack
From the user. A scene may set its text in a column beside the panes a
beat is about: col.beat names the panes and their rows, where the text
is placed (beside, below, above, or on a drawing) and what it is level
with; panes the beat leaves out fold to their title bars on a shelf,
their changes struck there. Tried as two scenes beside the originals:
the call followed down (column) and a bubble on sort's rings
(column_sort).
annotation = .tied names the word an instruction touched and draws a
touch to its stack row; offsets count from the frame's base; rsp's pin
travels with its amount before the stack follows; .whole keeps the full
chain. carry = .arrow draws a value's way between memory and a register.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/scenes/column_sort.zig')
| -rw-r--r-- | anim/scenes/column_sort.zig | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/anim/scenes/column_sort.zig b/anim/scenes/column_sort.zig new file mode 100644 index 0000000..d851172 --- /dev/null +++ b/anim/scenes/column_sort.zig @@ -0,0 +1,59 @@ +//! The column's wide placements, on sort's rings (design/README.md, +//! "column (an experiment)", mock 55): the opening in the working frame +//! (the `blocks` lens), then the drawing across both columns twice its size, +//! the rest folded to the shelf, a beat's text `on` it, in the corner the +//! rings leave free, its stem round the drawing's outside to the pc's block; +//! then a beat `above` it; then the working frame again. The steps are +//! sort's own: its first trip round the inner loop, a block at a time. +const anim = @import("anim"); +const canim = @import("canim"); +const recordings = @import("recordings"); + +pub const background = canim.background; +pub const scene = anim.Live(frame, struct {}); + +fn frame(s: *anim.Frame) void { + const rec = canim.open(recordings.sort); + const graph = canim.graph; + // As the sort scene opens: the `while`, about to compare 31 with 12. + var start = rec.call("sort", 0).enter; + 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); + at.levels = .{ .fire = .disasm, .source_rows = 6 }; + at.journey(.over, rec.call("swap", 0).exit.?); + const ctx = canim.context(s, at, .{ .split = canim.layout.split.blocks, .graph = true }); + const blocks = canim.add(s, graph.Blocks{ .cursor = at, .stage = ctx.stage, .focus = true }); + const col = canim.column(s, ctx, .{ .lens = blocks, .titles = .{ .band = "its blocks" }, .at = .below }); + const joins = ctx.ties(s); + const block = struct { + fn walk(c: canim.Cursor, f: *anim.Frame) void { + graph.toEnd(c, f); + graph.leave(c, f); + } + /// The block the pc is in, by its first instruction's address. + fn here(c: canim.Cursor, f: *anim.Frame) u64 { + const i = c.moment(f); + const pc = c.rec.register(i, "rip"); + const g = graph.read(f.arena, c.rec, i, pc) orelse return pc; + return g.nodes[g.nodeOf(pc) orelse return pc].start; + } + }; + + canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, blocks, joins }); + col.beat(s, .{ .say = "`sort` as its blocks: each loop a ring, the inner touching\nthe outer. `j > 0`, so `jle` goes on to the compare." }); + block.walk(at, s); + // `on`: the drawing across both columns, the text in the corner the rings leave free. + col.beat(s, .{ + .at = .on, + .say = "31 > 12: `setg` leaves 1,\nand `jne` takes the swap,\nthe first time it is reached.", + .where = .{ 104, 144 }, + .level = .{ .block = block.here(at, s) }, + }); + block.walk(at, s); + block.walk(at, s); + // `above`: the text leads the eye in at the top. + col.beat(s, .{ .at = .above, .say = "The swap and `j--`; then the inner loop turns, back up to `j > 0`: its first turn." }); + block.walk(at, s); + col.beat(s, .{ .at = .below, .say = "" }); + col.close(s); +} |
