The shell scrolls, and the moon was drawn where nobody was looking

Lunar Porter never put the row origin back. The map is a ring 128 rows
tall that the screen shows 25 of, and the shell leaves that origin
wherever its last command finished - so a moon drawn into rows nought to
24 while the screen is reading from row forty is a moon nobody can see. It
came out as terrain missing, or half there, depending on how far down the
prompt had got. Running Pad first was enough; so was holding Return.

Nothing here is tidiness. It is the difference between the rows a program
WRITES and the rows the screen READS, and only one of those is under the
program's control. Grid has always known this; Lander did not.

The check for it needed writing twice. Forty returns caught nothing,
because the shell runs an eighty column screen which is FIFTY rows tall -
forty returns fill it and never scroll it, so the origin was still nought
and the test passed against a build with the fix taken out. The screenful
that matters is the one the shell is using, not the one the program is
about to ask for. At eighty it is 28,608 pixels of moon with the fix and
none at all without it.

break.sh is what said so. The first version of this check looked exactly
like a passing test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-02 23:51:48 -04:00
co-authored by Claude Opus 5
parent f7be843ed9
commit a074a831f0
12 changed files with 55 additions and 10 deletions
+30
View File
@@ -1568,6 +1568,36 @@ EOT
&& result ok "and a lander in the middle of it" "all forty pixels, at the screen's centre" \
|| result no "and a lander in the middle of it" "$SHIP pixels, x $SHIPLEFT to $SHIPRIGHT"
# ---- The same lander, after the shell has scrolled ----
#
# THE SHELL SCROLLS, and its row origin is wherever the last command left it. The map is a
# ring 128 rows tall that the screen shows 25 of, so a moon drawn into rows nought to 24 while
# the screen is looking at row forty is a moon nobody can see - which came out as terrain that
# was missing, or half there, depending on how far down the prompt had got.
#
# EIGHTY returns before the program is started. Forty was the first try and it caught nothing,
# because the shell runs an eighty column screen which is FIFTY ROWS TALL - forty returns fill
# it and never scroll it, so the origin was still nought and the check passed against a
# version with the fix taken out. The screenful that matters is the one the shell is using,
# not the one the program is about to ask for. The moon has to come out exactly as it does from a fresh
# prompt: the rows a program WRITES and the rows the screen READS are two different things,
# and only one of them is under the program's control.
python3 -c "open('$BUILD/scrolled.keys','wb').write(b'\n' * 80 + b'Lander\n' + b'\x00' * 3000)"
python3 -c "open('$BUILD/scrolled.pad','wb').write(b'\\x00' * 40 + b'\\x08' * 400)"
timeout 30 "$EMU" --fast --cycles 1500000 --keyboard "$BUILD/scrolled.keys" \
--pad "$BUILD/scrolled.pad" --screen "$BUILD/scrolled.ppm" \
--disk "$ROOT/Tests/build/disks/cosmos.img" --ram-disk 2048 \
"$BUILD/cosmos.bin" > "$BUILD/scrolled.out" 2>&1 || true
SCROLLEDMOON="$(python3 -c "
d = open('$BUILD/scrolled.ppm', 'rb').read()
px = d[d.index(b'255\n') + 4:]
moon = bytes.fromhex('d8d8d8')
print(sum(1 for o in range(0, len(px), 3) if px[o:o + 3] == moon))
" 2>/dev/null || echo 0)"
[ "$SCROLLEDMOON" -gt 10000 ] \
&& result ok "a scrolled shell does not hide the moon" "$SCROLLEDMOON pixels of it, drawn where the screen looks" \
|| result no "a scrolled shell does not hide the moon" "$SCROLLEDMOON pixels of ground"
# ---- And the same lander, on a controller ----
#
# A pad reports what is HELD, so the thruster can be leaned on rather than pumped - which is