From 83457808e7a6020db5ae77f8e5218d2e94b276f0 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sat, 29 May 2021 00:00:15 +0000 Subject: [PATCH] A bit of refactoring and debug messages. --- bemani/format/afp/render.py | 3 +++ bemani/format/afp/swf.py | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bemani/format/afp/render.py b/bemani/format/afp/render.py index 080d43f..88e7cdc 100644 --- a/bemani/format/afp/render.py +++ b/bemani/format/afp/render.py @@ -497,6 +497,7 @@ class AFPRenderer(VerboseOutput): if not hasattr(obj, attribute): print(f"WARNING: Tried to set attribute {attribute} on {obj} but that attribute doesn't exist!") else: + self.vprint(f"{prefix} Setting attribute {attribute} on {obj} to {set_value}") setattr(obj, attribute, set_value) elif action.opcode == AP2Action.CALL_METHOD: # Grab the method name. @@ -515,6 +516,7 @@ class AFPRenderer(VerboseOutput): # Look up the python function we're calling. try: + self.vprint(f"{prefix} Calling method {methname}({', '.join(repr(s) for s in params)}) on {obj}") meth = getattr(obj, methname) # Call it, set the return on the stack. @@ -537,6 +539,7 @@ class AFPRenderer(VerboseOutput): # Look up the python function we're calling. try: + self.vprint(f"{prefix} Calling global function {funcname}({', '.join(repr(s) for s in params)})") func = getattr(globalobj, funcname) # Call it, set the return on the stack. diff --git a/bemani/format/afp/swf.py b/bemani/format/afp/swf.py index 9b71792..89948f2 100644 --- a/bemani/format/afp/swf.py +++ b/bemani/format/afp/swf.py @@ -1437,22 +1437,28 @@ class SWF(TrackedCoverage, VerboseOutput): # I have no idea what any of this is either, so I am duplicating game logic in the # hopes that someday it makes sense. - cur_size = 0 - for bit in range(32): if bool(bitmask & (1 << bit)): - unk_flags, unk_size = struct.unpack("> 2) * + # Either 1 or 2, depending on unk_flags & 0x1 set. ((unk_flags & 1) + 1) * - unk_size + # Raw size as read from the header above. + unk_size * + # I assume this is some number of shorts, much like many other + # file formats, so this is why all of these counts are doubled. + 2 ) - self.vprint(f"{prefix} WTF: {hex(unk_flags)}, {unk_size}, {cur_size}") + self.vprint(f"{prefix} WTF: {hex(unk_flags)}, {unk_size}, {chunk_size}") - self.add_coverage(dataoffset + running_pointer, cur_size * 2) - running_pointer += cur_size * 2 + # Skip past data. + running_pointer += chunk_size if flags & 0x1000000000: # I have no idea what this is, but the two shorts that it pulls out are assigned