#!/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-win16-input.sh - Typed-character acceptance gate for the Win16 # port. Runs KEYS.EXE on Windows 3.11 under DOSBox # (scripts/lib/win16Gate.sh) at one window pixel per stage pixel # (JOEYLIB_SCALE=1, JOEYLIB_ASPECT=square), types the RetroNet # definition-of-done string with xdotool (X key events DOSBox turns into # the PC keyboard's, which Windows turns into WM_KEYDOWN/WM_CHAR), takes # DOSBox's own screenshot of the 800x600 screen, and decodes the example's # verification scanline (row 198) with scripts/lib/keysRow.py, wherever # Windows put the window. # # Usage: scripts/verify-win16-input.sh # Requires: Windows on DOSBox (install.sh install emulator:win16), Xvfb, # xdotool, python3 + PIL; build/win16/bin/KEYS.EXE (make win16). set -euo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) source "$repo/scripts/lib/joeyEnv.sh" source "$repo/scripts/lib/win16Gate.sh" label=verify-win16-input win16Need target="192.168.1.10:6510" program=$(joeyExampleProgram keys win16) [ -f "$program" ] || { echo "$label: build KEYS.EXE first (make win16)" >&2; exit 2; } # Windows' boot and KEYS reaching its poll loop. bootSeconds=10 work=$(mktemp -d -t joeylib-win16-input.XXXXXX) cleanup() { win16Stop rm -rf "$work" } trap cleanup EXIT mkdir -p "$work/program" "$work/shots" cp "$program" "$work/program/KEYS.EXE" win16Stage "$work" "$work/program" KEYS.EXE WIN16_DOSBOX_ARGS=(--set "capture_dir=$work/shots" --set "default_image_capture_formats=raw") win16Start "$work" JOEYLIB_SCALE=1 JOEYLIB_ASPECT=square sleep "$bootSeconds" win=$(win16Window) || { echo "$label: FAIL - DOSBox window not found" >&2; exit 1; } DISPLAY="$WIN16_DISPLAY" xdotool windowactivate --sync "$win" 2> /dev/null || true DISPLAY="$WIN16_DISPLAY" xdotool type --window "$win" --delay 150 -- "$target" sleep 2 # Ctrl+F5: DOSBox's screenshot hotkey. DISPLAY="$WIN16_DISPLAY" xdotool key --window "$win" ctrl+F5 sleep 2 png=$(find "$work/shots" -name '*.png' -print -quit) [ -n "$png" ] || { echo "$label: FAIL - DOSBox took no screenshot" >&2; exit 1; } if python3 "$repo/scripts/lib/keysRow.py" "$png" "$target" --scale 1; then echo "$label: PASS (typed \"$target\", all ${#target} chars arrived via jlInputGetChar)" else echo "$label: FAIL" >&2 exit 1 fi