From 81d97a9e38c740a96af13a8a981878947a508bc0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 23:36:18 -0300 Subject: canim: quieter marks, the stack's roles, the loupe, arcs, the minimap, the map and the dive From the user's notes on the second videos. The current row is a white wash, a strike a softened vermilion, held a turned corner. A stack row has its offset from rsp and its role from the tracer (a saved register, a local by name, argc and argv). The loupe is the telescope as a floating panel: the memory round what a pointer leads to, a pointer inside it opening the next. A pointer to a row of its own panel is an arc in a lane, in dumps, loupes and the stack. Every scene has the minimap; the map is the same moment with every panel at full length on 3840 by 2160, and the list opens on it and dives to the working frame, each panel travelling to its place. Recordings hold more round each stop. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- anim/src/rows.zig | 174 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 143 insertions(+), 31 deletions(-) (limited to 'anim/src/rows.zig') diff --git a/anim/src/rows.zig b/anim/src/rows.zig index 8446b52..83064a6 100644 --- a/anim/src/rows.zig +++ b/anim/src/rows.zig @@ -44,8 +44,8 @@ pub fn baseline(y: f32) f32 { pub const Marks = struct { /// The first hop: a register (or a word) written: armed, struck, held. first: ui.Heat = .none, - /// A later hop, the memory under a pointer that did not change: its - /// tick sits before that hop alone. + /// A later hop, the memory under a pointer that did not change: the + /// turned corner sits on that hop alone. changed: ?usize = null, changed_heat: ui.Heat = .ember, /// A hop read, and how much its frame shows. @@ -56,9 +56,6 @@ pub const Marks = struct { extend: ?f32 = null, /// The first hop's `lead` (a column of addresses). lead: usize = 0, - /// Where the first hop's tick goes, left of its digits: 9 after a - /// name, 5 after an arrow. - tick: f32 = 9, }; /// Where a chain's hops were drawn: x and width of each one's digits. @@ -105,9 +102,9 @@ pub fn chain(u: ui.Ui, x: f32, y: f32, moment: Recording.Moment, value: u64, roo const marked: Rect = .{ .x = at, .y = y, .w = w, .h = row_h }; var face_ink: ui.Ink = .{ .ink = ui.rgb(if (pointer) ink(link.region) else t.primary) }; if (i == 0) { - if (v.written(marked, marks.first, marks.tick)) |struck| face_ink = struck; + if (v.written(marked, marks.first)) |struck| face_ink = struck; } else if (marks.changed == i) { - if (v.written(marked, marks.changed_heat, 5)) |struck| face_ink = struck; + if (v.written(marked, marks.changed_heat)) |struck| face_ink = struck; } if (marks.read == i) v.read(marked, marks.read_shows); if (pointer) { @@ -166,11 +163,12 @@ pub fn reg(u: ui.Ui, y: f32, w: f32, name: []const u8, moment: Recording.Moment, pub const Flag = struct { name: []const u8, bit: u6 }; pub const flags = [_]Flag{ .{ .name = "CF", .bit = 0 }, .{ .name = "PF", .bit = 2 }, .{ .name = "AF", .bit = 4 }, .{ .name = "ZF", .bit = 6 }, .{ .name = "SF", .bit = 7 }, .{ .name = "IF", .bit = 9 }, .{ .name = "DF", .bit = 10 }, .{ .name = "OF", .bit = 11 } }; -/// `reg` rip: gold plaque on the name, ember across, the address in +/// `reg` rip: gold plaque on the name, the wash across, the address in /// code's ink and its name; never struck. At its right end the `flags`, /// eight names on a pitch of 42: set, upper case on a chip, bold, bright; -/// clear, lower case, dim; changed, a tick (`changed`: a bit per flag, and -/// how held). The value of eflags is not drawn: the names are the value. +/// clear, lower case, dim; changed, a turned corner (`changed`: a bit per +/// flag, and how much of the corner shows). The value of eflags is not +/// drawn: the names are the value. pub fn rip(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, pc: u64, eflags: u64, changed: u64, held: f32, fire: f32) void { const gold = theme.mark(.current); u.current(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = row_h }, theme.metric.plaque.rip, fire); @@ -180,26 +178,37 @@ pub fn rip(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, pc: u64, eflags: _ = chain(u, m.chain_x, y, moment, pc, x - 16, .{}); for (flags) |flag| { const set = eflags >> flag.bit & 1 != 0; - if (changed >> flag.bit & 1 != 0 and held > 0) u.fill(.{ .x = x - 7, .y = y + 3, .w = m.tick, .h = row_h - 6 }, ui.mix(gold.ember, theme.mark(.write).solid, held)); if (set) { u.chip(.{ .x = x, .y = y + 2, .w = fl.chip[0], .h = fl.chip[1] }); u.text(.mono_bold, size, x + 4, baseline(y), flag.name, t.bright); } else u.text(.mono, size, x + 4, baseline(y), u.print("{c}{c}", .{ std.ascii.toLower(flag.name[0]), std.ascii.toLower(flag.name[1]) }), ui.mix(t.dim, gold.ember, 0.2)); + if (changed >> flag.bit & 1 != 0) u.corner(x, y + 2, m.corner, held); x += fl.pitch; } } -/// `slot`: a word of the stack: a lane 112 wide for `row` pins (`pins`, -/// the registers that hold its address), then its chain from 122, -/// beginning with the slot's own address in stack ink with `lead`, room -/// to 136 from the right edge `w` (the `call` spans'). -pub fn slot(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, addr: u64, pins: []const []const u8, pin_shows: f32, marks: Marks) Hops { +/// `slot`: a word of the stack: a lane to 112 for `row` pins (`pins`, the +/// registers that hold its address); its offset from rsp (`from_rsp` +/// bytes), hex, faint, ranged right to 172 (`+18`, `-8` above rsp); its +/// address in stack ink with `lead` from 184; then its chain, beginning +/// with the word it holds; and its `role` (what the word is, where the +/// recording knows it: `saved rbp` dim, a `local`'s name primary), ranged right where the room ends +/// (136 from the right edge `w`: the `call` spans'), the chain ending a +/// character before it. +pub fn slot(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, addr: u64, from_rsp: i64, pins: []const []const u8, pin_shows: f32, marks: Marks, role: []const u8, local: bool) Hops { const s = theme.metric.slot; if (pins.len > 0 and pin_shows > 0) u.faded(pin_shows).pinRow(s.lane, y, pins, theme.color.region.stack); + offset(u, y, from_rsp); var lead = marks; lead.first = .none; const base = baseline(y); - const end = u.address(s.chain, base, addr, .{ .ink = ui.rgb(theme.color.region.stack), .lead = marks.lead }); + const end = u.address(s.address, base, addr, .{ .ink = ui.rgb(theme.color.region.stack), .lead = marks.lead }); + var room = w - s.room; + if (role.len > 0) { + const rx = room - u.width(.mono, size, role); + u.text(.mono, size, rx, base, role, if (local) t.primary else t.dim); + room = rx - adv; + } const held = (Recording.word(moment, addr, 8) catch null) orelse { _ = u.arrow(end, y + row_h / 2, .points); u.unknown(.{ .x = end + m.arrow_w, .y = y, .w = 24, .h = row_h }); @@ -210,17 +219,23 @@ pub fn slot(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, addr: u64, pins: const at = u.arrow(end, y + row_h / 2, if (pointer) .points else .holds); lead.lead = 0; lead.first = marks.first; - lead.tick = 5; - return chain(u, at, y, moment, held, w - s.room, lead); + return chain(u, at, y, moment, held, room, lead); +} + +/// A slot's offset from rsp, `from_rsp` bytes: hex, faint, ranged right to 172. +fn offset(u: ui.Ui, y: f32, from_rsp: i64) void { + const text = if (from_rsp < 0) u.print("-{x}", .{@as(u64, @intCast(-from_rsp))}) else u.print("+{x}", .{@as(u64, @intCast(from_rsp))}); + u.text(.mono, size, theme.metric.slot.offset - u.width(.mono, size, text), baseline(y), text, t.faint); } /// `slot` `free`: a word above rsp the stack has not reached, shown while -/// the window is held for the camera: its address at 60%, its word -/// faint, no chain, no pin. -pub fn free(u: ui.Ui, y: f32, moment: Recording.Moment, addr: u64, lead: usize) void { +/// the window is held for the camera: its offset, its address at 60%, its +/// word faint, no chain, no pin. +pub fn free(u: ui.Ui, y: f32, moment: Recording.Moment, addr: u64, from_rsp: i64, lead: usize) void { const s = theme.metric.slot; const base = baseline(y); - const end = u.address(s.chain, base, addr, .{ .ink = ui.mix(theme.color.region.stack, theme.color.page, theme.metric.context.lead_alpha), .lead = lead }); + offset(u, y, from_rsp); + const end = u.address(s.address, base, addr, .{ .ink = ui.mix(theme.color.region.stack, theme.color.page, theme.metric.context.lead_alpha), .lead = lead }); const word = (Recording.word(moment, addr, 8) catch null) orelse return u.unknown(.{ .x = end + m.arrow_w, .y = y, .w = 24, .h = row_h }); u.text(.mono, size, end + m.arrow_w, base, u.print("{x}", .{word}), t.faint); } @@ -347,8 +362,8 @@ pub fn bytes(u: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *const [ } /// How far right of their column a dump's bytes (and its reading) go to -/// leave its widest address room: none for one of eight digits, 42 for a -/// stack address's twelve. A dump sets it once, so its rows keep one column. +/// leave its widest address room: none up to seven digits, 58 for a stack +/// address's twelve. A dump sets it once, so its rows keep one column. pub fn addressRoom(addr: u64) f32 { const b = theme.metric.bytes; return @max(b.address + @as(f32, @floatFromInt(ui.digits(addr))) * adv + adv - b.first, 0); @@ -367,22 +382,22 @@ pub fn bytesAt(at: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *cons const r: Rect = .{ .x = x0, .y = y + 1, .w = x1 - x0, .h = row_h - 2 }; const field = run.kind == .number or run.kind == .pointer or run.kind == .text; if (field) u.fill(r, theme.color.raised); - // Marks per run, never per byte: struck (the paper solid), read (a - // frame 3 out), held (a tick in the gap at the run's left). + // Marks per run, never per byte: struck (the softened paper, the + // digits bold and bright), read (a frame 3 out), held (a turned + // corner at the run's top left). var face: ui.Face = .mono; var struck_ink: ?ui.Color = null; const h = run.heat; - const held = h.level * (1 - (if (h.level >= 1) h.solid * h.in else 0)); - if (held > 0) u.fill(.{ .x = x0 - 7, .y = y + 3, .w = m.tick, .h = row_h - 6 }, ui.mix(theme.color.page, theme.mark(.write).solid, held)); if (h.arm > 0) u.faded(h.arm).frame(.{ .x = x0 - 3, .y = y - 1, .w = x1 - x0 + 6, .h = row_h + 2 }, theme.mark(.write).solid, 2); const solid = if (h.level >= 1) h.solid * h.in else 0; if (solid > 0) { - u.fill(.{ .x = r.x - h.out, .y = r.y - h.out, .w = r.w + 2 * h.out, .h = r.h + 2 * h.out }, ui.mix(theme.color.raised, theme.mark(.write).solid, solid)); + u.fill(.{ .x = r.x - h.out, .y = r.y - h.out, .w = r.w + 2 * h.out, .h = r.h + 2 * h.out }, ui.mix(theme.color.raised, theme.color.struck, solid)); if (solid >= 0.5) { face = .mono_bold; - struck_ink = ui.rgb(theme.mark(.write).on_solid); + struck_ink = ui.rgb(t.bright); } } + u.corner(x0, y + 2, m.corner, h.level * h.corner); if (run.read > 0) u.faded(run.read).frame(.{ .x = x0 - 3, .y = y - 1, .w = x1 - x0 + 6, .h = row_h + 2 }, theme.mark(.read).solid, 2); // A little-endian word: the bytes above its highest non-zero one are its padding. var top: usize = 0; @@ -416,3 +431,100 @@ pub fn byteX(i: u8) f32 { const b = theme.metric.bytes; return b.first + @as(f32, @floatFromInt(i)) * b.pitch + @as(f32, if (i >= 8) b.middle else 0); } + +/// `arc`s: the pointers of a panel of rows whose targets are rows of the +/// same panel, each drawn from its row along a lane at the panel's left +/// edge to the target's row, head first. A panel adds the pointers it +/// draws (`add`), then `draw`s them over its rows. +pub const Arcs = struct { + items: [32]Arc = undefined, + n: usize = 0, + + pub const Arc = struct { + /// The rows' tops: the pointer's, its target's (or the panel's + /// rule, for a `stub`: a target in the same region past the window). + from: f32 = 0, + to: f32 = 0, + ink: u24 = 0, + /// 0 standing, 1 full ink: the step writes or reads the pointer. + full: f32 = 0, + /// How much of it is drawn from its pointer (it draws head first), + /// and how much shows (it fades). + drawn: f32 = 1, + shows: f32 = 1, + dashed: bool = false, + stub: bool = false, + /// The step's: its lane comes first. + hot: bool = false, + }; + + pub fn add(a: *Arcs, arc: Arc) void { + if (a.n == a.items.len or arc.shows <= 0 or arc.from == arc.to) return; + a.items[a.n] = arc; + a.n += 1; + } + + /// Nested spans take separate lanes, the longest outermost; spans that + /// do not overlap share one; past `lanes` the step's come first, then + /// the shorter, and the rest are only read. + pub fn draw(a: *Arcs, u: ui.Ui, lanes: usize) void { + const k = theme.metric.arc; + const Span = struct { lo: f32, hi: f32, y0: f32, y1: f32, i: usize }; + var spans: [32]Span = undefined; + for (a.items[0..a.n], spans[0..a.n], 0..) |arc, *sp, i| { + const up = arc.to < arc.from; + const high: f32 = k.high; + const low: f32 = k.low; + sp.y0 = arc.from + if (up) high else low; + sp.y1 = if (arc.stub) arc.to else arc.to + if (up) low else high; + sp.lo = @min(sp.y0, sp.y1); + sp.hi = @max(sp.y0, sp.y1); + sp.i = i; + } + // The longest first, so it takes the outermost lane free. + std.mem.sort(Span, spans[0..a.n], {}, struct { + fn longer(_: void, x: Span, y: Span) bool { + return x.hi - x.lo > y.hi - y.lo; + } + }.longer); + var taken: [3][32][2]f32 = undefined; + var counts = [3]usize{ 0, 0, 0 }; + var lane_of: [32]?usize = @splat(null); + for ([_]bool{ true, false }) |hot| for (spans[0..a.n]) |sp| { + if (a.items[sp.i].hot != hot) continue; + lane_of[sp.i] = for (0..@min(lanes, 3)) |l| { + const clear = for (taken[l][0..counts[l]]) |t2| { + if (!(sp.hi < t2[0] or sp.lo > t2[1])) break false; + } else true; + if (clear) { + taken[l][counts[l]] = .{ sp.lo, sp.hi }; + counts[l] += 1; + break l; + } + } else null; + }; + for (spans[0..a.n]) |sp| { + const arc = a.items[sp.i]; + const lane = lane_of[sp.i] orelse continue; + const x = k.lanes[lane]; + const shade = ui.mix(arc.ink, theme.color.page, k.standing * (1 - std.math.clamp(arc.full, 0, 1))); + const v = u.faded(arc.shows); + if (arc.stub) { + v.route(&.{ .{ k.out, sp.y0 }, .{ x, sp.y0 }, .{ x, sp.y1 } }, shade, .{ .width = k.width, .head = k.head, .radius = k.radius, .progress = arc.drawn, .dashed = arc.dashed }); + } else v.route(&.{ .{ k.out, sp.y0 }, .{ x, sp.y0 }, .{ x, sp.y1 }, .{ k.in, sp.y1 } }, shade, .{ .width = k.width, .head = k.head, .radius = k.radius, .progress = arc.drawn, .dashed = arc.dashed }); + } + } +}; + +test "arcs of a chain share a lane; nested ones take the next" { + var a: Arcs = .{}; + // 1004090 -> 1004070 -> 1004050, rows 4, 2, 0: one lane. + a.add(.{ .from = 96, .to = 48, .ink = 0 }); + a.add(.{ .from = 48, .to = 0, .ink = 0 }); + // One across both: the outer lane. + a.add(.{ .from = 120, .to = 0, .ink = 0 }); + const k = theme.metric.arc; + const up_from = 96 + k.high; + const into = 48 + k.low; + try std.testing.expect(into < up_from and 48 + k.high < into); +} -- cgit v1.3