diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 22:02:01 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 22:06:03 -0300 |
| commit | 8b5d0340c9f9b3168c67f04e57cfa03712ac992c (patch) | |
| tree | 66891f03e905731b8afa2689e86fe612675f4f35 /anim/src/cursor.zig | |
| parent | 36bb1c332a124cb4d437dd8386b267ee58310a5d (diff) | |
| download | computeranim-8b5d0340c9f9b3168c67f04e57cfa03712ac992c.tar.gz computeranim-8b5d0340c9f9b3168c67f04e57cfa03712ac992c.zip | |
canim: a continue is a wave; what arrives after a fade is plain; a pin only where its register points
From the designer's review of the SQLite scene. Between far stops the
changed registers strike two frames apart in pwndbg's order, and links
and pins set off with memory. A stack window or a dump that fades in
carries no marks of changes the viewer did not see. At rest a moved
register kept a pin at its old place as well, in every scene: gone. The
kernel's answer is filled before the return arrow leaves, and rax strikes
as it lands. Every dump has one reading, by type (a char quoted, a bool
by name); line numbers are as wide as the program's largest; pins' names
keep the side they came to. Names and measures follow the catalogue
(.loose, theme.metric.calls, time.pin, time.continue_wave).
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'anim/src/cursor.zig')
| -rw-r--r-- | anim/src/cursor.zig | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig index ec05ec0..f196fab 100644 --- a/anim/src/cursor.zig +++ b/anim/src/cursor.zig @@ -78,6 +78,8 @@ pub const Plan = struct { travel: f32 = time.step, /// The whole step: the advance, then a rest in which the next line is read. total: f32 = time.fire + time.step + time.rest, + /// A `continue`: the registers strike in a wave, no arm and no pulse. + wave: bool = false, /// Once the pattern is known: the levels a stagger apart from the /// first frame, the mark after them, in `seconds`. @@ -106,7 +108,7 @@ pub const Cursor = struct { /// 0 to 1 through the step it is taking; 1 at rest. phase: anim.Value, /// The step's `Plan`, a value a field. - plan: [7]anim.Value, + plan: [8]anim.Value, /// The moment the current mark was on, and the one it is on (or going to). marks: [2]anim.Value, /// 1 while steps are hurried (the head counts them), and while what @@ -132,7 +134,7 @@ pub const Cursor = struct { .rec = rec, .stops = undefined, .phase = s.value(1), - .plan = .{ s.value(0), s.value(plan.at[0]), s.value(plan.at[1]), s.value(plan.at[2]), s.value(plan.advance), s.value(plan.travel), s.value(plan.total) }, + .plan = .{ s.value(0), s.value(plan.at[0]), s.value(plan.at[1]), s.value(plan.at[2]), s.value(plan.advance), s.value(plan.travel), s.value(plan.total), s.value(0) }, .marks = .{ s.value(here), s.value(here) }, .hurried = s.value(0), .veil = s.value(0), @@ -172,16 +174,16 @@ pub const Cursor = struct { /// sentence said faster). pub fn step(c: Cursor, s: *anim.Frame, to: u64, plan: Plan, seconds: f32) void { const from = c.moment(s); - var set: [history + 11]anim.Animation = undefined; + var set: [history + 12]anim.Animation = undefined; for (1..history) |i| set[i] = c.stops[i].to(settled(s, c.stops[i - 1])); set[0] = c.stops[0].to(@floatFromInt(to)); - for (c.plan, [_]f32{ @floatFromInt(@intFromEnum(plan.gait)), plan.at[0], plan.at[1], plan.at[2], plan.advance, plan.travel, plan.total }, history..) |value, is, n| set[n] = value.to(is); + for (c.plan, [_]f32{ @floatFromInt(@intFromEnum(plan.gait)), plan.at[0], plan.at[1], plan.at[2], plan.advance, plan.travel, plan.total, @floatFromInt(@intFromBool(plan.wave)) }, history..) |value, is, n| set[n] = value.to(is); // At a sprint the mark is seen only where a phrase ends. const was = settled(s, c.marks[1]); - set[history + 7] = c.marks[0].to(was); - set[history + 8] = c.marks[1].to(if (plan.gait == .sprint and !c.phraseEnds(from, to)) was else @floatFromInt(to)); - set[history + 9] = c.phase.to(0); - set[history + 10] = c.count.to(settled(s, c.count) + 1); + set[history + 8] = c.marks[0].to(was); + set[history + 9] = c.marks[1].to(if (plan.gait == .sprint and !c.phraseEnds(from, to)) was else @floatFromInt(to)); + set[history + 10] = c.phase.to(0); + set[history + 11] = c.count.to(settled(s, c.count) + 1); s.play(set, .{ .seconds = 0 }); s.play(.{c.phase.to(1)}, .{ .seconds = seconds, .ease = anim.ease.linear }); } @@ -207,6 +209,24 @@ pub const Cursor = struct { /// advance; a rest. A line and no more comes to 0.8 s, one value to /// 1.5, a register and memory to 2.0, a call through three levels 2.5. pub fn reading(c: Cursor, from: u64, to: u64) Plan { + return c.timetable(from, to, false); + } + + /// `continue`: straight to a stop far from this one (a breakpoint, not + /// a step). The line it leaves fires; the registers it changed strike + /// in a wave, 2 f apart in pwndbg's order, the fill in over 6 f, no arm + /// and no pulse (a dozen arms at once are a crowd, a dozen pulses a + /// flash); memory 18 f after the last of them (the stack's window + /// scrolls or fades to its place, the backtrace's frames leave, slide + /// and arrive), then the idea; a hold of 36 f after the last strike; + /// the advance, the mark out and in (6 f each), the source fading + /// through first if it goes farther than its window; a rest. + pub fn @"continue"(c: Cursor, s: *anim.Frame, to: u64) void { + const plan = c.timetable(c.moment(s), to, true); + c.step(s, to, plan, plan.total); + } + + fn timetable(c: Cursor, from: u64, to: u64, wave: bool) Plan { const rec = c.rec; const regs: f32 = @floatFromInt(@popCount(rec.registersChanged(from, to) & ~quiet)); // Memory gives up its slot when nothing it touched is drawn. @@ -227,7 +247,7 @@ pub const Cursor = struct { .data => touched, }, }; - var plan: Plan = .{ .travel = c.travel(from, to) }; + var plan: Plan = .{ .travel = c.travel(from, to, wave), .wave = wave }; var slot: f32 = 0; for (levels, &plan.at, 0..) |is, *strikes, level| { // A drawing made of the bytes reacts when the projection from @@ -236,6 +256,8 @@ pub const Cursor = struct { const projected = level == 2 and is and levels[1] and (c.levels.idea == .data or deeper); if (projected) slot += time.project.bracket + @as(f32, if (c.levels.idea == .data) time.project.draw else time.project.far) + @as(f32, if (wrote > 0 and c.levels.idea == .data) time.strike.arm else 0) else if (is) slot += time.cascade; strikes.* = @max(slot, time.cascade); + // A wave's last register strikes 2 f a register after its first: the next level is 18 f after that. + if (wave and level == 0 and is) slot += (regs - 1) * time.continue_wave; } // The writes of one step strike 6 f apart: the last is later. if (levels[1]) slot += @min(@max(wrote - 1, 0), 3) * write_apart; @@ -251,19 +273,21 @@ pub const Cursor = struct { .calls => if (back) time.returning else time.snap, .data => c.levels.follow, }; - plan.advance = slot + follow + @min(time.read_value + time.read_more * (values - 1), time.read_most); + // A continue's hold is 36 f: what it changed is too much to read value by value. + plan.advance = slot + follow + if (wave) time.read_value else @min(time.read_value + time.read_more * (values - 1), time.read_most); } plan.total = plan.advance + plan.travel + time.rest; return plan; } /// How long the mark takes to the next line: a slide by how far, or a - /// jump (out, then in) into or out of a call, or further than a few rows. - fn travel(c: Cursor, from: u64, to: u64) f32 { + /// jump (out, then in) into or out of a call, further than a few rows, + /// or at the end of a continue (`wave`). + fn travel(c: Cursor, from: u64, to: u64, wave: bool) f32 { const rec = c.rec; // The source's window moves with it: by whole lines, and never a cut. if (rec.viewFirst(c.levels.source_rows, rec.own[from]) != rec.viewFirst(c.levels.source_rows, rec.own[to])) return time.move; - if (jumps(rec, from, to)) return 2 * time.current_jump; + if (wave or jumps(rec, from, to)) return 2 * time.current_jump; const rows: f32 = @floatFromInt(@max(rec.own[from], rec.own[to]) - @min(rec.own[from], rec.own[to])); return @min(time.step + time.step_per_row * @max(rows - 1, 0), time.step_max); } @@ -346,6 +370,7 @@ pub const Cursor = struct { .advance = placed.value(c.plan[4]), .travel = placed.value(c.plan[5]), .total = placed.value(c.plan[6]), + .wave = placed.value(c.plan[7]) >= 0.5, }, .marks = .{ whole(rec, placed.value(c.marks[0])), whole(rec, placed.value(c.marks[1])) }, .hurried = placed.value(c.hurried), @@ -587,6 +612,14 @@ pub const Now = struct { return n.heat(n.writeAge(addr, size), n.writeAgeFrom(addr, size, 1), n.since(level, delay + n.writeDelay(addr, size))); } + /// `written`, on a thing the viewer has watched only through the steps + /// `lo` to `hi` ago (a window that faded to its place, a view that came + /// in after its step): what changed in any other step is plain. + pub fn writtenWatched(n: Now, addr: u64, size: u64, level: Level, delay: f32, lo: usize, hi: usize) ui.Heat { + const age = n.writeAge(addr, size) orelse return .none; + return if (age >= lo and age < hi) n.written(addr, size, level, delay) else .none; + } + /// How far after this step's first write the one of `addr .. addr + size` is. pub fn writeDelay(n: Now, addr: u64, size: u64) f32 { var order: f32 = 0; @@ -600,9 +633,14 @@ pub const Now = struct { return 0; } - /// The mark of a register: the CPU's level. + /// The mark of a register: the CPU's level. In a continue's wave, no arm and no pulse. pub fn register(n: Now, reg: usize, delay: f32) ui.Heat { - return n.heat(n.registerAge(reg), n.registerAgeFrom(reg, 1), n.since(.cpu, delay)); + var h = n.heat(n.registerAge(reg), n.registerAgeFrom(reg, 1), n.since(.cpu, delay)); + if (n.plan.wave) { + h.arm = 0; + h.out = 0; + } + return h; } /// How much (0 to 1) the frame round a thing this step read shows: in |
