Lander opens on a splash, with music
The first customer for the player outside the program it was pulled out of, and the argument for doing it: a splash needs no resident player at all. Nothing else is happening while the logo is up, so Lander owns the timer and all four channels exactly as Play does. Music UNDER a running game is still deferred, and still the harder problem. It polls the timer rather than being interrupted by it. Lander has no vector segment and waits for the screen by reading port 0x30, so it waits for a beat by reading port 0x50 - the same shape, and it brings no handler that would have to be taken away before the game starts. The tune is read off the disk. A missing one means the logo and silence and the game starts anyway, the way a missing /lander.state means the defaults stand. FOUR THINGS THIS COST, each found by running it: A subroutine cannot answer in A. CALL saves and restores it, so splashSkip handed its caller back the A it already had - the channel number of the last stepVoice - and the splash ended on its first pass whatever anybody pressed. Q is what survives a RET, which nextRandom says twenty lines away and I did not read. Port 0x3D is how many window rows are SHOWN, and it is two once putGauge runs and nothing before. A line written to row eleven went somewhere real and was displayed nowhere. A nought is not a keypress. It is what a recorded keyboard file holds while nobody is typing, and a splash that took it for a key is one no test could ever watch. And skipping has to be free. Asked after blanking the window and reading the file, a skipped splash still cost a fifth of a second - enough to push the thruster test's early capture past the frame it looks at. Asked first, it costs a pad read. player.asm no longer asks a caller for Order0 to Order3: the voice records name NoOrder instead, so a program whose tune comes from a file does not have to define four order lists it never uses. That was the file case finding a wart in the contract. Every other Lander test now skips the splash with a space - a key the game itself ignores, since it answers to q, z and the arrows - so they go on testing what they tested. The one in sound.sh presses nothing, which is what makes it the one that hears the music. 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
6bb1565dea
commit
00b31b88af
@@ -916,6 +916,54 @@ PY2
|
||||
|| result no "and a file that is not a tune is refused" "$(tail -2 "$BUILD/notune.out" | tr '\n' ' ')"
|
||||
fi
|
||||
|
||||
# ---- A game plays its own music ----
|
||||
#
|
||||
# The first customer for the player outside the program it was extracted from. Lander includes
|
||||
# Libraries/player.asm, reads /splash.tune off the disk, and plays it over a studio line before
|
||||
# the world is built - owning the timer and all four channels while it does, because nothing
|
||||
# else is happening yet.
|
||||
#
|
||||
# IT POLLS THE TIMER RATHER THAN BEING INTERRUPTED BY IT. Lander has no vector segment and
|
||||
# waits for the screen by reading port 0x30, so it waits for a beat by reading port 0x50 - and
|
||||
# brings no handler that would have to be taken away before the game starts.
|
||||
#
|
||||
# No key is pressed here, which is the point: every other Lander test skips the splash with a
|
||||
# space, so this is the only one that hears it.
|
||||
if [ ! -f "$ROOT/Tests/build/disks/cosmos.img" ]; then
|
||||
result no "a game plays its own music" "cosmos.img is missing"
|
||||
else
|
||||
python3 -c "
|
||||
open('$BUILD/splash.keys','wb').write(b'Lander\n' + b'\x00'*900)
|
||||
open('$BUILD/still.pad','wb').write(b'\x00' * 20000)"
|
||||
timeout 90 "$EMU" --fast --cycles 40000000 --keyboard "$BUILD/splash.keys" \
|
||||
--pad "$BUILD/still.pad" --sound "$BUILD/splash.raw" \
|
||||
--disk "$ROOT/Tests/build/disks/cosmos.img" --ram-disk 2048 \
|
||||
"$BUILD/cosmos.bin" > "$BUILD/splash.out" 2>&1 || true
|
||||
|
||||
# The tune is six seconds of ticks. What is checked is that music is still playing well
|
||||
# after a splash that failed to load would have given up: the silent path holds the logo
|
||||
# for ninety frames, a second and a half, and then the game starts.
|
||||
read -r EARLY LATE <<EOT
|
||||
$(python3 - "$BUILD/splash.raw" <<'PY2'
|
||||
import struct, sys
|
||||
try:
|
||||
d = open(sys.argv[1], "rb").read()
|
||||
except OSError:
|
||||
print("0 0"); raise SystemExit
|
||||
n = len(d) // 2
|
||||
v = struct.unpack("<%dh" % n, d)
|
||||
def rms(a, b):
|
||||
w = v[a:b]
|
||||
return int((sum(x*x for x in w) / len(w)) ** 0.5) if w else 0
|
||||
print("%d %d" % (rms(48000, 96000), rms(192000, 240000)))
|
||||
PY2
|
||||
)
|
||||
EOT
|
||||
[ "${EARLY:-0}" -gt 500 ] && [ "${LATE:-0}" -gt 500 ] \
|
||||
&& result ok "a game plays its own music" "still sounding at four seconds, so it is the tune and not the silent hold" \
|
||||
|| result no "a game plays its own music" "RMS was $EARLY at one second and $LATE at four"
|
||||
fi
|
||||
|
||||
echo
|
||||
if [ "$FAIL" -eq 0 ]; then
|
||||
echo "All $PASS sound checks passed."
|
||||
|
||||
Reference in New Issue
Block a user