Decompile DrawDungeonMenuStatusWindow

This commit is contained in:
user 2024-07-26 13:48:37 +02:00
parent 3524397834
commit 99a9732067
8 changed files with 196 additions and 186 deletions

View File

@ -10,7 +10,6 @@
.public BaseFormsEqual
.public CanAiUseMove
.public CanMonsterSpawn
.public CeilFixedPoint
.public CheckTeamMemberIdxVeneer
.public CloseAdvancedTextBox
.public CloseAdvancedTextBox2
@ -31,6 +30,7 @@
.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
@ -69,12 +69,12 @@
.public Debug_Print0
.public DisableDungeonSubMenuOption
.public DisplayMessage
.public DrawDungeonMenuStatusWindow
.public DrawTextInWindow
.public DrawTileGrid
.public FormatMoveString
.public FormatMoveStringMore
.public GetActiveTeamMember
.public GetApparentWeather
.public GetCurrentBagCapacity
.public GetDexNumber
.public GetFloorType
@ -89,7 +89,6 @@
.public GetLeaderChangeFlag
.public GetLeaderMonster
.public GetMaxPp
.public GetMoneyCarried
.public GetMonsterIdFromSpawnEntry
.public GetMonsterName
.public GetNbItemsInBag
@ -233,7 +232,6 @@
.public ov29_0235352C
.public ov29_0237C91C
.public ov29_0238280C
.public DUNGEON_MENU_SWITCH_STR1
.public ov31_02389E22
.public ov31_02389F5C
.public ov31_0238A044
@ -315,7 +313,6 @@
.public sub_020420F4
.public sub_0204AEA0
.public sub_0204F10C
.public sub_0204F9E0
.public sub_02053CA0
.public sub_02054F44
.public sub_02056228

View File

@ -1,183 +1,8 @@
.include "asm/macros.inc"
.include "overlay_3102382864.inc"
.include "overlay_31002382AC0.inc"
.text
arm_func_start DrawDungeonMenuStatusWindow
DrawDungeonMenuStatusWindow: ; 0x02382864
#ifdef JAPAN
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_OFFSET -4
#else
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_OFFSET 0
#endif
stmdb sp!, {r4, r5, r6, r7, r8, sb, sl, fp, lr}
sub sp, sp, #0x254
mov sl, r0
bl GetLeader
ldr r4, [r0, #0xb4]
sub r2, sp, #4
add r0, r4, #0x100
ldrh r1, [r0, #0x46 + DRAW_DUNGEON_MENU_STATUS_WINDOW_OFFSET]
strh r1, [r2]
ldrh r0, [r0, #0x48 + DRAW_DUNGEON_MENU_STATUS_WINDOW_OFFSET]
strh r0, [r2, #2]
ldr r0, [r2]
bl CeilFixedPoint
str r0, [sp, #0x228]
add r0, r4, #0x100
ldrh r1, [r0, #0x4a + DRAW_DUNGEON_MENU_STATUS_WINDOW_OFFSET]
sub r2, sp, #4
strh r1, [r2]
ldrh r0, [r0, #0x4c + DRAW_DUNGEON_MENU_STATUS_WINDOW_OFFSET]
strh r0, [r2, #2]
ldr r0, [r2]
bl CeilFixedPoint
str r0, [sp, #0x22c]
ldr r0, _02382AA0 ; =0x000008B2
bl StringFromId
add r1, sp, #0x204
mov r2, r0
str r1, [sp]
add r0, sp, #0x104
mov r1, #0x100
mov r3, #0
bl PreprocessString
mov r0, sl
mov r1, #0x73
mov r2, #0
add r3, sp, #0x104
bl DrawTextInWindow
bl GetMoneyCarried
str r0, [sp, #0x228]
ldr r0, _02382AA4 ; =0x000008B5
bl StringFromId
add r1, sp, #0x204
mov r2, r0
str r1, [sp]
add r0, sp, #0x104
mov r1, #0x100
mov r3, #0
bl PreprocessString
mov r0, sl
mov r1, #0x73
mov r2, #0xc
add r3, sp, #0x104
bl DrawTextInWindow
mov r0, #0
bl GetApparentWeather
str r0, [sp, #0x204]
ldr r0, _02382AA8 ; =0x000008B6
bl StringFromId
add r1, sp, #0x204
mov r2, r0
str r1, [sp]
add r0, sp, #0x104
mov r1, #0x100
mov r3, #0
bl PreprocessString
add r3, sp, #0x104
mov r0, sl
mov r1, #0x73
mov r2, #0x18
bl DrawTextInWindow
bl sub_0204F9E0
str r0, [sp, #0x228]
ldr r0, _02382AAC ; =0x000008B7
bl StringFromId
add r1, sp, #0x204
mov r2, r0
str r1, [sp]
ldr r3, _02382AB0 ; =0x0000C402
add r0, sp, #0x104
mov r1, #0x100
bl PreprocessString
mov r0, sl
mov r1, #0x73
mov r2, #0x24
add r3, sp, #0x104
bl DrawTextInWindow
mov r7, #0
mov r8, r7
add r6, sp, #4
ldr r5, _02382AB4 ; =0x000003E7
add r4, sp, #0x204
ldr fp, _02382AB8 ; =DUNGEON_PTR
b _02382A88
_023829D8:
ldr r0, [fp]
add r0, r0, r8, lsl #2
add r0, r0, #0x12000
#ifdef JAPAN
ldr r1, [r0, #0xa84]
#else
ldr r1, [r0, #0xb28]
#endif
cmp r1, #0
moveq r0, #0
beq _02382A08
ldr r0, [r1]
cmp r0, #0
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
_02382A08:
cmp r0, #0
beq _02382A84
ldr sb, [r1, #0xb4]
mov r0, r6
mov r2, #0
bl ov29_022E2A78
str r6, [sp, #0x23c]
ldrsh r0, [sb, #0x10]
str r0, [sp, #0x228]
ldrsh r1, [sb, #0x12]
ldrsh r0, [sb, #0x16]
add r0, r1, r0
cmp r0, r5
movgt r0, r5
str r0, [sp, #0x22c]
ldr r0, _02382ABC ; =0x000008B8
bl StringFromId
mov r2, r0
add r0, sp, #0x104
mov r1, #0x100
mov r3, #0
str r4, [sp]
bl PreprocessString
mov r0, sl
mov r1, #4
mov r2, r7
add r3, sp, #0x104
bl DrawTextInWindow
add r7, r7, #0xc
cmp r7, #0x30
bge _02382A90
_02382A84:
add r8, r8, #1
_02382A88:
cmp r8, #4
blt _023829D8
_02382A90:
mov r0, sl
bl UpdateWindow
add sp, sp, #0x254
ldmia sp!, {r4, r5, r6, r7, r8, sb, sl, fp, pc}
.align 2, 0
#ifdef JAPAN
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET 0x1458
#else
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET 0
#endif
_02382AA0: .word 0x000008B2 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET
_02382AA4: .word 0x000008B5 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET
_02382AA8: .word 0x000008B6 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET
_02382AAC: .word 0x000008B7 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET
_02382AB0: .word 0x0000C402
_02382AB4: .word 0x000003E7
_02382AB8: .word DUNGEON_PTR
_02382ABC: .word 0x000008B8 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET
arm_func_end DrawDungeonMenuStatusWindow
arm_func_start DungeonMenuSwitch
DungeonMenuSwitch: ; 0x02382AC0
stmdb sp!, {r3, r4, r5, r6, lr}

View File

@ -1,6 +1,7 @@
#ifndef PMDSKY_DUNGEON_MODE_H
#define PMDSKY_DUNGEON_MODE_H
#include "util.h"
#include "graphics.h"
// Used in various contexts, like with entity positions in the dungeon
@ -16,6 +17,19 @@ struct pixel_position {
u32 y;
};
// Dungeon data
struct dungeon {
u8 PAD1[1864];
u8 dungeon; // 0x748
u8 floor; // 0x749
u8 PAD2[74554];
#ifndef JAPAN
u32 PAD3[41];
#endif
struct entity* party_members[4]; // 0x4800
// Possibly more stuff
};
// Entity type. This is used to tag generic entity pointers.
enum entity_type {
ENTITY_NOTHING = 0,
@ -68,4 +82,25 @@ struct entity {
void* info; // 0xB4: Points to info struct for monster/item/trap
};
#endif //PMDSKY_DUNGEON_MODE_H
// Info struct for leader
struct leader_info {
u8 PAD[322];
#ifndef JAPAN
u8 PAD2[4];
#endif
struct fixed_point belly; // 0x146
struct fixed_point max_belly; // 0x14a
// Possibly more stuff
};
// Info struct for party members
struct party_member_info {
u8 PAD[16];
s16 hp_left; // 0x10
s16 hp_max_1; // 0x12
s16 field_0x14;
s16 hp_max_2; // 0x16
// Possibly more stuff
};
#endif //PMDSKY_DUNGEON_MODE_H

View File

@ -1,6 +1,36 @@
#ifndef PMDSKY_OVERLAY_3102382820_H
#define PMDSKY_OVERLAY_3102382820_H
#include "util.h"
#include "preprocessString.h"
#include "dungeon_mode.h"
struct Window;
void EntryOverlay31(void);
#ifdef JAPAN
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET 0x1458
#else
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET 0
#endif
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_1 (0x000008B2 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET)
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_2 (0x000008B5 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET)
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_3 (0x000008B6 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET)
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_4 (0x000008B7 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET)
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_5 (0x000008B8 + DRAW_DUNGEON_MENU_STATUS_WINDOW_DATA_OFFSET)
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_CONST_1 (0x0000C402)
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_CONST_2 (999)
#define DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE (256)
#define LINE_HEIGHT 12
#define X_OFFSET 115
void DrawDungeonMenuStatusWindow(struct Window* window);
#endif //PMDSKY_OVERLAY_3102382820_H

View File

@ -0,0 +1,35 @@
#ifndef PREPROCESS_STRING_H
#define PREPROCESS_STRING_H
struct PPStrValues {
u8* weather_0; // 0x0
u32 field_0x4;
u32 field_0x8;
u32 field_0xB;
u8* dungeon_0; // 0xC
u32 field_0x10;
u32 field_0x14;
u32 field_0x18;
u32 field_0x1c;
union { // 0x20
u32 digits_0;
u32 value_0;
u32 time_0;
u32 gold_left_0;
};
union { // 0x24
u32 digits_1;
u32 value_1;
};
u32 field_0x28;
u32 field_0x2c;
u32 field_0x30;
u8* string0; // 0x34
u32 field_0x38;
u32 field_0x3c;
u32 field_0x40;
u32 field_0x44;
u32 field_0x48;
};
#endif

View File

@ -21,4 +21,13 @@ struct uvec2_16 {
u16 y;
};
#endif //PMDSKY_UTIL_H
// a (16b.16b) fixed-point rational
struct fixed_point {
u16 integer;
u16 fractional;
};
// Compares two numbers and return the minimum
#define MIN(A, B) ((A > B) ? B : A)
#endif //PMDSKY_UTIL_H

View File

@ -306,7 +306,7 @@ Overlay OVY_31
{
After OVY_29
Object src/overlay_3102382820.o
Object asm/overlay_3102382864.o
Object asm/overlay_31002382AC0.o
}
Overlay OVY_32
{

View File

@ -2,10 +2,22 @@
extern u32 DUNGEON_WINDOW_PARAMS_3[];
extern struct {u32* a; u32 b;} OVERLAY31_UNKNOWN_POINTER__NA_238A260;
extern struct dungeon* DUNGEON_PTR;
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
// 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*);
void EntryOverlay31(void) {
u32* r0 = (u32*)sub_020348E4(DUNGEON_WINDOW_PARAMS_3);
@ -16,6 +28,73 @@ void EntryOverlay31(void) {
OVERLAY31_UNKNOWN_POINTER__NA_238A260.a = r0;
r0[1] = 0;
OVERLAY31_UNKNOWN_POINTER__NA_238A260.b = 0xa;
return;
}
void DrawDungeonMenuStatusWindow(struct Window* window)
{
struct PPStrValues str_values;
u8 str_buff[DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE];
u8 member_name_buffer[256];
struct entity* leader;
struct leader_info* leader_info;
u8* str;
s32 line_offset;
u8 is_valid_member;
s32 i;
leader = GetLeader();
leader_info = (struct leader_info*)leader->info;
str_values.digits_0 = CeilFixedPoint(leader_info->belly);
str_values.digits_1 = CeilFixedPoint(leader_info->max_belly);
str = StringFromId(DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_1);
PreprocessString(str_buff, DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE, str, 0, &str_values);
DrawTextInWindow(window, X_OFFSET, 0, str_buff);
str_values.gold_left_0 = GetMoneyCarried();
str = StringFromId(DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_2);
PreprocessString(str_buff, DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE, str, 0, &str_values);
DrawTextInWindow(window, X_OFFSET, LINE_HEIGHT, str_buff);
str_values.weather_0 = GetApparentWeather(0);
str = StringFromId(DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_3);
PreprocessString(str_buff, DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE, str, 0, &str_values);
DrawTextInWindow(window, X_OFFSET, LINE_HEIGHT * 2, str_buff);
str_values.time_0 = sub_0204F9E0();
str = StringFromId(DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_4);
PreprocessString(str_buff, DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE, str, DRAW_DUNGEON_MENU_STATUS_WINDOW_CONST_1, &str_values);
DrawTextInWindow(window, X_OFFSET, LINE_HEIGHT * 3, str_buff);
line_offset = 0;
for (i = 0; i < 4; i++) {
struct entity* party_member = DUNGEON_PTR->party_members[i];
if (party_member == NULL) {
is_valid_member = FALSE;
} else {
is_valid_member = (party_member->type != ENTITY_NOTHING);
}
if (is_valid_member) {
struct party_member_info* member_info = party_member->info;
ov29_022E2A78(member_name_buffer, party_member, 0);
str_values.string0 = member_name_buffer;
str_values.value_0 = member_info->hp_left;
str_values.value_1 = MIN(member_info->hp_max_1 + member_info->hp_max_2, DRAW_DUNGEON_MENU_STATUS_WINDOW_CONST_2);
str = StringFromId(DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_5);
PreprocessString(str_buff, DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE, str, 0, &str_values);
DrawTextInWindow(window, 4, line_offset, str_buff);
line_offset += 12;
if (line_offset >= 0x30) {
break;
}
}
}
UpdateWindow(window);
}