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

echo [RUN] Direct native auth-state setter probe: entry=0x9001D05B d0=2
echo [RUN] Expected writes: 0x071E=02, 0x8003E7BA=01, plus layout builder call path
"%PY%" "%HERE%run_direct_firmware.py" ^
  --workspace "%WS%" ^
  --bin "%FW%" ^
  --base 0x90000000 ^
  --entry 0x9001D05B ^
  --model GDR-8050L ^
  --name "GDR-8050L v108 direct d05b d0=2 auth-state setter" ^
  --max-cycles 40000 ^
  --sp 0x003FF000 ^
  --d0 0x02 ^
  --preset none ^
  --breakpoint 0x9001D05B ^
  --breakpoint 0x9001D084 ^
  --breakpoint 0x9001D086 ^
  --breakpoint 0x9001D089 ^
  --breakpoint 0x9001D090 ^
  --breakpoint 0x9001D096 ^
  --breakpoint 0x9001D0C6 ^
  --breakpoint 0x9001D2F2 ^
  --watchpoint 0x0000071E:1 ^
  --watchpoint 0x0003E7BA:8 ^
  --watchpoint 0x8003E7BA:8 ^
  --trace-csv "%HERE%%OUT%" ^
  --trace-summary ^
  --stop-pc 0x9001D096 ^
  --stop-pc-hit-count 1 ^
  --config-out "%HERE%%CFG%"

echo [NEXT] Inspect %OUT% for 0x071E=02 and 0x8003E7BA=01.
endlocal
