51 lines
2.2 KiB
Bash
Executable file
51 lines
2.2 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
|
|
#
|
|
# check-tilebank.sh - Host-cc gate for the baked tile-bank loaders
|
|
# (jlTileBankLoad / jlTileBankLoadToSurface in src/core/assetLoad.c), end to
|
|
# end: assetbake bakes tests/host/tileBank.png, the real loader reads it,
|
|
# the real generic tile paste draws it, and tests/host/tileBankHost.c checks
|
|
# every pixel against the PNG. Also checks the refusals (a bank baked for any
|
|
# other target, bad magic, short header, missing file), a truncated bank,
|
|
# maxTiles below the bank size, a bank without a palette, and a bank bigger
|
|
# than a surface.
|
|
#
|
|
# Built as a whole BLANK-port program (the check-blank.sh source set plus the
|
|
# harness). BLANK draws chunky 4bpp like DOS, and assetLoad.c expects the DOS
|
|
# target byte there, so the DOS bake is the bank that must load. Every other
|
|
# target assetbake knows is baked too and must be refused.
|
|
#
|
|
# tests/host/tileBankStage.sh stages the banks and the expected pixels and
|
|
# palette (decoded from the PNG by tileBankExpect, independent of assetbake's
|
|
# encoders; make/tools.mk builds both), exactly as make/examples.mk stages
|
|
# them for examples/tilebank on the real ports. The harness prints the
|
|
# surface hash of its to-surface load; scripts/verify-<port>-tilebank.sh run
|
|
# this script and require each port's own bake to hash the same. Exits
|
|
# nonzero on any failed check.
|
|
set -euo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
cc=${CC:-cc}
|
|
work=$(mktemp -d -t joeylib-tilebank.XXXXXX)
|
|
trap 'rm -rf "$work"' EXIT
|
|
png="$repo/tests/host/tileBank.png"
|
|
hostTarget=dos
|
|
|
|
cd "$repo"
|
|
"$cc" -DJOEYLIB_PLATFORM_BLANK \
|
|
-Iinclude -Iinclude/joey -Isrc/core -Isrc/codegen -Wall \
|
|
src/core/*.c src/generic/*.c src/blank/blank.c tests/host/tileBankHost.c \
|
|
-o "$work/tileBankHost"
|
|
|
|
make -s -f "$repo/make/tools.mk" assetbake tileBankExpect > /dev/null
|
|
"$repo/tests/host/tileBankStage.sh" "$hostTarget" "$png" "$work/DATA"
|
|
refuse=()
|
|
for bank in "$work"/DATA/refuse*.tbk; do
|
|
refuse+=("$(basename "$bank")")
|
|
done
|
|
|
|
# Run from the temp dir: the harness reads and writes DATA/ there.
|
|
cd "$work"
|
|
"$work/tileBankHost" "${refuse[@]}"
|