@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_v110_data_in_model_trace.csv"
set "CFG=gdr8050l_readcap_route_probe_v110_data_in_model_config.json"

echo [RUN] v110 READ CAPACITY route probe with GDR packet data-in model.
echo [RUN] workspace=%WS%
echo [RUN] fw=%FW%
echo [RUN] out=%OUT%
"%PY%" "%HERE%run_direct_firmware.py" ^
  --workspace "%WS%" ^
  --bin "%FW%" ^
  --base 0x90000000 ^
  --entry 0x90000020 ^
  --model GDR-8050L ^
  --name "GDR-8050L v110 READ CAPACITY route probe data-in model" ^
  --max-cycles 220000 ^
  --sp 0x003FF000 ^
  --preset gdr8050l-packet-full-cdb ^
  --clear-preset-stops ^
  --packet-cdb 0x25 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ^
  --packet-data-in 0x00 0x34 0x5B 0x5F 0x00 0x00 0x08 0x00 ^
  --packet-data-in-model-stop ^
  --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@access ^
  --watchpoint 0x0000071E:1@access ^
  --watchpoint 0x0003E7BA:8@access ^
  --watchpoint 0x8003E7BA:8@access ^
  --trace-csv "%HERE%%OUT%" ^
  --trace-summary ^
  --config-out "%HERE%%CFG%"

"%PY%" "%HERE%analyze_gdr8050l_v109_readcap_route.py" "%HERE%%OUT%" --out "%HERE%gdr8050l_readcap_route_probe_v110_data_in_model_summary.md"
echo [NEXT] Send %OUT% and gdr8050l_readcap_route_probe_v110_data_in_model_summary.md
endlocal
