The system takes a leftover window down

Lunar Porter put a fuel gauge up and never took it away, so the shell came
back with FUEL across the top and the cursor underneath. Clearing did not
help: a window is a layer at a SCREEN position that does not scroll, which
is exactly what makes one left behind unpleasant - it sits over whatever
comes next and cannot be scrolled off, cleared away or typed past.

Taken away rather than given back, like the sprite table and for the same
reason: nothing the shell draws is a window, so there is nothing to
restore. And a program that FAULTED while one was up could not have taken
it down itself, which is why this belongs to the system rather than to
whichever programs remember.

The check for it needed writing twice, and the first version was the
familiar kind of wrong. It counted the gauge BAR's colour - and the bar
disappears on its own whatever happens, because it is drawn with a tile
the screen save puts back, so the check passed with the teardown deleted.
What actually survives is the LABEL, in font tiles the shell needs anyway.

So the screen is cleared afterwards and read cell by cell. With the window
down a cleared row is "> " and a cursor; with it up the same row is F, U,
E, L. Cells one and three being empty is the whole difference, and it is
29 and 22 pixels of it rather than a threshold somebody has to believe.

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-03 00:50:42 -04:00
co-authored by Claude Opus 5
parent 2274be4b68
commit 6073086584
3 changed files with 60 additions and 0 deletions
+6
View File
@@ -1217,6 +1217,12 @@ and nobody is looking at it afterwards.
the table is cleared, so there are none - a program that wants one writes it, and a program
that leaves one behind has left something nobody is asking about.
**A window left up is taken down at exit**, for the same reasons as the sprites and by the
same rule. A window is a layer at a screen position that does not scroll, which is exactly
what makes one left behind unpleasant: it sits over the top rows of whatever comes next and
cannot be scrolled off, cleared away or typed past. Lunar Porter left its fuel gauge up once
and the shell came back with FUEL across the top and the cursor underneath it.
**The sprite table is cleared at exit, not saved and restored.** It lives in the atlas at
0xC000, and the pages the screen save walks run to the end of the map and pick up again at the
palette, with the sprites in the gap between. That is deliberate: nothing the shell draws is a
+13
View File
@@ -5125,6 +5125,19 @@ screenSane:
OUTA 0x38 ; No fraction of a cell in either direction.
OUTA 0x3C ; And the screen everybody else's map is in.
; ---- And no window left over the shell ----
;
; A window is a layer at a screen position that does not scroll, which is exactly what makes
; one left behind so unpleasant: it sits over the top rows of whatever comes next and cannot
; be scrolled off, cleared away or typed past. Lunar Porter left its fuel gauge there and
; the shell came back with FUEL across the top of it and the cursor underneath.
;
; Taken away rather than given back, for the same reason the sprite table is: nothing the
; shell draws is a window, so there is nothing to restore - and a program that FAULTED while
; one was up could not have taken it down itself.
OUTA 0x3D ; No rows, which is no window.
OUTA 0x3E ; And nowhere for it to start, so the state is a known one.
; ---- Which of the two screens is being shown ----
;
; A program that draws into the back buffer and flips is showing screen one, and the shell
+41
View File
@@ -1739,6 +1739,47 @@ EOT
&& result ok "a held thruster spends the tank" "the gauge ran to $GAUGEEARLY, then to $GAUGELATE" \
|| result no "a held thruster spends the tank" "$GAUGEEARLY early, $GAUGELATE later"
# ---- And the system takes the window down ----
#
# A window is a layer at a screen position that does not scroll, which is exactly what makes
# one left behind so unpleasant: it sits over the top of whatever comes next and cannot be
# scrolled off, cleared away or typed past. Lunar Porter left its fuel gauge up and the shell
# came back with FUEL across the top and the cursor underneath it.
#
# Taken away rather than given back, like the sprite table: nothing the shell draws is a
# window, so there is nothing to restore - and a program that faulted while one was up could
# not have taken it down itself. Lander deliberately does not, which is what leaves the
# system's guarantee as the thing under test.
# CLEARED AFTERWARDS, and looked at cell by cell, which is what makes this sharp. The gauge
# BAR disappears on its own whatever happens - it is drawn with a tile the screen save puts
# back - so counting its colour proved nothing and passed with the teardown deleted. What
# survives is the LABEL, in font tiles the shell needs anyway, sitting over the top row where
# clearing cannot reach it.
#
# With the window down a cleared screen reads "> " and a cursor: cells nought and two. With it
# up the same row reads F, U, E, L across cells nought to three. So cells one and three being
# empty is the whole difference, and it is 29 and 22 pixels of it rather than a threshold
# somebody has to believe.
python3 -c "open('$BUILD/quit.keys','wb').write(b'Lander\n' + b'\x00' * 400 + b'q' + b'\x00' * 200 + b'clear\n' + b'\x00' * 200)"
timeout 30 "$EMU" --fast --cycles 14000000 --keyboard "$BUILD/quit.keys" \
--pad "$BUILD/burn.pad" --screen "$BUILD/quit.ppm" \
--disk "$ROOT/Tests/build/disks/cosmos.img" --ram-disk 2048 \
"$BUILD/cosmos.bin" > "$BUILD/quit.out" 2>&1 || true
read -r CELLONE CELLTHREE <<EOT
$(python3 -c "
d = open('$BUILD/quit.ppm', 'rb').read()
px = d[d.index(b'255\n') + 4:]
w = 640
def cell(c):
return sum(1 for x in range(c * 8, c * 8 + 8) for y in range(8)
if px[(y * w + x) * 3:(y * w + x) * 3 + 3] != bytes(3))
print(cell(1), cell(3))
" 2>/dev/null || echo "-1 -1")
EOT
[ "$CELLONE" = "0" ] && [ "$CELLTHREE" = "0" ] \
&& result ok "and the system takes the window down" "a cleared screen is clear to the top" \
|| result no "and the system takes the window down" "cells one and three hold $CELLONE and $CELLTHREE pixels"
# ---- The drift bar, which is a scaled sprite doing a job ----
#
# A moon has no air, so a sideways drift never stops by itself and stopping one means