#!/usr/bin/env bash # Build the phase-1 ROM in WSL: out32/hello/hello.32x # # The 32X startup code (ROM header, Sega's security program at $3F0, SH-2 vectors and # init) is marsdev's 32x-skeleton, copied at build time from the pinned source # (andwn/marsdev 3318d3f, MIT; the security bytes are Sega's and stay out of this repo). # Our files replace the skeleton's m_main.c and its demo images. # # wsl -e bash player32x/build_hello.sh set -euo pipefail HERE="$(cd "$(dirname "$0")/.." && pwd)" MARSDEV="${MARSDEV:-/mnt/d/dev/tools/marsdev/mars}" SKEL="${MARSDEV_SRC:-/mnt/d/dev/tools/_dl/marsdev-src}/examples/32x-skeleton" DATA="$HERE/out32/hello" BUILD="$DATA/build" [ -f "$DATA/frame_pix.bin" ] || { echo "run: py -3.12 study/hello_frame.py --out out32/hello" >&2; exit 1; } [ "$(git -C "$SKEL/../.." rev-parse HEAD)" = 3318d3f39823154b24ce48bfa5d8fe6e3f6cde3f ] || { echo "marsdev source is not at the pinned revision" >&2; exit 1; } mkdir -p "$BUILD" find "$BUILD" -mindepth 1 -delete # empty it (a Windows handle can pin the directory itself) cp -r "$SKEL"/. "$BUILD"/ rm -f "$BUILD/sh_src/images.c" "$BUILD/sh_src/images.h" cp "$HERE/player32x/hello/m_main.c" "$HERE/player32x/hello/frame.s" "$BUILD/sh_src/" cp "$DATA/frame_pal.bin" "$DATA/frame_pix.bin" "$BUILD/" make -C "$BUILD" MARSDEV="$MARSDEV" TARGET=hello cp "$BUILD/hello.32x" "$DATA/hello.32x" ls -l "$DATA/hello.32x"