Decomped GetTurnLimit

This commit is contained in:
AnonymousRandomPerson 2025-11-15 22:36:13 -05:00
parent ad1ce11c99
commit 12e467d633
11 changed files with 134 additions and 110 deletions

View File

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

View File

@ -0,0 +1,4 @@
#pragma once
.public DUNGEON_RESTRICTIONS
.public _020A0C68
.public _020A0C69

View File

@ -166,96 +166,3 @@ DungeonGoesUp: ; 0x02051288
.align 2, 0
_020512AC: .word DUNGEON_RESTRICTIONS
arm_func_end DungeonGoesUp
arm_func_start GetTurnLimit
GetTurnLimit: ; 0x020512B0
mov r1, #0xc
mul r1, r0, r1
ldr r0, _020512C4 ; =_020A0C6C
ldrsh r0, [r0, r1]
bx lr
.align 2, 0
_020512C4: .word _020A0C6C
arm_func_end GetTurnLimit
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

86
asm/main_020512C8.s Normal file
View File

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

@ -10402,8 +10402,6 @@ _020A0C69:
.global _020A0C6A
_020A0C6A:
.byte 0x04, 0x00
.global _020A0C6C
_020A0C6C:
.byte 0xE8, 0x03
.global _020A0C6E
_020A0C6E:

View File

@ -1823,14 +1823,27 @@ struct dungeon {
u8 field_0x2cb13;
};
// Entry for a single dungeon in the dungeon restriction list
struct dungeon_restriction {
// 0x0: flags: 2-byte bitfield
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;
// bool8 f_dungeon_goes_up : 1; // Dungeon goes up (stairs ascend, floors are labeled 1F, 2F, ...)
// bool8 f_enemies_evolve : 1; // Enemies evolve after they defeat another monster
// bool8 f_enemies_give_exp : 1; // Enemies give experience
// bool8 f_recruitment_allowed : 1; // Recruitment is allowed
// bool8 f_reset_to_level_1 : 1; // Team members are reset to level 1 for the dungeon
// bool8 f_money_allowed : 1; // Money is allowed to be brought into the dungeon
// bool8 f_leader_change_enabled : 1; // The team leader can be changed within the dungeon
// bool8 f_enter_without_saving : 1; // If false, the game will be saved upon entering
// bool8 f_disable_iq_skills : 1; // IQ skills won't work in the dungeon
// bool8 f_no_trap_uncovering : 1; // Traps cannot be revealed by attacking or throwing items
// bool8 f_treasure_box_drops : 1; // Enemies can drop Treasure Boxes
u8 max_rescue_attempts; // 0x4: 0xFF means no rescues allowed
u8 max_items_allowed; // 0x5: Maximum number of items that can be brought into the dungeon
u8 max_party_size; // 0x6: Maximum number of team members that can enter the dungeon
s16 turn_limit_per_floor; // 0x8: Number of turns per floor before the wind blows you out
// 0xA: Chance of setting the monster::random_movement field to 1 when spawning an enemy
s16 random_movement_chance;
};
#endif // PMDSKY_DUNGEON_H

9
include/main_020512B0.h Normal file
View File

@ -0,0 +1,9 @@
#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

@ -94,6 +94,8 @@ Static main
Object asm/main_0204DE7C.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

View File

@ -3,10 +3,9 @@
#include "dungeon_mode.h"
#include "dungeon_util_static.h"
#include "fixed_room_data_1.h"
#include "main_020512B0.h"
#include "util.h"
extern s32 GetTurnLimit(enum dungeon_id dungeon_id);
bool8 IsMonsterLoneOutlaw(struct monster* monster_info)
{
return IsBehaviorLoneOutlaw(monster_info->monster_behavior);

View File

@ -4,7 +4,7 @@
#include "enums.h"
#include "util.h"
extern struct dungeon_restriction DUNGEON_RESTRICTIONS[];
extern struct dungeon_restriction DUNGEON_RESTRICTIONS[256];
bool8 IsRecruitingAllowed(enum dungeon_id dungeon_id)
{

9
src/main_020512B0.c Normal file
View File

@ -0,0 +1,9 @@
#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;
}