from ED63RDScenarioHelper import *

def main():
    SetCodePage("ms932")

    CreateScenaFile(
        FileName            = 'U4150   ._SN',
        MapName             = 'Gaiden2',
        Location            = 'U4150.x',
        MapIndex            = 1,
        MapDefaultBGM       = "ed60221",
        Flags               = 0,
        EntryFunctionIndex  = 0xFFFF,
        Reserved            = 0,
        IncludedScenario    = [
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            ''
        ],
    )

    BuildStringList(
        '@FileName',                            # 8
        '',                                     # 9
        '',                                     # 10
    )

    DeclEntryPoint(
        Unknown_00              = 0,
        Unknown_04              = 0,
        Unknown_08              = 0,
        Unknown_0C              = 4,
        Unknown_0E              = 5,
        Unknown_10              = 0,
        Unknown_14              = 9500,
        Unknown_18              = -10000,
        Unknown_1C              = 0,
        Unknown_20              = 0,
        Unknown_24              = 2500,
        Unknown_28              = 2800,
        Unknown_2C              = 262,
        Unknown_30              = 45,
        Unknown_32              = 0,
        Unknown_34              = 360,
        Unknown_36              = 0,
        Unknown_38              = 1,
        Unknown_3A              = 1,
        InitScenaIndex          = 0,
        InitFunctionIndex       = 0,
        EntryScenaIndex         = 0,
        EntryFunctionIndex      = 1,
    )


    AddCharChip(
        'ED6_DT29/CH14450 ._CH',             # 00
        'ED6_DT29/CH14451 ._CH',             # 01
        'ED6_DT29/CH14730 ._CH',             # 02
        'ED6_DT29/CH14730 ._CH',             # 03
        'ED6_DT29/CH14790 ._CH',             # 04
        'ED6_DT29/CH14791 ._CH',             # 05
    )

    AddCharChipPat(
        'ED6_DT29/CH14450P._CP',             # 00
        'ED6_DT29/CH14451P._CP',             # 01
        'ED6_DT29/CH14730P._CP',             # 02
        'ED6_DT29/CH14730P._CP',             # 03
        'ED6_DT29/CH14790P._CP',             # 04
        'ED6_DT29/CH14791P._CP',             # 05
    )

    DeclMonster(
        X                   = -140,
        Z                   = 0,
        Y                   = -21440,
        Unknown_0C          = 180,
        Unknown_0E          = 0,
        Unknown_10          = 65,
        Unknown_11          = 1,
        Unknown_12          = 0xFFFFFFFF,
        BattleIndex         = 0xD7,
        Unknown_18          = 0,
        Unknown_1A          = 0,
    )

    DeclMonster(
        X                   = 140,
        Z                   = 0,
        Y                   = -5820,
        Unknown_0C          = 180,
        Unknown_0E          = 2,
        Unknown_10          = 65,
        Unknown_11          = 1,
        Unknown_12          = 0xFFFFFFFF,
        BattleIndex         = 0xD8,
        Unknown_18          = 0,
        Unknown_1A          = 0,
    )


    DeclActor(
        TriggerX            = 8880,
        TriggerZ            = 0,
        TriggerY            = -43040,
        TriggerRange        = 1000,
        ActorX              = 8880,
        ActorZ              = 2000,
        ActorY              = -43040,
        Flags               = 0x7C,
        TalkScenaIndex      = 0,
        TalkFunctionIndex   = 2,
        Unknown_22          = 0,
    )


    ScpFunction(
        "Function_0_136",          # 00, 0
        "Function_1_156",          # 01, 1
        "Function_2_18B",          # 02, 2
        "Function_3_40D",          # 03, 3
        "Function_4_4EB",          # 04, 4
        "Function_5_5A7",          # 05, 5
        "Function_6_6BD",          # 06, 6
    )


    def Function_0_136(): pass

    label("Function_0_136")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0x42), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_EQU), scpexpr(EXPR_END)), "loc_155")
    Switch(
        (scpexpr(EXPR_PUSH_VALUE_INDEX, 0x0), scpexpr(EXPR_END)),
        (115, "loc_14E"),
        (SWITCH_DEFAULT, "loc_155"),
    )


    label("loc_14E")

    Event(0, 3)
    Jump("loc_155")

    label("loc_155")

    Return()

    # Function_0_136 end

    def Function_1_156(): pass

    label("Function_1_156")

    OP_16(0x2, 0xFA0, 0xFFFE0C00, 0xFFFDBDE0, 0x23005B)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0x42), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_EQU), scpexpr(EXPR_END)), "loc_179")
    OP_1B(0xF, 0x0, 0x4)

    label("loc_179")

    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(0x4B0, 6)), scpexpr(EXPR_EQUZ), scpexpr(EXPR_END)), "loc_18A")
    OP_82(0x81, 0x0)
    OP_82(0x82, 0x0)
    OP_82(0x84, 0x0)

    label("loc_18A")

    Return()

    # Function_1_156 end

    def Function_2_18B(): pass

    label("Function_2_18B")

    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(0x4B0, 6)), scpexpr(EXPR_EQUZ), scpexpr(EXPR_END)), "loc_25A")
    EventBegin(0x1)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Sleep(500)
    OP_22(0x161, 0x0, 0x64)
    Fade(1000)
    PlayEffect(0x81, 0xFF, 0xFFFF, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    PlayEffect(0x82, 0xFF, 0xFFFF, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    PlayEffect(0x84, 0xFF, 0xFFFF, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    OP_0D()
    OP_AA(768)
    Sleep(500)
    Jump("loc_25D")

    label("loc_25A")

    TalkBegin(0xFF)

    label("loc_25D")

    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)

    AnonymousTalk(    #0
        "\x07\x05Select an Option\x18\x02",
    )

    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0x18), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0x0), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))

    label("loc_299")

    Jc((scpexpr(EXPR_GET_RESULT, 0x0), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_3DC")

    Menu(
        1,
        -1,
        150,
        1,
        (
            "Restore HP/EP\x01",          # 0
            "Shop\x01",                   # 1
            "Synthesize Quartz\x01",      # 2
            "End\x01",                    # 3
        )
    )

    MenuEnd(0x0)
    OP_5F(0x1)
    OP_56(0x0)
    Switch(
        (scpexpr(EXPR_GET_RESULT, 0x0), scpexpr(EXPR_END)),
        (0, "loc_2F5"),
        (1, "loc_370"),
        (2, "loc_39E"),
        (SWITCH_DEFAULT, "loc_3CC"),
    )


    label("loc_2F5")

    FadeToBright(300, 0)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Sleep(300)
    OP_20(0x3E8)
    OP_22(0xC, 0x0, 0x64)
    FadeToDark(1000, 0, -1)
    OP_0D()
    OP_22(0xD, 0x0, 0x64)
    OP_C0(0x15, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    OP_30(0x1)
    Sleep(3500)
    OP_1D(0xDD)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0x18), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    FadeToBright(1000, 0)
    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Jump("loc_3D9")

    label("loc_370")

    OP_A9(0x16)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)

    AnonymousTalk(    #1
        "\x07\x05Select an Option\x18\x02",
    )

    Jump("loc_3D9")

    label("loc_39E")

    OP_A9(0x2)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)

    AnonymousTalk(    #2
        "\x07\x05Select an Option\x18\x02",
    )

    Jump("loc_3D9")

    label("loc_3CC")

    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Jump("loc_3D9")

    label("loc_3D9")

    Jump("loc_299")

    label("loc_3DC")

    OP_5F(0x1)
    OP_56(0x0)
    FadeToBright(300, 0)
    Sleep(300)
    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0x0), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(0x4B0, 6)), scpexpr(EXPR_EQUZ), scpexpr(EXPR_END)), "loc_409")
    OP_A2(0x2586)
    EventEnd(0x1)
    Jump("loc_40C")

    label("loc_409")

    TalkEnd(0xFF)

    label("loc_40C")

    Return()

    # Function_2_18B end

    def Function_3_40D(): pass

    label("Function_3_40D")

    OP_DE(0x0, 0xF, 0x1)
    EventBegin(0x2)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    SetChrPos(0x0, 120, 0, -53710, 0)
    SetChrPos(0x1, 900, 0, -54640, 0)
    SetChrPos(0x2, -890, 0, -54580, 0)
    SetChrPos(0x3, -120, 0, -55500, 0)
    OP_69(0x0, 0x0)
    LoadEffect(0x0, "map\\mp204_02.eff")
    PlayEffect(0x0, 0xFF, 0xFF, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    OP_22(0x99, 0x0, 0x64)
    OP_22(0xB8, 0x0, 0x64)
    Call(0, 5)
    EventEnd(0x0)
    OP_4F(0x31, (scpexpr(EXPR_PUSH_LONG, 0xAA), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    OP_C0(0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    Return()

    # Function_3_40D end

    def Function_4_4EB(): pass

    label("Function_4_4EB")

    EventBegin(0x1)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Fade(500)
    SetChrPos(0x3, 120, 0, -53710, 180)
    SetChrPos(0x2, 900, 0, -54640, 180)
    SetChrPos(0x1, -890, 0, -54580, 180)
    SetChrPos(0x0, -120, 0, -55500, 180)
    OP_69(0x0, 0x0)
    OP_0D()
    LoadEffect(0x0, "map\\mp204_01.eff")
    PlayEffect(0x0, 0xFF, 0xFF, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    OP_22(0x99, 0x0, 0x64)
    OP_22(0xB8, 0x0, 0x64)
    Call(0, 6)
    NewScene("ED6_DT21/M7005   ._SN", 102, 0, 0)
    IdleLoop()
    Return()

    # Function_4_4EB end

    def Function_5_5A7(): pass

    label("Function_5_5A7")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xA), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_5D0")
    OP_9F(0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_5C4():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x0, 1, lambda_5C4)

    label("loc_5D0")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xB), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_5F9")
    OP_9F(0x1, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_5ED():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x1, 1, lambda_5ED)

    label("loc_5F9")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xC), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_622")
    OP_9F(0x2, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_616():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x2, 1, lambda_616)

    label("loc_622")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xD), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_64B")
    OP_9F(0x3, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_63F():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x3, 1, lambda_63F)

    label("loc_64B")

    Sleep(800)
    OP_44(0x0, 0x1)
    OP_44(0x1, 0x1)
    OP_44(0x2, 0x1)
    OP_44(0x3, 0x1)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xA), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_677")
    OP_9F(0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_677")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xB), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_68E")
    OP_9F(0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_68E")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xC), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_6A5")
    OP_9F(0x2, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_6A5")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xD), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_6BC")
    OP_9F(0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_6BC")

    Return()

    # Function_5_5A7 end

    def Function_6_6BD(): pass

    label("Function_6_6BD")


    def lambda_6C3():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x0, 1, lambda_6C3)

    def lambda_6D5():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x1, 1, lambda_6D5)

    def lambda_6E7():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x2, 1, lambda_6E7)

    def lambda_6F9():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x3, 1, lambda_6F9)
    Sleep(1000)
    Return()

    # Function_6_6BD end

    SaveToFile()

Try(main)

881f0045b5ad311e6b17d3ecca7cff00da7689c6
<mask token>

<mask token>


def main():
    SetCodePage('ms932')
    CreateScenaFile(FileName='U4150   ._SN', MapName='Gaiden2', Location=
        'U4150.x', MapIndex=1, MapDefaultBGM='ed60221', Flags=0,
        EntryFunctionIndex=65535, Reserved=0, IncludedScenario=['', '', '',
        '', '', '', '', ''])
    BuildStringList('@FileName', '', '')
    DeclEntryPoint(Unknown_00=0, Unknown_04=0, Unknown_08=0, Unknown_0C=4,
        Unknown_0E=5, Unknown_10=0, Unknown_14=9500, Unknown_18=-10000,
        Unknown_1C=0, Unknown_20=0, Unknown_24=2500, Unknown_28=2800,
        Unknown_2C=262, Unknown_30=45, Unknown_32=0, Unknown_34=360,
        Unknown_36=0, Unknown_38=1, Unknown_3A=1, InitScenaIndex=0,
        InitFunctionIndex=0, EntryScenaIndex=0, EntryFunctionIndex=1)
    AddCharChip('ED6_DT29/CH14450 ._CH', 'ED6_DT29/CH14451 ._CH',
        'ED6_DT29/CH14730 ._CH', 'ED6_DT29/CH14730 ._CH',
        'ED6_DT29/CH14790 ._CH', 'ED6_DT29/CH14791 ._CH')
    AddCharChipPat('ED6_DT29/CH14450P._CP', 'ED6_DT29/CH14451P._CP',
        'ED6_DT29/CH14730P._CP', 'ED6_DT29/CH14730P._CP',
        'ED6_DT29/CH14790P._CP', 'ED6_DT29/CH14791P._CP')
    DeclMonster(X=-140, Z=0, Y=-21440, Unknown_0C=180, Unknown_0E=0,
        Unknown_10=65, Unknown_11=1, Unknown_12=4294967295, BattleIndex=215,
        Unknown_18=0, Unknown_1A=0)
    DeclMonster(X=140, Z=0, Y=-5820, Unknown_0C=180, Unknown_0E=2,
        Unknown_10=65, Unknown_11=1, Unknown_12=4294967295, BattleIndex=216,
        Unknown_18=0, Unknown_1A=0)
    DeclActor(TriggerX=8880, TriggerZ=0, TriggerY=-43040, TriggerRange=1000,
        ActorX=8880, ActorZ=2000, ActorY=-43040, Flags=124, TalkScenaIndex=
        0, TalkFunctionIndex=2, Unknown_22=0)
    ScpFunction('Function_0_136', 'Function_1_156', 'Function_2_18B',
        'Function_3_40D', 'Function_4_4EB', 'Function_5_5A7', 'Function_6_6BD')

    def Function_0_136():
        pass
    label('Function_0_136')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 66), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_EQU), scpexpr(EXPR_END)), 'loc_155')
    Switch((scpexpr(EXPR_PUSH_VALUE_INDEX, 0), scpexpr(EXPR_END)), (115,
        'loc_14E'), (SWITCH_DEFAULT, 'loc_155'))
    label('loc_14E')
    Event(0, 3)
    Jump('loc_155')
    label('loc_155')
    Return()

    def Function_1_156():
        pass
    label('Function_1_156')
    OP_16(2, 4000, 4294839296, 4294819296, 2293851)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 66), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_EQU), scpexpr(EXPR_END)), 'loc_179')
    OP_1B(15, 0, 4)
    label('loc_179')
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_18A')
    OP_82(129, 0)
    OP_82(130, 0)
    OP_82(132, 0)
    label('loc_18A')
    Return()

    def Function_2_18B():
        pass
    label('Function_2_18B')
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_25A')
    EventBegin(1)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Sleep(500)
    OP_22(353, 0, 100)
    Fade(1000)
    PlayEffect(129, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    PlayEffect(130, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    PlayEffect(132, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    OP_0D()
    OP_AA(768)
    Sleep(500)
    Jump('loc_25D')
    label('loc_25A')
    TalkBegin(255)
    label('loc_25D')
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 24), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 0), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    label('loc_299')
    Jc((scpexpr(EXPR_GET_RESULT, 0), scpexpr(EXPR_PUSH_LONG, 255), scpexpr(
        EXPR_NEQ), scpexpr(EXPR_END)), 'loc_3DC')
    Menu(1, -1, 150, 1, ('Restore HP/EP\x01', 'Shop\x01',
        'Synthesize Quartz\x01', 'End\x01'))
    MenuEnd(0)
    OP_5F(1)
    OP_56(0)
    Switch((scpexpr(EXPR_GET_RESULT, 0), scpexpr(EXPR_END)), (0, 'loc_2F5'),
        (1, 'loc_370'), (2, 'loc_39E'), (SWITCH_DEFAULT, 'loc_3CC'))
    label('loc_2F5')
    FadeToBright(300, 0)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Sleep(300)
    OP_20(1000)
    OP_22(12, 0, 100)
    FadeToDark(1000, 0, -1)
    OP_0D()
    OP_22(13, 0, 100)
    OP_C0(21, 0, 0, 0, 0, 0, 0, 0, 0)
    OP_30(1)
    Sleep(3500)
    OP_1D(221)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 24), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    FadeToBright(1000, 0)
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 255), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jump('loc_3D9')
    label('loc_370')
    OP_A9(22)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    Jump('loc_3D9')
    label('loc_39E')
    OP_A9(2)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    Jump('loc_3D9')
    label('loc_3CC')
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 255), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jump('loc_3D9')
    label('loc_3D9')
    Jump('loc_299')
    label('loc_3DC')
    OP_5F(1)
    OP_56(0)
    FadeToBright(300, 0)
    Sleep(300)
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 0), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_409')
    OP_A2(9606)
    EventEnd(1)
    Jump('loc_40C')
    label('loc_409')
    TalkEnd(255)
    label('loc_40C')
    Return()

    def Function_3_40D():
        pass
    label('Function_3_40D')
    OP_DE(0, 15, 1)
    EventBegin(2)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    SetChrPos(0, 120, 0, -53710, 0)
    SetChrPos(1, 900, 0, -54640, 0)
    SetChrPos(2, -890, 0, -54580, 0)
    SetChrPos(3, -120, 0, -55500, 0)
    OP_69(0, 0)
    LoadEffect(0, 'map\\mp204_02.eff')
    PlayEffect(0, 255, 255, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 255, 
        0, 0, 0, 0)
    OP_22(153, 0, 100)
    OP_22(184, 0, 100)
    Call(0, 5)
    EventEnd(0)
    OP_4F(49, (scpexpr(EXPR_PUSH_LONG, 170), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    OP_C0(22, 0, 0, 0, 0, 0, 0, 0, 0)
    Return()

    def Function_4_4EB():
        pass
    label('Function_4_4EB')
    EventBegin(1)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Fade(500)
    SetChrPos(3, 120, 0, -53710, 180)
    SetChrPos(2, 900, 0, -54640, 180)
    SetChrPos(1, -890, 0, -54580, 180)
    SetChrPos(0, -120, 0, -55500, 180)
    OP_69(0, 0)
    OP_0D()
    LoadEffect(0, 'map\\mp204_01.eff')
    PlayEffect(0, 255, 255, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 255, 
        0, 0, 0, 0)
    OP_22(153, 0, 100)
    OP_22(184, 0, 100)
    Call(0, 6)
    NewScene('ED6_DT21/M7005   ._SN', 102, 0, 0)
    IdleLoop()
    Return()

    def Function_5_5A7():
        pass
    label('Function_5_5A7')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 10), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_5D0')
    OP_9F(0, 255, 255, 255, 0, 0)

    def lambda_5C4():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(0, 1, lambda_5C4)
    label('loc_5D0')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 11), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_5F9')
    OP_9F(1, 255, 255, 255, 0, 0)

    def lambda_5ED():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(1, 1, lambda_5ED)
    label('loc_5F9')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 12), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_622')
    OP_9F(2, 255, 255, 255, 0, 0)

    def lambda_616():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(2, 1, lambda_616)
    label('loc_622')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 13), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_64B')
    OP_9F(3, 255, 255, 255, 0, 0)

    def lambda_63F():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(3, 1, lambda_63F)
    label('loc_64B')
    Sleep(800)
    OP_44(0, 1)
    OP_44(1, 1)
    OP_44(2, 1)
    OP_44(3, 1)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 10), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_677')
    OP_9F(0, 255, 255, 255, 255, 0)
    label('loc_677')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 11), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_68E')
    OP_9F(1, 255, 255, 255, 255, 0)
    label('loc_68E')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 12), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_6A5')
    OP_9F(2, 255, 255, 255, 255, 0)
    label('loc_6A5')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 13), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_6BC')
    OP_9F(3, 255, 255, 255, 255, 0)
    label('loc_6BC')
    Return()

    def Function_6_6BD():
        pass
    label('Function_6_6BD')

    def lambda_6C3():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(0, 1, lambda_6C3)

    def lambda_6D5():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(1, 1, lambda_6D5)

    def lambda_6E7():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(2, 1, lambda_6E7)

    def lambda_6F9():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(3, 1, lambda_6F9)
    Sleep(1000)
    Return()
    SaveToFile()


<mask token>

<mask token>


def main():
    SetCodePage('ms932')
    CreateScenaFile(FileName='U4150   ._SN', MapName='Gaiden2', Location=
        'U4150.x', MapIndex=1, MapDefaultBGM='ed60221', Flags=0,
        EntryFunctionIndex=65535, Reserved=0, IncludedScenario=['', '', '',
        '', '', '', '', ''])
    BuildStringList('@FileName', '', '')
    DeclEntryPoint(Unknown_00=0, Unknown_04=0, Unknown_08=0, Unknown_0C=4,
        Unknown_0E=5, Unknown_10=0, Unknown_14=9500, Unknown_18=-10000,
        Unknown_1C=0, Unknown_20=0, Unknown_24=2500, Unknown_28=2800,
        Unknown_2C=262, Unknown_30=45, Unknown_32=0, Unknown_34=360,
        Unknown_36=0, Unknown_38=1, Unknown_3A=1, InitScenaIndex=0,
        InitFunctionIndex=0, EntryScenaIndex=0, EntryFunctionIndex=1)
    AddCharChip('ED6_DT29/CH14450 ._CH', 'ED6_DT29/CH14451 ._CH',
        'ED6_DT29/CH14730 ._CH', 'ED6_DT29/CH14730 ._CH',
        'ED6_DT29/CH14790 ._CH', 'ED6_DT29/CH14791 ._CH')
    AddCharChipPat('ED6_DT29/CH14450P._CP', 'ED6_DT29/CH14451P._CP',
        'ED6_DT29/CH14730P._CP', 'ED6_DT29/CH14730P._CP',
        'ED6_DT29/CH14790P._CP', 'ED6_DT29/CH14791P._CP')
    DeclMonster(X=-140, Z=0, Y=-21440, Unknown_0C=180, Unknown_0E=0,
        Unknown_10=65, Unknown_11=1, Unknown_12=4294967295, BattleIndex=215,
        Unknown_18=0, Unknown_1A=0)
    DeclMonster(X=140, Z=0, Y=-5820, Unknown_0C=180, Unknown_0E=2,
        Unknown_10=65, Unknown_11=1, Unknown_12=4294967295, BattleIndex=216,
        Unknown_18=0, Unknown_1A=0)
    DeclActor(TriggerX=8880, TriggerZ=0, TriggerY=-43040, TriggerRange=1000,
        ActorX=8880, ActorZ=2000, ActorY=-43040, Flags=124, TalkScenaIndex=
        0, TalkFunctionIndex=2, Unknown_22=0)
    ScpFunction('Function_0_136', 'Function_1_156', 'Function_2_18B',
        'Function_3_40D', 'Function_4_4EB', 'Function_5_5A7', 'Function_6_6BD')

    def Function_0_136():
        pass
    label('Function_0_136')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 66), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_EQU), scpexpr(EXPR_END)), 'loc_155')
    Switch((scpexpr(EXPR_PUSH_VALUE_INDEX, 0), scpexpr(EXPR_END)), (115,
        'loc_14E'), (SWITCH_DEFAULT, 'loc_155'))
    label('loc_14E')
    Event(0, 3)
    Jump('loc_155')
    label('loc_155')
    Return()

    def Function_1_156():
        pass
    label('Function_1_156')
    OP_16(2, 4000, 4294839296, 4294819296, 2293851)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 66), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_EQU), scpexpr(EXPR_END)), 'loc_179')
    OP_1B(15, 0, 4)
    label('loc_179')
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_18A')
    OP_82(129, 0)
    OP_82(130, 0)
    OP_82(132, 0)
    label('loc_18A')
    Return()

    def Function_2_18B():
        pass
    label('Function_2_18B')
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_25A')
    EventBegin(1)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Sleep(500)
    OP_22(353, 0, 100)
    Fade(1000)
    PlayEffect(129, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    PlayEffect(130, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    PlayEffect(132, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    OP_0D()
    OP_AA(768)
    Sleep(500)
    Jump('loc_25D')
    label('loc_25A')
    TalkBegin(255)
    label('loc_25D')
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 24), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 0), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    label('loc_299')
    Jc((scpexpr(EXPR_GET_RESULT, 0), scpexpr(EXPR_PUSH_LONG, 255), scpexpr(
        EXPR_NEQ), scpexpr(EXPR_END)), 'loc_3DC')
    Menu(1, -1, 150, 1, ('Restore HP/EP\x01', 'Shop\x01',
        'Synthesize Quartz\x01', 'End\x01'))
    MenuEnd(0)
    OP_5F(1)
    OP_56(0)
    Switch((scpexpr(EXPR_GET_RESULT, 0), scpexpr(EXPR_END)), (0, 'loc_2F5'),
        (1, 'loc_370'), (2, 'loc_39E'), (SWITCH_DEFAULT, 'loc_3CC'))
    label('loc_2F5')
    FadeToBright(300, 0)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Sleep(300)
    OP_20(1000)
    OP_22(12, 0, 100)
    FadeToDark(1000, 0, -1)
    OP_0D()
    OP_22(13, 0, 100)
    OP_C0(21, 0, 0, 0, 0, 0, 0, 0, 0)
    OP_30(1)
    Sleep(3500)
    OP_1D(221)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 24), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    FadeToBright(1000, 0)
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 255), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jump('loc_3D9')
    label('loc_370')
    OP_A9(22)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    Jump('loc_3D9')
    label('loc_39E')
    OP_A9(2)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    Jump('loc_3D9')
    label('loc_3CC')
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 255), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jump('loc_3D9')
    label('loc_3D9')
    Jump('loc_299')
    label('loc_3DC')
    OP_5F(1)
    OP_56(0)
    FadeToBright(300, 0)
    Sleep(300)
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 0), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_409')
    OP_A2(9606)
    EventEnd(1)
    Jump('loc_40C')
    label('loc_409')
    TalkEnd(255)
    label('loc_40C')
    Return()

    def Function_3_40D():
        pass
    label('Function_3_40D')
    OP_DE(0, 15, 1)
    EventBegin(2)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    SetChrPos(0, 120, 0, -53710, 0)
    SetChrPos(1, 900, 0, -54640, 0)
    SetChrPos(2, -890, 0, -54580, 0)
    SetChrPos(3, -120, 0, -55500, 0)
    OP_69(0, 0)
    LoadEffect(0, 'map\\mp204_02.eff')
    PlayEffect(0, 255, 255, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 255, 
        0, 0, 0, 0)
    OP_22(153, 0, 100)
    OP_22(184, 0, 100)
    Call(0, 5)
    EventEnd(0)
    OP_4F(49, (scpexpr(EXPR_PUSH_LONG, 170), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    OP_C0(22, 0, 0, 0, 0, 0, 0, 0, 0)
    Return()

    def Function_4_4EB():
        pass
    label('Function_4_4EB')
    EventBegin(1)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Fade(500)
    SetChrPos(3, 120, 0, -53710, 180)
    SetChrPos(2, 900, 0, -54640, 180)
    SetChrPos(1, -890, 0, -54580, 180)
    SetChrPos(0, -120, 0, -55500, 180)
    OP_69(0, 0)
    OP_0D()
    LoadEffect(0, 'map\\mp204_01.eff')
    PlayEffect(0, 255, 255, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 255, 
        0, 0, 0, 0)
    OP_22(153, 0, 100)
    OP_22(184, 0, 100)
    Call(0, 6)
    NewScene('ED6_DT21/M7005   ._SN', 102, 0, 0)
    IdleLoop()
    Return()

    def Function_5_5A7():
        pass
    label('Function_5_5A7')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 10), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_5D0')
    OP_9F(0, 255, 255, 255, 0, 0)

    def lambda_5C4():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(0, 1, lambda_5C4)
    label('loc_5D0')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 11), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_5F9')
    OP_9F(1, 255, 255, 255, 0, 0)

    def lambda_5ED():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(1, 1, lambda_5ED)
    label('loc_5F9')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 12), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_622')
    OP_9F(2, 255, 255, 255, 0, 0)

    def lambda_616():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(2, 1, lambda_616)
    label('loc_622')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 13), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_64B')
    OP_9F(3, 255, 255, 255, 0, 0)

    def lambda_63F():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(3, 1, lambda_63F)
    label('loc_64B')
    Sleep(800)
    OP_44(0, 1)
    OP_44(1, 1)
    OP_44(2, 1)
    OP_44(3, 1)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 10), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_677')
    OP_9F(0, 255, 255, 255, 255, 0)
    label('loc_677')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 11), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_68E')
    OP_9F(1, 255, 255, 255, 255, 0)
    label('loc_68E')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 12), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_6A5')
    OP_9F(2, 255, 255, 255, 255, 0)
    label('loc_6A5')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 13), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_6BC')
    OP_9F(3, 255, 255, 255, 255, 0)
    label('loc_6BC')
    Return()

    def Function_6_6BD():
        pass
    label('Function_6_6BD')

    def lambda_6C3():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(0, 1, lambda_6C3)

    def lambda_6D5():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(1, 1, lambda_6D5)

    def lambda_6E7():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(2, 1, lambda_6E7)

    def lambda_6F9():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(3, 1, lambda_6F9)
    Sleep(1000)
    Return()
    SaveToFile()


Try(main)

from ED63RDScenarioHelper import *


def main():
    SetCodePage('ms932')
    CreateScenaFile(FileName='U4150   ._SN', MapName='Gaiden2', Location=
        'U4150.x', MapIndex=1, MapDefaultBGM='ed60221', Flags=0,
        EntryFunctionIndex=65535, Reserved=0, IncludedScenario=['', '', '',
        '', '', '', '', ''])
    BuildStringList('@FileName', '', '')
    DeclEntryPoint(Unknown_00=0, Unknown_04=0, Unknown_08=0, Unknown_0C=4,
        Unknown_0E=5, Unknown_10=0, Unknown_14=9500, Unknown_18=-10000,
        Unknown_1C=0, Unknown_20=0, Unknown_24=2500, Unknown_28=2800,
        Unknown_2C=262, Unknown_30=45, Unknown_32=0, Unknown_34=360,
        Unknown_36=0, Unknown_38=1, Unknown_3A=1, InitScenaIndex=0,
        InitFunctionIndex=0, EntryScenaIndex=0, EntryFunctionIndex=1)
    AddCharChip('ED6_DT29/CH14450 ._CH', 'ED6_DT29/CH14451 ._CH',
        'ED6_DT29/CH14730 ._CH', 'ED6_DT29/CH14730 ._CH',
        'ED6_DT29/CH14790 ._CH', 'ED6_DT29/CH14791 ._CH')
    AddCharChipPat('ED6_DT29/CH14450P._CP', 'ED6_DT29/CH14451P._CP',
        'ED6_DT29/CH14730P._CP', 'ED6_DT29/CH14730P._CP',
        'ED6_DT29/CH14790P._CP', 'ED6_DT29/CH14791P._CP')
    DeclMonster(X=-140, Z=0, Y=-21440, Unknown_0C=180, Unknown_0E=0,
        Unknown_10=65, Unknown_11=1, Unknown_12=4294967295, BattleIndex=215,
        Unknown_18=0, Unknown_1A=0)
    DeclMonster(X=140, Z=0, Y=-5820, Unknown_0C=180, Unknown_0E=2,
        Unknown_10=65, Unknown_11=1, Unknown_12=4294967295, BattleIndex=216,
        Unknown_18=0, Unknown_1A=0)
    DeclActor(TriggerX=8880, TriggerZ=0, TriggerY=-43040, TriggerRange=1000,
        ActorX=8880, ActorZ=2000, ActorY=-43040, Flags=124, TalkScenaIndex=
        0, TalkFunctionIndex=2, Unknown_22=0)
    ScpFunction('Function_0_136', 'Function_1_156', 'Function_2_18B',
        'Function_3_40D', 'Function_4_4EB', 'Function_5_5A7', 'Function_6_6BD')

    def Function_0_136():
        pass
    label('Function_0_136')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 66), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_EQU), scpexpr(EXPR_END)), 'loc_155')
    Switch((scpexpr(EXPR_PUSH_VALUE_INDEX, 0), scpexpr(EXPR_END)), (115,
        'loc_14E'), (SWITCH_DEFAULT, 'loc_155'))
    label('loc_14E')
    Event(0, 3)
    Jump('loc_155')
    label('loc_155')
    Return()

    def Function_1_156():
        pass
    label('Function_1_156')
    OP_16(2, 4000, 4294839296, 4294819296, 2293851)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 66), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_EQU), scpexpr(EXPR_END)), 'loc_179')
    OP_1B(15, 0, 4)
    label('loc_179')
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_18A')
    OP_82(129, 0)
    OP_82(130, 0)
    OP_82(132, 0)
    label('loc_18A')
    Return()

    def Function_2_18B():
        pass
    label('Function_2_18B')
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_25A')
    EventBegin(1)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Sleep(500)
    OP_22(353, 0, 100)
    Fade(1000)
    PlayEffect(129, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    PlayEffect(130, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    PlayEffect(132, 255, 65535, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 255, 0,
        0, 0, 0)
    OP_0D()
    OP_AA(768)
    Sleep(500)
    Jump('loc_25D')
    label('loc_25A')
    TalkBegin(255)
    label('loc_25D')
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 24), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 0), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    label('loc_299')
    Jc((scpexpr(EXPR_GET_RESULT, 0), scpexpr(EXPR_PUSH_LONG, 255), scpexpr(
        EXPR_NEQ), scpexpr(EXPR_END)), 'loc_3DC')
    Menu(1, -1, 150, 1, ('Restore HP/EP\x01', 'Shop\x01',
        'Synthesize Quartz\x01', 'End\x01'))
    MenuEnd(0)
    OP_5F(1)
    OP_56(0)
    Switch((scpexpr(EXPR_GET_RESULT, 0), scpexpr(EXPR_END)), (0, 'loc_2F5'),
        (1, 'loc_370'), (2, 'loc_39E'), (SWITCH_DEFAULT, 'loc_3CC'))
    label('loc_2F5')
    FadeToBright(300, 0)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Sleep(300)
    OP_20(1000)
    OP_22(12, 0, 100)
    FadeToDark(1000, 0, -1)
    OP_0D()
    OP_22(13, 0, 100)
    OP_C0(21, 0, 0, 0, 0, 0, 0, 0, 0)
    OP_30(1)
    Sleep(3500)
    OP_1D(221)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 24), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    FadeToBright(1000, 0)
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 255), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jump('loc_3D9')
    label('loc_370')
    OP_A9(22)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    Jump('loc_3D9')
    label('loc_39E')
    OP_A9(2)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)
    AnonymousTalk('\x07\x05Select an Option\x18\x02')
    Jump('loc_3D9')
    label('loc_3CC')
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 255), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jump('loc_3D9')
    label('loc_3D9')
    Jump('loc_299')
    label('loc_3DC')
    OP_5F(1)
    OP_56(0)
    FadeToBright(300, 0)
    Sleep(300)
    RunExpression(0, (scpexpr(EXPR_PUSH_LONG, 0), scpexpr(EXPR_STUB),
        scpexpr(EXPR_END)))
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(1200, 6)), scpexpr
        (EXPR_EQUZ), scpexpr(EXPR_END)), 'loc_409')
    OP_A2(9606)
    EventEnd(1)
    Jump('loc_40C')
    label('loc_409')
    TalkEnd(255)
    label('loc_40C')
    Return()

    def Function_3_40D():
        pass
    label('Function_3_40D')
    OP_DE(0, 15, 1)
    EventBegin(2)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    SetChrPos(0, 120, 0, -53710, 0)
    SetChrPos(1, 900, 0, -54640, 0)
    SetChrPos(2, -890, 0, -54580, 0)
    SetChrPos(3, -120, 0, -55500, 0)
    OP_69(0, 0)
    LoadEffect(0, 'map\\mp204_02.eff')
    PlayEffect(0, 255, 255, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 255, 
        0, 0, 0, 0)
    OP_22(153, 0, 100)
    OP_22(184, 0, 100)
    Call(0, 5)
    EventEnd(0)
    OP_4F(49, (scpexpr(EXPR_PUSH_LONG, 170), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    OP_C0(22, 0, 0, 0, 0, 0, 0, 0, 0)
    Return()

    def Function_4_4EB():
        pass
    label('Function_4_4EB')
    EventBegin(1)
    OP_4F(40, (scpexpr(EXPR_PUSH_LONG, 65535), scpexpr(EXPR_STUB), scpexpr(
        EXPR_END)))
    Fade(500)
    SetChrPos(3, 120, 0, -53710, 180)
    SetChrPos(2, 900, 0, -54640, 180)
    SetChrPos(1, -890, 0, -54580, 180)
    SetChrPos(0, -120, 0, -55500, 180)
    OP_69(0, 0)
    OP_0D()
    LoadEffect(0, 'map\\mp204_01.eff')
    PlayEffect(0, 255, 255, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 255, 
        0, 0, 0, 0)
    OP_22(153, 0, 100)
    OP_22(184, 0, 100)
    Call(0, 6)
    NewScene('ED6_DT21/M7005   ._SN', 102, 0, 0)
    IdleLoop()
    Return()

    def Function_5_5A7():
        pass
    label('Function_5_5A7')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 10), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_5D0')
    OP_9F(0, 255, 255, 255, 0, 0)

    def lambda_5C4():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(0, 1, lambda_5C4)
    label('loc_5D0')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 11), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_5F9')
    OP_9F(1, 255, 255, 255, 0, 0)

    def lambda_5ED():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(1, 1, lambda_5ED)
    label('loc_5F9')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 12), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_622')
    OP_9F(2, 255, 255, 255, 0, 0)

    def lambda_616():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(2, 1, lambda_616)
    label('loc_622')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 13), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_64B')
    OP_9F(3, 255, 255, 255, 0, 0)

    def lambda_63F():
        OP_9F(254, 255, 255, 255, 255, 800)
        ExitThread()
    QueueWorkItem(3, 1, lambda_63F)
    label('loc_64B')
    Sleep(800)
    OP_44(0, 1)
    OP_44(1, 1)
    OP_44(2, 1)
    OP_44(3, 1)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 10), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_677')
    OP_9F(0, 255, 255, 255, 255, 0)
    label('loc_677')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 11), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_68E')
    OP_9F(1, 255, 255, 255, 255, 0)
    label('loc_68E')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 12), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_6A5')
    OP_9F(2, 255, 255, 255, 255, 0)
    label('loc_6A5')
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 13), scpexpr(EXPR_PUSH_LONG, 255),
        scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), 'loc_6BC')
    OP_9F(3, 255, 255, 255, 255, 0)
    label('loc_6BC')
    Return()

    def Function_6_6BD():
        pass
    label('Function_6_6BD')

    def lambda_6C3():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(0, 1, lambda_6C3)

    def lambda_6D5():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(1, 1, lambda_6D5)

    def lambda_6E7():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(2, 1, lambda_6E7)

    def lambda_6F9():
        OP_9F(254, 255, 255, 255, 0, 800)
        ExitThread()
    QueueWorkItem(3, 1, lambda_6F9)
    Sleep(1000)
    Return()
    SaveToFile()


Try(main)

from ED63RDScenarioHelper import *

def main():
    SetCodePage("ms932")

    CreateScenaFile(
        FileName            = 'U4150   ._SN',
        MapName             = 'Gaiden2',
        Location            = 'U4150.x',
        MapIndex            = 1,
        MapDefaultBGM       = "ed60221",
        Flags               = 0,
        EntryFunctionIndex  = 0xFFFF,
        Reserved            = 0,
        IncludedScenario    = [
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            ''
        ],
    )

    BuildStringList(
        '@FileName',                            # 8
        '',                                     # 9
        '',                                     # 10
    )

    DeclEntryPoint(
        Unknown_00              = 0,
        Unknown_04              = 0,
        Unknown_08              = 0,
        Unknown_0C              = 4,
        Unknown_0E              = 5,
        Unknown_10              = 0,
        Unknown_14              = 9500,
        Unknown_18              = -10000,
        Unknown_1C              = 0,
        Unknown_20              = 0,
        Unknown_24              = 2500,
        Unknown_28              = 2800,
        Unknown_2C              = 262,
        Unknown_30              = 45,
        Unknown_32              = 0,
        Unknown_34              = 360,
        Unknown_36              = 0,
        Unknown_38              = 1,
        Unknown_3A              = 1,
        InitScenaIndex          = 0,
        InitFunctionIndex       = 0,
        EntryScenaIndex         = 0,
        EntryFunctionIndex      = 1,
    )


    AddCharChip(
        'ED6_DT29/CH14450 ._CH',             # 00
        'ED6_DT29/CH14451 ._CH',             # 01
        'ED6_DT29/CH14730 ._CH',             # 02
        'ED6_DT29/CH14730 ._CH',             # 03
        'ED6_DT29/CH14790 ._CH',             # 04
        'ED6_DT29/CH14791 ._CH',             # 05
    )

    AddCharChipPat(
        'ED6_DT29/CH14450P._CP',             # 00
        'ED6_DT29/CH14451P._CP',             # 01
        'ED6_DT29/CH14730P._CP',             # 02
        'ED6_DT29/CH14730P._CP',             # 03
        'ED6_DT29/CH14790P._CP',             # 04
        'ED6_DT29/CH14791P._CP',             # 05
    )

    DeclMonster(
        X                   = -140,
        Z                   = 0,
        Y                   = -21440,
        Unknown_0C          = 180,
        Unknown_0E          = 0,
        Unknown_10          = 65,
        Unknown_11          = 1,
        Unknown_12          = 0xFFFFFFFF,
        BattleIndex         = 0xD7,
        Unknown_18          = 0,
        Unknown_1A          = 0,
    )

    DeclMonster(
        X                   = 140,
        Z                   = 0,
        Y                   = -5820,
        Unknown_0C          = 180,
        Unknown_0E          = 2,
        Unknown_10          = 65,
        Unknown_11          = 1,
        Unknown_12          = 0xFFFFFFFF,
        BattleIndex         = 0xD8,
        Unknown_18          = 0,
        Unknown_1A          = 0,
    )


    DeclActor(
        TriggerX            = 8880,
        TriggerZ            = 0,
        TriggerY            = -43040,
        TriggerRange        = 1000,
        ActorX              = 8880,
        ActorZ              = 2000,
        ActorY              = -43040,
        Flags               = 0x7C,
        TalkScenaIndex      = 0,
        TalkFunctionIndex   = 2,
        Unknown_22          = 0,
    )


    ScpFunction(
        "Function_0_136",          # 00, 0
        "Function_1_156",          # 01, 1
        "Function_2_18B",          # 02, 2
        "Function_3_40D",          # 03, 3
        "Function_4_4EB",          # 04, 4
        "Function_5_5A7",          # 05, 5
        "Function_6_6BD",          # 06, 6
    )


    def Function_0_136(): pass

    label("Function_0_136")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0x42), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_EQU), scpexpr(EXPR_END)), "loc_155")
    Switch(
        (scpexpr(EXPR_PUSH_VALUE_INDEX, 0x0), scpexpr(EXPR_END)),
        (115, "loc_14E"),
        (SWITCH_DEFAULT, "loc_155"),
    )


    label("loc_14E")

    Event(0, 3)
    Jump("loc_155")

    label("loc_155")

    Return()

    # Function_0_136 end

    def Function_1_156(): pass

    label("Function_1_156")

    OP_16(0x2, 0xFA0, 0xFFFE0C00, 0xFFFDBDE0, 0x23005B)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0x42), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_EQU), scpexpr(EXPR_END)), "loc_179")
    OP_1B(0xF, 0x0, 0x4)

    label("loc_179")

    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(0x4B0, 6)), scpexpr(EXPR_EQUZ), scpexpr(EXPR_END)), "loc_18A")
    OP_82(0x81, 0x0)
    OP_82(0x82, 0x0)
    OP_82(0x84, 0x0)

    label("loc_18A")

    Return()

    # Function_1_156 end

    def Function_2_18B(): pass

    label("Function_2_18B")

    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(0x4B0, 6)), scpexpr(EXPR_EQUZ), scpexpr(EXPR_END)), "loc_25A")
    EventBegin(0x1)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Sleep(500)
    OP_22(0x161, 0x0, 0x64)
    Fade(1000)
    PlayEffect(0x81, 0xFF, 0xFFFF, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    PlayEffect(0x82, 0xFF, 0xFFFF, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    PlayEffect(0x84, 0xFF, 0xFFFF, 0, 0, 0, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    OP_0D()
    OP_AA(768)
    Sleep(500)
    Jump("loc_25D")

    label("loc_25A")

    TalkBegin(0xFF)

    label("loc_25D")

    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)

    AnonymousTalk(    #0
        "\x07\x05Select an Option\x18\x02",
    )

    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0x18), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0x0), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))

    label("loc_299")

    Jc((scpexpr(EXPR_GET_RESULT, 0x0), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_3DC")

    Menu(
        1,
        -1,
        150,
        1,
        (
            "Restore HP/EP\x01",          # 0
            "Shop\x01",                   # 1
            "Synthesize Quartz\x01",      # 2
            "End\x01",                    # 3
        )
    )

    MenuEnd(0x0)
    OP_5F(0x1)
    OP_56(0x0)
    Switch(
        (scpexpr(EXPR_GET_RESULT, 0x0), scpexpr(EXPR_END)),
        (0, "loc_2F5"),
        (1, "loc_370"),
        (2, "loc_39E"),
        (SWITCH_DEFAULT, "loc_3CC"),
    )


    label("loc_2F5")

    FadeToBright(300, 0)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Sleep(300)
    OP_20(0x3E8)
    OP_22(0xC, 0x0, 0x64)
    FadeToDark(1000, 0, -1)
    OP_0D()
    OP_22(0xD, 0x0, 0x64)
    OP_C0(0x15, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    OP_30(0x1)
    Sleep(3500)
    OP_1D(0xDD)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0x18), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    FadeToBright(1000, 0)
    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Jump("loc_3D9")

    label("loc_370")

    OP_A9(0x16)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)

    AnonymousTalk(    #1
        "\x07\x05Select an Option\x18\x02",
    )

    Jump("loc_3D9")

    label("loc_39E")

    OP_A9(0x2)
    FadeToDark(300, 0, 100)
    SetMessageWindowPos(-1, 60, -1, -1)

    AnonymousTalk(    #2
        "\x07\x05Select an Option\x18\x02",
    )

    Jump("loc_3D9")

    label("loc_3CC")

    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Jump("loc_3D9")

    label("loc_3D9")

    Jump("loc_299")

    label("loc_3DC")

    OP_5F(0x1)
    OP_56(0x0)
    FadeToBright(300, 0)
    Sleep(300)
    RunExpression(0x0, (scpexpr(EXPR_PUSH_LONG, 0x0), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Jc((scpexpr(EXPR_TEST_SCENA_FLAGS, MakeScenarioFlags(0x4B0, 6)), scpexpr(EXPR_EQUZ), scpexpr(EXPR_END)), "loc_409")
    OP_A2(0x2586)
    EventEnd(0x1)
    Jump("loc_40C")

    label("loc_409")

    TalkEnd(0xFF)

    label("loc_40C")

    Return()

    # Function_2_18B end

    def Function_3_40D(): pass

    label("Function_3_40D")

    OP_DE(0x0, 0xF, 0x1)
    EventBegin(0x2)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    SetChrPos(0x0, 120, 0, -53710, 0)
    SetChrPos(0x1, 900, 0, -54640, 0)
    SetChrPos(0x2, -890, 0, -54580, 0)
    SetChrPos(0x3, -120, 0, -55500, 0)
    OP_69(0x0, 0x0)
    LoadEffect(0x0, "map\\mp204_02.eff")
    PlayEffect(0x0, 0xFF, 0xFF, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    OP_22(0x99, 0x0, 0x64)
    OP_22(0xB8, 0x0, 0x64)
    Call(0, 5)
    EventEnd(0x0)
    OP_4F(0x31, (scpexpr(EXPR_PUSH_LONG, 0xAA), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    OP_C0(0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    Return()

    # Function_3_40D end

    def Function_4_4EB(): pass

    label("Function_4_4EB")

    EventBegin(0x1)
    OP_4F(0x28, (scpexpr(EXPR_PUSH_LONG, 0xFFFF), scpexpr(EXPR_STUB), scpexpr(EXPR_END)))
    Fade(500)
    SetChrPos(0x3, 120, 0, -53710, 180)
    SetChrPos(0x2, 900, 0, -54640, 180)
    SetChrPos(0x1, -890, 0, -54580, 180)
    SetChrPos(0x0, -120, 0, -55500, 180)
    OP_69(0x0, 0x0)
    OP_0D()
    LoadEffect(0x0, "map\\mp204_01.eff")
    PlayEffect(0x0, 0xFF, 0xFF, 50, 0, -54570, 0, 0, 0, 1000, 1000, 1000, 0xFF, 0, 0, 0, 0)
    OP_22(0x99, 0x0, 0x64)
    OP_22(0xB8, 0x0, 0x64)
    Call(0, 6)
    NewScene("ED6_DT21/M7005   ._SN", 102, 0, 0)
    IdleLoop()
    Return()

    # Function_4_4EB end

    def Function_5_5A7(): pass

    label("Function_5_5A7")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xA), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_5D0")
    OP_9F(0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_5C4():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x0, 1, lambda_5C4)

    label("loc_5D0")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xB), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_5F9")
    OP_9F(0x1, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_5ED():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x1, 1, lambda_5ED)

    label("loc_5F9")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xC), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_622")
    OP_9F(0x2, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_616():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x2, 1, lambda_616)

    label("loc_622")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xD), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_64B")
    OP_9F(0x3, 0xFF, 0xFF, 0xFF, 0x0, 0x0)

    def lambda_63F():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x320)
        ExitThread()

    QueueWorkItem(0x3, 1, lambda_63F)

    label("loc_64B")

    Sleep(800)
    OP_44(0x0, 0x1)
    OP_44(0x1, 0x1)
    OP_44(0x2, 0x1)
    OP_44(0x3, 0x1)
    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xA), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_677")
    OP_9F(0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_677")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xB), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_68E")
    OP_9F(0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_68E")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xC), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_6A5")
    OP_9F(0x2, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_6A5")

    Jc((scpexpr(EXPR_PUSH_VALUE_INDEX, 0xD), scpexpr(EXPR_PUSH_LONG, 0xFF), scpexpr(EXPR_NEQ), scpexpr(EXPR_END)), "loc_6BC")
    OP_9F(0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x0)

    label("loc_6BC")

    Return()

    # Function_5_5A7 end

    def Function_6_6BD(): pass

    label("Function_6_6BD")


    def lambda_6C3():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x0, 1, lambda_6C3)

    def lambda_6D5():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x1, 1, lambda_6D5)

    def lambda_6E7():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x2, 1, lambda_6E7)

    def lambda_6F9():
        OP_9F(0xFE, 0xFF, 0xFF, 0xFF, 0x0, 0x320)
        ExitThread()

    QueueWorkItem(0x3, 1, lambda_6F9)
    Sleep(1000)
    Return()

    # Function_6_6BD end

    SaveToFile()

Try(main)
