A bar for the drift, and a lighter touch sideways
A moon has no air, so a sideways drift never stops by itself and stopping one means cancelling the velocity EXACTLY. That is not hard to do; it is hard to do blind, which is what it was - a number nothing on the screen said anything about. So sprite one is a bar whose width is the drift. It runs right from the middle of the screen for a rightward one and left for a leftward one, so which way is as plain as how fast, and stopped is the one state with nothing drawn at all. The whole of it is a target width written once a frame; the device stretches one tile into it and the program draws nothing. Sideways thrust is one a tick rather than two. At two, the smallest correction available was twice the size it needed to be and overshooting was the normal outcome. WHICH ZERO MEANS NOTHING TURNED OUT TO MATTER. A target width of nought is the NATURAL width, not an empty sprite - so a bar with no drift in it came out eight pixels wide, sitting at the middle of the screen, saying "stopped" in the same shape it says "drifting slightly". What draws nothing is a SIZE of nought, which is the other zero in the other byte. Both meanings are deliberate and documented and it still caught me out inside a week of writing them down. The check for it earned its place by failing on that before it was found, which is the best evidence a check can offer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
b1dde7908c
commit
db0c26e13f
@@ -25,7 +25,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -15,7 +15,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -32,7 +32,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -22,7 +22,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -22,7 +22,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -108,7 +108,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -27,7 +27,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -15,7 +15,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -13,7 +13,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -22,7 +22,7 @@ Mode.sbx 48
|
||||
Flip.sbx 173
|
||||
Sprite.sbx 442
|
||||
Depth.sbx 672
|
||||
Lander.sbx 1118
|
||||
Lander.sbx 1330
|
||||
Crash.sbx 632
|
||||
vars.script 50
|
||||
blocks.script 343
|
||||
|
||||
@@ -1599,6 +1599,43 @@ EOT
|
||||
&& result ok "a held thruster keeps lifting" "row $EARLY early, row $LATE later" \
|
||||
|| result no "a held thruster keeps lifting" "row $EARLY early, row $LATE later"
|
||||
|
||||
# ---- 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
|
||||
# cancelling the velocity exactly. That is not hard; it is hard BLIND. So one sprite's width
|
||||
# is the drift: it grows right from the middle of the screen for a rightward one and left for
|
||||
# a leftward one, and NOUGHT DRAWS NOTHING, so "stopped" is the state with no bar at all.
|
||||
#
|
||||
# The recording holds Right for eighty frames and then nothing. Checked in two places: with a
|
||||
# drift, where the bar starts at the middle and runs right; and with none, where a sprite of
|
||||
# no width is a sprite that is not drawn.
|
||||
python3 -c "open('$BUILD/drift.pad','wb').write(b'\x00' * 20 + b'\x01' * 80 + b'\x00' * 400)"
|
||||
timeout 30 "$EMU" --fast --cycles 1600000 --keyboard "$BUILD/lander.keys" \
|
||||
--pad "$BUILD/drift.pad" --screen "$BUILD/drift.ppm" \
|
||||
--disk "$ROOT/Tests/build/disks/cosmos.img" --ram-disk 2048 \
|
||||
"$BUILD/cosmos.bin" > "$BUILD/drift.out" 2>&1 || true
|
||||
read -r BARLEFT BARWIDE STILLWIDE <<EOT
|
||||
$(python3 -c "
|
||||
def bar(path):
|
||||
d = open(path, 'rb').read()
|
||||
px = d[d.index(b'255\n') + 4:]
|
||||
red = bytes.fromhex('d04038')
|
||||
at = [i % 320 for i in range(len(px) // 3)
|
||||
if px[i * 3:i * 3 + 3] == red and i // 320 == 189]
|
||||
return (min(at), len(at)) if at else (-1, 0)
|
||||
drifting = bar('$BUILD/drift.ppm')
|
||||
print(drifting[0], drifting[1], bar('$BUILD/lander.ppm')[1])
|
||||
" 2>/dev/null || echo "-1 0 0")
|
||||
EOT
|
||||
[ "$BARLEFT" = "160" ] && [ "$BARWIDE" -gt 4 ] \
|
||||
&& result ok "a drift draws a bar" "$BARWIDE pixels of it, running right from the middle" \
|
||||
|| result no "a drift draws a bar" "starts at $BARLEFT, $BARWIDE wide"
|
||||
# The lander recording holds only Up, so there is no sideways drift and nothing to draw. A
|
||||
# sprite of no width is not drawn at all, which is what makes "stopped" visible as emptiness.
|
||||
[ "$STILLWIDE" = "0" ] \
|
||||
&& result ok "and no drift draws none" "a width of nought is a sprite that is not there" \
|
||||
|| result no "and no drift draws none" "$STILLWIDE pixels of bar with nothing moving"
|
||||
|
||||
# ---- Clearing puts the cursor back at the top ----
|
||||
#
|
||||
# A screen with nothing on it and a cursor half way down it is not a cleared screen. This
|
||||
|
||||
Reference in New Issue
Block a user