Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PQ2 FlowScript Compile Fails #76

Open
AcidicPeridot opened this issue Apr 25, 2024 · 3 comments
Open

PQ2 FlowScript Compile Fails #76

AcidicPeridot opened this issue Apr 25, 2024 · 3 comments

Comments

@AcidicPeridot
Copy link

This .bf file from Persona Q2 throws an error when attempting to recompile, even when no changes are made.

Command:
"combi01.bf.flow" -Compile -OutFormat V2 -Library PQ2 -Encoding SJ -Hook -SumBits
Error:

[04/25/2024 02:53 AM] 4/25/2024 2:53:58 AM  Info: (0103:0000) Compiling procedure: BTL_TAG_RUN
[04/25/2024 02:53 AM] 4/25/2024 2:53:58 AM  Error: (0107:0004) A integer literal is an invalid statement
[04/25/2024 02:53 AM] 4/25/2024 2:53:58 AM  Error: (0104:0000) Failed to emit procedure body
[04/25/2024 02:53 AM] 4/25/2024 2:53:58 AM  Error: One or more errors occured during compilation!
[04/25/2024 02:53 AM] 4/25/2024 2:53:58 AM  Error: One or more errors occured while executing task!
[04/25/2024 02:53 AM] 
@AnimatedSwine37
Copy link
Contributor

The actual problem is with the decompilation. The procedure ends up as the following when is clearly incorrect and therefore can't be compiled

void BTL_TAG_RUN()
{
    PUTS( "実行" );
    EVT_FUNCTION_0018( 4, 9001 );
    0;
    0;
    UNKNOWN_FUNCTION_12707();
    60;
    1;
    UNKNOWN_FUNCTION_12707();
    140;
    UNKNOWN_FUNCTION_12708();
    300;
    2;
    UNKNOWN_FUNCTION_12707();
    BTL_FUNCTION_0198();
}

@lraty-li
Copy link

same problem in event/e800 series .bf files.
event/e800/e808_020.bf.flow line 26

......
// Procedure Index: 0
void e808_020()
{
    int var0;
    EVT_FUNCTION_000F( 1 );
    EVT_FUNCTION_0001( -1, -1 );
    EVT_FUNCTION_0017( 1 );
    EVT_SET_USUAL();
    0;
    1;
    
    if ( UNKNOWN_FUNCTION_-32764() == 8 )
    {
        WND_FUNCTION_000C( 0, 1 );
        WND_FUNCTION_000B( 2 );
        WND_FUNCTION_000B( 3 );
......

and unknown function numer gets negative value, like -32764 of UNKNOWN_FUNCTION_-32764()

e828_045.zip

@oceanstuck
Copy link

oceanstuck commented Aug 12, 2024

Went and did a look with this alongside Peridot. The initial example with UNKNOWN_FUNCTIONs 12707 and 12708 was the result of the library having no functions at their respective ids (0x31a3 and 0x31a4) and was resolved by adding functions of those ids with the correct number of parameters. They appear to both control the displaying of subtitles during Unison Skills, with 12707 displaying a msg at a certain frame and 12708 controlling how long a msg is displayed for.

However, UNKNOWN_FUNCTION_-32764 appears to already be properly defined in the library. From disassembling the assembly, one can see that its id is 0x8004 and it takes two int parameters, corresponding to CAMP_FUNCTION_0004. The decompiler appears to be interpreting the function index (a value that should be unsigned) as signed, as -32764 in hex is -7ffc, the two's complement of which is 8004.
Screenshot_21
Screenshot_4
Screenshot_5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants