decomp dungeon restriction funcs

This commit is contained in:
Seth Barberee 2026-01-09 11:44:31 -08:00
parent ed52925052
commit f032e986f7
9 changed files with 188 additions and 258 deletions

View File

@ -1,33 +0,0 @@
.include "asm/macros.inc"
.include "main_02013B70.inc"
.text
; https://decomp.me/scratch/zfpDG
arm_func_start GetMoveActualAccuracy
GetMoveActualAccuracy: ; 0x02013B90
stmdb sp!, {r3, lr}
ldr r2, _02013BE4 ; =DUNGEON_MOVE_TABLES
mov r1, #0x1a
ldr r2, [r2, #8]
mla r1, r0, r1, r2
ldrb r0, [r1, #0xe]
cmp r0, #0
ldreqb r0, [r1, #0xa]
ldmeqia sp!, {r3, pc}
cmp r0, #0x63
bne _02013BDC
ldrb r2, [r1, #0xa]
ldrb r0, [r1, #0xb]
cmp r2, #0x7d
ldmeqia sp!, {r3, pc}
mul r0, r2, r0
mov r1, #0x64
bl _s32_div_f
ldmia sp!, {r3, pc}
_02013BDC:
mov r0, #0
ldmia sp!, {r3, pc}
.align 2, 0
_02013BE4: .word DUNGEON_MOVE_TABLES
arm_func_end GetMoveActualAccuracy

View File

@ -152,17 +152,3 @@ _02051280: .word 0x9D2C5680
_02051284: .word 0xEFC60000
arm_func_end sub_02051134
arm_func_start DungeonGoesUp
DungeonGoesUp: ; 0x02051288
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020512AC ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #1
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_020512AC: .word DUNGEON_RESTRICTIONS
arm_func_end DungeonGoesUp

View File

@ -1,86 +0,0 @@
.include "asm/macros.inc"
.include "main_020512C8.inc"
.text
arm_func_start DoesNotSaveWhenEntering
DoesNotSaveWhenEntering: ; 0x020512C8
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020512EC ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x80
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_020512EC: .word DUNGEON_RESTRICTIONS
arm_func_end DoesNotSaveWhenEntering
arm_func_start TreasureBoxDropsEnabled
TreasureBoxDropsEnabled: ; 0x020512F0
mov r1, #0xc
mul r1, r0, r1
ldr r0, _02051314 ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x400
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_02051314: .word DUNGEON_RESTRICTIONS
arm_func_end TreasureBoxDropsEnabled
arm_func_start IsLevelResetDungeon
IsLevelResetDungeon: ; 0x02051318
mov r1, #0xc
mul r1, r0, r1
ldr r0, _0205133C ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x10
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_0205133C: .word DUNGEON_RESTRICTIONS
arm_func_end IsLevelResetDungeon
arm_func_start GetMaxItemsAllowed
GetMaxItemsAllowed: ; 0x02051340
mov r1, #0xc
mul r1, r0, r1
ldr r0, _02051354 ; =_020A0C69
ldrb r0, [r0, r1]
bx lr
.align 2, 0
_02051354: .word _020A0C69
arm_func_end GetMaxItemsAllowed
arm_func_start IsMoneyAllowed
IsMoneyAllowed: ; 0x02051358
mov r1, #0xc
mul r1, r0, r1
ldr r0, _0205137C ; =DUNGEON_RESTRICTIONS
ldr r0, [r0, r1]
tst r0, #0x20
movne r0, #1
moveq r0, #0
and r0, r0, #0xff
bx lr
.align 2, 0
_0205137C: .word DUNGEON_RESTRICTIONS
arm_func_end IsMoneyAllowed
arm_func_start GetMaxRescueAttempts
GetMaxRescueAttempts: ; 0x02051380
mov r1, #0xc
mul r1, r0, r1
ldr r0, _02051394 ; =_020A0C68
ldrsb r0, [r0, r1]
bx lr
.align 2, 0
_02051394: .word _020A0C68
arm_func_end GetMaxRescueAttempts

View File

@ -1,100 +0,0 @@
.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

@ -4,6 +4,21 @@
#include "enums.h"
#include "util.h"
bool8 DungeonGoesUp(enum dungeon_id dungeon_id);
s32 GetTurnLimit(enum dungeon_id dungeon_id);
bool8 DoesNotSaveWhenEntering(enum dungeon_id dungeon_id);
bool8 TreasureBoxDropsEnabled(enum dungeon_id dungeon_id);
bool8 IsLevelResetDungeon(enum dungeon_id dungeon_id);
s32 GetMaxItemsAllowed(enum dungeon_id dungeon_id);
bool8 IsMoneyAllowed(enum dungeon_id dungeon_id);
s8 GetMaxRescueAttempts(enum dungeon_id dungeon_id);
bool8 IsRecruitingAllowed(enum dungeon_id dungeon_id);
bool8 GetLeaderChangeFlag(enum dungeon_id dungeon_id);
s32 GetRandomMovementChance(enum dungeon_id dungeon_id);
bool8 CanEnemyEvolve(enum dungeon_id dungeon_id);
s32 GetMaxMembersAllowed(enum dungeon_id dungeon_id);
bool8 IsIqEnabled(enum dungeon_id dungeon_id);
bool8 IsTrapInvisibleWhenAttacking(enum dungeon_id dungeon_id);
bool8 JoinedAtRangeCheck(enum dungeon_id dungeon_id);
#endif //PMDSKY_MAIN_02051398_H

View File

@ -1,9 +0,0 @@
#ifndef PMDSKY_MAIN_020512B0_H
#define PMDSKY_MAIN_020512B0_H
#include "enums.h"
#include "util.h"
s32 GetTurnLimit(enum dungeon_id dungeon_id);
#endif //PMDSKY_MAIN_020512B0_H

View File

@ -95,10 +95,7 @@ Static main
Object asm/main_0204EFE0.o
Object src/number_util.o
Object asm/main_02051098.o
Object src/main_020512B0.o
Object asm/main_020512C8.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

@ -6,14 +6,183 @@
extern struct dungeon_restriction DUNGEON_RESTRICTIONS[256];
bool8 IsRecruitingAllowed(enum dungeon_id dungeon_id)
bool8 DungeonGoesUp(enum dungeon_id dungeon_id)
{
bool8 return_val;
if (DUNGEON_RESTRICTIONS[dungeon_id].flags & ALLOW_RECRUITING) {
if(DUNGEON_RESTRICTIONS[dungeon_id].flags & DUNGEON_ASCENDS)
{
return_val = TRUE;
} else {
}
else
{
return_val = FALSE;
}
return return_val;
}
s32 GetTurnLimit(enum dungeon_id dungeon_id)
{
return DUNGEON_RESTRICTIONS[dungeon_id].turn_limit_per_floor;
}
bool8 DoesNotSaveWhenEntering(enum dungeon_id dungeon_id)
{
bool8 return_val;
if(DUNGEON_RESTRICTIONS[dungeon_id].flags & NO_SAVE_ON_ENTRY)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
bool8 TreasureBoxDropsEnabled(enum dungeon_id dungeon_id)
{
bool8 return_val;
if(DUNGEON_RESTRICTIONS[dungeon_id].flags & ENEMIES_DROP_CHESTS)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
bool8 IsLevelResetDungeon(enum dungeon_id dungeon_id)
{
bool8 return_val;
if(DUNGEON_RESTRICTIONS[dungeon_id].flags & RESET_TEAM_LEVEL_TO_1)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
s32 GetMaxItemsAllowed(enum dungeon_id dungeon_id)
{
return DUNGEON_RESTRICTIONS[dungeon_id].max_items_allowed;
}
bool8 IsMoneyAllowed(enum dungeon_id dungeon_id)
{
bool8 return_val;
if(DUNGEON_RESTRICTIONS[dungeon_id].flags & KEEP_MONEY_ON_ENTRY)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
s8 GetMaxRescueAttempts(enum dungeon_id dungeon_id)
{
return DUNGEON_RESTRICTIONS[dungeon_id].max_rescue_attempts;
}
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;
}
bool8 GetLeaderChangeFlag(enum dungeon_id dungeon_id)
{
bool8 return_val;
if (DUNGEON_RESTRICTIONS[dungeon_id].flags & ALLOW_LEADER_CHANGE)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
s32 GetRandomMovementChance(enum dungeon_id dungeon_id)
{
return DUNGEON_RESTRICTIONS[dungeon_id].random_movement_chance;
}
bool8 CanEnemyEvolve(enum dungeon_id dungeon_id)
{
bool8 return_val;
if (DUNGEON_RESTRICTIONS[dungeon_id].flags & ENEMIES_CAN_EVOLVE)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
s32 GetMaxMembersAllowed(enum dungeon_id dungeon_id)
{
return DUNGEON_RESTRICTIONS[dungeon_id].max_party_size;
}
bool8 IsIqEnabled(enum dungeon_id dungeon_id)
{
bool8 return_val;
if (DUNGEON_RESTRICTIONS[dungeon_id].flags & DISABLE_IQ_SKILLS)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
bool8 IsTrapInvisibleWhenAttacking(enum dungeon_id dungeon_id)
{
bool8 return_val;
if (DUNGEON_RESTRICTIONS[dungeon_id].flags & TRAPS_STAY_HIDDEN_ON_ATTACK)
{
return_val = TRUE;
}
else
{
return_val = FALSE;
}
return return_val;
}
bool8 JoinedAtRangeCheck(enum dungeon_id dungeon_id)
{
return ((dungeon_id >= DUNGEON_JOINED_AT_BIDOOF) && (dungeon_id < DUNGEON_DUMMY_0xE4));
}

View File

@ -1,9 +0,0 @@
#include "main_020512B0.h"
#include "dungeon.h"
extern struct dungeon_restriction DUNGEON_RESTRICTIONS[256];
s32 GetTurnLimit(enum dungeon_id dungeon_id)
{
return DUNGEON_RESTRICTIONS[dungeon_id].turn_limit_per_floor;
}