diff options
Diffstat (limited to 'anim/src/context.zig')
| -rw-r--r-- | anim/src/context.zig | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/anim/src/context.zig b/anim/src/context.zig index 7d56c62..874a22a 100644 --- a/anim/src/context.zig +++ b/anim/src/context.zig @@ -391,7 +391,8 @@ pub fn frameBase(rec: *const Recording, i: u64, regs: zt.Regs) Base { /// `d` bytes from base `name` (`rbp-18`, `rbp+8`, `rbp`), as the stack's tag writes a range. fn fromBase(u: ui.Ui, name: []const u8, d: i64) []const u8 { - return if (d == 0) name else if (d > 0) u.print("{s}+{x}", .{ name, @as(u64, @intCast(d)) }) else u.print("{s}-{x}", .{ name, @as(u64, @intCast(-d)) }); + const p = rows.hexMark(@abs(d)); + return if (d == 0) name else if (d > 0) u.print("{s}+{s}{x}", .{ name, p, @as(u64, @intCast(d)) }) else u.print("{s}-{s}{x}", .{ name, p, @as(u64, @intCast(-d)) }); } /// A frame's span on the stack: its function's name, and as a call its @@ -472,15 +473,16 @@ pub const Stack = struct { /// The stack built a `column` at a time (design/README.md, 6. Verbs: /// `column`; motion.md, chapter II): each part a clock the scene plays /// (frames, negative before it begins), its rows coming in top down as - /// shown, 2 f apart, 12 f each; until then under the page. + /// shown, `apart` frames apart (2 by default), 12 f each; until then under the page. pub const Reveal = struct { offsets: anim.Value, roles: anim.Value, spans: anim.Value, + apart: f32 = 2, /// How much of row (or span) `k`'s part is still under the page, its clock at `clock`. - fn hidden(clock: f32, k: f32) f32 { - return 1 - std.math.clamp((clock - 2 * @max(k, 0)) / 12, 0, 1); + fn hidden(r: Reveal, clock: f32, k: f32) f32 { + return 1 - std.math.clamp((clock - r.apart * @max(k, 0)) / 12, 0, 1); } }; @@ -493,6 +495,8 @@ pub const Stack = struct { const slots = rowsOf(box); const is = (now.moment().regs(rec.tid) catch null) orelse return; const was = (now.before().regs(rec.tid) catch null) orelse is; + rows.prefixed = now.introduction; + defer rows.prefixed = false; // The window: from rsp, or further into the frame ([rsp, rbp+16)) // when that is longer than the panel, so that the word the last // steps touched is in its middle. When a step moves it the rows @@ -729,12 +733,12 @@ pub const Stack = struct { if (y + m.row < body.y or y > box.h) continue; const addr = window[0] +% @as(u64, @bitCast(n * 8)); // Not come in yet (`reveal`): the offset under the page (from past the pins to 172), the role with its row. - const hide_offset = if (k.reveal) |rv| Reveal.hidden(placed.value(rv.offsets), (y - top) / m.row) else 0; - const hide_role = if (k.reveal) |rv| Reveal.hidden(placed.value(rv.roles), (y - top) / m.row) else 0; + const hide_offset = if (k.reveal) |rv| rv.hidden(placed.value(rv.offsets), (y - top) / m.row) else 0; + const hide_role = if (k.reveal) |rv| rv.hidden(placed.value(rv.roles), (y - top) / m.row) else 0; // The page laid over them is opaque whatever the panel's own fade (a faded page over faded text leaves some). var page_u = u; page_u.at.pose.opacity = 1; - defer if (hide_offset > 0) page_u.faded(hide_offset).fill(.{ .x = 120, .y = y, .w = theme.metric.slot.offset + 4 - 120, .h = m.row }, theme.color.page); + defer if (hide_offset > 0) page_u.faded(hide_offset).fill(.{ .x = theme.metric.slot.lane_end, .y = y, .w = theme.metric.slot.offset + 4 - theme.metric.slot.lane_end, .h = m.row }, theme.color.page); // Who points here: a pin in the lane, landing with its link. const names = pins(u, now, is, was, addr, travel); var marks: rows.Marks = .{ .lead = lead, .first = now.writtenWatched(addr, 8, .memory, 0, watched_from, watched_to) }; @@ -744,10 +748,15 @@ pub const Stack = struct { marks.read = 0; marks.read_shows = now.reading(.memory, 0); } - // A word stored with the value it held (a `push rbp` over the old saved rbp): armed, and nothing struck. + // A word stored with the value it held (a `push rbp` over the old saved rbp): armed, and nothing struck; + // in the introduction struck as any write, its mark gone by the step's end (nothing remembers it). if (touched_here and touch.?.write and now.walking() and now.writeAge(addr, 8) != 0) { const s_at = now.plan.at[1]; - marks.first.arm = std.math.clamp((now.time - (s_at - time.strike.arm)) / time.stagger, 0, 1) * (1 - std.math.clamp((now.time - s_at) / time.quick, 0, 1)); + if (now.introduction) { + marks.first = now.heat(0, null, now.time - s_at); + marks.first.corner = 0; + marks.first.level *= 1 - std.math.clamp((now.time - now.plan.advance) / @max(now.plan.total - now.plan.advance, 1.0 / 60.0), 0, 1); + } else marks.first.arm = std.math.clamp((now.time - (s_at - time.strike.arm)) / time.stagger, 0, 1) * (1 - std.math.clamp((now.time - s_at) / time.quick, 0, 1)); } const below_rsp: i64 = if (tied) @bitCast(addr -% bases[1].value(is)) else @bitCast(addr -% if (held) rsp_shown else is.rsp); map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); @@ -792,7 +801,9 @@ pub const Stack = struct { const k_role = (addr -% roles_from) / 8; var role_at: [2]@TypeOf(roleName(u, .none, 0)) = undefined; for (&role_at, roles, [2]Recording.Moment{ now.before(), now.moment() }) |*r, of, mem| { - r.* = slotName(u, if (k_role < of.len) of[k_role] else .{}, (Recording.word(mem, addr, 8) catch null) orelse 1); + const slot_is: zt.telescope.Slot = if (k_role < of.len) of[k_role] else .{}; + // The introduction names the way back too (its caption's words: `return address` would cut `main+50`). + r.* = if (now.introduction and slot_is.role == .return_address) .{ .name = "the way back" } else slotName(u, slot_is, (Recording.word(mem, addr, 8) catch null) orelse 1); } const what: zt.telescope.Role = if (k_role < roles[1].len) roles[1][k_role].role else .none; const role = role_at[1]; @@ -870,7 +881,7 @@ pub const Stack = struct { // Rows crossed, counted on its whole way (its start may be off the window). const count = std.math.clamp(@ceil(goes(now, was, is, "rsp") * total_rows - 0.01), 1, total_rows); const bytes: u64 = @intFromFloat(count * 8); - pinAmount(u, x, top + place * m.row, names_, if (is.rsp < was.rsp) u.print("-{x}", .{bytes}) else u.print("+{x}", .{bytes}), amount_shows); + pinAmount(u, x, top + place * m.row, names_, u.print("{s}{s}{x}", .{ if (is.rsp < was.rsp) "-" else "+", rows.hexMark(bytes), bytes }), amount_shows); // The rows it crossed, a 3-unit vermilion bracket in the outer arc lane. if (crossed > 0.05) u.faded(amount_shows).bracket(theme.metric.arc.lanes[0], top + @min(place, old) * m.row + 2, top + @max(place, old) * m.row - 2, theme.mark(.write).solid, theme.metric.bracket.tie, 1, false); } else if (lone != null and joinsBefore(pins(u, now, is, was, is.named(name) orelse 0, travel).names, name)) { @@ -886,7 +897,7 @@ pub const Stack = struct { } else u.pinRow(x, top + place * m.row, names_, theme.color.region.stack); } for (spans[0..n_spans], 0..) |sp, i| if (sp.shows > 0) { - const sv = if (k.reveal) |rv| v.faded(1 - Reveal.hidden(placed.value(rv.spans), @floatFromInt(i))) else v; + const sv = if (k.reveal) |rv| v.faded(1 - rv.hidden(placed.value(rv.spans), @floatFromInt(i))) else v; if (sp.was) |was_name| { rows.span(sv.faded(1 - renamed), map.content(box.w), sp.y0, sp.y1, was_name, sp.newest, sp.open); rows.span(sv.faded(renamed), map.content(box.w), sp.y0, sp.y1, sp.name, sp.newest, sp.open); |
