From 08601dfcfec0390cfa38b802009a5c83ab5fc06f Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sun, 9 May 2021 19:19:19 +0000 Subject: [PATCH] Initial parsing of AFP buttons, which is good enough to parse all of DDR PS3's files and decompile them. --- bemani/format/afp/swf.py | 180 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 178 insertions(+), 2 deletions(-) diff --git a/bemani/format/afp/swf.py b/bemani/format/afp/swf.py index dcde122..69bb532 100644 --- a/bemani/format/afp/swf.py +++ b/bemani/format/afp/swf.py @@ -189,6 +189,18 @@ class AP2DefineMorphShape(Tag): } +class AP2DefineButton(Tag): + def __init__(self, id: int) -> None: + # TODO: I need to figure out what buttons actually DO, and take the + # values that I parsed out store them here... + super().__init__(id) + + def as_dict(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: + return { + **super().as_dict(*args, **kwargs), + } + + class AP2DefineTextTag(Tag): def __init__(self, id: int, lines: List[AP2TextLine]) -> None: super().__init__(id) @@ -425,9 +437,9 @@ class SWF(TrackedCoverage, VerboseOutput): # Whether this is parsed or not. self.parsed = False - def print_coverage(self) -> None: + def print_coverage(self, *args: Any, **kwargs: Any) -> None: # First print uncovered bytes - super().print_coverage() + super().print_coverage(*args, **kwargs) # Now, print uncovered strings for offset, (string, covered) in self.__strings.items(): @@ -1580,6 +1592,170 @@ class SWF(TrackedCoverage, VerboseOutput): self.vprint(f"{prefix} Floats: {fv1} {fv2} {fv3} {fv4} {fv5} {fv6} {fv7} {fv8}") return AP2DefineMorphShape(define_shape_id) + elif tagid == AP2Tag.AP2_DEFINE_BUTTON: + flags, button_id, source_tags_count, bytecode_count = struct.unpack("> 24) & 0xFF) / 255.0 + multcolor.g = float((rgba >> 16) & 0xFF) / 255.0 + multcolor.b = float((rgba >> 8) & 0xFF) / 255.0 + multcolor.a = float(rgba & 0xFF) / 255.0 + self.vprint(f"{prefix} Mult Color: {multcolor}") + + if flags & 0x4000: + # Additive color present, smaller integers. + rgba = struct.unpack("> 24) & 0xFF) / 255.0 + addcolor.g = float((rgba >> 16) & 0xFF) / 255.0 + addcolor.b = float((rgba >> 8) & 0xFF) / 255.0 + addcolor.a = float(rgba & 0xFF) / 255.0 + self.vprint(f"{prefix} Add Color: {addcolor}") + + if flags & 0x8000: + # Some sort of filter data? Not sure what this is either. Needs more investigation + # if I encounter files with it. + count, filter_size = struct.unpack("