Skip to content

Commit

Permalink
Merge pull request #123 from dyceron/parse-blsnd
Browse files Browse the repository at this point in the history
MSR - Add .blsnd support
  • Loading branch information
ThanatosGit authored Feb 8, 2024
2 parents d70ee02 + 7c90d98 commit f559a36
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mercury_engine_data_structures/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from mercury_engine_data_structures.formats.base_resource import AssetType, BaseResource
from mercury_engine_data_structures.formats.bcmdl import Bcmdl
from mercury_engine_data_structures.formats.bldef import Bldef
from mercury_engine_data_structures.formats.blsnd import Blsnd
from mercury_engine_data_structures.formats.bmbls import Bmbls
from mercury_engine_data_structures.formats.bmmap import Bmmap
from mercury_engine_data_structures.formats.bmmdef import Bmmdef
Expand Down Expand Up @@ -38,6 +39,7 @@
"PKG": Pkg,
"BCMDL": Bcmdl,
"BLDEF": Bldef,
"BLSND": Blsnd,
"BMBLS": Bmbls,
"BMMAP": Bmmap,
"BMMDEF": Bmmdef,
Expand Down
32 changes: 32 additions & 0 deletions src/mercury_engine_data_structures/formats/blsnd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import functools

import construct
from construct.core import (
Const,
Construct,
Hex,
Int32ul,
Struct,
)

from mercury_engine_data_structures.common_types import StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.game_check import Game

BLSND = Struct(
"_magic" / Const(b"LSND"),
"version" / Const(0x000B0001, Hex(Int32ul)),
"unk" / Int32ul,
"sound_limits" / make_vector(Struct(
"name" / StrId,
"value" / Int32ul,
)),
construct.Terminated,
)


class Blsnd(BaseResource):
@classmethod
@functools.lru_cache
def construct_class(cls, target_game: Game) -> Construct:
return BLSND
13 changes: 13 additions & 0 deletions tests/formats/test_blsnd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
from tests.test_lib import parse_build_compare_editor

from mercury_engine_data_structures import samus_returns_data
from mercury_engine_data_structures.formats.blsnd import Blsnd

all_sr_blsnd = [name for name in samus_returns_data.all_name_to_asset_id().keys()
if name.endswith(".blsnd")]


@pytest.mark.parametrize("blsnd_path", all_sr_blsnd)
def test_blsnd(samus_returns_tree, blsnd_path):
parse_build_compare_editor(Blsnd, samus_returns_tree, blsnd_path)

0 comments on commit f559a36

Please sign in to comment.