From 72aa5ca40b008d72ccba45a760ad36184a1f7577 Mon Sep 17 00:00:00 2001 From: seedds Date: Thu, 15 Oct 2026 00:40:49 +0800 Subject: [PATCH] Host: real thread pause for IL2CPP's GC; Engage reaches its first battle - SetThreadActivity and GetThreadContext3 were placeholders that only reported success. IL2CPP's garbage collector pauses each thread and reads its registers for roots, so threads kept running and roots held in registers were missed. A thread inside an SVC now counts as paused at once with the gate frame as its context (thr_svc_enter / leave around every gate SVC; it waits at the SVC exit while paused). A thread in guest code is stopped with SIGUSR2 and parks in the handler. The context is Horizon's 0x320-byte ThreadContext. - nn::pctl::IsFreeCommunicationAvailable answers "not available" like the other free-communication calls; the SDK aborted in sm when Engage entered its first battle map. - Memory log lines: heap growth, alias-region high-water mark and the total mapped in the alias region (one line per 256 MB). - Engage profile: a 6 GB reservation (5.375 GB alias region, 128 MB heap region), iOS's single-reservation limit without the extended virtual addressing entitlement. Engage never calls SetHeapSize; its mappings reach +5.26 GB. - Engage on the Mac: with scripted input and DM_KBD answering the name keyboard, a new game reaches the prologue cutscene and first battle map. Open: a heap-allocator crash a few minutes into that battle, and occasional early stalls (docs/agents/04-graphics.md). - Docs: catalogue entries, README rows. Mario 1.2.1 regression (120 s scripted) clean; the iOS project compiles. --- README.md | 4 +- dm/games/fe_engage/game.tsv | 10 ++-- dm/host/hle.c | 4 +- dm/host/hle_misc.c | 2 + dm/host/hle_svc.c | 9 +++ dm/host/hle_thread.c | 111 +++++++++++++++++++++++++++++++++++- docs/agents/03-bringup.md | 4 ++ docs/agents/04-graphics.md | 1 + 8 files changed, 135 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0abd7b7..5379c64 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The project is built from the generic parts of [d2r-mobile](../d2r-mobile) (MIT) | Game | Profile | State | |---|---|---| | Super Mario Bros. Wonder (base game v0, update 1.2.1) | `smbw` | **Playable on the iPhone with sound through several levels**: an 11-minute session at 60 fps with no crash and no audio dropouts. Scripted Mac runs reach the opening course. Notes are in the [Super Mario Bros. Wonder](#super-mario-bros-wonder-smbw) section | -| Fire Emblem Engage | `fe_engage` | Bring-up (Unity 2020.3 IL2CPP, SDK 12.3.7): **on the Mac it reaches the title screen** and, left idle, its 3D attract demo. `shader_split.py` reads the shaders out of the Unity bundles (9,268 of 9,269 compile). Movies play through a host decoder (VP9 with libvpx), and the menus respond to the controller as far as a new game's appearance choice. Not yet: a crash in the attract demo, some render targets and textures, iOS | +| Fire Emblem Engage | `fe_engage` | Bring-up (Unity 2020.3 IL2CPP, SDK 12.3.7): **on the Mac it reaches the title screen** and, left idle, its 3D attract demo. `shader_split.py` reads the shaders out of the Unity bundles (9,268 of 9,269 compile). Movies play through a host decoder (VP9 with libvpx). Scripted input starts a new game and reaches the prologue cutscene and first battle map. Not yet: a heap-allocator crash a few minutes into that battle, a crash in the attract demo, iOS (the profile now fits iOS's 6 GB reservation) | ## Status @@ -22,7 +22,7 @@ The project is built from the generic parts of [d2r-mobile](../d2r-mobile) (MIT) | Mac host | Runs Mario through the menus into the opening course: the course, effects and HUD render. The title screen runs at 60 fps with flat memory (about 900 MB physical footprint). Menu and dialogue text currently render blank on the Mac (they are fine on the iPhone); this is not investigated yet | | Shaders | `shader_split.py` extracts the shaders from Nintendo's containers (bfsha archives, particle effects, `agl` packages, UI layouts, shaders embedded in `main`) and from Unity's `Shader` objects. They are translated offline, and each vertex shader gets the outputs its paired pixel shader reads. For Mario, 16,266 of 16,268 shaders compile; 2 `agl` post-effect compute shaders make SPIRV-Cross throw. All 14,603 pairs link | | Audio | The game's own SDK renderer runs in-process in its CPU / manual-execution mode (`hle_audren.c`). The host renders one 5 ms frame per buffer the output hands back. It sends the device-sink mix (5.1 folded to stereo) through Core Audio (`DM_AUDIO=1` on Mac, default on iOS). This costs about 0.1 ms of CPU per frame on an M-series Mac | -| Input | On iOS, a touch gamepad and physical controllers. On the Mac, scripted input (`DM_KEYS=: