summaryrefslogtreecommitdiff
path: root/anim/src/cursor.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/cursor.zig')
-rw-r--r--anim/src/cursor.zig65
1 files changed, 57 insertions, 8 deletions
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig
index b09db8d..c145823 100644
--- a/anim/src/cursor.zig
+++ b/anim/src/cursor.zig
@@ -80,8 +80,17 @@ pub const Levels = struct {
annotation: enum { tied, whole } = .tied,
/// A value's way between memory and a register (`carry`, "4. Ties"),
/// read at each step (a beat may turn it on): none, an arrow, or the
- /// arrow carrying the value's digits on a chip.
- carry: enum { off, arrow, value } = .off,
+ /// arrow carrying the value's digits on a chip; or the arrow after the
+ /// instruction's touch, a store's too (the row names the word, then the
+ /// value goes there: the introduction's `push rbp`).
+ carry: enum { off, arrow, value, after_touch } = .off,
+ /// The introduction's (design/motion.md, "A scene: the introduction"):
+ /// what the working frame leaves to the eye, said: the stack's offsets
+ /// and a pin's amount written with `0x` where hex and decimal differ
+ /// (beside a symbol's decimal offset, `main+50`), a return address's
+ /// role named (`the way back`), and a store of the value its word held
+ /// struck as any write (the step's event).
+ introduction: bool = false,
};
/// How a step is drawn. Walk: everything, as a sentence. Run: the mark and
@@ -303,6 +312,11 @@ pub const Cursor = struct {
/// The `aim` relation's knob (design/README.md, "4. Ties"): 0 off (the
/// default), 1 standing (in and out over 18 f), 2 for the step.
aim_knob: anim.Value,
+ /// A standing aim drawn as a step's is (`aim(.drawn)`): frames of its
+ /// way, 0 to 24 (18 the head's, 6 the row's frame; past 24, drawn), and
+ /// 1 while at full ink, 0 at the standing 60%.
+ aim_drawn: anim.Value,
+ aim_lit: anim.Value,
/// 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
@@ -333,6 +347,8 @@ pub const Cursor = struct {
.sprint_veil = s.value(0),
.count = s.value(0),
.aim_knob = s.value(0),
+ .aim_drawn = s.value(99),
+ .aim_lit = s.value(0),
.lags = undefined,
.first = start,
.last = start,
@@ -628,7 +644,12 @@ pub const Cursor = struct {
const writes = c.levels.memory and (wrote > 0 or (touch != null and touch.?.write));
if (writes) {
const store = if (carry) |cc| !cc.load else false;
- if (store) {
+ if (store and c.levels.carry == .after_touch and touch != null and touch.?.write) {
+ // The touch to the word, the register framed as read (6 f), then the carry.
+ plan.touch = t + 6 * f;
+ plan.carry = plan.touch + k.touch + 12 * f;
+ plan.at[1] = plan.carry + k.carry + time.strike.arm;
+ } else if (store) {
// The register framed as read (6 f), then the carry: no touch, the row having named the word.
plan.carry = t + 12 * f;
plan.at[1] = plan.carry + k.carry + time.strike.arm;
@@ -778,30 +799,50 @@ pub const Cursor = struct {
/// off unless the author turns it on, for a scene or a beat): `.standing`
/// draws the aims of the words on screen, coming and going over 18 f;
/// `.step` those of the words a walked step writes or reads.
- pub fn aim(c: Cursor, s: *anim.Frame, knob: enum { off, step, standing }) void {
+ /// `drawn`: standing, but drawn as a step's aim is, head first from the
+ /// word at full ink (18 f), the row's address framed as it lands (6 f);
+ /// a `standing` after it falls to 60% (18 f).
+ pub fn aim(c: Cursor, s: *anim.Frame, knob: enum { off, step, standing, drawn }) void {
// Over what follows: the timeline's cursor stays where it was.
const start = s.cursor;
defer s.cursor = start;
switch (knob) {
- .off, .standing => s.play(.{c.aim_knob.to(if (knob == .off) 0 else 1)}, .{ .seconds = 18.0 / 60.0, .ease = anim.ease.linear }),
+ .off, .standing => s.play(.{ c.aim_knob.to(if (knob == .off) 0 else 1), c.aim_lit.to(0) }, .{ .seconds = 18.0 / 60.0, .ease = anim.ease.linear }),
.step => s.play(.{c.aim_knob.to(2)}, .{ .seconds = 0 }),
+ .drawn => {
+ s.play(.{ c.aim_knob.to(1), c.aim_lit.to(1), c.aim_drawn.to(0) }, .{ .seconds = 0 });
+ s.play(.{c.aim_drawn.to(24)}, .{ .seconds = 24.0 / 60.0, .ease = anim.ease.linear });
+ },
}
}
/// There at once, with nothing struck: a cut.
pub fn jump(c: Cursor, s: *anim.Frame, to: u64) void {
+ c.jumpWalked(s, to, to);
+ }
+
+ /// There at once, as though each moment from `from` on had been walked
+ /// to `to`, at rest: what the panels read of the steps before (the rows
+ /// run, the trail, the marks they left) as a walk leaves it (a chapter
+ /// opening on the last one's picture).
+ pub fn jumpWalked(c: Cursor, s: *anim.Frame, from: u64, to: u64) void {
const Jump = struct {
+ from: u64,
to: u64,
fn run(j: @This(), sf: *anim.Frame, v: Cursor) void {
var all: [history + 3]anim.Animation = undefined;
- for (v.stops, 0..) |stop_value, i| all[i] = stop_value.to(@floatFromInt(j.to));
+ for (v.stops, 0..) |stop_value, i| all[i] = stop_value.to(@floatFromInt(@max(j.to -| i, j.from)));
all[history] = v.phase.to(1);
all[history + 1] = v.marks[0].to(@floatFromInt(j.to));
all[history + 2] = v.marks[1].to(@floatFromInt(j.to));
sf.play(all, .{ .seconds = 0 });
}
};
- c.both(s, Jump{ .to = to });
+ // At the scene's first instant there is no before for the minimap's mirrors to lag behind.
+ if (s.cursor == 0) {
+ for (0..c.lags.len) |k| (Jump{ .from = from, .to = to }).run(s, lagged(c, k));
+ (Jump{ .from = from, .to = to }).run(s, c);
+ } else c.both(s, Jump{ .from = from, .to = to });
}
/// For a component, while it draws (on the minimap the values are a lagging mirror's: `lagInto`).
@@ -824,6 +865,9 @@ pub const Cursor = struct {
.annotation = c.levels.annotation,
.way = .{ c.first, c.last },
.aim = placed.value(c.aim_knob),
+ .aim_drawn = placed.value(c.aim_drawn),
+ .aim_lit = placed.value(c.aim_lit),
+ .introduction = c.levels.introduction,
};
var plan: [Plan.values]f32 = undefined;
for (&plan, c.plan) |*is, v| is.* = placed.value(v);
@@ -908,8 +952,13 @@ pub const Now = struct {
annotation: @FieldType(Levels, "annotation") = .tied,
/// The scene's way through the recording: its first moment and its last.
way: [2]u64 = .{ 0, 0 },
- /// The `aim` knob: 0 off, up to 1 standing (coming or going), 2 for the step.
+ /// The `aim` knob: 0 off, up to 1 standing (coming or going), 2 for the step;
+ /// a standing one's way drawn (`Cursor.aim_drawn`, frames) and its ink (`aim_lit`).
aim: f32 = 0,
+ aim_drawn: f32 = 99,
+ aim_lit: f32 = 0,
+ /// `Levels.introduction`.
+ introduction: bool = false,
/// The program's state as shown.
pub fn moment(n: Now) Recording.Moment {