diff --git a/assets/xml/scenes/overworld/spot05.xml b/assets/xml/scenes/overworld/spot05.xml index 53ee4a5125..640323ff8c 100644 --- a/assets/xml/scenes/overworld/spot05.xml +++ b/assets/xml/scenes/overworld/spot05.xml @@ -1,9 +1,18 @@ - - + + + + + + + + - + + + + diff --git a/assets/xml/scenes/overworld/spot05_pal_n64.xml b/assets/xml/scenes/overworld/spot05_pal_n64.xml deleted file mode 100644 index eba27fbc44..0000000000 --- a/assets/xml/scenes/overworld/spot05_pal_n64.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/baseroms/pal-1.0/config.yml b/baseroms/pal-1.0/config.yml index 37ffb7500b..c9aca5da30 100644 --- a/baseroms/pal-1.0/config.yml +++ b/baseroms/pal-1.0/config.yml @@ -1134,7 +1134,7 @@ assets: - name: scenes/overworld/spot04 xml_path: assets/xml/scenes/overworld/spot04_pal_n64.xml - name: scenes/overworld/spot05 - xml_path: assets/xml/scenes/overworld/spot05_pal_n64.xml + xml_path: assets/xml/scenes/overworld/spot05.xml - name: scenes/overworld/spot06 xml_path: assets/xml/scenes/overworld/spot06_pal_n64.xml - name: scenes/overworld/spot07 diff --git a/baseroms/pal-1.1/config.yml b/baseroms/pal-1.1/config.yml index 45bf82b877..b25148152c 100644 --- a/baseroms/pal-1.1/config.yml +++ b/baseroms/pal-1.1/config.yml @@ -1134,7 +1134,7 @@ assets: - name: scenes/overworld/spot04 xml_path: assets/xml/scenes/overworld/spot04_pal_n64.xml - name: scenes/overworld/spot05 - xml_path: assets/xml/scenes/overworld/spot05_pal_n64.xml + xml_path: assets/xml/scenes/overworld/spot05.xml - name: scenes/overworld/spot06 xml_path: assets/xml/scenes/overworld/spot06_pal_n64.xml - name: scenes/overworld/spot07 diff --git a/tools/assets/descriptor/base.py b/tools/assets/descriptor/base.py index a0833ec093..2c1f929ede 100644 --- a/tools/assets/descriptor/base.py +++ b/tools/assets/descriptor/base.py @@ -5,6 +5,7 @@ import abc import dataclasses from functools import cache from pathlib import Path +import re from typing import Callable, Optional from xml.etree import ElementTree @@ -260,7 +261,19 @@ def _get_resources_fileelem_to_resourcescollection_pass1( for reselem in fileelem: try: symbol_name = reselem.attrib["Name"] - offset = int(reselem.attrib["Offset"], 16) + if "Offset" in reselem.attrib: + offset = int(reselem.attrib["Offset"], 16) + else: + offset = None + for version_elem in reselem: + if version_elem.tag != "Version": + continue + if re.fullmatch(version_elem.attrib["Pattern"], vc.version): + offset = int(version_elem.attrib["Offset"], 16) + break + if offset is None: + raise Exception(f"No Offset on resource {symbol_name}") + res_handler = _get_resource_handler(reselem.tag) try: res = res_handler(symbol_name, offset, collection, reselem) diff --git a/tools/assets/descriptor/n64resources.py b/tools/assets/descriptor/n64resources.py index fe7c7172da..49aa5127ec 100644 --- a/tools/assets/descriptor/n64resources.py +++ b/tools/assets/descriptor/n64resources.py @@ -34,7 +34,7 @@ class DListResourceDesc(ResourceDesc): def handler_DList(symbol_name, offset, collection, reselem: Element): xml_errors.check_attrib( - reselem, {"Name", "Offset"}, {"Ucode", "RawPointers"} | STATIC_ATTRIB + reselem, {"Name"}, {"Offset", "Ucode", "RawPointers"} | STATIC_ATTRIB ) if "Ucode" in reselem.attrib: ucode = GfxMicroCode[reselem.attrib["Ucode"].upper()] @@ -54,7 +54,7 @@ class BlobResourceDesc(ResourceDesc): def handler_Blob(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset", "Size"}, STATIC_ATTRIB) + xml_errors.check_attrib(reselem, {"Name", "Size"}, {"Offset"} | STATIC_ATTRIB) size = int(reselem.attrib["Size"], 16) return BlobResourceDesc(symbol_name, offset, collection, reselem, size) @@ -65,7 +65,7 @@ class MtxResourceDesc(ResourceDesc): def handler_Mtx(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}, STATIC_ATTRIB) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset"} | STATIC_ATTRIB) return MtxResourceDesc(symbol_name, offset, collection, reselem) @@ -85,7 +85,7 @@ class VtxArrayResourceDesc(ResourceDesc): def handler_Array(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset", "Count"}, STATIC_ATTRIB) + xml_errors.check_attrib(reselem, {"Name", "Count"}, {"Offset"} | STATIC_ATTRIB) count = int(reselem.attrib["Count"]) assert len(reselem) == 1, "Expected exactly one child of Array node" array_elem = reselem[0] @@ -137,9 +137,10 @@ def handler_Texture( ): xml_errors.check_attrib( reselem, - {"Name", "Offset", "Format", "Width", "Height"}, + {"Name", "Format", "Width", "Height"}, # TODO remove OutName, SplitTlut { + "Offset", "OutName", "SplitTlut", "TlutOffset", @@ -169,9 +170,9 @@ def handler_Texture( if "TlutOffset" in reselem.attrib: xml_errors.check_attrib( reselem, - {"Name", "Offset", "Format", "Width", "Height", "TlutOffset"}, + {"Name", "Format", "Width", "Height", "TlutOffset"}, # TODO remove OutName, SplitTlut - {"OutName", "SplitTlut", "HackMode"} | STATIC_ATTRIB, + {"Offset", "OutName", "SplitTlut", "HackMode"} | STATIC_ATTRIB, ) tlut_offset = int(reselem.attrib["TlutOffset"], 16) @@ -193,7 +194,6 @@ def handler_Texture( reselem, { "Name", - "Offset", "Format", "Width", "Height", @@ -201,7 +201,7 @@ def handler_Texture( "ExternalTlutOffset", }, # TODO remove OutName, SplitTlut - {"OutName", "SplitTlut", "HackMode"} | STATIC_ATTRIB, + {"Offset", "OutName", "SplitTlut", "HackMode"} | STATIC_ATTRIB, ) external_tlut_file = reselem.attrib["ExternalTlut"] external_tlut_offset = int(reselem.attrib["ExternalTlutOffset"], 16) @@ -229,9 +229,9 @@ def handler_Texture( else: xml_errors.check_attrib( reselem, - {"Name", "Offset", "Format", "Width", "Height"}, + {"Name", "Format", "Width", "Height"}, # TODO remove OutName - {"OutName", "HackMode"} | STATIC_ATTRIB, + {"Offset", "OutName", "HackMode"} | STATIC_ATTRIB, ) res = TextureResourceDesc( symbol_name, offset, collection, reselem, format, width, height diff --git a/tools/assets/descriptor/z64resources.py b/tools/assets/descriptor/z64resources.py index fba264151f..d5e6cf032c 100644 --- a/tools/assets/descriptor/z64resources.py +++ b/tools/assets/descriptor/z64resources.py @@ -20,7 +20,7 @@ class CollisionResourceDesc(ResourceDesc): def handler_Collision(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset"}) return CollisionResourceDesc(symbol_name, offset, collection, reselem) @@ -30,7 +30,7 @@ class AnimationResourceDesc(ResourceDesc): def handler_Animation(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset"}) return AnimationResourceDesc(symbol_name, offset, collection, reselem) @@ -40,7 +40,7 @@ class PlayerAnimationResourceDesc(ResourceDesc): def handler_PlayerAnimation(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset"}) return PlayerAnimationResourceDesc(symbol_name, offset, collection, reselem) @@ -50,7 +50,7 @@ class LegacyAnimationResourceDesc(ResourceDesc): def handler_LegacyAnimation(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset"}) return LegacyAnimationResourceDesc(symbol_name, offset, collection, reselem) @@ -60,7 +60,7 @@ class CutsceneResourceDesc(ResourceDesc): def handler_Cutscene(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset"}) return CutsceneResourceDesc(symbol_name, offset, collection, reselem) @@ -70,7 +70,7 @@ class SceneResourceDesc(ResourceDesc): def handler_Scene(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset"}) return SceneResourceDesc(symbol_name, offset, collection, reselem) @@ -80,7 +80,7 @@ class RoomResourceDesc(ResourceDesc): def handler_Room(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset"}, {"HackMode"}) + xml_errors.check_attrib(reselem, {"Name"}, {"Offset", "HackMode"}) res = RoomResourceDesc(symbol_name, offset, collection, reselem) if reselem.attrib.get("HackMode") == "syotes_room": res.hack_modes.add("hackmode_syotes_room") @@ -93,7 +93,7 @@ class PlayerAnimationDataResourceDesc(ResourceDesc): def handler_PlayerAnimationData(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset", "FrameCount"}) + xml_errors.check_attrib(reselem, {"Name", "FrameCount"}, {"Offset"}) frame_count = int(reselem.attrib["FrameCount"]) return PlayerAnimationDataResourceDesc( symbol_name, offset, collection, reselem, frame_count @@ -106,7 +106,7 @@ class PathListResourceDesc(ResourceDesc): def handler_PathList(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset", "NumPaths"}) + xml_errors.check_attrib(reselem, {"Name", "NumPaths"}, {"Offset"}) num_paths = int(reselem.attrib["NumPaths"]) return PathListResourceDesc(symbol_name, offset, collection, reselem, num_paths) @@ -137,8 +137,8 @@ class SkeletonResourceDesc(ResourceDesc): def handler_Skeleton(symbol_name, offset, collection, reselem: Element): xml_errors.check_attrib( reselem, - {"Name", "Offset", "Type", "LimbType"}, - {"EnumName", "LimbNone", "LimbMax"}, + {"Name", "Type", "LimbType"}, + {"Offset", "EnumName", "LimbNone", "LimbMax"}, ) skel_type = SkeletonType[reselem.attrib["Type"].upper()] limb_type = LimbType[reselem.attrib["LimbType"].upper()] @@ -162,7 +162,7 @@ class LimbResourceDesc(ResourceDesc): def handler_Limb(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset", "LimbType"}, {"EnumName"}) + xml_errors.check_attrib(reselem, {"Name", "LimbType"}, {"Offset", "EnumName"}) limb_type = LimbType[reselem.attrib["LimbType"].upper()] return LimbResourceDesc( symbol_name, @@ -181,7 +181,7 @@ class LimbTableResourceDesc(ResourceDesc): def handler_LimbTable(symbol_name, offset, collection, reselem: Element): - xml_errors.check_attrib(reselem, {"Name", "Offset", "LimbType", "Count"}) + xml_errors.check_attrib(reselem, {"Name", "LimbType", "Count"}, {"Offset"}) limb_type = LimbType[reselem.attrib["LimbType"].upper()] count = int(reselem.attrib["Count"]) return LimbTableResourceDesc( @@ -197,7 +197,7 @@ class CurveAnimationResourceDesc(ResourceDesc): def handler_CurveAnimation( symbol_name, offset, collection: ResourcesDescCollection, reselem: Element ): - xml_errors.check_attrib(reselem, {"Name", "Offset", "SkelOffset"}) + xml_errors.check_attrib(reselem, {"Name", "SkelOffset"}, {"Offset"}) res = CurveAnimationResourceDesc(symbol_name, offset, collection, reselem, None) skel_offset = int(reselem.attrib["SkelOffset"], 16)