From 76e8d94dc1b60b719f774d923f1c766682a6eb59 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 31 Jul 2024 08:22:44 +0200 Subject: [PATCH] Decomp ov31_02382F68 --- ...1002382F68.inc => overlay_31002382FBC.inc} | 1 + ...ay_31002382F68.s => overlay_31002382FBC.s} | 28 +------------------ include/overlay_3102382820.h | 1 + main.lsf | 2 +- src/overlay_3102382820.c | 27 ++++++++++++------ tools/extract_function/extract_function.py | 2 ++ 6 files changed, 25 insertions(+), 36 deletions(-) rename asm/include/{overlay_31002382F68.inc => overlay_31002382FBC.inc} (99%) rename asm/{overlay_31002382F68.s => overlay_31002382FBC.s} (99%) diff --git a/asm/include/overlay_31002382F68.inc b/asm/include/overlay_31002382FBC.inc similarity index 99% rename from asm/include/overlay_31002382F68.inc rename to asm/include/overlay_31002382FBC.inc index fa7338e3..017e8da8 100644 --- a/asm/include/overlay_31002382F68.inc +++ b/asm/include/overlay_31002382FBC.inc @@ -221,6 +221,7 @@ .public ov29_0238280C .public ov31_02382B54 .public ov31_02382DAC +.public ov31_02382F68 .public ov31_02389E22 .public ov31_02389F5C .public ov31_0238A044 diff --git a/asm/overlay_31002382F68.s b/asm/overlay_31002382FBC.s similarity index 99% rename from asm/overlay_31002382F68.s rename to asm/overlay_31002382FBC.s index a09bb998..5b93bc47 100644 --- a/asm/overlay_31002382F68.s +++ b/asm/overlay_31002382FBC.s @@ -1,34 +1,8 @@ .include "asm/macros.inc" - .include "overlay_31002382F68.inc" + .include "overlay_31002382FBC.inc" .text - arm_func_start ov31_02382F68 -ov31_02382F68: ; 0x02382F68 - stmdb sp!, {r4, lr} - ldr r1, _02382FB4 ; =ov31_0238A2A0 - ldr r2, _02382FB8 ; =ov31_02389E22 - ldr r1, [r1, #4] - mov r4, r0 - ldr r0, [r1, #0x14] - mov r0, r0, lsl #2 - ldrh r0, [r2, r0] - bl StringFromId - mov r3, r0 - ldr ip, _02382FB4 ; =ov31_0238A2A0 - mov r0, r4 - mov r1, #0x10 - mov r2, #0x12 - str r3, [ip] - bl DrawTextInWindow - mov r0, r4 - bl UpdateWindow - ldmia sp!, {r4, pc} - .align 2, 0 -_02382FB4: .word ov31_0238A2A0 -_02382FB8: .word ov31_02389E22 - arm_func_end ov31_02382F68 - arm_func_start ov31_02382FBC ov31_02382FBC: ; 0x02382FBC stmdb sp!, {r4, lr} diff --git a/include/overlay_3102382820.h b/include/overlay_3102382820.h index 9a03c8a7..8407b103 100644 --- a/include/overlay_3102382820.h +++ b/include/overlay_3102382820.h @@ -57,6 +57,7 @@ void ov31_02382DAC(void); struct struct_1* ov31_02382E08(void); void ov31_02382E18(u32* arg_1, u32 arg_2); void ov31_02382ED4(u32* arg_1); +void ov31_02382F68(struct Window* window); diff --git a/main.lsf b/main.lsf index c933f106..d075ba2b 100644 --- a/main.lsf +++ b/main.lsf @@ -308,7 +308,7 @@ Overlay OVY_31 { After OVY_29 Object src/overlay_3102382820.o - Object asm/overlay_31002382F68.o + Object asm/overlay_31002382FBC.o } Overlay OVY_32 { diff --git a/src/overlay_3102382820.c b/src/overlay_3102382820.c index ccc85787..bb484c5c 100644 --- a/src/overlay_3102382820.c +++ b/src/overlay_3102382820.c @@ -11,10 +11,12 @@ extern struct struct_1 DUNGEON_WINDOW_PARAMS_3; extern u32 DUNGEON_WINDOW_PARAMS_4; extern u32 DUNGEON_MAIN_MENU_ITEMS; -extern struct struct_3* ov31_0238A2A0[2]; +extern struct {u8* str; struct struct_3* st3;} ov31_0238A2A0; extern struct struct_1 OVERLAY31_UNKNOWN_STRUCT__NA_2389E30; +extern u16 ov31_02389E22[]; + extern void* MemAlloc(u32 size, u32 nmemb); //extern u32 sub_020348E4(struct struct_1*); @@ -252,7 +254,7 @@ void ov31_02382E18(u32* arg_1, u32 arg_2) AdvanceFrame(0x62); ov31_02382ED4(arg_1); - while ((u8)(ov31_0238A2A0[1] != NULL)) { + while ((u8)(ov31_0238A2A0.st3 != NULL)) { AdvanceFrame(0x62); } @@ -275,11 +277,11 @@ void ov31_02382ED4(u32* arg_1) return; tmp1 = MemAlloc(sizeof(struct struct_3), 8); - ov31_0238A2A0[1] = tmp1; - ov31_0238A2A0[1]->field_0x4 = 0; - ov31_0238A2A0[1]->a = arg_1; - ov31_0238A2A0[1]->b = 0; - ov31_0238A2A0[1]->c = 0; + ov31_0238A2A0.st3 = tmp1; + ov31_0238A2A0.st3->field_0x4 = 0; + ov31_0238A2A0.st3->a = arg_1; + ov31_0238A2A0.st3->b = 0; + ov31_0238A2A0.st3->c = 0; u32 floor_type = GetFloorType(); u32 r4 = 0; @@ -291,5 +293,14 @@ void ov31_02382ED4(u32* arg_1) r4 = 3; } - ov31_0238A2A0[1]->d = r4; + ov31_0238A2A0.st3->d = r4; +} + +void ov31_02382F68(struct Window* window) +{ + u8* str = StringFromId(ov31_02389E22[ov31_0238A2A0.st3->d * 2]); + + ov31_0238A2A0.str = str; + DrawTextInWindow(window, 16, 18, str); + UpdateWindow(window); } diff --git a/tools/extract_function/extract_function.py b/tools/extract_function/extract_function.py index 8a82ebbe..6c5114bc 100644 --- a/tools/extract_function/extract_function.py +++ b/tools/extract_function/extract_function.py @@ -16,6 +16,8 @@ if len(sys.argv) != 3: _, function_location, function_header = sys.argv if function_location.endswith('.s'): function_location = function_location[:-2] +if function_location.startswith("./asm/"): + function_location = function_location[6:] if function_header.endswith(';'): function_header = function_header[:-1]