Mods folder: RomFS mods in the emulator layout #321

Merged
hiKareeem merged 1 commit from mods-folder into main 2026-11-07 23:46:13 +00:00
hiKareeem commented 2026-11-07 20:43:31 +00:00 (Migrated from github.com)

Hookshot already asks for mods (hos_mods_init, hos_mods_romfs, hos_mods_dir_extras in hos_main.c and nn_fs.c), but mkw_glue.c answered with stubs, so the only way to try a changed game file was the HOS_FS_OVERLAY test switch. This adds the loader.

What it does

host/mods.c is the RomFS part of Skybound's loader (NotRexed/SkyboundTotk a64-kit/hos/mods.c, MIT, commit 4315342):

  • mods/<name>/romfs/... beside hookshot.exe, or HOS_MODS=<dir>, in the layout emulators use, so their RomFS mods work as they are. Deeper layouts (contents/<title id>/<name>/romfs) work too.
  • Folders starting with - or _ are off; when two mods have the same file, the last-sorted one wins.
  • Each file read from a mod is logged (mods: <path> <- <file>).
  • HOS_FS_OVERLAY is unchanged and still wins over a mod.

Changes from Skybound's file

  • No browser-build stubs.
  • The executable's folder is found with either path separator, so host/posix finds the mods folder.

Left out: exefs patches (.pchtxt, .ips). The code is compiled ahead of time, and the game folder has only image.bin, not the module map Skybound places data patches with. A mod's exefs folder is logged as left out.

I also added a short "Mods" section to the readme.

Tested

  • A full Windows build of this branch with make_game.py and the release builder's own toolchain: compiled in 1089s, 0 failed.
  • Headless, muted boots of that build:
    • A mod holding a byte-identical Pack/ZsDic.pack.zs logged mods: Pack/ZsDic.pack.zs <- ...\mods\r1-test\romfs\Pack\ZsDic.pack.zs, and loading went on to 60 fps.
    • A -off folder was skipped.
    • An exefs-only mod was logged as left out.
    • With HOS_FS_OVERLAY also set, the overlay copy was opened instead of the mod's.
  • Rebased onto 7ef5f40 afterwards. In the files this touches, only mkw_glue.c changed upstream (two lines). clang -fsyntax-only on mods.c, mkw_glue.c and nn_fs.c passes on the rebased tree.
  • Linux: syntax-checked against host/posix with glibc headers; not linked or run.
  • Not tried in game: a mod that adds new entries to a folder listing. That path is Skybound's code, unchanged.

Context: we're building a randomizer that writes its output as an emulator-layout mod folder. With this it drops into mods\ as is.

Hookshot already asks for mods (`hos_mods_init`, `hos_mods_romfs`, `hos_mods_dir_extras` in `hos_main.c` and `nn_fs.c`), but `mkw_glue.c` answered with stubs, so the only way to try a changed game file was the `HOS_FS_OVERLAY` test switch. This adds the loader. **What it does** `host/mods.c` is the RomFS part of Skybound's loader (`NotRexed/SkyboundTotk` `a64-kit/hos/mods.c`, MIT, commit `4315342`): - `mods/<name>/romfs/...` beside `hookshot.exe`, or `HOS_MODS=<dir>`, in the layout emulators use, so their RomFS mods work as they are. Deeper layouts (`contents/<title id>/<name>/romfs`) work too. - Folders starting with `-` or `_` are off; when two mods have the same file, the last-sorted one wins. - Each file read from a mod is logged (`mods: <path> <- <file>`). - `HOS_FS_OVERLAY` is unchanged and still wins over a mod. **Changes from Skybound's file** - No browser-build stubs. - The executable's folder is found with either path separator, so `host/posix` finds the mods folder. **Left out:** exefs patches (`.pchtxt`, `.ips`). The code is compiled ahead of time, and the game folder has only `image.bin`, not the module map Skybound places data patches with. A mod's `exefs` folder is logged as left out. I also added a short "Mods" section to the readme. **Tested** - A full Windows build of this branch with `make_game.py` and the release builder's own toolchain: `compiled in 1089s, 0 failed`. - Headless, muted boots of that build: - A mod holding a byte-identical `Pack/ZsDic.pack.zs` logged `mods: Pack/ZsDic.pack.zs <- ...\mods\r1-test\romfs\Pack\ZsDic.pack.zs`, and loading went on to 60 fps. - A `-off` folder was skipped. - An exefs-only mod was logged as left out. - With `HOS_FS_OVERLAY` also set, the overlay copy was opened instead of the mod's. - Rebased onto `7ef5f40` afterwards. In the files this touches, only `mkw_glue.c` changed upstream (two lines). `clang -fsyntax-only` on `mods.c`, `mkw_glue.c` and `nn_fs.c` passes on the rebased tree. - Linux: syntax-checked against `host/posix` with glibc headers; not linked or run. - Not tried in game: a mod that adds new entries to a folder listing. That path is Skybound's code, unchanged. Context: we're building a randomizer that writes its output as an emulator-layout mod folder. With this it drops into `mods\` as is.
Commenting is not possible because the repository is archived.
No description provided.