summaryrefslogtreecommitdiff
path: root/anim/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 06:49:10 -0300
committerGabriel Schneider <[email protected]>2026-11-11 06:50:11 -0300
commit378379807fb4cd751e90808c8363caddb365bcd8 (patch)
treef84c7d0e7cbd42a9b9c93e791ab2b5376499d23d /anim/src
parent5922ee911b9a6604f60dc83be36ba9e6c9abac98 (diff)
downloadcomputeranim-378379807fb4cd751e90808c8363caddb365bcd8.tar.gz
computeranim-378379807fb4cd751e90808c8363caddb365bcd8.zip
canim: nothing changes in one frame; the map's space is used; the heap scene at its storyboard's length
The motion check counts a third of the one-frame changes it did: the minimap's changes fade, and a register's value, a flag, a role, a pin's names, a tag's note, a backtrace row, a call tree's node and a dump row crossfade where they changed at once. What still fires is named in the README; an encoder's keyframe and the gallery's cuts are exempt by name. No caption stands over twelve seconds or under its reading time. The heap scene is 78 s: what the storyboard does not narrate runs, and each free's line cascades onto its call row (line stepping stops at a breakpoint for that). On the map, leftover space holds the stack continued, dumps round what the registers and the stack point at, open loupes and the key: between 1% and 13% of a map is page, where it was 14% to 42%. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/src')
-rw-r--r--anim/src/array.zig9
-rw-r--r--anim/src/calls.zig61
-rw-r--r--anim/src/context.zig198
-rw-r--r--anim/src/cursor.zig95
-rw-r--r--anim/src/descent.zig12
-rw-r--r--anim/src/disasm.zig16
-rw-r--r--anim/src/hexdump.zig24
-rw-r--r--anim/src/loupe.zig15
-rw-r--r--anim/src/map.zig360
-rw-r--r--anim/src/nodes.zig18
-rw-r--r--anim/src/root.zig6
-rw-r--r--anim/src/rows.zig114
-rw-r--r--anim/src/source.zig56
-rw-r--r--anim/src/stage.zig2
-rw-r--r--anim/src/theme.zig9
-rw-r--r--anim/src/ties.zig9
-rw-r--r--anim/src/words.zig1
17 files changed, 788 insertions, 217 deletions
diff --git a/anim/src/array.zig b/anim/src/array.zig
index 8bb0a52..8d53fb8 100644
--- a/anim/src/array.zig
+++ b/anim/src/array.zig
@@ -81,7 +81,7 @@ pub const Array = struct {
const dump = hexdump.panel(f, at, g.stage, u.print("{x} to {x}, an element a run", .{ v.addr, v.addr + v.size - 1 }), &.{});
const rows_n = @min(dump.rows, (v.addr + v.size - first + 15) / 16);
if (rows_n > 0) hexdump.draw(dump.u, now, 0, m.tag + m.pad, first, rows_n, .{ .array = .{ .addr = v.addr, .len = v.size, .elem = @intCast(elem), .type = elem_type }, .region = context.ink(context.regionOf(moment, v.addr)) });
- if (rows_n > 0) @import("map.zig").window(.view, first, first + 16 * (rows_n - 1));
+ if (rows_n > 0) @import("map.zig").window(.view, .{ first, first + 16 * (rows_n - 1) }, .{ first, first + 16 * (rows_n - 1) }, 1);
dump.veil(now);
u.clip(.{ .x = 0, .y = 0, .w = box.w, .h = box.h });
}
@@ -211,6 +211,8 @@ pub const Array = struct {
ties.anchor(u, .{ .node_pin = addr }, .{ .x = cx - 1, .y = top + cell[1], .w = 2, .h = label + 10 });
const indices = names.items.len;
var shows: f32 = 1;
+ // A register joining or leaving: the names cross the middle of its change faded out (`Nodes.Pins.text`).
+ var text: f32 = 1;
for (theme.metric.all_registers[0..16]) |name| {
const i = context.index(name).?;
const before = was_regs.named(name) == addr;
@@ -218,6 +220,7 @@ pub const Array = struct {
if (!before and !after) continue;
const s = ties.pinShows(now, i, .node);
const this = if (before and after) 1 else if (after) s.new else s.old;
+ if (before != after and indices > 0) text = @min(text, @abs(2 * this - 1));
if (this < 0.5) continue;
names.append(f.scratch, name) catch {};
if (indices == 0) shows = @min(shows, this);
@@ -229,7 +232,9 @@ pub const Array = struct {
// An index lives on the stack: its name in stack's ink; a register's primary.
var inks: [8]u24 = @splat(t.primary);
for (inks[0..@min(indices, inks.len)]) |*i_ink| i_ink.* = theme.color.region.stack;
- u.faded(shows * ties.rise(rising, k, count).element).pinUnderInked(x, top + cell[1], names.items, inks[0..@min(names.items.len, inks.len)], if (names.items.len > indices) ink else t.primary, label);
+ const pv = u.faded(shows * ties.rise(rising, k, count).element);
+ pv.pinUnderInked(x, top + cell[1], &.{}, &.{}, if (names.items.len > indices) ink else t.primary, label);
+ pv.faded(text).pinNames(x, top + cell[1], names.items, inks[0..@min(names.items.len, inks.len)], label);
}
}
diff --git a/anim/src/calls.zig b/anim/src/calls.zig
index 4a669f3..9c3df04 100644
--- a/anim/src/calls.zig
+++ b/anim/src/calls.zig
@@ -92,6 +92,17 @@ pub const Tree = struct {
u.line(from, to, if (live or n.call.enter > moment) ui.rgb(t.primary) else ui.rgb(theme.color.rule), theme.stroke.line);
}
const deepest = deepestActive(nodes, moment);
+ // A node's look before the step: one that changes (the gold going on
+ // to the new call, a ring to done) crossfades as the new one comes in.
+ const deepest_was = deepestActive(nodes, now.stops[1]);
+ // From the frame the tree's moment changes (a return's, its badge's).
+ const turned = if (now.plan.gait == .sprint) appears else std.math.clamp((since - (if (returned) @as(f32, time.badge_after) else 0)) / time.snap, 0, 1);
+ const Look = enum { gold, ring, done };
+ const look = struct {
+ fn of(n: Node, i: usize, at_moment: u64, deep: ?usize) Look {
+ return if (deep == i) .gold else if (n.call.active(at_moment)) .ring else .done;
+ }
+ }.of;
for (nodes, 0..) |n, i| {
const c = at_of(left, pitch, top, n);
// Where a projection from its frame's way back (the word its
@@ -99,12 +110,11 @@ pub const Tree = struct {
// there before the node, which comes when it arrives.
if (n.call.enter <= now.stops[0]) ties.anchor(u, .{ .node_address = n.call.sp }, .{ .x = c[0] - m.radius, .y = c[1] - m.radius, .w = 2 * m.radius, .h = 2 * m.radius });
if (n.call.enter > moment) continue;
- const v = if (n.call.enter > now.stops[1]) u.faded(appears) else u;
- if (deepest == i) {
- v.disc(c, m.radius, ui.rgb(theme.mark(.current).solid), null, 0);
- } else if (n.call.active(moment)) {
- v.disc(c, m.radius - theme.stroke.line / 2, ui.rgb(theme.color.page), ui.rgb(t.primary), theme.stroke.line);
- } else v.disc(c, m.radius, ui.rgb(theme.color.raised), null, 0);
+ const is = look(n, i, moment, deepest);
+ const was = if (n.call.enter > now.stops[1]) is else look(n, i, now.stops[1], deepest_was);
+ const shows = if (n.call.enter > now.stops[1]) appears else if (was != is) turned else 1;
+ if (was != is) disc(u.faded(1 - shows), c, was);
+ disc(u.faded(shows), c, is);
}
// Then the words, so shapes and text each go in one run.
const size = theme.size.mono.small;
@@ -114,10 +124,15 @@ pub const Tree = struct {
const active = n.call.active(moment);
const words = if (n.call.arg) |arg| u.print("{d}", .{@as(i64, @bitCast(arg))}) else "?";
const cell: Rect = .{ .x = c[0] - m.radius, .y = c[1] - m.radius, .w = 2 * m.radius, .h = 2 * m.radius };
- const v = if (n.call.enter > now.stops[1]) u.faded(appears) else u;
- if (deepest == i) {
- v.label(.mono_bold, size, cell, .center, words, theme.mark(.current).on_solid);
- } else v.label(.mono, size, cell, .center, words, t.primary);
+ const is = look(n, i, moment, deepest) == .gold;
+ const was = n.call.enter <= now.stops[1] and look(n, i, now.stops[1], deepest_was) == .gold;
+ const shows = if (n.call.enter > now.stops[1]) appears else if (was != is) turned else 1;
+ for ([2]bool{ was, is }, [2]f32{ if (was != is) 1 - shows else 0, shows }) |gold, amount| {
+ if (amount <= 0) continue;
+ if (gold) {
+ u.faded(amount).label(.mono_bold, size, cell, .center, words, theme.mark(.current).on_solid);
+ } else u.faded(amount).label(.mono, size, cell, .center, words, t.primary);
+ }
if (active) continue;
// Done: what it returned, on its shoulder; struck as it lands.
const badge: Rect = .{ .x = c[0] + m.badge_at[0], .y = c[1] - m.badge_at[1], .w = m.badge, .h = m.badge };
@@ -139,26 +154,22 @@ pub const Tree = struct {
u.clip(.{ .x = 0, .y = 0, .w = box.w, .h = box.h });
defer u.unclip();
const now = k.cursor.now(at);
- const rec = k.cursor.rec;
- // A frame is its words on the stack: the view changes with memory.
- const moment = now.stop(.memory);
- var buf: [24]context.Frame = undefined;
- const chain = context.frames(rec, moment, &buf);
- const room = theme.layout.rowsIn(box.h);
- const body = u.panel(box.w, box.h, "backtrace", .{ .note = u.print("the calls waiting \u{00b7} {s}", .{context.newestAtBottom(u, chain.len, room)}) });
- const open = rec.stack(f.scratch, moment);
// Newest at the bottom, as the tree grows down beside it; the oldest go from the top.
- const shown = @min(chain.len, room);
- for (chain[0..shown], 0..) |frame, i| {
- const y = body.y + cm.pad + @as(f32, @floatFromInt(shown - 1 - i)) * cm.row;
- const name = ui.symbol(u, rec.strings.get(frame.pc) orelse u.print("{x}", .{frame.pc}));
- // The call this frame is, by its place on the chain: its arguments.
- rows.callRow(u, y, box.w, i, name, context.callArguments(u, rec, open, i, frame.pc), context.frameWhere(u, rec, now.marked(), i, frame.pc), i == 0);
- }
+ context.backtraceRows(u, now, k.cursor.rec, box, false, "the calls waiting \u{00b7} ");
context.veiled(u, box, now.sprint_veil);
}
};
+/// A node of the tree as it looks: the deepest call gold, one waiting ringed, one done raised.
+fn disc(u: ui.Ui, c: ui.Vec, look: anytype) void {
+ const m = metric;
+ switch (look) {
+ .gold => u.disc(c, m.radius, ui.rgb(theme.mark(.current).solid), null, 0),
+ .ring => u.disc(c, m.radius - theme.stroke.line / 2, ui.rgb(theme.color.page), ui.rgb(t.primary), theme.stroke.line),
+ .done => u.disc(c, m.radius, ui.rgb(theme.color.raised), null, 0),
+ }
+}
+
/// A call's arguments as its backtrace row and its span say them: its
/// parameter's name and value, `n=4`; "" for one that takes nothing.
pub fn arguments(u: ui.Ui, rec: *const Recording, c: Recording.Call) []const u8 {
diff --git a/anim/src/context.zig b/anim/src/context.zig
index f551aa8..37a95a6 100644
--- a/anim/src/context.zig
+++ b/anim/src/context.zig
@@ -62,6 +62,8 @@ pub fn at(f: *sk.Frame, placed: anim.Placed, box: Rect) ui.Ui {
ui.chrome = zz.chrome;
return u;
};
+ // Looking at the map alone (`map.looking`): the working panels stand aside.
+ if (!ui.mapping and map.looking(f)) p.pose.opacity = 0;
return (ui.Ui{ .f = f, .at = p }).moved(box.x, box.y);
}
@@ -126,12 +128,10 @@ pub const Registers = struct {
/// disassembly's; it moves with them, at the advance.
fn rip(r: *const Registers, u: ui.Ui, now: cursors.Now, y: f32, w: f32, is: Shown, was: Shown) void {
const rec = r.cursor.rec;
- const moment = now.marks[if (now.advancing() >= 0.5) 1 else 0];
// The flags' corners are secondary: 6 f after the registers strike,
// not with them; in a continue's wave, in its place after r15.
const delay = if (now.plan.wave) ties.strikeDelay(now, index("eflags").?) else cursors.write_apart;
const landed = now.landed(.cpu, delay);
- const flags = (if (landed) is else was).regs.eflags;
// The flags a step changed have a turned corner, for three steps.
const eflags_index = comptime index("eflags").?;
// Until this step's change lands, the corners are the last one's: no effect before its cause.
@@ -142,7 +142,9 @@ pub const Registers = struct {
const held = if (r.quiet) 0 else heat.level * heat.corner;
// While a conditional jump runs, the flags it reads are framed (an echo of the row that set them).
const reads: u64 = if (now.resting() or now.advancing() >= 0.5) 0 else @import("disasm.zig").readsFlags(rec, now.stops[1]);
- rows.rip(u, y, w, rec.moment(moment), rec.register(moment, "rip"), flags, changed, held, 0, reads, now.reading(.cpu, 0));
+ // rip crossfades with the advance; a flag set or cleared, over the 6 f it lands in.
+ const flip = std.math.clamp(now.since(.cpu, delay) / time.strike.in, 0, 1);
+ rows.rip(u, y, w, rec.moment(now.marks[1]), rec.register(now.marks[1], "rip"), is.regs.eflags, changed, held, 0, reads, now.reading(.cpu, 0), .{ .moment = rec.moment(now.marks[0]), .pc = rec.register(now.marks[0], "rip"), .eflags = was.regs.eflags, .going = now.advancing(), .flip = if (now.resting()) 1 else flip });
}
fn row(r: *const Registers, u: ui.Ui, now: cursors.Now, line_is: Shown, line_was: Shown, name: []const u8, y: f32, w: f32) void {
@@ -205,7 +207,10 @@ pub const Registers = struct {
const since = now.since(.cpu, delay);
if (age == 0 and now.walking() and since >= 0) marks.extend = since;
}
- const hops = rows.reg(u, y, w, name, if (landed) is.moment else was.moment, if (landed) value_now else value_was, marks);
+ // At a run a value changes in place under an 8 f crossfade, unmarked, never in a frame.
+ const ran = runFade(now, .cpu);
+ if (ran < 1 and value_was != value_now) _ = rows.reg(u.faded(1 - ran), y, w, name, was.moment, value_was, marks);
+ const hops = rows.reg(if (ran < 1 and value_was != value_now) u.faded(ran) else u, y, w, name, if (landed or ran < 1) is.moment else was.moment, if (landed or ran < 1) value_now else value_was, marks);
fdNote(u, hops, y, note);
anchor(u, i, hops, y);
}
@@ -220,6 +225,12 @@ pub const Registers = struct {
}
};
+/// How far (0 to 1) a run's step has crossfaded its values at `level` (8 f from it); 1 at any other pace.
+fn runFade(now: cursors.Now, level: cursors.Level) f32 {
+ if (now.plan.gait != .run or now.resting()) return 1;
+ return std.math.clamp(now.since(level, 0) / time.run_ease, 0, 1);
+}
+
/// A register's place in `Regs.names`.
pub fn index(name: []const u8) ?usize {
for (zt.Regs.names, 0..) |known, i| if (std.mem.eql(u8, known, name)) return i;
@@ -340,6 +351,8 @@ pub const Stack = struct {
// each with the memory of its own stop.
const landed = now.landed(.memory, 0);
const jumped = far(window[0], window[1], slots);
+ // On the minimap the window glides there, whether it scrolls or fades here.
+ const ways = window;
const since_memory = now.since(.memory, 0);
const jump_shows: f32 = if (!jumped or now.resting()) 1 else if (!landed) 1 - std.math.clamp((since_memory + time.quick) / time.quick, 0, 1) else std.math.clamp((since_memory - time.strike.in / 2.0) / time.quick, 0, 1);
if (jumped) window = if (landed) .{ window[0], window[0] } else .{ window[1], window[1] };
@@ -350,7 +363,6 @@ pub const Stack = struct {
const hold_scroll: f32 = if (held) @as(f32, @floatFromInt(@as(i64, @bitCast(held_at -% natural)))) / 8 * (1 - cursors.glide(placed.value(k.stage.hold_in))) else 0;
// From rsp, or the range shown when the window is elsewhere: in
// bytes from rsp, as the catalogue writes it (`rsp+20 to rsp+48`).
- const from_rsp: i64 = if (landed) @bitCast(window[0] -% is.rsp) else @bitCast(window[1] -% was.rsp);
const offset = struct {
fn of(u_: ui.Ui, d: i64) []const u8 {
return if (d == 0) "rsp" else if (d > 0) u_.print("rsp+{x}", .{@as(u64, @intCast(d))}) else u_.print("rsp-{x}", .{@as(u64, @intCast(-d))});
@@ -363,8 +375,20 @@ pub const Stack = struct {
else => u.print("{d}", .{slots}),
};
// The first word shown and the last.
- const range = if (from_rsp == 0) u.print("{s} words from rsp", .{words}) else u.print("{s} to {s}", .{ offset(u, from_rsp), offset(u, from_rsp + 8 * (@as(i64, @intCast(slots)) - 1)) });
- const body = u.panel(box.w, box.h, if (k.part == .more) "stack, continued" else "stack", .{ .focus = k.focus, .note = u.print("{s} \u{00b7} the frames they belong to", .{range}) });
+ // The range before memory lands and after: one that changes crossfades (12 f), as a role does.
+ const recast = if (now.resting()) 1 else std.math.clamp(since_memory / time.quick, 0, 1);
+ const ranges = [2]i64{ @bitCast(ways[1] -% was.rsp), @bitCast(ways[0] -% is.rsp) };
+ var notes: [2][]const u8 = undefined;
+ for (ranges, &notes) |r_, *note| {
+ const range = if (r_ == 0) u.print("{s} words from rsp", .{words}) else u.print("{s} to {s}", .{ offset(u, r_), offset(u, r_ + 8 * (@as(i64, @intCast(slots)) - 1)) });
+ note.* = u.print("{s} \u{00b7} the frames they belong to", .{range});
+ }
+ const renote = !std.mem.eql(u8, notes[0], notes[1]) and recast < 1;
+ const body = u.panel(box.w, box.h, if (k.part == .more) "stack, continued" else "stack", .{ .focus = k.focus, .note = if (renote) "" else notes[1] });
+ if (renote) {
+ u.faded(1 - recast).tagNote(box.w, notes[0]);
+ u.faded(recast).tagNote(box.w, notes[1]);
+ }
const p = cursors.glide(now.moving(.memory, 0, time.move));
const moved = @as(f32, @floatFromInt(@as(i64, @bitCast(window[0] -% window[1])))) / 8;
const slide: f32 = (if (jumped) 0 else moved * (1 - p)) + hold_scroll;
@@ -408,7 +432,7 @@ pub const Stack = struct {
}.at;
const Span = struct { y0: f32, y1: f32, name: []const u8, newest: bool, open: bool, was: ?[]const u8 = null };
// A frame whose name changes in place (on through a stub) crossfades over the 12 f before the advance.
- const renamed = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1);
+ const renamed = now.renaming();
const calls_was = rec.stack(u.f.scratch, now.stops[1]);
const calls_is = rec.stack(u.f.scratch, now.stops[0]);
var spans: [16]Span = undefined;
@@ -453,8 +477,12 @@ pub const Stack = struct {
// What each word is, where the recording says (`zt.telescope.slots`):
// a register saved for the caller, a local, the process's first stack.
const roles_from = window[0] -% 16;
- var roles_buf: [80]zt.telescope.Slot = undefined;
- const roles = zt.telescope.slots(memory, if (landed) &is else &was, roles_from, roles_buf[0..@min(slots + 4, roles_buf.len)]) catch roles_buf[0..0];
+ // Before the step and after it: a role that changes crossfades as memory strikes (12 f).
+ var roles_buf: [2][80]zt.telescope.Slot = undefined;
+ const roles = [2][]zt.telescope.Slot{
+ zt.telescope.slots(now.before(), &was, roles_from, roles_buf[0][0..@min(slots + 4, roles_buf[0].len)]) catch roles_buf[0][0..0],
+ zt.telescope.slots(now.moment(), &is, roles_from, roles_buf[1][0..@min(slots + 4, roles_buf[1].len)]) catch roles_buf[1][0..0],
+ };
// The words that point at other words of the window: `arc`s.
var at_rows: std.ArrayList(hexdump.RowAt) = .empty;
var pointers: std.ArrayList(struct { hexdump.RowAt, bool }) = .empty;
@@ -470,8 +498,8 @@ pub const Stack = struct {
marks.read = 0;
marks.read_shows = now.reading(.memory, 0);
}
- const below_rsp: i64 = @bitCast(addr -% rsp_shown);
- if (k.part == .stack) map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
+ const below_rsp: i64 = @bitCast(addr -% if (held) rsp_shown else is.rsp);
+ map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
// `free`: above rsp, not yet reached: its address at 60%, its word faint.
if (held and addr < rsp_shown) {
rows.free(v, y, memory, addr, below_rsp, lead);
@@ -492,9 +520,21 @@ pub const Stack = struct {
const gapped = gap > 0 and names.names.len > 0 and names.shows > 0;
if (gapped) pinGap(v.faded(names.shows), y, names.names, lone.?, gap);
const k_role = (addr -% roles_from) / 8;
- const what: zt.telescope.Role = if (k_role < roles.len) roles[k_role].role else .none;
- const role = roleName(u, what, (Recording.word(memory, addr, 8) catch null) orelse 1);
- const hops = rows.slot(v, y, room_w, now.shownAt(addr), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local);
+ var role_at: [2]@TypeOf(roleName(u, .none, 0)) = undefined;
+ for (&role_at, roles, [2]Recording.Moment{ now.before(), now.moment() }) |*r, of, mem| {
+ const what: zt.telescope.Role = if (k_role < of.len) of[k_role].role else .none;
+ r.* = roleName(u, what, (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];
+ const role_was: rows.Role = .{ .name = role_at[0].name, .local = role_at[0].local, .going = recast, .from_rsp = @bitCast(addr -% was.rsp) };
+ // At a run a word changes in place under an 8 f crossfade, as a register does.
+ const ran = runFade(now, .memory);
+ const word_was = Recording.word(now.before(), addr, 8) catch null;
+ const word_is = Recording.word(now.moment(), addr, 8) catch null;
+ const fades = ran < 1 and !std.meta.eql(word_was, word_is);
+ if (fades) _ = rows.slot(v.faded(1 - ran), y, room_w, now.before(), addr, below_rsp, &.{}, 0, marks, role.name, role.local, role_was);
+ const hops = rows.slot(if (fades) v.faded(ran) else v, y, room_w, if (fades) now.moment() else now.shownAt(addr), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local, role_was);
at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {};
pointers.append(u.f.scratch, .{ .{ .addr = addr, .y = y }, what == .saved and std.mem.eql(u8, what.saved, "rbp") }) catch {};
// Only a row on show is a place a tie can land.
@@ -503,13 +543,16 @@ pub const Stack = struct {
ties.anchor(u, .{ .slot_pin = addr }, .{ .x = theme.metric.slot.lane, .y = y, .w = theme.metric.slot.lane_end - theme.metric.slot.lane, .h = m.row });
}
}
- map.window(.stack, shown_at, shown_at + 8 * (@as(u64, slots) -| 1));
+ if (k.part == .stack) map.window(.stack, .{ ways[0], ways[0] + 8 * (@as(u64, slots) -| 1) }, .{ ways[1], ways[1] + 8 * (@as(u64, slots) -| 1) }, p);
// A frame's saved rbp is drawn by its span: its arc only in a step that touches it.
var arcs: rows.Arcs = .{};
for (pointers.items) |p_| {
const word, const saved = p_;
if (saved and !(now.writeAge(word.addr, 8) == 0 or now.wasRead(word.addr, 8))) continue;
+ const before = arcs.n;
hexdump.pointerArcs(&arcs, now, word.addr, word.y, at_rows.items, 8, .{ top - m.pad, box.h - m.pad }, false, false);
+ // Its step's alone: it goes with the advance (18 f), not in the next step's first frame.
+ if (saved and arcs.n > before) arcs.items[before].shows *= 1 - std.math.clamp((now.time - now.plan.advance) / time.read.out, 0, 1);
}
arcs.draw(v, theme.metric.arc.stack_lanes);
// Where the window is, for a link to a word outside it.
@@ -666,59 +709,84 @@ pub const Backtrace = struct {
if (box.h < m.tag) return;
const u = if (b.lens) at(f, placed, box).faded(placed.value(b.stage.drawing)) else at(f, placed, box);
const now = b.cursor.now(placed);
- const rec = b.cursor.rec;
- // A frame is its words on the stack: the chain changes with memory.
- // The frames both chains have (the same way back, counted from the
- // oldest) slide to their new depth, as rows making room; those that
- // end fade out first, those that begin fade in after.
- var new_buf: [24]Frame = undefined;
- var old_buf: [24]Frame = undefined;
- const chains = [2][]Frame{ frames(rec, now.stops[1], &old_buf), frames(rec, now.stops[0], &new_buf) };
- var shared: usize = 0;
- while (shared < @min(chains[0].len, chains[1].len) and chains[0][chains[0].len - 1 - shared].pc == chains[1][chains[1].len - 1 - shared].pc) shared += 1;
- const since = if (now.walking()) now.since(.memory, 0) else if (now.landed(.memory, 0)) std.math.inf(f32) else -std.math.inf(f32);
- const leave = std.math.clamp(since / time.quick, 0, 1);
- const slide = cursors.glide(std.math.clamp((since - time.quick / 2.0) / time.move, 0, 1));
- const arrive = std.math.clamp((since - time.quick / 2.0 - time.move) / time.quick, 0, 1);
- const room = rowsOf(box);
- const total = chains[if (slide >= 0.5) 1 else 0].len;
- map.measure(.backtrace, @max(chains[0].len, chains[1].len));
- const body = u.panel(box.w, box.h, "backtrace", .{ .focus = b.focus, .note = newestAtBottom(u, total, room) });
- clipBody(u, box);
- defer u.unclip();
- const opens = [2][]const Recording.Call{ rec.stack(u.f.scratch, now.stops[1]), rec.stack(u.f.scratch, now.stops[0]) };
- const top = body.y + m.pad;
- // Newest at the bottom, `#0` last: a frame's row is its place from
- // the oldest, less the oldest that do not fit (dropped from the top).
- const dropped = [2]usize{ chains[0].len -| room, chains[1].len -| room };
- for (chains, 0..) |chain, side| {
- const shows = if (side == 0) 1 - leave else arrive;
- for (chain, 0..) |frame, i| {
- const from_end = chain.len - 1 - i;
- const kept = from_end < shared;
- // A frame both have is drawn once, from the old chain to its place in the new.
- if (kept and side == 1) continue;
- var at_row = @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[side]));
- var depth = i;
- var which = side;
- if (kept) {
- const to = chains[1].len - 1 - from_end;
- at_row = std.math.lerp(at_row, @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[1])), slide);
- if (slide >= 0.5) {
- depth = to;
- which = 1;
- }
- } else if (shows <= 0) continue;
- if (at_row <= -1 or at_row >= @as(f32, @floatFromInt(room))) continue;
- const v = if (kept) u else u.faded(shows);
- const name = ui.symbol(u, rec.strings.get(frame.pc) orelse u.print("{x}", .{frame.pc}));
- rows.callRow(v, top + at_row * m.row, box.w, depth, name, callArguments(u, rec, opens[which], depth, frame.pc), frameWhere(u, rec, if (which == 1) now.marks[1] else now.marks[0], depth, frame.pc), depth == 0);
- }
- }
+ backtraceRows(u, now, b.cursor.rec, box, b.focus, "");
veiled(u, box, now.veil);
}
};
+/// A backtrace's panel and rows in `u`'s `box` (the panel, a lens's
+/// drawing, the calls lens's view: its tag's note after `prefix`).
+/// A frame is its words on the stack: the chain changes with memory. The
+/// frames both chains have (the same way back, counted from the oldest)
+/// slide to their new depth, as rows making room; those that end fade out
+/// first, those that begin fade in after. What a kept row says that
+/// changes (its depth, its pc's offset, its line) crossfades over the 12 f
+/// before the advance, as a stack span's name does; the newest's wash goes
+/// from one row to the other the same way. Nothing changes in a frame.
+pub fn backtraceRows(u: ui.Ui, now: cursors.Now, rec: *const Recording, box: Rect, focus: bool, prefix: []const u8) void {
+ var new_buf: [24]Frame = undefined;
+ var old_buf: [24]Frame = undefined;
+ const chains = [2][]Frame{ frames(rec, now.stops[1], &old_buf), frames(rec, now.stops[0], &new_buf) };
+ var shared: usize = 0;
+ while (shared < @min(chains[0].len, chains[1].len) and chains[0][chains[0].len - 1 - shared].pc == chains[1][chains[1].len - 1 - shared].pc) shared += 1;
+ // The newest frame's pc is the step's: it is the same frame whatever its offset.
+ if (shared < @min(chains[0].len, chains[1].len) and chains[0].len == chains[1].len and shared + 1 == chains[0].len) shared += 1;
+ const since = if (now.walking()) now.since(.memory, 0) else if (now.landed(.memory, 0)) std.math.inf(f32) else -std.math.inf(f32);
+ const leave = std.math.clamp(since / time.quick, 0, 1);
+ const slide = cursors.glide(std.math.clamp((since - time.quick / 2.0) / time.move, 0, 1));
+ const arrive = std.math.clamp((since - time.quick / 2.0 - time.move) / time.quick, 0, 1);
+ const renamed = now.renaming();
+ const room = rowsOf(box);
+ map.measure(.backtrace, @max(chains[0].len, chains[1].len));
+ const notes = [2][]const u8{ u.print("{s}{s}", .{ prefix, newestAtBottom(u, chains[0].len, room) }), u.print("{s}{s}", .{ prefix, newestAtBottom(u, chains[1].len, room) }) };
+ const renote = !std.mem.eql(u8, notes[0], notes[1]);
+ const body = u.panel(box.w, box.h, "backtrace", .{ .focus = focus, .note = if (renote) "" else notes[1] });
+ if (renote) {
+ u.faded(1 - slide).tagNote(box.w, notes[0]);
+ u.faded(slide).tagNote(box.w, notes[1]);
+ }
+ clipBody(u, box);
+ defer u.unclip();
+ const opens = [2][]const Recording.Call{ rec.stack(u.f.scratch, now.stops[1]), rec.stack(u.f.scratch, now.stops[0]) };
+ const top = body.y + m.pad;
+ // Newest at the bottom, `#0` last: a frame's row is its place from
+ // the oldest, less the oldest that do not fit (dropped from the top).
+ const dropped = [2]usize{ chains[0].len -| room, chains[1].len -| room };
+ const Row = struct { depth: usize, name: []const u8, args: []const u8, where: []const u8 };
+ for (chains, 0..) |chain, side| {
+ const shows = if (side == 0) 1 - leave else arrive;
+ for (chain, 0..) |frame, i| {
+ const from_end = chain.len - 1 - i;
+ const kept = from_end < shared;
+ // A frame both have is drawn once, from the old chain to its place in the new.
+ if (kept and side == 1) continue;
+ var at_row = @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[side]));
+ const here: Row = .{ .depth = i, .name = ui.symbol(u, rec.strings.get(frame.pc) orelse u.print("{x}", .{frame.pc})), .args = callArguments(u, rec, opens[side], i, frame.pc), .where = frameWhere(u, rec, now.marks[side], i, frame.pc) };
+ if (!kept) {
+ if (shows <= 0 or at_row <= -1 or at_row >= @as(f32, @floatFromInt(room))) continue;
+ rows.callRow(u.faded(shows), top + at_row * m.row, box.w, here.depth, here.name, here.args, here.where, here.depth == 0);
+ continue;
+ }
+ const to = chains[1].len - 1 - from_end;
+ const next = chains[1][to];
+ const there: Row = .{ .depth = to, .name = ui.symbol(u, rec.strings.get(next.pc) orelse u.print("{x}", .{next.pc})), .args = callArguments(u, rec, opens[1], to, next.pc), .where = frameWhere(u, rec, now.marks[1], to, next.pc) };
+ at_row = std.math.lerp(at_row, @as(f32, @floatFromInt(from_end)) - @as(f32, @floatFromInt(dropped[1])), slide);
+ if (at_row <= -1 or at_row >= @as(f32, @floatFromInt(room))) continue;
+ const y = top + at_row * m.row;
+ // The wash where the row is the newest, going and coming with the words.
+ const washed = @as(f32, if (here.depth == 0) 1 - renamed else 0) + @as(f32, if (there.depth == 0) renamed else 0);
+ if (washed > 0) rows.callCurrent(u.faded(washed), y, box.w);
+ const same = here.depth == there.depth and std.mem.eql(u8, here.name, there.name) and std.mem.eql(u8, here.args, there.args) and std.mem.eql(u8, here.where, there.where);
+ if (same) {
+ rows.callLabels(u, y, box.w, there.depth, there.name, there.args, there.where, there.depth == 0);
+ } else {
+ rows.callLabels(u.faded(1 - renamed), y, box.w, here.depth, here.name, here.args, here.where, here.depth == 0);
+ rows.callLabels(u.faded(renamed), y, box.w, there.depth, there.name, there.args, there.where, there.depth == 0);
+ }
+ }
+ }
+}
+
/// A backtrace's tag note: `newest at the bottom`, and how many of the
/// oldest a panel of `room` rows leaves out above.
pub fn newestAtBottom(u: ui.Ui, total: usize, room: usize) []const u8 {
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig
index bbc3cf1..2811488 100644
--- a/anim/src/cursor.zig
+++ b/anim/src/cursor.zig
@@ -126,10 +126,11 @@ pub const Cursor = struct {
sprint_veil: anim.Value,
/// Steps taken.
count: anim.Value,
- /// The same values a little behind (`time.minimap_lag`): what the
- /// minimap draws from, secondary action that never starts on a primary
- /// onset's frame.
- lag: Lagged,
+ /// The same values a little behind (`time.minimap_lag`, then a frame
+ /// later each, `time.minimap_fade` of them): what the minimap draws
+ /// from, secondary action that never starts on a primary onset's frame
+ /// and fades over those frames.
+ lags: [time.minimap_fade]Lagged,
/// The levels the scene shows: set before the first step.
levels: Levels = .{},
/// The scene's whole way, for the head's progress line and counter (`journey`).
@@ -152,21 +153,21 @@ pub const Cursor = struct {
.veil = s.value(0),
.sprint_veil = s.value(0),
.count = s.value(0),
- .lag = undefined,
+ .lags = undefined,
.first = start,
.last = start,
};
// shortcut: an f32 holds whole moments up to 16 million; a longer recording needs two values a stop.
for (&c.stops) |*stop| stop.* = s.value(here);
for (&c.gaits) |*gait| gait.* = s.value(0);
- inline for (@typeInfo(Lagged).@"struct".field_names) |name| {
+ for (&c.lags) |*lag| inline for (@typeInfo(Lagged).@"struct".field_names) |name| {
const from = @field(c, name);
if (@TypeOf(from) == anim.Value) {
- @field(c.lag, name) = s.value(s.get(from));
- } else for (&@field(c.lag, name), from) |*to, one| {
+ @field(lag, name) = s.value(s.get(from));
+ } else for (&@field(lag, name), from) |*to, one| {
to.* = s.value(s.get(one));
}
- }
+ };
return c;
}
@@ -184,22 +185,44 @@ pub const Cursor = struct {
};
/// Plays `plays(values)` on the cursor's values from here, and on their
- /// lagging mirror `time.minimap_lag` later; the cursor ends where the first left it.
+ /// lagging mirrors `time.minimap_lag` later and a frame apart; the cursor ends where the first left it.
fn both(c: Cursor, s: *anim.Frame, plays: anytype) void {
const start = s.cursor;
- s.cursor = start + time.minimap_lag;
- plays.run(s, lagged(c));
+ for (0..c.lags.len) |k| {
+ s.cursor = start + time.minimap_lag + @as(f32, @floatFromInt(k)) / 60.0;
+ plays.run(s, lagged(c, k));
+ }
s.cursor = start;
plays.run(s, c);
}
- /// `c` with its lagging values in place of its own.
- fn lagged(c: Cursor) Cursor {
+ /// `c` with its `k`th lagging values in place of its own.
+ fn lagged(c: Cursor, k: usize) Cursor {
var out = c;
- inline for (@typeInfo(Lagged).@"struct".field_names) |name| @field(out, name) = @field(c.lag, name);
+ inline for (@typeInfo(Lagged).@"struct".field_names) |name| @field(out, name) = @field(c.lags[k], name);
return out;
}
+ /// `values` (a frame's every value, a copy) with the cursor's own as its
+ /// `k`th lagging mirror has them: what the minimap's `k`th drawing reads.
+ /// Returns whether they differ from the mirror before's (a drawing to make, not one to reuse).
+ pub fn lagInto(c: Cursor, values: []f32, k: usize) bool {
+ var differs = k == 0;
+ inline for (@typeInfo(Lagged).@"struct".field_names) |name| {
+ const own = @field(c, name);
+ const mirror = @field(c.lags[k], name);
+ const before = @field(c.lags[k -| 1], name);
+ if (@TypeOf(own) == anim.Value) {
+ values[@backingInt(own)] = values[@backingInt(mirror)];
+ differs = differs or values[@backingInt(mirror)] != values[@backingInt(before)];
+ } else for (own, mirror, before) |o, mv, b| {
+ values[@backingInt(o)] = values[@backingInt(mv)];
+ differs = differs or values[@backingInt(mv)] != values[@backingInt(b)];
+ }
+ }
+ return differs;
+ }
+
/// Where the timeline has taken the cursor so far: for scene code that
/// finds the next place from the last.
pub fn moment(c: Cursor, s: *const anim.Frame) u64 {
@@ -447,9 +470,8 @@ pub const Cursor = struct {
c.both(s, Jump{ .to = to });
}
- /// For a component, while it draws (on the minimap, `time.minimap_lag` behind).
- pub fn now(c_: Cursor, placed: anim.Placed) Now {
- const c = if (ui.strokes) lagged(c_) else c_;
+ /// For a component, while it draws (on the minimap the values are a lagging mirror's: `lagInto`).
+ pub fn now(c: Cursor, placed: anim.Placed) Now {
const rec = c.rec;
var n: Now = .{
.rec = rec,
@@ -577,12 +599,13 @@ pub const Now = struct {
/// How far (0 to 1, to be eased) a thing has got that moves as `level`
/// strikes: it sets off `lead` seconds before the strike and takes
/// `seconds`. At a run it sets off with its level and takes
- /// `time.run_ease`; at a sprint, and at rest, it is there.
+ /// `time.run_ease`; at a sprint it takes the step (4 f: never one
+ /// frame); at rest it is there.
pub fn moving(n: Now, level: Level, lead: f32, seconds: f32) f32 {
return switch (n.plan.gait) {
.walk => std.math.clamp((n.since(level, 0) + lead) / seconds, 0, 1),
.run => std.math.clamp(n.since(level, 0) / time.run_ease, 0, 1),
- .sprint => 1,
+ .sprint => if (n.resting()) 1 else std.math.clamp(n.time / @max(n.plan.total, 1.0 / 60.0), 0, 1),
};
}
@@ -597,6 +620,17 @@ pub const Now = struct {
return if (n.fired == in) n.fire() else 0;
}
+ /// 0 to 1 over the 12 f before the advance (from the step's start where
+ /// that is sooner, over the step at a sprint): how far a label that
+ /// changes in place with the step (a frame's name, a tag's note) has
+ /// crossfaded to the new one. Never in a frame.
+ pub fn renaming(n: Now) f32 {
+ if (n.resting()) return 1;
+ const span = @min(time.quick, n.plan.advance);
+ if (span <= 0) return std.math.clamp(n.time / @max(n.plan.total, 1.0 / 60.0), 0, 1);
+ return std.math.clamp((n.time - (n.plan.advance - span)) / span, 0, 1);
+ }
+
/// 0 to 1 (to be eased) through the mark's move to the next line: the
/// step's follow-through, and the next step's anticipation.
pub fn advancing(n: Now) f32 {
@@ -687,7 +721,8 @@ pub const Now = struct {
if (a < s.ember_steps) return .ember;
// Linear: a fade, as the mark leaves: secondary action does not
// start on the fire's frame, where the step's primary one does.
- return .{ .level = 1 - std.math.clamp((n.time - n.plan.advance) / s.out, 0, 1) };
+ // Within the step: a short one (a run's) is not cut off mid-fade by the next.
+ return .{ .level = 1 - std.math.clamp((n.time - n.plan.advance) / @max(@min(s.out, n.plan.total - n.plan.advance), 1.0 / 60.0), 0, 1) };
}
/// The mark of a thing last changed `age` steps ago (`older`: not
@@ -701,10 +736,15 @@ pub const Now = struct {
if (age != 0) return n.left(age);
const was = n.left(older);
switch (n.plan.gait) {
- // Faster than a strike can be seen: embers only.
- .sprint => return .ember,
- // A run strikes nothing: its values change in place.
- .run => return .none,
+ // Faster than a strike can be seen: embers only, coming in over the step.
+ .sprint => return .{ .level = if (n.resting()) 1 else std.math.clamp(n.time / @max(n.plan.total, 1.0 / 60.0), 0, 1) },
+ // A run strikes nothing: its values change in place, and what
+ // marked them before goes with the run's ease, not in a frame.
+ .run => {
+ var gone = was;
+ gone.level *= 1 - (if (n.resting()) 1 else std.math.clamp(n.time / time.run_ease, 0, 1));
+ return gone;
+ },
.walk => {},
}
if (n.resting()) return .ember;
@@ -841,9 +881,10 @@ test "a write is armed, strikes, holds, cools with the advance, and leaves after
// Struck again over its ember: armed with the ember still under it.
h = instant(0.20, plan).heat(0, 1, -0.10);
try expect(h.level == 1 and h.arm == 1 and h.solid == 0);
- // Running: nothing struck. Sprinting: an ember, at once.
+ // Running: nothing struck, and the ember before goes over the run's ease. Sprinting: an ember, coming in over the step.
try expectEqual(ui.Heat.none, instant(0.2, Plan.running(0.3)).heat(0, null, 0.2));
- try expectEqual(ui.Heat.ember, instant(0.01, Plan.sprinting(0.05)).heat(0, null, 0.01));
+ try std.testing.expectApproxEqAbs(@as(f32, 0.5), instant(time.run_ease / 2.0, Plan.running(0.3)).heat(0, 1, 0).level, 1e-4);
+ try std.testing.expectApproxEqAbs(@as(f32, 0.2), instant(0.01, Plan.sprinting(0.05)).heat(0, null, 0.01).level, 1e-4);
}
test "what a step read is framed while its line is gold" {
diff --git a/anim/src/descent.zig b/anim/src/descent.zig
index 3394eaa..d435b59 100644
--- a/anim/src/descent.zig
+++ b/anim/src/descent.zig
@@ -107,11 +107,19 @@ pub const Descent = struct {
const room = theme.layout.rowsIn(box.h);
const before = layout(u, rec, now.stops[1], room, d.root);
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;
const shown = if (going >= 0.5) after else before;
- const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = shown.tag });
+ // A tag that changes with the advance crossfades over it.
+ const retag = !std.mem.eql(u8, before.tag, after.tag);
+ const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = if (retag) "" else shown.tag });
+ if (retag) {
+ u.faded(1 - going).tagNote(box.w, before.tag);
+ u.faded(going).tagNote(box.w, after.tag);
+ }
const top = body.y + m.pad;
u.clip(.{ .x = theme.stroke.rule, .y = m.tag, .w = box.w - 2 * theme.stroke.rule, .h = box.h - m.tag - theme.stroke.rule });
defer u.unclip();
@@ -328,7 +336,7 @@ pub const Descent = struct {
const yb = p.y + m.row / 2;
u.route(&.{ .{ 14, ya }, .{ 14, yb }, .{ c.address - 4, yb } }, t.primary, .{ .width = theme.stroke.rule, .head = .{ 7, 8 }, .radius = 4, .progress = cursors.standard(drawn) });
}
- map.window(.disasm, first(shown), last(shown));
+ map.window(.disasm, .{ first(after), last(after) }, .{ first(before), last(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]);
context.veiled(u, box, now.veil);
diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig
index e871cc6..cf16c6a 100644
--- a/anim/src/disasm.zig
+++ b/anim/src/disasm.zig
@@ -85,8 +85,18 @@ pub const Disasm = struct {
if (ui.mapping) map.measure(.disasm, listing(u, rec, now.marks[1], theme.map.disasm_rows, (theme.map.disasm_rows - 1) / 2).rows.len);
const pc = [2]u64{ rec.register(now.marks[0], "rip"), rec.register(now.marks[1], "rip") };
- const name = rec.strings.get(pc[if (going >= 0.5) 1 else 0]) orelse "";
- const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = name[0 .. std.mem.lastIndexOfScalar(u8, name, '+') orelse name.len] });
+ // The function's name: one that changes with the advance crossfades over it.
+ var names: [2][]const u8 = undefined;
+ for (pc, &names) |at_pc, *name| {
+ const sym = rec.strings.get(at_pc) orelse "";
+ name.* = sym[0 .. std.mem.lastIndexOfScalar(u8, sym, '+') orelse sym.len];
+ }
+ const renamed = !std.mem.eql(u8, names[0], names[1]);
+ const body = u.panel(box.w, box.h, "disassembly", .{ .focus = d.focus, .note = if (renamed) "" else names[1] });
+ if (renamed) {
+ u.faded(1 - going).tagNote(box.w, names[0]);
+ u.faded(going).tagNote(box.w, names[1]);
+ }
const top = body.y + m.pad;
u.clip(.{ .x = theme.stroke.rule, .y = m.tag, .w = box.w - 2 * theme.stroke.rule, .h = box.h - m.tag - theme.stroke.rule });
defer u.unclip();
@@ -172,7 +182,7 @@ pub const Disasm = struct {
break :blk rec.register(at - 1, "rip");
};
- if (shown.rows.len > 0) map.window(.disasm, shown.rows[0].addr, shown.rows[shown.rows.len - 1].addr);
+ if (to.rows.len > 0) map.window(.disasm, .{ to.rows[0].addr, to.rows[to.rows.len - 1].addr }, if (from.rows.len > 0) .{ from.rows[0].addr, from.rows[from.rows.len - 1].addr } else .{ to.rows[0].addr, to.rows[to.rows.len - 1].addr }, cursors.glide(going));
var last_line: ?u32 = null;
// A source of many lines (SQLite's) has wider numbers, as wide as
// its largest: what is right of them moves right by as much.
diff --git a/anim/src/hexdump.zig b/anim/src/hexdump.zig
index 3abd052..47283e7 100644
--- a/anim/src/hexdump.zig
+++ b/anim/src/hexdump.zig
@@ -242,6 +242,27 @@ fn crossfade(now: cursors.Now) Passes {
return .{ .moments = .{ now.shown(.memory), undefined }, .shows = .{ 1, 0 }, .n = 1 };
}
+/// `crossfade`, for one row: at a walk too, a row whose bytes the step
+/// changed where the recording saw no write (memory nothing watches, read
+/// anew at the stop), or that became known, crossfades over 12 f from
+/// memory's slot. Nothing changes in a frame.
+fn rowPasses(now: cursors.Now, addr: u64) Passes {
+ const plain = crossfade(now);
+ if (plain.n == 2 or now.resting() or now.plan.gait != .walk or now.writeAge(addr, 16) == 0) return plain;
+ const q = std.math.clamp(now.since(.memory, 0) / theme.time.quick, 0, 1);
+ if (q <= 0 or q >= 1) return plain;
+ var was: [16]u8 = undefined;
+ var is: [16]u8 = undefined;
+ var known_was: [16]bool = undefined;
+ var known_is: [16]bool = undefined;
+ now.before().read(addr, &was, &known_was) catch return plain;
+ now.moment().read(addr, &is, &known_is) catch return plain;
+ for (0..16) |i| if (known_was[i] != known_is[i] or (known_is[i] and was[i] != is[i])) {
+ return .{ .moments = .{ now.before(), now.moment() }, .shows = .{ 1 - q, q }, .n = 2 };
+ };
+ return plain;
+}
+
/// A row of a panel: its first byte's address and its top.
pub const RowAt = struct { addr: u64, y: f32 };
@@ -418,9 +439,10 @@ pub fn fielded(v: View, now: cursors.Now, y: f32, of: Fields) void {
ry += m.row;
}
last = r;
- const passes = crossfade(now);
+ const passes = rowPasses(now, of.base + 16 * r);
for (passes.moments[0..passes.n], passes.shows[0..passes.n]) |mm, shows| fieldRow(u.faded(shows), now, ry, of.base + 16 * r, if (passes.n == 2) mm else moment, of, lead, shift);
at_rows.append(u.f.scratch, .{ .addr = of.base + 16 * r, .y = ry }) catch {};
+ @import("map.zig").row(.view, of.base + 16 * r, u, .{ .x = 0, .y = ry, .w = 860, .h = m.row });
ry += m.row;
}
if (shown[shown.len - 1] < total - 1) more(u, ry, total - 1 - shown[shown.len - 1]);
diff --git a/anim/src/loupe.zig b/anim/src/loupe.zig
index 65a9463..4ffe860 100644
--- a/anim/src/loupe.zig
+++ b/anim/src/loupe.zig
@@ -69,6 +69,19 @@ pub const Loupe = struct {
s.play(.{l.closing.to(1)}, .{ .seconds = time.close, .ease = anim.ease.linear });
}
+ /// What it opens on, by the pointer's name: for the map, where an open loupe is a panel of its own.
+ pub fn aim(l: *const Loupe, now: cursors.Now) ?struct { name: []const u8, target: u64 } {
+ const moment = now.moment();
+ return switch (l.from) {
+ .register => |name| blk: {
+ const regs = (moment.regs(l.cursor.rec.tid) catch null) orelse return null;
+ break :blk .{ .name = name, .target = regs.named(name) orelse return null };
+ },
+ .field => |field| .{ .name = "its field", .target = (Recording.word(moment, field.at, 8) catch null) orelse return null },
+ .row => |row| .{ .name = row.name, .target = row.fields.base },
+ };
+ }
+
/// Where it is now (in the working frame's units) and what it shows:
/// null while it is shut, or where its pointer is not on screen.
const Placed = struct { box: Rect, pointer: Rect, target: u64, first: u64, ink: u24 };
@@ -131,7 +144,7 @@ pub const Loupe = struct {
holding[@intFromBool(deep)] = null;
const opened = placed.value(l.opening) * time.open;
const closed = placed.value(l.closing);
- if (opened <= 0 or closed >= 1 or ui.mapping) return;
+ if (opened <= 0 or closed >= 1 or ui.mapping or @import("map.zig").looking(f)) return;
const u: ui.Ui = .{ .f = f, .at = placed };
const now = l.cursor.now(placed);
const p = l.place(u, now) orelse return;
diff --git a/anim/src/map.zig b/anim/src/map.zig
index 341d75f..255ea2d 100644
--- a/anim/src/map.zig
+++ b/anim/src/map.zig
@@ -36,6 +36,11 @@ pub const diving = struct {
pub const surface = 84;
};
+/// Whether every frame is the map (`Map.wholeMap`): `CANIM_MAP` in the environment.
+pub fn looking(f: *sk.Frame) bool {
+ return f.host.env("CANIM_MAP") != null;
+}
+
/// The dive's frames over which the falling map crossfades into the minimap's drawing.
pub const minimap_lands = [2]f32{ 90, 96 };
@@ -48,8 +53,10 @@ pub fn minimapShows(t: f32) f32 {
var window_px: [7]?[4]f32 = @splat(null);
/// The working frame's windows this frame: the first and last key of the
-/// rows each shows (a line number, an address).
-var windows: [7]?[2]u64 = @splat(null);
+/// rows each shows (a line number, an address), those it shows at the
+/// step's start, and how far (0 to 1, eased) it has gone from them.
+var windows: [7]?Window = @splat(null);
+const Window = struct { now: [2]u64, was: [2]u64, p: f32 };
/// The map's rows this frame, in canvas pixels: each one's key and box.
var rows: [7][160]struct { key: u64, box: [4]f32 } = undefined;
var counts: [7]usize = @splat(0);
@@ -64,9 +71,11 @@ pub fn measure(panel: Panel, n: usize) void {
if (ui.mapping) held[@intFromEnum(panel)] = @max(held[@intFromEnum(panel)], n);
}
-/// A working panel shows the rows of keys `first` to `last`.
-pub fn window(panel: Panel, first: u64, last: u64) void {
- if (!ui.mapping) windows[@intFromEnum(panel)] = .{ first, last };
+/// A working panel shows the rows of keys `now` (first and last), going
+/// there from `was`, `p` of the way (eased): its outline on the minimap
+/// glides with its scroll, and never jumps.
+pub fn window(panel: Panel, now: [2]u64, was: [2]u64, p: f32) void {
+ if (!ui.mapping) windows[@intFromEnum(panel)] = .{ .now = now, .was = was, .p = p };
}
/// A map panel's row of key `key` is at `r`, in `u`'s units.
@@ -87,7 +96,7 @@ pub fn row(panel: Panel, key: u64, u: ui.Ui, r: Rect) void {
/// lens's view, the registers, and in the rest the stack going on
/// (`continued`), in the third; the stack in the fourth, whole.
// shortcut: a column's rest after the disassembly is page: the 5-row dumps round what the registers point at, the open loupes and the key are not built.
-pub fn split(rec: *const Recording, lens: bool) Split {
+pub fn split(rec: *const Recording, lens: bool, way: [2]u64) Split {
const st = theme.map.stage;
const c = theme.map.columns;
const w = theme.map.column;
@@ -102,32 +111,203 @@ pub fn split(rec: *const Recording, lens: bool) Split {
}.of;
const band: Rect = .{ .x = c[0], .y = st.y, .w = w, .h = if (lens) theme.layout.split.subject.band.h else 0 };
const source_y = if (lens) band.y + band.h + gap else st.y;
- const bt_rows = want(.backtrace, 5);
+ // The backtrace as long as the call chain gets over the scene's way: packed once, never repacked under the eye.
+ const bt_rows = @max(want(.backtrace, 0), deepest(rec, way));
const source_rows: f32 = @floatFromInt(@min(rec.line_count, theme.layout.rowsIn(foot - source_y - gap - panelH(bt_rows))));
const source: Rect = .{ .x = c[0], .y = source_y, .w = w, .h = panelH(source_rows) };
const bt_y = source.y + source.h + gap;
- const view: Rect = .{ .x = c[2], .y = st.y, .w = w, .h = if (lens) panelH(@min(want(.view, theme.map.memory_rows), theme.map.memory_rows)) else 0 };
- const registers: Rect = .{ .x = c[2], .y = if (lens) view.y + view.h + gap else st.y, .w = w, .h = panelH(17) };
+ // The view as long as what draws there has wanted: none where nothing does (a lens drawn alone).
+ const view_rows = @min(want(.view, 0), theme.map.memory_rows);
+ const view: Rect = .{ .x = c[2], .y = st.y, .w = w, .h = if (lens and view_rows > 0) panelH(view_rows) else 0 };
+ const registers: Rect = .{ .x = c[2], .y = if (view.h > 0) view.y + view.h + gap else st.y, .w = w, .h = panelH(17) };
const more_y = registers.y + registers.h + gap;
const more_h = foot - more_y;
+ const disasm: Rect = .{ .x = c[1], .y = st.y, .w = w, .h = panelH(@min(want(.disasm, theme.map.disasm_rows), theme.map.disasm_rows)) };
+ // The source longer than its column (69 lines round the current line, or the file whole if shorter)
+ // goes on at the top of the next column's free space, under its tag, `continued`.
+ const lines_left: f32 = @as(f32, @floatFromInt(@min(rec.line_count, theme.map.disasm_rows))) - source_rows;
+ const under_disasm = disasm.y + disasm.h + gap;
+ const more_rows = @min(lines_left, @as(f32, @floatFromInt(theme.layout.rowsIn(foot - under_disasm))));
+ const source_more: Rect = .{ .x = c[1], .y = under_disasm, .w = w, .h = if (more_rows >= 3) panelH(more_rows) else 0 };
+ const backtrace: Rect = .{ .x = c[0], .y = bt_y, .w = w, .h = @min(panelH(bt_rows), foot - bt_y) };
+ const rest = struct {
+ fn under(r: Rect, bottom: f32) Rect {
+ const y = r.y + r.h + theme.canvas.row_gap;
+ return .{ .x = r.x, .y = y, .w = r.w, .h = @max(bottom - y, 0) };
+ }
+ }.under;
return .{
.band = band,
.view = view,
.source = source,
- .disasm = .{ .x = c[1], .y = st.y, .w = w, .h = panelH(@min(want(.disasm, theme.map.disasm_rows), theme.map.disasm_rows)) },
+ .disasm = disasm,
.registers = registers,
.stack = .{ .x = c[3], .y = st.y, .w = w, .h = st.h },
- .backtrace = .{ .x = c[0], .y = bt_y, .w = w, .h = @min(panelH(bt_rows), foot - bt_y) },
+ .backtrace = backtrace,
.dump_rows = theme.map.memory_rows,
.more = .{ .x = c[2], .y = more_y, .w = w, .h = if (more_h >= panelH(3)) theme.layout.panelH(@floor((more_h - 32) / 24)) else 0 },
+ .source_more = source_more,
+ .spare = .{ rest(backtrace, foot), if (source_more.h > 0) rest(source_more, foot) else rest(disasm, foot) },
};
}
+/// The most frames the call chain has from moment `way[0]` to `way[1]` (5 where it knows none).
+fn deepest(rec: *const Recording, way: [2]u64) f32 {
+ const context = @import("context.zig");
+ var most: usize = 0;
+ var seen: ?@TypeOf(rec.depths[0]) = null;
+ var i = way[0];
+ while (i <= @min(way[1], rec.end())) : (i += 1) {
+ if (seen != null and rec.depths[i] <= seen.?) continue;
+ seen = rec.depths[i];
+ var buf: [24]context.Frame = undefined;
+ most = @max(most, context.frames(rec, i, &buf).len);
+ }
+ return @floatFromInt(if (most > 0) most else 5);
+}
+
+/// What the map gives the rest of its first two columns, in the
+/// catalogue's order once the stack has had more (its own column, and the
+/// registers' column's rest, `stack, continued`): a short dump round each
+/// place the registers and the stack's words point at, outside the stack
+/// and the code (five rows, the target's row in the middle, its region's
+/// ink: registers first, in pwndbg's order, then the words up from rsp,
+/// none within another's rows); the loupes open, each a lifted panel of
+/// nine rows; and last the key. Only then page.
+pub const Spare = struct {
+ cursor: @import("cursor.zig").Cursor,
+ stage: *const Stage,
+ map: *const Map,
+
+ pub fn draw(sp: *const Spare, f: *sk.Frame, placed: anim.Placed) void {
+ if (!ui.mapping) return;
+ const hexdump = @import("hexdump.zig");
+ const context = @import("context.zig");
+ const rows_ = @import("rows.zig");
+ const m = theme.metric.context;
+ const panelH = theme.layout.panelH;
+ var free = sp.stage.now(placed).spare;
+ const now = sp.cursor.now(placed);
+ const rec = sp.cursor.rec;
+ const moment = now.moment();
+ const regs = (moment.regs(rec.tid) catch null) orelse return;
+ const things = @import("objects.zig").reach(f.scratch, rec, moment, null);
+ // The next box of height `h` in what is left: from the top of the first column with room.
+ const take = struct {
+ fn of(left: *[2]Rect, h: f32) ?Rect {
+ for (left) |*r| if (r.h >= h) {
+ const out: Rect = .{ .x = r.x, .y = r.y, .w = r.w, .h = h };
+ r.y += h + theme.canvas.row_gap;
+ r.h = @max(r.h - h - theme.canvas.row_gap, 0);
+ return out;
+ };
+ return null;
+ }
+ }.of;
+ const Target = struct { name: []const u8, at: u64 };
+ var targets: [24]Target = undefined;
+ var n: usize = 0;
+ const add = struct {
+ fn of(list: []Target, count: *usize, mo: Recording.Moment, name: []const u8, at: u64) void {
+ if (count.* == list.len) return;
+ switch (rows_.regionOf(mo, at)) {
+ .heap, .data, .rwx, .rodata => {},
+ .none, .stack, .code => return,
+ }
+ var byte: [8]u8 = undefined;
+ var known: [8]bool = undefined;
+ mo.read(at & ~@as(u64, 7), &byte, &known) catch return;
+ if (!known[0]) return;
+ // None within another's five rows.
+ for (list[0..count.*]) |t_| if (@abs(@as(i64, @bitCast((at & ~@as(u64, 15)) -% (t_.at & ~@as(u64, 15))))) < 5 * 16) return;
+ list[count.*] = .{ .name = name, .at = at };
+ count.* += 1;
+ }
+ }.of;
+ for (theme.metric.all_registers[0..16]) |name| {
+ if (std.mem.eql(u8, name, "rsp") or std.mem.eql(u8, name, "rbp")) continue;
+ add(&targets, &n, moment, name, regs.named(name) orelse continue);
+ }
+ var word: u64 = 0;
+ while (word < 64) : (word += 1) {
+ const addr = regs.rsp + 8 * word;
+ const points = (Recording.word(moment, addr, 8) catch null) orelse continue;
+ add(&targets, &n, moment, f.format("rsp+{x}", .{8 * word}), points);
+ }
+ for (targets[0..n]) |target| {
+ const box = take(&free, panelH(5)) orelse break;
+ const u = context.at(f, placed, box);
+ const region = rows_.regionOf(moment, target.at);
+ _ = u.panel(box.w, box.h, target.name, .{ .note = f.format("\u{2192} {x} \u{00b7} {s}", .{ target.at, regionName(region) }) });
+ hexdump.drawArcs(u, now, 0, m.tag + m.pad, (target.at & ~@as(u64, 15)) -| 32, 5, .{ .things = things, .region = rows_.ink(region) }, false, .{ m.tag, box.h - m.pad });
+ }
+ // The loupes open: lifted, nine rows round their target.
+ for (sp.map.loupes) |maybe| {
+ const l = maybe orelse continue;
+ const shows = std.math.clamp(placed.value(l.opening) * theme.time.loupe.open / theme.time.loupe.rise, 0, 1) * (1 - placed.value(l.closing));
+ if (shows <= 0) continue;
+ const aim = l.aim(now) orelse continue;
+ const box = take(&free, panelH(9)) orelse break;
+ const u = context.at(f, placed, box).faded(shows);
+ u.fill(.{ .x = 0, .y = 0, .w = box.w, .h = box.h }, theme.color.lift);
+ _ = u.panel(box.w, box.h, "loupe", .{ .note = f.format("{s} \u{2192} {x}", .{ aim.name, aim.target }) });
+ hexdump.drawArcs(u, now, 0, m.tag + m.pad, (aim.target & ~@as(u64, 15)) -| 64, 9, .{ .things = things, .region = rows_.ink(rows_.regionOf(moment, aim.target)) }, true, .{ m.tag, box.h - m.pad });
+ }
+ // The key: the recording and the moment, the marks, the inks.
+ if (take(&free, panelH(3))) |box| key(context.at(f, placed, box), box, rec, now);
+ }
+
+ fn regionName(region: @import("ztrace").telescope.Region) []const u8 {
+ return switch (region) {
+ .stack => "stack",
+ .heap => "heap",
+ .code => "code",
+ .data, .rwx => "data",
+ .rodata => "read-only",
+ .none => "",
+ };
+ }
+
+ /// The map's key, three rows: what ran and where in it the map is; the marks, each drawn as it is; the inks.
+ fn key(u: ui.Ui, box: Rect, rec: *const Recording, now: @import("cursor.zig").Now) void {
+ const m = theme.metric.context;
+ const t = theme.color.text;
+ const size = theme.size.mono.context;
+ const body = u.panel(box.w, box.h, "key", .{ .note = "the marks and inks of every picture", .legend = &.{} });
+ const rows_ = @import("rows.zig");
+ var y = body.y + m.pad;
+ u.text(.mono, size, m.side, rows_.baseline(y), u.print("{s} \u{00b7} moment {d} of {d}", .{ rec.file, now.marked() -| now.way[0], now.way[1] -| now.way[0] }), t.primary);
+ y += m.row;
+ var x: f32 = m.side;
+ u.current(.{ .x = x, .y = y, .w = 120, .h = m.row }, 40, 0);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "current", t.primary);
+ x += 160;
+ _ = u.written(.{ .x = x + 6, .y = y, .w = 24, .h = m.row }, .struck);
+ u.text(.mono_bold, size, x + 6, rows_.baseline(y), "2a", t.bright);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "written", t.primary);
+ x += 160;
+ u.corner(x + 2, y + 2, m.corner, 1);
+ u.text(.mono, size, x + 6, rows_.baseline(y), "2a", t.primary);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "changed", t.primary);
+ x += 160;
+ u.read(.{ .x = x + 6, .y = y, .w = 24, .h = m.row }, 1);
+ u.text(.mono, size, x + 6, rows_.baseline(y), "2a", t.primary);
+ u.text(.mono, size, x + 48, rows_.baseline(y), "read", t.primary);
+ y += m.row;
+ x = m.side;
+ for (@import("context.zig").legend) |entry| {
+ u.text(.mono, size, x, rows_.baseline(y), entry.text, entry.ink);
+ if (entry.under) u.fill(.{ .x = x, .y = rows_.baseline(y) + 3, .w = u.width(.mono, size, entry.text), .h = theme.stroke.rule }, entry.ink);
+ x += u.width(.mono, size, entry.text) + 24;
+ }
+ }
+};
+
/// The map: its stage, and the components drawn on it, each a working
/// frame's component bound to that stage.
pub const Map = struct {
stage: *Stage,
- parts: [8]Part = undefined,
+ parts: [12]Part = undefined,
n: usize = 0,
/// The panel the narration is in: its window bright on the minimap.
focus: ?Panel = null,
@@ -140,6 +320,8 @@ pub const Map = struct {
obj: anim.Obj = undefined,
/// Where the program is: for the thread across the gutter, and the minimap's flashes.
cursor: ?@import("cursor.zig").Cursor = null,
+ /// The scene's loupes: open, each is a panel of its own on the map (`Spare`).
+ loupes: [2]?*const @import("loupe.zig").Loupe = .{ null, null },
const Part = struct { ctx: *const anyopaque, draw: *const fn (*const anyopaque, *sk.Frame, anim.Placed) void };
@@ -155,6 +337,13 @@ pub const Map = struct {
m.n += 1;
}
+ /// Puts a drawing on the map, in a band of its own over the source,
+ /// for a scene whose working frame has none (its map is split anew).
+ pub fn drawing(m: *Map, s: *anim.Frame, rec: *const Recording, component: anytype) void {
+ m.stage.first = split(rec, true, if (m.cursor) |c| .{ c.first, c.last } else .{ 0, 0 });
+ m.add(s, component);
+ }
+
/// Whether the working frame is in place (the minimap is the map).
pub fn settled(m: *const Map, at: anim.Placed) bool {
return at.value(m.t) >= diving.land;
@@ -229,6 +418,21 @@ pub const Map = struct {
}
}
+ /// Frames into the dive now; 0 (the map filling the frame, as a scene
+ /// that opens on it shows it) with `CANIM_MAP` in the environment.
+ fn diveAt(m: *const Map, f: *sk.Frame, placed: anim.Placed) f32 {
+ return if (looking(f)) 0 else placed.value(m.t);
+ }
+
+ /// With `CANIM_MAP` in the environment every frame is the map filling
+ /// it, as a scene that opens on it shows it (the clock draws it, `wholeMap`; the
+ /// working panels, the ties and the loupes stand aside): for looking at
+ /// any scene's map at 1:1 in a 4K export.
+ pub fn wholeMap(m: *const Map, f: *sk.Frame, placed: anim.Placed) void {
+ const fixed = @import("words.zig").fixed(f, placed, 0);
+ m.copy(f, m.falling(f, placed, 0), fixed, 0);
+ }
+
/// Below this scale (of the frame's) the falling map is drawn over the
/// panels, on its way into the corner, and not under them.
const small = 0.12;
@@ -328,19 +532,39 @@ pub const Map = struct {
raw.route(&.{ .{ a[2], (a[1] + a[3]) / 2 }, .{ lane, (a[1] + a[3]) / 2 }, .{ lane, (b[1] + b[3]) / 2 }, .{ b[0], (b[1] + b[3]) / 2 } }, gold, .{ .width = w, .head = null, .radius = 0 });
}
if (!mini or !now.walking()) return;
- // A struck word outside every window: the stack's, round its rsp.
+ // A mark no working window shows: a word struck or read, on the
+ // stack (its own column or continued) or in memory the map draws
+ // (the view's dump, the dumps round the pointers), flashes where the
+ // map has it, in the mark's colour.
const since = now.since(.memory, 0);
const p = since / (12.0 / 60.0);
if (p < 0 or p > 1) return;
- const win = windows[@intFromEnum(Panel.stack)] orelse return;
- for (rec.written(now.stops[1], now.stops[0])) |span| {
+ const marks = [2]struct { spans: []const Recording.Span, ink: u24 }{
+ .{ .spans = rec.written(now.stops[1], now.stops[0]), .ink = theme.color.struck },
+ .{ .spans = rec.read(now.stops[1], now.stops[0]), .ink = theme.mark(.read).solid },
+ };
+ for (marks) |mark| for (mark.spans) |span| {
+ // Where the map has it: the stack's word, or the 16 bytes of a dump's row.
const word = span.addr & ~@as(u64, 7);
- if (word >= win[0] and word <= win[1]) continue;
- const box = rows_of(.stack, word) orelse continue;
+ const sixteen = span.addr & ~@as(u64, 15);
+ const panel: Panel, const key: u64 = if (rows_of(.stack, word) != null) .{ .stack, word } else .{ .view, sixteen };
+ const box = rows_of(panel, key) orelse continue;
+ if (windows[@intFromEnum(panel)]) |win| if (key >= win.now[0] and key <= win.now[1]) continue;
const c = ui.Vec{ (box[0] + box[2]) / 2, (box[1] + box[3]) / 2 };
const r = std.math.lerp(@as(f32, 4), 7, p) * k / theme.minimap.scale;
- raw.faded(1 - p).disc(c, r, null, ui.rgb(theme.color.struck), @max(1, k / theme.minimap.scale));
- }
+ raw.faded(1 - p).disc(c, r, null, ui.rgb(mark.ink), @max(1, k / theme.minimap.scale));
+ };
+ }
+
+ /// The top and bottom of the map's rows of panel `i` with keys from `keys[0]` to `keys[1]`, in canvas pixels.
+ fn spanOf(i: usize, keys: [2]u64) ?[2]f32 {
+ var top: f32 = std.math.inf(f32);
+ var bottom: f32 = -std.math.inf(f32);
+ for (rows[i][0..counts[i]]) |rw| if (rw.key >= keys[0] and rw.key <= keys[1]) {
+ top = @min(top, rw.box[1]);
+ bottom = @max(bottom, rw.box[3]);
+ };
+ return if (top < bottom) .{ top, bottom } else null;
}
/// Where the map's row of key `key` in `panel` is this frame, in canvas pixels.
@@ -367,48 +591,110 @@ pub const Map = struct {
var r: [4]f32 = .{ a[0], a[1], b[0], b[1] };
var shown = panel == .registers or panel == .band;
if (windows[i]) |win| {
- var top: f32 = std.math.inf(f32);
- var bottom: f32 = -std.math.inf(f32);
- for (rows[i][0..counts[i]]) |rw| if (rw.key >= win[0] and rw.key <= win[1]) {
- top = @min(top, rw.box[1]);
- bottom = @max(bottom, rw.box[3]);
- };
- if (top < bottom) {
- r[1] = top;
- r[3] = bottom;
+ // Where the window was and where it is, and between them as far as its scroll has gone.
+ const is = spanOf(i, win.now);
+ const was = spanOf(i, win.was) orelse is;
+ if (is orelse was) |to| {
+ const from = was orelse to;
+ // On the minimap each end on whole pixels: crisp at rest, between them only while it glides.
+ const snap = struct {
+ fn of(v: f32, on: bool) f32 {
+ return if (on) @round(v) else v;
+ }
+ }.of;
+ r[1] = std.math.lerp(snap(from[0], mini), snap(to[0], mini), win.p);
+ r[3] = std.math.lerp(snap(from[1], mini), snap(to[1], mini), win.p);
shown = true;
}
}
+ // On the minimap on whole pixels (a window's ends already are, at rest).
+ if (mini) {
+ r[0] = @round(r[0]);
+ r[2] = @round(r[2]);
+ if (windows[i] == null) {
+ r[1] = @round(r[1]);
+ r[3] = @round(r[3]);
+ }
+ }
window_px[i] = if (shown) r else null;
if (shown) {
const focus = m.focus == panel;
// On the minimap a pixel of the frame: `k` is the canvas's pixels to a map unit.
const w = if (mini) @as(f32, if (focus) 1.5 else 1) * k / theme.minimap.scale else theme.map.outline * k;
const out = if (mini) w else theme.map.outline_out * k;
- raw.frame(.{ .x = r[0] - out, .y = r[1] - out, .w = r[2] - r[0] + 2 * out, .h = r[3] - r[1] + 2 * out }, ui.mix(if (mini) theme.color.text.primary else theme.color.text.dim, theme.color.text.bright, bright), if (bright > 0 and !mini) w * 1.5 else w);
+ const ring: Rect = .{ .x = r[0] - out, .y = r[1] - out, .w = r[2] - r[0] + 2 * out, .h = r[3] - r[1] + 2 * out };
+ const ink = ui.mix(if (mini) theme.color.text.primary else theme.color.text.dim, theme.color.text.bright, bright);
+ // On the minimap not snapped to pixels: a window that glides moves a pixel over many frames, not in one.
+ if (mini) {
+ const pen = raw.at.pen(.{ .fill = ink });
+ for ([4]sk.math.Rect{ .{ .x = ring.x, .y = ring.y, .w = ring.w, .h = w }, .{ .x = ring.x, .y = ring.y + ring.h - w, .w = ring.w, .h = w }, .{ .x = ring.x, .y = ring.y + w, .w = w, .h = ring.h - 2 * w }, .{ .x = ring.x + ring.w - w, .y = ring.y + w, .w = w, .h = ring.h - 2 * w } }) |edge| sk.draw.rect(f, edge, pen);
+ } else raw.frame(ring, ink, if (bright > 0) w * 1.5 else w);
}
}
}
}
};
+/// The minimap's drawings, a frame apart, and what they are averaged into:
+/// the host's images, made once for a size.
+/// shortcut: a process-wide cache of host images, for one player at a time; two at once want it in their Session.
+var fades: struct { w: u32 = 0, h: u32 = 0, images: [theme.time.minimap_fade + 1]sk.Image = undefined } = .{};
+
/// The minimap: `m` at a twentieth in the caption band's right end, still
/// while the camera moves; the page under it, framed a pixel in `rule`.
+/// Every change on it fades in over `time.minimap_fade` frames from
+/// `time.minimap_lag` after its onset: it is the average of that many
+/// drawings, each from the cursor's mirror a frame later (`Cursor.lagInto`),
+/// so a stroke that changes, a mark that comes and the gold that moves on
+/// all fade, and a window's glide is smoothed, never stepped.
pub fn minimap(m: *const Map, f: *sk.Frame, at: anim.Placed) void {
var shown = at;
- shown.pose.opacity *= minimapShows(at.value(m.t));
+ shown.pose.opacity *= minimapShows(m.diveAt(f, at));
if (shown.pose.opacity <= 0) return;
const fixed = @import("words.zig").fixed(f, shown, 0);
const box = theme.minimap.box;
- fixed.fill(box, theme.color.page);
+ const a = fixed.at.xf.apply(.{ box.x, box.y });
+ const b = fixed.at.xf.apply(.{ box.x + box.w, box.y + box.h });
+ const px: sk.Rect = .{ .x = @round(a[0]), .y = @round(a[1]), .w = @round(b[0]) - @round(a[0]), .h = @round(b[1]) - @round(a[1]) };
+ const w: u32 = @intFromFloat(@max(px.w, 1));
+ const h: u32 = @intFromFloat(@max(px.h, 1));
+ if (fades.w != w or fades.h != h) {
+ if (fades.w != 0) for (fades.images) |img| f.host.freeImage(img);
+ for (&fades.images) |*img| img.* = f.host.newImage(w, h);
+ fades.w = w;
+ fades.h = h;
+ }
+ // Each drawing in an image of its own, the page under it, in the image's pixels.
var placed = fixed.at;
- placed.xf = placed.xf.mul(.translate(box.x, box.y)).mul(.scale(theme.minimap.scale, theme.minimap.scale));
+ placed.pose.opacity = 1;
+ placed.xf = sk.math.Affine.translate(-px.x, -px.y).mul(fixed.at.xf).mul(.translate(box.x, box.y)).mul(.scale(theme.minimap.scale, theme.minimap.scale));
placed.scale = fixed.at.scale * theme.minimap.scale;
- const clip = fixed.at.xf.apply(.{ box.x, box.y });
- const end = fixed.at.xf.apply(.{ box.x + box.w, box.y + box.h });
- f.clip(sk.Rect{ .x = @round(clip[0]), .y = @round(clip[1]), .w = @round(end[0]) - @round(clip[0]), .h = @round(end[1]) - @round(clip[1]) });
- m.drawAt(f, placed, true);
- f.clip(null);
+ const values = f.scratch.dupe(f32, at.values) catch return;
+ placed.values = values;
+ const n = theme.time.minimap_fade;
+ var weights: [n]f32 = @splat(0);
+ var made: usize = 0;
+ for (0..n) |k| {
+ // A mirror the same as the one before draws the same: its drawing counts twice.
+ const differs = if (m.cursor) |c| c.lagInto(values, k) else k == 0;
+ if (differs) {
+ f.target(fades.images[made]);
+ f.clear(ui.rgb(theme.color.page));
+ m.drawAt(f, placed, true);
+ made += 1;
+ }
+ weights[made - 1] += 1;
+ }
+ // Averaged: each drawing over those before it at its share of the drawings so far.
+ const whole: sk.Rect = .{ .x = 0, .y = 0, .w = px.w, .h = px.h };
+ f.target(fades.images[n]);
+ var so_far: f32 = 0;
+ for (fades.images[0..made], weights[0..made]) |img, weight| {
+ so_far += weight;
+ f.image(img, whole, .{ .tint = sk.Color.white.alphaFloat(weight / so_far) });
+ }
+ f.target(.none);
+ f.image(fades.images[n], px, .{ .tint = sk.Color.white.alphaFloat(shown.pose.opacity) });
fixed.frame(.{ .x = box.x - 1, .y = box.y - 1, .w = box.w + 2, .h = box.h + 2 }, theme.color.rule, 1);
}
diff --git a/anim/src/nodes.zig b/anim/src/nodes.zig
index 81a9953..7c842d3 100644
--- a/anim/src/nodes.zig
+++ b/anim/src/nodes.zig
@@ -77,7 +77,7 @@ pub const Nodes = struct {
const shown = @min(count, (hi - first) / 16);
const v = hexdump.panel(f, placed, g.stage, u.print("the heap, {x} to {x}", .{ first, first + 16 * shown - 1 }), &legend);
if (v.rows > 0) hexdump.draw(v.u, now, 0, m.tag + m.pad, first, @min(shown, v.rows), .{ .things = things });
- if (v.rows > 0) @import("map.zig").window(.view, first, first + 16 * (@min(shown, v.rows) -| 1));
+ if (v.rows > 0) @import("map.zig").window(.view, .{ first, first + 16 * (@min(shown, v.rows) -| 1) }, .{ first, first + 16 * (@min(shown, v.rows) -| 1) }, 1);
v.veil(now);
u.clip(.{ .x = 0, .y = 0, .w = box.w, .h = box.h });
}
@@ -221,7 +221,10 @@ pub const Nodes = struct {
const names = g.pins(u, now, o.addr);
const cx = r.x + r.w / 2;
ties.anchor(u, .{ .node_pin = o.addr }, .{ .x = cx - 1, .y = r.y + r.h, .w = 2, .h = label + 10 });
- if (names.names.len > 0 and names.shows > 0) u.faded(names.shows).pinUnderInked(cx, r.y + r.h, names.names, names.inks, heap, label);
+ if (names.names.len > 0 and names.shows > 0) {
+ u.faded(names.shows).pinUnderInked(cx, r.y + r.h, &.{}, &.{}, heap, label);
+ u.faded(names.shows * names.text).pinNames(cx, r.y + r.h, names.names, names.inks, label);
+ }
}
/// Where variable `name`'s tag is: it travels from node to node in the
@@ -279,7 +282,10 @@ pub const Nodes = struct {
}
}
- const Pins = struct { names: []const []const u8, inks: []const u24, shows: f32 };
+ /// `text`: how much its names show: a register joining or leaving
+ /// crosses the middle of its change with them faded out, so the names
+ /// it leaves and those it gets never swap in a frame.
+ const Pins = struct { names: []const []const u8, inks: []const u24, shows: f32, text: f32 = 1 };
/// The registers that hold `addr` (before this step, and after it once
/// their link has landed), then the scene's variables that do.
@@ -288,6 +294,7 @@ pub const Nodes = struct {
var out: std.ArrayList([]const u8) = .empty;
var inks: std.ArrayList(u24) = .empty;
var shows: f32 = 0;
+ var text: f32 = 1;
const is = (now.moment().regs(rec.tid) catch null) orelse zt.Regs{};
const was = (now.before().regs(rec.tid) catch null) orelse is;
// The scene's variables first: what the narration names, in the ink
@@ -309,6 +316,7 @@ pub const Nodes = struct {
if (!before and !after) continue;
const s = ties.pinShows(now, i, .node);
const this = if (before and after) 1 else if (after) s.new else s.old;
+ if (before != after) text = @min(text, @abs(2 * this - 1));
if (this < 0.5) continue;
out.append(u.f.scratch, name) catch break;
inks.append(u.f.scratch, t.primary) catch break;
@@ -317,7 +325,7 @@ pub const Nodes = struct {
// Names keep their side: the first to come is on the left, the next
// on the right, and a name that lands where another is stays on the
// right it travelled on; one left alone where it was on the right stays there.
- const came = u.f.scratch.alloc(u64, out.items.len) catch return .{ .names = out.items, .inks = inks.items, .shows = shows };
+ const came = u.f.scratch.alloc(u64, out.items.len) catch return .{ .names = out.items, .inks = inks.items, .shows = shows, .text = text };
for (out.items, came) |name, *at| at.* = g.arrival(u, now, name, addr);
for (1..@max(out.items.len, 1)) |i| {
var k = i;
@@ -345,7 +353,7 @@ pub const Nodes = struct {
inks.insert(u.f.scratch, 0, t.primary) catch {};
}
}
- return .{ .names = out.items, .inks = inks.items, .shows = shows };
+ return .{ .names = out.items, .inks = inks.items, .shows = shows, .text = text };
}
/// When `name` came to point at `addr`: the moment its value last
diff --git a/anim/src/root.zig b/anim/src/root.zig
index e289641..7e4206a 100644
--- a/anim/src/root.zig
+++ b/anim/src/root.zig
@@ -35,6 +35,8 @@ const contexts = @import("context.zig");
pub const Registers = contexts.Registers;
pub const Stack = contexts.Stack;
pub const Backtrace = contexts.Backtrace;
+/// A panel's `Ui` at its box on the stage now (in a dive, on its way out of its window on the map).
+pub const panelAt = contexts.at;
/// The registers' tag: what an address's ink says.
pub const contextLegend = contexts.legend;
pub const disasm = @import("disasm.zig");
@@ -275,15 +277,17 @@ pub fn context(s: *anim.Frame, cursor_: Cursor, options: Context.Options) Contex
var at = cursor_;
at.levels.crossings = options.syscalls;
// The map first: while it fills the frame or falls to the minimap it is under the panels diving out of it.
- const whole = s.new(map.Map{ .stage = Stage.init(s, map.split(at.rec, options.split.band.h > 0)), .frame = stage, .t = s.value(map.diving.land + map.diving.still), .cursor = at });
+ const whole = s.new(map.Map{ .stage = Stage.init(s, map.split(at.rec, options.split.band.h > 0, .{ at.first, at.last })), .frame = stage, .t = s.value(map.diving.land + map.diving.still), .cursor = at });
whole.obj = s.custom(whole, .{ .x = -640, .y = -360, .scale = ui.scale });
whole.add(s, Source{ .cursor = at, .stage = whole.stage, .descent = options.descent });
+ whole.add(s, Source{ .cursor = at, .stage = whole.stage, .descent = options.descent, .part = .source_more });
if (options.descent) whole.add(s, Descent{ .cursor = at, .stage = whole.stage }) else whole.add(s, Disasm{ .cursor = at, .stage = whole.stage });
whole.add(s, Registers{ .cursor = at, .stage = whole.stage, .syscalls = options.syscalls, .quiet = options.quiet });
whole.add(s, Stack{ .cursor = at, .stage = whole.stage, .above = theme.map.stack_above });
// The stack goes on in the rest of the memory's column, from where its own column ends.
whole.add(s, Stack{ .cursor = at, .stage = whole.stage, .above = theme.map.stack_above - @as(i32, @intCast(theme.layout.rowsIn(whole.stage.first.stack.h))), .part = .more });
whole.add(s, Backtrace{ .cursor = at, .stage = whole.stage });
+ whole.add(s, map.Spare{ .cursor = at, .stage = whole.stage, .map = whole });
return .{
.stage = stage,
.map = whole,
diff --git a/anim/src/rows.zig b/anim/src/rows.zig
index 69aa62b..a125b05 100644
--- a/anim/src/rows.zig
+++ b/anim/src/rows.zig
@@ -205,25 +205,46 @@ pub const flags = [_]Flag{ .{ .name = "CF", .bit = 0 }, .{ .name = "PF", .bit =
/// flag, and how much of the corner shows); read, framed (`read`: a bit per
/// flag, while a conditional reads them: an echo of the row that set them,
/// `read_shows` how much). 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, read: u64, read_shows: f32) void {
+pub fn rip(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, pc: u64, eflags: u64, changed: u64, held: f32, fire: f32, read: u64, read_shows: f32, was: ?RipWas) 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);
u.text(.mono_bold, size, m.side, baseline(y), "rip", gold.on_solid);
const fl = theme.metric.flags;
var x = w - m.side - @as(f32, flags.len) * fl.pitch + 10;
- _ = chain(u, m.chain_x, y, moment, pc, x - 16, .{});
+ // Where execution is changes with the advance: the old value goes as the new one comes, over it.
+ const before = was orelse RipWas{ .moment = moment, .pc = pc, .eflags = eflags };
+ if (before.pc != pc and before.going < 1) {
+ _ = chain(u.faded(1 - before.going), m.chain_x, y, before.moment, before.pc, x - 16, .{});
+ _ = chain(u.faded(before.going), m.chain_x, y, moment, pc, x - 16, .{});
+ } else _ = chain(u, m.chain_x, y, moment, pc, x - 16, .{});
for (flags) |flag| {
const set = eflags >> flag.bit & 1 != 0;
- 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));
+ // A flag the step sets or clears crossfades as it lands (`flip`).
+ if (set != (before.eflags >> flag.bit & 1 != 0) and before.flip < 1) {
+ ripFlag(u.faded(1 - before.flip), x, y, flag, !set);
+ ripFlag(u.faded(before.flip), x, y, flag, set);
+ } else ripFlag(u, x, y, flag, set);
if (changed >> flag.bit & 1 != 0) u.corner(x, y + 2, m.corner, held);
if (read >> flag.bit & 1 != 0 and read_shows > 0) u.read(.{ .x = x, .y = y + 2, .w = fl.chip[0], .h = fl.chip[1] }, read_shows);
x += fl.pitch;
}
}
+/// rip's row as it was before the step: its value, going to the new one
+/// `going` of the way (the advance), and the flags, `flip` of the way.
+pub const RipWas = struct { moment: Recording.Moment, pc: u64, eflags: u64, going: f32 = 1, flip: f32 = 1 };
+
+fn ripFlag(u: ui.Ui, x: f32, y: f32, flag: Flag, set: bool) void {
+ const fl = theme.metric.flags;
+ 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, theme.mark(.current).ember, 0.2));
+}
+
+/// A slot's role as it was before the step, and how far (0 to 1) the role it has now has come in over it.
+pub const Role = struct { name: []const u8, local: bool = false, going: f32 = 1, from_rsp: ?i64 = null };
+
/// `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
@@ -232,19 +253,28 @@ pub fn rip(u: ui.Ui, y: f32, w: f32, moment: Recording.Moment, pc: u64, eflags:
/// 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 {
+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, was: ?Role) 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);
+ // An offset that changes with rsp (the window held, or moved by more than the slide) crossfades as a role does.
+ if (was) |o| if (o.from_rsp) |old| if (old != from_rsp and o.going < 1) {
+ offset(u.faded(1 - o.going), y, old);
+ offset(u.faded(o.going), y, from_rsp);
+ } else offset(u, y, from_rsp) else offset(u, y, from_rsp) else offset(u, y, from_rsp);
var lead = marks;
lead.first = .none;
const base = baseline(y);
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;
+ // A role that changes in place (the step makes the word another's) crossfades, `was.going` of the way.
+ const before = was orelse Role{ .name = role, .local = local };
+ const changes = !std.mem.eql(u8, before.name, role) or before.local != local;
+ const right = room;
+ for ([2]Role{ before, .{ .name = role, .local = local } }, [2]f32{ if (changes) 1 - before.going else 0, if (changes) before.going else 1 }) |r, shows| {
+ if (r.name.len == 0 or shows <= 0) continue;
+ const rx = right - u.width(.mono, size, r.name);
+ u.faded(shows).text(.mono, size, rx, base, r.name, if (r.local) t.primary else t.dim);
+ room = @min(room, rx - adv);
}
const held = (Recording.word(moment, addr, 8) catch null) orelse {
_ = u.arrow(end, y + row_h / 2, .points);
@@ -299,8 +329,18 @@ pub fn spanNameX(u: ui.Ui, w: f32, name: []const u8) f32 {
/// primary), file and line ranged right, dim. A name cut only where the
/// arguments begin, saying so.
pub fn callRow(u: ui.Ui, y: f32, w: f32, n: usize, name: []const u8, args: []const u8, where: []const u8, newest: bool) void {
+ if (newest) callCurrent(u, y, w);
+ callLabels(u, y, w, n, name, args, where, newest);
+}
+
+/// The newest call's wash and plaque, apart from its words: for a row that becomes or stops being the newest.
+pub fn callCurrent(u: ui.Ui, y: f32, w: f32) void {
+ u.current(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = row_h }, 40, 0);
+}
+
+/// A `call` row's words, apart from its wash: for one whose words crossfade.
+pub fn callLabels(u: ui.Ui, y: f32, w: f32, n: usize, name: []const u8, args: []const u8, where: []const u8, newest: bool) void {
const gold = theme.mark(.current);
- if (newest) u.current(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = row_h }, 40, 0);
u.text(if (newest) .mono_bold else .mono, size, m.side, baseline(y), u.print("#{d}", .{n}), if (newest) gold.on_solid else t.faint);
const where_x = w - m.side - u.width(.mono, size, where);
const args_x: f32 = 384;
@@ -515,10 +555,11 @@ pub const Arcs = struct {
/// 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.
+ /// the shorter, and the rest are only read. A lane change glides: while
+ /// an arc draws or fades (12 f), the others go from the lanes they have
+ /// without it to those they have with it, as far as it has drawn or shows.
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;
@@ -536,11 +577,35 @@ pub const Arcs = struct {
return x.hi - x.lo > y.hi - y.lo;
}
}.longer);
+ // Arriving or leaving: how far (the least of them), and the lanes without them.
+ var settled: f32 = 1;
+ for (a.items[0..a.n]) |arc| settled = @min(settled, @min(arc.drawn, arc.shows));
+ const with = a.assign(spans[0..a.n], lanes, false);
+ const without = if (settled < 1) a.assign(spans[0..a.n], lanes, true) else with;
+ for (spans[0..a.n]) |sp| {
+ const arc = a.items[sp.i];
+ const lane = with[sp.i] orelse continue;
+ const was = without[sp.i] orelse lane;
+ const x = std.math.lerp(k.lanes[was], k.lanes[lane], cursorGlide(settled));
+ 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 });
+ }
+ }
+
+ const Span = struct { lo: f32, hi: f32, y0: f32, y1: f32, i: usize };
+
+ /// Each span's lane (`spans` longest first), the step's first; `settled`:
+ /// only of the arcs neither drawing nor fading (those keep their lane in full).
+ fn assign(a: *const Arcs, spans: []const Span, lanes: usize, settled: bool) [32]?usize {
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;
+ for ([_]bool{ true, false }) |hot| for (spans) |sp| {
+ const arc = a.items[sp.i];
+ if (arc.hot != hot or (settled and (arc.drawn < 1 or arc.shows < 1))) 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;
@@ -552,16 +617,11 @@ pub const Arcs = struct {
}
} 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 });
- }
+ return lane_of;
+ }
+
+ fn cursorGlide(p: f32) f32 {
+ return theme.ease(.glide, std.math.clamp(p, 0, 1));
}
};
diff --git a/anim/src/source.zig b/anim/src/source.zig
index 3843825..0705f5b 100644
--- a/anim/src/source.zig
+++ b/anim/src/source.zig
@@ -32,21 +32,29 @@ pub const Source = struct {
/// In a `descent`: while the pc is in code without source, the line it
/// called from waits, ringed, and the tag says where the pc is.
descent: bool = false,
+ /// Which box of its stage it is in: on the map the source may go on in `source_more`.
+ part: @import("stage.zig").Part = .source,
pub fn draw(p: *const Source, f: *sk.Frame, placed: anim.Placed) void {
- const box = p.stage.box(placed, .source);
+ const box = p.stage.box(placed, p.part);
+ if (box.h < m.tag + m.row) return;
const u = context.at(f, placed, box);
const rec = p.cursor.rec;
const now = p.cursor.now(placed);
const text = prepared(rec.source, rec.file) orelse return;
+ // Its window, and on the map the lines of both its boxes (`continued`): this one from `skip` lines in.
+ const head = theme.layout.rowsIn(p.stage.box(placed, .source).h);
+ const tail = theme.layout.rowsIn(p.stage.box(placed, .source_more).h);
const fit: u32 = @intCast(theme.layout.rowsIn(box.h));
+ const span_fit: u32 = @intCast(head + tail);
+ const skip: f32 = if (p.part == .source_more) @floatFromInt(head) else 0;
// The mark: leaving the line of one moment for that of the next.
const was = rec.own[now.marks[0]];
const here = rec.own[now.marks[1]];
// The window: where the line it is on has it, and (as the mark
// moves on) gliding to where the next one does. It never cuts.
const going = now.advancing();
- const windows = [2]f32{ @floatFromInt(rec.viewFirst(fit, was)), @floatFromInt(rec.viewFirst(fit, here)) };
+ const windows = [2]f32{ @as(f32, @floatFromInt(rec.viewFirst(span_fit, was))) + skip, @as(f32, @floatFromInt(rec.viewFirst(span_fit, here))) + skip };
// Farther than its own height (another function far off): what
// leaves has left before what replaces it arrives; a scroll of more
// lines than the window shows would be a blur, and say nothing.
@@ -64,9 +72,9 @@ pub const Source = struct {
var notes: [2][]const u8 = undefined;
for (now.marks, &notes) |mk, *note| note.* = if (p.descent and !rec.sourced(mk) and rec.own[mk] != 0) u.print("{s} waits at line {d} \u{00b7} the pc is in {s}", .{ context.frameName(u, rec, rec.register(firstOwn(rec, mk), "rip")), rec.own[mk], whereIs(u, rec, mk) }) else lines_note;
const swap = !std.mem.eql(u8, notes[0], notes[1]) and (notes[0].ptr != lines_note.ptr or notes[1].ptr != lines_note.ptr) and now.walking();
- const body = u.panel(box.w, box.h, rec.file, .{ .focus = p.focus, .note = if (swap) "" else if (waits) notes[if (going >= 0.5) 1 else 0] else lines_note });
+ const body = u.panel(box.w, box.h, if (p.part == .source_more) u.print("{s}, continued", .{rec.file}) else rec.file, .{ .focus = p.focus, .note = if (swap) "" else if (waits) notes[if (going >= 0.5) 1 else 0] else lines_note });
if (swap) {
- const c = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1);
+ const c = now.renaming();
u.faded(1 - c).tagNote(box.w, notes[0]);
u.faded(c).tagNote(box.w, notes[1]);
}
@@ -109,28 +117,40 @@ pub const Source = struct {
} else if (shows > 0) u.faded(shows).current(.{ .x = theme.stroke.rule, .y = mark_y, .w = box.w - 2 * theme.stroke.rule, .h = m.row }, theme.metric.plaque.line + widen, now.fires(.source));
if (shows >= 1 and mark_y >= body.y and mark_y + m.row <= box.h) ties.anchor(u, .source, .{ .x = 0, .y = mark_y, .w = box.w, .h = m.row });
- // The trail: the last three other lines it was on. It shifts without animation.
- const on_line = rec.own[now.marked()];
- var trail: [3]u32 = @splat(0);
- var found: usize = 0;
- var back = now.marked();
- while (back > 0 and found < trail.len) {
- back -= 1;
- const l = rec.own[back];
- if (l == 0 or l == on_line or std.mem.indexOfScalar(u32, trail[0..found], l) != null) continue;
- trail[found] = l;
- found += 1;
+ // The trail: the last three other lines it was on, as the mark left
+ // them and as it finds them: a bar that moves crossfades with the advance.
+ var trails: [2][3]u32 = @splat(@splat(0));
+ var founds = [2]usize{ 0, 0 };
+ for (now.marks, &trails, &founds) |mk, *trail, *found| {
+ const on_line = rec.own[mk];
+ var back = mk;
+ while (back > 0 and found.* < trail.len) {
+ back -= 1;
+ const l = rec.own[back];
+ if (l == 0 or l == on_line or std.mem.indexOfScalar(u32, trail[0..found.*], l) != null) continue;
+ trail[found.*] = l;
+ found.* += 1;
+ }
}
- map.window(.source, shown_first, @min(shown_first + fit - 1, rec.line_count));
+ const lines_of = struct {
+ fn of(at: f32, n: u32, lines: u32) [2]u64 {
+ const a: u32 = @intFromFloat(at);
+ return .{ a, @min(a + n - 1, lines) };
+ }
+ }.of;
+ map.window(.source, lines_of(windows[1], fit, rec.line_count), lines_of(windows[0], fit, rec.line_count), cursors.glide(going));
var line = @max(from, 1);
while (line <= last) : (line += 1) {
const y = top + (@as(f32, @floatFromInt(line)) - first) * m.row;
map.row(.source, line, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
const span = text.lines[line - 1];
- const k = std.mem.indexOfScalar(u32, trail[0..found], line);
+ const ks = [2]?usize{ std.mem.indexOfScalar(u32, trails[0][0..founds[0]], line), std.mem.indexOfScalar(u32, trails[1][0..founds[1]], line) };
+ const k = if (going >= 0.5) ks[1] else ks[0];
const on = shows >= 0.5 and line == mark_line;
- rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on and !waits) .marked else if (k) |n| .{ .trail = n } else .plain);
+ const fading = !std.meta.eql(ks[0], ks[1]) and going > 0 and going < 1;
+ rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on and !waits) .marked else if (fading) .plain else if (k) |n| .{ .trail = n } else .plain);
+ if (fading and !(on and !waits)) for (ks, [2]f32{ 1 - going, going }) |kk, amount| if (kk) |n| lit.faded(amount).trail(theme.stroke.rule, y, n);
}
// The source is read at a run; at a sprint it is veiled too.
context.veiled(u, box, now.sprint_veil);
diff --git a/anim/src/stage.zig b/anim/src/stage.zig
index a24ec28..35988aa 100644
--- a/anim/src/stage.zig
+++ b/anim/src/stage.zig
@@ -10,7 +10,7 @@ const theme = ui.theme;
const Split = theme.layout.Split;
const Rect = theme.Rect;
-pub const Part = enum { band, view, source, disasm, registers, stack, backtrace, more };
+pub const Part = enum { band, view, source, disasm, registers, stack, backtrace, more, source_more };
pub const Stage = struct {
first: Split,
diff --git a/anim/src/theme.zig b/anim/src/theme.zig
index 78c1d7d..cb52287 100644
--- a/anim/src/theme.zig
+++ b/anim/src/theme.zig
@@ -111,6 +111,12 @@ pub const layout = struct {
dump_rows: u32,
/// On the map: the rest of a column, where the stack goes on (`continued`).
more: Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 },
+ /// On the map: the source going on, `continued`, where its column cannot hold it.
+ source_more: Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 },
+ /// On the map: the rest of the first two columns (under the backtrace,
+ /// under the disassembly), given to the dumps round what the registers
+ /// and the stack point at, the loupes open and the key (`map.Spare`).
+ spare: [2]Rect = @splat(.{ .x = 0, .y = 0, .w = 0, .h = 0 }),
};
pub const split = struct {
/// The machine alone: fourteen lines over seventeen instructions;
@@ -971,6 +977,9 @@ pub const time = struct {
/// The minimap follows the frame this far behind: secondary action, it
/// never starts on a primary onset's frame.
pub const minimap_lag = 6.0 / 60.0;
+ /// And every change on it fades in over this many frames, a frame apart
+ /// from the lag: it is drawn this many times, each a frame later, averaged.
+ pub const minimap_fade = 6;
/// A hurried step with this long or more is still a whole sentence,
/// said faster; with less, it is a run.
pub const walk_least = 0.70;
diff --git a/anim/src/ties.zig b/anim/src/ties.zig
index d3a9ec7..e25c34b 100644
--- a/anim/src/ties.zig
+++ b/anim/src/ties.zig
@@ -139,7 +139,11 @@ pub fn pinShows(now: cursors.Now, i: usize, target: enum { slot, node }) struct
if (now.registerAge(i) != 0) return .{ .old = 1, .new = 1 };
if (now.resting()) return .{ .old = 0, .new = 1 };
const since = linkSince(now, i);
- if (!now.walking()) return if (since >= 0) .{ .old = 0, .new = 1 } else .{ .old = 1, .new = 0 };
+ // At a run the pin changes with the run's ease (8 f), never in a frame.
+ if (!now.walking()) {
+ const p = std.math.clamp(since / time.run_ease, 0, 1);
+ return .{ .old = 1 - p, .new = p };
+ }
const l = time.link;
const arrives = l.after + linkTime(if (target == .slot) .slot else .node);
return .{
@@ -180,8 +184,9 @@ pub const Ties = struct {
defer stack_window = null;
defer thread_waits = false;
const now = g.cursor.now(at);
- // Diving or surfacing, the panels are on their way: no ties.
+ // Diving or surfacing, the panels are on their way: no ties; nor while the map alone is looked at.
for (@import("context.zig").zoomed) |z| if (z != null) return;
+ if (@import("map.zig").looking(f)) return;
// In canvas pixels, `k` of them a unit: places come from panels anywhere.
var raw: ui.Ui = .{ .f = f, .at = at };
raw.at.xf = .identity;
diff --git a/anim/src/words.zig b/anim/src/words.zig
index 280abbc..4d221f4 100644
--- a/anim/src/words.zig
+++ b/anim/src/words.zig
@@ -69,6 +69,7 @@ pub const Clock = struct {
u.faded(now.hurried).text(.mono, size, count_x - u.width(.mono, size, steps) - 3 * ui.advance(size), base, steps, t.dim);
}
if (k.map) |m| {
+ if (@import("map.zig").looking(f)) return m.wholeMap(f, at);
m.fallingOver(f, at);
@import("map.zig").minimap(m, f, at);
}