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.
53 lines
2.3 KiB
Docker
53 lines
2.3 KiB
Docker
# Windows cross-build for the emulator.
|
|
#
|
|
# There is no MinGW package for either dependency, so both are built or
|
|
# unpacked into the cross sysroot here: SDL2 ships an official MinGW devel
|
|
# tarball, and Unicorn is compiled from source with the same toolchain.
|
|
# Doing it in a container keeps the host free of a second toolchain and makes
|
|
# the CI job and a local build the same thing.
|
|
FROM ubuntu:24.04
|
|
|
|
ARG SDL2_VERSION=2.30.9
|
|
ARG UNICORN_VERSION=2.1.1
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
g++-mingw-w64-x86-64 gcc-mingw-w64-x86-64 \
|
|
build-essential cmake make git pkg-config \
|
|
wget ca-certificates xz-utils \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV MINGW_PREFIX=/usr/x86_64-w64-mingw32
|
|
|
|
# SDL2: unpack the official MinGW devel tree into the cross sysroot.
|
|
RUN wget -q https://github.com/libsdl-org/SDL/releases/download/release-${SDL2_VERSION}/SDL2-devel-${SDL2_VERSION}-mingw.tar.gz \
|
|
&& tar xf SDL2-devel-${SDL2_VERSION}-mingw.tar.gz \
|
|
&& cp -r SDL2-${SDL2_VERSION}/x86_64-w64-mingw32/* ${MINGW_PREFIX}/ \
|
|
&& rm -rf SDL2-${SDL2_VERSION}*
|
|
|
|
# Unicorn: no prebuilt Windows package, so cross-compile it. Static, so the
|
|
# emulator .exe does not need a unicorn DLL beside it.
|
|
#
|
|
# Built at -O1, not -O2: mingw GCC 13 hits an internal compiler error
|
|
# (segfault) on qemu/softmmu/memory.c at -O2. -O1 compiles it, and unicorn is
|
|
# not the bottleneck here - the MMIO hooks are.
|
|
RUN git clone --depth 1 --branch ${UNICORN_VERSION} \
|
|
https://github.com/unicorn-engine/unicorn.git /tmp/unicorn \
|
|
&& cmake -S /tmp/unicorn -B /tmp/unicorn/build \
|
|
-DCMAKE_SYSTEM_NAME=Windows \
|
|
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
|
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
|
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
|
|
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_C_FLAGS_RELEASE="-O1" \
|
|
-DCMAKE_CXX_FLAGS_RELEASE="-O1" \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-DUNICORN_ARCH="arm;aarch64" \
|
|
&& cmake --build /tmp/unicorn/build -j"$(nproc)" \
|
|
&& cmake --install /tmp/unicorn/build \
|
|
&& rm -rf /tmp/unicorn
|
|
|
|
WORKDIR /work
|
|
CMD ["sh", "-c", "git config --global --add safe.directory /work; git submodule update --init --recursive && make windows -j$(nproc)"]
|