mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 02:48:11 +01:00
Two things, both about being able to check the emulator's work rather than
infer it.
Sound. The samples a payload pushes through the ADMAIF PIO port were being
discarded; now they are written to last_audio.wav and played on the host.
Each FIFO word is already a stereo frame, so the capture needs only a header.
The take is played after it is complete rather than streamed while it is
produced: the emulator generates samples in bursts and stalls entirely
between phrases while the payload talks to the codec over I2C, so a live
stream underruns wherever the producer falls behind the sound card, heard as
flicker. Queueing the finished buffer removes the producer from the timing
path. The rate comes from the I2S_TIMING the payload programmed, not a
nominal 48 kHz, or the melody replays at the wrong pitch.
Windows. Cross-compiled in a container, since neither dependency has a MinGW
package. Three things had to be fixed to get there, none of them findable
without actually trying it:
- mingw GCC 13 hits an internal compiler error on unicorn's
qemu/softmmu/memory.c at -O2, so unicorn is built at -O1.
- pread/pwrite are POSIX and absent on MinGW. The SD/eMMC image access now
has a seek-then-read shim, which is equivalent here because the emulated
storage is only touched from the CPU thread.
- SDL renames main on Windows, so SDL2main must be linked before SDL2 with
SDL_MAIN_HANDLED, and unicorn's threads need winpthread.
The .exe is static: one file, no DLLs beside it. Verified running natively -
it emulates a full hwtest sweep and plays the melody through WASAPI.
CI covers both platforms, and a third job runs the .exe on a Windows runner,
because a cross-build only proves it links. Builds on push and PR, not just
tags: the Windows build broke in three separate ways the first time it was
attempted, and a Linux-only workflow would have shown none of them.
136 lines
4.4 KiB
YAML
136 lines
4.4 KiB
YAML
name: Build
|
|
|
|
# Tags publish a release; pushes and PRs just prove it still builds. That
|
|
# second half is the point: the Windows build broke three different ways the
|
|
# first time anyone tried it (a compiler ICE in a dependency, POSIX-only file
|
|
# I/O, and library ordering), none of which a Linux-only workflow would show.
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
tags: ['v*']
|
|
pull_request:
|
|
branches: [master]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-linux:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout (with submodules)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y --no-install-recommends \
|
|
build-essential pkg-config libunicorn-dev libsdl2-dev
|
|
|
|
- name: Build
|
|
run: make -j"$(nproc)"
|
|
|
|
- name: Smoke test
|
|
# No display and no sound card on a runner, so this only checks the
|
|
# binary starts, reads its ini and rejects a missing payload. That is
|
|
# enough to catch a bad link or a missing shared library.
|
|
env:
|
|
RCM_EMU_NO_AUDIO: "1"
|
|
run: |
|
|
test -x rcm_emu || { echo "rcm_emu missing"; exit 1; }
|
|
./rcm_emu /nonexistent.bin 2>&1 | tee out.txt || true
|
|
grep -q "RCM Payload Emulator" out.txt \
|
|
|| { echo "banner missing - binary did not start"; exit 1; }
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: rcm_emu-linux
|
|
path: rcm_emu
|
|
if-no-files-found: error
|
|
|
|
- name: Attach to release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: rcm_emu
|
|
fail_on_unmatched_files: true
|
|
generate_release_notes: true
|
|
|
|
build-windows:
|
|
# Cross-compiled from Linux rather than built on a Windows runner: neither
|
|
# dependency has a MinGW package (SDL2 ships a devel tarball, unicorn has
|
|
# to be compiled), so the toolchain has to be assembled either way - and
|
|
# doing it in the container means CI and a local `make windows` are the
|
|
# same build.
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout (with submodules)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Set up Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build the cross-compile image
|
|
# Cached between runs: compiling unicorn for Windows is the slow part
|
|
# and it only changes when the Dockerfile pins a new version.
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile.windows
|
|
tags: rcm_emu_win:latest
|
|
load: true
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Cross-compile rcm_emu.exe
|
|
run: |
|
|
docker run --rm -v "$PWD:/work" rcm_emu_win
|
|
test -s rcm_emu.exe || { echo "rcm_emu.exe missing"; exit 1; }
|
|
file rcm_emu.exe | grep -q "PE32+" \
|
|
|| { echo "not a Windows executable"; exit 1; }
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: rcm_emu-windows
|
|
path: rcm_emu.exe
|
|
if-no-files-found: error
|
|
|
|
- name: Attach to release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: rcm_emu.exe
|
|
fail_on_unmatched_files: true
|
|
generate_release_notes: true
|
|
|
|
smoke-windows:
|
|
# The cross-build only proves it links. This proves the .exe actually
|
|
# starts on a real Windows machine - the static link, the SDL entry point
|
|
# and the unicorn init are all things that can pass the linker and still
|
|
# fail at runtime.
|
|
needs: build-windows
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Download the exe
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rcm_emu-windows
|
|
|
|
- name: Run it
|
|
env:
|
|
RCM_EMU_NO_AUDIO: "1"
|
|
shell: bash
|
|
run: |
|
|
./rcm_emu.exe /nonexistent.bin 2>&1 | tee out.txt || true
|
|
grep -q "RCM Payload Emulator" out.txt \
|
|
|| { echo "banner missing - the exe did not start on Windows"; exit 1; }
|
|
echo "rcm_emu.exe starts on a clean Windows runner"
|