#!/usr/bin/env bash # Matcha9000 (WASM-4, de dosisod, GPL-3.0): o release 1.0.2 do autor (tag 1.0.2, commit 501a9bc, gerado pelo GitHub Actions do repositorio) so traz o HTML do "w4 bundle". # O "w4 bundle --html" grava o cartucho em Z85 (WASM4_CART, WASM4_CART_SIZE no script wasm4-cart-json). # Este script baixa o HTML conferido e tira o .wasm de dentro, sem mudar nada. # # src/FredGames.Bundler/Builds/fetch-matcha9000.sh # precisa de python3 >= 3.13 (base64.z85decode) # # Saida: artifacts/build/matcha9000/matcha9000.wasm set -euo pipefail HTML_SHA256=715d7f81b188ead6443664626eca9c32b454b1efd3ccce80c654b6585c3da935 CART_SHA256=471ec2f27a9c51a506bf541667dc50d26bf186dab19ca62e3041efcaf4c7e326 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/matcha9000" cache="$root/artifacts/build/cache" mkdir -p "$out" "$cache" html="$cache/matcha9000-1.0.2.html" [ -f "$html" ] || curl -fsSL --retry 4 https://github.com/dosisod/matcha9000/releases/download/1.0.2/matcha9000.html -o "$html" echo "$HTML_SHA256 $html" | shasum -a 256 -c - python3 - "$html" "$out/matcha9000.wasm" <<'PY' import base64, json, re, sys page = open(sys.argv[1], encoding="utf-8").read() m = re.search(r']*id="wasm4-cart-json"[^>]*>(.*?)', page, re.S) if not m: sys.exit("matcha9000-1.0.2.html: script wasm4-cart-json nao encontrado") cart = json.loads(m.group(1)) data = base64.z85decode(cart["WASM4_CART"])[:cart["WASM4_CART_SIZE"]] open(sys.argv[2], "wb").write(data) PY echo "$CART_SHA256 $out/matcha9000.wasm" | shasum -a 256 -c -