diff options
Diffstat (limited to 'anim/src/regroup.zig')
| -rw-r--r-- | anim/src/regroup.zig | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/anim/src/regroup.zig b/anim/src/regroup.zig index 431abd8..c9f618a 100644 --- a/anim/src/regroup.zig +++ b/anim/src/regroup.zig @@ -92,7 +92,8 @@ pub const Words = struct { } /// The return address the newest frame has, and the first word that - /// points into the heap, into the stack, and the return address, top down. + /// points into the heap (or, with none, the first other address), into + /// the stack, and the return address, top down. pub fn pick(rec: *const Recording, moment: u64) struct { walked: usize, three: [3]usize } { const m = rec.moment(moment); const rsp = rec.register(moment, "rsp"); @@ -109,12 +110,17 @@ pub const Words = struct { const values = read(rec, moment); var heap: ?usize = null; var stack: ?usize = null; + var other: ?usize = null; for (values.words, 0..) |v, i| switch (rows.regionOf(m, v)) { .heap => heap = heap orelse i, .stack => stack = stack orelse i, - else => {}, + .none => {}, + else => if (i != walked) { + other = other orelse i; + }, }; - var three = [3]usize{ heap orelse 0, stack orelse 1, walked }; + // With no heap word in the 128 bytes, the first other address that is not the walked one. + var three = [3]usize{ heap orelse other orelse 1, stack orelse 2, walked }; std.mem.sort(usize, &three, {}, std.sort.asc(usize)); return .{ .walked = walked, .three = three }; } @@ -162,11 +168,11 @@ pub const Words = struct { const data = read(w.rec, w.at); const m = w.rec.moment(w.at); // The header (mock 29), with the first row; gone as the dump is tied to its place. - const header = clamp01(in / 18) * (1 - placed.value(w.placed)); + // The veil over every row but the walked one, while it is walked (the header too). + const veil = clamp01((r - 48) / 18) - clamp01((r - 270) / 18); + const header = clamp01(in / 18) * (1 - placed.value(w.placed)) * (1 - veil); if (header > 0) v.faded(header).text(.sans, theme.size.sans.micro, at.address, at.top - 12, "128 bytes, from where rsp points", t.faint); - // The veil over every row but the walked one, while it is walked. - const veil = clamp01((r - 48) / 18) - clamp01((r - 270) / 18); const address_ink = ui.mix(t.faint, theme.color.region.stack, placed.value(w.placed)); const become = placed.value(w.become); const g = glide(become); @@ -178,9 +184,10 @@ pub const Words = struct { const slot: f32 = @floatFromInt(@as(i64, @bitCast(data.base + 8 * i -% w.panel.first)) >> 3); const y = std.math.lerp(p.y, w.panel.top + pitch * slot, g); const base = theme.baseline(y, pitch, size); - const ax = std.math.lerp(at.address, w.panel.x + theme.metric.slot.address, g); + // The bytes go first (9 f), then the addresses travel right to the slots' column: never over them. + const ax = std.math.lerp(at.address, w.panel.x + theme.metric.slot.address, glide((become - 0.25) / 0.75)); if (p.address > 0) _ = row.faded(p.address).address(ax, base, data.base + 8 * i, .{ .ink = address_ink }); - w.drawBytes(row.faded(1 - clamp01(become * 2)), data, i, p.x, base, r, placed); + w.drawBytes(row.faded(1 - clamp01(become * 4)), data, i, p.x, base, r, placed); w.drawWord(row, m, data.words[i], i, y, r, placed); } if (r >= 0) w.walk(v, data, r); @@ -258,7 +265,13 @@ pub const Words = struct { // A code address's chain is its name: it comes in as a hop does (6 f). const end = v.address(rect.x, base, value, .{ .ink = ink, .rwx = kind == .rwx }); var name_buf: [128]u8 = undefined; - if (m.string(value, &name_buf) catch null) |name| v.faded(clamp01(since * 10)).text(.mono, size, end + 10, base, ui.symbol(u, name), t.primary); + if (m.string(value, &name_buf) catch null) |name| { + // Cut with `…` at the state column's edge, as the stack's rows cut theirs. + const sym = ui.symbol(u, name); + const fits: usize = @intFromFloat(@max((theme.layout.state.x + theme.layout.state.w - end - 10) / adv, 2)); + const shown = if (sym.len > fits) u.print("{s}\u{2026}", .{sym[0 .. fits - 1]}) else sym; + v.faded(clamp01(since * 10)).text(.mono, size, end + 10, base, shown, t.primary); + } return; } if (since >= 0) { @@ -277,13 +290,20 @@ pub const Words = struct { const y = at.top + pitch * @as(f32, @floatFromInt(w.walked)); const base = theme.baseline(y, pitch, size); const value = data.words[w.walked]; - // Under the row, its offsets and labels on the page (the veiled rows under them give way). + // A row near the dump's top has no room over it for the arcs at x2 (the camera's frame + // begins two rows over the header): there the bytes fly under the row, over the veiled + // rows, and the offsets and labels stand over it, the header's place (veiled with the rest). + const flip = w.walked < 4; + const dir: f32 = if (flip) -1 else 1; + // Under the row (over it, flipped), its offsets and labels on the page (the veiled rows there give way). // They go as the gaps close (192), not after: closed, their pairs are 24 apart and they would touch. const labels = clamp01((r - 84) / 12) * (1 - clamp01((r - 192) / 12)); const offsets = clamp01((r - 66) / 12) * (1 - clamp01((r - 192) / 12)); const zeros_mark = clamp01((r - 204) / 12) * (1 - clamp01((r - 228) / 12)); - const under = @max(offsets, zeros_mark); - if (under > 0) u.faded(under).fill(.{ .x = at.bytes - 12, .y = y + pitch, .w = at.field_end - at.bytes + 24, .h = 2 * pitch + 6 }, theme.color.page); + const page_x = at.bytes - 12; + const page_w = at.field_end - at.bytes + 24; + if (offsets > 0) u.faded(offsets).fill(.{ .x = page_x, .y = if (flip) y - 2 * pitch - 6 else y + pitch, .w = page_w, .h = 2 * pitch + 6 }, theme.color.page); + if (zeros_mark > 0) u.faded(zeros_mark).fill(.{ .x = page_x, .y = y + pitch, .w = page_w, .h = 2 * pitch + 6 }, theme.color.page); const close = glide((r - 192) / 12); for (0..8) |k| { const kf: f32 = @floatFromInt(k); @@ -294,7 +314,7 @@ pub const Words = struct { const long = to - from; const high = std.math.clamp(long / 4, theme.time.flight.arc_min, theme.time.flight.arc_max); const x = std.math.lerp(from, to, theme.ease(.glide, s)); - const lift = high * @sin(std.math.pi * s); + const lift = dir * high * @sin(std.math.pi * s); // The byte itself: bright and bold in the air (from 108 the walk draws it, not the row). if (r >= 108) { const air = s > 0 and s < 1; @@ -310,13 +330,13 @@ pub const Words = struct { } // Its offset under it, going with it. const off = offsets * clamp01((r - 66 - 2 * kf) / 12); - if (off > 0 and s > 0 and s < 1) u.faded(off).fill(.{ .x = x - 3, .y = base + pitch - lift - 18, .w = 2 * adv + 6, .h = 24 }, theme.color.page); - if (off > 0) u.faded(off).text(.mono, size, x, base + pitch - lift, u.print("+{d}", .{k}), t.dim); + if (off > 0 and s > 0 and s < 1) u.faded(off).fill(.{ .x = x - 3, .y = base + dir * pitch - lift - 18, .w = 2 * adv + 6, .h = 24 }, theme.color.page); + if (off > 0) u.faded(off).text(.mono, size, x, base + dir * pitch - lift, u.print("+{d}", .{k}), t.dim); // `low byte` from its byte's left, `high byte` to its byte's right: under the bytes, never the addresses. if (k == 0 or k == 7) if (labels > 0) { const label = if (k == 0) "low byte" else "high byte"; const lw = u.width(.sans, theme.size.sans.tag, label); - u.faded(labels).text(.sans, theme.size.sans.tag, if (k == 0) x else x + 2 * adv - lw, base + 2 * pitch + 2 - lift, label, t.dim); + u.faded(labels).text(.sans, theme.size.sans.tag, if (k == 0) x else x + 2 * adv - lw, base + dir * 2 * pitch + 2 - lift, label, t.dim); }; } // The zeros in front, bracketed (motion.md: 204 to 228). |
