diff --git a/asm/include/main_02051098.inc b/asm/include/main_02051098.inc index 1714f2c8..0f056522 100644 --- a/asm/include/main_02051098.inc +++ b/asm/include/main_02051098.inc @@ -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 diff --git a/asm/include/main_020512C8.inc b/asm/include/main_020512C8.inc new file mode 100644 index 00000000..ac3c8096 --- /dev/null +++ b/asm/include/main_020512C8.inc @@ -0,0 +1,4 @@ +#pragma once +.public DUNGEON_RESTRICTIONS +.public _020A0C68 +.public _020A0C69 diff --git a/asm/main_02051098.s b/asm/main_02051098.s index bac1c586..9a3e7e53 100644 --- a/asm/main_02051098.s +++ b/asm/main_02051098.s @@ -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 diff --git a/asm/main_020512C8.s b/asm/main_020512C8.s new file mode 100644 index 00000000..bd9aad70 --- /dev/null +++ b/asm/main_020512C8.s @@ -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 diff --git a/asm/main_rodata_020908D4.s b/asm/main_rodata_020908D4.s index 0fc0af95..450ab3f7 100644 --- a/asm/main_rodata_020908D4.s +++ b/asm/main_rodata_020908D4.s @@ -10402,8 +10402,6 @@ _020A0C69: .global _020A0C6A _020A0C6A: .byte 0x04, 0x00 - .global _020A0C6C -_020A0C6C: .byte 0xE8, 0x03 .global _020A0C6E _020A0C6E: diff --git a/include/dungeon.h b/include/dungeon.h index 5150752d..b21da84b 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -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 diff --git a/include/main_020512B0.h b/include/main_020512B0.h new file mode 100644 index 00000000..bec3477d --- /dev/null +++ b/include/main_020512B0.h @@ -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 diff --git a/main.lsf b/main.lsf index 10fda222..1ff17fe6 100644 --- a/main.lsf +++ b/main.lsf @@ -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 diff --git a/src/dungeon_logic_7.c b/src/dungeon_logic_7.c index 152f7c8a..e8277238 100644 --- a/src/dungeon_logic_7.c +++ b/src/dungeon_logic_7.c @@ -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); diff --git a/src/dungeon_recruitment_2.c b/src/dungeon_recruitment_2.c index f6b48752..7eadff2b 100644 --- a/src/dungeon_recruitment_2.c +++ b/src/dungeon_recruitment_2.c @@ -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) { diff --git a/src/main_020512B0.c b/src/main_020512B0.c new file mode 100644 index 00000000..2c12582e --- /dev/null +++ b/src/main_020512B0.c @@ -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; +}