From 481c5a50ceb13a758668f4fe92343e06e2d3f71c Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Wed, 5 May 2021 00:57:31 +0000 Subject: [PATCH] Implement one more opcode that I've seen in Bishi levels. --- bemani/format/afp/decompile.py | 24 ++++++++++++++++++++++-- bemani/format/afp/types/ap2.py | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/bemani/format/afp/decompile.py b/bemani/format/afp/decompile.py index f44fcce..2a10ece 100644 --- a/bemani/format/afp/decompile.py +++ b/bemani/format/afp/decompile.py @@ -368,6 +368,24 @@ class CloneSpriteStatement(Statement): return [f"{prefix}builtin_CloneSprite({obj}, {name}, {depth});"] +class GetURL2Statement(Statement): + # Load the URL given in the parameters, with any possible target. + def __init__(self, action: int, url: Any, target: Any) -> None: + self.action = action + self.url = url + self.target = target + + def __repr__(self) -> str: + url = value_ref(self.url, "") + target = value_ref(self.target, "") + return f"builtin_GetURL2({self.action}, {url}, {target})" + + def render(self, prefix: str) -> List[str]: + url = value_ref(self.url, "") + target = value_ref(self.target, "") + return [f"{prefix}builtin_GetURL2({self.action}, {url}, {target});"] + + class MaybeStackEntry(Expression): def __init__(self, parent_stack_id: int) -> None: self.parent_stack_id = parent_stack_id @@ -2419,7 +2437,10 @@ class ByteCodeDecompiler(VerboseOutput): # TODO: I have to figure out what "geturl2" actually even does. # It is something to do with getting the "URL" of the current # movie clip. - raise Exception(f"TODO: {action}") + url = stack.pop() + target = stack.pop() + chunk.actions[i] = GetURL2Statement(action.action, url, target) + continue if isinstance(action, StartDragAction): # TODO: I have to implement this, if I ever come across it. @@ -2861,7 +2882,6 @@ class ByteCodeDecompiler(VerboseOutput): ) continue - self.vprint(chunk.actions) self.vprint(stack) raise Exception(f"TODO: {action}") diff --git a/bemani/format/afp/types/ap2.py b/bemani/format/afp/types/ap2.py index ec40571..732dccd 100644 --- a/bemani/format/afp/types/ap2.py +++ b/bemani/format/afp/types/ap2.py @@ -394,7 +394,7 @@ class AP2Action: # Gets a single 8-bit integer as an opcode param, take the top two bits of that param as the # action to take. Looks like it is similar to SWF GET_URL2 action. Supported actions are 0, - # 2 and 3. It pops two objects from the stack to perform against. + # 1 and 3. It pops two objects from the stack to perform against. GET_URL2 = 69 # Pops a value from the stack, jumps to offset from opcode params if value is truthy.