Files
retroDE_ps2/docs/hardware/ps2_feeder_shapes_test.sh
thejayman77 ec82764bef Initial commit: retroDE_ps2 — first-of-its-kind PS2 GS FPGA core (DE25-Nano / Agilex 5)
RTL (GS rasterizer, EE core stub, platform bridge, LPDDR4B path), sim regression
(272 TBs), docs, and tooling. Copyrighted PS2 content (BIOS, game code, GS dumps,
and all dump-derived textures/traces) is excluded via .gitignore and stays local.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 20:10:50 -04:00

53 lines
5.2 KiB
Bash
Executable File

#!/bin/sh
# retroDE_ps2 — Ch332 SHAPE VOCABULARY silicon proof (triangles + rectangles, runtime-switched).
#
# Proves the feeder is no longer triangle-only smoke: a RECTANGLE (filled quad) is expressed as
# two textured triangles, so the host can command quads on the SAME Ch330/Ch331 path with NO
# rebuild/reset (and NO new bitstream — this runs on the Ch331 feeder RBF). Three scenes:
# TRI : 3 half-tile triangles tiles {0,5,10}
# RECT : 3 filled quads (6 prims) tiles {0,5,10} — same tiles, visibly FULLER
# MIXED : triangles {0,15} + rects {5,10}
# Ends on MIXED. Sim proof (tb_top_psmct32_feeder_shapes_demo): tri tile=91 blue px, rect tile=169
# (full 13x13 quad, no diagonal seam).
#
# Register map identical to ps2_feeder_test.sh (BASE 0x40000000). Needs the Ch331 feeder bitstream.
set -u
BASE="${PS2_BRIDGE_BASE:-0x40000000}"
DEVMEM="${DEVMEM:-busybox devmem}"
OFF_STATUS=0x0D8; OFF_LO=0x0DC; OFF_HI=0x0E4; OFF_GO=0x0E8
w() { $DEVMEM $(printf "0x%X" $(( BASE + $1 ))) w "$2" >/dev/null; }
r() { $DEVMEM $(printf "0x%X" $(( BASE + $1 ))) w; }
SHAPE_TRI="0000000000000003 0000000000010000 0000000000000044 0000000000050000 0000000000000002 0000000888004040 0000000000000053 00000000ff000000 0000000000000000 0000500000100010 00000000ff000000 0000000000000030 00005000001000e0 00000000ff000000 00000000000c0000 0000500000e00010 00000000ff000000 0000000000000000 0000510001100110 00000000ff000000 0000000000000030 00005100011001e0 00000000ff000000 00000000000c0000 0000510001e00110 00000000ff000000 0000000000000000 0000520002100210 00000000ff000000 0000000000000030 00005200021002e0 00000000ff000000 00000000000c0000 0000520002e00210"
SHAPE_RECT="0000000000000006 0000000000010000 0000000000000044 0000000000050000 0000000000000002 0000000888004040 0000000000000053 00000000ff000000 0000000000000000 0000500000100010 00000000ff000000 0000000000000030 00005000001000e0 00000000ff000000 00000000000c0000 0000500000e00010 00000000ff000000 0000000000000000 00005100001000e0 00000000ff000000 0000000000000030 0000510000e00010 00000000ff000000 00000000000c0000 0000510000e000e0 00000000ff000000 0000000000000000 0000520001100110 00000000ff000000 0000000000000030 00005200011001e0 00000000ff000000 00000000000c0000 0000520001e00110 00000000ff000000 0000000000000000 00005300011001e0 00000000ff000000 0000000000000030 0000530001e00110 00000000ff000000 00000000000c0000 0000530001e001e0 00000000ff000000 0000000000000000 0000540002100210 00000000ff000000 0000000000000030 00005400021002e0 00000000ff000000 00000000000c0000 0000540002e00210 00000000ff000000 0000000000000000 00005500021002e0 00000000ff000000 0000000000000030 0000550002e00210 00000000ff000000 00000000000c0000 0000550002e002e0"
SHAPE_MIXED="0000000000000006 0000000000010000 0000000000000044 0000000000050000 0000000000000002 0000000888004040 0000000000000053 00000000ff000000 0000000000000000 0000500000100010 00000000ff000000 0000000000000030 00005000001000e0 00000000ff000000 00000000000c0000 0000500000e00010 00000000ff000000 0000000000000000 0000510001100110 00000000ff000000 0000000000000030 00005100011001e0 00000000ff000000 00000000000c0000 0000510001e00110 00000000ff000000 0000000000000000 00005200011001e0 00000000ff000000 0000000000000030 0000520001e00110 00000000ff000000 00000000000c0000 0000520001e001e0 00000000ff000000 0000000000000000 0000530002100210 00000000ff000000 0000000000000030 00005300021002e0 00000000ff000000 00000000000c0000 0000530002e00210 00000000ff000000 0000000000000000 00005400021002e0 00000000ff000000 0000000000000030 0000540002e00210 00000000ff000000 00000000000c0000 0000540002e002e0 00000000ff000000 0000000000000000 0000550003100310 00000000ff000000 0000000000000030 00005500031003e0 00000000ff000000 00000000000c0000 0000550003e00310"
wait_ready() {
i=0
while [ $i -lt 300 ]; do st=$(r $OFF_STATUS); [ $(( st & 1 )) -eq 1 ] && return 0; i=$(( i + 1 )); sleep 0.01 2>/dev/null || true; done
echo " !! feeder never reported ready — is this the Ch331 feeder bitstream?"; return 1
}
stage_and_go() { # $1 label $2 words $3 expected-records
label="$1"; words="$2"; exp="$3"
echo "[$label] waiting for feeder ready ..."; wait_ready || return 1
echo "[$label] streaming the list, then GO ..."; w $OFF_STATUS 0x0; n=0
for word in $words; do
lo=$(printf '%s' "$word" | cut -c9-16); hi=$(printf '%s' "$word" | cut -c1-8)
w $OFF_LO 0x$lo; w $OFF_HI 0x$hi; n=$(( n + 1 ))
done
echo "[$label] wrote $n words; bridge staging addr now=$(( $(r $OFF_LO) )) (expect $n)"
wait_ready || return 1; w $OFF_GO 0x1; wait_ready || return 1
rec=$(r $OFF_HI)
echo "[$label] records=$(( rec )) (expect $exp)"
[ $(( rec )) -eq $exp ] || { echo " !! records != $exp"; return 1; }
echo "[$label] OK — look at HDMI."; sleep 2 2>/dev/null || true
}
echo "=== Ch332 shape vocabulary — TRI(triangles) -> RECT(filled quads) -> MIXED ==="
stage_and_go "TRI (3 triangles: tiles 0/5/10)" "$SHAPE_TRI" 3 || exit 1
stage_and_go "RECT (3 filled quads: tiles 0/5/10)" "$SHAPE_RECT" 6 || exit 1
stage_and_go "MIXED (tri 0/15 + rect 5/10)" "$SHAPE_MIXED" 6 || exit 1
echo "=== done — ENDS ON MIXED: top-left + bottom-right are triangles, the two middle-diagonal"
echo " tiles are FILLED squares. Triangles vs rectangles, runtime-switched, no rebuild/reset. ==="