From d9a48e150f8620275ef7a09d958a9ace57e2d471 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Tue, 25 May 2021 02:00:56 +0000 Subject: [PATCH] Implement additional tag parsing necessary to render some Museca animations. --- bemani/format/afp/swf.py | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/bemani/format/afp/swf.py b/bemani/format/afp/swf.py index 9076ca4..9b71792 100644 --- a/bemani/format/afp/swf.py +++ b/bemani/format/afp/swf.py @@ -111,6 +111,20 @@ class AP2ShapeTag(Tag): } +class AP2ImageTag(Tag): + def __init__(self, id: int, reference: str) -> None: + super().__init__(id) + + # The reference is the name of a texture that will be displayed directly. + self.reference = reference + + def as_dict(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: + return { + **super().as_dict(*args, **kwargs), + 'reference': self.reference, + } + + class AP2DefineFontTag(Tag): def __init__(self, id: int, fontname: str, xml_prefix: str, heights: List[int], text_indexes: List[int]) -> None: super().__init__(id) @@ -1400,12 +1414,76 @@ class SWF(TrackedCoverage, VerboseOutput): if flags & 0x20000000: # TODO: Again, absolutely no idea, gets passed into a function and I # don't see how its used. + unhandled_flags &= ~0x20000000 unk_a, unk_b, unk_c = struct.unpack("> 2) * + ((unk_flags & 1) + 1) * + unk_size + ) + + self.vprint(f"{prefix} WTF: {hex(unk_flags)}, {unk_size}, {cur_size}") + + self.add_coverage(dataoffset + running_pointer, cur_size * 2) + running_pointer += cur_size * 2 + + if flags & 0x1000000000: + # I have no idea what this is, but the two shorts that it pulls out are assigned + # to the same variables as those in 0x2000000000, so they're obviously linked. + unhandled_flags &= ~0x1000000000 + unk1, unk2, unk3 = struct.unpack(" 0: + catchup = 4 - misalignment + self.add_coverage(dataoffset + running_pointer, catchup) + running_pointer += catchup + + if flags & 0x4000000000: + raise Exception("TODO") + # This flag states whether we are creating a new object on this depth, or updating one. unhandled_flags &= ~0x400000D if flags & 0x1: @@ -1915,6 +1993,20 @@ class SWF(TrackedCoverage, VerboseOutput): raise Exception(f"Failed to parse {dataoffset + size - running_data_ptr} bytes of data!") return AP2PlaceCameraTag() + elif tagid == AP2Tag.AP2_IMAGE: + if size != 8: + raise Exception(f"Invalid size {size} to get data from AP2_IMAGE!") + flags, image_id, image_str_ptr = struct.unpack("