This PR adds four mod features: mod order in the macOS launcher, new MSBT labels, new files inside SARC archives, and code modules with a Skyline-style hook API.
Mod order
The Mods page is a list with a handle on each row. It uses a List mode of CategoryPage, because a Form cannot reorder rows on macOS. You drag a row to change the order. The launcher saves the order as mod_order and uses it for RomFS mods, code patches and code modules. Mods that are not in the saved order come after it, in name order. The rows keep the inspect and delete actions.
Mod files
- A
.txtedit for an MSBT label that the game file does not have now adds that label, instead of being skipped. The label goes into the hash bucket that the game looks up. Files with sections other than LBL1 and TXT2 still refuse new labels. SitBar's CT Pack needs this for its new course prefixes. - A file in an archive edit folder that has no match in the archive is now added to it (
nxfs::sarc::rebuild_adding).
Code modules
A mod can put 64-bit modules named subsdk1 to subsdk9 in its exefs folder (macOS only):
- The launcher passes them to
nxpatch rewrite --module, which converts them with the game code and adds them to the stamp. Prepare runs again when they change. - nxhost loads them after
main,subsdk0andsdk, and runs their init functions before the game starts. - A module can import the symbols that the game's modules export, and four Skyline functions that nxhost gives:
A64HookFunction,A64InlineHook,sky_memcpyandskyline::utils::getRegionAddress. - Hook stubs live in a pool right after the modules, in reach of a
binstruction. Code pages lose execute while they are written, because macOS does not allow writable and executable pages.
The mod checks in nxhost and the launcher accept subsdk1 to subsdk9 on macOS. On iOS they still count as unsupported game modules. The README has a Code modules section.
This is generic: Mush8 has no code for any one mod. A port of CTGP Deluxe 1.1.1 to update 4.0.1, written as such a module, uses it. It is excluded from this PR
Tests
cargo test --workspacepasses, including a new MSBT test for added labels. The label hash matches the bucket of all 1,265 labels in the 4.0.1message.sarc../make-app.shbuilds the macOS app, and the iOS launcher sources passswiftc -typecheckwith the iOS SDK.- Tested on macOS with update 4.0.1: the CTGP module loads from this branch and runs races. Before the rebase on
main, it ran full Grand Prix cups. After the merge with the category pages, mod reordering worked on the new Mods page.