summaryrefslogtreecommitdiff
path: root/anim/scenes/sort.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/scenes/sort.zig')
-rw-r--r--anim/scenes/sort.zig39
1 files changed, 24 insertions, 15 deletions
diff --git a/anim/scenes/sort.zig b/anim/scenes/sort.zig
index 81d55dd..454c3ad 100644
--- a/anim/scenes/sort.zig
+++ b/anim/scenes/sort.zig
@@ -1,16 +1,19 @@
-//! Insertion sort as its blocks: the graph of `sort` in the band (the
-//! `blocks` lens), the disassembly its view over the state column, the
-//! source alone in the program column; on the map the same graph with its
-//! rows.
+//! Insertion sort as its blocks: the graph of `sort` as rings over the
+//! program column (the `blocks` lens: the outer loop's ring, the inner's
+//! touching it at its header), the source and the disassembly under it,
+//! the registers and a stack of twenty beside; on the map the same
+//! drawing over the source, the disassembly linear beside it.
//!
//! How it moves (design/motion.md, "A block left"): it opens where `i` has
-//! reached 12, the first value out of order. One trip round the inner
-//! loop is walked a block at a time: each block's instructions a cascade
-//! onto its last row, then `leave` along the edge that row takes (the
-//! compare's chips framed, the edge drawn gold, the mark along it, the
-//! target's count struck), and `turn` up the inner loop's lane. The next
-//! trip is a run; the long middle is a sprint on the map (`surface`, the
-//! gold going block to block, `dive`); the last value's trip is walked
+//! reached 12, the first value out of order, the swap's block not reached
+//! yet. One trip round the inner loop is walked a block at a time: each block's
+//! instructions a cascade onto its last row, then `leave` along the edge
+//! that row takes (the compare's chips framed, the edge drawn gold, the
+//! mark along it, the target's count struck): the swap's first `reach`,
+//! then the inner ring's first `turn`; the disassembly unrolls for a beat,
+//! the function whole. The next trip is a run; the long
+//! middle a sprint on the map (`surface`, the gold going round the rings
+//! and down the linear column, `dive`); the last value's trip is walked
//! again, and the way out run.
const anim = @import("anim");
const canim = @import("canim");
@@ -29,7 +32,7 @@ fn frame(s: *anim.Frame) void {
// The inner loop's test (`j > 0`): where each of its trips begins.
const test_pc = rec.register(start, "rip");
var at = canim.cursor(s, rec, start);
- at.levels = .{ .fire = .disasm, .source_rows = 20 };
+ at.levels = .{ .fire = .disasm, .source_rows = 6 };
const last = rec.call("swap", 9);
// The last value's trip: from its test, before the compare that leads to the last swap.
var last_trip = last.enter;
@@ -48,13 +51,19 @@ fn frame(s: *anim.Frame) void {
}.walk;
canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, blocks, joins });
- says.line(s, "`sort` as its blocks: two loops. `j > 0`, so its `jle`\nis not taken, and the inner loop goes on to its compare.");
+ says.line(s, "`sort` as its blocks: each loop a ring, the inner touching\nthe outer. `j > 0`, so `jle` goes on to the compare.");
block(at, s);
- says.line(s, "31 > 12: `setg` leaves 1, and `jne` takes the swap.");
+ says.line(s, "31 > 12: `setg` leaves 1, and `jne` takes the swap,\nthe first time it is reached.");
block(at, s);
block(at, s);
- says.line(s, "The swap and `j--`; then the inner loop turns,\nback up to `j > 0`.");
+ says.line(s, "The swap and `j--`; then the inner loop turns,\nback up to `j > 0`: its first turn.");
block(at, s);
+ // The whole function for a beat: the disassembly unrolled, each block's first row ruled with its visits.
+ says.line(s, "The function whole: each block under a rule, with its visits.");
+ ctx.map.unroll(s, .disasm);
+ // Held while the caption is read: rolled back in as its reading time ends.
+ s.wait(@max(says.read_by - s.cursor - t.unroll.roll - t.unroll.veil, t.unroll.hold));
+ ctx.map.roll(s);
// Pacing: the next trip at a run; then the long middle on the map, at a sprint.
says.line(s, "Once more at a run: 17 > 12, a second swap.");