Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fc61452
Run 32-bit launcher games such as Command & Conquer 3
marcocebrian Nov 29, 2026
301df88
Scale StretchRect, report the real display mode, activate a fullscree…
marcocebrian Nov 29, 2026
793bdbe
Draw point sprites with their texture coordinates and size
marcocebrian Nov 29, 2026
6ee8958
Fast return to a fullscreen game; Metal-safe low memory; accelerated …
marcocebrian Nov 29, 2026
6e555f4
tools/pack_portable.sh: make a converted game a portable folder (the …
marcocebrian Nov 29, 2026
553f30e
Relative constant reads as on D3D9; fullscreen minimise and DirectInp…
marcocebrian Nov 29, 2026
06cecde
LAN games: announce on the network, not on loopback; ask for local ne…
marcocebrian Nov 29, 2026
6f35301
Free standalone surfaces; report low memory in use
marcocebrian Nov 29, 2026
f5c91d3
Rewriter: try each switch target once (Kane's Wrath hung at Rewriting…
marcocebrian Nov 30, 2026
26e66c3
Keep profiles and saves when converting again; Winsock errors and opt…
marcocebrian Nov 30, 2026
f56f588
Direct3D 9: uploads between draws keep the render pass; send only cha…
marcocebrian Nov 30, 2026
8cff743
Pipelines made ahead from records of earlier runs; PE2_PROF sampling …
marcocebrian Nov 30, 2026
1aba574
Idle Sleep(0) loops sleep 100 us after 200 yields; measured results a…
marcocebrian Nov 30, 2026
f52bd55
Release builds: the frame-rate line only when traced; 64-bit D3D9 lay…
marcocebrian Nov 30, 2026
4fed55f
pack_portable.sh: say that macOS asks once for removable-volume access
marcocebrian Nov 30, 2026
5684a08
Each Mac its own machine name and disk serial, from the hardware UUID…
marcocebrian Nov 30, 2026
fe45a13
LAN: a UDP socket bound to the Mac's own address hears broadcasts, as…
marcocebrian Nov 30, 2026
7662a83
Shader constants exactly as far as the generated code reads them (the…
marcocebrian Nov 30, 2026
f7bb026
Sharp pixel-doubling when the screen is an exact multiple of the game…
marcocebrian Nov 30, 2026
87ff1a5
Offer every display mode a game may choose (C&C 3 drew no units at a …
marcocebrian Nov 30, 2026
7f15685
d3d9: post-process module (FXAA, MetalFX upscaling) with a standalone…
marcocebrian Dec 1, 2026
ed72f07
d3d9: FXAA and MetalFX upscaling at present (PE2_AA, PE2_SCALE=metalf…
marcocebrian Dec 1, 2026
e0e034f
d3d9: offer multisampling (NONMASKABLE, 2x, 4x) and serve it with FXA…
marcocebrian Dec 1, 2026
e92939e
d3d9: MetalFX upscaling for any frame smaller than the screen (PE2_SC…
marcocebrian Dec 1, 2026
32e362f
Anti-aliasing on by default for every game; off only when the game ch…
marcocebrian Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ for t in anticheat.py build.py build_dx11lib.py build_m32.py build_shaderlib.py
cp "$H/tools/$t" "$C/Resources/kit/tools/" || { echo "missing tools/$t" >&2; exit 1; }
done
mkdir -p "$C/Resources/kit/tests/w64"; cp "$H/tests/d3d11/post.m" "$C/Resources/kit/tests/d3d11/"; cp "$H/tests/w64/exe_main.c" "$H/tests/w64/plug_main.c" "$C/Resources/kit/tests/w64/" # a program's entry, a 64-bit plug-in's entry
# DAISY_FROM=<an existing DAISY.app>: take the parts built from outside sources (system libraries, shader tools, the
# slimmed Python and 7-Zip) from that app instead of the data folder; everything made from this repository is built anew
F="${DAISY_FROM:-}"; [ -z "$F" ] || [ -d "$F/Contents/Resources/py" ] || { echo "DAISY_FROM is not a DAISY.app: $F" >&2; exit 1; }
if [ -n "$F" ]; then : "${DAISY_SYS:=$F/Contents/Resources/kit/sys}"; : "${DAISY_SC:=$F/Contents/Resources/kit/sc}"; fi
rsync -a "${DAISY_SYS:-$HOME/Work/pe2mac-data/z64/sys}/" "$C/Resources/kit/sys/"
# shader tools for Direct3D 12 and for Direct3D 11 tessellation/geometry stages: the DirectX shader compiler (LLVM licence),
# our DXIL assembler, bytecode converter and Metal converter front end, Apple's Metal shader converter library
Expand All @@ -19,6 +23,9 @@ S="${DAISY_SC:-$HOME/Work/pe2mac-data/sc}"; [ -x "$S/bin/conv12" ] || { echo "mi
rsync -a "$S/" "$C/Resources/kit/sc/"
# self-contained: a standalone Python 3.12 per CPU with capstone, and 7-Zip (universal). Only Apple's compiler comes from the system.
X="${DAISY_BUNDLE:-$HOME/Work/pe2mac-data/py}"
if [ -n "$F" ]; then
ditto "$F/Contents/Resources/py" "$C/Resources/py"; ditto "$F/Contents/Resources/bin" "$C/Resources/bin"
else
T=$(mktemp -d /tmp/daisy-py.XXXXXX); printf 'import capstone, json, lzma, bz2, zlib, multiprocessing.spawn, multiprocessing.popen_spawn_posix, multiprocessing.resource_tracker, multiprocessing.queues, multiprocessing.synchronize, concurrent.futures.process, concurrent.futures.thread\n' > "$T/stub.py"
for a in x86_64:x86_64 arm64:aarch64; do # only what the tools import (pyslim.py), so none of Python's own extras ship
p="$X/inst/cpython-3.12.14-macos-${a#*:}-none"; d="$C/Resources/py/${a%%:*}"; w=$(ls "$X/wheels/capstone-"*"${a%%:*}.whl")
Expand All @@ -32,6 +39,10 @@ rm -rf "$T"
for a in x86_64 arm64; do /usr/bin/python3 -c 'import sys; p=sys.argv[1]; b=open(p,"rb").read(); w=bytes.fromhex("47454d494e49"); n=b.count(w); assert n==1, n; open(p,"wb").write(b.replace(w,w[:3]+b"1"+w[4:]))' "$C/Resources/py/$a/bin/python3.12" || exit 1; done
find "$C/Resources/py" -name '*.pyc' -delete; find "$C/Resources/py" -name __pycache__ -type d -empty -delete
mkdir -p "$C/Resources/bin"; cp "$X/7z/7zz" "$C/Resources/bin/"; cp "$X/7z/License.txt" "$C/Resources/bin/7zz-License.txt"
fi
# 32-bit system libraries older games use without shipping them (msvcr80/90, d3dx9_NN), from Microsoft's redistributables
# (tools/fetch_sys32.sh); a DAISY_SYS that already holds x86/ keeps its own
[ -f "$C/Resources/kit/sys/x86/msvcr80.dll" ] || DAISY_7ZZ="$C/Resources/bin/7zz" "$H/tools/fetch_sys32.sh" "$C/Resources/kit/sys/x86" >/dev/null || { echo "could not fetch the 32-bit system libraries" >&2; exit 1; }
cat > "$C/Info.plist" <<'P'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand Down
25 changes: 18 additions & 7 deletions app/convert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
R="$(cd "$(dirname "$0")" && pwd)"; K="$HOME/Library/Application Support/DAISY"; OUT="${DAISY_GAMES:-$HOME/Library/Application Support/DAISY/Games}"
# the app goes where Mac software goes, so Launchpad and Spotlight list it; the program's own files (game data,
# saves it writes, learned shaders) stay in Application Support, named by Contents/Resources/daisy-root
# macOS asks before a program sends to the local network (LAN games: broadcasts are refused with "no route to host"
# until the user allows it); the prompt shows this reason
LNET="Lets the game find and join games on your local network (LAN play)."
APPS="${DAISY_APPS:-/Applications}"; [ -w "$APPS" ] || APPS="$HOME/Applications"
[ -n "$DAISY_TMP" ] && export TMPDIR="$DAISY_TMP/" # the compiler's own temporary files go with the build, not to the system disk
install_app() { # install_app <title> <work folder>: the .app in $1.app moves to $APPS, signed in place
Expand Down Expand Up @@ -218,7 +221,7 @@ if [ -d "$MA/Contents/MacOS" ]; then
/usr/libexec/PlistBuddy -c "Delete :LSRequiresCarbon" "$B/$n.app/Contents/Info.plist" >/dev/null 2>&1
else
cp -R "$MA/Contents/Resources/." "$B/data/" 2>/dev/null
printf '<?xml version="1.0"?><plist version="1.0"><dict><key>CFBundleExecutable</key><string>%s</string><key>CFBundleIdentifier</key><string>daisy.%s</string><key>CFBundleName</key><string>%s</string><key>CFBundlePackageType</key><string>APPL</string><key>LSMinimumSystemVersion</key><string>13.0</string><key>NSHighResolutionCapable</key><false/></dict></plist>' "$n" "$n" "$n" > "$B/$n.app/Contents/Info.plist"
printf '<?xml version="1.0"?><plist version="1.0"><dict><key>CFBundleExecutable</key><string>%s</string><key>CFBundleIdentifier</key><string>daisy.%s</string><key>CFBundleName</key><string>%s</string><key>CFBundlePackageType</key><string>APPL</string><key>LSMinimumSystemVersion</key><string>13.0</string><key>NSHighResolutionCapable</key><true/><key>NSLocalNetworkUsageDescription</key><string>%s</string></dict></plist>' "$n" "$n" "$n" "$LNET" > "$B/$n.app/Contents/Info.plist"
fi
echo "STAGE Finishing"; echo "PROGRESS 97"
rm -rf "$B/o" "$B/thin" "$B"/lib[0-9]* "$B/build.log" "$W"; [ -d "$D/data" ] && cp -Rn "$D/data/." "$B/data/" 2>/dev/null # files the user added to data are kept
Expand Down Expand Up @@ -249,6 +252,7 @@ fi
# intake says why it stopped (a lone program in Downloads, a DRM-locked program, nothing to unpack); else the general reason
[ $rc = 0 ] && [ -n "$j" ] || { why=$(tail -1 "$W/intake.err" 2>/dev/null); [ -n "$why" ] || why="could not unpack or find the game's program"; echo "FAILED: $why"; exit 1; }
f=$(get folder); exe=$(get exe); bits=$(get bits); top=$(get top); [ -n "$top" ] || top="$f"
largs=$(get args); launcher=$(get launcher) # a launcher's game: the program it runs (exe, maybe in a sub-folder) and its arguments
# A dropped folder is the game's whole folder even when its program sits in a sub-folder (files beside that
# sub-folder belong to the game too); an unpacked archive or installer likewise.
whole="$1"; [ -d "$1" ] || whole="$W/game"; whole=$(cd "$whole" 2>/dev/null && pwd -P); ff=$(cd "$f" 2>/dev/null && pwd -P)
Expand All @@ -268,9 +272,11 @@ fi
t="${DAISY_TITLE:-$in}"; t=$(printf '%s' "$t" | tr -d '/:'); n=$(printf '%s' "$t" | tr -cd 'A-Za-z0-9' | cut -c1-24); [ -n "$n" ] || n=game
case "$t" in ''|.|..|-*|*/*) t="$n";; esac # the folder below is replaced: it must be a plain child of OUT
D="$OUT/$t"; B=$(mktemp -d "${DAISY_TMP:-/tmp}/daisy.XXXXXX") || exit 1
echo "STAGE Rewriting $exe"
[ -n "$launcher" ] && echo "LAUNCHER $launcher runs $exe${largs:+ ($largs)}"
echo "STAGE Rewriting $(basename "$exe")"
# daisy64 prints "@P <stage> <fraction>"; each stage owns a slice of the bar: rewrite 12-50, copy 50-60, compile 60-97
known=$("$PY" -I -B -c 'import json,sys; print(json.load(open(sys.argv[1])).get(sys.argv[2].lower(), ""))' "$K/kit/tools/known.json" "$exe" 2>/dev/null) # start-up settings a known program needs
known=$("$PY" -I -B -c 'import json,sys; print(json.load(open(sys.argv[1])).get(sys.argv[2].lower(), ""))' "$K/kit/tools/known.json" "$(basename "$exe")" 2>/dev/null) # start-up settings a known program needs
[ -n "$known" ] || known="$largs"
# libraries in sub-folders (add-ins the program loads by name: "plugins", Qt "platforms"...) are built in too
plug=""; np=$(find "$top" -mindepth 2 -maxdepth 4 -iname '*.dll' 2>/dev/null | head -400 | wc -l); [ "$np" -gt 0 ] && [ "$np" -lt 400 ] && plug="--plugins"
# Direct3D 12 and the Direct3D 11 stages that go through it (tessellation, geometry shaders): requests a run of the
Expand All @@ -286,14 +292,14 @@ MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-13.0} DAISY_HOST=local DAIS
{ print > lf; fflush(lf) }'
else # 32-bit: the program and its libraries are rewritten and linked with the 32-bit runtime; its folder stays whole beside the app
mkdir -p "$B/data" "$B/o32"; echo "STAGE Copying game files"; rsync -a "${f%/}/" "$B/data/" || { echo "FAILED: could not copy the program files"; exit 1; }
echo "PROGRESS 20"; echo "STAGE Rewriting $exe"
MACOSX_DEPLOYMENT_TARGET=13.0 "$PY" -I -B "$K/kit/tools/build.py" "$f" "$B/o32" "$exe" --auto 2>&1 \
echo "PROGRESS 20"; echo "STAGE Rewriting $(basename "$exe")"
MACOSX_DEPLOYMENT_TARGET=13.0 "$PY" -I -B "$K/kit/tools/build.py" "$f" "$B/o32" "$exe" --auto --data "$B/data" ${known:+--args "$known"} 2>&1 \
| /usr/bin/awk -v lf="$B/build.log" '$1 == "@P" { print "PROGRESS " int(($2 == "rewrite" ? 20 : 90) + ($2 == "rewrite" ? 70 : 7) * $3); if ($2 == "compile") print "STAGE Building the Mac app"; fflush(); next }
{ print > lf; fflush(lf) }'
x=$(printf '%s' "${exe%.*}" | tr 'A-Z' 'a-z')
x=$(basename "$exe"); x=$(printf '%s' "${x%.*}" | tr 'A-Z' 'a-z')
if [ -x "$B/o32/$x" ]; then
mkdir -p "$B/$n.app/Contents/MacOS"; cp "$B/o32/$x" "$B/$n.app/Contents/MacOS/$n"
printf '<?xml version="1.0"?><plist version="1.0"><dict><key>CFBundleExecutable</key><string>%s</string><key>CFBundleIdentifier</key><string>daisy.%s</string><key>CFBundleName</key><string>%s</string><key>CFBundlePackageType</key><string>APPL</string><key>LSMinimumSystemVersion</key><string>13.0</string><key>NSHighResolutionCapable</key><false/></dict></plist>' "$n" "$n" "$n" > "$B/$n.app/Contents/Info.plist"
printf '<?xml version="1.0"?><plist version="1.0"><dict><key>CFBundleExecutable</key><string>%s</string><key>CFBundleIdentifier</key><string>daisy.%s</string><key>CFBundleName</key><string>%s</string><key>CFBundlePackageType</key><string>APPL</string><key>LSMinimumSystemVersion</key><string>13.0</string><key>NSHighResolutionCapable</key><true/><key>NSLocalNetworkUsageDescription</key><string>%s</string></dict></plist>' "$n" "$n" "$n" "$LNET" > "$B/$n.app/Contents/Info.plist"
mkdir -p "$B/$n.app/Contents/Resources"
fi
rm -rf "$B/o32"
Expand All @@ -304,6 +310,10 @@ cp "$B/build.log" "$K/last-build.log" 2>/dev/null # kept for a failed conversi
# uses for the first time is recorded there, rewritten to Metal source by the tool and compiled by the system, so no
# Metal compiler is needed and nothing has to be learned ahead of time.
mkdir -p "$B/learn/d3d9" "$B/$n.app/Contents/Helpers"; [ -d "$D/learn" ] && cp -R "$D/learn/." "$B/learn/" 2>/dev/null
# Converting again (as after playing, to build the learned shaders ahead) keeps what the player made: profiles, saves
# and settings (the Windows user folders) and the program's registry. The folder below is replaced as a whole.
[ -d "$D/Documents and Settings" ] && cp -Rp "$D/Documents and Settings" "$B/" 2>/dev/null
[ -f "$D/registry.txt" ] && cp -p "$D/registry.txt" "$B/" 2>/dev/null
clang -arch x86_64 -arch arm64 -O1 -w -DDAISY_BUILDER -o "$B/$n.app/Contents/Helpers/shtool" "$K/kit/tools/shtool.c" "$K/kit/runtime/d3d9_shader.c" "$K/kit/runtime/d3d9_ff.c" 2>>"$B/build.log" \
|| { echo "FAILED: could not build the shader tool"; exit 1; }
# Direct3D 11: the same idea. Its shader rewriter is a Python tool, so a program that uses Direct3D 11 also gets the
Expand All @@ -323,6 +333,7 @@ cd "$D" || exit 1
/usr/libexec/PlistBuddy -c "Set :CFBundleName $t" "$t.app/Contents/Info.plist" >/dev/null 2>&1
# the program's own icon, from the .exe's resources; DAISY's only when it has none
ep="$f/$exe"; [ -f "$ep" ] || ep=$(find "$f" -iname "$(basename "$exe")" 2>/dev/null | head -1)
[ -n "$launcher" ] && [ -f "$f/$launcher" ] && ep="$f/$launcher" # a launcher carries the game's icon
"$PY" -I -B "$K/kit/tools/exeicon.py" "$ep" "$t.app/Contents/Resources/AppIcon.icns" 2>>"$D/build-icon.log" || cp "$R/daisy.icns" "$t.app/Contents/Resources/AppIcon.icns" 2>/dev/null
[ -f "$t.app/Contents/Resources/AppIcon.icns" ] && /usr/libexec/PlistBuddy -c 'Add :CFBundleIconFile string AppIcon' "$t.app/Contents/Info.plist" >/dev/null 2>&1
strip -S "$t.app/Contents/MacOS/"* 2>/dev/null; install_app "$t" "$D"
Loading