const rom = @import("../rom.zig");
const script = @import("../script.zig");
const std = @import("std");

const builtin = std.builtin;
const mem = std.mem;

const li32 = rom.int.li32;
const lu16 = rom.int.lu16;
const lu32 = rom.int.lu32;

pub fn getScriptOffsets(data: []const u8) []align(1) const li32 {
    var len: usize = 0;
    while (true) : (len += 1) {
        const rest = data[len * 4 ..];
        if (rest.len < 4 or (rest[0] == 0x13 and rest[1] == 0xFD))
            break;
    }
    return mem.bytesAsSlice(li32, data[0 .. len * 4]);
}

pub const CommandDecoder = script.CommandDecoder(Command, struct {
    fn isEnd(cmd: Command) bool {
        switch (cmd.kind) {
            .end,
            .jump,
            .end_function,
            => return true,
            else => return false,
        }
    }
}.isEnd);

pub fn expectNext(decoder: *CommandDecoder, kind: Command.Kind) ?*align(1) Command {
    const command = (decoder.next() catch return null) orelse return null;
    if (command.kind != kind)
        return null;
    return command;
}

// https://pastebin.com/QPrYmFwY
pub const Command = extern union {
    kind: Kind,
    nop1: Arg0,
    nop2: Arg0,
    end: Arg0,
    return_after_delay: Arg1(lu16),
    call_routine: CallRoutine,
    end_function: Arg1(lu16),
    logic06: Arg1(lu16),
    logic07: Arg1(lu16),
    compare_to: Value,
    store_var: Var,
    clear_var: Var,
    unknown_0B: Value,
    unknown_0C: Value,
    unknown_0D: Value,
    unknown_0E: Value,
    unknown_0F: Value,
    store_flag: Value,
    condition: Condition,
    unknown_12: Value,
    unknown_13: Arg2(lu16, lu16),
    unknown_14: Value,
    unknown_16: Value,
    unknown_17: Value,
    compare: Value2,
    add_script_vm: Arg1(lu16),
    call_std: CallStd,
    return_std: Arg0,
    jump: Jump,
    when: If,
    @"if": If,
    unknown_21: Value,
    unknown_22: Value,
    set_flag: Value,
    clear_flag: ClearFlag,
    set_var_flag_status: SetVarFlagStatus,
    set_var_26: Value2,
    set_var_27: Value2,
    set_var_eq_val: SetVarContainer,
    set_var_29: SetVarContainer,
    set_var_2a: SetVarContainer,
    set_var_2b: Value,
    dir_vars: Arg2(lu16, lu16),
    unknown_2D: Value,
    lock_all: Arg0,
    unlock_all: Arg0,
    wait_moment: Arg0,
    wait_a_press: Arg0,
    wait_button: Arg0,
    musical_message: MusicalMessage,
    event_grey_message: EventGreyMessage,
    close_musical_message: Arg0,
    closed_event_grey_message: Arg0,
    unknown_37: Arg1(lu16),
    bubble_message: BubbleMessage,
    close_bubble_message: Arg0,
    show_message_at: ShowMessageAt,
    close_show_message_at: Arg0,
    message: Message,
    message2: Message,
    close_message_k_p: Arg0,
    close_message_k_p2: Arg0,
    money_box: Coord,
    close_money_box: Arg0,
    update_money_box: Arg0,
    bordered_message: BorderedMessage,
    close_bordered_message: Arg0,
    paper_message: PaperMessage,
    close_paper_message: Arg0,
    yes_no: YesNo,
    message3: Message3,
    double_message: DoubleMessage,
    angry_message: AngryMessage,
    close_angry_message: Arg0,
    set_var_hero: Arg1(u8),
    set_var_item: ArgValue(u8, lu16),
    unknown_4E: Arg4(u8, lu16, lu16, u8),
    set_var_item2: ArgValue(u8, lu16),
    set_var_item3: ArgValue(u8, lu16),
    set_var_move: ArgValue(u8, lu16),
    set_var_bag: ArgValue(u8, lu16),
    set_var_party_poke: ArgValue(u8, lu16),
    set_var_party_poke2: ArgValue(u8, lu16),
    set_var_unknown: ArgValue(u8, lu16),
    set_var_type: ArgValue(u8, lu16),
    set_var_poke: ArgValue(u8, lu16),
    set_var_poke2: ArgValue(u8, lu16),
    set_var_location: ArgValue(u8, lu16),
    set_var_poke_nick: ArgValue(u8, lu16),
    set_var_unknown2: ArgValue(u8, lu16),
    set_var_store_value5_c: SetVarStoreValue5C,
    set_var_musical_info: ArgValue(lu16, lu16),
    set_var_nations: ArgValue(u8, lu16),
    set_var_activities: ArgValue(u8, lu16),
    set_var_power: ArgValue(u8, lu16),
    set_var_trainer_type: ArgValue(u8, lu16),
    set_var_trainer_type2: ArgValue(u8, lu16),
    set_var_general_word: ArgValue(u8, lu16),
    apply_movement: ApplyMovement,
    wait_movement: Arg0,
    store_hero_position: Coord,
    unknown_67: Arg2(lu16, lu16),
    store_hero_position2: Coord,
    store_npc_position: StoreNPCPosition,
    unknown_6A: Unknown_6A,
    add_npc: NPC,
    remove_npc: NPC,
    set_o_w_position: SetOWPosition,
    unknown_6E: Arg1(lu16),
    unknown_6F: Arg1(lu16),
    unknown_70: Unknown_70,
    unknown_71: Arg3(lu16, lu16, lu16),
    unknown_72: Arg4(lu16, lu16, lu16, lu16),
    unknown_73: Arg2(lu16, lu16),
    face_player: Arg0,
    release: NPC,
    release_all: Arg0,
    lock_77: NPC,
    unknown_78: Var,
    unknown_79: Unknown_79,
    move_npc_to: MoveNPCTo,
    unknown_7C: Arg4(lu16, lu16, lu16, lu16),
    unknown_7D: Arg4(lu16, lu16, lu16, lu16),
    teleport_up_npc: TeleportUpNPC,
    unknown_7F: Arg2(lu16, lu16),
    unknown_80: Arg1(lu16),
    unknown_81: Arg0,
    unknown_82: Arg2(lu16, lu16),
    set_var83: Value,
    set_var84: Value,
    single_trainer_battle: SingleTrainerBattle,
    double_trainer_battle: DoubleTrainerBattle,
    unknown_87: Arg3(lu16, lu16, lu16),
    unknown_88: Arg3(lu16, lu16, lu16),
    unknown_8A: Arg2(lu16, lu16),
    play_trainer_music: PlayTrainerMusic,
    end_battle: Arg0,
    store_battle_result: StoreBattleResult,
    unknown_179: Arg0,
    unknown_17A: Arg0,
    unknown_17B: Arg1(lu16),
    unknown_17C: Arg1(lu16),
    unknown_185: Arg1(lu16),
    drift_gym_lift_anm_second_room: Arg1(lu16),
    unknown_191: Arg1(lu16),
    unknown_193: Arg1(lu16),
    unknown_194: Arg1(lu16),
    drift_gym_lift_anm_first_room: Arg1(lu16),
    unknown_196: Arg0,
    unknown_197: Arg2(lu16, lu16),
    unknown_198: Arg1(lu16),
    unknown_199: Arg1(lu16),
    unknown_19A: Arg2(lu16, lu16),
    set_status_cg: Arg1(lu16),
    unknown_19C: Arg1(lu16),
    unknown_19D: Arg0,
    show_cg: Arg1(lu16),
    call_screen_animation: Arg1(lu16),
    open_xtransciever: Arg1(lu16),
    disable_trainer: Arg0,
    d_var90: Arg2(lu16, lu16),
    d_var92: Arg2(lu16, lu16),
    d_var93: Arg2(lu16, lu16),
    trainer_battle: TrainerBattle,
    deactivate_trainer_i_d: DeactivateTrainerID,
    unknown_96: Unknown_96,
    store_active_trainer_i_d: StoreActiveTrainerID,
    change_music: ChangeMusic,
    fade_to_default_music: Arg0,
    unknown_9F: Arg0,
    stop_music: Arg1(lu16),
    unknown_A2: Unknown_A2,
    unknown_A3: Arg1(lu16),
    unknown_A4: Arg1(lu16),
    unknown_A5: Arg2(lu16, lu16),
    play_sound: PlaySound,
    wait_sound_a7: Arg0,
    wait_sound: Arg0,
    play_fanfare: PlayFanfare,
    wait_fanfare: Arg0,
    play_cry: PlayCry,
    wait_cry: Arg0,
    set_text_script_message: SetTextScriptMessage,
    close_multi: Arg0,
    unknown_B1: Arg0,
    multi2: Multi2,
    fade_screen: Arg4(lu16, lu16, lu16, lu16),
    reset_screen: Arg3(lu16, lu16, lu16),
    screen_b5: Arg3(lu16, lu16, lu16),
    take_item: TakeItem,
    check_item_bag_space: CheckItemBagSpace,
    check_item_bag_number: CheckItemBagNumber,
    store_item_count: StoreItemCount,
    unknown_BA: Arg4(lu16, lu16, lu16, lu16),
    unknown_BB: Arg2(lu16, lu16),
    unknown_BC: Arg1(lu16),
    unknown_BD: Arg2(lu16, lu16),
    warp: Warp,
    teleport_warp: TeleportWarp,
    fall_warp: FallWarp,
    fast_warp: FastWarp,
    union_warp: Arg0,
    teleport_warp2: TeleportWarp2,
    surf_animation: Arg0,
    special_animation: Arg1(lu16),
    special_animation2: Arg2(lu16, lu16),
    call_animation: Arg2(lu16, lu16),
    store_random_number: Arg2(lu16, lu16),
    store_var_item: Arg1(lu16),
    store_var_cd: Arg1(lu16),
    store_var_ce: Arg1(lu16),
    store_var_cf: Arg1(lu16),
    store_date: StoreDate,
    store_d1: Arg2(lu16, lu16),
    store_d2: Arg1(lu16),
    store_d3: Arg1(lu16),
    store_birth_day: StoreBirthDay,
    store_badge: StoreBadge,
    set_badge: Badge,
    store_badge_number: Badge,
    check_change_map_event: Arg2(lu16, lu16),
    unknown_D9: Arg1(lu16),
    unknown_DA: Arg3(lu16, lu16, lu16),
    unknown_DC: Arg4(lu16, lu16, lu16, lu16),
    store_pokemon_caught: Arg2(lu16, lu16),
    show_pokemon_species: Arg2(lu16, lu16),
    check_pokemon_seen: Arg3(lu16, lu16, lu16),
    store_version: Arg1(lu16),
    store_gender: Arg1(lu16),
    activate_key_item: Arg1(lu16),
    unknown_E9: Arg1(lu16),
    give_poke_day_care: Arg1(lu16),
    unknown_F9: Arg1(lu16),
    take_money: TakeMoney,
    check_money: CheckMoney,
    store_pokemon_happiness: Arg2(lu16, lu16),
    inc_pokemon_happiness: Arg3(lu16, lu16, lu16),
    store_party_species: Arg2(lu16, lu16),
    store_pokemon_form_number: Arg2(lu16, lu16),
    check_pokerus: Arg1(lu16),
    unknown_101: Arg2(lu16, lu16),
    check_egg: Arg2(lu16, lu16),
    store_party_number_minimum: StorePartyNumberMinimum,
    heal_pokemon: Arg0,
    rename_pokemon: Arg3(lu16, lu16, lu16),
    store_chosen_pokemon: Arg3(lu16, lu16, lu16),
    give_pokemon_1: GivePokemon1,
    give_pokemon_2: GivePokemon2,
    store_pokemon_party_at: Arg2(lu16, lu16),
    give_pokemon_3: GivePokemon3,
    store_pokemon_sex: Arg3(lu16, lu16, lu16),
    check_pokemon_nickname: Arg2(lu16, lu16),
    store_party_have_pokemon: Arg2(lu16, lu16),
    store_party_can_learn_move: Arg3(lu16, lu16, lu16),
    store_party_can_use_move: Arg2(lu16, lu16),
    store_pokemon_form: Arg2(lu16, lu16),
    check_chosen_species: Arg3(lu16, lu16, lu16),
    unknown_11A: Arg4(lu16, lu16, lu16, lu16),
    store_party_type: Arg3(lu16, lu16, lu16),
    forgot_move: Arg3(lu16, lu16, lu16),
    set_favorite: Arg1(lu16),
    badge_animation: Arg1(lu16),
    set_var_pokemon_trade: Arg2(lu16, lu16),
    check_party_amount: Arg2(lu16, lu16),
    unknown_122: Arg0,
    unknown_125: Arg4(lu16, lu16, lu16, lu16),
    unknown_127: Arg4(lu16, lu16, lu16, lu16),
    unknown_128: Arg1(lu16),
    unknown_129: Arg2(lu16, lu16),
    unknown_12A: Arg1(lu16),
    unknown_12B: Arg3(lu16, lu16, lu16),
    unknown_12C: Arg1(lu16),
    unknown_12D: Arg4(lu16, lu16, lu16, lu16),
    unknown_12E: Arg3(lu16, lu16, lu16),
    unknown_12F: Arg1(lu16),
    unknown_134: Arg0,
    unknown_135: Arg0,
    unknown_136: Arg1(lu16),
    show_clock_saving: Arg1(lu16),
    store_save_data: Arg3(lu16, lu16, lu16),
    store_comunication_status: Arg1(lu16),
    unknown_13C: Arg0,
    unknown_13D: Arg0,
    unknown_13E: Arg0,
    unknown_13F: Arg0,
    stop_camera_event: Arg0,
    lock_camera: Arg0,
    move_camera: MoveCamera,
    unknown_144: Arg1(lu16),
    unknown_146: Arg0,
    bumping_camera: Arg8(lu16, lu16, lu16, lu16, lu16, lu16, lu16, lu16),
    choose_interesting_item: Arg3(lu16, lu16, lu16),
    end_camera_event: Arg0,
    unknown_152: Arg0,
    unknown_158: Arg2(lu16, lu16),
    unknown_159: Arg0,
    unknown_15A: Arg4(lu16, lu16, lu16, lu16),
    unknown_15B: Arg1(lu16),
    unknown_15C: Arg0,
    unknown_15D: Arg1(lu16),
    unknown_15E: Arg1(lu16),
    start_pokemon_musical: Arg2(u8, lu16),
    start_dress_pokemon_musical: Arg1(lu16),
    check_pokemon_musical_functions: Arg3(u8, lu16, lu16),
    store_status_pokemon_musical: Arg3(u8, lu16, lu16),
    pokemon_menu_musical_functions: Arg4(lu16, lu16, lu16, lu16),
    choose_pokemon_musical: Arg2(lu16, lu16),
    unknown_16F: Arg0,
    unknown_170: Arg1(lu16),
    unknown_171: Arg0,
    unknown_175: Arg1(lu16),
    unknown_17D: Arg0,
    unknown_17E: Arg0,
    unknown_17F: Arg2(lu16, lu16),
    nimbasa_gym_rail_animation: Arg1(lu16),
    unknown_181: Arg1(lu16),
    unknown_182: Arg1(lu16),
    unknown_186: Arg1(lu16),
    unknown_187: Arg1(lu16),
    unknown_188: Arg1(lu16),
    unknown_189: Arg1(lu16),
    unknown_18A: Arg1(lu16),
    unknown_18B: Arg1(lu16),
    unknown_18C: Arg1(lu16),
    unknown_18D: Arg1(lu16),
    unknown_18E: Arg1(lu16),
    unknown_18F: Arg8(lu16, lu16, lu16, lu16, lu16, lu16, lu16, lu16),
    end_event_bc: Arg0,
    store_trainer_id: Arg2(lu16, lu16),
    unknown_1C7: Arg0,
    store_var_message: Arg2(lu16, lu16),
    check_pokedex_status: Arg2(lu16, lu16),
    boot_p_c_sound: Arg0,
    check_wireless: Arg1(lu16),
    release_camera: Arg0,
    reset_camera: ResetCamera,
    call_end: Arg0,
    call_start: Arg0,
    unknown_150: Arg1(lu16),
    show_diploma: Arg2(lu16, lu16),
    liberty_ship_anm: Arg2(lu16, lu16),
    open_interpoke: Arg2(lu16, lu16),
    wild_battle: WildBattle,
    wild_battle_store_result: WildBattleStoreResult,
    screen_function: Arg0,
    unknown_1A2: Arg0,
    flash_black_instant: Arg0,
    unknown_1A4: Arg1(lu16),
    unknown_1A5: Arg0,
    unknown_1A6: Arg2(lu16, lu16),
    unknown_1A7: Arg2(lu16, lu16),
    unknown_1A8: Arg0,
    unknown_1A9: Arg4(lu16, lu16, lu16, lu16),
    unknown_1AA: Arg4(lu16, lu16, lu16, lu16),
    fade_from_black: Arg0,
    fade_into_black: Arg0,
    fade_from_white: Arg0,
    fade_into_white: Arg0,
    unknown_1AF: Arg0,
    unknown_1B2: Arg0,
    unknown_1B4: Arg0,
    unknown_1B5: Arg0,
    unknown_1B6: Arg0,
    unknown_1B7: Arg1(lu16),
    unknown_1B8: Arg1(lu16),
    unknown_1BB: Arg0,
    unknown_1BC: Arg1(lu16),
    unknown_1BD: Arg2(lu16, lu16),
    unknown_1C2: Arg2(lu16, lu16),
    unknown_1C8: Arg0,
    unknown_1D0: Arg0,
    unknown_1D1: Arg1(lu16),
    unknown_1D2: Arg0,
    unknown_1D3: Arg3(lu16, lu16, lu16),
    unknown_1D4: Arg0,
    unknown_1D5: Arg0,
    affinity_check: Arg1(lu16),
    set_var_affinity_check: Arg1(lu16),
    unknown_1D8: Arg2(lu16, lu16),
    unknown_1DA: Arg2(lu16, lu16),
    unknown_1DB: Arg1(lu16),
    unknown_1DD: Arg2(lu16, lu16),
    store_data_unity: Arg2(lu16, lu16),
    unknown_1E0: Arg4(lu16, lu16, lu16, lu16),
    store_trainer_unity: Arg1(lu16),
    unknown_1E2: Arg1(lu16),
    store_unity_activities: Arg1(lu16),
    unknown_1EA: Arg4(lu16, lu16, lu16, lu16),
    unknown_1EB: Arg4(lu16, lu16, lu16, lu16),
    trade_pokemon: Arg2(lu16, lu16),
    compare_chosen_pokemon: Arg3(lu16, lu16, lu16),
    switch_ow_position: SwitchOwPosition,
    double_phrase_box_input: Arg4(lu16, lu16, lu16, lu16),
    hm_effect: Arg2(lu16, lu16),
    create_stadium_trainer: Arg4(lu16, lu16, lu16, lu16),
    start_stadium_function: Arg0,
    end_stadium_function: Arg0,
    create_stadium_overworld: Arg3(lu16, lu16, lu16),
    unknown_1F7: Arg6(lu16, lu16, lu16, lu16, lu16, lu16),
    set_stadium_busy: Arg0,
    dream_world_function: Arg4(lu16, lu16, lu16, lu16),
    dream_world_function2: Arg4(lu16, lu16, lu16, lu16),
    show_dream_world_furniture: Arg2(lu16, lu16),
    unknown_20D: Arg4(lu16, lu16, lu16, lu16),
    check_item_interesting_bag: Arg2(lu16, lu16),
    unknown_211: Arg0,
    store_survey_active: Arg1(lu16),
    unknown_210: Arg4(lu16, lu16, lu16, lu16),
    unknown_213: Arg3(lu16, lu16, lu16),
    unknown_214: Arg2(lu16, lu16),
    unknown_215: Arg2(lu16, lu16),
    unknown_216: Arg1(lu16),
    store_greeting: Arg1(lu16),
    store_thanks: Arg1(lu16),
    unknown_21C: Arg2(lu16, lu16),
    unknown_21D: Arg0,
    store_survey_done: Arg1(lu16),
    unknown_21F: Arg0,
    check_have_pokemon: Arg4(lu16, lu16, lu16, lu16),
    unknown_221: Arg6(lu16, lu16, lu16, lu16, lu16, lu16),
    unknown_222: Arg4(lu16, lu16, lu16, lu16),
    unknown_224: Arg1(lu16),
    unknown_225: Arg3(lu16, lu16, lu16),
    unknown_226: Arg1(lu16),
    unknown_227: Arg2(lu16, lu16),
    unknown_228: Arg2(lu16, lu16),
    unknown_229: Arg2(lu16, lu16),
    store_fish_pokemon: Arg1(lu16),
    unknown_236: Arg4(lu16, lu16, lu16, lu16),
    unknown_23C: Arg0,
    unknown_238: Arg1(lu16),
    unknown_23A: Arg2(lu16, lu16),
    unknown_23E: Arg4(lu16, lu16, lu16, lu16),
    unknown_23F: Arg0,
    check_send_save_cg: Arg2(lu16, lu16),
    unknown_240: Arg1(lu16),
    unknown_241: Arg0,
    unknown_242: Arg2(lu16, lu16),
    special_message: Arg2(lu16, lu16),
    unknown_246: Arg1(lu16),
    wrap: Arg5(lu16, lu16, lu16, lu16, lu16),
    unknown_248: Arg2(lu16, lu16),
    unknown_24B: Arg1(lu16),
    unknown_24C: Arg1(lu16),
    unknown_24E: Arg0,
    lock_24f: Arg0,
    unknown_250: Arg0,
    show_map_name: Arg0,
    change_music_volume: Arg2(lu16, lu16),
    unknown_254: Arg1(lu16),
    unknown_255: Arg1(lu16),
    unknown_259: Arg0,
    check_cgear_active: Arg1(lu16),
    unknown_25B: Arg1(lu16),
    unknown_25C: Arg6(lu16, lu16, lu16, lu16, lu16, lu16),
    unknown_25E: Arg0,
    unknown_260: Arg0,
    play_theatral_music: Arg0,
    give_pokemon_4: GivePokemon4,

    pub const Kind = enum(u16) {
        nop1 = @intFromEnum(lu16.init(0x00)),
        nop2 = @intFromEnum(lu16.init(0x01)),
        end = @intFromEnum(lu16.init(0x02)),
        return_after_delay = @intFromEnum(lu16.init(0x03)),
        call_routine = @intFromEnum(lu16.init(0x04)),
        end_function = @intFromEnum(lu16.init(0x05)),
        logic06 = @intFromEnum(lu16.init(0x06)),
        logic07 = @intFromEnum(lu16.init(0x07)),
        compare_to = @intFromEnum(lu16.init(0x08)),
        store_var = @intFromEnum(lu16.init(0x09)),
        clear_var = @intFromEnum(lu16.init(0x0A)),
        unknown_0B = @intFromEnum(lu16.init(0x0B)),
        unknown_0C = @intFromEnum(lu16.init(0x0C)),
        unknown_0D = @intFromEnum(lu16.init(0x0D)),
        unknown_0E = @intFromEnum(lu16.init(0x0E)),
        unknown_0F = @intFromEnum(lu16.init(0x0F)),
        store_flag = @intFromEnum(lu16.init(0x10)),
        condition = @intFromEnum(lu16.init(0x11)),
        unknown_12 = @intFromEnum(lu16.init(0x12)),
        unknown_13 = @intFromEnum(lu16.init(0x13)),
        unknown_14 = @intFromEnum(lu16.init(0x14)),
        unknown_16 = @intFromEnum(lu16.init(0x16)),
        unknown_17 = @intFromEnum(lu16.init(0x17)),
        compare = @intFromEnum(lu16.init(0x19)),
        add_script_vm = @intFromEnum(lu16.init(0x1B)),
        call_std = @intFromEnum(lu16.init(0x1C)),
        return_std = @intFromEnum(lu16.init(0x1D)),
        jump = @intFromEnum(lu16.init(0x1E)),
        when = @intFromEnum(lu16.init(0x1F)),
        @"if" = @intFromEnum(lu16.init(0x20)),
        unknown_21 = @intFromEnum(lu16.init(0x21)),
        unknown_22 = @intFromEnum(lu16.init(0x22)),
        set_flag = @intFromEnum(lu16.init(0x23)),
        clear_flag = @intFromEnum(lu16.init(0x24)),
        set_var_flag_status = @intFromEnum(lu16.init(0x25)),
        set_var_26 = @intFromEnum(lu16.init(0x26)),
        set_var_27 = @intFromEnum(lu16.init(0x27)),
        set_var_eq_val = @intFromEnum(lu16.init(0x28)),
        set_var_29 = @intFromEnum(lu16.init(0x29)),
        set_var_2a = @intFromEnum(lu16.init(0x2A)),
        set_var_2b = @intFromEnum(lu16.init(0x2B)),
        dir_vars = @intFromEnum(lu16.init(0x2C)),
        unknown_2D = @intFromEnum(lu16.init(0x2D)),
        lock_all = @intFromEnum(lu16.init(0x2E)),
        unlock_all = @intFromEnum(lu16.init(0x2F)),
        wait_moment = @intFromEnum(lu16.init(0x30)),
        wait_a_press = @intFromEnum(lu16.init(0x31)),
        wait_button = @intFromEnum(lu16.init(0x32)),
        musical_message = @intFromEnum(lu16.init(0x33)),
        event_grey_message = @intFromEnum(lu16.init(0x34)),
        close_musical_message = @intFromEnum(lu16.init(0x35)),
        closed_event_grey_message = @intFromEnum(lu16.init(0x36)),
        unknown_37 = @intFromEnum(lu16.init(0x37)),
        bubble_message = @intFromEnum(lu16.init(0x38)),
        close_bubble_message = @intFromEnum(lu16.init(0x39)),
        show_message_at = @intFromEnum(lu16.init(0x3A)),
        close_show_message_at = @intFromEnum(lu16.init(0x3B)),
        message = @intFromEnum(lu16.init(0x3C)),
        message2 = @intFromEnum(lu16.init(0x3D)),
        close_message_k_p = @intFromEnum(lu16.init(0x3E)),
        close_message_k_p2 = @intFromEnum(lu16.init(0x3F)),
        money_box = @intFromEnum(lu16.init(0x40)),
        close_money_box = @intFromEnum(lu16.init(0x41)),
        update_money_box = @intFromEnum(lu16.init(0x42)),
        bordered_message = @intFromEnum(lu16.init(0x43)),
        close_bordered_message = @intFromEnum(lu16.init(0x44)),
        paper_message = @intFromEnum(lu16.init(0x45)),
        close_paper_message = @intFromEnum(lu16.init(0x46)),
        yes_no = @intFromEnum(lu16.init(0x47)),
        message3 = @intFromEnum(lu16.init(0x48)),
        double_message = @intFromEnum(lu16.init(0x49)),
        angry_message = @intFromEnum(lu16.init(0x4A)),
        close_angry_message = @intFromEnum(lu16.init(0x4B)),
        set_var_hero = @intFromEnum(lu16.init(0x4C)),
        set_var_item = @intFromEnum(lu16.init(0x4D)),
        unknown_4E = @intFromEnum(lu16.init(0x4E)),
        set_var_item2 = @intFromEnum(lu16.init(0x4F)),
        set_var_item3 = @intFromEnum(lu16.init(0x50)),
        set_var_move = @intFromEnum(lu16.init(0x51)),
        set_var_bag = @intFromEnum(lu16.init(0x52)),
        set_var_party_poke = @intFromEnum(lu16.init(0x53)),
        set_var_party_poke2 = @intFromEnum(lu16.init(0x54)),
        set_var_unknown = @intFromEnum(lu16.init(0x55)),
        set_var_type = @intFromEnum(lu16.init(0x56)),
        set_var_poke = @intFromEnum(lu16.init(0x57)),
        set_var_poke2 = @intFromEnum(lu16.init(0x58)),
        set_var_location = @intFromEnum(lu16.init(0x59)),
        set_var_poke_nick = @intFromEnum(lu16.init(0x5A)),
        set_var_unknown2 = @intFromEnum(lu16.init(0x5B)),
        set_var_store_value5_c = @intFromEnum(lu16.init(0x5C)),
        set_var_musical_info = @intFromEnum(lu16.init(0x5D)),
        set_var_nations = @intFromEnum(lu16.init(0x5E)),
        set_var_activities = @intFromEnum(lu16.init(0x5F)),
        set_var_power = @intFromEnum(lu16.init(0x60)),
        set_var_trainer_type = @intFromEnum(lu16.init(0x61)),
        set_var_trainer_type2 = @intFromEnum(lu16.init(0x62)),
        set_var_general_word = @intFromEnum(lu16.init(0x63)),
        apply_movement = @intFromEnum(lu16.init(0x64)),
        wait_movement = @intFromEnum(lu16.init(0x65)),
        store_hero_position = @intFromEnum(lu16.init(0x66)),
        unknown_67 = @intFromEnum(lu16.init(0x67)),
        store_hero_position2 = @intFromEnum(lu16.init(0x68)),
        store_npc_position = @intFromEnum(lu16.init(0x69)),
        unknown_6A = @intFromEnum(lu16.init(0x6A)),
        add_npc = @intFromEnum(lu16.init(0x6B)),
        remove_npc = @intFromEnum(lu16.init(0x6C)),
        set_o_w_position = @intFromEnum(lu16.init(0x6D)),
        unknown_6E = @intFromEnum(lu16.init(0x6E)),
        unknown_6F = @intFromEnum(lu16.init(0x6F)),
        unknown_70 = @intFromEnum(lu16.init(0x70)),
        unknown_71 = @intFromEnum(lu16.init(0x71)),
        unknown_72 = @intFromEnum(lu16.init(0x72)),
        unknown_73 = @intFromEnum(lu16.init(0x73)),
        face_player = @intFromEnum(lu16.init(0x74)),
        release = @intFromEnum(lu16.init(0x75)),
        release_all = @intFromEnum(lu16.init(0x76)),
        lock_77 = @intFromEnum(lu16.init(0x77)),
        unknown_78 = @intFromEnum(lu16.init(0x78)),
        unknown_79 = @intFromEnum(lu16.init(0x79)),
        move_npc_to = @intFromEnum(lu16.init(0x7B)),
        unknown_7C = @intFromEnum(lu16.init(0x7C)),
        unknown_7D = @intFromEnum(lu16.init(0x7D)),
        teleport_up_npc = @intFromEnum(lu16.init(0x7E)),
        unknown_7F = @intFromEnum(lu16.init(0x7F)),
        unknown_80 = @intFromEnum(lu16.init(0x80)),
        unknown_81 = @intFromEnum(lu16.init(0x81)),
        unknown_82 = @intFromEnum(lu16.init(0x82)),
        set_var83 = @intFromEnum(lu16.init(0x83)),
        set_var84 = @intFromEnum(lu16.init(0x84)),
        single_trainer_battle = @intFromEnum(lu16.init(0x85)),
        double_trainer_battle = @intFromEnum(lu16.init(0x86)),
        unknown_87 = @intFromEnum(lu16.init(0x87)),
        unknown_88 = @intFromEnum(lu16.init(0x88)),
        unknown_8A = @intFromEnum(lu16.init(0x8A)),
        play_trainer_music = @intFromEnum(lu16.init(0x8B)),
        end_battle = @intFromEnum(lu16.init(0x8C)),
        store_battle_result = @intFromEnum(lu16.init(0x8D)),
        disable_trainer = @intFromEnum(lu16.init(0x8E)),
        d_var90 = @intFromEnum(lu16.init(0x90)),
        d_var92 = @intFromEnum(lu16.init(0x92)),
        d_var93 = @intFromEnum(lu16.init(0x93)),
        trainer_battle = @intFromEnum(lu16.init(0x94)),
        deactivate_trainer_i_d = @intFromEnum(lu16.init(0x95)),
        unknown_96 = @intFromEnum(lu16.init(0x96)),
        store_active_trainer_i_d = @intFromEnum(lu16.init(0x97)),
        change_music = @intFromEnum(lu16.init(0x98)),
        fade_to_default_music = @intFromEnum(lu16.init(0x9E)),
        unknown_9F = @intFromEnum(lu16.init(0x9F)),
        stop_music = @intFromEnum(lu16.init(0xA1)),
        unknown_A2 = @intFromEnum(lu16.init(0xA2)),
        unknown_A3 = @intFromEnum(lu16.init(0xA3)),
        unknown_A4 = @intFromEnum(lu16.init(0xA4)),
        unknown_A5 = @intFromEnum(lu16.init(0xA5)),
        play_sound = @intFromEnum(lu16.init(0xA6)),
        wait_sound_a7 = @intFromEnum(lu16.init(0xA7)),
        wait_sound = @intFromEnum(lu16.init(0xA8)),
        play_fanfare = @intFromEnum(lu16.init(0xA9)),
        wait_fanfare = @intFromEnum(lu16.init(0xAA)),
        play_cry = @intFromEnum(lu16.init(0xAB)),
        wait_cry = @intFromEnum(lu16.init(0xAC)),
        set_text_script_message = @intFromEnum(lu16.init(0xAF)),
        close_multi = @intFromEnum(lu16.init(0xB0)),
        unknown_B1 = @intFromEnum(lu16.init(0xB1)),
        multi2 = @intFromEnum(lu16.init(0xB2)),
        fade_screen = @intFromEnum(lu16.init(0xB3)),
        reset_screen = @intFromEnum(lu16.init(0xB4)),
        screen_b5 = @intFromEnum(lu16.init(0xB5)),
        take_item = @intFromEnum(lu16.init(0xB6)),
        check_item_bag_space = @intFromEnum(lu16.init(0xB7)),
        check_item_bag_number = @intFromEnum(lu16.init(0xB8)),
        store_item_count = @intFromEnum(lu16.init(0xB9)),
        unknown_BA = @intFromEnum(lu16.init(0xBA)),
        unknown_BB = @intFromEnum(lu16.init(0xBB)),
        unknown_BC = @intFromEnum(lu16.init(0xBC)),
        unknown_BD = @intFromEnum(lu16.init(0xBD)),
        warp = @intFromEnum(lu16.init(0xBE)),
        teleport_warp = @intFromEnum(lu16.init(0xBF)),
        fall_warp = @intFromEnum(lu16.init(0xC1)),
        fast_warp = @intFromEnum(lu16.init(0xC2)),
        union_warp = @intFromEnum(lu16.init(0xC3)),
        teleport_warp2 = @intFromEnum(lu16.init(0xC4)),
        surf_animation = @intFromEnum(lu16.init(0xC5)),
        special_animation = @intFromEnum(lu16.init(0xC6)),
        special_animation2 = @intFromEnum(lu16.init(0xC7)),
        call_animation = @intFromEnum(lu16.init(0xC8)),
        store_random_number = @intFromEnum(lu16.init(0xCB)),
        store_var_item = @intFromEnum(lu16.init(0xCC)),
        store_var_cd = @intFromEnum(lu16.init(0xCD)),
        store_var_ce = @intFromEnum(lu16.init(0xCE)),
        store_var_cf = @intFromEnum(lu16.init(0xCF)),
        store_date = @intFromEnum(lu16.init(0xD0)),
        store_d1 = @intFromEnum(lu16.init(0xD1)),
        store_d2 = @intFromEnum(lu16.init(0xD2)),
        store_d3 = @intFromEnum(lu16.init(0xD3)),
        store_birth_day = @intFromEnum(lu16.init(0xD4)),
        store_badge = @intFromEnum(lu16.init(0xD5)),
        set_badge = @intFromEnum(lu16.init(0xD6)),
        store_badge_number = @intFromEnum(lu16.init(0xD7)),
        check_change_map_event = @intFromEnum(lu16.init(0xD8)),
        unknown_D9 = @intFromEnum(lu16.init(0xD9)),
        unknown_DA = @intFromEnum(lu16.init(0xDA)),
        unknown_DC = @intFromEnum(lu16.init(0xDC)),
        store_pokemon_caught = @intFromEnum(lu16.init(0xDD)),
        show_pokemon_species = @intFromEnum(lu16.init(0xDE)),
        check_pokemon_seen = @intFromEnum(lu16.init(0xDF)),
        store_version = @intFromEnum(lu16.init(0xE0)),
        store_gender = @intFromEnum(lu16.init(0xE1)),
        activate_key_item = @intFromEnum(lu16.init(0xE7)),
        unknown_E9 = @intFromEnum(lu16.init(0xE9)),
        give_poke_day_care = @intFromEnum(lu16.init(0xF0)),
        unknown_F9 = @intFromEnum(lu16.init(0xF9)),
        take_money = @intFromEnum(lu16.init(0xFA)),
        check_money = @intFromEnum(lu16.init(0xFB)),
        store_pokemon_happiness = @intFromEnum(lu16.init(0xFC)),
        inc_pokemon_happiness = @intFromEnum(lu16.init(0xFD)),
        store_party_species = @intFromEnum(lu16.init(0xFE)),
        store_pokemon_form_number = @intFromEnum(lu16.init(0xFF)),
        check_pokerus = @intFromEnum(lu16.init(0x100)),
        unknown_101 = @intFromEnum(lu16.init(0x101)),
        check_egg = @intFromEnum(lu16.init(0x102)),
        store_party_number_minimum = @intFromEnum(lu16.init(0x103)),
        heal_pokemon = @intFromEnum(lu16.init(0x104)),
        rename_pokemon = @intFromEnum(lu16.init(0x105)),
        store_chosen_pokemon = @intFromEnum(lu16.init(0x107)),
        give_pokemon_1 = @intFromEnum(lu16.init(0x10C)),
        give_pokemon_2 = @intFromEnum(lu16.init(0x10E)),
        store_pokemon_party_at = @intFromEnum(lu16.init(0x10D)),
        give_pokemon_3 = @intFromEnum(lu16.init(0x10F)),
        store_pokemon_sex = @intFromEnum(lu16.init(0x110)),
        check_pokemon_nickname = @intFromEnum(lu16.init(0x113)),
        store_party_have_pokemon = @intFromEnum(lu16.init(0x114)),
        store_party_can_learn_move = @intFromEnum(lu16.init(0x115)),
        store_party_can_use_move = @intFromEnum(lu16.init(0x116)),
        store_pokemon_form = @intFromEnum(lu16.init(0x117)),
        check_chosen_species = @intFromEnum(lu16.init(0x118)),
        unknown_11A = @intFromEnum(lu16.init(0x11A)),
        store_party_type = @intFromEnum(lu16.init(0x11B)),
        forgot_move = @intFromEnum(lu16.init(0x11C)),
        set_favorite = @intFromEnum(lu16.init(0x11D)),
        badge_animation = @intFromEnum(lu16.init(0x11E)),
        set_var_pokemon_trade = @intFromEnum(lu16.init(0x120)),
        check_party_amount = @intFromEnum(lu16.init(0x121)),
        unknown_122 = @intFromEnum(lu16.init(0x122)),
        unknown_125 = @intFromEnum(lu16.init(0x125)),
        unknown_127 = @intFromEnum(lu16.init(0x127)),
        unknown_128 = @intFromEnum(lu16.init(0x128)),
        unknown_129 = @intFromEnum(lu16.init(0x129)),
        unknown_12A = @intFromEnum(lu16.init(0x12A)),
        unknown_12B = @intFromEnum(lu16.init(0x12B)),
        unknown_12C = @intFromEnum(lu16.init(0x12C)),
        unknown_12D = @intFromEnum(lu16.init(0x12D)),
        unknown_12E = @intFromEnum(lu16.init(0x12E)),
        unknown_12F = @intFromEnum(lu16.init(0x12F)),
        unknown_134 = @intFromEnum(lu16.init(0x134)),
        unknown_135 = @intFromEnum(lu16.init(0x135)),
        unknown_136 = @intFromEnum(lu16.init(0x136)),
        show_clock_saving = @intFromEnum(lu16.init(0x137)),
        store_save_data = @intFromEnum(lu16.init(0x138)),
        store_comunication_status = @intFromEnum(lu16.init(0x13A)),
        unknown_13C = @intFromEnum(lu16.init(0x13C)),
        unknown_13D = @intFromEnum(lu16.init(0x13D)),
        unknown_13E = @intFromEnum(lu16.init(0x13E)),
        unknown_13F = @intFromEnum(lu16.init(0x13F)),
        stop_camera_event = @intFromEnum(lu16.init(0x140)),
        lock_camera = @intFromEnum(lu16.init(0x141)),
        move_camera = @intFromEnum(lu16.init(0x143)),
        unknown_144 = @intFromEnum(lu16.init(0x144)),
        end_camera_event = @intFromEnum(lu16.init(0x145)),
        unknown_146 = @intFromEnum(lu16.init(0x146)),
        bumping_camera = @intFromEnum(lu16.init(0x148)),
        choose_interesting_item = @intFromEnum(lu16.init(0x14E)),
        unknown_152 = @intFromEnum(lu16.init(0x152)),
        unknown_158 = @intFromEnum(lu16.init(0x158)),
        unknown_159 = @intFromEnum(lu16.init(0x159)),
        unknown_15A = @intFromEnum(lu16.init(0x15A)),
        unknown_15B = @intFromEnum(lu16.init(0x15B)),
        unknown_15C = @intFromEnum(lu16.init(0x15C)),
        unknown_15D = @intFromEnum(lu16.init(0x15D)),
        unknown_15E = @intFromEnum(lu16.init(0x15E)),
        start_pokemon_musical = @intFromEnum(lu16.init(0x167)),
        start_dress_pokemon_musical = @intFromEnum(lu16.init(0x168)),
        check_pokemon_musical_functions = @intFromEnum(lu16.init(0x169)),
        store_status_pokemon_musical = @intFromEnum(lu16.init(0x16A)),
        pokemon_menu_musical_functions = @intFromEnum(lu16.init(0x16B)),
        choose_pokemon_musical = @intFromEnum(lu16.init(0x16E)),
        unknown_16F = @intFromEnum(lu16.init(0x16F)),
        unknown_170 = @intFromEnum(lu16.init(0x170)),
        unknown_171 = @intFromEnum(lu16.init(0x171)),
        unknown_175 = @intFromEnum(lu16.init(0x175)),
        unknown_17D = @intFromEnum(lu16.init(0x17D)),
        unknown_17E = @intFromEnum(lu16.init(0x17E)),
        unknown_17F = @intFromEnum(lu16.init(0x17F)),
        nimbasa_gym_rail_animation = @intFromEnum(lu16.init(0x180)),
        unknown_181 = @intFromEnum(lu16.init(0x181)),
        unknown_182 = @intFromEnum(lu16.init(0x182)),
        unknown_186 = @intFromEnum(lu16.init(0x186)),
        unknown_187 = @intFromEnum(lu16.init(0x187)),
        unknown_188 = @intFromEnum(lu16.init(0x188)),
        unknown_189 = @intFromEnum(lu16.init(0x189)),
        unknown_18A = @intFromEnum(lu16.init(0x18A)),
        unknown_18B = @intFromEnum(lu16.init(0x18B)),
        unknown_18C = @intFromEnum(lu16.init(0x18C)),
        unknown_18D = @intFromEnum(lu16.init(0x18D)),
        unknown_18E = @intFromEnum(lu16.init(0x18E)),
        unknown_18F = @intFromEnum(lu16.init(0x18F)),
        end_event_bc = @intFromEnum(lu16.init(0x1C3)),
        store_trainer_id = @intFromEnum(lu16.init(0x1C4)),
        unknown_1C7 = @intFromEnum(lu16.init(0x1C7)),
        store_var_message = @intFromEnum(lu16.init(0x1C9)),
        check_pokedex_status = @intFromEnum(lu16.init(0x1CE)),
        boot_p_c_sound = @intFromEnum(lu16.init(0x130)),
        check_wireless = @intFromEnum(lu16.init(0x13B)),
        release_camera = @intFromEnum(lu16.init(0x142)),
        reset_camera = @intFromEnum(lu16.init(0x147)),
        call_end = @intFromEnum(lu16.init(0x14A)),
        call_start = @intFromEnum(lu16.init(0x14B)),
        unknown_150 = @intFromEnum(lu16.init(0x150)),
        show_diploma = @intFromEnum(lu16.init(0x151)),
        liberty_ship_anm = @intFromEnum(lu16.init(0x154)),
        open_interpoke = @intFromEnum(lu16.init(0x155)),
        wild_battle = @intFromEnum(lu16.init(0x174)),
        wild_battle_store_result = @intFromEnum(lu16.init(0x178)),
        unknown_179 = @intFromEnum(lu16.init(0x179)),
        unknown_17A = @intFromEnum(lu16.init(0x17a)),
        unknown_17B = @intFromEnum(lu16.init(0x17b)),
        unknown_17C = @intFromEnum(lu16.init(0x17c)),
        unknown_185 = @intFromEnum(lu16.init(0x185)),
        drift_gym_lift_anm_second_room = @intFromEnum(lu16.init(0x190)),
        unknown_191 = @intFromEnum(lu16.init(0x191)),
        unknown_193 = @intFromEnum(lu16.init(0x193)),
        unknown_194 = @intFromEnum(lu16.init(0x194)),
        drift_gym_lift_anm_first_room = @intFromEnum(lu16.init(0x192)),
        unknown_196 = @intFromEnum(lu16.init(0x196)),
        unknown_197 = @intFromEnum(lu16.init(0x197)),
        unknown_198 = @intFromEnum(lu16.init(0x198)),
        unknown_199 = @intFromEnum(lu16.init(0x199)),
        unknown_19A = @intFromEnum(lu16.init(0x19A)),
        set_status_cg = @intFromEnum(lu16.init(0x19B)),
        unknown_19C = @intFromEnum(lu16.init(0x19C)),
        unknown_19D = @intFromEnum(lu16.init(0x19D)),
        show_cg = @intFromEnum(lu16.init(0x19E)),
        call_screen_animation = @intFromEnum(lu16.init(0x19F)),
        open_xtransciever = @intFromEnum(lu16.init(0x1A1)),
        unknown_1A2 = @intFromEnum(lu16.init(0x1A2)),
        flash_black_instant = @intFromEnum(lu16.init(0x1A3)),
        unknown_1A4 = @intFromEnum(lu16.init(0x1A4)),
        unknown_1A5 = @intFromEnum(lu16.init(0x1A5)),
        unknown_1A6 = @intFromEnum(lu16.init(0x1A6)),
        unknown_1A7 = @intFromEnum(lu16.init(0x1A7)),
        unknown_1A8 = @intFromEnum(lu16.init(0x1A8)),
        unknown_1A9 = @intFromEnum(lu16.init(0x1A9)),
        unknown_1AA = @intFromEnum(lu16.init(0x1AA)),
        fade_from_black = @intFromEnum(lu16.init(0x1AB)),
        fade_into_black = @intFromEnum(lu16.init(0x1AC)),
        fade_from_white = @intFromEnum(lu16.init(0x1AD)),
        fade_into_white = @intFromEnum(lu16.init(0x1AE)),
        unknown_1AF = @intFromEnum(lu16.init(0x1AF)),
        screen_function = @intFromEnum(lu16.init(0x1B1)),
        unknown_1B2 = @intFromEnum(lu16.init(0x1b2)),
        unknown_1B4 = @intFromEnum(lu16.init(0x1b4)),
        unknown_1B5 = @intFromEnum(lu16.init(0x1b5)),
        unknown_1B6 = @intFromEnum(lu16.init(0x1b6)),
        unknown_1B7 = @intFromEnum(lu16.init(0x1b7)),
        unknown_1B8 = @intFromEnum(lu16.init(0x1b8)),
        unknown_1BB = @intFromEnum(lu16.init(0x1BB)),
        unknown_1BC = @intFromEnum(lu16.init(0x1BC)),
        unknown_1BD = @intFromEnum(lu16.init(0x1BD)),
        unknown_1C2 = @intFromEnum(lu16.init(0x1C2)),
        unknown_1C8 = @intFromEnum(lu16.init(0x1C8)),
        unknown_1D0 = @intFromEnum(lu16.init(0x1D0)),
        unknown_1D1 = @intFromEnum(lu16.init(0x1D1)),
        unknown_1D2 = @intFromEnum(lu16.init(0x1D2)),
        unknown_1D3 = @intFromEnum(lu16.init(0x1D3)),
        unknown_1D4 = @intFromEnum(lu16.init(0x1D4)),
        unknown_1D5 = @intFromEnum(lu16.init(0x1D5)),
        affinity_check = @intFromEnum(lu16.init(0x1D6)),
        set_var_affinity_check = @intFromEnum(lu16.init(0x1D7)),
        unknown_1D8 = @intFromEnum(lu16.init(0x1D8)),
        unknown_1DA = @intFromEnum(lu16.init(0x1DA)),
        unknown_1DB = @intFromEnum(lu16.init(0x1DB)),
        unknown_1DD = @intFromEnum(lu16.init(0x1DD)),
        store_data_unity = @intFromEnum(lu16.init(0x1DE)),
        unknown_1E0 = @intFromEnum(lu16.init(0x1E0)),
        store_trainer_unity = @intFromEnum(lu16.init(0x1E1)),
        unknown_1E2 = @intFromEnum(lu16.init(0x1E2)),
        store_unity_activities = @intFromEnum(lu16.init(0x1E3)),
        unknown_1EA = @intFromEnum(lu16.init(0x1EA)),
        unknown_1EB = @intFromEnum(lu16.init(0x1EB)),
        trade_pokemon = @intFromEnum(lu16.init(0x1BE)),
        compare_chosen_pokemon = @intFromEnum(lu16.init(0x1BF)),
        switch_ow_position = @intFromEnum(lu16.init(0x1EC)),
        double_phrase_box_input = @intFromEnum(lu16.init(0x1ED)),
        hm_effect = @intFromEnum(lu16.init(0x1F0)),
        create_stadium_trainer = @intFromEnum(lu16.init(0x1F3)),
        start_stadium_function = @intFromEnum(lu16.init(0x1F4)),
        end_stadium_function = @intFromEnum(lu16.init(0x1F5)),
        create_stadium_overworld = @intFromEnum(lu16.init(0x1F6)),
        unknown_1F7 = @intFromEnum(lu16.init(0x1F7)),
        set_stadium_busy = @intFromEnum(lu16.init(0x1F8)),
        dream_world_function = @intFromEnum(lu16.init(0x209)),
        dream_world_function2 = @intFromEnum(lu16.init(0x20A)),
        show_dream_world_furniture = @intFromEnum(lu16.init(0x20B)),
        unknown_20D = @intFromEnum(lu16.init(0x20D)),
        check_item_interesting_bag = @intFromEnum(lu16.init(0x20E)),
        unknown_211 = @intFromEnum(lu16.init(0x211)),
        store_survey_active = @intFromEnum(lu16.init(0x212)),
        unknown_210 = @intFromEnum(lu16.init(0x210)),
        unknown_213 = @intFromEnum(lu16.init(0x213)),
        unknown_214 = @intFromEnum(lu16.init(0x214)),
        unknown_215 = @intFromEnum(lu16.init(0x215)),
        unknown_216 = @intFromEnum(lu16.init(0x216)),
        store_greeting = @intFromEnum(lu16.init(0x218)),
        store_thanks = @intFromEnum(lu16.init(0x219)),
        unknown_21C = @intFromEnum(lu16.init(0x21C)),
        unknown_21D = @intFromEnum(lu16.init(0x21D)),
        store_survey_done = @intFromEnum(lu16.init(0x21E)),
        unknown_21F = @intFromEnum(lu16.init(0x21F)),
        check_have_pokemon = @intFromEnum(lu16.init(0x220)),
        unknown_221 = @intFromEnum(lu16.init(0x221)),
        unknown_222 = @intFromEnum(lu16.init(0x222)),
        unknown_224 = @intFromEnum(lu16.init(0x224)),
        unknown_225 = @intFromEnum(lu16.init(0x225)),
        unknown_226 = @intFromEnum(lu16.init(0x226)),
        unknown_227 = @intFromEnum(lu16.init(0x227)),
        unknown_228 = @intFromEnum(lu16.init(0x228)),
        unknown_229 = @intFromEnum(lu16.init(0x229)),
        store_fish_pokemon = @intFromEnum(lu16.init(0x231)),
        unknown_236 = @intFromEnum(lu16.init(0x236)),
        unknown_238 = @intFromEnum(lu16.init(0x238)),
        unknown_23A = @intFromEnum(lu16.init(0x23A)),
        unknown_23C = @intFromEnum(lu16.init(0x23C)),
        unknown_23E = @intFromEnum(lu16.init(0x23E)),
        unknown_23F = @intFromEnum(lu16.init(0x23F)),
        check_send_save_cg = @intFromEnum(lu16.init(0x23B)),
        unknown_240 = @intFromEnum(lu16.init(0x240)),
        unknown_241 = @intFromEnum(lu16.init(0x241)),
        unknown_242 = @intFromEnum(lu16.init(0x242)),
        special_message = @intFromEnum(lu16.init(0x243)),
        unknown_246 = @intFromEnum(lu16.init(0x246)),
        wrap = @intFromEnum(lu16.init(0x247)),
        unknown_248 = @intFromEnum(lu16.init(0x248)),
        unknown_24B = @intFromEnum(lu16.init(0x24B)),
        unknown_24C = @intFromEnum(lu16.init(0x24C)),
        unknown_24E = @intFromEnum(lu16.init(0x24E)),
        lock_24f = @intFromEnum(lu16.init(0x24f)),
        unknown_250 = @intFromEnum(lu16.init(0x250)),
        show_map_name = @intFromEnum(lu16.init(0x252)),
        change_music_volume = @intFromEnum(lu16.init(0x253)),
        unknown_254 = @intFromEnum(lu16.init(0x254)),
        unknown_255 = @intFromEnum(lu16.init(0x255)),
        unknown_259 = @intFromEnum(lu16.init(0x259)),
        unknown_25B = @intFromEnum(lu16.init(0x25B)),
        unknown_25C = @intFromEnum(lu16.init(0x25C)),
        check_cgear_active = @intFromEnum(lu16.init(0x25D)),
        unknown_25E = @intFromEnum(lu16.init(0x25E)),
        unknown_260 = @intFromEnum(lu16.init(0x260)),
        play_theatral_music = @intFromEnum(lu16.init(0x25F)),
        give_pokemon_4 = @intFromEnum(lu16.init(0x2EA)),
    };

    pub const Arg0 = extern struct {
        kind: Kind align(1),
    };
    pub fn Arg1(comptime T: type) type {
        return extern struct {
            kind: Kind align(1),
            arg: T align(1),
        };
    }

    pub fn Arg2(comptime T1: type, comptime T2: type) type {
        return extern struct {
            kind: Kind align(1),
            arg1: T1 align(1),
            arg2: T2 align(1),
        };
    }
    pub fn Arg3(comptime T1: type, comptime T2: type, comptime T3: type) type {
        return extern struct {
            kind: Kind align(1),
            arg1: T1 align(1),
            arg2: T2 align(1),
            arg3: T3 align(1),
        };
    }
    pub fn Arg4(comptime T1: type, comptime T2: type, comptime T3: type, comptime T4: type) type {
        return extern struct {
            kind: Kind align(1),
            arg1: T1 align(1),
            arg2: T2 align(1),
            arg3: T3 align(1),
            arg4: T4 align(1),
        };
    }
    pub fn Arg5(
        comptime T1: type,
        comptime T2: type,
        comptime T3: type,
        comptime T4: type,
        comptime T5: type,
    ) type {
        return extern struct {
            kind: Kind align(1),
            arg1: T1 align(1),
            arg2: T2 align(1),
            arg3: T3 align(1),
            arg4: T4 align(1),
            arg5: T5 align(1),
        };
    }
    pub fn Arg6(
        comptime T1: type,
        comptime T2: type,
        comptime T3: type,
        comptime T4: type,
        comptime T5: type,
        comptime T6: type,
    ) type {
        return extern struct {
            kind: Kind align(1),
            arg1: T1 align(1),
            arg2: T2 align(1),
            arg3: T3 align(1),
            arg4: T4 align(1),
            arg5: T5 align(1),
            arg6: T6 align(1),
        };
    }
    pub fn Arg8(
        comptime T1: type,
        comptime T2: type,
        comptime T3: type,
        comptime T4: type,
        comptime T5: type,
        comptime T6: type,
        comptime T7: type,
        comptime T8: type,
    ) type {
        return extern struct {
            kind: Kind align(1),
            arg1: T1 align(1),
            arg2: T2 align(1),
            arg3: T3 align(1),
            arg4: T4 align(1),
            arg5: T5 align(1),
            arg6: T6 align(1),
            arg7: T7 align(1),
            arg8: T8 align(1),
        };
    }
    pub fn ArgValue(comptime T1: type, comptime T2: type) type {
        return extern struct {
            kind: Kind align(1),
            arg: T1 align(1),
            value: T2 align(1),
        };
    }
    pub const Value = extern struct {
        kind: Kind align(1),
        value: lu16 align(1),
    };
    pub const Value2 = extern struct {
        kind: Kind align(1),
        value1: lu16 align(1),
        value2: lu16 align(1),
    };
    pub const CallRoutine = extern struct {
        kind: Kind align(1),
        offset: li32 align(1),
    };
    pub const Var = extern struct {
        kind: Kind align(1),
        @"var": lu16 align(1),
    };
    pub const Condition = extern struct {
        kind: Kind align(1),
        condition: lu16 align(1),
    };
    pub const CallStd = extern struct {
        kind: Kind align(1),
        function: lu16 align(1),
    };
    pub const Jump = extern struct {
        kind: Kind align(1),
        offset: li32 align(1),
    };
    pub const If = extern struct {
        kind: Kind align(1),
        value: u8 align(1),
        offset: li32 align(1),
    };
    pub const ClearFlag = extern struct {
        kind: Kind align(1),
        flag: lu16 align(1),
    };
    pub const SetVarFlagStatus = extern struct {
        kind: Kind align(1),
        flag: lu16 align(1),
        status: lu16 align(1),
    };
    pub const SetVarContainer = extern struct {
        kind: Kind align(1),
        container: lu16 align(1),
        value: lu16 align(1),
    };
    pub const MusicalMessage = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
    };
    pub const EventGreyMessage = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        view: lu16 align(1),
    };
    pub const BubbleMessage = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        location: u8 align(1),
    };
    pub const ShowMessageAt = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
        zcoord: lu16 align(1),
    };
    pub const Message = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        npc: lu16 align(1),
        position: lu16 align(1),
        type: lu16 align(1),
    };
    pub const Coord = extern struct {
        kind: Kind align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
    };
    pub const BorderedMessage = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        color: lu16 align(1),
    };
    pub const PaperMessage = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        transcoord: lu16 align(1),
    };
    pub const YesNo = extern struct {
        kind: Kind align(1),
        yesno: lu16 align(1),
    };
    pub const Message3 = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        npc: lu16 align(1),
        position: lu16 align(1),
        type: lu16 align(1),
        unknown: lu16 align(1),
    };
    pub const DoubleMessage = extern struct {
        kind: Kind align(1),
        idblack: lu16 align(1),
        idwhite: lu16 align(1),
        npc: lu16 align(1),
        position: lu16 align(1),
        type: lu16 align(1),
    };
    pub const AngryMessage = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        unknownbyte: u8 align(1),
        position: lu16 align(1),
    };
    pub const SetVarStoreValue5C = extern struct {
        kind: Kind align(1),
        arg: u8 align(1),
        container: lu16 align(1),
        stat: lu16 align(1),
    };
    pub const ApplyMovement = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
        movementdata: lu32 align(1),
    };
    pub const StoreNPCPosition = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
    };
    pub const Unknown_6A = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
        flag: lu16 align(1),
    };
    pub const NPC = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
    };
    pub const SetOWPosition = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
        zcoord: lu16 align(1),
        direction: lu16 align(1),
    };
    pub const Unknown_70 = extern struct {
        kind: Kind align(1),
        arg: lu16 align(1),
        arg2: lu16 align(1),
        arg3: lu16 align(1),
        arg4: lu16 align(1),
        arg5: lu16 align(1),
    };
    pub const Unknown_79 = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
        arg2: lu16 align(1),
        arg3: lu16 align(1),
    };
    pub const MoveNPCTo = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
        zcoord: lu16 align(1),
    };
    pub const TeleportUpNPC = extern struct {
        kind: Kind align(1),
        npc: lu16 align(1),
    };
    pub const SingleTrainerBattle = extern struct {
        kind: Kind align(1),
        trainerid: lu16 align(1),
        trainerid2: lu16 align(1),
        logic: lu16 align(1),
    };
    pub const DoubleTrainerBattle = extern struct {
        kind: Kind align(1),
        ally: lu16 align(1),
        trainerid: lu16 align(1),
        trainerid2: lu16 align(1),
        logic: lu16 align(1),
    };
    pub const PlayTrainerMusic = extern struct {
        kind: Kind align(1),
        songid: lu16 align(1),
    };
    pub const StoreBattleResult = extern struct {
        kind: Kind align(1),
        variable: lu16 align(1),
    };
    pub const TrainerBattle = extern struct {
        kind: Kind align(1),
        trainerid: lu16 align(1),
        arg2: lu16 align(1),
        arg3: lu16 align(1),
        arg4: lu16 align(1),
    };
    pub const DeactivateTrainerID = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
    };
    pub const Unknown_96 = extern struct {
        kind: Kind align(1),
        trainerid: lu16 align(1),
    };
    pub const StoreActiveTrainerID = extern struct {
        kind: Kind align(1),
        trainerid: lu16 align(1),
        arg2: lu16 align(1),
    };
    pub const ChangeMusic = extern struct {
        kind: Kind align(1),
        songid: lu16 align(1),
    };
    pub const Unknown_A2 = extern struct {
        kind: Kind align(1),
        sound: lu16 align(1),
        arg2: lu16 align(1),
    };
    pub const PlaySound = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
    };
    pub const PlayFanfare = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
    };
    pub const PlayCry = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        arg2: lu16 align(1),
    };
    pub const SetTextScriptMessage = extern struct {
        kind: Kind align(1),
        id: lu16 align(1),
        arg2: lu16 align(1),
        arg3: lu16 align(1),
    };
    pub const Multi2 = extern struct {
        kind: Kind align(1),
        arg: u8 align(1),
        arg2: u8 align(1),
        arg3: u8 align(1),
        arg4: u8 align(1),
        arg5: u8 align(1),
        @"var": lu16 align(1),
    };
    pub const TakeItem = extern struct {
        kind: Kind align(1),
        item: lu16 align(1),
        quantity: lu16 align(1),
        result: lu16 align(1),
    };
    pub const CheckItemBagSpace = extern struct {
        kind: Kind align(1),
        item: lu16 align(1),
        quantity: lu16 align(1),
        result: lu16 align(1),
    };
    pub const CheckItemBagNumber = extern struct {
        kind: Kind align(1),
        item: lu16 align(1),
        quantity: lu16 align(1),
        result: lu16 align(1),
    };
    pub const StoreItemCount = extern struct {
        kind: Kind align(1),
        item: lu16 align(1),
        result: lu16 align(1),
    };
    pub const Warp = extern struct {
        kind: Kind align(1),
        mapid: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
    };
    pub const TeleportWarp = extern struct {
        kind: Kind align(1),
        mapid: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
        zcoord: lu16 align(1),
        npcfacing: lu16 align(1),
    };
    pub const FallWarp = extern struct {
        kind: Kind align(1),
        mapid: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
    };
    pub const FastWarp = extern struct {
        kind: Kind align(1),
        mapid: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
        herofacing: lu16 align(1),
    };
    pub const TeleportWarp2 = extern struct {
        kind: Kind align(1),
        mapid: lu16 align(1),
        xcoord: lu16 align(1),
        ycoord: lu16 align(1),
        zcoord: lu16 align(1),
        herofacing: lu16 align(1),
    };
    pub const StoreDate = extern struct {
        kind: Kind align(1),
        month: lu16 align(1),
        date: lu16 align(1),
    };
    pub const StoreBirthDay = extern struct {
        kind: Kind align(1),
        month: lu16 align(1),
        day: lu16 align(1),
    };
    pub const StoreBadge = extern struct {
        kind: Kind align(1),
        @"var": lu16 align(1),
        badge: lu16 align(1),
    };
    pub const Badge = extern struct {
        kind: Kind align(1),
        badge: lu16 align(1),
    };
    pub const TakeMoney = extern struct {
        kind: Kind align(1),
        amount: lu16 align(1),
    };
    pub const CheckMoney = extern struct {
        kind: Kind align(1),
        storage: lu16 align(1),
        value: lu16 align(1),
    };
    pub const StorePartyNumberMinimum = extern struct {
        kind: Kind align(1),
        result: lu16 align(1),
        number: lu16 align(1),
    };
    pub const GivePokemon1 = extern struct {
        kind: Kind align(1),
        result: lu16 align(1),
        species: lu16 align(1),
        item: lu16 align(1),
        level: lu16 align(1),
    };
    pub const GivePokemon2 = extern struct {
        kind: Kind align(1),
        result: lu16 align(1),
        species: lu16 align(1),
        form: lu16 align(1),
        level: lu16 align(1),
        unknown_0: lu16 align(1),
        unknown_1: lu16 align(1),
        unknown_2: lu16 align(1),
        unknown_3: lu16 align(1),
        unknown_4: lu16 align(1),
    };
    pub const GivePokemon3 = extern struct {
        kind: Kind align(1),
        result: lu16 align(1),
        species: lu16 align(1),
        is_full: lu16 align(1),
    };
    pub const GivePokemon4 = extern struct {
        kind: Kind align(1),
        result: lu16 align(1),
        species: lu16 align(1),
        level: lu16 align(1),
        unknown_0: lu16 align(1),
        unknown_1: lu16 align(1),
        unknown_2: lu16 align(1),
    };
    pub const MoveCamera = extern struct {
        kind: Kind align(1),
        arg1: lu16 align(1),
        arg2: lu16 align(1),
        arg3: lu32 align(1),
        arg4: lu32 align(1),
        arg5: lu32 align(1),
        arg6: lu32 align(1),
        arg7: lu16 align(1),
    };
    pub const ResetCamera = extern struct {
        kind: Kind align(1),
        arg1: lu16 align(1),
        arg2: lu16 align(1),
        arg3: lu16 align(1),
        arg4: lu16 align(1),
        arg5: lu16 align(1),
        arg6: lu16 align(1),
    };
    pub const SwitchOwPosition = extern struct {
        kind: Kind align(1),
        arg1: lu16 align(1),
        arg2: lu16 align(1),
        arg3: lu16 align(1),
        arg4: lu16 align(1),
        arg5: lu16 align(1),
    };
    pub const WildBattle = extern struct {
        kind: Kind align(1),
        species: lu16 align(1),
        level: lu16 align(1),
    };
    pub const WildBattleStoreResult = extern struct {
        kind: Kind align(1),
        species: lu16 align(1),
        level: lu16 align(1),
        variable: lu16 align(1),
    };

    comptime {
        @setEvalBranchQuota(1000000);
        std.debug.assert(script.isPacked(@This()));
    }
};
