From 52831afb6641acb923fbab116f049cb9d79fd127 Mon Sep 17 00:00:00 2001 From: chordtoll Date: Mon, 21 Oct 2024 22:19:56 -0700 Subject: [PATCH] Disassemble more dungeon functions --- asm/include/overlay_29_0231CBEC.inc | 2 +- asm/include/overlay_29_02337CCC.inc | 4 - asm/include/overlay_29_02338560.inc | 5 + asm/overlay_29_0231CBEC.s | 2 +- asm/overlay_29_02337CCC.s | 162 ---------------------------- asm/overlay_29_02338560.s | 43 ++++++++ include/overlay_29_02338548.h | 12 +++ include/overlay_29_02338604.h | 2 + main.lsf | 2 + src/overlay_29_02338548.c | 35 ++++++ src/overlay_29_02338604.c | 15 +++ 11 files changed, 116 insertions(+), 168 deletions(-) create mode 100644 asm/include/overlay_29_02338560.inc create mode 100644 asm/overlay_29_02338560.s create mode 100644 include/overlay_29_02338548.h create mode 100644 src/overlay_29_02338548.c diff --git a/asm/include/overlay_29_0231CBEC.inc b/asm/include/overlay_29_0231CBEC.inc index 02760c03..3c7e8c73 100644 --- a/asm/include/overlay_29_0231CBEC.inc +++ b/asm/include/overlay_29_0231CBEC.inc @@ -103,7 +103,7 @@ .public ov29_02305814 .public ov29_0233665C .public ov29_0233785C -.public ov29_02338530 +.public GetDoughSeedFlag .public ov29_02339FF4 .public ov29_0233FB1C .public ov29_02344B44 diff --git a/asm/include/overlay_29_02337CCC.inc b/asm/include/overlay_29_02337CCC.inc index ccfc9ef5..3cff9c5b 100644 --- a/asm/include/overlay_29_02337CCC.inc +++ b/asm/include/overlay_29_02337CCC.inc @@ -12,7 +12,6 @@ .public GetVictoriesOnOneFloor .public HiddenStairsTrigger .public IqSkillIsEnabled -.public IsFullFloorFixedRoom .public LogMessageByIdWithPopupCheckUser .public MemAlloc .public MemFree @@ -21,7 +20,6 @@ .public RandInt .public SECONDARY_TERRAIN_TYPES .public SetVictoriesOnOneFloor -.public TeamMemberHasExclusiveItemEffectActive .public UpdateTrapsVisibility .public ov10_022C6327 .public ov29_022E66C4 @@ -30,5 +28,3 @@ .public ov29_02304BAC .public ov29_02306D54 .public ov29_02336694 -.public ov29_02344E88 -.public ov29_02352B5C diff --git a/asm/include/overlay_29_02338560.inc b/asm/include/overlay_29_02338560.inc new file mode 100644 index 00000000..03bf576e --- /dev/null +++ b/asm/include/overlay_29_02338560.inc @@ -0,0 +1,5 @@ +#pragma once +.public DUNGEON_PTR +.public IsFullFloorFixedRoom +.public ov29_02344E88 +.public ov29_02352B5C diff --git a/asm/overlay_29_0231CBEC.s b/asm/overlay_29_0231CBEC.s index 9c278dc0..04e924cb 100644 --- a/asm/overlay_29_0231CBEC.s +++ b/asm/overlay_29_0231CBEC.s @@ -893,7 +893,7 @@ ApplyDoughSeedEffect: ; 0x0231D6E0 ldrb r0, [r0, #6] cmp r0, #0 bne _0231D730 - bl ov29_02338530 + bl GetDoughSeedFlag cmp r0, #0 bne _0231D730 mov r0, #1 diff --git a/asm/overlay_29_02337CCC.s b/asm/overlay_29_02337CCC.s index ee25d726..79015e83 100644 --- a/asm/overlay_29_02337CCC.s +++ b/asm/overlay_29_02337CCC.s @@ -694,165 +694,3 @@ _023384BC: .word 0x00012A5A _023384BC: .word 0x00012AFE #endif arm_func_end ov29_0233847C - - arm_func_start ShouldBoostKecleonShopSpawnChance -ShouldBoostKecleonShopSpawnChance: ; 0x023384C0 - ldr r0, _023384D4 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x12000 -#ifdef JAPAN - ldrb r0, [r0, #0xa80] -#else - ldrb r0, [r0, #0xb24] -#endif - bx lr - .align 2, 0 -_023384D4: .word DUNGEON_PTR - arm_func_end ShouldBoostKecleonShopSpawnChance - - arm_func_start SetShouldBoostKecleonShopSpawnChance -SetShouldBoostKecleonShopSpawnChance: ; 0x023384D8 - ldr r1, _023384EC ; =DUNGEON_PTR - ldr r1, [r1] - add r1, r1, #0x12000 -#ifdef JAPAN - strb r0, [r1, #0xa80] -#else - strb r0, [r1, #0xb24] -#endif - bx lr - .align 2, 0 -_023384EC: .word DUNGEON_PTR - arm_func_end SetShouldBoostKecleonShopSpawnChance - - arm_func_start UpdateShouldBoostKecleonShopSpawnChance -UpdateShouldBoostKecleonShopSpawnChance: ; 0x023384F0 - stmdb sp!, {r3, lr} - ldr r0, _0233852C ; =DUNGEON_PTR - mov r2, #0 - ldr r1, [r0] - mov r0, #0x5e - add r1, r1, #0x12000 -#ifdef JAPAN - strb r2, [r1, #0xa80] -#else - strb r2, [r1, #0xb24] -#endif - bl TeamMemberHasExclusiveItemEffectActive - cmp r0, #0 - ldrne r0, _0233852C ; =DUNGEON_PTR - movne r1, #1 - ldrne r0, [r0] - addne r0, r0, #0x12000 -#ifdef JAPAN - strneb r1, [r0, #0xa80] -#else - strneb r1, [r0, #0xb24] -#endif - ldmia sp!, {r3, pc} - .align 2, 0 -_0233852C: .word DUNGEON_PTR - arm_func_end UpdateShouldBoostKecleonShopSpawnChance - - arm_func_start ov29_02338530 -ov29_02338530: ; 0x02338530 - ldr r0, _02338544 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x4000 -#ifdef JAPAN - ldrb r0, [r0, #0x24] -#else - ldrb r0, [r0, #0xc8] -#endif - bx lr - .align 2, 0 -_02338544: .word DUNGEON_PTR - arm_func_end ov29_02338530 - - arm_func_start SetDoughSeedFlag -SetDoughSeedFlag: ; 0x02338548 - ldr r1, _0233855C ; =DUNGEON_PTR - ldr r1, [r1] - add r1, r1, #0x4000 -#ifdef JAPAN - strb r0, [r1, #0x24] -#else - strb r0, [r1, #0xc8] -#endif - bx lr - .align 2, 0 -_0233855C: .word DUNGEON_PTR - arm_func_end SetDoughSeedFlag - - arm_func_start TrySpawnDoughSeedPoke -TrySpawnDoughSeedPoke: ; 0x02338560 - stmdb sp!, {r3, lr} - ldr r0, _023385BC ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x4000 -#ifdef JAPAN - ldrb r0, [r0, #0x24] -#else - ldrb r0, [r0, #0xc8] -#endif - cmp r0, #0 - ldmeqia sp!, {r3, pc} - bl IsFullFloorFixedRoom - cmp r0, #0 - bne _023385A4 - ldr r1, _023385C0 ; =ov29_02352B5C - add r0, sp, #0 - ldrh r2, [r1] - strh r2, [sp] - ldrh r1, [r1, #2] - strh r1, [sp, #2] - bl ov29_02344E88 -_023385A4: - ldr r0, _023385BC ; =DUNGEON_PTR - mov r1, #0 - ldr r0, [r0] - add r0, r0, #0x4000 -#ifdef JAPAN - strb r1, [r0, #0x24] -#else - strb r1, [r0, #0xc8] -#endif - ldmia sp!, {r3, pc} - .align 2, 0 -_023385BC: .word DUNGEON_PTR -_023385C0: .word ov29_02352B5C - arm_func_end TrySpawnDoughSeedPoke - - arm_func_start IsSecretBazaar -IsSecretBazaar: ; 0x023385C4 - ldr r0, _023385E8 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x4000 -#ifdef JAPAN - ldrb r0, [r0, #0x36] -#else - ldrb r0, [r0, #0xda] -#endif - cmp r0, #0x70 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - .align 2, 0 -_023385E8: .word DUNGEON_PTR - arm_func_end IsSecretBazaar - - arm_func_start ShouldBoostHiddenStairsSpawnChance -ShouldBoostHiddenStairsSpawnChance: ; 0x023385EC - ldr r0, _02338600 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x12000 -#ifdef JAPAN - ldrb r0, [r0, #0xa81] -#else - ldrb r0, [r0, #0xb25] -#endif - bx lr - .align 2, 0 -_02338600: .word DUNGEON_PTR - arm_func_end ShouldBoostHiddenStairsSpawnChance diff --git a/asm/overlay_29_02338560.s b/asm/overlay_29_02338560.s new file mode 100644 index 00000000..682d6e3c --- /dev/null +++ b/asm/overlay_29_02338560.s @@ -0,0 +1,43 @@ + .include "asm/macros.inc" + .include "overlay_29_02338560.inc" + + .text + + arm_func_start TrySpawnDoughSeedPoke +TrySpawnDoughSeedPoke: ; 0x02338560 + stmdb sp!, {r3, lr} + ldr r0, _023385BC ; =DUNGEON_PTR + ldr r0, [r0] + add r0, r0, #0x4000 +#ifdef JAPAN + ldrb r0, [r0, #0x24] +#else + ldrb r0, [r0, #0xc8] +#endif + cmp r0, #0 + ldmeqia sp!, {r3, pc} + bl IsFullFloorFixedRoom + cmp r0, #0 + bne _023385A4 + ldr r1, _023385C0 ; =ov29_02352B5C + add r0, sp, #0 + ldrh r2, [r1] + strh r2, [sp] + ldrh r1, [r1, #2] + strh r1, [sp, #2] + bl ov29_02344E88 +_023385A4: + ldr r0, _023385BC ; =DUNGEON_PTR + mov r1, #0 + ldr r0, [r0] + add r0, r0, #0x4000 +#ifdef JAPAN + strb r1, [r0, #0x24] +#else + strb r1, [r0, #0xc8] +#endif + ldmia sp!, {r3, pc} + .align 2, 0 +_023385BC: .word DUNGEON_PTR +_023385C0: .word ov29_02352B5C + arm_func_end TrySpawnDoughSeedPoke diff --git a/include/overlay_29_02338548.h b/include/overlay_29_02338548.h new file mode 100644 index 00000000..74376512 --- /dev/null +++ b/include/overlay_29_02338548.h @@ -0,0 +1,12 @@ +#ifndef PMDSKY_OVERLAY_29_02338548_H +#define PMDSKY_OVERLAY_29_02338548_H + +#include "util.h" + +bool ShouldBoostKecleonShopSpawnChance(void); +void SetShouldBoostKecleonShopSpawnChance(bool boost); +void UpdateShouldBoostKecleonShopSpawnChance(void); +bool GetDoughSeedFlag(void); +void SetDoughSeedFlag(bool flag); + +#endif //PMDSKY_OVERLAY_29_02338548_H diff --git a/include/overlay_29_02338604.h b/include/overlay_29_02338604.h index 22bd69ff..7664d066 100644 --- a/include/overlay_29_02338604.h +++ b/include/overlay_29_02338604.h @@ -1,6 +1,8 @@ #ifndef PMDSKY_OVERLAY_29_02338604_H #define PMDSKY_OVERLAY_29_02338604_H +u8 IsSecretBazaar(); +u8 ShouldBoostHiddenStairsSpawnChance(); void SetShouldBoostHiddenStairsSpawnChance(u8 should_boost); #endif //PMDSKY_OVERLAY_29_02338604_H diff --git a/main.lsf b/main.lsf index 81ba3279..ec09cc4c 100644 --- a/main.lsf +++ b/main.lsf @@ -311,6 +311,8 @@ Overlay OVY_29 Object asm/overlay_29_023350FC.o Object src/overlay_29_02337CA8.o Object asm/overlay_29_02337CCC.o + Object src/overlay_29_02338548.o + Object asm/overlay_29_02338560.o Object src/overlay_29_02338604.o Object asm/overlay_29_0233861C.o Object src/overlay_29_02344AF8.o diff --git a/src/overlay_29_02338548.c b/src/overlay_29_02338548.c new file mode 100644 index 00000000..fa6e5171 --- /dev/null +++ b/src/overlay_29_02338548.c @@ -0,0 +1,35 @@ +#include "overlay_29_02338548.h" + +#include "dungeon.h" + +extern struct dungeon* DUNGEON_PTR[]; +bool TeamMemberHasExclusiveItemEffectActive(u8); + +bool ShouldBoostKecleonShopSpawnChance(void) +{ + return DUNGEON_PTR[0]->boost_kecleon_shop_spawn_chance; +} + +void SetShouldBoostKecleonShopSpawnChance(bool boost) +{ + DUNGEON_PTR[0]->boost_kecleon_shop_spawn_chance=boost; +} + +void UpdateShouldBoostKecleonShopSpawnChance(void) +{ + DUNGEON_PTR[0]->boost_kecleon_shop_spawn_chance = FALSE; + if (TeamMemberHasExclusiveItemEffectActive(0x5e)) { + DUNGEON_PTR[0]->boost_kecleon_shop_spawn_chance = TRUE; + } +} + +bool GetDoughSeedFlag(void) +{ + return DUNGEON_PTR[0]->gen_info.dough_seed_extra_poke_flag; +} + + +void SetDoughSeedFlag(bool flag) +{ + DUNGEON_PTR[0]->gen_info.dough_seed_extra_poke_flag=flag; +} diff --git a/src/overlay_29_02338604.c b/src/overlay_29_02338604.c index dc920b74..27e764cf 100644 --- a/src/overlay_29_02338604.c +++ b/src/overlay_29_02338604.c @@ -4,6 +4,21 @@ extern struct dungeon* DUNGEON_PTR[]; +u8 IsSecretBazaar() +{ + return DUNGEON_PTR[0]->gen_info.fixed_room_id==FIXED_SECRET_BAZAAR; +} + + +u8 ShouldBoostHiddenStairsSpawnChance() +{ + #ifdef JAPAN + return DUNGEON_PTR[0]->boost_hidden_stairs_spawn_chance; + #else + return DUNGEON_PTR[0]->boost_hidden_stairs_spawn_chance; + #endif +} + void SetShouldBoostHiddenStairsSpawnChance(u8 should_boost) { #ifdef JAPAN