summaryrefslogtreecommitdiff
path: root/anim/src/descent.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 20:08:07 -0300
committerGabriel Schneider <[email protected]>2026-11-11 21:45:12 -0300
commit15de88cf82c187635c1989e91bfa639a10304066 (patch)
tree16fa83854258c0c6aec1dff7f70ebabf5fd64c09 /anim/src/descent.zig
parent0ec2376cae2fdfc50e90d930ebc86c7a5b7f5594 (diff)
downloadcomputeranim-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/src/descent.zig')
-rw-r--r--anim/src/descent.zig37
1 files changed, 32 insertions, 5 deletions
diff --git a/anim/src/descent.zig b/anim/src/descent.zig
index 5dd156c..ff478df 100644
--- a/anim/src/descent.zig
+++ b/anim/src/descent.zig
@@ -59,15 +59,32 @@ pub fn step(cur: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void {
const b = rec.insn_branches[from] orelse return cur.walk(s, by, to);
var name_buf: [256]u8 = undefined;
const here = (rec.moment(from).string(rec.register(from, "rip"), &name_buf) catch null) orelse "";
+ // `tied`: the push or the read first, as any call's or return's (the touch, the word, rsp's pin, the
+ // window following: the stack's own timetable), then the windows, 42 f (a call) or 48 f (a return) later.
+ const tied = cur.levels.annotation == .tied;
const plan: cursors.Plan = switch (b.kind) {
- .call => .{ .at = .{ f(24), f(60), f(60) }, .advance = f(138), .travel = f(12), .total = f(174) },
- .ret => .{ .at = .{ f(36), f(18), f(36) }, .advance = f(114), .travel = f(12), .total = f(150) },
+ .call => if (tied) stacked(cur, from, to, f(180), f(216)) else .{ .at = .{ f(24), f(60), f(60) }, .advance = f(138), .travel = f(12), .total = f(174) },
+ .ret => if (tied) stacked(cur, from, to, f(162), f(198)) else .{ .at = .{ f(36), f(18), f(36) }, .advance = f(114), .travel = f(12), .total = f(150) },
.jump => if (std.mem.indexOf(u8, here, "@plt") != null) .{ .at = .{ f(18), f(24), f(24) }, .advance = f(96), .travel = f(12), .total = f(132) } else return cur.walk(s, by, to),
.none => return cur.walk(s, by, to),
};
cur.step(s, to, plan, plan.total);
}
+/// The key of the head row over function `name`'s window (a `ties.Place.row`).
+pub fn headKey(name: []const u8) u64 {
+ return std.hash.Wyhash.hash(0, name) | 1 << 63;
+}
+
+/// The stack's own timetable for the step (`Cursor.planned`), its advance and its end the descent's.
+fn stacked(cur: cursors.Cursor, from: u64, to: u64, advance: f32, total: f32) cursors.Plan {
+ var plan = cur.planned(from, to, false);
+ plan.advance = advance;
+ plan.travel = f(12);
+ plan.total = total;
+ return plan;
+}
+
/// A row of the panel.
const Item = struct {
key: u64,
@@ -110,9 +127,15 @@ pub const Descent = struct {
const after = layout(u, rec, now.stops[0], room, d.root);
// On the map its box is as long as the rows it has wanted: not 69 for a function of 30.
if (ui.mapping) map.measure(.disasm, @max(before.items.len, after.items.len));
- const tm = now.time;
const going = now.advancing();
const kind: enum { same, down, through, up } = if (now.resting() or now.stops[0] == now.stops[1]) .same else if (after.windows > before.windows) (if (before.in_stub) .through else .down) else if (after.windows < before.windows) .up else .same;
+ // `tied` (a plan with the stack's own moves, `stacked`): the windows move once the stack has, 42 f later down, 48 f up.
+ const shift: f32 = if (now.plan.follow < 0) 0 else switch (kind) {
+ .down => f(42),
+ .up => f(48),
+ .same, .through => 0,
+ };
+ const tm = now.time - shift;
const shown = if (going >= 0.5) after else before;
// A tag that changes with the advance crossfades over it.
const retag = !std.mem.eql(u8, before.tag, after.tag);
@@ -268,6 +291,7 @@ pub const Descent = struct {
last_window = p.item.window;
switch (p.item.what) {
.head => |h| {
+ ties.anchor(u, .{ .row = p.item.key }, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
v.fill(.{ .x = theme.stroke.rule, .y = y, .w = box.w - 2 * theme.stroke.rule, .h = theme.stroke.rule }, theme.color.rule);
v.text(.sans_medium, theme.size.sans.micro, c.address, y + 18, h.name, t.primary);
v.text(.sans, theme.size.sans.micro, map.content(box.w) - m.side - v.width(.sans, theme.size.sans.micro, h.note), y + 18, h.note, t.faint);
@@ -319,6 +343,7 @@ pub const Descent = struct {
covered = if (p.twin) @max(covered, hangs) else @max(covered -| 1, hangs);
last_line = line;
map.row(.disasm, row.addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
+ if (!p.twin) ties.anchor(u, .{ .row = row.addr }, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
},
}
}
@@ -348,7 +373,9 @@ pub const Descent = struct {
// Its strip is the deepest window's function's column, that window framed on it.
map.window(.disasm, deepest(after), deepest(before), cursors.glide(going));
if (pc_y[1] orelse pc_y[0]) |y| ties.anchor(u, .pc, .{ .x = 0, .y = y, .w = theme.metric.plaque.pc, .h = m.row });
- kernel(u, now, box, under orelse top + @as(f32, @floatFromInt(room -| 3)) * m.row, pc_y[0] orelse pc_y[1]);
+ const floor = under orelse top + @as(f32, @floatFromInt(room -| 3)) * m.row;
+ if (shown.kernel) ties.anchor(u, .floor, .{ .x = 0, .y = floor, .w = box.w, .h = m.row });
+ kernel(u, now, box, floor, pc_y[0] orelse pc_y[1]);
context.veiled(u, box, now.veil);
// Going down or up, the strip is another function's column: it fades through as the mark lands (24 f).
map.strip(.disasm, if (kind == .same) u else u.faded(map.through(now, now.plan.travel + f(12))), box);
@@ -513,7 +540,7 @@ fn layout(u: ui.Ui, rec: *const Recording, i: u64, room: usize, root: []const u8
row += 1;
}
if (li > 0) {
- items.append(a, .{ .key = std.hash.Wyhash.hash(0, l.name) | 1 << 63, .row = row, .window = window, .what = .{ .head = .{ .name = l.name, .note = headNote(u, rec, i, l) } } }) catch {};
+ items.append(a, .{ .key = headKey(l.name), .row = row, .window = window, .what = .{ .head = .{ .name = l.name, .note = headNote(u, rec, i, l) } } }) catch {};
row += 1;
}
const nearest = li + 2 == kept.len and l.kind == .caller;