Decomp IsRecruitingAllowed

This commit is contained in:
slaw-22 2025-09-29 20:01:20 +00:00
parent 7e20d92e17
commit 9016a31ff3
9 changed files with 165 additions and 119 deletions

View File

@ -1,12 +1,10 @@
#pragma once
.public _020A0C68
.public _020A0C69
.public _020A0C6A
.public _020A0C6C
.public _020A0C6E
.public _020AFF7C
.public _020AFF80
.public _020AFF88
.public CopyBitsFrom
.public CopyBitsTo
.public DUNGEON_RESTRICTIONS
.public _020A0C68
.public _020A0C69
.public _020A0C6C
.public _020AFF7C
.public _020AFF80
.public _020AFF88

View File

@ -0,0 +1,4 @@
#pragma once
.public DUNGEON_RESTRICTIONS
.public _020A0C6A
.public _020A0C6E

View File

@ -259,114 +259,3 @@ GetMaxRescueAttempts: ; 0x02051380
.align 2, 0
_02051394: .word _020A0C68
arm_func_end GetMaxRescueAttempts
arm_func_start IsRecruitingAllowed
IsRecruitingAllowed: ; 0x02051398
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020513BC ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #8
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_020513BC: .word DUNGEON_RESTRICTIONS
arm_func_end IsRecruitingAllowed
arm_func_start GetLeaderChangeFlag
GetLeaderChangeFlag: ; 0x020513C0
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020513E4 ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x40
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_020513E4: .word DUNGEON_RESTRICTIONS
arm_func_end GetLeaderChangeFlag
arm_func_start GetRandomMovementChance
GetRandomMovementChance: ; 0x020513E8
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020513FC ; =_020A0C6E
ldrsh r0, [r0, r1]
bx lr
.align 2, 0
_020513FC: .word _020A0C6E
arm_func_end GetRandomMovementChance
arm_func_start CanEnemyEvolve
CanEnemyEvolve: ; 0x02051400
mov r1, #0xc
mul r1, r0, r1
ldr r0, _02051424 ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #2
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_02051424: .word DUNGEON_RESTRICTIONS
arm_func_end CanEnemyEvolve
arm_func_start GetMaxMembersAllowed
GetMaxMembersAllowed: ; 0x02051428
mov r1, #0xc
mul r1, r0, r1
ldr r0, _0205143C ; =_020A0C6A
ldrb r0, [r0, r1]
bx lr
.align 2, 0
_0205143C: .word _020A0C6A
arm_func_end GetMaxMembersAllowed
arm_func_start IsIqEnabled
IsIqEnabled: ; 0x02051440
mov r1, #0xc
mul r1, r0, r1
ldr r0, _02051464 ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x100
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_02051464: .word DUNGEON_RESTRICTIONS
arm_func_end IsIqEnabled
arm_func_start IsTrapInvisibleWhenAttacking
IsTrapInvisibleWhenAttacking: ; 0x02051468
mov r1, #0xc
mul r1, r0, r1
ldr r0, _0205148C ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x200
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_0205148C: .word DUNGEON_RESTRICTIONS
arm_func_end IsTrapInvisibleWhenAttacking
arm_func_start JoinedAtRangeCheck
JoinedAtRangeCheck: ; 0x02051490
cmp r0, #0xd9
blo _020514A4
cmp r0, #0xe4
movlo r0, #1
blo _020514A8
_020514A4:
mov r0, #0
_020514A8:
and r0, r0, #0xff
bx lr
arm_func_end JoinedAtRangeCheck

100
asm/main_020513C0.s Normal file
View File

@ -0,0 +1,100 @@
.include "asm/macros.inc"
.include "main_020513C0.inc"
.text
arm_func_start GetLeaderChangeFlag
GetLeaderChangeFlag: ; 0x020513C0
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020513E4 ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x40
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_020513E4: .word DUNGEON_RESTRICTIONS
arm_func_end GetLeaderChangeFlag
arm_func_start GetRandomMovementChance
GetRandomMovementChance: ; 0x020513E8
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020513FC ; =_020A0C6E
ldrsh r0, [r0, r1]
bx lr
.align 2, 0
_020513FC: .word _020A0C6E
arm_func_end GetRandomMovementChance
arm_func_start CanEnemyEvolve
CanEnemyEvolve: ; 0x02051400
mov r1, #0xc
mul r1, r0, r1
ldr r0, _02051424 ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #2
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_02051424: .word DUNGEON_RESTRICTIONS
arm_func_end CanEnemyEvolve
arm_func_start GetMaxMembersAllowed
GetMaxMembersAllowed: ; 0x02051428
mov r1, #0xc
mul r1, r0, r1
ldr r0, _0205143C ; =_020A0C6A
ldrb r0, [r0, r1]
bx lr
.align 2, 0
_0205143C: .word _020A0C6A
arm_func_end GetMaxMembersAllowed
arm_func_start IsIqEnabled
IsIqEnabled: ; 0x02051440
mov r1, #0xc
mul r1, r0, r1
ldr r0, _02051464 ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x100
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_02051464: .word DUNGEON_RESTRICTIONS
arm_func_end IsIqEnabled
arm_func_start IsTrapInvisibleWhenAttacking
IsTrapInvisibleWhenAttacking: ; 0x02051468
mov r1, #0xc
mul r1, r0, r1
ldr r0, _0205148C ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x200
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_0205148C: .word DUNGEON_RESTRICTIONS
arm_func_end IsTrapInvisibleWhenAttacking
arm_func_start JoinedAtRangeCheck
JoinedAtRangeCheck: ; 0x02051490
cmp r0, #0xd9
blo _020514A4
cmp r0, #0xe4
movlo r0, #1
blo _020514A8
_020514A4:
mov r0, #0
_020514A8:
and r0, r0, #0xff
bx lr
arm_func_end JoinedAtRangeCheck

View File

@ -1779,4 +1779,14 @@ struct dungeon {
u8 field_0x2cb13;
};
struct dungeon_restriction {
u32 flags;
u8 max_rescue_attempts;
u8 max_items_allowed;
u8 max_party_size;
u8 pad;
u16 turn_limit_per_floor;
u16 random_movement_chance;
};
#endif // PMDSKY_DUNGEON_H

View File

@ -0,0 +1,9 @@
#ifndef PMDSKY_MAIN_02051398_H
#define PMDSKY_MAIN_02051398_H
#include "enums.h"
#include "util.h"
bool8 IsRecruitingAllowed(enum dungeon_id dungeon_id);
#endif //PMDSKY_MAIN_02051398_H

View File

@ -2931,4 +2931,19 @@ enum pack_file_id {
PACK_ARCHIVE_M_LEVEL = 5,
};
enum dungeon_restriction_flags {
DUNGEON_ASCENDS = 1 << 0, // 0 if dungeon goes down, 1 if it goes up
ENEMIES_CAN_EVOLVE = 1 << 1,
GRANT_XP = 1 << 2, // when defeating enemies
ALLOW_RECRUITING = 1 << 3,
RESET_TEAM_LEVEL_TO_1 = 1 << 4, // when entering
KEEP_MONEY_ON_ENTRY = 1 << 5, // 0 if money is lost when entering
ALLOW_LEADER_CHANGE = 1 << 6,
NO_SAVE_ON_ENTRY = 1 << 7,
DISABLE_IQ_SKILLS = 1 << 8,
TRAPS_STAY_HIDDEN_ON_ATTACK = 1 << 9, // true if traps remain invisible when attacked / item-thrown
ENEMIES_DROP_CHESTS = 1 << 10
// Remaining flags are unused
};
#endif //PMDSKY_ENUMS_H

View File

@ -83,6 +83,8 @@ Static main
Object asm/main_0204DE7C.o
Object src/number_util.o
Object asm/main_02051098.o
Object src/dungeon_recruitment_2.o
Object asm/main_020513C0.o
Object src/main_020514CC.o
Object asm/main_02051504.o
Object src/main_02051760.o

View File

@ -0,0 +1,19 @@
#include "dungeon_recruitment_2.h"
#include "dungeon.h"
#include "enums.h"
#include "util.h"
extern struct dungeon_restriction DUNGEON_RESTRICTIONS[];
bool8 IsRecruitingAllowed(enum dungeon_id dungeon_id)
{
bool8 return_val;
if (DUNGEON_RESTRICTIONS[dungeon_id].flags & ALLOW_RECRUITING) {
return_val = TRUE;
} else {
return_val = FALSE;
}
return return_val;
}