+# --------------------------------------------------------------- fetch deps -
+# Download the Goldberg emulator binaries (kept out of git). Proton needs the
+# gbe_fork Windows steam_api.dll; native needs the classic Mr_Goldberg Linux .so.
+cmd_fetch() { # downloads the Goldberg binary the detected MODE needs
+ command -v bsdtar >/dev/null || die "bsdtar missing (sudo pacman -S libarchive)"
+ command -v curl >/dev/null || die "curl missing (sudo pacman -S curl)"
+ mkdir -p "$BASE/goldberg"
+ local tmp; tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' RETURN
+
+ if [ "$MODE" = proton ]; then
+ if [ -f "$GOLDBERG_DLL" ]; then ok "gbe_fork steam_api.dll already present"; return; fi
+ say "Downloading gbe_fork (Windows) $GBE_FORK_TAG ..."
+ curl -fsSL -o "$tmp/win.7z" "$GBE_FORK_WIN_URL" || die "download failed: $GBE_FORK_WIN_URL"
+ bsdtar -xf "$tmp/win.7z" -C "$tmp" release/experimental/x86/steam_api.dll \
+ || die "could not extract steam_api.dll from the archive"
+ cp "$tmp/release/experimental/x86/steam_api.dll" "$GOLDBERG_DLL"
+ file "$GOLDBERG_DLL" | grep -qi "PE32 .*i386" && ok "steam_api.dll (proton) fetched" \
+ || die "fetched steam_api.dll is not the expected 32-bit PE"
+ else
+ if [ -f "$GOLDBERG_SO" ]; then ok "classic goldberg libsteam_api.so already present"; return; fi
+ say "Downloading classic Mr_Goldberg (Linux) ..."
+ curl -fsSL -o "$tmp/lin.zip" "$CLASSIC_GOLDBERG_URL" || die "download failed: $CLASSIC_GOLDBERG_URL"
+ bsdtar -xf "$tmp/lin.zip" -C "$tmp" linux/x86/libsteam_api.so \
+ || die "could not extract libsteam_api.so from the archive"
+ cp "$tmp/linux/x86/libsteam_api.so" "$GOLDBERG_SO"
+ file "$GOLDBERG_SO" | grep -q "ELF 32-bit" && ok "libsteam_api.so (native) fetched" \
+ || die "fetched libsteam_api.so is not the expected 32-bit ELF"
+ fi
+}
+