diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-26 11:12:04 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-26 11:12:04 -0300 |
| commit | adb23572bc2d7aae09cf8605825f6d48ca23ba4a (patch) | |
| tree | 1afa309350d0d730342ccacbbd19ca1f5af9b4df /build.zig | |
| parent | 55743cc5d564f6ef6d6f8a0eb1a614a74b021d3a (diff) | |
| download | esp32p4-adb23572bc2d7aae09cf8605825f6d48ca23ba4a.tar.gz esp32p4-adb23572bc2d7aae09cf8605825f6d48ca23ba4a.zip | |
Set the grid from the firmware build, and check Poke against Peek on the die
## -Dcols / -Drows
The geometry is baked into pardes's object, and that object is built by the other
repository - so changing the grid was two commands in two directories, and the second one
silently linked whatever the first had left behind. That is the shape of mistake that ends
with a firmware whose grid is not the grid you think you flashed.
`-Dcols` and `-Drows` now drive the editor's own build before linking it. A nested
`zig build`, not a package dependency: the seam between these repositories stays a file,
for the reasons the comment above it has always given. This only reaches across to ask for
the file to be made a particular way, and it stands aside entirely when `-Dpardes-obj`
names an object explicitly, because then the caller has already said which one they want.
Verified by the segment table: `-Dcols=80 -Drows=24` takes the loaded segment from 20,408
to 49,944 bytes, which is the shadow grid going from 784 cells to 1,920.
## Poke and Peek, checked against each other
Two more checks in `p4-bench --check`, and they are checked against each other because
that is the only way to check either one without a second debugger: a Peek alone cannot
tell a correct read from a stuck one, and a Poke alone cannot tell a write from a no-op.
Both oracles were wrong before they were right, and both failures are worth recording.
The Escape check asked whether an `x` came back on the wire. That was true until the boot
buffer gained a line beginning "x selects a line", at which point a passing check began
failing for a reason that had nothing to do with Escape. It now reads the CURSOR COLUMN
after `0`, which the document cannot spell: 8 in normal mode, three further right if the
`0` had been inserted instead.
The Poke and Peek checks searched the raw byte stream for `deadbeef` and could not find it -
because this renderer emits only the cells that CHANGED, jumping between runs with absolute
cursor positioning, so a word on screen is frequently not a word on the wire. `stripAnsi`
removes the escapes first. The Poke assertion then had to be loosened from one phrase to
three facts, because the message row is 49 columns here and a wrapped line puts a row
boundary inside whichever phrase straddles it.
Four checks, all passing on the die:
lone Escape still leaves insert mode ok (cursor col 8)
a click split byte-by-byte lands at 18 ok (cursor 3,18)
Poke writes a word and reads it back ok
and a later Peek still finds it ok
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -292,6 +292,31 @@ pub fn build(b: *std.Build) void { // renderer stays next to the vaxis it needs, and the boundary is bytes in / bytes out. const obj = b.option([]const u8, "pardes-obj", "path to pardes's p4 object (default ../02-pardes-code/zig-out/pardes-p4.o)") orelse "../02-pardes-code/zig-out/pardes-p4.o"; + + // THE GRID, set from here, because the object is where it is baked and the object is built + // by the other repository. Without this, changing the geometry is two commands in two + // directories and the second one silently links whatever the first one left behind - which is + // exactly the shape of mistake that ends with a firmware whose grid does not match the + // firmware you think you flashed. + // + // Implemented as a nested `zig build`, not a package dependency, for the reasons above: the + // seam between these repositories is a file, and it stays a file. This only reaches across it + // to ask for the file to be made a particular way. Skipped entirely when `-Dpardes-obj` names + // an object explicitly, because then the caller has said which one they want. + const cols = b.option(u16, "cols", "board grid width in cells; rebuilds pardes's object"); + const rows = b.option(u16, "rows", "board grid height in cells; rebuilds pardes's object"); + if ((cols != null or rows != null) and b.user_input_options.get("pardes-obj") == null) { + const editor_dir = std.fs.path.dirname(std.fs.path.dirname(obj) orelse ".") orelse ".."; + const build_editor = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "-Dplatform=p4" }); + build_editor.setCwd(.{ .cwd_relative = editor_dir }); + if (cols) |c| build_editor.addArg(b.fmt("-Dp4-cols={d}", .{c})); + if (rows) |v| build_editor.addArg(b.fmt("-Dp4-rows={d}", .{v})); + // Its output is a file this build then links, and the linker has no idea it is generated, + // so the ordering has to be said out loud. + build_editor.has_side_effects = true; + app.step.dependOn(&build_editor.step); + } + app.root_module.addObjectFile(if (std.fs.path.isAbsolute(obj)) .{ .cwd_relative = obj } else |
