142 lines
5.7 KiB
Bash
Executable file
142 lines
5.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# verify-dvx-display.sh - Display parity gate for DVX: what the present puts
|
|
# where the stage is shown must be the stage, on every desktop depth, at
|
|
# every window scale and on the full screen.
|
|
#
|
|
# The golden hashes gate the stage, never the display. UBER's probe build
|
|
# (make dvx builds it: examples/uber with UBER_PROBE) ends with a row for DVX
|
|
# (P13) that draws one-pixel stripes in all 16 colours, bands and a small rect, moves
|
|
# rows to another palette and changes that palette, presenting after each,
|
|
# and asks the port after every present how many pixels differ from the
|
|
# stage (jlDvxPortProbeDisplayMismatch in src/dvx/hal.c): the window's content
|
|
# buffer in the desktop's own pixel format, every screen pixel of a stage
|
|
# pixel's block (scale across; down, the rows the window's shape gives it:
|
|
# 4:3 stretches every fifth row one more, square pixels take scale each),
|
|
# or the full-screen backbuffer and its palette; each pixel derived from the
|
|
# stage's palette entries, not through the present's tables. Each run is
|
|
# scripts/bench-dvx.sh --probe on one desktop (DVX.INI's video mode), about
|
|
# 8 s, in 4:3 or (":square") with square pixels. Every count must be 0, every
|
|
# pixel of the window must have been compared (320 x 240 x scale^2 in 4:3,
|
|
# 320 x 200 x scale^2 square, plus the 256 palette entries on the full
|
|
# screen), and DVX.LOG must show the program on the desktop asked for, at
|
|
# the scale and in the shape asked for.
|
|
#
|
|
# The default desktops cover each pixel size the present writes (1, 2 and
|
|
# 4 bytes) at each window scale (1x, 2x, 3x: 3x is square pixels only, as 4:3
|
|
# at 3x does not fit 1024x768), in both shapes, the 8-bit desktop's nearest
|
|
# colours and both 16-bit packings (5-5-5 and 5-6-5), then the full screen
|
|
# (320x200 at 8 bits, its palette the stage's 16).
|
|
#
|
|
# Usage: scripts/verify-dvx-display.sh [WxHxBPP:SCALE[:square] | full]...
|
|
# Requires: DOSBox Staging, Xvfb, the dvx component; the probe build
|
|
# (make dvx builds it, into build/dvx/probe).
|
|
set -uo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
source "$repo/scripts/lib/joeyEnv.sh"
|
|
source "$repo/scripts/lib/dvxGate.sh"
|
|
joeyNeed DOSBOX dosbox
|
|
joeyNeed DVX_ROOT dvx
|
|
|
|
program=uberprob
|
|
stageWidth=320
|
|
stageHeight=200
|
|
stagePixels=$((stageWidth * stageHeight))
|
|
paletteEntries=256
|
|
probeLine="UBER-PROBE: dvxDisplayMismatch"
|
|
fullSpec=full
|
|
benchSeconds=120 # one probe run, boot to done line
|
|
defaults=(640x480x8:1 800x600x8:2 1024x768x8:3:square
|
|
640x480x16:1:square 800x600x15:2 1024x768x16:3:square
|
|
640x480x32:1 800x600x32:2:square 1024x768x32:2
|
|
"$fullSpec")
|
|
shape43Height=240
|
|
specs=("$@")
|
|
[ ${#specs[@]} -gt 0 ] || specs=("${defaults[@]}")
|
|
|
|
if [ ! -f "$DVX_PROBE_DIR/apps/$DVX_VENDOR/$program/$program.app" ]; then
|
|
echo "verify-dvx-display: the probe build is missing; run: make dvx" >&2
|
|
exit 2
|
|
fi
|
|
|
|
log=$DVX_PROBE_DIR/$DVX_LOG_NAME
|
|
dvxLog=$DVX_PROBE_DIR/dvx.log
|
|
fails=""
|
|
passed=0
|
|
|
|
|
|
# fail SPEC WHAT -- note a failed run; the gate goes on with the rest.
|
|
fail() {
|
|
echo "verify-dvx-display: FAIL - $1: $2"
|
|
fails="${fails:+$fails; }$1"
|
|
}
|
|
|
|
|
|
for spec in "${specs[@]}"; do
|
|
benchArgs=(--probe)
|
|
if [ "$spec" = "$fullSpec" ]; then
|
|
w=$DVX_VIDEO_W
|
|
h=$DVX_VIDEO_H
|
|
bpp=$DVX_VIDEO_BPP
|
|
scale=1
|
|
shape=4:3
|
|
rows=$((shape43Height * scale))
|
|
want=$((stagePixels + paletteEntries))
|
|
benchArgs+=(--full-screen)
|
|
else
|
|
if ! [[ "$spec" =~ ^([0-9]+)x([0-9]+)x([0-9]+):([0-9]+)(:square)?$ ]]; then
|
|
echo "verify-dvx-display: bad desktop \"$spec\" (WxHxBPP:SCALE[:square] or $fullSpec)" >&2
|
|
exit 2
|
|
fi
|
|
w=${BASH_REMATCH[1]}
|
|
h=${BASH_REMATCH[2]}
|
|
bpp=${BASH_REMATCH[3]}
|
|
scale=${BASH_REMATCH[4]}
|
|
if [ -n "${BASH_REMATCH[5]}" ]; then
|
|
shape=square
|
|
rows=$((stageHeight * scale))
|
|
benchArgs+=(--square)
|
|
else
|
|
shape=4:3
|
|
rows=$((shape43Height * scale))
|
|
fi
|
|
want=$((stageWidth * scale * rows))
|
|
fi
|
|
DVX_VIDEO_W=$w DVX_VIDEO_H=$h DVX_VIDEO_BPP=$bpp TIMEOUT=$benchSeconds \
|
|
"$repo/scripts/bench-dvx.sh" "${benchArgs[@]}" > /dev/null 2>&1
|
|
row=$(grep -F "$probeLine" "$log" 2> /dev/null | tail -1)
|
|
if [ -z "$row" ]; then
|
|
fail "$spec" "no \"$probeLine\" line (DVX.LOG follows)"
|
|
tail -n 15 "$dvxLog" 2> /dev/null
|
|
continue
|
|
fi
|
|
counts=${row#*"$probeLine" }
|
|
echo "verify-dvx-display: $spec: $counts"
|
|
if ! grep -qF "JoeyLib: Uber Probe: $((stageWidth * scale))x$rows at ${scale}x, $shape, on a ${w}x${h} ${bpp}-bit desktop" "$dvxLog"; then
|
|
fail "$spec" "DVX.LOG does not show the window at ${scale}x, $shape, on a ${w}x${h} ${bpp}-bit desktop: $(grep -F 'JoeyLib: Uber Probe:' "$dvxLog")"
|
|
continue
|
|
fi
|
|
if [ "$spec" = "$fullSpec" ] && ! grep -qF "$DVX_FULL_SCREEN_LOG" "$dvxLog"; then
|
|
fail "$spec" "DVX.LOG has no \"$DVX_FULL_SCREEN_LOG\""
|
|
continue
|
|
fi
|
|
bad=$(printf '%s\n' "$counts" | tr ' ' '\n' | grep '^after' | grep -v '=0$' | tr '\n' ' ')
|
|
compared=$(printf '%s\n' "$counts" | sed -n 's/.*compared=\([0-9]*\).*/\1/p')
|
|
if [ -n "$bad" ]; then
|
|
fail "$spec" "pixels differ from the stage: $bad"
|
|
elif [ "$compared" != "$want" ]; then
|
|
fail "$spec" "compared $compared, want $want"
|
|
else
|
|
passed=$((passed + 1))
|
|
fi
|
|
done
|
|
|
|
if [ -n "$fails" ]; then
|
|
echo "verify-dvx-display: FAIL - $fails"
|
|
exit 1
|
|
fi
|
|
echo "verify-dvx-display: PASS ($passed desktops: every pixel where the stage is shown matches it after every present)"
|