Repository navigation
Is there any way to configure the initial setup to setup and use a fully extracted romfs folder instead of using romfs.bin? #1279
|
I wanted to try my hand at some modding and thought the recomp was a perfect opportunity to do so given how many troubles I've been through with all the emulators, performance and stability-wise. (The performance of the recomp is astounding by the way) I had just assumed I would be able to quickly get my hands dirty, but alas romfs is a binary blob. I don't really know the exact reason why we repack the filesystem into a contiguous blob, I'm new on the Switch scene so please enlighten me on that one if you know, but is there any way to allow the setup to keep romfs fully extracted? If not, is there a tool that will let me extract it manually so I could pack it back up as much of a pain as that would be? What are my options in this case? |
Replies: 1 comment
|
Thanks, glad it runs well for you. Short version: the game itself can't run from a loose RomFS folder, but you don't need that to mod it. Why one file. On the Switch a game's RomFS is already a single filesystem image, and the setup keeps it that way. It merges the base game and the update from your dump into Where your files go. Mods are loose files: Getting the originals to edit. Because import json, os, sys
src, out, prefixes = sys.argv[1], sys.argv[2], tuple(sys.argv[3:])
with open(os.path.join(src, 'index.json'), encoding='utf-8') as f:
files = json.load(f)['files']
n = 0
with open(os.path.join(src, 'romfs.bin'), 'rb') as image:
for e in files:
if prefixes and not e['path'].startswith(prefixes):
continue
dest = os.path.join(out, *e['path'].split('/'))
os.makedirs(os.path.dirname(dest), exist_ok=True)
image.seek(e['offset'])
left = e['size']
with open(dest, 'wb') as o:
while left:
chunk = image.read(min(left, 1 << 20))
if not chunk:
raise SystemExit(f'romfs.bin ends early at {e["path"]}')
o.write(chunk)
left -= len(chunk)
n += 1
print(f'{n} files written to {out}')
|
Thanks, glad it runs well for you. Short version: the game itself can't run from a loose RomFS folder, but you don't need that to mod it.
Why one file. On the Switch a game's RomFS is already a single filesystem image, and the setup keeps it that way. It merges the base game and the update from your dump into
romfs\romfs.binand checks its SHA-256. It also writesromfs\index.json, which lists the path, offset and size of each of its 304,243 files. At runtime the port reads each file straight out of the image at its offset (romfs-index.binnext tototk.exeis a compact copy of that table). There is no setup option ortotk.inisetting for an extracted folder, neither in 0.4.1 nor ondev: the…