#!/bin/bash # Build the SCSI VOLUME the P4 rigs read, and the blank card ROM MAME needs to # instantiate the card. Sourced-by-calling from tools/bench/scsi_run.sh and # tools/bench/pace_run.sh so there is ONE copy of the layout. # # tools/bench/mkvol.sh [container.dlx | container.dlxp] # # TWO CONTAINERS, ONE VOLUME BUILDER. A DLX volume is tools/bench/prep_stream.py's # disk image -- the codec's records, laid down from sector 0. A DLXP volume # (ROADMAP K2/K3) needs no preparation at all: the container is ALREADY a # sector-aligned image of itself -- a 512 B header, then fixed 97-sector records # -- so the file IS the volume and copying it is the whole build. That is not a # convenience, it is the format's central claim (tools/encoder/dlxp.py) arriving # at the disc, and a builder that transformed it on the way would be hiding the # claim rather than testing it. # # The two get DIFFERENT CHD NAMES. Alternating between the packed rig and the # codec rig would otherwise rebuild the volume on every run, and -- much worse -- # a stale CHD under the name the other rig expected would serve one container's # bytes to the other's gate, which reads as a decode failure and is not one. # # ONE COPY, ON PURPOSE. The volume is tmp/stream_disk.bin -- byte for byte the # file the host-file ring rig reads -- laid out as 512 B sectors. If two scripts # each built it, a difference between the SCSI rig and the modelled-transport rig # could be a difference in what they were reading, and the whole value of running # both is that it cannot be. This tree has already paid twice for a transform # with two copies of itself (FINDINGS 49.7.5, and check.sh's dlxload note). # # THE BLANK BOOT ROM is the substitution session 25 argued for and it is # unchanged: MAME refuses to instantiate the CZ-6BS1 without an 8 KB # `scsiexrom.bin` (CRC 7be488de) that the player never executes, so a zero-filled # placeholder goes on a SEPARATE rompath and the user's romset is untouched. # MAME prints WRONG CHECKSUMS, as it should. DO NOT reuse this rompath for # anything that boots from the card or calls SCSI IOCS -- those DO execute it. set -e cd "$(dirname "$0")/../.." DLX=${1:-tmp/rc_fr_singe_scsi_span.dlx} case "$DLX" in *.dlxp) SRC="$DLX" IMG=tmp/dlxpdisk.img; CHD=tmp/dlxpdisk.chd ;; *) SRC=tmp/stream_disk.bin IMG=tmp/dlxdisk.img; CHD=tmp/dlxdisk.chd [ -f "$SRC" ] || python3 tools/bench/prep_stream.py "$DLX" > /dev/null ;; esac if [ ! -f "$CHD" ] || [ "$SRC" -nt "$CHD" ]; then SRC="$SRC" IMG="$IMG" python3 - <<'PY' import os src, img = os.environ["SRC"], os.environ["IMG"] d = open(src, "rb").read() n = (len(d) + 511) // 512 open(img, "wb").write(d + b"\0" * (n * 512 - len(d))) print(f" disc image: {len(d)} B of records -> {n} sectors") PY rm -f "$CHD" # -c none IS LOAD-BEARING, and it was found by a gate rather than by taste. # Session 28, on the DLX5 volume: with the default (lzma/zlib/huff/flac) MAME # 0.277 served the CHD FILE'S OWN BYTES as sector data -- the destination # buffer after READ(10) at LBA 0 was byte-for-byte the first 4,096 bytes of # dlxdisk.chd, starting "MComprHD" -- while `chdman verify` reported both SHA1s # correct. Uncompressed, the identical image reads byte-exact. The trigger is # the image's CONTENT: the same 8,768-sector length that works for the DLX4 # volume fails for the DLX5 one, a conventional 16x63 geometry fails too, and # `-c zlib` alone fails as well. The MAME-side cause is NOT diagnosed; what is # measured is that compression decides it and uncompressed is sound. # Costs 4.5 MB in tmp/ against 1.6 MB. DO NOT restore compression to save the # disc space: the failure is SILENT at the transport layer -- every READ(10) # reports success and returns the wrong bytes -- and only the byte comparison # in tools/bench/scsi.lua catches it. chdman createhd -i "$IMG" -o "$CHD" -ss 512 -c none > /dev/null 2>&1 fi mkdir -p tmp/p4roms/x68k_cz6bs1 [ -f tmp/p4roms/x68k_cz6bs1/scsiexrom.bin ] || \ head -c 8192 /dev/zero > tmp/p4roms/x68k_cz6bs1/scsiexrom.bin