diff --git a/src/data_formats/parsing/quest/bin.ts b/src/data_formats/parsing/quest/bin.ts index 6789fd07..71b7ae55 100644 --- a/src/data_formats/parsing/quest/bin.ts +++ b/src/data_formats/parsing/quest/bin.ts @@ -95,80 +95,113 @@ export function write_bin(bin: BinFile): ArrayBuffer { return buffer; } -export type Instruction = { - opcode: number; - mnemonic: string; - args: any[]; +/** + * Script object code instruction. Invoked by {@link Instruction}s. + */ +export class Opcode { + /** + * Byte size of the instruction code, either 1 or 2. + */ + readonly code_size: number; + + constructor( + /** + * 1- Or 2-byte instruction code used to invoke this opcode. + */ + readonly code: number, + readonly mnemonic: string, + /** + * Directly passed in arguments. + */ + readonly params: Type[], + /** + * If true, this opcode pushes arguments onto the stack. + */ + readonly push_stack: boolean, + /** + * Arguments passed in via the stack. + * These arguments are popped from the stack after the opcode has executed. + */ + readonly stack_params: Type[] + ) { + const table = this.code >>> 8; + this.code_size = table === 0 ? 1 : 2; + } +} + +/** + * Instruction parameter types. + */ +export enum Type { + U8, + U16, + U32, + I32, + F32, + Register, + SwitchData, + JumpData, + String, +} + +/** + * Instruction invocation. + */ +export class Instruction { + /** + * Byte size of the argument list. + */ + readonly arg_size: number = 0; + /** + * Byte size of the entire instruction, i.e. the sum of the opcode size and all argument sizes. + */ + readonly size: number; + + constructor(readonly opcode: Opcode, readonly args: Arg[]) { + for (const { size } of args) { + this.arg_size += size; + } + + this.size = opcode.code_size + this.arg_size; + } +} + +export type Arg = { + value: any; size: number; }; function parse_object_code(cursor: Cursor, lenient: boolean): Instruction[] { - const instructions = []; + const instructions: Instruction[] = []; try { while (cursor.bytes_left) { const main_opcode = cursor.u8(); - let opcode; - let opsize; - let list; + let code; + let opcode_list; switch (main_opcode) { case 0xf8: - opcode = cursor.u8(); - opsize = 2; - list = f8_opcode_list; + code = cursor.u8(); + opcode_list = f8_opcodes; break; case 0xf9: - opcode = cursor.u8(); - opsize = 2; - list = f9_opcode_list; + code = cursor.u8(); + opcode_list = f9_opcodes; break; default: - opcode = main_opcode; - opsize = 1; - list = opcode_list; + code = main_opcode; + opcode_list = opcodes; break; } - let [, mnemonic, mask] = list[opcode]; + let opcode = opcode_list[code]; - if (mask == null) { - let full_opcode = main_opcode; - - if (main_opcode === 0xf8 || main_opcode === 0xf9) { - full_opcode = (full_opcode << 8) | opcode; - } - - logger.warn( - `Parameters unknown for opcode 0x${full_opcode - .toString(16) - .toUpperCase()}, assuming 0.` - ); - - instructions.push({ - opcode, - mnemonic, - args: [], - size: opsize, - }); - } else { - try { - const opargs = parse_instruction_arguments(cursor, mask); - - instructions.push({ - opcode, - mnemonic, - args: opargs.args, - size: opsize + opargs.size, - }); - } catch (e) { - instructions.push({ - opcode, - mnemonic, - args: [], - size: opsize, - }); - } + try { + const args = parse_instruction_arguments(cursor, opcode); + instructions.push(new Instruction(opcode, args)); + } catch (e) { + instructions.push(new Instruction(opcode, [])); } } } catch (e) { @@ -182,887 +215,926 @@ function parse_object_code(cursor: Cursor, lenient: boolean): Instruction[] { return instructions; } -function parse_instruction_arguments(cursor: Cursor, mask: string): { args: any[]; size: number } { - const old_pos = cursor.position; - const args = []; - let args_size: number; +function parse_instruction_arguments(cursor: Cursor, opcode: Opcode): Arg[] { + const args: Arg[] = []; - outer: for (let i = 0; i < mask.length; ++i) { - switch (mask.charAt(i)) { - // Pushes something on the stack - case "p": - break; - // Pops the stack (no increments) - case "a": - break outer; + for (const param of opcode.params) { + let arg: any; + const start_pos = cursor.position; - // Unsigned integers - case "B": - args.push(cursor.u8()); + switch (param) { + case Type.U8: + arg = cursor.u8(); break; - case "W": - args.push(cursor.u16()); + case Type.U16: + arg = cursor.u16(); break; - case "L": - args.push(cursor.u32()); + case Type.U32: + arg = cursor.u32(); break; - - // Signed integers - case "I": - args.push(cursor.i32()); + case Type.I32: + arg = cursor.i32(); break; - - // Floats - case "f": - case "F": - args.push(cursor.f32()); + case Type.F32: + arg = cursor.f32(); break; - - // Registers? - case "R": - case "r": - cursor.seek(1); + case Type.Register: + arg = cursor.u8(); break; - - // Registers with unsigned integers? - case "b": - args.push(cursor.u8()); - break; - case "w": - args.push(cursor.u16()); - break; - case "l": - args.push(cursor.u32()); - break; - - // Registers with signed integers? - case "i": - args.push(cursor.i32()); - break; - - // Variably sized data? - case "j": - case "J": - args_size = 2 * cursor.u8(); - cursor.seek(args_size); - break; - case "t": - case "T": - args_size = cursor.u8(); - cursor.seek(args_size); - break; - - // Strings - case "s": - case "S": - while (cursor.u16()) { - // Eat up the entire string. + case Type.SwitchData: + { + const arg_size = 2 * cursor.u8(); + arg = cursor.u8_array(arg_size); } break; - + case Type.JumpData: + { + const arg_size = cursor.u8(); + arg = cursor.u8_array(arg_size); + } + break; + case Type.String: + arg = cursor.string_utf16(1024, true, false); + break; default: - throw new Error(`Unknown mask part ${mask.charAt(i)}.`); + throw new Error(`Parameter type ${Type[param]} (${param}) not implemented.`); } + + args.push({ value: arg, size: cursor.position - start_pos }); } - return { args, size: cursor.position - old_pos }; + return args; } -const opcode_list: [number, string, string | null][] = [ - [0x00, "nop", ""], - [0x01, "ret", ""], - [0x02, "sync", ""], - [0x03, "exit", "aL"], - [0x04, "thread", "W"], - [0x05, "va_start", ""], - [0x06, "va_end", ""], - [0x07, "va_call", "W"], - [0x08, "let", "RR"], - [0x09, "leti", "RI"], - [0x0a, "unknown", null], - [0x0b, "unknown", null], - [0x0c, "unknown", null], - [0x0d, "unknown", null], - [0x0e, "unknown", null], - [0x0f, "unknown", null], - [0x10, "set", "R"], - [0x11, "clear", "R"], - [0x12, "rev", "R"], - [0x13, "gset", "w"], - [0x14, "gclear", "w"], - [0x15, "grev", "w"], - [0x16, "glet", "w"], - [0x17, "gget", "wR"], - [0x18, "add", "RR"], - [0x19, "addi", "RI"], - [0x1a, "sub", "RR"], - [0x1b, "subi", "RI"], - [0x1c, "mul", "RR"], - [0x1d, "muli", "RI"], - [0x1e, "div", "RR"], - [0x1f, "divi", "RI"], - [0x20, "and", "RR"], - [0x21, "andi", "RI"], - [0x22, "or", "RR"], - [0x23, "ori", "RI"], - [0x24, "xor", "RR"], - [0x25, "xori", "RI"], - [0x26, "mod", "RR"], - [0x27, "modi", "RI"], - [0x28, "jmp", "W"], - [0x29, "call", "W"], - [0x2a, "jmp_on", "Wt"], - [0x2b, "jmp_off", "Wt"], - [0x2c, "jmp_=", "RRW"], - [0x2d, "jmpi_=", "RIW"], - [0x2e, "jmp_!=", "RRW"], - [0x2f, "jmpi_!=", "RIW"], - [0x30, "ujmp_>", "RRW"], - [0x31, "ujmpi_>", "RLW"], - [0x32, "jmp_>", "RRW"], - [0x33, "jmpi_>", "RIW"], - [0x34, "ujmp_<", "RRW"], - [0x35, "ujmpi_<", "RLW"], - [0x36, "jmp_<", "RRW"], - [0x37, "jmpi_<", "RIW"], - [0x38, "ujmp_>=", "RRW"], - [0x39, "ujmpi_>=", "RLW"], - [0x3a, "jmp_>=", "RRW"], - [0x3b, "jmpi_>=", "RIW"], - [0x3c, "ujmp_<=", "RRW"], - [0x3d, "ujmpi_<=", "RLW"], - [0x3e, "jmp_<=", "RRW"], - [0x3f, "jmpi_<=", "RIW"], - [0x40, "switch_jmp", "Rj"], - [0x41, "switch_call", "Rj"], - [0x42, "stack_push", "R"], - [0x43, "stack_pop", "R"], - [0x44, "stack_pushm", "RL"], - [0x45, "stack_popm", "RL"], - [0x46, "unknown", null], - [0x47, "unknown", null], - [0x48, "arg_pushr", "pR"], - [0x49, "arg_pushl", "pI"], - [0x4a, "arg_pushb", "pB"], - [0x4b, "arg_pushw", "pW"], - [0x4c, "unknown", null], - [0x4d, "unknown", null], - [0x4e, "arg_pushs", "ps"], - [0x4f, "unknown4F", "RR"], - [0x50, "message", "aLs"], - [0x51, "list", "aRs"], - [0x52, "fadein", ""], - [0x53, "fadeout", ""], - [0x54, "se", "aL"], - [0x55, "bgm", "aL"], - [0x56, "unknown", null], - [0x57, "unknown", null], - [0x58, "enable", "aL"], - [0x59, "disable", "aL"], - [0x5a, "window_msg", "as"], - [0x5b, "add_msg", "as"], - [0x5c, "mesend", ""], - [0x5d, "gettime", "R"], - [0x5e, "winend", ""], - [0x5f, "unknown", null], - //[ 0x60, 'npc_crt_V1', null ], - [0x60, "npc_crt_V3", "R"], - [0x61, "npc_stop", "aR"], - [0x62, "npc_play", "aL"], - [0x63, "npc_kill", "aR"], - [0x64, "npc_nont", ""], - [0x65, "npc_talk", ""], - //[ 0x66, 'npc_crp_V1', null ], - [0x66, "npc_crp_V3", "R"], - [0x67, "unknown", null], - [0x68, "create_pipe", "aL"], - //[ 0x69, 'p_hpstat_V1', null ], - [0x69, "p_hpstat_V3", "aRL"], - //[ 0x6A, 'p_dead_V1', null ], - [0x6a, "p_dead_V3", "aRL"], - [0x6b, "p_disablewarp", ""], - [0x6c, "p_enablewarp", ""], - //[ 0x6D, 'p_move_V1', null ], - [0x6d, "p_move_V3", "R"], - [0x6e, "p_look", "aL"], - [0x6f, "unknown", null], - [0x70, "p_action_disable", ""], - [0x71, "p_action_enable", ""], - [0x72, "disable_movement1", "aR"], - [0x73, "enable_movement1", "aR"], - [0x74, "p_noncol", ""], - [0x75, "p_col", ""], - [0x76, "p_setpos", "aRR"], - [0x77, "p_return_guild", ""], - [0x78, "p_talk_guild", "aL"], - //[ 0x79, 'npc_talk_pl_V1', null ], - [0x79, "npc_talk_pl_V3", "R"], - [0x7a, "npc_talk_kill", "aL"], - //[ 0x7B, 'npc_crtpk_V1', null ], - [0x7b, "npc_crtpk_V3", "R"], - //[ 0x7C, 'npc_crppk_V1', null ], - [0x7c, "npc_crppk_V3", "R"], - //[ 0x7D, 'npc_crptalk_v1', null ], - [0x7d, "npc_crptalk_v3", "R"], - [0x7e, "p_look_at_V1", "aLL"], - //[ 0x7F, 'npc_crp_id_V1', null ], - [0x7f, "npc_crp_id_V3", "R"], - [0x80, "cam_quake", ""], - [0x81, "cam_adj", ""], - [0x82, "cam_zmin", ""], - [0x83, "cam_zmout", ""], - //[ 0x84, 'cam_pan_V1', null ], - [0x84, "cam_pan_V3", "R"], - [0x85, "game_lev_super", ""], - [0x86, "game_lev_reset", ""], - //[ 0x87, 'pos_pipe_V1', null ], - [0x87, "pos_pipe_V3", "R"], - [0x88, "if_zone_clear", "RR"], - [0x89, "chk_ene_num", "R"], - [0x8a, "unhide_obj", "R"], - [0x8b, "unhide_ene", "R"], - [0x8c, "at_coords_call", "R"], - [0x8d, "at_coords_talk", "R"], - [0x8e, "col_npcin", "R"], - [0x8f, "col_npcinr", "R"], - [0x90, "switch_on", "aL"], - [0x91, "switch_off", "aL"], - [0x92, "playbgm_epi", "aL"], - [0x93, "set_mainwarp", "aL"], - [0x94, "set_obj_param", "RR"], - [0x95, "set_floor_handler", "aLW"], - [0x96, "clr_floor_handler", "aL"], - [0x97, "col_plinaw", "R"], - [0x98, "hud_hide", ""], - [0x99, "hud_show", ""], - [0x9a, "cine_enable", ""], - [0x9b, "cine_disable", ""], - [0x9c, "unknown", null], - [0x9d, "unknown", null], - [0x9e, "unknown", null], - [0x9f, "unknown", null], - [0xa0, "unknown", null], - [0xa1, "set_qt_failure", "W"], - [0xa2, "set_qt_success", "W"], - [0xa3, "clr_qt_failure", ""], - [0xa4, "clr_qt_success", ""], - [0xa5, "set_qt_cancel", "W"], - [0xa6, "clr_qt_cancel", ""], - [0xa7, "unknown", null], - //[ 0xA8, 'pl_walk_V1', null ], - [0xa8, "pl_walk_V3", "R"], - [0xa9, "unknown", null], - [0xaa, "unknown", null], - [0xab, "unknown", null], - [0xac, "unknown", null], - [0xad, "unknown", null], - [0xae, "unknown", null], - [0xaf, "unknown", null], - [0xb0, "pl_add_meseta", "aLL"], - [0xb1, "thread_stg", "W"], - [0xb2, "del_obj_param", "R"], - [0xb3, "item_create", "RR"], - [0xb4, "item_create2", "RR"], - [0xb5, "item_delete", "RR"], - [0xb6, "item_delete2", "RR"], - [0xb7, "item_check", "RR"], - [0xb8, "setevt", "aL"], - [0xb9, "get_difflvl", "R"], - [0xba, "set_qt_exit", "W"], - [0xbb, "clr_qt_exit", ""], - [0xbc, "unknown", null], - [0xbd, "unknown", null], - [0xbe, "unknown", null], - [0xbf, "unknown", null], - //[ 0xC0, 'particle_V1', null ], - [0xc0, "particle_V3", "R"], - [0xc1, "npc_text", "aLs"], - [0xc2, "npc_chkwarp", ""], - [0xc3, "pl_pkoff", ""], - [0xc4, "map_designate", "R"], - [0xc5, "masterkey_on", ""], - [0xc6, "masterkey_off", ""], - [0xc7, "window_time", ""], - [0xc8, "winend_time", ""], - [0xc9, "winset_time", "R"], - [0xca, "getmtime", "R"], - [0xcb, "set_quest_board_handler", "aLWs"], - [0xcc, "clear_quest_board_handler", "aL"], - //[ 0xCD, 'particle_id_V1', null ], - [0xcd, "particle_id_V3", "R"], - //[ 0xCE, 'npc_crptalk_id_V1', null ], - [0xce, "npc_crptalk_id_V3", "R"], - [0xcf, "npc_lang_clean", ""], - [0xd0, "pl_pkon", ""], - [0xd1, "pl_chk_item2", "RR"], - [0xd2, "enable_mainmenu", ""], - [0xd3, "disable_mainmenu", ""], - [0xd4, "start_battlebgm", ""], - [0xd5, "end_battlebgm", ""], - [0xd6, "disp_msg_qb", "as"], - [0xd7, "close_msg_qb", ""], - //[ 0xD8, 'set_eventflag_v1', null ], - [0xd8, "set_eventflag_v3", "aLL"], - [0xd9, "sync_leti", null], - [0xda, "set_returnhunter", ""], - [0xdb, "set_returncity", ""], - [0xdc, "load_pvr", ""], - [0xdd, "load_midi", ""], - [0xde, "unknown", null], - //[ 0xDF, 'npc_param_V1', null ], - [0xdf, "npc_param_V3", "aRL"], - [0xe0, "pad_dragon", ""], - [0xe1, "clear_mainwarp", "aL"], - //[ 0xE2, 'pcam_param_V1', null ], - [0xe2, "pcam_param_V3", "R"], - //[ 0xE3, 'start_setevt_v1', null ], - [0xe3, "start_setevt_v3", "aRL"], - [0xe4, "warp_on", ""], - [0xe5, "warp_off", ""], - [0xe6, "get_slotnumber", "R"], - [0xe7, "get_servernumber", "R"], - [0xe8, "set_eventflag2", "aLR"], - [0xe9, "res", "RR"], - [0xea, "unknownEA", "RL"], - [0xeb, "enable_bgmctrl", "aL"], - [0xec, "sw_send", "R"], - [0xed, "create_bgmctrl", ""], - [0xee, "pl_add_meseta2", "aL"], - //[ 0xEF, 'sync_let', null ], - [0xef, "sync_register", "aRL"], - [0xf0, "send_regwork", null], - //[ 0xF1, 'leti_fixed_camera_V1', null ], - [0xf1, "leti_fixed_camera_V3", "R"], - [0xf2, "default_camera_pos1", ""], - [0xf3, "unknown", null], - [0xf4, "unknown", null], - [0xf5, "unknown", null], - [0xf6, "unknown", null], - [0xf7, "unknown", null], - [0xf8, "unknownF8", "R"], - [0xf9, "unknown", null], - [0xfa, "get_gc_number", "R"], - [0xfb, "unknownFB", "W"], - [0xfc, "unknown", null], - [0xfd, "unknown", null], - [0xfe, "unknown", null], - [0xff, "unknownFF", ""], +const opcodes: Opcode[] = [ + new Opcode(0x00, "nop", [], false, []), + new Opcode(0x01, "ret", [], false, []), + new Opcode(0x02, "sync", [], false, []), + new Opcode(0x03, "exit", [], false, [Type.U32]), + new Opcode(0x04, "thread", [Type.U16], false, []), + new Opcode(0x05, "va_start", [], false, []), + new Opcode(0x06, "va_end", [], false, []), + new Opcode(0x07, "va_call", [Type.U16], false, []), + new Opcode(0x08, "let", [Type.Register, Type.Register], false, []), + new Opcode(0x09, "leti", [Type.Register, Type.I32], false, []), + new Opcode(0x0a, "unknown", [], false, []), + new Opcode(0x0b, "unknown", [], false, []), + new Opcode(0x0c, "unknown", [], false, []), + new Opcode(0x0d, "unknown", [], false, []), + new Opcode(0x0e, "unknown", [], false, []), + new Opcode(0x0f, "unknown", [], false, []), + new Opcode(0x10, "set", [Type.Register], false, []), + new Opcode(0x11, "clear", [Type.Register], false, []), + new Opcode(0x12, "rev", [Type.Register], false, []), + new Opcode(0x13, "gset", [Type.U16], false, []), + new Opcode(0x14, "gclear", [Type.U16], false, []), + new Opcode(0x15, "grev", [Type.U16], false, []), + new Opcode(0x16, "glet", [Type.U16], false, []), + new Opcode(0x17, "gget", [Type.U16, Type.Register], false, []), + new Opcode(0x18, "add", [Type.Register, Type.Register], false, []), + new Opcode(0x19, "addi", [Type.Register, Type.I32], false, []), + new Opcode(0x1a, "sub", [Type.Register, Type.Register], false, []), + new Opcode(0x1b, "subi", [Type.Register, Type.I32], false, []), + new Opcode(0x1c, "mul", [Type.Register, Type.Register], false, []), + new Opcode(0x1d, "muli", [Type.Register, Type.I32], false, []), + new Opcode(0x1e, "div", [Type.Register, Type.Register], false, []), + new Opcode(0x1f, "divi", [Type.Register, Type.I32], false, []), + new Opcode(0x20, "and", [Type.Register, Type.Register], false, []), + new Opcode(0x21, "andi", [Type.Register, Type.I32], false, []), + new Opcode(0x22, "or", [Type.Register, Type.Register], false, []), + new Opcode(0x23, "ori", [Type.Register, Type.I32], false, []), + new Opcode(0x24, "xor", [Type.Register, Type.Register], false, []), + new Opcode(0x25, "xori", [Type.Register, Type.I32], false, []), + new Opcode(0x26, "mod", [Type.Register, Type.Register], false, []), + new Opcode(0x27, "modi", [Type.Register, Type.I32], false, []), + new Opcode(0x28, "jmp", [Type.U16], false, []), + new Opcode(0x29, "call", [Type.U16], false, []), + new Opcode(0x2a, "jmp_on", [Type.U16, Type.JumpData], false, []), + new Opcode(0x2b, "jmp_off", [Type.U16, Type.JumpData], false, []), + new Opcode(0x2c, "jmp_=", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x2d, "jmpi_=", [Type.Register, Type.I32, Type.U16], false, []), + new Opcode(0x2e, "jmp_!=", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x2f, "jmpi_!=", [Type.Register, Type.I32, Type.U16], false, []), + new Opcode(0x30, "ujmp_>", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x31, "ujmpi_>", [Type.Register, Type.U32, Type.U16], false, []), + new Opcode(0x32, "jmp_>", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x33, "jmpi_>", [Type.Register, Type.I32, Type.U16], false, []), + new Opcode(0x34, "ujmp_<", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x35, "ujmpi_<", [Type.Register, Type.U32, Type.U16], false, []), + new Opcode(0x36, "jmp_<", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x37, "jmpi_<", [Type.Register, Type.I32, Type.U16], false, []), + new Opcode(0x38, "ujmp_>=", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x39, "ujmpi_>=", [Type.Register, Type.U32, Type.U16], false, []), + new Opcode(0x3a, "jmp_>=", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x3b, "jmpi_>=", [Type.Register, Type.I32, Type.U16], false, []), + new Opcode(0x3c, "ujmp_<=", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x3d, "ujmpi_<=", [Type.Register, Type.U32, Type.U16], false, []), + new Opcode(0x3e, "jmp_<=", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0x3f, "jmpi_<=", [Type.Register, Type.I32, Type.U16], false, []), + new Opcode(0x40, "switch_jmp", [Type.Register, Type.SwitchData], false, []), + new Opcode(0x41, "switch_call", [Type.Register, Type.SwitchData], false, []), + new Opcode(0x42, "stack_push", [Type.Register], false, []), + new Opcode(0x43, "stack_pop", [Type.Register], false, []), + new Opcode(0x44, "stack_pushm", [Type.Register, Type.U32], false, []), + new Opcode(0x45, "stack_popm", [Type.Register, Type.U32], false, []), + new Opcode(0x46, "unknown", [], false, []), + new Opcode(0x47, "unknown", [], false, []), + new Opcode(0x48, "arg_pushr", [Type.Register], true, []), + new Opcode(0x49, "arg_pushl", [Type.I32], true, []), + new Opcode(0x4a, "arg_pushb", [Type.U8], true, []), + new Opcode(0x4b, "arg_pushw", [Type.U16], true, []), + new Opcode(0x4c, "unknown", [], false, []), + new Opcode(0x4d, "unknown", [], false, []), + new Opcode(0x4e, "arg_pushs", [Type.String], true, []), + new Opcode(0x4f, "unknown4F", [Type.Register, Type.Register], false, []), + new Opcode(0x50, "message", [], false, [Type.U32, Type.String]), + new Opcode(0x51, "list", [], false, [Type.Register, Type.String]), + new Opcode(0x52, "fadein", [], false, []), + new Opcode(0x53, "fadeout", [], false, []), + new Opcode(0x54, "se", [], false, [Type.U32]), + new Opcode(0x55, "bgm", [], false, [Type.U32]), + new Opcode(0x56, "unknown", [], false, []), + new Opcode(0x57, "unknown", [], false, []), + new Opcode(0x58, "enable", [], false, [Type.U32]), + new Opcode(0x59, "disable", [], false, [Type.U32]), + new Opcode(0x5a, "window_msg", [], false, [Type.String]), + new Opcode(0x5b, "add_msg", [], false, [Type.String]), + new Opcode(0x5c, "mesend", [], false, []), + new Opcode(0x5d, "gettime", [Type.Register], false, []), + new Opcode(0x5e, "winend", [], false, []), + new Opcode(0x5f, "unknown", [], false, []), + new Opcode(0x60, "npc_crt_V3", [Type.Register], false, []), + new Opcode(0x61, "npc_stop", [], false, [Type.Register]), + new Opcode(0x62, "npc_play", [], false, [Type.U32]), + new Opcode(0x63, "npc_kill", [], false, [Type.Register]), + new Opcode(0x64, "npc_nont", [], false, []), + new Opcode(0x65, "npc_talk", [], false, []), + new Opcode(0x66, "npc_crp_V3", [Type.Register], false, []), + new Opcode(0x67, "unknown", [], false, []), + new Opcode(0x68, "create_pipe", [], false, [Type.U32]), + new Opcode(0x69, "p_hpstat_V3", [], false, [Type.Register, Type.U32]), + new Opcode(0x6a, "p_dead_V3", [], false, [Type.Register, Type.U32]), + new Opcode(0x6b, "p_disablewarp", [], false, []), + new Opcode(0x6c, "p_enablewarp", [], false, []), + new Opcode(0x6d, "p_move_V3", [Type.Register], false, []), + new Opcode(0x6e, "p_look", [], false, [Type.U32]), + new Opcode(0x6f, "unknown", [], false, []), + new Opcode(0x70, "p_action_disable", [], false, []), + new Opcode(0x71, "p_action_enable", [], false, []), + new Opcode(0x72, "disable_movement1", [], false, [Type.Register]), + new Opcode(0x73, "enable_movement1", [], false, [Type.Register]), + new Opcode(0x74, "p_noncol", [], false, []), + new Opcode(0x75, "p_col", [], false, []), + new Opcode(0x76, "p_setpos", [], false, [Type.Register, Type.Register]), + new Opcode(0x77, "p_return_guild", [], false, []), + new Opcode(0x78, "p_talk_guild", [], false, [Type.U32]), + new Opcode(0x79, "npc_talk_pl_V3", [Type.Register], false, []), + new Opcode(0x7a, "npc_talk_kill", [], false, [Type.U32]), + new Opcode(0x7b, "npc_crtpk_V3", [Type.Register], false, []), + new Opcode(0x7c, "npc_crppk_V3", [Type.Register], false, []), + new Opcode(0x7d, "npc_crptalk_v3", [Type.Register], false, []), + new Opcode(0x7e, "p_look_at_V1", [], false, [Type.U32, Type.U32]), + new Opcode(0x7f, "npc_crp_id_V3", [Type.Register], false, []), + new Opcode(0x80, "cam_quake", [], false, []), + new Opcode(0x81, "cam_adj", [], false, []), + new Opcode(0x82, "cam_zmin", [], false, []), + new Opcode(0x83, "cam_zmout", [], false, []), + new Opcode(0x84, "cam_pan_V3", [Type.Register], false, []), + new Opcode(0x85, "game_lev_super", [], false, []), + new Opcode(0x86, "game_lev_reset", [], false, []), + new Opcode(0x87, "pos_pipe_V3", [Type.Register], false, []), + new Opcode(0x88, "if_zone_clear", [Type.Register, Type.Register], false, []), + new Opcode(0x89, "chk_ene_num", [Type.Register], false, []), + new Opcode(0x8a, "unhide_obj", [Type.Register], false, []), + new Opcode(0x8b, "unhide_ene", [Type.Register], false, []), + new Opcode(0x8c, "at_coords_call", [Type.Register], false, []), + new Opcode(0x8d, "at_coords_talk", [Type.Register], false, []), + new Opcode(0x8e, "col_npcin", [Type.Register], false, []), + new Opcode(0x8f, "col_npcinr", [Type.Register], false, []), + new Opcode(0x90, "switch_on", [], false, [Type.U32]), + new Opcode(0x91, "switch_off", [], false, [Type.U32]), + new Opcode(0x92, "playbgm_epi", [], false, [Type.U32]), + new Opcode(0x93, "set_mainwarp", [], false, [Type.U32]), + new Opcode(0x94, "set_obj_param", [Type.Register, Type.Register], false, []), + new Opcode(0x95, "set_floor_handler", [], false, [Type.U32, Type.U16]), + new Opcode(0x96, "clr_floor_handler", [], false, [Type.U32]), + new Opcode(0x97, "col_plinaw", [Type.Register], false, []), + new Opcode(0x98, "hud_hide", [], false, []), + new Opcode(0x99, "hud_show", [], false, []), + new Opcode(0x9a, "cine_enable", [], false, []), + new Opcode(0x9b, "cine_disable", [], false, []), + new Opcode(0x9c, "unknown", [], false, []), + new Opcode(0x9d, "unknown", [], false, []), + new Opcode(0x9e, "unknown", [], false, []), + new Opcode(0x9f, "unknown", [], false, []), + new Opcode(0xa0, "unknown", [], false, []), + new Opcode(0xa1, "set_qt_failure", [Type.U16], false, []), + new Opcode(0xa2, "set_qt_success", [Type.U16], false, []), + new Opcode(0xa3, "clr_qt_failure", [], false, []), + new Opcode(0xa4, "clr_qt_success", [], false, []), + new Opcode(0xa5, "set_qt_cancel", [Type.U16], false, []), + new Opcode(0xa6, "clr_qt_cancel", [], false, []), + new Opcode(0xa7, "unknown", [], false, []), + new Opcode(0xa8, "pl_walk_V3", [Type.Register], false, []), + new Opcode(0xa9, "unknown", [], false, []), + new Opcode(0xaa, "unknown", [], false, []), + new Opcode(0xab, "unknown", [], false, []), + new Opcode(0xac, "unknown", [], false, []), + new Opcode(0xad, "unknown", [], false, []), + new Opcode(0xae, "unknown", [], false, []), + new Opcode(0xaf, "unknown", [], false, []), + new Opcode(0xb0, "pl_add_meseta", [], false, [Type.U32, Type.U32]), + new Opcode(0xb1, "thread_stg", [Type.U16], false, []), + new Opcode(0xb2, "del_obj_param", [Type.Register], false, []), + new Opcode(0xb3, "item_create", [Type.Register, Type.Register], false, []), + new Opcode(0xb4, "item_create2", [Type.Register, Type.Register], false, []), + new Opcode(0xb5, "item_delete", [Type.Register, Type.Register], false, []), + new Opcode(0xb6, "item_delete2", [Type.Register, Type.Register], false, []), + new Opcode(0xb7, "item_check", [Type.Register, Type.Register], false, []), + new Opcode(0xb8, "setevt", [], false, [Type.U32]), + new Opcode(0xb9, "get_difflvl", [Type.Register], false, []), + new Opcode(0xba, "set_qt_exit", [Type.U16], false, []), + new Opcode(0xbb, "clr_qt_exit", [], false, []), + new Opcode(0xbc, "unknown", [], false, []), + new Opcode(0xbd, "unknown", [], false, []), + new Opcode(0xbe, "unknown", [], false, []), + new Opcode(0xbf, "unknown", [], false, []), + new Opcode(0xc0, "particle_V3", [Type.Register], false, []), + new Opcode(0xc1, "npc_text", [], false, [Type.U32, Type.String]), + new Opcode(0xc2, "npc_chkwarp", [], false, []), + new Opcode(0xc3, "pl_pkoff", [], false, []), + new Opcode(0xc4, "map_designate", [Type.Register], false, []), + new Opcode(0xc5, "masterkey_on", [], false, []), + new Opcode(0xc6, "masterkey_off", [], false, []), + new Opcode(0xc7, "window_time", [], false, []), + new Opcode(0xc8, "winend_time", [], false, []), + new Opcode(0xc9, "winset_time", [Type.Register], false, []), + new Opcode(0xca, "getmtime", [Type.Register], false, []), + new Opcode(0xcb, "set_quest_board_handler", [], false, [Type.U32, Type.U16, Type.String]), + new Opcode(0xcc, "clear_quest_board_handler", [], false, [Type.U32]), + new Opcode(0xcd, "particle_id_V3", [Type.Register], false, []), + new Opcode(0xce, "npc_crptalk_id_V3", [Type.Register], false, []), + new Opcode(0xcf, "npc_lang_clean", [], false, []), + new Opcode(0xd0, "pl_pkon", [], false, []), + new Opcode(0xd1, "pl_chk_item2", [Type.Register, Type.Register], false, []), + new Opcode(0xd2, "enable_mainmenu", [], false, []), + new Opcode(0xd3, "disable_mainmenu", [], false, []), + new Opcode(0xd4, "start_battlebgm", [], false, []), + new Opcode(0xd5, "end_battlebgm", [], false, []), + new Opcode(0xd6, "disp_msg_qb", [], false, [Type.String]), + new Opcode(0xd7, "close_msg_qb", [], false, []), + new Opcode(0xd8, "set_eventflag_v3", [], false, [Type.U32, Type.U32]), + new Opcode(0xd9, "sync_leti", [], false, []), + new Opcode(0xda, "set_returnhunter", [], false, []), + new Opcode(0xdb, "set_returncity", [], false, []), + new Opcode(0xdc, "load_pvr", [], false, []), + new Opcode(0xdd, "load_midi", [], false, []), + new Opcode(0xde, "unknown", [], false, []), + new Opcode(0xdf, "npc_param_V3", [], false, [Type.Register, Type.U32]), + new Opcode(0xe0, "pad_dragon", [], false, []), + new Opcode(0xe1, "clear_mainwarp", [], false, [Type.U32]), + new Opcode(0xe2, "pcam_param_V3", [Type.Register], false, []), + new Opcode(0xe3, "start_setevt_v3", [], false, [Type.Register, Type.U32]), + new Opcode(0xe4, "warp_on", [], false, []), + new Opcode(0xe5, "warp_off", [], false, []), + new Opcode(0xe6, "get_slotnumber", [Type.Register], false, []), + new Opcode(0xe7, "get_servernumber", [Type.Register], false, []), + new Opcode(0xe8, "set_eventflag2", [], false, [Type.U32, Type.Register]), + new Opcode(0xe9, "res", [Type.Register, Type.Register], false, []), + new Opcode(0xea, "unknownEA", [Type.Register, Type.U32], false, []), + new Opcode(0xeb, "enable_bgmctrl", [], false, [Type.U32]), + new Opcode(0xec, "sw_send", [Type.Register], false, []), + new Opcode(0xed, "create_bgmctrl", [], false, []), + new Opcode(0xee, "pl_add_meseta2", [], false, [Type.U32]), + new Opcode(0xef, "sync_register", [], false, [Type.Register, Type.U32]), + new Opcode(0xf0, "send_regwork", [], false, []), + new Opcode(0xf1, "leti_fixed_camera_V3", [Type.Register], false, []), + new Opcode(0xf2, "default_camera_pos1", [], false, []), + new Opcode(0xf3, "unknown", [], false, []), + new Opcode(0xf4, "unknown", [], false, []), + new Opcode(0xf5, "unknown", [], false, []), + new Opcode(0xf6, "unknown", [], false, []), + new Opcode(0xf7, "unknown", [], false, []), + new Opcode(0xf8, "unknownF8", [Type.Register], false, []), + new Opcode(0xf9, "unknown", [], false, []), + new Opcode(0xfa, "get_gc_number", [Type.Register], false, []), + new Opcode(0xfb, "unknownFB", [Type.U16], false, []), + new Opcode(0xfc, "unknown", [], false, []), + new Opcode(0xfd, "unknown", [], false, []), + new Opcode(0xfe, "unknown", [], false, []), + new Opcode(0xff, "unknownFF", [], false, []), ]; -const f8_opcode_list: [number, string, string | null][] = [ - [0x00, "unknown", null], - [0x01, "set_chat_callback?", "aRs"], - [0x02, "unknown", null], - [0x03, "unknown", null], - [0x04, "unknown", null], - [0x05, "unknown", null], - [0x06, "unknown", null], - [0x07, "unknown", null], - [0x08, "get_difficulty_level2", "R"], - [0x09, "get_number_of_player1", "R"], - [0x0a, "get_coord_of_player", "RR"], - [0x0b, "unknownF80B", ""], - [0x0c, "unknownF80C", ""], - [0x0d, "map_designate_ex", "R"], - [0x0e, "unknownF80E", "aL"], - [0x0f, "unknownF80F", "aL"], - [0x10, "ba_initial_floor", "aL"], - [0x11, "set_ba_rules", ""], - [0x12, "unknownF812", "aL"], - [0x13, "unknownF813", "aL"], - [0x14, "unknownF814", "aL"], - [0x15, "unknownF815", "aL"], - [0x16, "unknownF816", "aL"], - [0x17, "unknownF817", "aL"], - [0x18, "unknownF818", "aL"], - [0x19, "unknownF819", "aL"], - [0x1a, "unknownF81A", "aL"], - [0x1b, "unknownF81B", "aL"], - [0x1c, "ba_disp_msg", "as"], - [0x1d, "death_lvl_up", "aL"], - [0x1e, "death_tech_lvl_up", "aL"], - [0x1f, "unknown", null], - [0x20, "cmode_stage", "aL"], - [0x21, "unknown", null], - [0x22, "unknown", null], - [0x23, "unknownF823", "aL"], - [0x24, "unknownF824", "aL"], - [0x25, "exp_multiplication", "R"], - [0x26, "exp_division?", "R"], - [0x27, "get_user_is_dead?", "R"], - [0x28, "go_floor", "RR"], - [0x29, "unknown", null], - [0x2a, "unknown", null], - [0x2b, "unlock_door2", "aLL"], - [0x2c, "lock_door2", "aLL"], - [0x2d, "if_switch_not_pressed", "R"], - [0x2e, "if_switch_pressed", "R"], - [0x2f, "unknownF82F", "aLL"], - [0x30, "control_dragon", "R"], - [0x31, "release_dragon", ""], - [0x32, "unknown", null], - [0x33, "unknown", null], - [0x34, "unknown", null], - [0x35, "unknown", null], - [0x36, "unknown", null], - [0x37, "unknown", null], - [0x38, "shrink", "R"], - [0x39, "unshrink", "R"], - [0x3a, "unknown", null], - [0x3b, "unknown", null], - [0x3c, "display_clock2?", "R"], - [0x3d, "unknownF83D", "aL"], - [0x3e, "delete_area_title?", "aL"], - [0x3f, "unknown", null], - [0x40, "load_npc_data", ""], - [0x41, "get_npc_data", "W"], - [0x42, "unknown", null], - [0x43, "unknown", null], - [0x44, "unknown", null], - [0x45, "unknown", null], - [0x46, "unknown", null], - [0x47, "unknown", null], - [0x48, "give_damage_score", "R"], - [0x49, "take_damage_score", "R"], - [0x4a, "unk_score_F84A", "R"], - [0x4b, "unk_score_F84B", "R"], - [0x4c, "kill_score", "R"], - [0x4d, "death_score", "R"], - [0x4e, "unk_score_F84E", "R"], - [0x4f, "enemy_death_score", "R"], - [0x50, "meseta_score", "R"], - [0x51, "unknownF851", "R"], - [0x52, "unknownF852", "aL"], - [0x53, "reverse_warps", ""], - [0x54, "unreverse_warps", ""], - [0x55, "set_ult_map", ""], - [0x56, "unset_ult_map", ""], - [0x57, "set_area_title", "as"], - [0x58, "unknownF858", ""], - [0x59, "unknown", null], - [0x5a, "equip_item", "R"], - [0x5b, "unequip_item", "aLL"], - [0x5c, "unknown", null], - [0x5d, "unknown", null], - [0x5e, "unknownF85E", "aL"], - [0x5f, "unknownF85F", "aL"], - [0x60, "unknownF860", ""], - [0x61, "unknownF861", "aL"], - [0x62, "unknown", null], - [0x63, "unknown", null], - [0x64, "cmode_rank", "aLs"], - [0x65, "award_item_name?", ""], - [0x66, "award_item_select?", ""], - [0x67, "award_item_give_to?", "R"], - [0x68, "unknownF868", "RR"], - [0x69, "unknownF869", "RR"], - [0x6a, "item_create_cmode", "RR"], - [0x6b, "unknownF86B", "R"], - [0x6c, "award_item_ok?", "R"], - [0x6d, "unknownF86D", ""], - [0x6e, "unknownF86E", ""], - [0x6f, "ba_set_lives", "aL"], - [0x70, "ba_set_tech_lvl", "aL"], - [0x71, "ba_set_lvl", "aL"], - [0x72, "ba_set_time_limit", "aL"], - [0x73, "boss_is_dead?", "R"], - [0x74, "unknown", null], - [0x75, "unknown", null], - [0x76, "unknown", null], - [0x77, "enable_techs", "R"], - [0x78, "disable_techs", "R"], - [0x79, "get_gender", "RR"], - [0x7a, "get_chara_class", "RR"], - [0x7b, "take_slot_meseta", "RR"], - [0x7c, "unknown", null], - [0x7d, "unknown", null], - [0x7e, "unknown", null], - [0x7f, "read_guildcard_flag", "RR"], - [0x80, "unknownF880", "R"], - [0x81, "get_pl_name?", "R"], - [0x82, "unknown", null], - [0x83, "unknownF883", "RR"], - [0x84, "unknown", null], - [0x85, "unknown", null], - [0x86, "unknown", null], - [0x87, "unknown", null], - [0x88, "ba_close_msg", ""], - [0x89, "unknown", null], - [0x8a, "get_player_status", "RR"], - [0x8b, "send_mail", "aRs"], - [0x8c, "online_check", "R"], - [0x8d, "chl_set_timerecord?", "R"], - [0x8e, "chl_get_timerecord?", "R"], - [0x8f, "unknownF88F", "R"], - [0x90, "unknownF890", ""], - [0x91, "load_enemy_data", "aL"], - [0x92, "get_physical_data", "W"], - [0x93, "get_attack_data", "W"], - [0x94, "get_resist_data", "W"], - [0x95, "get_movement_data", "W"], - [0x96, "unknown", null], - [0x97, "unknown", null], - [0x98, "shift_left", "RR"], - [0x99, "shift_right", "RR"], - [0x9a, "get_random", "RR"], - [0x9b, "reset_map", ""], - [0x9c, "disp_chl_retry_menu", "R"], - [0x9d, "chl_reverser?", ""], - [0x9e, "unknownF89E", "aL"], - [0x9f, "unknownF89F", "R"], - [0xa0, "unknownF8A0", ""], - [0xa1, "unknownF8A1", ""], - [0xa2, "unknown", null], - [0xa3, "unknown", null], - [0xa4, "unknown", null], - [0xa5, "unknown", null], - [0xa6, "unknown", null], - [0xa7, "unknown", null], - [0xa8, "unknownF8A8", "aL"], - [0xa9, "unknownF8A9", "R"], - [0xaa, "unknown", null], - [0xab, "unknown", null], - [0xac, "unknown", null], - [0xad, "get_number_of_player2", "R"], - [0xae, "unknown", null], - [0xaf, "unknown", null], - [0xb0, "unknown", null], - [0xb1, "unknown", null], - [0xb2, "unknown", null], - [0xb3, "unknown", null], - [0xb4, "unknown", null], - [0xb5, "unknown", null], - [0xb6, "unknown", null], - [0xb7, "unknown", null], - [0xb8, "unknownF8B8", ""], - [0xb9, "chl_recovery?", ""], - [0xba, "unknown", null], - [0xbb, "unknown", null], - [0xbc, "set_episode", "L"], - [0xbd, "unknown", null], - [0xbe, "unknown", null], - [0xbf, "unknown", null], - [0xc0, "file_dl_req", "aLs"], - [0xc1, "get_dl_status", "R"], - [0xc2, "gba_unknown4?", ""], - [0xc3, "get_gba_state?", "R"], - [0xc4, "unknownF8C4", "R"], - [0xc5, "unknownF8C5", "R"], - [0xc6, "QEXIT", ""], - [0xc7, "use_animation", "RR"], - [0xc8, "stop_animation", "R"], - [0xc9, "run_to_coord", "RR"], - [0xca, "set_slot_invincible", "RR"], - [0xcb, "unknownF8CB", "R"], - [0xcc, "set_slot_poison", "R"], - [0xcd, "set_slot_paralyze", "R"], - [0xce, "set_slot_shock", "R"], - [0xcf, "set_slot_freeze", "R"], - [0xd0, "set_slot_slow", "R"], - [0xd1, "set_slot_confuse", "R"], - [0xd2, "set_slot_shifta", "R"], - [0xd3, "set_slot_deband", "R"], - [0xd4, "set_slot_jellen", "R"], - [0xd5, "set_slot_zalure", "R"], - [0xd6, "fleti_fixed_camera", "aR"], - [0xd7, "fleti_locked_camera", "aLR"], - [0xd8, "default_camera_pos2", ""], - [0xd9, "set_motion_blur", ""], - [0xda, "set_screen_b&w", ""], - [0xdb, "unknownF8DB", "aLLLLRW"], - [0xdc, "NPC_action_string", "RRW"], - [0xdd, "get_pad_cond", "RR"], - [0xde, "get_button_cond", "RR"], - [0xdf, "freeze_enemies", ""], - [0xe0, "unfreeze_enemies", ""], - [0xe1, "freeze_everything", ""], - [0xe2, "unfreeze_everything", ""], - [0xe3, "restore_hp", "R"], - [0xe4, "restore_tp", "R"], - [0xe5, "close_chat_bubble", "R"], - [0xe6, "unknownF8E6", "RR"], - [0xe7, "unknownF8E7", "RR"], - [0xe8, "unknownF8E8", "RR"], - [0xe9, "unknownF8E9", "RR"], - [0xea, "unknownF8EA", "RR"], - [0xeb, "unknownF8EB", "RR"], - [0xec, "unknownF8EC", "RR"], - [0xed, "animation_check", "RR"], - [0xee, "call_image_data", "aLW"], - [0xef, "unknownF8EF", ""], - [0xf0, "turn_off_bgm_p2", ""], - [0xf1, "turn_on_bgm_p2", ""], - [0xf2, "load_unk_data", "aLLLLRW"], - [0xf3, "particle2", "aRLf"], - [0xf4, "unknown", null], - [0xf5, "unknown", null], - [0xf6, "unknown", null], - [0xf7, "unknown", null], - [0xf8, "unknown", null], - [0xf9, "unknown", null], - [0xfa, "unknown", null], - [0xfb, "unknown", null], - [0xfc, "unknown", null], - [0xfd, "unknown", null], - [0xfe, "unknown", null], - [0xff, "unknown", null], +const f8_opcodes = [ + new Opcode(0x00f8, "unknown", [], false, []), + new Opcode(0x01f8, "set_chat_callback?", [], false, [Type.Register, Type.String]), + new Opcode(0x02f8, "unknown", [], false, []), + new Opcode(0x03f8, "unknown", [], false, []), + new Opcode(0x04f8, "unknown", [], false, []), + new Opcode(0x05f8, "unknown", [], false, []), + new Opcode(0x06f8, "unknown", [], false, []), + new Opcode(0x07f8, "unknown", [], false, []), + new Opcode(0x08f8, "get_difficulty_level2", [Type.Register], false, []), + new Opcode(0x09f8, "get_number_of_player1", [Type.Register], false, []), + new Opcode(0x0af8, "get_coord_of_player", [Type.Register, Type.Register], false, []), + new Opcode(0x0bf8, "unknownF80B", [], false, []), + new Opcode(0x0cf8, "unknownF80C", [], false, []), + new Opcode(0x0df8, "map_designate_ex", [Type.Register], false, []), + new Opcode(0x0ef8, "unknownF80E", [], false, [Type.U32]), + new Opcode(0x0ff8, "unknownF80F", [], false, [Type.U32]), + new Opcode(0x10f8, "ba_initial_floor", [], false, [Type.U32]), + new Opcode(0x11f8, "set_ba_rules", [], false, []), + new Opcode(0x12f8, "unknownF812", [], false, [Type.U32]), + new Opcode(0x13f8, "unknownF813", [], false, [Type.U32]), + new Opcode(0x14f8, "unknownF814", [], false, [Type.U32]), + new Opcode(0x15f8, "unknownF815", [], false, [Type.U32]), + new Opcode(0x16f8, "unknownF816", [], false, [Type.U32]), + new Opcode(0x17f8, "unknownF817", [], false, [Type.U32]), + new Opcode(0x18f8, "unknownF818", [], false, [Type.U32]), + new Opcode(0x19f8, "unknownF819", [], false, [Type.U32]), + new Opcode(0x1af8, "unknownF81A", [], false, [Type.U32]), + new Opcode(0x1bf8, "unknownF81B", [], false, [Type.U32]), + new Opcode(0x1cf8, "ba_disp_msg", [], false, [Type.String]), + new Opcode(0x1df8, "death_lvl_up", [], false, [Type.U32]), + new Opcode(0x1ef8, "death_tech_lvl_up", [], false, [Type.U32]), + new Opcode(0x1ff8, "unknown", [], false, []), + new Opcode(0x20f8, "cmode_stage", [], false, [Type.U32]), + new Opcode(0x21f8, "unknown", [], false, []), + new Opcode(0x22f8, "unknown", [], false, []), + new Opcode(0x23f8, "unknownF823", [], false, [Type.U32]), + new Opcode(0x24f8, "unknownF824", [], false, [Type.U32]), + new Opcode(0x25f8, "exp_multiplication", [Type.Register], false, []), + new Opcode(0x26f8, "exp_division?", [Type.Register], false, []), + new Opcode(0x27f8, "get_user_is_dead?", [Type.Register], false, []), + new Opcode(0x28f8, "go_floor", [Type.Register, Type.Register], false, []), + new Opcode(0x29f8, "unknown", [], false, []), + new Opcode(0x2af8, "unknown", [], false, []), + new Opcode(0x2bf8, "unlock_door2", [], false, [Type.U32, Type.U32]), + new Opcode(0x2cf8, "lock_door2", [], false, [Type.U32, Type.U32]), + new Opcode(0x2df8, "if_switch_not_pressed", [Type.Register], false, []), + new Opcode(0x2ef8, "if_switch_pressed", [Type.Register], false, []), + new Opcode(0x2ff8, "unknownF82F", [], false, [Type.U32, Type.U32]), + new Opcode(0x30f8, "control_dragon", [Type.Register], false, []), + new Opcode(0x31f8, "release_dragon", [], false, []), + new Opcode(0x32f8, "unknown", [], false, []), + new Opcode(0x33f8, "unknown", [], false, []), + new Opcode(0x34f8, "unknown", [], false, []), + new Opcode(0x35f8, "unknown", [], false, []), + new Opcode(0x36f8, "unknown", [], false, []), + new Opcode(0x37f8, "unknown", [], false, []), + new Opcode(0x38f8, "shrink", [Type.Register], false, []), + new Opcode(0x39f8, "unshrink", [Type.Register], false, []), + new Opcode(0x3af8, "unknown", [], false, []), + new Opcode(0x3bf8, "unknown", [], false, []), + new Opcode(0x3cf8, "display_clock2?", [Type.Register], false, []), + new Opcode(0x3df8, "unknownF83D", [], false, [Type.U32]), + new Opcode(0x3ef8, "delete_area_title?", [], false, [Type.U32]), + new Opcode(0x3ff8, "unknown", [], false, []), + new Opcode(0x40f8, "load_npc_data", [], false, []), + new Opcode(0x41f8, "get_npc_data", [Type.U16], false, []), + new Opcode(0x42f8, "unknown", [], false, []), + new Opcode(0x43f8, "unknown", [], false, []), + new Opcode(0x44f8, "unknown", [], false, []), + new Opcode(0x45f8, "unknown", [], false, []), + new Opcode(0x46f8, "unknown", [], false, []), + new Opcode(0x47f8, "unknown", [], false, []), + new Opcode(0x48f8, "give_damage_score", [Type.Register], false, []), + new Opcode(0x49f8, "take_damage_score", [Type.Register], false, []), + new Opcode(0x4af8, "unk_score_F84A", [Type.Register], false, []), + new Opcode(0x4bf8, "unk_score_F84B", [Type.Register], false, []), + new Opcode(0x4cf8, "kill_score", [Type.Register], false, []), + new Opcode(0x4df8, "death_score", [Type.Register], false, []), + new Opcode(0x4ef8, "unk_score_F84E", [Type.Register], false, []), + new Opcode(0x4ff8, "enemy_death_score", [Type.Register], false, []), + new Opcode(0x50f8, "meseta_score", [Type.Register], false, []), + new Opcode(0x51f8, "unknownF851", [Type.Register], false, []), + new Opcode(0x52f8, "unknownF852", [], false, [Type.U32]), + new Opcode(0x53f8, "reverse_warps", [], false, []), + new Opcode(0x54f8, "unreverse_warps", [], false, []), + new Opcode(0x55f8, "set_ult_map", [], false, []), + new Opcode(0x56f8, "unset_ult_map", [], false, []), + new Opcode(0x57f8, "set_area_title", [], false, [Type.String]), + new Opcode(0x58f8, "unknownF858", [], false, []), + new Opcode(0x59f8, "unknown", [], false, []), + new Opcode(0x5af8, "equip_item", [Type.Register], false, []), + new Opcode(0x5bf8, "unequip_item", [], false, [Type.U32, Type.U32]), + new Opcode(0x5cf8, "unknown", [], false, []), + new Opcode(0x5df8, "unknown", [], false, []), + new Opcode(0x5ef8, "unknownF85E", [], false, [Type.U32]), + new Opcode(0x5ff8, "unknownF85F", [], false, [Type.U32]), + new Opcode(0x60f8, "unknownF860", [], false, []), + new Opcode(0x61f8, "unknownF861", [], false, [Type.U32]), + new Opcode(0x62f8, "unknown", [], false, []), + new Opcode(0x63f8, "unknown", [], false, []), + new Opcode(0x64f8, "cmode_rank", [], false, [Type.U32, Type.String]), + new Opcode(0x65f8, "award_item_name?", [], false, []), + new Opcode(0x66f8, "award_item_select?", [], false, []), + new Opcode(0x67f8, "award_item_give_to?", [Type.Register], false, []), + new Opcode(0x68f8, "unknownF868", [Type.Register, Type.Register], false, []), + new Opcode(0x69f8, "unknownF869", [Type.Register, Type.Register], false, []), + new Opcode(0x6af8, "item_create_cmode", [Type.Register, Type.Register], false, []), + new Opcode(0x6bf8, "unknownF86B", [Type.Register], false, []), + new Opcode(0x6cf8, "award_item_ok?", [Type.Register], false, []), + new Opcode(0x6df8, "unknownF86D", [], false, []), + new Opcode(0x6ef8, "unknownF86E", [], false, []), + new Opcode(0x6ff8, "ba_set_lives", [], false, [Type.U32]), + new Opcode(0x70f8, "ba_set_tech_lvl", [], false, [Type.U32]), + new Opcode(0x71f8, "ba_set_lvl", [], false, [Type.U32]), + new Opcode(0x72f8, "ba_set_time_limit", [], false, [Type.U32]), + new Opcode(0x73f8, "boss_is_dead?", [Type.Register], false, []), + new Opcode(0x74f8, "unknown", [], false, []), + new Opcode(0x75f8, "unknown", [], false, []), + new Opcode(0x76f8, "unknown", [], false, []), + new Opcode(0x77f8, "enable_techs", [Type.Register], false, []), + new Opcode(0x78f8, "disable_techs", [Type.Register], false, []), + new Opcode(0x79f8, "get_gender", [Type.Register, Type.Register], false, []), + new Opcode(0x7af8, "get_chara_class", [Type.Register, Type.Register], false, []), + new Opcode(0x7bf8, "take_slot_meseta", [Type.Register, Type.Register], false, []), + new Opcode(0x7cf8, "unknown", [], false, []), + new Opcode(0x7df8, "unknown", [], false, []), + new Opcode(0x7ef8, "unknown", [], false, []), + new Opcode(0x7ff8, "read_guildcard_flag", [Type.Register, Type.Register], false, []), + new Opcode(0x80f8, "unknownF880", [Type.Register], false, []), + new Opcode(0x81f8, "get_pl_name?", [Type.Register], false, []), + new Opcode(0x82f8, "unknown", [], false, []), + new Opcode(0x83f8, "unknownF883", [Type.Register, Type.Register], false, []), + new Opcode(0x84f8, "unknown", [], false, []), + new Opcode(0x85f8, "unknown", [], false, []), + new Opcode(0x86f8, "unknown", [], false, []), + new Opcode(0x87f8, "unknown", [], false, []), + new Opcode(0x88f8, "ba_close_msg", [], false, []), + new Opcode(0x89f8, "unknown", [], false, []), + new Opcode(0x8af8, "get_player_status", [Type.Register, Type.Register], false, []), + new Opcode(0x8bf8, "send_mail", [], false, [Type.Register, Type.String]), + new Opcode(0x8cf8, "online_check", [Type.Register], false, []), + new Opcode(0x8df8, "chl_set_timerecord?", [Type.Register], false, []), + new Opcode(0x8ef8, "chl_get_timerecord?", [Type.Register], false, []), + new Opcode(0x8ff8, "unknownF88F", [Type.Register], false, []), + new Opcode(0x90f8, "unknownF890", [], false, []), + new Opcode(0x91f8, "load_enemy_data", [], false, [Type.U32]), + new Opcode(0x92f8, "get_physical_data", [Type.U16], false, []), + new Opcode(0x93f8, "get_attack_data", [Type.U16], false, []), + new Opcode(0x94f8, "get_resist_data", [Type.U16], false, []), + new Opcode(0x95f8, "get_movement_data", [Type.U16], false, []), + new Opcode(0x96f8, "unknown", [], false, []), + new Opcode(0x97f8, "unknown", [], false, []), + new Opcode(0x98f8, "shift_left", [Type.Register, Type.Register], false, []), + new Opcode(0x99f8, "shift_right", [Type.Register, Type.Register], false, []), + new Opcode(0x9af8, "get_random", [Type.Register, Type.Register], false, []), + new Opcode(0x9bf8, "reset_map", [], false, []), + new Opcode(0x9cf8, "disp_chl_retry_menu", [Type.Register], false, []), + new Opcode(0x9df8, "chl_reverser?", [], false, []), + new Opcode(0x9ef8, "unknownF89E", [], false, [Type.U32]), + new Opcode(0x9ff8, "unknownF89F", [Type.Register], false, []), + new Opcode(0xa0f8, "unknownF8A0", [], false, []), + new Opcode(0xa1f8, "unknownF8A1", [], false, []), + new Opcode(0xa2f8, "unknown", [], false, []), + new Opcode(0xa3f8, "unknown", [], false, []), + new Opcode(0xa4f8, "unknown", [], false, []), + new Opcode(0xa5f8, "unknown", [], false, []), + new Opcode(0xa6f8, "unknown", [], false, []), + new Opcode(0xa7f8, "unknown", [], false, []), + new Opcode(0xa8f8, "unknownF8A8", [], false, [Type.U32]), + new Opcode(0xa9f8, "unknownF8A9", [Type.Register], false, []), + new Opcode(0xaaf8, "unknown", [], false, []), + new Opcode(0xabf8, "unknown", [], false, []), + new Opcode(0xacf8, "unknown", [], false, []), + new Opcode(0xadf8, "get_number_of_player2", [Type.Register], false, []), + new Opcode(0xaef8, "unknown", [], false, []), + new Opcode(0xaff8, "unknown", [], false, []), + new Opcode(0xb0f8, "unknown", [], false, []), + new Opcode(0xb1f8, "unknown", [], false, []), + new Opcode(0xb2f8, "unknown", [], false, []), + new Opcode(0xb3f8, "unknown", [], false, []), + new Opcode(0xb4f8, "unknown", [], false, []), + new Opcode(0xb5f8, "unknown", [], false, []), + new Opcode(0xb6f8, "unknown", [], false, []), + new Opcode(0xb7f8, "unknown", [], false, []), + new Opcode(0xb8f8, "unknownF8B8", [], false, []), + new Opcode(0xb9f8, "chl_recovery?", [], false, []), + new Opcode(0xbaf8, "unknown", [], false, []), + new Opcode(0xbbf8, "unknown", [], false, []), + new Opcode(0xbcf8, "set_episode", [Type.U32], false, []), + new Opcode(0xbdf8, "unknown", [], false, []), + new Opcode(0xbef8, "unknown", [], false, []), + new Opcode(0xbff8, "unknown", [], false, []), + new Opcode(0xc0f8, "file_dl_req", [], false, [Type.U32, Type.String]), + new Opcode(0xc1f8, "get_dl_status", [Type.Register], false, []), + new Opcode(0xc2f8, "gba_unknown4?", [], false, []), + new Opcode(0xc3f8, "get_gba_state?", [Type.Register], false, []), + new Opcode(0xc4f8, "unknownF8C4", [Type.Register], false, []), + new Opcode(0xc5f8, "unknownF8C5", [Type.Register], false, []), + new Opcode(0xc6f8, "QEXIT", [], false, []), + new Opcode(0xc7f8, "use_animation", [Type.Register, Type.Register], false, []), + new Opcode(0xc8f8, "stop_animation", [Type.Register], false, []), + new Opcode(0xc9f8, "run_to_coord", [Type.Register, Type.Register], false, []), + new Opcode(0xcaf8, "set_slot_invincible", [Type.Register, Type.Register], false, []), + new Opcode(0xcbf8, "unknownF8CB", [Type.Register], false, []), + new Opcode(0xccf8, "set_slot_poison", [Type.Register], false, []), + new Opcode(0xcdf8, "set_slot_paralyze", [Type.Register], false, []), + new Opcode(0xcef8, "set_slot_shock", [Type.Register], false, []), + new Opcode(0xcff8, "set_slot_freeze", [Type.Register], false, []), + new Opcode(0xd0f8, "set_slot_slow", [Type.Register], false, []), + new Opcode(0xd1f8, "set_slot_confuse", [Type.Register], false, []), + new Opcode(0xd2f8, "set_slot_shifta", [Type.Register], false, []), + new Opcode(0xd3f8, "set_slot_deband", [Type.Register], false, []), + new Opcode(0xd4f8, "set_slot_jellen", [Type.Register], false, []), + new Opcode(0xd5f8, "set_slot_zalure", [Type.Register], false, []), + new Opcode(0xd6f8, "fleti_fixed_camera", [], false, [Type.Register]), + new Opcode(0xd7f8, "fleti_locked_camera", [], false, [Type.U32, Type.Register]), + new Opcode(0xd8f8, "default_camera_pos2", [], false, []), + new Opcode(0xd9f8, "set_motion_blur", [], false, []), + new Opcode(0xdaf8, "set_screen_b&w", [], false, []), + new Opcode(0xdbf8, "unknownF8DB", [], false, [ + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.Register, + Type.U16, + ]), + new Opcode(0xdcf8, "NPC_action_string", [Type.Register, Type.Register, Type.U16], false, []), + new Opcode(0xddf8, "get_pad_cond", [Type.Register, Type.Register], false, []), + new Opcode(0xdef8, "get_button_cond", [Type.Register, Type.Register], false, []), + new Opcode(0xdff8, "freeze_enemies", [], false, []), + new Opcode(0xe0f8, "unfreeze_enemies", [], false, []), + new Opcode(0xe1f8, "freeze_everything", [], false, []), + new Opcode(0xe2f8, "unfreeze_everything", [], false, []), + new Opcode(0xe3f8, "restore_hp", [Type.Register], false, []), + new Opcode(0xe4f8, "restore_tp", [Type.Register], false, []), + new Opcode(0xe5f8, "close_chat_bubble", [Type.Register], false, []), + new Opcode(0xe6f8, "unknownF8E6", [Type.Register, Type.Register], false, []), + new Opcode(0xe7f8, "unknownF8E7", [Type.Register, Type.Register], false, []), + new Opcode(0xe8f8, "unknownF8E8", [Type.Register, Type.Register], false, []), + new Opcode(0xe9f8, "unknownF8E9", [Type.Register, Type.Register], false, []), + new Opcode(0xeaf8, "unknownF8EA", [Type.Register, Type.Register], false, []), + new Opcode(0xebf8, "unknownF8EB", [Type.Register, Type.Register], false, []), + new Opcode(0xecf8, "unknownF8EC", [Type.Register, Type.Register], false, []), + new Opcode(0xedf8, "animation_check", [Type.Register, Type.Register], false, []), + new Opcode(0xeef8, "call_image_data", [], false, [Type.U32, Type.U16]), + new Opcode(0xeff8, "unknownF8EF", [], false, []), + new Opcode(0xf0f8, "turn_off_bgm_p2", [], false, []), + new Opcode(0xf1f8, "turn_on_bgm_p2", [], false, []), + new Opcode(0xf2f8, "load_unk_data", [], false, [ + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.Register, + Type.U16, + ]), + new Opcode(0xf3f8, "particle2", [], false, [Type.Register, Type.U32, Type.F32]), + new Opcode(0xf4f8, "unknown", [], false, []), + new Opcode(0xf5f8, "unknown", [], false, []), + new Opcode(0xf6f8, "unknown", [], false, []), + new Opcode(0xf7f8, "unknown", [], false, []), + new Opcode(0xf8f8, "unknown", [], false, []), + new Opcode(0xf9f8, "unknown", [], false, []), + new Opcode(0xfaf8, "unknown", [], false, []), + new Opcode(0xfbf8, "unknown", [], false, []), + new Opcode(0xfcf8, "unknown", [], false, []), + new Opcode(0xfdf8, "unknown", [], false, []), + new Opcode(0xfef8, "unknown", [], false, []), + new Opcode(0xfff8, "unknown", [], false, []), ]; -const f9_opcode_list: [number, string, string | null][] = [ - [0x00, "unknown", null], - [0x01, "dec2float", "RR"], - [0x02, "float2dec", "RR"], - [0x03, "flet", "RR"], - [0x04, "fleti", "RF"], - [0x05, "unknown", null], - [0x06, "unknown", null], - [0x07, "unknown", null], - [0x08, "fadd", "RR"], - [0x09, "faddi", "RF"], - [0x0a, "fsub", "RR"], - [0x0b, "fsubi", "RF"], - [0x0c, "fmul", "RR"], - [0x0d, "fmuli", "RF"], - [0x0e, "fdiv", "RR"], - [0x0f, "fdivi", "RF"], - [0x10, "get_unknown_count?", "aLR"], - [0x11, "get_stackable_item_count", "RR"], - [0x12, "freeze_and_hide_equip", ""], - [0x13, "thaw_and_show_equip", ""], - [0x14, "set_paletteX_callback", "aRW"], - [0x15, "activate_paletteX", "aR"], - [0x16, "enable_paletteX", "aR"], - [0x17, "restore_paletteX", "aL"], - [0x18, "disable_paletteX", "aL"], - [0x19, "get_paletteX_activated", "aLR"], - [0x1a, "get_unknown_paletteX_status?", "aLR"], - [0x1b, "disable_movement2", "aR"], - [0x1c, "enable_movement2", "aR"], - [0x1d, "get_time_played", "R"], - [0x1e, "get_guildcard_total", "R"], - [0x1f, "get_slot_meseta", "R"], - [0x20, "get_player_level", "aLR"], - [0x21, "get_Section_ID", "aLR"], - [0x22, "get_player_hp", "aRR"], - [0x23, "get_floor_number", "aRR"], - [0x24, "get_coord_player_detect", "RR"], - [0x25, "read_global_flag", "abR"], - [0x26, "write_global_flag", "abR"], - [0x27, "unknownF927", "RR"], - [0x28, "floor_player_detect", "R"], - [0x29, "read_disk_file?", "as"], - [0x2a, "open_pack_select", ""], - [0x2b, "item_select", "R"], - [0x2c, "get_item_id", "R"], - [0x2d, "color_change", "aRRRRR"], - [0x2e, "send_statistic?", "aLLLLLLLL"], - [0x2f, "unknownF92F", "aLL"], - [0x30, "chat_box", "aLLLLLs"], - [0x31, "chat_bubble", "aLs"], - [0x32, "unknown", null], - [0x33, "unknownF933", "R"], - [0x34, "scroll_text", "aLLLLLfRs"], - [0x35, "gba_unknown1", ""], - [0x36, "gba_unknown2", ""], - [0x37, "gba_unknown3", ""], - [0x38, "add_damage_to?", "aLL"], - [0x39, "item_delete2", "aL"], - [0x3a, "get_item_info", "aLR"], - [0x3b, "item_packing1", "aL"], - [0x3c, "item_packing2", "aLL"], - [0x3d, "get_lang_setting?", "aR"], - [0x3e, "prepare_statistic?", "aLWW"], - [0x3f, "keyword_detect", ""], - [0x40, "Keyword", "aRLs"], - [0x41, "get_guildcard_num", "aLR"], - [0x42, "unknown", null], - [0x43, "unknown", null], - [0x44, "get_wrap_status", "aLR"], - [0x45, "initial_floor", "aL"], - [0x46, "sin", "aRL"], - [0x47, "cos", "aRL"], - [0x48, "unknown", null], - [0x49, "unknown", null], - [0x4a, "boss_is_dead2?", "R"], - [0x4b, "unknownF94B", "R"], - [0x4c, "unknownF94C", "R"], - [0x4d, "is_there_cardbattle", "R"], - [0x4e, "unknown", null], - [0x4f, "unknown", null], - [0x50, "BB_p2_menu", "aL"], - [0x51, "BB_Map_Designate", "BWBB"], - [0x52, "BB_get_number_in_pack", "R"], - [0x53, "BB_swap_item", "aLLLLLLWW"], - [0x54, "BB_check_wrap", "aRR"], - [0x55, "BB_exchange_PD_item", "aRRRWW"], - [0x56, "BB_exchange_PD_srank", "aRRRRRWW"], - [0x57, "BB_exchange_PD_special", "aRRRRRLWW"], - [0x58, "BB_exchange_PD_percent", "aRRRRRLWW"], - [0x59, "unknownF959", "aL"], - [0x5a, "unknown", null], - [0x5b, "unknown", null], - [0x5c, "BB_exchange_SLT", "aLRWW"], - [0x5d, "BB_exchange_PC", ""], - [0x5e, "BB_box_create_BP", "aLff"], - [0x5f, "BB_exchange_PT", "aRRLWW"], - [0x60, "unknownF960", "aL"], - [0x61, "unknownF961", ""], - [0x62, "unknown", null], - [0x63, "unknown", null], - [0x64, "unknown", null], - [0x65, "unknown", null], - [0x66, "unknown", null], - [0x67, "unknown", null], - [0x68, "unknown", null], - [0x69, "unknown", null], - [0x6a, "unknown", null], - [0x6b, "unknown", null], - [0x6c, "unknown", null], - [0x6d, "unknown", null], - [0x6e, "unknown", null], - [0x6f, "unknown", null], - [0x70, "unknown", null], - [0x71, "unknown", null], - [0x72, "unknown", null], - [0x73, "unknown", null], - [0x74, "unknown", null], - [0x75, "unknown", null], - [0x76, "unknown", null], - [0x77, "unknown", null], - [0x78, "unknown", null], - [0x79, "unknown", null], - [0x7a, "unknown", null], - [0x7b, "unknown", null], - [0x7c, "unknown", null], - [0x7d, "unknown", null], - [0x7e, "unknown", null], - [0x7f, "unknown", null], - [0x80, "unknown", null], - [0x81, "unknown", null], - [0x82, "unknown", null], - [0x83, "unknown", null], - [0x84, "unknown", null], - [0x85, "unknown", null], - [0x86, "unknown", null], - [0x87, "unknown", null], - [0x88, "unknown", null], - [0x89, "unknown", null], - [0x8a, "unknown", null], - [0x8b, "unknown", null], - [0x8c, "unknown", null], - [0x8d, "unknown", null], - [0x8e, "unknown", null], - [0x8f, "unknown", null], - [0x90, "unknown", null], - [0x91, "unknown", null], - [0x92, "unknown", null], - [0x93, "unknown", null], - [0x94, "unknown", null], - [0x95, "unknown", null], - [0x96, "unknown", null], - [0x97, "unknown", null], - [0x98, "unknown", null], - [0x99, "unknown", null], - [0x9a, "unknown", null], - [0x9b, "unknown", null], - [0x9c, "unknown", null], - [0x9d, "unknown", null], - [0x9e, "unknown", null], - [0x9f, "unknown", null], - [0xa0, "unknown", null], - [0xa1, "unknown", null], - [0xa2, "unknown", null], - [0xa3, "unknown", null], - [0xa4, "unknown", null], - [0xa5, "unknown", null], - [0xa6, "unknown", null], - [0xa7, "unknown", null], - [0xa8, "unknown", null], - [0xa9, "unknown", null], - [0xaa, "unknown", null], - [0xab, "unknown", null], - [0xac, "unknown", null], - [0xad, "unknown", null], - [0xae, "unknown", null], - [0xaf, "unknown", null], - [0xb0, "unknown", null], - [0xb1, "unknown", null], - [0xb2, "unknown", null], - [0xb3, "unknown", null], - [0xb4, "unknown", null], - [0xb5, "unknown", null], - [0xb6, "unknown", null], - [0xb7, "unknown", null], - [0xb8, "unknown", null], - [0xb9, "unknown", null], - [0xba, "unknown", null], - [0xbb, "unknown", null], - [0xbc, "unknown", null], - [0xbd, "unknown", null], - [0xbe, "unknown", null], - [0xbf, "unknown", null], - [0xc0, "unknown", null], - [0xc1, "unknown", null], - [0xc2, "unknown", null], - [0xc3, "unknown", null], - [0xc4, "unknown", null], - [0xc5, "unknown", null], - [0xc6, "unknown", null], - [0xc7, "unknown", null], - [0xc8, "unknown", null], - [0xc9, "unknown", null], - [0xca, "unknown", null], - [0xcb, "unknown", null], - [0xcc, "unknown", null], - [0xcd, "unknown", null], - [0xce, "unknown", null], - [0xcf, "unknown", null], - [0xd0, "unknown", null], - [0xd1, "unknown", null], - [0xd2, "unknown", null], - [0xd3, "unknown", null], - [0xd4, "unknown", null], - [0xd5, "unknown", null], - [0xd6, "unknown", null], - [0xd7, "unknown", null], - [0xd8, "unknown", null], - [0xd9, "unknown", null], - [0xda, "unknown", null], - [0xdb, "unknown", null], - [0xdc, "unknown", null], - [0xdd, "unknown", null], - [0xde, "unknown", null], - [0xdf, "unknown", null], - [0xe0, "unknown", null], - [0xe1, "unknown", null], - [0xe2, "unknown", null], - [0xe3, "unknown", null], - [0xe4, "unknown", null], - [0xe5, "unknown", null], - [0xe6, "unknown", null], - [0xe7, "unknown", null], - [0xe8, "unknown", null], - [0xe9, "unknown", null], - [0xea, "unknown", null], - [0xeb, "unknown", null], - [0xec, "unknown", null], - [0xed, "unknown", null], - [0xee, "unknown", null], - [0xef, "unknown", null], - [0xf0, "unknown", null], - [0xf1, "unknown", null], - [0xf2, "unknown", null], - [0xf3, "unknown", null], - [0xf4, "unknown", null], - [0xf5, "unknown", null], - [0xf6, "unknown", null], - [0xf7, "unknown", null], - [0xf8, "unknown", null], - [0xf9, "unknown", null], - [0xfa, "unknown", null], - [0xfb, "unknown", null], - [0xfc, "unknown", null], - [0xfd, "unknown", null], - [0xfe, "unknown", null], - [0xff, "unknown", null], +const f9_opcodes = [ + new Opcode(0x00f9, "unknown", [], false, []), + new Opcode(0x01f9, "dec2float", [Type.Register, Type.Register], false, []), + new Opcode(0x02f9, "float2dec", [Type.Register, Type.Register], false, []), + new Opcode(0x03f9, "flet", [Type.Register, Type.Register], false, []), + new Opcode(0x04f9, "fleti", [Type.Register, Type.F32], false, []), + new Opcode(0x05f9, "unknown", [], false, []), + new Opcode(0x06f9, "unknown", [], false, []), + new Opcode(0x07f9, "unknown", [], false, []), + new Opcode(0x08f9, "fadd", [Type.Register, Type.Register], false, []), + new Opcode(0x09f9, "faddi", [Type.Register, Type.F32], false, []), + new Opcode(0x0af9, "fsub", [Type.Register, Type.Register], false, []), + new Opcode(0x0bf9, "fsubi", [Type.Register, Type.F32], false, []), + new Opcode(0x0cf9, "fmul", [Type.Register, Type.Register], false, []), + new Opcode(0x0df9, "fmuli", [Type.Register, Type.F32], false, []), + new Opcode(0x0ef9, "fdiv", [Type.Register, Type.Register], false, []), + new Opcode(0x0ff9, "fdivi", [Type.Register, Type.F32], false, []), + new Opcode(0x10f9, "get_unknown_count?", [], false, [Type.U32, Type.Register]), + new Opcode(0x11f9, "get_stackable_item_count", [Type.Register, Type.Register], false, []), + new Opcode(0x12f9, "freeze_and_hide_equip", [], false, []), + new Opcode(0x13f9, "thaw_and_show_equip", [], false, []), + new Opcode(0x14f9, "set_paletteX_callback", [], false, [Type.Register, Type.U16]), + new Opcode(0x15f9, "activate_paletteX", [], false, [Type.Register]), + new Opcode(0x16f9, "enable_paletteX", [], false, [Type.Register]), + new Opcode(0x17f9, "restore_paletteX", [], false, [Type.U32]), + new Opcode(0x18f9, "disable_paletteX", [], false, [Type.U32]), + new Opcode(0x19f9, "get_paletteX_activated", [], false, [Type.U32, Type.Register]), + new Opcode(0x1af9, "get_unknown_paletteX_status?", [], false, [Type.U32, Type.Register]), + new Opcode(0x1bf9, "disable_movement2", [], false, [Type.Register]), + new Opcode(0x1cf9, "enable_movement2", [], false, [Type.Register]), + new Opcode(0x1df9, "get_time_played", [Type.Register], false, []), + new Opcode(0x1ef9, "get_guildcard_total", [Type.Register], false, []), + new Opcode(0x1ff9, "get_slot_meseta", [Type.Register], false, []), + new Opcode(0x20f9, "get_player_level", [], false, [Type.U32, Type.Register]), + new Opcode(0x21f9, "get_Section_ID", [], false, [Type.U32, Type.Register]), + new Opcode(0x22f9, "get_player_hp", [], false, [Type.Register, Type.Register]), + new Opcode(0x23f9, "get_floor_number", [], false, [Type.Register, Type.Register]), + new Opcode(0x24f9, "get_coord_player_detect", [Type.Register, Type.Register], false, []), + new Opcode(0x25f9, "read_global_flag", [], false, [Type.U8, Type.Register]), + new Opcode(0x26f9, "write_global_flag", [], false, [Type.U8, Type.Register]), + new Opcode(0x27f9, "unknownF927", [Type.Register, Type.Register], false, []), + new Opcode(0x28f9, "floor_player_detect", [Type.Register], false, []), + new Opcode(0x29f9, "read_disk_file?", [], false, [Type.String]), + new Opcode(0x2af9, "open_pack_select", [], false, []), + new Opcode(0x2bf9, "item_select", [Type.Register], false, []), + new Opcode(0x2cf9, "get_item_id", [Type.Register], false, []), + new Opcode(0x2df9, "color_change", [], false, [ + Type.Register, + Type.Register, + Type.Register, + Type.Register, + Type.Register, + ]), + new Opcode(0x2ef9, "send_statistic?", [], false, [ + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + ]), + new Opcode(0x2ff9, "unknownF92F", [], false, [Type.U32, Type.U32]), + new Opcode(0x30f9, "chat_box", [], false, [ + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.String, + ]), + new Opcode(0x31f9, "chat_bubble", [], false, [Type.U32, Type.String]), + new Opcode(0x32f9, "unknown", [], false, []), + new Opcode(0x33f9, "unknownF933", [Type.Register], false, []), + new Opcode(0x34f9, "scroll_text", [], false, [ + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.F32, + Type.Register, + Type.String, + ]), + new Opcode(0x35f9, "gba_unknown1", [], false, []), + new Opcode(0x36f9, "gba_unknown2", [], false, []), + new Opcode(0x37f9, "gba_unknown3", [], false, []), + new Opcode(0x38f9, "add_damage_to?", [], false, [Type.U32, Type.U32]), + new Opcode(0x39f9, "item_delete2", [], false, [Type.U32]), + new Opcode(0x3af9, "get_item_info", [], false, [Type.U32, Type.Register]), + new Opcode(0x3bf9, "item_packing1", [], false, [Type.U32]), + new Opcode(0x3cf9, "item_packing2", [], false, [Type.U32, Type.U32]), + new Opcode(0x3df9, "get_lang_setting?", [], false, [Type.Register]), + new Opcode(0x3ef9, "prepare_statistic?", [], false, [Type.U32, Type.U16, Type.U16]), + new Opcode(0x3ff9, "keyword_detect", [], false, []), + new Opcode(0x40f9, "Keyword", [], false, [Type.Register, Type.U32, Type.String]), + new Opcode(0x41f9, "get_guildcard_num", [], false, [Type.U32, Type.Register]), + new Opcode(0x42f9, "unknown", [], false, []), + new Opcode(0x43f9, "unknown", [], false, []), + new Opcode(0x44f9, "get_wrap_status", [], false, [Type.U32, Type.Register]), + new Opcode(0x45f9, "initial_floor", [], false, [Type.U32]), + new Opcode(0x46f9, "sin", [], false, [Type.Register, Type.U32]), + new Opcode(0x47f9, "cos", [], false, [Type.Register, Type.U32]), + new Opcode(0x48f9, "unknown", [], false, []), + new Opcode(0x49f9, "unknown", [], false, []), + new Opcode(0x4af9, "boss_is_dead2?", [Type.Register], false, []), + new Opcode(0x4bf9, "unknownF94B", [Type.Register], false, []), + new Opcode(0x4cf9, "unknownF94C", [Type.Register], false, []), + new Opcode(0x4df9, "is_there_cardbattle", [Type.Register], false, []), + new Opcode(0x4ef9, "unknown", [], false, []), + new Opcode(0x4ff9, "unknown", [], false, []), + new Opcode(0x50f9, "BB_p2_menu", [], false, [Type.U32]), + new Opcode(0x51f9, "BB_Map_Designate", [Type.U8, Type.U16, Type.U8, Type.U8], false, []), + new Opcode(0x52f9, "BB_get_number_in_pack", [Type.Register], false, []), + new Opcode(0x53f9, "BB_swap_item", [], false, [ + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U32, + Type.U16, + Type.U16, + ]), + new Opcode(0x54f9, "BB_check_wrap", [], false, [Type.Register, Type.Register]), + new Opcode(0x55f9, "BB_exchange_PD_item", [], false, [ + Type.Register, + Type.Register, + Type.Register, + Type.U16, + Type.U16, + ]), + new Opcode(0x56f9, "BB_exchange_PD_srank", [], false, [ + Type.Register, + Type.Register, + Type.Register, + Type.Register, + Type.Register, + Type.U16, + Type.U16, + ]), + new Opcode(0x57f9, "BB_exchange_PD_special", [], false, [ + Type.Register, + Type.Register, + Type.Register, + Type.Register, + Type.Register, + Type.U32, + Type.U16, + Type.U16, + ]), + new Opcode(0x58f9, "BB_exchange_PD_percent", [], false, [ + Type.Register, + Type.Register, + Type.Register, + Type.Register, + Type.Register, + Type.U32, + Type.U16, + Type.U16, + ]), + new Opcode(0x59f9, "unknownF959", [], false, [Type.U32]), + new Opcode(0x5af9, "unknown", [], false, []), + new Opcode(0x5bf9, "unknown", [], false, []), + new Opcode(0x5cf9, "BB_exchange_SLT", [], false, [Type.U32, Type.Register, Type.U16, Type.U16]), + new Opcode(0x5df9, "BB_exchange_PC", [], false, []), + new Opcode(0x5ef9, "BB_box_create_BP", [], false, [Type.U32, Type.F32, Type.F32]), + new Opcode(0x5ff9, "BB_exchange_PT", [], false, [ + Type.Register, + Type.Register, + Type.U32, + Type.U16, + Type.U16, + ]), + new Opcode(0x60f9, "unknownF960", [], false, [Type.U32]), + new Opcode(0x61f9, "unknownF961", [], false, []), + new Opcode(0x62f9, "unknown", [], false, []), + new Opcode(0x63f9, "unknown", [], false, []), + new Opcode(0x64f9, "unknown", [], false, []), + new Opcode(0x65f9, "unknown", [], false, []), + new Opcode(0x66f9, "unknown", [], false, []), + new Opcode(0x67f9, "unknown", [], false, []), + new Opcode(0x68f9, "unknown", [], false, []), + new Opcode(0x69f9, "unknown", [], false, []), + new Opcode(0x6af9, "unknown", [], false, []), + new Opcode(0x6bf9, "unknown", [], false, []), + new Opcode(0x6cf9, "unknown", [], false, []), + new Opcode(0x6df9, "unknown", [], false, []), + new Opcode(0x6ef9, "unknown", [], false, []), + new Opcode(0x6ff9, "unknown", [], false, []), + new Opcode(0x70f9, "unknown", [], false, []), + new Opcode(0x71f9, "unknown", [], false, []), + new Opcode(0x72f9, "unknown", [], false, []), + new Opcode(0x73f9, "unknown", [], false, []), + new Opcode(0x74f9, "unknown", [], false, []), + new Opcode(0x75f9, "unknown", [], false, []), + new Opcode(0x76f9, "unknown", [], false, []), + new Opcode(0x77f9, "unknown", [], false, []), + new Opcode(0x78f9, "unknown", [], false, []), + new Opcode(0x79f9, "unknown", [], false, []), + new Opcode(0x7af9, "unknown", [], false, []), + new Opcode(0x7bf9, "unknown", [], false, []), + new Opcode(0x7cf9, "unknown", [], false, []), + new Opcode(0x7df9, "unknown", [], false, []), + new Opcode(0x7ef9, "unknown", [], false, []), + new Opcode(0x7ff9, "unknown", [], false, []), + new Opcode(0x80f9, "unknown", [], false, []), + new Opcode(0x81f9, "unknown", [], false, []), + new Opcode(0x82f9, "unknown", [], false, []), + new Opcode(0x83f9, "unknown", [], false, []), + new Opcode(0x84f9, "unknown", [], false, []), + new Opcode(0x85f9, "unknown", [], false, []), + new Opcode(0x86f9, "unknown", [], false, []), + new Opcode(0x87f9, "unknown", [], false, []), + new Opcode(0x88f9, "unknown", [], false, []), + new Opcode(0x89f9, "unknown", [], false, []), + new Opcode(0x8af9, "unknown", [], false, []), + new Opcode(0x8bf9, "unknown", [], false, []), + new Opcode(0x8cf9, "unknown", [], false, []), + new Opcode(0x8df9, "unknown", [], false, []), + new Opcode(0x8ef9, "unknown", [], false, []), + new Opcode(0x8ff9, "unknown", [], false, []), + new Opcode(0x90f9, "unknown", [], false, []), + new Opcode(0x91f9, "unknown", [], false, []), + new Opcode(0x92f9, "unknown", [], false, []), + new Opcode(0x93f9, "unknown", [], false, []), + new Opcode(0x94f9, "unknown", [], false, []), + new Opcode(0x95f9, "unknown", [], false, []), + new Opcode(0x96f9, "unknown", [], false, []), + new Opcode(0x97f9, "unknown", [], false, []), + new Opcode(0x98f9, "unknown", [], false, []), + new Opcode(0x99f9, "unknown", [], false, []), + new Opcode(0x9af9, "unknown", [], false, []), + new Opcode(0x9bf9, "unknown", [], false, []), + new Opcode(0x9cf9, "unknown", [], false, []), + new Opcode(0x9df9, "unknown", [], false, []), + new Opcode(0x9ef9, "unknown", [], false, []), + new Opcode(0x9ff9, "unknown", [], false, []), + new Opcode(0xa0f9, "unknown", [], false, []), + new Opcode(0xa1f9, "unknown", [], false, []), + new Opcode(0xa2f9, "unknown", [], false, []), + new Opcode(0xa3f9, "unknown", [], false, []), + new Opcode(0xa4f9, "unknown", [], false, []), + new Opcode(0xa5f9, "unknown", [], false, []), + new Opcode(0xa6f9, "unknown", [], false, []), + new Opcode(0xa7f9, "unknown", [], false, []), + new Opcode(0xa8f9, "unknown", [], false, []), + new Opcode(0xa9f9, "unknown", [], false, []), + new Opcode(0xaaf9, "unknown", [], false, []), + new Opcode(0xabf9, "unknown", [], false, []), + new Opcode(0xacf9, "unknown", [], false, []), + new Opcode(0xadf9, "unknown", [], false, []), + new Opcode(0xaef9, "unknown", [], false, []), + new Opcode(0xaff9, "unknown", [], false, []), + new Opcode(0xb0f9, "unknown", [], false, []), + new Opcode(0xb1f9, "unknown", [], false, []), + new Opcode(0xb2f9, "unknown", [], false, []), + new Opcode(0xb3f9, "unknown", [], false, []), + new Opcode(0xb4f9, "unknown", [], false, []), + new Opcode(0xb5f9, "unknown", [], false, []), + new Opcode(0xb6f9, "unknown", [], false, []), + new Opcode(0xb7f9, "unknown", [], false, []), + new Opcode(0xb8f9, "unknown", [], false, []), + new Opcode(0xb9f9, "unknown", [], false, []), + new Opcode(0xbaf9, "unknown", [], false, []), + new Opcode(0xbbf9, "unknown", [], false, []), + new Opcode(0xbcf9, "unknown", [], false, []), + new Opcode(0xbdf9, "unknown", [], false, []), + new Opcode(0xbef9, "unknown", [], false, []), + new Opcode(0xbff9, "unknown", [], false, []), + new Opcode(0xc0f9, "unknown", [], false, []), + new Opcode(0xc1f9, "unknown", [], false, []), + new Opcode(0xc2f9, "unknown", [], false, []), + new Opcode(0xc3f9, "unknown", [], false, []), + new Opcode(0xc4f9, "unknown", [], false, []), + new Opcode(0xc5f9, "unknown", [], false, []), + new Opcode(0xc6f9, "unknown", [], false, []), + new Opcode(0xc7f9, "unknown", [], false, []), + new Opcode(0xc8f9, "unknown", [], false, []), + new Opcode(0xc9f9, "unknown", [], false, []), + new Opcode(0xcaf9, "unknown", [], false, []), + new Opcode(0xcbf9, "unknown", [], false, []), + new Opcode(0xccf9, "unknown", [], false, []), + new Opcode(0xcdf9, "unknown", [], false, []), + new Opcode(0xcef9, "unknown", [], false, []), + new Opcode(0xcff9, "unknown", [], false, []), + new Opcode(0xd0f9, "unknown", [], false, []), + new Opcode(0xd1f9, "unknown", [], false, []), + new Opcode(0xd2f9, "unknown", [], false, []), + new Opcode(0xd3f9, "unknown", [], false, []), + new Opcode(0xd4f9, "unknown", [], false, []), + new Opcode(0xd5f9, "unknown", [], false, []), + new Opcode(0xd6f9, "unknown", [], false, []), + new Opcode(0xd7f9, "unknown", [], false, []), + new Opcode(0xd8f9, "unknown", [], false, []), + new Opcode(0xd9f9, "unknown", [], false, []), + new Opcode(0xdaf9, "unknown", [], false, []), + new Opcode(0xdbf9, "unknown", [], false, []), + new Opcode(0xdcf9, "unknown", [], false, []), + new Opcode(0xddf9, "unknown", [], false, []), + new Opcode(0xdef9, "unknown", [], false, []), + new Opcode(0xdff9, "unknown", [], false, []), + new Opcode(0xe0f9, "unknown", [], false, []), + new Opcode(0xe1f9, "unknown", [], false, []), + new Opcode(0xe2f9, "unknown", [], false, []), + new Opcode(0xe3f9, "unknown", [], false, []), + new Opcode(0xe4f9, "unknown", [], false, []), + new Opcode(0xe5f9, "unknown", [], false, []), + new Opcode(0xe6f9, "unknown", [], false, []), + new Opcode(0xe7f9, "unknown", [], false, []), + new Opcode(0xe8f9, "unknown", [], false, []), + new Opcode(0xe9f9, "unknown", [], false, []), + new Opcode(0xeaf9, "unknown", [], false, []), + new Opcode(0xebf9, "unknown", [], false, []), + new Opcode(0xecf9, "unknown", [], false, []), + new Opcode(0xedf9, "unknown", [], false, []), + new Opcode(0xeef9, "unknown", [], false, []), + new Opcode(0xeff9, "unknown", [], false, []), + new Opcode(0xf0f9, "unknown", [], false, []), + new Opcode(0xf1f9, "unknown", [], false, []), + new Opcode(0xf2f9, "unknown", [], false, []), + new Opcode(0xf3f9, "unknown", [], false, []), + new Opcode(0xf4f9, "unknown", [], false, []), + new Opcode(0xf5f9, "unknown", [], false, []), + new Opcode(0xf6f9, "unknown", [], false, []), + new Opcode(0xf7f9, "unknown", [], false, []), + new Opcode(0xf8f9, "unknown", [], false, []), + new Opcode(0xf9f9, "unknown", [], false, []), + new Opcode(0xfaf9, "unknown", [], false, []), + new Opcode(0xfbf9, "unknown", [], false, []), + new Opcode(0xfcf9, "unknown", [], false, []), + new Opcode(0xfdf9, "unknown", [], false, []), + new Opcode(0xfef9, "unknown", [], false, []), + new Opcode(0xfff9, "unknown", [], false, []), ]; + +export const OP_RET = opcodes[0x01]; +export const SET_EPISODE = f8_opcodes[0xbc]; +export const BB_MAP_DESIGNATE = f9_opcodes[0x51]; diff --git a/src/data_formats/parsing/quest/index.ts b/src/data_formats/parsing/quest/index.ts index 140d97f0..da807233 100644 --- a/src/data_formats/parsing/quest/index.ts +++ b/src/data_formats/parsing/quest/index.ts @@ -7,9 +7,10 @@ import { ArrayBufferCursor } from "../../cursor/ArrayBufferCursor"; import { Cursor } from "../../cursor/Cursor"; import { ResizableBufferCursor } from "../../cursor/ResizableBufferCursor"; import { Vec3 } from "../../vector"; -import { Instruction, parse_bin, write_bin } from "./bin"; +import { Instruction, parse_bin, write_bin, OP_RET, BB_MAP_DESIGNATE, SET_EPISODE } from "./bin"; import { DatFile, DatNpc, DatObject, parse_dat, write_dat } from "./dat"; import { parse_qst, QstContainedFile, write_qst } from "./qst"; +import { number } from "prop-types"; const logger = Logger.get("data_formats/parsing/quest"); @@ -59,13 +60,13 @@ export function parse_quest(cursor: Cursor, lenient: boolean = false): Quest | u let area_variants: AreaVariant[] = []; if (bin.function_offsets.length) { - const func_0_ops = get_func_operations(bin.instructions, bin.function_offsets[0]); + const func_0_ops = get_func_instructions(bin.instructions, bin.function_offsets[0]); if (func_0_ops) { episode = get_episode(func_0_ops); area_variants = get_area_variants(dat, episode, func_0_ops, lenient); } else { - logger.warn(`Function 0 offset ${bin.function_offsets[0]} is invalid.`); + logger.warn(`Offset ${bin.function_offsets[0]} for function 0 is invalid.`); } } else { logger.warn("File contains no functions."); @@ -130,11 +131,11 @@ export function write_quest_qst(quest: Quest, file_name: string): ArrayBuffer { /** * Defaults to episode I. */ -function get_episode(func_0_ops: Instruction[]): number { - const set_episode = func_0_ops.find(op => op.mnemonic === "set_episode"); +function get_episode(func_0_instructions: Instruction[]): number { + const set_episode = func_0_instructions.find(instruction => instruction.opcode === SET_EPISODE); if (set_episode) { - switch (set_episode.args[0]) { + switch (set_episode.args[0].value) { default: case 0: return 1; @@ -152,11 +153,11 @@ function get_episode(func_0_ops: Instruction[]): number { function get_area_variants( dat: DatFile, episode: number, - func_0_ops: Instruction[], + func_0_instructions: Instruction[], lenient: boolean ): AreaVariant[] { // Add area variants that have npcs or objects even if there are no BB_Map_Designate instructions for them. - const area_variants = new Map(); + const area_variants = new Map(); for (const npc of dat.npcs) { area_variants.set(npc.area_id, 0); @@ -166,11 +167,13 @@ function get_area_variants( area_variants.set(obj.area_id, 0); } - const bb_maps = func_0_ops.filter(op => op.mnemonic === "BB_Map_Designate"); + const bb_maps = func_0_instructions.filter( + instruction => instruction.opcode === BB_MAP_DESIGNATE + ); for (const bb_map of bb_maps) { - const area_id = bb_map.args[0]; - const variant_id = bb_map.args[2]; + const area_id: number = bb_map.args[0].value; + const variant_id: number = bb_map.args[2].value; area_variants.set(area_id, variant_id); } @@ -192,29 +195,29 @@ function get_area_variants( return area_variants_array.sort((a, b) => a.area.order - b.area.order || a.id - b.id); } -function get_func_operations( - operations: Instruction[], +function get_func_instructions( + instructions: Instruction[], func_offset: number ): Instruction[] | undefined { let position = 0; let func_found = false; const func_ops: Instruction[] = []; - for (const operation of operations) { + for (const instruction of instructions) { if (position === func_offset) { func_found = true; } if (func_found) { - func_ops.push(operation); + func_ops.push(instruction); // Break when ret is encountered. - if (operation.opcode === 1) { + if (instruction.opcode === OP_RET) { break; } } - position += operation.size; + position += instruction.size; } return func_found ? func_ops : undefined;