@echo off
setlocal EnableExtensions
set "EMUDIR=%~dp0"
if "%EMUDIR:~-1%"=="\" set "EMUDIR=%EMUDIR:~0,-1%"
set "WORKSPACE=%~1"
if "%WORKSPACE%"=="" set "WORKSPACE=D:\vscode-workspace\xbox-dvd-tools-v2"
set "FW=%WORKSPACE%\firmware\GDR-8050L\8050L_fw_plaintext_256k.bin"
set "OUT=gdr8050l_partition_watch_v103_real_seed_fixed_trace.csv"

echo [RUN] GDR-8050L partition/auth watch with real pre-step8 byte seeds - fixed single-byte mem8
echo [RUN] workspace=%WORKSPACE%
echo [RUN] fw=%FW%
echo [RUN] out=%OUT%

python "%EMUDIR%\run_direct_firmware.py" ^
  --workspace "%WORKSPACE%" ^
  --model GDR-8050L ^
  --bin "%FW%" ^
  --base 0x90000000 ^
  --entry 0x90000020 ^
  --max-cycles 90000 ^
  --preset gdr8050l-packet-full-cdb ^
  --clear-preset-stops ^
  --packet-cdb mode-select-auth-xbox ^
  --packet-data-out 00 1A 00 00 00 00 00 00 3E 12 01 01 01 D1 01 DC A2 E7 C8 ED 00 00 00 00 00 00 00 00 ^
  --auth-watch ^
  --mem8 0x000005CD=0x40 ^
  --mem8 0x000005B1=0x40 ^
  --mem8 0x000005B6=0x00 ^
  --mem8 0x000006F1=0x02 ^
  --mem8 0x0000DA0C=0x05 ^
  --mem8 0x0000D95C=0x24 ^
  --mem8 0x0000071E=0x01 ^
  --mem8 0x00000722=0x00 ^
  --mem8 0x0000076D=0x01 ^
  --mem8 0x0000076E=0x03 ^
  --mem8 0x0000077C=0x0C ^
  --mem8 0x0000077D=0x01 ^
  --mem8 0x0000077E=0x00 ^
  --mem8 0x0000077F=0x00 ^
  --mem8 0x000007F8=0x21 ^
  --mem8 0x000007F9=0x00 ^
  --watchpoint 0x000005CD:1@access ^
  --watchpoint 0x000005B1:1@access ^
  --watchpoint 0x000005B6:1@access ^
  --watchpoint 0x000006E1:1@access ^
  --watchpoint 0x000006EC:2@access ^
  --watchpoint 0x000006F1:1@access ^
  --watchpoint 0x0000DA0C:1@access ^
  --watchpoint 0x0000DA24:1@access ^
  --watchpoint 0x0000DA28:1@access ^
  --watchpoint 0x0000DA3C:1@access ^
  --watchpoint 0x0000071E:1@access ^
  --watchpoint 0x00000722:1@access ^
  --watchpoint 0x00000724:1@access ^
  --watchpoint 0x0000076D:2@access ^
  --watchpoint 0x0000077C:4@access ^
  --watchpoint 0x000007F8:2@access ^
  --watchpoint 0x0000D95C:1@access ^
  --breakpoint 0x9001CFCA ^
  --breakpoint 0x90021696 ^
  --breakpoint 0x9001B71B ^
  --breakpoint 0x9001B72C ^
  --breakpoint 0x9001B731 ^
  --breakpoint 0x9001B735 ^
  --breakpoint 0x9001B73E ^
  --breakpoint 0x9001B743 ^
  --breakpoint 0x9001B749 ^
  --breakpoint 0x9001B757 ^
  --breakpoint 0x9001B75C ^
  --breakpoint 0x9001B75F ^
  --breakpoint 0x9001B764 ^
  --breakpoint 0x9001B76E ^
  --breakpoint 0x9001EF37 ^
  --breakpoint 0x9001EF54 ^
  --breakpoint 0x9001EF66 ^
  --breakpoint 0x9001EF71 ^
  --breakpoint 0x9001B96C ^
  --breakpoint 0x9001BC3B ^
  --breakpoint 0x9001D086 ^
  --breakpoint 0x9001EE4A ^
  --stop-pc 0x9001EF71 ^
  --stop-pc-min-cycle 54000 ^
  --trace-csv "%OUT%" ^
  --trace-summary

endlocal
