summaryrefslogtreecommitdiff
path: root/anim/scenes
diff options
context:
space:
mode:
Diffstat (limited to 'anim/scenes')
-rw-r--r--anim/scenes/intro_code.zig124
-rw-r--r--anim/scenes/intro_memory.zig26
-rw-r--r--anim/scenes/intro_stack.zig141
3 files changed, 198 insertions, 93 deletions
diff --git a/anim/scenes/intro_code.zig b/anim/scenes/intro_code.zig
index a5660ed..b50c971 100644
--- a/anim/scenes/intro_code.zig
+++ b/anim/scenes/intro_code.zig
@@ -1,14 +1,16 @@
//! The introduction, chapter III: code and meaning (design/motion.md, "A
//! scene: the introduction", III1 to III5; mocks 32, 33, 36). On the
-//! `list` recording at the load in `reverse` (line 21, `node *next =
+//! `intro` recording at the load in `reverse` (line 21, `node *next =
//! cur->next;`, the instruction that reads `cur->next`): the code's bytes
//! as a dump row, that instruction's four framed; `decode`d into its row
//! of `aligned` (`interleaved`), its neighbours at a run, each line level
//! with its run; then `align` to `columns`; then the working frame with the
-//! nodes drawn from the heap's bytes; then the map (`surface`). The texts
-//! `above` the aligned panel, then below the working frame.
+//! nodes drawn from the heap's bytes, each pane's minimap drawing itself
+//! last; then the map (`surface`). The texts `above` the aligned panel,
+//! then below the working frame, and the last one on the map.
const std = @import("std");
const anim = @import("anim");
+const sk = @import("sketch");
const canim = @import("canim");
const recordings = @import("recordings");
@@ -33,11 +35,60 @@ fn on(rec: *canim.Recording, from: u64, text: []const u8) u64 {
return from;
}
+/// The page over a part not drawn yet (a pane's minimap until III4).
+const Page = struct {
+ box: canim.Rect,
+ pub fn draw(c: *const Page, fr: *sk.Frame, placed: anim.Placed) void {
+ (canim.ui.Ui{ .f = fr, .at = placed }).fill(c.box, canim.theme.color.page);
+ }
+};
+
+/// Chapter II's last picture (scenes/intro_stack.zig, its layout and texts
+/// as there): its registers and stack, a context of their own at II's last
+/// moment; main's rows, faint; II3's text dimmed and II4's.
+fn lastOfTwo(s: *anim.Frame, rec: *canim.Recording) struct { panels: [3]anim.Obj, texts: [2]anim.Obj } {
+ const enter = rec.call("reverse", 0).enter;
+ const last = enter + 3;
+ const row = canim.theme.metric.context.row;
+ const head = canim.theme.metric.context.tag + canim.theme.metric.context.pad;
+ var at = canim.cursor(s, rec, enter);
+ at.journey(.moment, last);
+ at.levels = .{ .fire = .disasm, .source_rows = 14 };
+ at.jump(s, last);
+ var split = canim.layout.split.none;
+ split.backtrace.h = 0;
+ const ctx = canim.context(s, at, .{ .split = split });
+ const rb = ctx.stage.first.registers;
+ ctx.stage.first.stack.h = canim.layout.panelH(18);
+ ctx.stage.first.stack.y = rb.y + rb.h + canim.theme.canvas.row_gap;
+ const top = ctx.stage.first.stack.y + head;
+ const rsp = rec.register(enter, "rsp");
+ const window = rec.register(last, "rsp") - 16;
+ const rowY = struct {
+ fn y(t0: f32, from: u64, addr: u64) f32 {
+ return t0 + row * @as(f32, @floatFromInt(@as(i64, @bitCast(addr -% from)) >> 3));
+ }
+ }.y;
+ const stack = canim.add(s, canim.Stack{ .cursor = ctx.cursor, .stage = ctx.stage });
+ const back_y = rowY(top, rsp - 8 - 16, rsp);
+ // (Placed at the origin: it draws at its own box.)
+ const caller = s.custom(s.new(canim.descent.Caller{ .rec = rec, .at = enter, .call = rec.register(enter - 1, "rip"), .box = .{ .x = canim.theme.layout.program.x, .y = back_y + row / 2 + 176, .w = canim.theme.layout.program.w, .h = 4 * row }, .in = s.value(999), .faint = s.value(1) }), .{ .x = -640, .y = -360, .scale = canim.ui.scale });
+ const left = canim.theme.canvas.margin_x;
+ const said = [2]canim.Aside{
+ .{ .text = "A function's words are its frame: the saved rbp, its locals, the way back.", .x = left, .level = (rowY(top, window, window + 16) + rowY(top, window, rsp + 8)) / 2, .dim = s.value(1) },
+ .{ .text = "The registers are the other place values live: seventeen of them.", .x = left, .level = rb.y + head + row * 2.5, .dim = s.value(0) },
+ };
+ var texts: [2]anim.Obj = undefined;
+ for (said, &texts) |a, *o| o.* = s.custom(s.new(a), .{ .x = -640, .y = -360, .scale = canim.ui.scale });
+ for ([_]anim.Obj{ ctx.registers, stack, caller, texts[0], texts[1] }) |o| s.play(.{o.fadeIn()}, .{ .seconds = 0 });
+ return .{ .panels = .{ ctx.registers, stack, caller }, .texts = texts };
+}
+
/// The variables whose tags the nodes carry, as the list scene's.
const tracked = [_][]const u8{ "prev", "cur", "next", "head" };
fn frame(s: *anim.Frame) void {
- const rec = canim.open(recordings.list);
+ const rec = canim.open(recordings.intro);
const reverse = rec.call("reverse", 0);
// The load: `cur->next` read, line 21's second instruction.
const moment = on(rec, rec.lineMoment(21, reverse.enter), "[rax + 8]");
@@ -52,6 +103,10 @@ fn frame(s: *anim.Frame) void {
for (code[0..insn.len], 0..) |b, k| hex.print(s.arena, "{s}{x:0>2}", .{ if (k > 0) " " else "", b }) catch {};
const text = std.mem.replaceOwned(u8, s.arena, insn.text, "qword ptr ", "") catch insn.text;
+ // Chapter II's last picture, which this chapter opens on (II's own
+ // context at II's last moment, laid out as II has it, under this one's).
+ const opening = lastOfTwo(s, rec);
+
var at = canim.cursor(s, rec, moment);
at.journey(.moment, moment + 1);
at.levels = .{ .idea = .data, .follow = t.move, .source_rows = 8 };
@@ -60,6 +115,13 @@ fn frame(s: *anim.Frame) void {
ctx.map.add(s, canim.Nodes{ .cursor = at, .stage = ctx.map.stage, .root = "head", .track = &tracked });
const joins = ctx.ties(s);
+ // Each pane's minimap under the page until III4, where they draw themselves last, top down
+ // (over the panels, under the aligned rows landing on them; on from the panels' first frame).
+ const first = ctx.stage.first;
+ var strips: [4]anim.Obj = undefined;
+ for ([_]canim.Rect{ first.view, first.source, first.stack, first.disasm }, &strips) |b, *o|
+ o.* = s.custom(s.new(Page{ .box = .{ .x = b.x + b.w - canim.theme.strip.cost, .y = b.y + canim.theme.metric.context.tag, .w = canim.theme.strip.cost - canim.theme.stroke.rule, .h = b.h - canim.theme.metric.context.tag - canim.theme.stroke.rule } }), .{ .x = -640, .y = -360, .scale = canim.ui.scale });
+
const al = s.new(canim.Aligned.init(s, rec, moment));
const panel = s.custom(al, .{ .x = -640, .y = -360, .scale = canim.ui.scale });
s.play(.{panel.fadeIn()}, .{ .seconds = 0 });
@@ -67,8 +129,14 @@ fn frame(s: *anim.Frame) void {
const left = canim.theme.canvas.margin_x;
const above = canim.theme.canvas.stage.y + 40;
+ // From II's last picture: it gives way (its texts 12 f, the rest 18 f), the stage clear for the code.
+ s.wait(t.beat);
+ s.play(.{ opening.texts[0].fadeOut(), opening.texts[1].fadeOut() }, .{ .seconds = t.caption_out, .ease = canim.ease.exit });
+ s.cursor -= t.caption_out;
+ s.play(.{ opening.panels[0].fadeOut(), opening.panels[1].fadeOut(), opening.panels[2].fadeOut() }, .{ .seconds = f(18), .ease = anim.ease.linear });
+ s.wait(t.beat);
+
// III1: the code's bytes, one instruction's framed.
- s.wait(1.0);
asides.say(s, std.fmt.allocPrint(s.arena, "Code is bytes too: `{s}` is one instruction.", .{hex.items}) catch "", left, above);
s.wait(t.caption_lead);
run(s, al.bytes, 12 + 2 * 15 + 12 + 6);
@@ -83,28 +151,46 @@ fn frame(s: *anim.Frame) void {
// III2, the other form: two columns, each line level with the first of its instructions.
asides.say(s, "Two columns: each line level with its first instruction.", left, above);
- run(s, al.form, 72);
+ run(s, al.form, 80);
s.wait(t.beat);
- // Into the working frame: the texts above leave, the panel goes, the frame comes in.
+ // Into the working frame: the texts above leave; `stack`: the lines glide to
+ // the source panel's rows, the instructions to the disassembly's (60 f); those
+ // panels come in under them as the aligned rows go (12 f): the same rows; then
+ // the band and the state column (`establish`).
asides.leave(s);
- s.play(.{panel.fadeOut()}, .{ .seconds = f(12), .ease = anim.ease.linear });
+ al.to = .{ .source = ctx.stage.first.source, .disasm = ctx.stage.first.disasm };
+ run(s, al.stack, 60);
+ s.play(.{ strips[0].fadeIn(), strips[1].fadeIn(), strips[2].fadeIn(), strips[3].fadeIn() }, .{ .seconds = 0 });
+ s.play(.{ ctx.source.fadeIn(), ctx.disasm.fadeIn(), panel.fadeOut() }, .{ .seconds = f(12), .ease = anim.ease.linear });
var says: canim.Narrator = .{};
- var cam: canim.Camera = .{};
- canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, joins });
+ canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, joins });
// III3: the node it reads, as bytes and drawn: the band comes in, its
- // elements rising from their bytes, and the camera nearer on it (x1.5).
+ // elements rising from their bytes. No camera: at x1.5 the drawing's
+ // nodes and its bytes do not both fit the frame, and the band is whole at x1.
says.line(s, "`rax` points at a list node on the heap:\nits bytes, and drawn, the node.");
- ctx.establish(s, .{list}, 3);
- cam.go(s, .{ .x = 512, .y = 48, .w = 896, .h = 296 }, 1.5, .{});
+ // The heap's dump first, in the band's right half (18 f); then the nodes drawn from it, rising (`establish`).
+ s.play(.{ctx.stage.drawing.to(0)}, .{ .seconds = 0 });
+ s.play(.{list.fadeIn()}, .{ .seconds = f(18), .ease = anim.ease.linear });
+ s.wait(f(30));
+ s.play(.{ctx.stage.drawing.to(1)}, .{ .seconds = f(12), .ease = anim.ease.linear });
+ s.cursor -= f(12);
+ ctx.establish(s, .{}, 3);
s.wait(t.beat);
- // III4: the whole frame: the camera back to x1.
+ // III4: the whole frame; each pane's minimap draws itself, last, top down (24 f, 48 f apart).
says.line(s, "This is the whole frame.\nEvery view in it is these same bytes.");
- cam.back(s, .{});
+ const strips_from = s.cursor;
+ for (strips, 0..) |o, k| {
+ s.cursor = strips_from + f(48 * @as(f32, @floatFromInt(k)));
+ s.play(.{o.fadeOut()}, .{ .seconds = f(24), .ease = anim.ease.linear });
+ }
s.wait(t.beat);
- // III5: the map.
- says.line(s, "And all of it at once: the map.");
+ // III5: the map, and its text on it, in the key's corner (the middle column's foot, empty on this map).
+ s.wait(@max(says.read_by - s.cursor, 0));
+ s.play(.{says.current.?.fadeOut()}, .{ .seconds = t.caption_out, .ease = canim.ease.exit });
+ s.wait(t.caption_gap);
ctx.map.surface(s);
- says.close(s);
- cam.apply(s);
+ asides.say(s, "And all of it at once:\nthe map.", 528, 720);
+ s.wait(@max(asides.read_by - s.cursor, 0));
+ s.wait(t.before_cut);
}
diff --git a/anim/scenes/intro_memory.zig b/anim/scenes/intro_memory.zig
index 07e694a..7aec267 100644
--- a/anim/scenes/intro_memory.zig
+++ b/anim/scenes/intro_memory.zig
@@ -1,8 +1,8 @@
//! The introduction, chapter I: memory (design/motion.md, "A scene: the
//! introduction", I1 to I10; mocks 29, 30, 34, 37). The frame built from
-//! its bytes up, on the `list` recording stopped in `reverse`'s prologue,
-//! at its first call (line 17: the push chapter II walks; the 128 bytes at
-//! rsp then are the load's but for `prev`, not yet stored), each part in
+//! its bytes up, on the `intro` recording (the list program from main's
+//! call of `reverse`) at reverse's first instruction, its `push rbp` (the
+//! push chapter II walks; rsp holds the way back to main), each part in
//! the place it keeps: the 128 bytes at the top
//! of the stack where the stack panel will stand, under the camera at x2;
//! made words (`regroup`); three of them addresses; then the address space
@@ -36,22 +36,10 @@ fn start(s: *anim.Frame, v: anim.Value, frames: f32) void {
s.cursor = at;
}
-/// The first moment from `from` whose instruction reads `text`.
-fn on(rec: *canim.Recording, from: u64, text: []const u8) u64 {
- var buf: [256]u8 = undefined;
- var i = from;
- while (i < rec.end()) : (i += 1) if (rec.instruction(i, rec.register(i, "rip"), &buf)) |here| if (std.mem.indexOf(u8, here.text, text) != null) return i;
- return from;
-}
-
fn frame(s: *anim.Frame) void {
- const rec = canim.open(recordings.list);
- const reverse = rec.call("reverse", 0);
- // reverse's first call (line 17, the tracer's `__zt_var` for its first
- // local): the push chapter II walks. The recording begins after
- // reverse's own `push rbp` (`--from` breaks past the prologue), so it is
- // the first push of reverse's that the recording has.
- const moment = on(rec, reverse.enter, "call");
+ const rec = canim.open(recordings.intro);
+ // reverse's first instruction (its call's first moment): its `push rbp`, which chapter II walks.
+ const moment = rec.call("reverse", 0).enter;
const ui = canim.ui;
const at = canim.regroup.at;
@@ -121,7 +109,7 @@ fn frame(s: *anim.Frame) void {
const clusters = @min(l.space.clusters.len, 6);
var top_end: usize = 0;
while (top_end < clusters and l.space.clusters[top_end].lo > canim.segments.user_end / 2) top_end += 1;
- asides.say(s, "Enlarged, the top end: the stack, the libraries and the tracer's ring, each band with its addresses and size.", column_x, l.boxes[0].y + 12);
+ asides.say(s, "Enlarged, the top end: the stack, then the libraries, each band with its addresses and size.", column_x, l.boxes[0].y + 12);
for (0..top_end) |i| {
start(s, space.rides[i], 6 + 72 + 90 + 2 * 12 + 12);
s.wait(f(78));
diff --git a/anim/scenes/intro_stack.zig b/anim/scenes/intro_stack.zig
index e504ffc..49162e6 100644
--- a/anim/scenes/intro_stack.zig
+++ b/anim/scenes/intro_stack.zig
@@ -1,17 +1,22 @@
//! The introduction, chapter II: the stack (design/motion.md, "A scene: the
//! introduction", II1 to II4; mock 31). It opens on chapter I's last
-//! picture, at the same moment of the `list` recording (reverse's first
-//! call, line 17): the address space and the dump's link fade, the words
-//! glide into the stack panel's rows where it stands in the working frame
-//! and become it; a push walked from the recording (that call's: the
-//! address to come back to, rsp's pin climbing onto it); the return
-//! address main left, and the offsets; rbp's pin and the panel's tag last;
-//! then the registers built over it a row at a time, their tag last. The
-//! text stands beside on the left, in the program column, empty until
-//! chapter III.
+//! picture, at the same moment of the `intro` recording (reverse's first
+//! instruction, its `push rbp`): the address space and the dump's link
+//! fade, the words glide into the stack panel's rows where it stands in the
+//! working frame (sixteen of them and two `free` over rsp) and become it.
+//! rsp's row arrives over the stack and its pin lands on the top word; the
+//! push walked from the recording (rsp's pin climbing onto the saved rbp).
+//! The way back main left framed, main's three rows round its call arriving
+//! in the program column, the word aimed at the row it returns to (`aim`,
+//! this beat only), the offsets a `column`. rbp's row and pin, `mov rbp,
+//! rsp` and `sub rsp` walked: the frame; its roles and spans, a `column`
+//! each, the panel's tag last (`frame up`). Then the registers built over
+//! it a row at a time, their tag last. The text stands beside on the left,
+//! in the program column, empty until chapter III but for main's rows.
//!
-//! What a beat has not reached yet is under the page (`Cover`), lifted as
-//! the beat says it: the context's panels draw every column at once.
+//! What a beat has not reached yet is under the page (`Cover`, and the
+//! stack's own `reveal`), lifted as the beat says it: the context's panels
+//! draw every column at once.
const std = @import("std");
const anim = @import("anim");
const sk = @import("sketch");
@@ -80,59 +85,62 @@ fn lift(s: *anim.Frame, covers: []const ?anim.Obj, apart: f32, each: f32) void {
s.cursor = end;
}
-fn on(rec: *canim.Recording, from: u64, text: []const u8) u64 {
- var buf: [256]u8 = undefined;
- var i = from;
- while (i < rec.end()) : (i += 1) if (rec.instruction(i, rec.register(i, "rip"), &buf)) |here| if (std.mem.indexOf(u8, here.text, text) != null) return i;
- return from;
-}
-
/// A value at once, from the cursor.
fn set(s: *anim.Frame, v: anim.Value, to: f32) void {
s.play(.{v.to(to)}, .{ .seconds = 0 });
}
+/// Clock `v` from 0 to `frames`, linear, from the cursor; the cursor after it.
+fn run(s: *anim.Frame, v: anim.Value, frames: f32) void {
+ s.play(.{v.to(0)}, .{ .seconds = 0 });
+ s.play(.{v.to(frames)}, .{ .seconds = f(frames), .ease = anim.ease.linear });
+}
+
fn frame(s: *anim.Frame) void {
- const rec = canim.open(recordings.list);
+ const rec = canim.open(recordings.intro);
const reverse = rec.call("reverse", 0);
- // Chapter I's moment: reverse's first call, whose push is walked here.
- const moment = on(rec, reverse.enter, "call");
+ // Chapter I's moment: reverse's first instruction, `push rbp`; then `mov rbp, rsp` and `sub rsp, 0x20`.
+ const moment = reverse.enter;
+ const framed = moment + 3;
var at = canim.cursor(s, rec, moment);
- at.journey(.moment, moment + 1);
+ at.journey(.moment, framed);
at.levels = .{ .fire = .disasm, .source_rows = 14 };
- // The working frame with no backtrace: the stack goes to the stage's foot under the registers.
var split = canim.layout.split.none;
split.backtrace.h = 0;
const ctx = canim.context(s, at, .{ .split = split });
- const sb = ctx.stage.first.stack;
+ // Sixteen slots and the headroom under the registers' box (the words
+ // become them where they stand), not the column's rest.
const rb = ctx.stage.first.registers;
+ ctx.stage.first.stack.h = canim.layout.panelH(18);
+ ctx.stage.first.stack.y = rb.y + rb.h + canim.theme.canvas.row_gap;
+ const sb = ctx.stage.first.stack;
const rsp = rec.register(moment, "rsp");
- const rsp_after = rec.register(moment + 1, "rsp");
// The window has two `free` words over rsp; rows from the panel's tag and padding.
const first = rsp - 16;
const top = sb.y + tag + pad;
const slots = canim.layout.rowsIn(sb.h);
const rowY = struct {
fn y(t0: f32, from: u64, addr: u64) f32 {
- return t0 + row * @as(f32, @floatFromInt((addr - from) / 8));
+ return t0 + row * @as(f32, @floatFromInt(@as(i64, @bitCast(addr -% from)) >> 3));
}
}.y;
- // What has not been said yet, under the page: the stack's offsets, the
- // pins' lane under rsp's row, its tag, rules and strip; the registers' rows, tag and rules.
- var offsets: [32]?anim.Obj = @splat(null);
- var lane: [32]?anim.Obj = @splat(null);
- const rsp_row = (rsp - first) / 8;
- for (0..@min(slots, 32)) |k| {
- const y = top + row * @as(f32, @floatFromInt(k));
- offsets[k] = cover(s, .{ .x = sb.x + 92, .y = y, .w = 84, .h = row });
- if (k > rsp_row) lane[k] = cover(s, .{ .x = sb.x + 2, .y = y, .w = 88, .h = row });
- }
- const stack_chrome = chrome(s, sb, true);
+ // The panels and the page over what they have not said yet, first: chapter I's
+ // picture, the words gliding into the stack among them, draws over them.
+ // The stack, its offsets, roles and spans under the page until their beats.
+ const reveal: canim.Stack.Reveal = .{ .offsets = s.value(-1), .roles = s.value(-1), .spans = s.value(-1) };
+ const stack = canim.add(s, canim.Stack{ .cursor = ctx.cursor, .stage = ctx.stage, .reveal = reveal });
+ // The registers, under the page: rbp's and rsp's rows (the scene's two, the first two), the rest, the chrome.
+ s.play(.{ctx.registers.fadeIn()}, .{ .seconds = 0 });
var regs_rows: [16]?anim.Obj = @splat(null);
for (0..@min(canim.layout.rowsIn(rb.h), 16)) |k|
- regs_rows[k] = cover(s, .{ .x = rb.x + 2, .y = rb.y + tag + pad + row * @as(f32, @floatFromInt(k)), .w = rb.w - 4, .h = row });
+ // (From the third row on 2 higher: the rule over the folded rows goes with them.)
+ regs_rows[k] = cover(s, .{ .x = rb.x + 2, .y = rb.y + tag + pad + row * @as(f32, @floatFromInt(k)) - @as(f32, if (k >= 2) 2 else 0), .w = rb.w - 4, .h = row + @as(f32, if (k >= 2) 2 else 0) });
const regs_chrome = chrome(s, rb, false);
+ // The pins' lane under the free words: rsp's row's lifted with rsp, the rest with rbp.
+ var lane: [32]?anim.Obj = @splat(null);
+ for (2..@min(slots, 32)) |k| lane[k] = cover(s, .{ .x = sb.x + 2, .y = top + row * @as(f32, @floatFromInt(k)), .w = 116, .h = row });
+ const stack_chrome = chrome(s, sb, true);
// Chapter I's last picture: the address space, the words with their chains, the link standing.
const space = s.new(canim.Segments.init(s, rec, moment));
@@ -148,33 +156,57 @@ fn frame(s: *anim.Frame) void {
set(s, dump.left, 24);
const objs = .{ place(s, space), place(s, dump), place(s, tie) };
inline for (objs) |o| s.play(.{o.fadeIn()}, .{ .seconds = 0 });
- const main_word: canim.Rect = .{ .x = sb.x + canim.theme.metric.slot.address + 12 * 12 + canim.theme.metric.context.arrow_w, .y = rowY(top, rsp_after - 16, rsp + 8 * dump.walked), .w = 6 * 12, .h = row };
- const framed = place(s, s.new(Read{ .box = main_word }));
+
+ // main's rows, in the program column under II2's text; the aim joins them to the word.
+ const rsp_after = rec.register(moment + 1, "rsp");
+ const back_y = rowY(top, rsp_after - 16, rsp);
+ const main_rows = s.new(canim.descent.Caller{ .rec = rec, .at = moment, .call = rec.register(moment - 1, "rip"), .box = .{ .x = canim.theme.layout.program.x, .y = back_y + row / 2 + 176, .w = canim.theme.layout.program.w, .h = 4 * row }, .in = s.value(-1), .faint = s.value(0) });
+ s.play(.{place(s, main_rows).fadeIn()}, .{ .seconds = 0 });
+ const main_word: canim.Rect = .{ .x = sb.x + canim.theme.metric.slot.address + 12 * 12 + canim.theme.metric.context.arrow_w, .y = back_y, .w = @as(f32, @floatFromInt(canim.ui.digits(rec.register(moment - 1, "rip") + 5))) * 12, .h = row };
+ const word_frame = place(s, s.new(Read{ .box = main_word }));
+ const joins = ctx.ties(s);
+ s.play(.{joins.fadeIn()}, .{ .seconds = 0 });
var asides: canim.Asides = .{};
const left = canim.theme.canvas.margin_x;
// II1: the address space and the link fade (18 f); the words glide into
- // the stack's rows (36 f) and become the panel (12 f); then the push.
+ // the stack's rows (36 f) and become the panel (12 f).
s.wait(t.beat);
s.play(.{ objs[0].fadeOut(), objs[2].fadeOut() }, .{ .seconds = f(18), .ease = anim.ease.linear });
s.play(.{dump.become.to(1)}, .{ .seconds = f(36), .ease = anim.ease.linear });
- s.play(.{ ctx.stack.fadeIn(), objs[1].fadeOut() }, .{ .seconds = f(12), .ease = anim.ease.linear });
- asides.say(s, "`rsp` holds the address of the stack's top; a push moves it down a word.", left, rowY(top, first, rsp) + row / 2);
+ s.play(.{ stack.fadeIn(), objs[1].fadeOut() }, .{ .seconds = f(12), .ease = anim.ease.linear });
+ asides.say(s, "`rsp` holds the address of the top of the stack. A push moves it down a word.", left, rowY(top, first, rsp) + row / 2);
+ // rsp's row arrives over the stack (12 f), then its pin lands on the top word (12 f).
+ lift(s, &.{regs_rows[1]}, 0, 12);
+ lift(s, &.{lane[2]}, 0, 12);
+ s.wait(f(18));
at.walk(s, .moment, moment + 1);
s.wait(t.beat);
- // II2: the address the call pushed, and main's under it; the offsets, a column.
- asides.say(s, "Each call pushes where to come back to: `main+50` is main's.", left, main_word.y + row / 2);
- s.play(.{framed.fadeIn()}, .{ .seconds = f(6), .ease = anim.ease.linear });
- s.wait(f(24));
- lift(s, &offsets, 2, 12);
+ // II2: the way back main left, framed; main's rows; the aim; the offsets, a column.
+ asides.say(s, "A call pushes the address to come back to: here, `main+50`.", left, back_y + row / 2);
+ s.play(.{word_frame.fadeIn()}, .{ .seconds = f(6), .ease = anim.ease.linear });
+ s.wait(f(12));
+ run(s, main_rows.in, 12 + 2 * 2 + 12);
+ s.wait(f(6));
+ at.aim(s, .standing);
+ s.wait(f(30));
+ run(s, reveal.offsets, 2 * @as(f32, @floatFromInt(slots)) + 12);
s.wait(t.beat);
- // II3: a function's frame: rbp's pin, and the panel's tag, last.
- asides.say(s, "A function's words are its frame: saved rbp, locals, the way back.", left, rowY(top, rsp_after - 16, rec.register(moment + 1, "rbp")) + row / 2);
- s.play(.{framed.fadeOut()}, .{ .seconds = f(18), .ease = anim.ease.linear });
- s.cursor -= f(18);
- lift(s, &lane, 2, 12);
+ // II3: rbp's row and its pin; the frame made (`mov rbp, rsp`, `sub rsp`); its roles, spans, and the tag last.
+ const rsp_framed = rec.register(framed, "rsp");
+ const span_y = (rowY(top, rsp_framed - 16, rsp_framed) + rowY(top, rsp_framed - 16, rsp + 8)) / 2;
+ asides.say(s, "A function's words are its frame: the saved rbp, its locals, the way back.", left, span_y);
+ at.aim(s, .off);
+ s.play(.{ word_frame.fadeOut(), main_rows.faint.to(1) }, .{ .seconds = f(18), .ease = anim.ease.linear });
+ lift(s, &.{regs_rows[0]}, 0, 12);
+ lift(s, lane[3..], 2, 12);
+ s.wait(f(12));
+ at.walk(s, .moment, moment + 2);
+ at.walk(s, .moment, framed);
+ run(s, reveal.roles, 2 * @as(f32, @floatFromInt(slots)) + 12);
+ run(s, reveal.spans, 2 * 4 + 12);
s.wait(t.beat);
// `frame up`: its rules (12 f), then its tag and strip (12 f).
lift(s, stack_chrome[1..4], 0, 12);
@@ -183,8 +215,7 @@ fn frame(s: *anim.Frame) void {
// II4: the registers built over the stack, a row at a time, their tag last.
asides.say(s, "The registers are the other place values live: seventeen of them.", left, rb.y + tag + pad + row * 2.5);
- s.play(.{ctx.registers.fadeIn()}, .{ .seconds = 0 });
- lift(s, &regs_rows, 12, 12);
+ lift(s, regs_rows[2..], 12, 12);
lift(s, regs_chrome[1..4], 0, 12);
lift(s, &.{regs_chrome[0]}, 0, 12);
// The chapter's last picture.