@echo off
setlocal
set "WS=%~1"
if "%WS%"=="" set "WS=D:\vscode-workspace\xbox-dvd-tools-v2"
set "HERE=%~dp0"
set "PY=python"
where python >nul 2>nul || set "PY=C:\Python312\python.exe"
set "FW=%WS%\firmware\GDR-8050L\8050L_fw_plaintext_256k.bin"
set "OUT=gdr8050l_readcap_route_probe_v108_trace.csv"
set "CFG=gdr8050l_readcap_route_probe_v108_config.json"

echo [RUN] READ CAPACITY route probe with high-block unlocked seed and dispatcher/watchpoints.
echo [RUN] This is not expected to reach 0x900397xx yet; it locates where routing stalls.
"%PY%" "%HERE%run_direct_firmware.py" ^
  --workspace "%WS%" ^
  --bin "%FW%" ^
  --base 0x90000000 ^
  --entry 0x90000020 ^
  --model GDR-8050L ^
  --name "GDR-8050L v108 READ CAPACITY route probe highblock unlocked" ^
  --max-cycles 220000 ^
  --sp 0x003FF000 ^
  --preset gdr8050l-packet-full-cdb ^
  --clear-preset-stops ^
  --packet-cdb 25 00 00 00 00 00 00 00 00 00 ^
  --packet-data-in 00 34 5B 5F 00 00 08 00 ^
  --mem8 0x0003E7BA=0x01 ^
  --mem8 0x0003E7BB=0x01 ^
  --mem8 0x0003E7BC=0x00 ^
  --mem8 0x0003E7BD=0x06 ^
  --mem8 0x0003E7BE=0x06 ^
  --mem8 0x0003E7BF=0x00 ^
  --breakpoint 0x9001DF69 ^
  --breakpoint 0x9001DF75 ^
  --breakpoint 0x9001D05B ^
  --breakpoint 0x9001D086 ^
  --breakpoint 0x9001D090 ^
  --breakpoint 0x900396FD ^
  --breakpoint 0x9003971A ^
  --breakpoint 0x90039767 ^
  --breakpoint 0x90039778 ^
  --breakpoint 0x900397B4 ^
  --watchpoint 0x00000729:1 ^
  --watchpoint 0x0000071E:1 ^
  --watchpoint 0x0003E7BA:8 ^
  --watchpoint 0x8003E7BA:8 ^
  --trace-csv "%HERE%%OUT%" ^
  --trace-summary ^
  --config-out "%HERE%%CFG%"

echo [NEXT] Inspect %OUT% for dispatcher value 0x0729 and first miss before 0x900397xx.
endlocal
