From 19fb3a75c96b94399f737d4476b2c6cbb01834e9 Mon Sep 17 00:00:00 2001 From: Deon Fouche Date: Sat, 31 Oct 2026 19:04:19 +1000 Subject: [PATCH] Find the resource size table by any ResourceSizeTable.*.rsizetable.zs name, as MacNativeGames does The prompts then do not fail on a table named without Nin_NX_NVN; the test RomFS of 1.4.3 uses that form. Co-Authored-By: Claude Opus 5.5 --- tests/romfs_prompts_test.py | 8 +++++--- tools/make_romfs_patches.py | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/romfs_prompts_test.py b/tests/romfs_prompts_test.py index e68b89bc..dca0d054 100644 --- a/tests/romfs_prompts_test.py +++ b/tests/romfs_prompts_test.py @@ -43,7 +43,9 @@ FACE = {'A': 0xE040, 'B': 0xE041, 'X': 0xE042, 'Y': 0xE043} DRAWN = {0xE044: 820, 0xE045: 820, 0xE046: 760, 0xE047: 760, 0xE04B: 640, 0xE04C: 640, 0xE049: 640, **{cp: 640 for cp in range(0xE060, 0xE066)}} -VERSIONS = {'v121': dict(common='110', size=72, newest=121), 'v143': dict(common='140', size=108, newest=143)} +# restbl: the resource size table's name after its version, in both forms the tool takes. +VERSIONS = {'v121': dict(common='110', size=72, newest=121, restbl='Nin_NX_NVN.rsizetable.zs'), + 'v143': dict(common='140', size=108, newest=143, restbl='rsizetable.zs')} DEFAULT_FONT, REGIONAL_FONT = 'Font/Font.Nin_NX_NVN.bfarc.zs', 'Font/Font_KRko.Nin_NX_NVN.bfarc.zs' PANES = {'T_A_00': 'A', 'T_B_00': 'B', 'T_X_00': 'X', 'T_Y_00': 'Y', 'T_Name_00': 'A'} MESSAGES = {**PANES, 'Greeting': 'Hello'} @@ -308,8 +310,8 @@ class Romfs: self.common = f'UI/LayoutArchive/Common.Product.{v["common"]}.Nin_NX_NVN.blarc.zs' self.mals = [f'Mals/EUen.Product.{v["newest"]}.sarc.zs', f'Mals/USen.Product.{v["newest"]}.sarc.zs'] self.old_mals = 'Mals/USen.Product.110.sarc.zs' - self.restbl = f'System/Resource/ResourceSizeTable.Product.{v["newest"]}.Nin_NX_NVN.rsizetable.zs' - self.old_restbl = 'System/Resource/ResourceSizeTable.Product.100.Nin_NX_NVN.rsizetable.zs' + self.restbl = f'System/Resource/ResourceSizeTable.Product.{v["newest"]}.{v["restbl"]}' + self.old_restbl = f'System/Resource/ResourceSizeTable.Product.100.{v["restbl"]}' # an older version's: left alone size = v['size'] images = {f'Nt_KeyTex{b}_00': (R8_UNORM, size, rnd.randbytes(IMAGE)) for b in 'ABXY'} images.update({'Nt_KeyTexL_00^z': (l_format, size, rnd.randbytes(IMAGE)), diff --git a/tools/make_romfs_patches.py b/tools/make_romfs_patches.py index 5f4dce9a..c3c2433e 100644 --- a/tools/make_romfs_patches.py +++ b/tools/make_romfs_patches.py @@ -225,9 +225,10 @@ for p in files: MALS[m[1]] = (int(m[2]), p) MALS = sorted(p for _, p in MALS.values()) LAYOUT_MSG = 'LayoutMsg/DoCommand_00.msbt' -# The resource size table, likewise the newest version in the RomFS. -RESTBL = max((p for p in files if re.fullmatch(r'System/Resource/ResourceSizeTable\.Product\.\d+\.[\w.]*rsizetable\.zs', p)), - key=lambda p: int(re.search(r'\.Product\.(\d+)\.', p)[1]), default=None) +# The resource size table (System/Resource/ResourceSizeTable.Product....rsizetable.zs, matched as loosely as +# MacNativeGames make_button_icons.py does), likewise the newest version in the RomFS. +RESTBL = max((p for p in files if p.startswith('System/Resource/ResourceSizeTable.') and p.endswith('.rsizetable.zs')), + key=lambda p: int((re.search(r'\.(\d+)\.', p) or [0, 0])[1]), default=None) by_position = args.prompts == 'xbox' # the face buttons' prompts swapped to the labels (pad_layout = nintendo) if args.prompts: assert FONTS, 'no Font/Font*.Nin_NX_NVN.bfarc.zs in the RomFS'