summaryrefslogtreecommitdiff
path: root/anim/scenes/intro_memory.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-12 04:45:57 -0300
committerGabriel Schneider <[email protected]>2026-11-12 07:03:05 -0300
commit4907e35bc45d12102d0e09380994814fc2e0a369 (patch)
tree7cfd90224653d73b63fbadaf2881fa0e6ba92860 /anim/scenes/intro_memory.zig
parentebdebe04a76f0302aeb24c1ac08fa9217b1a8257 (diff)
downloadcomputeranim-4907e35bc45d12102d0e09380994814fc2e0a369.tar.gz
computeranim-4907e35bc45d12102d0e09380994814fc2e0a369.zip
canim: the introduction, from the review
The introduction records the plain build (clang -O0, no instrumentation), so reverse's frame is the compiler's own push, mov and sub. The stack chapter says its convention once and keeps four free words over rsp so a push moves the pin and nothing else; reverse's rows stand under main's and are stepped, each touching its word, the call before the push, the aim drawn head first to the row it returns to. The close-up frames the bytes and the stack together with their 128 bytes marked. Nothing is named before it is shown; offsets are written in hex as the operands are; the dump folds into its tag; the map is announced before it is shown. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/scenes/intro_memory.zig')
-rw-r--r--anim/scenes/intro_memory.zig49
1 files changed, 32 insertions, 17 deletions
diff --git a/anim/scenes/intro_memory.zig b/anim/scenes/intro_memory.zig
index 7aec267..2dfda5e 100644
--- a/anim/scenes/intro_memory.zig
+++ b/anim/scenes/intro_memory.zig
@@ -8,7 +8,8 @@
//! made words (`regroup`); three of them addresses; then the address space
//! to scale in the program column (`segments`), each cluster enlarged, its
//! text beside it; back to the working frame, the dump tied to its place,
-//! a visit at x4, `ink`, and three chains.
+//! a visit at x2 framing the stack's box and the dump's top rows together
+//! (the place marked `128 bytes` on the box), `ink`, and three chains.
const std = @import("std");
const anim = @import("anim");
const canim = @import("canim");
@@ -45,7 +46,7 @@ fn frame(s: *anim.Frame) void {
const space = s.new(canim.Segments.init(s, rec, moment));
const dump = s.new(canim.Words.init(s, rec, moment));
- const place = s.new(canim.segments.Place{ .segments = space, .addr = rec.register(moment, "rsp"), .x = at.bracket, .y0 = at.top + 2, .y1 = at.top + 16 * 24 - 2, .clock = s.value(-1), .quiet = s.value(0) });
+ const place = s.new(canim.segments.Place{ .segments = space, .addr = rec.register(moment, "rsp"), .x = at.bracket, .y0 = at.top + 2, .y1 = at.top + 16 * 24 - 2, .clock = s.value(-1), .quiet = s.value(0), .tick = s.value(0) });
// `ink`'s echoes: the walked word's band first, then the rest at a run, 2 f apart.
const values = canim.Words.read(rec, moment);
@@ -64,8 +65,10 @@ fn frame(s: *anim.Frame) void {
const objs = .{ s.custom(space, .{ .x = -640, .y = -360, .scale = ui.scale }), s.custom(dump, .{ .x = -640, .y = -360, .scale = ui.scale }), s.custom(place, .{ .x = -640, .y = -360, .scale = ui.scale }) };
inline for (objs) |o| s.play(.{o.fadeIn()}, .{ .seconds = 0 });
- // The camera at x2 on the dump from the first frame (I1 to I3).
- const near = ui.framing(.{ .x = 888, .y = 72, .w = 896, .h = 408 }, 2);
+ // The camera at x2 on the dump from the first frame (I1 to I3), with the
+ // room over it that the walked word's bytes and offsets fly in, and its
+ // sixteen rows over the stage's foot.
+ const near = ui.framing(.{ .x = 888, .y = 66, .w = 896, .h = 408 }, 2);
var cam: canim.Camera = .{};
cam.moves[0] = .{ .from = near, .to = near, .p = s.value(1) };
cam.count = 1;
@@ -73,15 +76,20 @@ fn frame(s: *anim.Frame) void {
var says: canim.Narrator = .{};
var asides: canim.Asides = .{};
- // I1: the bytes, a row at a time.
+ // I1: the bytes, a row at a time (18 f apart), a text's lead (60 f) after it lands, not
+ // the first's 120: little "here" over an empty stage, and they come while it is read.
s.wait(1.0);
- says.line(s, "A running program is bytes in memory:\nhere, 128 of them at the top of the stack.");
- run(s, dump.in, 7 * 12 + 18);
+ const said_at = s.cursor;
+ says.line(s, "A running program is bytes in memory:\nhere are 128 of them.");
+ const lead_end = s.cursor;
+ s.cursor = said_at + t.caption_in + t.caption_lead;
+ run(s, dump.in, 7 * canim.regroup.rows_apart + 18);
+ s.cursor = @max(s.cursor, lead_end);
s.wait(t.beat);
// I2: eight a row; the return address walked, the other fifteen at a run.
says.line(s, "Eight bytes make a word, stored low byte first:\nthe lowest byte is its last two digits.");
- run(s, dump.regroup, 386);
+ run(s, dump.regroup, canim.regroup.regroup_frames);
s.wait(t.beat);
// I3: three words that hold addresses, framed as read.
@@ -94,7 +102,7 @@ fn frame(s: *anim.Frame) void {
says.current = canim.caption(s, "");
s.wait(t.caption_gap);
cam.back(s, .{});
- run(s, dump.fold, 30);
+ run(s, dump.fold, 48);
// Folded, the three frames go with the rows: unfolded, the dump is plain words again.
s.play(.{dump.framed.to(-1)}, .{ .seconds = 0 });
@@ -109,7 +117,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, then the libraries, 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 file 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));
@@ -125,21 +133,28 @@ fn frame(s: *anim.Frame) void {
// Back to the working frame: the texts leave, the drawing to the stage's height, the dump unfolds.
asides.leave(s);
s.play(.{space.form.to(1)}, .{ .seconds = f(24), .ease = anim.ease.linear });
- s.play(.{dump.fold.to(0)}, .{ .seconds = f(30), .ease = anim.ease.linear });
+ s.play(.{dump.fold.to(0)}, .{ .seconds = f(48), .ease = anim.ease.linear });
// I7: the dump's place: the tie bracket, the link onto the stack's box.
says.line(s, "These 128 bytes are here,\nat the very top of the stack.");
- s.play(.{dump.placed.to(1)}, .{ .seconds = f(12), .ease = anim.ease.linear });
- s.cursor -= f(12);
+ // The rows' addresses take the stack's ink as the link's head lands and its band is framed (42), 12 f.
+ const placing = s.cursor;
run(s, place.clock, 60);
+ const placed_at = s.cursor;
+ s.cursor = placing + f(42);
+ s.play(.{dump.placed.to(1)}, .{ .seconds = f(12), .ease = anim.ease.linear });
+ s.cursor = placed_at;
s.wait(t.beat);
// I8: a visit at x4 to where the link lands, and back.
says.line(s, "Were the bar the Eiffel Tower,\nthey would be an atom thick, at its top.");
+ // At x2: the stack's box with its names, the link, and the dump's top rows to a byte's edge,
+ // the place marked on the box (`128 bytes`), nothing cut at the frame's edge but the rows running on.
const landed = space.layout(1, s.arena);
- const head = canim.Segments.place(landed, place.addr) orelse .{ 0, 0 };
- cam.go(s, .{ .x = head[0] - 112, .y = 48, .w = 224, .h = 104 }, 4, .{});
- s.wait(t.beat);
+ cam.go(s, .{ .x = 280, .y = 44, .w = 960, .h = 448 }, 2, .{});
+ s.play(.{place.tick.?.to(1)}, .{ .seconds = f(12), .ease = anim.ease.linear });
+ s.wait(1.0);
+ s.play(.{place.tick.?.to(0)}, .{ .seconds = f(12), .ease = anim.ease.linear });
cam.back(s, .{});
// I9: `ink`: the return address walked, its band framed; the rest at a run; the link quiets.
@@ -164,7 +179,7 @@ fn frame(s: *anim.Frame) void {
s.wait(t.beat);
// I10: the words to their field's left, then three chains, walked.
- says.line(s, "Follow an address and you reach another word:\na chain.");
+ says.line(s, "Follow an address and you reach another word: a chain.\n`→` points to a word, `←` holds a value.");
run(s, dump.left, 24);
run(s, dump.chains, 36 * 2 + 30);
s.wait(t.beat);