diff --git a/asm/include/overlay_31002382AC0.inc b/asm/include/overlay_31002382B54.inc similarity index 98% rename from asm/include/overlay_31002382AC0.inc rename to asm/include/overlay_31002382B54.inc index 2203d2a3..bef43a7c 100644 --- a/asm/include/overlay_31002382AC0.inc +++ b/asm/include/overlay_31002382B54.inc @@ -30,7 +30,6 @@ .public CreateTextBox .public CreateTextBoxWithArg .public DUNGEON_MAIN_MENU_ITEMS -.public DUNGEON_MENU_SWITCH_STR1 .public DUNGEON_PTR .public DUNGEON_SUBMENU_ITEMS_1 .public DUNGEON_SUBMENU_ITEMS_5 @@ -72,6 +71,7 @@ .public DrawDungeonMenuStatusWindow .public DrawTextInWindow .public DrawTileGrid +.public DungeonMenuSwitch .public FormatMoveString .public FormatMoveStringMore .public GetActiveTeamMember @@ -101,7 +101,6 @@ .public GetTile .public GetTrapInfo .public GetUnlockedTactics -.public GetWindow .public GetWindowRectangle .public HideTileGrid .public InitPreprocessorArgs @@ -264,8 +263,6 @@ .public sub_0200D894 .public sub_02017C74 .public sub_02017C80 -.public sub_02025888 -.public sub_020265A8 .public sub_02027B1C .public sub_0202810C .public sub_0202812C diff --git a/asm/overlay_31002382AC0.s b/asm/overlay_31002382B54.s similarity index 99% rename from asm/overlay_31002382AC0.s rename to asm/overlay_31002382B54.s index b17f19dc..c8f9064f 100644 --- a/asm/overlay_31002382AC0.s +++ b/asm/overlay_31002382B54.s @@ -1,50 +1,8 @@ .include "asm/macros.inc" - .include "overlay_31002382AC0.inc" + .include "overlay_31002382B54.inc" .text - arm_func_start DungeonMenuSwitch -DungeonMenuSwitch: ; 0x02382AC0 - stmdb sp!, {r3, r4, r5, r6, lr} - sub sp, sp, #0x54 - ldr r1, _02382B4C ; =DUNGEON_PTR - mov r4, r0 - ldr r1, [r1] - ldrb r0, [r1, #0x748] - orr r0, r0, #0x40000 - str r0, [sp, #0x14] - ldrb r0, [r1, #0x749] - str r0, [sp, #0x28] - bl sub_02025888 - add r5, sp, #4 - ldr r2, _02382B50 ; =DUNGEON_MENU_SWITCH_STR1 - mov r1, #0x400 - mov r3, #0 - mov r6, r0 - str r5, [sp] - bl PreprocessString - mov r0, r4 - bl GetWindow - mov r5, r0 - mov r0, r6 - bl sub_020265A8 - ldrb r1, [r5, #6] - mov r3, r6 - mov r2, #2 - rsb r0, r0, r1, lsl #3 - add r0, r0, r0, lsr #31 - mov r1, r0, asr #1 - mov r0, r4 - bl DrawTextInWindow - mov r0, r4 - bl UpdateWindow - add sp, sp, #0x54 - ldmia sp!, {r3, r4, r5, r6, pc} - .align 2, 0 -_02382B4C: .word DUNGEON_PTR -_02382B50: .word DUNGEON_MENU_SWITCH_STR1 - arm_func_end DungeonMenuSwitch - arm_func_start ov31_02382B54 ov31_02382B54: ; 0x02382B54 stmdb sp!, {lr} diff --git a/include/overlay_3102382820.h b/include/overlay_3102382820.h index 5a40e210..b60445dc 100644 --- a/include/overlay_3102382820.h +++ b/include/overlay_3102382820.h @@ -29,6 +29,7 @@ void EntryOverlay31(void); #define LINE_HEIGHT 12 #define X_OFFSET 115 void DrawDungeonMenuStatusWindow(struct Window* window); +u32 DungeonMenuSwitch(struct Window* window); diff --git a/include/preprocessString.h b/include/preprocessString.h index aaf560f4..bf3b974e 100644 --- a/include/preprocessString.h +++ b/include/preprocessString.h @@ -6,7 +6,7 @@ struct PPStrValues { u32 field_0x4; u32 field_0x8; u32 field_0xB; - u8* dungeon_0; // 0xC + u32 dungeon_0; // 0xC u32 field_0x10; u32 field_0x14; u32 field_0x18; diff --git a/main.lsf b/main.lsf index 6f1d913a..e4c9ed2f 100644 --- a/main.lsf +++ b/main.lsf @@ -306,7 +306,7 @@ Overlay OVY_31 { After OVY_29 Object src/overlay_3102382820.o - Object asm/overlay_31002382AC0.o + Object asm/overlay_31002382B54.o } Overlay OVY_32 { diff --git a/src/overlay_3102382820.c b/src/overlay_3102382820.c index a39e450e..9ef7410d 100644 --- a/src/overlay_3102382820.c +++ b/src/overlay_3102382820.c @@ -4,20 +4,33 @@ extern u32 DUNGEON_WINDOW_PARAMS_3[]; extern struct {u32* a; u32 b;} OVERLAY31_UNKNOWN_POINTER__NA_238A260; extern struct dungeon* DUNGEON_PTR; +extern const u8 DUNGEON_MENU_SWITCH_STR1[];// = "[dungeon:0]"; + extern void* MemAlloc(u32 len, u32 flags); extern void* sub_020348E4(u32*); -struct entity* GetLeader(void); -s32 CeilFixedPoint(struct fixed_point); -u32 GetMoneyCarried(void); -void* GetApparentWeather(u32); -u32 sub_0204F9E0(void); -void ov29_022E2A78(u8*, void*, u32); // The third argument isn't actually used in the + +struct Window { + u8 PAD[6]; + u8 width; // 0x6: Window width in multiples of 8 pixels +}; + + +extern struct entity* GetLeader(void); +extern s32 CeilFixedPoint(struct fixed_point); +extern u32 GetMoneyCarried(void); +extern void* GetApparentWeather(u32); +extern u32 sub_0204F9E0(void); +extern void ov29_022E2A78(u8*, void*, u32); // The third argument isn't actually used in the // function (../asm/overlay_29_022E1A40.s#L1378) -u8* StringFromId(u32); -void PreprocessString(u8* dst, u32 dsize, const u8* src, u32 flags, struct PPStrValues* ptr); -void DrawTextInWindow(struct Window*, u32, u32, u8*); -void UpdateWindow(struct Window*); +extern u8* StringFromId(u32); +extern void PreprocessString(u8* dst, u32 dsize, const u8* src, u32 flags, struct PPStrValues* ptr); +extern void DrawTextInWindow(struct Window*, u32, u32, u8*); +extern void UpdateWindow(struct Window*); + +extern u8* sub_02025888(void); +extern struct Window* GetWindow(struct Window*); +extern s32 sub_020265A8(u8*); // Measures the text's width in pixels void EntryOverlay31(void) { u32* r0 = (u32*)sub_020348E4(DUNGEON_WINDOW_PARAMS_3); @@ -98,3 +111,17 @@ void DrawDungeonMenuStatusWindow(struct Window* window) UpdateWindow(window); } + +u32 DungeonMenuSwitch(struct Window* window) +{ + struct PPStrValues str_values; + str_values.dungeon_0 = DUNGEON_PTR->dungeon | 0x40000; + str_values.digits_0 = DUNGEON_PTR->floor; + u8* str_buff = sub_02025888(); + PreprocessString(str_buff, 0x400, DUNGEON_MENU_SWITCH_STR1, 0, &str_values); + struct Window* window2 = GetWindow(window); + s32 text_width = sub_020265A8(str_buff); + s32 x_offset = (window2->width * 8 - text_width) / 2; + DrawTextInWindow(window, x_offset, 2, str_buff); + UpdateWindow(window); +}