From 45b0de18d3a131902e2f44b05d0a715dc44d8993 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Mon, 16 Mar 2026 00:09:10 -0400 Subject: [PATCH] Decomped GetExplorerMazeTeamName Decomped by @slaw-22 --- .../{main_02059060.inc => main_020590C0.inc} | 1 - asm/{main_02059060.s => main_020590C0.s} | 40 +------------------ include/main_02059060.h | 9 +++++ main.lsf | 3 +- src/main_02059060.c | 33 +++++++++++++++ tools/extract_function/extract_function.py | 9 ++++- 6 files changed, 52 insertions(+), 43 deletions(-) rename asm/include/{main_02059060.inc => main_020590C0.inc} (99%) rename asm/{main_02059060.s => main_020590C0.s} (99%) create mode 100644 include/main_02059060.h create mode 100644 src/main_02059060.c diff --git a/asm/include/main_02059060.inc b/asm/include/main_020590C0.inc similarity index 99% rename from asm/include/main_02059060.inc rename to asm/include/main_020590C0.inc index 04eec236..7a6228d7 100644 --- a/asm/include/main_02059060.inc +++ b/asm/include/main_020590C0.inc @@ -31,7 +31,6 @@ .public EVENTS .public EnableAllLearnableIqSkills .public EnqueueRender3dTiling -.public ExplorerMazeMonsterExists .public ExplorersOfSkyMain .public FemaleToMaleForm .public FindItemInInventory diff --git a/asm/main_02059060.s b/asm/main_020590C0.s similarity index 99% rename from asm/main_02059060.s rename to asm/main_020590C0.s index f47f7985..335d3214 100644 --- a/asm/main_02059060.s +++ b/asm/main_020590C0.s @@ -1,46 +1,8 @@ .include "asm/macros.inc" - .include "main_02059060.inc" + .include "main_020590C0.inc" .text - arm_func_start GetExplorerMazeTeamName -GetExplorerMazeTeamName: ; 0x02059060 - stmdb sp!, {r3, r4, r5, lr} - ldr r1, _020590B8 ; =TEAM_MEMBER_TABLE_PTR - mov r5, r0 - ldr r0, [r1] - add r0, r0, #0x1880 - add r4, r0, #0x8000 - bl ExplorerMazeMonsterExists - cmp r0, #0 - beq _020590A8 - bl GetLanguageType - ldrsb r1, [r4] - cmp r1, r0 - bne _020590A8 - mov r0, r5 - add r1, r4, #2 -#ifdef JAPAN - mov r2, #5 -#else - mov r2, #0xa -#endif - bl StrncpySimpleNoPadSafe - ldmia sp!, {r3, r4, r5, pc} -_020590A8: - ldr r1, _020590BC ; =0x00000235 - mov r0, r5 - bl GetStringFromFileVeneer - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_020590B8: .word TEAM_MEMBER_TABLE_PTR -#ifdef JAPAN -_020590BC: .word 0x000004C6 -#else -_020590BC: .word 0x00000235 -#endif - arm_func_end GetExplorerMazeTeamName - arm_func_start sub_020590C0 sub_020590C0: ; 0x020590C0 ldr r0, _020590D8 ; =TEAM_MEMBER_TABLE_PTR diff --git a/include/main_02059060.h b/include/main_02059060.h new file mode 100644 index 00000000..7cf67929 --- /dev/null +++ b/include/main_02059060.h @@ -0,0 +1,9 @@ +#ifndef PMDSKY_MAIN_02059060_H +#define PMDSKY_MAIN_02059060_H + +// Returns the name of the explorer maze team. If the language of the team name is different from the +// language of selected in this game a default team name is written to the buffer instead. +// dest: [output] Buffer +void GetExplorerMazeTeamName(u8 *dest); + +#endif //PMDSKY_MAIN_02059060_H diff --git a/main.lsf b/main.lsf index ce383fb7..730f7ee6 100644 --- a/main.lsf +++ b/main.lsf @@ -129,7 +129,8 @@ Static main Object src/pokemon.o Object asm/main_02058F24.o Object src/main_02058FA4.o - Object asm/main_02059060.o + Object src/main_02059060.o + Object asm/main_020590C0.o Object src/dungeon_init_2.o Object asm/main_0206A750.o Object src/main_0206C98C.o diff --git a/src/main_02059060.c b/src/main_02059060.c new file mode 100644 index 00000000..408f3dc9 --- /dev/null +++ b/src/main_02059060.c @@ -0,0 +1,33 @@ +#include "main_02059060.h" +#include "common.h" +#include "main_0202593C.h" +#include "main_02058FA4.h" + +extern struct team_member_table *TEAM_MEMBER_TABLE_PTR; + +s32 GetLanguageType(void); +void StrncpySimpleNoPadSafe(u8* dest, const u8* src, u32 n); + +void GetExplorerMazeTeamName(u8 *dest) +{ + s8 *explorer_maze_team_native_language = &TEAM_MEMBER_TABLE_PTR->explorer_maze_team_native_language; + if (ExplorerMazeMonsterExists()) + { + if (GetLanguageType() == *explorer_maze_team_native_language) + { + u8 *explorer_maze_team_name = explorer_maze_team_native_language + 2; +#ifdef JAPAN + StrncpySimpleNoPadSafe(dest, explorer_maze_team_name, 5); +#else + StrncpySimpleNoPadSafe(dest, explorer_maze_team_name, 0xA); +#endif + return; + } + } + +#ifdef JAPAN + GetStringFromFileVeneer(dest, 0x4C6); +#else + GetStringFromFileVeneer(dest, 0x235); +#endif +} diff --git a/tools/extract_function/extract_function.py b/tools/extract_function/extract_function.py index 48f38051..5bc5f95d 100644 --- a/tools/extract_function/extract_function.py +++ b/tools/extract_function/extract_function.py @@ -17,11 +17,13 @@ parser.add_argument('asm_file') parser.add_argument('function_header') parser.add_argument('-f', '--extract_file_name') parser.add_argument('-n', '--nonmatching', action='store_true') +parser.add_argument('-nm', '--no_file_merge', action='store_false') args = parser.parse_args() function_location = args.asm_file function_header = args.function_header extract_file_name = args.extract_file_name +enable_file_merge = args.no_file_merge nonmatching = args.nonmatching if function_location.endswith('.s'): @@ -126,16 +128,17 @@ lsf_suffix = '' if is_itcm: lsf_suffix = ' (.itcm)' SRC_LSF_PREFIX = '\tObject src/' + for i, line in enumerate(lsf_lines): if line.endswith(f'{function_location}.o{lsf_suffix}\n'): if remove_orig_file: lsf_lines[i] = '' prev_line = lsf_lines[i - 1] - if prev_line.startswith(SRC_LSF_PREFIX): + if prev_line.startswith(SRC_LSF_PREFIX) and enable_file_merge: merge_prev_file = prev_line[len(SRC_LSF_PREFIX):] if not include_new_asm_file and merge_prev_file is None: next_line = lsf_lines[i + 1] - if next_line.startswith(SRC_LSF_PREFIX): + if next_line.startswith(SRC_LSF_PREFIX) and enable_file_merge: merge_next_file = next_line[len(SRC_LSF_PREFIX):] if merge_prev_file is None and merge_next_file is None: lsf_lines[i] += f'\tObject src/{extract_file_name}.o{lsf_suffix}\n' @@ -154,6 +157,8 @@ def trim_merge_file_name(file_name: str) -> str: merge_prev_file = trim_merge_file_name(merge_prev_file) merge_next_file = trim_merge_file_name(merge_next_file) +print(merge_prev_file) +print(merge_next_file) print('Updating', LSF_FILE_PATH) with open(LSF_FILE_PATH, 'w') as lsf_file: