diff --git a/asm/include/main_02051098.inc b/asm/include/main_02051098.inc index e0e22f57..c3b14f99 100644 --- a/asm/include/main_02051098.inc +++ b/asm/include/main_02051098.inc @@ -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 diff --git a/asm/include/main_020513C0.inc b/asm/include/main_020513C0.inc new file mode 100644 index 00000000..69c3154c --- /dev/null +++ b/asm/include/main_020513C0.inc @@ -0,0 +1,4 @@ +#pragma once +.public DUNGEON_RESTRICTIONS +.public _020A0C6A +.public _020A0C6E diff --git a/asm/main_02051098.s b/asm/main_02051098.s index 1ad20fe6..bac1c586 100644 --- a/asm/main_02051098.s +++ b/asm/main_02051098.s @@ -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 diff --git a/asm/main_020513C0.s b/asm/main_020513C0.s new file mode 100644 index 00000000..a1a3d3fa --- /dev/null +++ b/asm/main_020513C0.s @@ -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 diff --git a/include/dungeon.h b/include/dungeon.h index 469f55a2..79a06cf2 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -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 diff --git a/include/dungeon_recruitment_2.h b/include/dungeon_recruitment_2.h new file mode 100644 index 00000000..4554960b --- /dev/null +++ b/include/dungeon_recruitment_2.h @@ -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 diff --git a/include/enums.h b/include/enums.h index ef64bc91..762b188d 100644 --- a/include/enums.h +++ b/include/enums.h @@ -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 diff --git a/main.lsf b/main.lsf index dac9a5ee..bb1a9c97 100644 --- a/main.lsf +++ b/main.lsf @@ -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 diff --git a/src/dungeon_recruitment_2.c b/src/dungeon_recruitment_2.c new file mode 100644 index 00000000..f6b48752 --- /dev/null +++ b/src/dungeon_recruitment_2.c @@ -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; +}