From 5c895f8a1d50112502e2eeb0979c9bef9414ed5b Mon Sep 17 00:00:00 2001 From: cecilarmitais Date: Tue, 18 Aug 2026 01:38:01 -0700 Subject: [PATCH] Decomp nine mission predicates against a faithful scratch context Decompile from asm: IsOutlawMonsterHouseFloor IsDestinationFloorWithMonster IsGoldenChamber MissionTargetEnemyIsDefeated IsJirachiChallengeFloor SetMissionTargetEnemyDefeated IsDestinationFloorWithFixedRoom IsDestinationFloorWithHiddenOutlaw GetMissionEnemyMinionGroup These are the functions the two previous commits could not land. The obstacle was the scratch context, not the C, and this commit is the result of replacing it. The context is now the real headers rather than a hand-written struct: mwccarm -E over a file including global.pch, dungeon.h and mission.h, with LM_LICENSE_FILE set, gives 14500 lines reproducing what the build actually sees. Two things that took finding. global.pch is required -- without it util.h fails at typedef s32 fx32_8, because s32 comes from nitro.h, which the build supplies through -prefix rather than through any include in dungeon.h. And -E consumes every macro, so TRUE, FALSE and NULL have to be restored by hand afterwards; their values are taken from lib/include/nitro/types.h, NULL being ((void *)0) on the C branch. Against that context the earlier verdicts change. All eight functions landed in the two previous commits still score 0, which is the check that the new oracle agrees with the build. Eight of the thirteen unlanded ones score 0 unchanged and are landed here as written. GetMissionEnemyMinionGroup does not: the real headers let the compiler fold the +1 of enemy_species[index + 1] into the load displacement, one instruction shorter than the target. Binding index + 1 to a local first blocks the fold and scores 0, which is what is landed. Four remain unmatched and are genuinely unmatched rather than mis-measured: IsCurrentMissionType and IsCurrentMissionTypeExact at 515, where the target branches to separate return blocks and every spelling tried so far produces predicated moves; GetItemToRetrieve at 665 and GetItemToDeliver at 1530. Their scores are identical under both contexts, so the context was never their problem. The mission_type arguments use the enumerators from mission.h -- ARREST_OUTLAW, EXPLORE_WITH_CLIENT, TAKE_ITEM_FROM_OUTLAW and CHALLENGE_REQUEST -- because the build rejects the implicit conversion from int. The values agree with the function names rather than being chosen to fit them. No comments are added to any pmd-sky file. Authored by Claude (Opus 5) under human direction. Confirmed by a matching build: build/pmdsky.us/pmdsky.us.nds: OK. Co-Authored-By: Claude Opus 5 --- asm/include/overlay_29_0234921C.inc | 3 - asm/include/overlay_29_023492D4.inc | 3 + asm/include/overlay_29_02349378.inc | 5 + asm/include/overlay_29_023494CC.inc | 4 + asm/include/overlay_29_023495E8.inc | 2 + ...9_02349638.inc => overlay_29_02349658.inc} | 0 asm/overlay_29_0234921C.s | 319 ------------------ asm/overlay_29_023492D4.s | 26 ++ asm/overlay_29_02349378.s | 83 +++++ asm/overlay_29_023494CC.s | 90 +++++ asm/overlay_29_023495E8.s | 23 ++ ...ay_29_02349638.s => overlay_29_02349658.s} | 15 +- include/overlay_29_0234928C.h | 10 + include/overlay_29_02349314.h | 10 + include/overlay_29_02349470.h | 11 + include/overlay_29_023495C4.h | 9 + include/overlay_29_02349620.h | 1 + main.lsf | 10 +- src/overlay_29_0234928C.c | 21 ++ src/overlay_29_02349314.c | 24 ++ src/overlay_29_02349470.c | 35 ++ src/overlay_29_023495C4.c | 16 + src/overlay_29_02349620.c | 7 + 23 files changed, 390 insertions(+), 337 deletions(-) create mode 100644 asm/include/overlay_29_023492D4.inc create mode 100644 asm/include/overlay_29_02349378.inc create mode 100644 asm/include/overlay_29_023494CC.inc create mode 100644 asm/include/overlay_29_023495E8.inc rename asm/include/{overlay_29_02349638.inc => overlay_29_02349658.inc} (100%) create mode 100644 asm/overlay_29_023492D4.s create mode 100644 asm/overlay_29_02349378.s create mode 100644 asm/overlay_29_023494CC.s create mode 100644 asm/overlay_29_023495E8.s rename asm/{overlay_29_02349638.s => overlay_29_02349658.s} (50%) create mode 100644 include/overlay_29_0234928C.h create mode 100644 include/overlay_29_02349314.h create mode 100644 include/overlay_29_02349470.h create mode 100644 include/overlay_29_023495C4.h create mode 100644 src/overlay_29_0234928C.c create mode 100644 src/overlay_29_02349314.c create mode 100644 src/overlay_29_02349470.c create mode 100644 src/overlay_29_023495C4.c diff --git a/asm/include/overlay_29_0234921C.inc b/asm/include/overlay_29_0234921C.inc index 8ea4159d..a00f434c 100644 --- a/asm/include/overlay_29_0234921C.inc +++ b/asm/include/overlay_29_0234921C.inc @@ -1,5 +1,2 @@ #pragma once .public DUNGEON_PTR -.public FloorHasMissionMonster -.public GetSpriteFileSize -.public LoadMonsterSprite diff --git a/asm/include/overlay_29_023492D4.inc b/asm/include/overlay_29_023492D4.inc new file mode 100644 index 00000000..eacd8bdb --- /dev/null +++ b/asm/include/overlay_29_023492D4.inc @@ -0,0 +1,3 @@ +#pragma once +.public DUNGEON_PTR +.public IsCurrentMissionType diff --git a/asm/include/overlay_29_02349378.inc b/asm/include/overlay_29_02349378.inc new file mode 100644 index 00000000..8ea4159d --- /dev/null +++ b/asm/include/overlay_29_02349378.inc @@ -0,0 +1,5 @@ +#pragma once +.public DUNGEON_PTR +.public FloorHasMissionMonster +.public GetSpriteFileSize +.public LoadMonsterSprite diff --git a/asm/include/overlay_29_023494CC.inc b/asm/include/overlay_29_023494CC.inc new file mode 100644 index 00000000..9cf0fc4d --- /dev/null +++ b/asm/include/overlay_29_023494CC.inc @@ -0,0 +1,4 @@ +#pragma once +.public DUNGEON_PTR +.public IsCurrentMissionType +.public IsCurrentMissionTypeExact diff --git a/asm/include/overlay_29_023495E8.inc b/asm/include/overlay_29_023495E8.inc new file mode 100644 index 00000000..c2fa61c3 --- /dev/null +++ b/asm/include/overlay_29_023495E8.inc @@ -0,0 +1,2 @@ +#pragma once +.public IsCurrentMissionTypeExact diff --git a/asm/include/overlay_29_02349638.inc b/asm/include/overlay_29_02349658.inc similarity index 100% rename from asm/include/overlay_29_02349638.inc rename to asm/include/overlay_29_02349658.inc diff --git a/asm/overlay_29_0234921C.s b/asm/overlay_29_0234921C.s index c5e15ddb..d63c8871 100644 --- a/asm/overlay_29_0234921C.s +++ b/asm/overlay_29_0234921C.s @@ -44,322 +44,3 @@ _02349280: .align 2, 0 _02349288: .word DUNGEON_PTR arm_func_end IsCurrentMissionTypeExact - - arm_func_start IsOutlawMonsterHouseFloor -IsOutlawMonsterHouseFloor: ; 0x0234928C - stmdb sp!, {r3, lr} - mov r0, #0xa - mov r1, #7 - bl IsCurrentMissionTypeExact - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - arm_func_end IsOutlawMonsterHouseFloor - - arm_func_start IsGoldenChamber -IsGoldenChamber: ; 0x023492B0 - stmdb sp!, {r3, lr} - mov r0, #3 - mov r1, #2 - bl IsCurrentMissionTypeExact - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - arm_func_end IsGoldenChamber - - arm_func_start IsLegendaryChallengeFloor -IsLegendaryChallengeFloor: ; 0x023492D4 - stmdb sp!, {r3, lr} - mov r0, #0xb - bl IsCurrentMissionType - cmp r0, #0 - beq _02349308 - ldr r0, _02349310 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x762] - add r0, r0, #0xff - and r0, r0, #0xff - cmp r0, #4 - movls r0, #1 - ldmlsia sp!, {r3, pc} -_02349308: - mov r0, #0 - ldmia sp!, {r3, pc} - .align 2, 0 -_02349310: .word DUNGEON_PTR - arm_func_end IsLegendaryChallengeFloor - - arm_func_start IsJirachiChallengeFloor -IsJirachiChallengeFloor: ; 0x02349314 - stmdb sp!, {r3, lr} - mov r0, #0xb - bl IsCurrentMissionType - cmp r0, #0 - beq _02349340 - ldr r0, _02349348 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x762] - cmp r0, #5 - moveq r0, #1 - ldmeqia sp!, {r3, pc} -_02349340: - mov r0, #0 - ldmia sp!, {r3, pc} - .align 2, 0 -_02349348: .word DUNGEON_PTR - arm_func_end IsJirachiChallengeFloor - - arm_func_start IsDestinationFloorWithMonster -IsDestinationFloorWithMonster: ; 0x0234934C - stmdb sp!, {r3, lr} - ldr r0, _02349374 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x760 - bl FloorHasMissionMonster - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - .align 2, 0 -_02349374: .word DUNGEON_PTR - arm_func_end IsDestinationFloorWithMonster - - arm_func_start ov29_02349378 -ov29_02349378: ; 0x02349378 - stmdb sp!, {r4, r5, r6, lr} - ldr r0, _023493F4 ; =DUNGEON_PTR - ldr r0, [r0] - add r6, r0, #0x760 - mov r0, r6 - bl FloorHasMissionMonster - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r4, r5, r6, pc} - ldrsh r0, [r6, #0xc] - mov r4, #0 - mov r5, r4 - cmp r0, #0 - beq _023493E0 - bl GetSpriteFileSize - add r4, r4, r0 - b _023493E0 -_023493BC: - add r0, r6, r5, lsl #1 - ldrsh r0, [r0, #0xe] - cmp r0, #0 - beq _023493D4 - bl GetSpriteFileSize - add r4, r4, r0 -_023493D4: - add r0, r5, #1 - mov r0, r0, lsl #0x10 - mov r5, r0, asr #0x10 -_023493E0: - ldrsh r0, [r6, #0x14] - cmp r5, r0 - blt _023493BC - mov r0, r4 - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_023493F4: .word DUNGEON_PTR - arm_func_end ov29_02349378 - - arm_func_start LoadMissionMonsterSprites -LoadMissionMonsterSprites: ; 0x023493F8 - stmdb sp!, {r4, r5, r6, lr} - ldr r0, _0234946C ; =DUNGEON_PTR - ldr r0, [r0] - add r6, r0, #0x760 - mov r0, r6 - bl FloorHasMissionMonster - cmp r0, #0 - ldmeqia sp!, {r4, r5, r6, pc} - ldrsh r0, [r6, #0xc] - cmp r0, #0 - beq _0234942C - mov r1, #1 - bl LoadMonsterSprite -_0234942C: - mov r5, #0 - mov r4, #1 - b _0234945C -_02349438: - add r0, r6, r5, lsl #1 - ldrsh r0, [r0, #0xe] - cmp r0, #0 - beq _02349450 - mov r1, r4 - bl LoadMonsterSprite -_02349450: - add r0, r5, #1 - mov r0, r0, lsl #0x10 - mov r5, r0, asr #0x10 -_0234945C: - ldrsh r0, [r6, #0x14] - cmp r5, r0 - blt _02349438 - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_0234946C: .word DUNGEON_PTR - arm_func_end LoadMissionMonsterSprites - - arm_func_start MissionTargetEnemyIsDefeated -MissionTargetEnemyIsDefeated: ; 0x02349470 - ldr r0, _0234948C ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x760] - cmp r0, #0 - ldrneb r0, [r1, #0x77b] - moveq r0, #0 - bx lr - .align 2, 0 -_0234948C: .word DUNGEON_PTR - arm_func_end MissionTargetEnemyIsDefeated - - arm_func_start SetMissionTargetEnemyDefeated -SetMissionTargetEnemyDefeated: ; 0x02349490 - ldr r1, _023494A0 ; =DUNGEON_PTR - ldr r1, [r1] - strb r0, [r1, #0x77b] - bx lr - .align 2, 0 -_023494A0: .word DUNGEON_PTR - arm_func_end SetMissionTargetEnemyDefeated - - arm_func_start IsDestinationFloorWithFixedRoom -IsDestinationFloorWithFixedRoom: ; 0x023494A4 - ldr r0, _023494C8 ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x760] - cmp r0, #0 - ldrneb r0, [r1, #0x776] - cmpne r0, #0 - moveq r0, #0 - movne r0, #1 - bx lr - .align 2, 0 -_023494C8: .word DUNGEON_PTR - arm_func_end IsDestinationFloorWithFixedRoom - - arm_func_start GetItemToRetrieve -GetItemToRetrieve: ; 0x023494CC - ldr r0, _023494EC ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x760] - add r1, r1, #0x760 - cmp r0, #0 - ldrnesh r0, [r1, #4] - moveq r0, #0 - bx lr - .align 2, 0 -_023494EC: .word DUNGEON_PTR - arm_func_end GetItemToRetrieve - - arm_func_start GetItemToDeliver -GetItemToDeliver: ; 0x023494F0 - stmdb sp!, {r4, lr} - ldr r1, _02349518 ; =DUNGEON_PTR - mov r0, #7 - ldr r1, [r1] - add r4, r1, #0x760 - bl IsCurrentMissionType - cmp r0, #0 - ldrnesh r0, [r4, #6] - moveq r0, #0 - ldmia sp!, {r4, pc} - .align 2, 0 -_02349518: .word DUNGEON_PTR - arm_func_end GetItemToDeliver - - arm_func_start GetSpecialTargetItem -GetSpecialTargetItem: ; 0x0234951C - stmdb sp!, {r4, lr} - ldr r1, _02349560 ; =DUNGEON_PTR - mov r0, #3 - ldr r2, [r1] - mov r1, #1 - add r4, r2, #0x760 - bl IsCurrentMissionTypeExact - cmp r0, #0 - bne _02349550 - mov r0, #0xc - bl IsCurrentMissionType - cmp r0, #0 - beq _02349558 -_02349550: - ldrsh r0, [r4, #8] - ldmia sp!, {r4, pc} -_02349558: - mov r0, #0 - ldmia sp!, {r4, pc} - .align 2, 0 -_02349560: .word DUNGEON_PTR - arm_func_end GetSpecialTargetItem - - arm_func_start IsDestinationFloorWithItem -IsDestinationFloorWithItem: ; 0x02349564 - stmdb sp!, {r4, lr} - ldr r0, _023495C0 ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x760] - add r4, r1, #0x760 - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r4, pc} - mov r0, #9 - bl IsCurrentMissionType - cmp r0, #0 - bne _023495B0 - mov r0, #7 - bl IsCurrentMissionType - cmp r0, #0 - bne _023495B0 - ldrsh r0, [r4, #4] - cmp r0, #0 - bne _023495B8 -_023495B0: - mov r0, #0 - ldmia sp!, {r4, pc} -_023495B8: - mov r0, #1 - ldmia sp!, {r4, pc} - .align 2, 0 -_023495C0: .word DUNGEON_PTR - arm_func_end IsDestinationFloorWithItem - - arm_func_start IsDestinationFloorWithHiddenOutlaw -IsDestinationFloorWithHiddenOutlaw: ; 0x023495C4 - stmdb sp!, {r3, lr} - mov r0, #9 - mov r1, #1 - bl IsCurrentMissionTypeExact - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - arm_func_end IsDestinationFloorWithHiddenOutlaw - - arm_func_start IsDestinationFloorWithFleeingOutlaw -IsDestinationFloorWithFleeingOutlaw: ; 0x023495E8 - stmdb sp!, {r3, lr} - mov r0, #0xa - mov r1, #5 - bl IsCurrentMissionTypeExact - cmp r0, #0 - bne _02349618 - mov r0, #9 - mov r1, #2 - bl IsCurrentMissionTypeExact - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r3, pc} -_02349618: - mov r0, #1 - ldmia sp!, {r3, pc} - arm_func_end IsDestinationFloorWithFleeingOutlaw diff --git a/asm/overlay_29_023492D4.s b/asm/overlay_29_023492D4.s new file mode 100644 index 00000000..994b4858 --- /dev/null +++ b/asm/overlay_29_023492D4.s @@ -0,0 +1,26 @@ + .include "asm/macros.inc" + .include "overlay_29_023492D4.inc" + + .text + + arm_func_start IsLegendaryChallengeFloor +IsLegendaryChallengeFloor: ; 0x023492D4 + stmdb sp!, {r3, lr} + mov r0, #0xb + bl IsCurrentMissionType + cmp r0, #0 + beq _02349308 + ldr r0, _02349310 ; =DUNGEON_PTR + ldr r0, [r0] + ldrb r0, [r0, #0x762] + add r0, r0, #0xff + and r0, r0, #0xff + cmp r0, #4 + movls r0, #1 + ldmlsia sp!, {r3, pc} +_02349308: + mov r0, #0 + ldmia sp!, {r3, pc} + .align 2, 0 +_02349310: .word DUNGEON_PTR + arm_func_end IsLegendaryChallengeFloor diff --git a/asm/overlay_29_02349378.s b/asm/overlay_29_02349378.s new file mode 100644 index 00000000..2c7b5e88 --- /dev/null +++ b/asm/overlay_29_02349378.s @@ -0,0 +1,83 @@ + .include "asm/macros.inc" + .include "overlay_29_02349378.inc" + + .text + + arm_func_start ov29_02349378 +ov29_02349378: ; 0x02349378 + stmdb sp!, {r4, r5, r6, lr} + ldr r0, _023493F4 ; =DUNGEON_PTR + ldr r0, [r0] + add r6, r0, #0x760 + mov r0, r6 + bl FloorHasMissionMonster + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r4, r5, r6, pc} + ldrsh r0, [r6, #0xc] + mov r4, #0 + mov r5, r4 + cmp r0, #0 + beq _023493E0 + bl GetSpriteFileSize + add r4, r4, r0 + b _023493E0 +_023493BC: + add r0, r6, r5, lsl #1 + ldrsh r0, [r0, #0xe] + cmp r0, #0 + beq _023493D4 + bl GetSpriteFileSize + add r4, r4, r0 +_023493D4: + add r0, r5, #1 + mov r0, r0, lsl #0x10 + mov r5, r0, asr #0x10 +_023493E0: + ldrsh r0, [r6, #0x14] + cmp r5, r0 + blt _023493BC + mov r0, r4 + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_023493F4: .word DUNGEON_PTR + arm_func_end ov29_02349378 + + arm_func_start LoadMissionMonsterSprites +LoadMissionMonsterSprites: ; 0x023493F8 + stmdb sp!, {r4, r5, r6, lr} + ldr r0, _0234946C ; =DUNGEON_PTR + ldr r0, [r0] + add r6, r0, #0x760 + mov r0, r6 + bl FloorHasMissionMonster + cmp r0, #0 + ldmeqia sp!, {r4, r5, r6, pc} + ldrsh r0, [r6, #0xc] + cmp r0, #0 + beq _0234942C + mov r1, #1 + bl LoadMonsterSprite +_0234942C: + mov r5, #0 + mov r4, #1 + b _0234945C +_02349438: + add r0, r6, r5, lsl #1 + ldrsh r0, [r0, #0xe] + cmp r0, #0 + beq _02349450 + mov r1, r4 + bl LoadMonsterSprite +_02349450: + add r0, r5, #1 + mov r0, r0, lsl #0x10 + mov r5, r0, asr #0x10 +_0234945C: + ldrsh r0, [r6, #0x14] + cmp r5, r0 + blt _02349438 + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_0234946C: .word DUNGEON_PTR + arm_func_end LoadMissionMonsterSprites diff --git a/asm/overlay_29_023494CC.s b/asm/overlay_29_023494CC.s new file mode 100644 index 00000000..0f113d69 --- /dev/null +++ b/asm/overlay_29_023494CC.s @@ -0,0 +1,90 @@ + .include "asm/macros.inc" + .include "overlay_29_023494CC.inc" + + .text + + arm_func_start GetItemToRetrieve +GetItemToRetrieve: ; 0x023494CC + ldr r0, _023494EC ; =DUNGEON_PTR + ldr r1, [r0] + ldrb r0, [r1, #0x760] + add r1, r1, #0x760 + cmp r0, #0 + ldrnesh r0, [r1, #4] + moveq r0, #0 + bx lr + .align 2, 0 +_023494EC: .word DUNGEON_PTR + arm_func_end GetItemToRetrieve + + arm_func_start GetItemToDeliver +GetItemToDeliver: ; 0x023494F0 + stmdb sp!, {r4, lr} + ldr r1, _02349518 ; =DUNGEON_PTR + mov r0, #7 + ldr r1, [r1] + add r4, r1, #0x760 + bl IsCurrentMissionType + cmp r0, #0 + ldrnesh r0, [r4, #6] + moveq r0, #0 + ldmia sp!, {r4, pc} + .align 2, 0 +_02349518: .word DUNGEON_PTR + arm_func_end GetItemToDeliver + + arm_func_start GetSpecialTargetItem +GetSpecialTargetItem: ; 0x0234951C + stmdb sp!, {r4, lr} + ldr r1, _02349560 ; =DUNGEON_PTR + mov r0, #3 + ldr r2, [r1] + mov r1, #1 + add r4, r2, #0x760 + bl IsCurrentMissionTypeExact + cmp r0, #0 + bne _02349550 + mov r0, #0xc + bl IsCurrentMissionType + cmp r0, #0 + beq _02349558 +_02349550: + ldrsh r0, [r4, #8] + ldmia sp!, {r4, pc} +_02349558: + mov r0, #0 + ldmia sp!, {r4, pc} + .align 2, 0 +_02349560: .word DUNGEON_PTR + arm_func_end GetSpecialTargetItem + + arm_func_start IsDestinationFloorWithItem +IsDestinationFloorWithItem: ; 0x02349564 + stmdb sp!, {r4, lr} + ldr r0, _023495C0 ; =DUNGEON_PTR + ldr r1, [r0] + ldrb r0, [r1, #0x760] + add r4, r1, #0x760 + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r4, pc} + mov r0, #9 + bl IsCurrentMissionType + cmp r0, #0 + bne _023495B0 + mov r0, #7 + bl IsCurrentMissionType + cmp r0, #0 + bne _023495B0 + ldrsh r0, [r4, #4] + cmp r0, #0 + bne _023495B8 +_023495B0: + mov r0, #0 + ldmia sp!, {r4, pc} +_023495B8: + mov r0, #1 + ldmia sp!, {r4, pc} + .align 2, 0 +_023495C0: .word DUNGEON_PTR + arm_func_end IsDestinationFloorWithItem diff --git a/asm/overlay_29_023495E8.s b/asm/overlay_29_023495E8.s new file mode 100644 index 00000000..94760772 --- /dev/null +++ b/asm/overlay_29_023495E8.s @@ -0,0 +1,23 @@ + .include "asm/macros.inc" + .include "overlay_29_023495E8.inc" + + .text + + arm_func_start IsDestinationFloorWithFleeingOutlaw +IsDestinationFloorWithFleeingOutlaw: ; 0x023495E8 + stmdb sp!, {r3, lr} + mov r0, #0xa + mov r1, #5 + bl IsCurrentMissionTypeExact + cmp r0, #0 + bne _02349618 + mov r0, #9 + mov r1, #2 + bl IsCurrentMissionTypeExact + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r3, pc} +_02349618: + mov r0, #1 + ldmia sp!, {r3, pc} + arm_func_end IsDestinationFloorWithFleeingOutlaw diff --git a/asm/overlay_29_02349638.s b/asm/overlay_29_02349658.s similarity index 50% rename from asm/overlay_29_02349638.s rename to asm/overlay_29_02349658.s index 2a7a5c6f..ff5be640 100644 --- a/asm/overlay_29_02349638.s +++ b/asm/overlay_29_02349658.s @@ -1,21 +1,8 @@ .include "asm/macros.inc" - .include "overlay_29_02349638.inc" + .include "overlay_29_02349658.inc" .text - arm_func_start GetMissionEnemyMinionGroup -GetMissionEnemyMinionGroup: ; 0x02349638 - ldr r1, _02349654 ; =DUNGEON_PTR - add r0, r0, #1 - ldr r1, [r1] - add r0, r1, r0, lsl #1 - add r0, r0, #0x700 - ldrsh r0, [r0, #0x6e] - bx lr - .align 2, 0 -_02349654: .word DUNGEON_PTR - arm_func_end GetMissionEnemyMinionGroup - arm_func_start ov29_02349658 ov29_02349658: ; 0x02349658 ldr r0, _02349684 ; =DUNGEON_PTR diff --git a/include/overlay_29_0234928C.h b/include/overlay_29_0234928C.h new file mode 100644 index 00000000..6881b33c --- /dev/null +++ b/include/overlay_29_0234928C.h @@ -0,0 +1,10 @@ +#ifndef PMDSKY_OVERLAY_29_0234928C_H +#define PMDSKY_OVERLAY_29_0234928C_H + +#include "dungeon.h" +#include "util.h" + +bool8 IsOutlawMonsterHouseFloor(void); +bool8 IsGoldenChamber(void); + +#endif diff --git a/include/overlay_29_02349314.h b/include/overlay_29_02349314.h new file mode 100644 index 00000000..f7f5251d --- /dev/null +++ b/include/overlay_29_02349314.h @@ -0,0 +1,10 @@ +#ifndef PMDSKY_OVERLAY_29_02349314_H +#define PMDSKY_OVERLAY_29_02349314_H + +#include "dungeon.h" +#include "util.h" + +bool8 IsJirachiChallengeFloor(void); +bool8 IsDestinationFloorWithMonster(void); + +#endif diff --git a/include/overlay_29_02349470.h b/include/overlay_29_02349470.h new file mode 100644 index 00000000..932646f8 --- /dev/null +++ b/include/overlay_29_02349470.h @@ -0,0 +1,11 @@ +#ifndef PMDSKY_OVERLAY_29_02349470_H +#define PMDSKY_OVERLAY_29_02349470_H + +#include "dungeon.h" +#include "util.h" + +s32 MissionTargetEnemyIsDefeated(void); +void SetMissionTargetEnemyDefeated(bool8 defeated); +s32 IsDestinationFloorWithFixedRoom(void); + +#endif diff --git a/include/overlay_29_023495C4.h b/include/overlay_29_023495C4.h new file mode 100644 index 00000000..60b3a19f --- /dev/null +++ b/include/overlay_29_023495C4.h @@ -0,0 +1,9 @@ +#ifndef PMDSKY_OVERLAY_29_023495C4_H +#define PMDSKY_OVERLAY_29_023495C4_H + +#include "dungeon.h" +#include "util.h" + +bool8 IsDestinationFloorWithHiddenOutlaw(void); + +#endif diff --git a/include/overlay_29_02349620.h b/include/overlay_29_02349620.h index dd1df3da..5c08f55d 100644 --- a/include/overlay_29_02349620.h +++ b/include/overlay_29_02349620.h @@ -5,5 +5,6 @@ #include "util.h" enum monster_id GetMissionTargetEnemy(void); +enum monster_id GetMissionEnemyMinionGroup(s32 index); #endif diff --git a/main.lsf b/main.lsf index 34545fcf..29796e8a 100644 --- a/main.lsf +++ b/main.lsf @@ -1038,8 +1038,16 @@ Overlay OVY_29 Object asm/overlay_29_023491C4.o Object src/overlay_29_02349208.o Object asm/overlay_29_0234921C.o + Object src/overlay_29_0234928C.o + Object asm/overlay_29_023492D4.o + Object src/overlay_29_02349314.o + Object asm/overlay_29_02349378.o + Object src/overlay_29_02349470.o + Object asm/overlay_29_023494CC.o + Object src/overlay_29_023495C4.o + Object asm/overlay_29_023495E8.o Object src/overlay_29_02349620.o - Object asm/overlay_29_02349638.o + Object asm/overlay_29_02349658.o Object src/overlay_29_02349688.o Object asm/overlay_29_0234969C.o Object src/overlay_29_023496D8.o diff --git a/src/overlay_29_0234928C.c b/src/overlay_29_0234928C.c new file mode 100644 index 00000000..f7c0e284 --- /dev/null +++ b/src/overlay_29_0234928C.c @@ -0,0 +1,21 @@ +#include "overlay_29_0234928C.h" +#include "dungeon.h" +#include "mission.h" + +extern struct dungeon *DUNGEON_PTR; + +void ClearMissionDestinationInfo(struct mission_destination_info *info); +s32 GetFirstExperienceLockedTeamMember(void); +bool8 FloorHasMissionMonster(struct mission_destination_info *info); +bool8 IsCurrentMissionType(enum mission_type type); +bool8 IsCurrentMissionTypeExact(enum mission_type type, u8 subtype); + +bool8 IsOutlawMonsterHouseFloor(void) +{ + return IsCurrentMissionTypeExact(MISSION_ARREST_OUTLAW, 7) != 0; +} + +bool8 IsGoldenChamber(void) +{ + return IsCurrentMissionTypeExact(MISSION_EXPLORE_WITH_CLIENT, 2) != 0; +} diff --git a/src/overlay_29_02349314.c b/src/overlay_29_02349314.c new file mode 100644 index 00000000..56cfb663 --- /dev/null +++ b/src/overlay_29_02349314.c @@ -0,0 +1,24 @@ +#include "overlay_29_02349314.h" +#include "dungeon.h" +#include "mission.h" + +extern struct dungeon *DUNGEON_PTR; + +void ClearMissionDestinationInfo(struct mission_destination_info *info); +s32 GetFirstExperienceLockedTeamMember(void); +bool8 FloorHasMissionMonster(struct mission_destination_info *info); +bool8 IsCurrentMissionType(enum mission_type type); +bool8 IsCurrentMissionTypeExact(enum mission_type type, u8 subtype); + +bool8 IsJirachiChallengeFloor(void) +{ + if (IsCurrentMissionType(MISSION_CHALLENGE_REQUEST) && DUNGEON_PTR->mission_destination.subtype == 5) { + return TRUE; + } + return FALSE; +} + +bool8 IsDestinationFloorWithMonster(void) +{ + return FloorHasMissionMonster(&DUNGEON_PTR->mission_destination) != 0; +} diff --git a/src/overlay_29_02349470.c b/src/overlay_29_02349470.c new file mode 100644 index 00000000..a46e13f9 --- /dev/null +++ b/src/overlay_29_02349470.c @@ -0,0 +1,35 @@ +#include "overlay_29_02349470.h" +#include "dungeon.h" +#include "mission.h" + +extern struct dungeon *DUNGEON_PTR; + +void ClearMissionDestinationInfo(struct mission_destination_info *info); +s32 GetFirstExperienceLockedTeamMember(void); +bool8 FloorHasMissionMonster(struct mission_destination_info *info); +bool8 IsCurrentMissionType(enum mission_type type); +bool8 IsCurrentMissionTypeExact(enum mission_type type, u8 subtype); + +s32 MissionTargetEnemyIsDefeated(void) +{ + struct dungeon *dungeon = DUNGEON_PTR; + + return dungeon->mission_destination.is_destination_floor + ? dungeon->mission_destination.target_enemy_is_defeated : FALSE; +} + +void SetMissionTargetEnemyDefeated(bool8 defeated) +{ + DUNGEON_PTR->mission_destination.target_enemy_is_defeated = defeated; +} + +s32 IsDestinationFloorWithFixedRoom(void) +{ + struct dungeon *dungeon = DUNGEON_PTR; + + if (dungeon->mission_destination.is_destination_floor == FALSE || + dungeon->mission_destination.fixed_room_id == 0) { + return FALSE; + } + return TRUE; +} diff --git a/src/overlay_29_023495C4.c b/src/overlay_29_023495C4.c new file mode 100644 index 00000000..a4b9da6f --- /dev/null +++ b/src/overlay_29_023495C4.c @@ -0,0 +1,16 @@ +#include "overlay_29_023495C4.h" +#include "dungeon.h" +#include "mission.h" + +extern struct dungeon *DUNGEON_PTR; + +void ClearMissionDestinationInfo(struct mission_destination_info *info); +s32 GetFirstExperienceLockedTeamMember(void); +bool8 FloorHasMissionMonster(struct mission_destination_info *info); +bool8 IsCurrentMissionType(enum mission_type type); +bool8 IsCurrentMissionTypeExact(enum mission_type type, u8 subtype); + +bool8 IsDestinationFloorWithHiddenOutlaw(void) +{ + return IsCurrentMissionTypeExact(MISSION_TAKE_ITEM_FROM_OUTLAW, 1) != 0; +} diff --git a/src/overlay_29_02349620.c b/src/overlay_29_02349620.c index 21019de3..7343fb20 100644 --- a/src/overlay_29_02349620.c +++ b/src/overlay_29_02349620.c @@ -14,3 +14,10 @@ enum monster_id GetMissionTargetEnemy(void) { return DUNGEON_PTR->mission_destination.enemy_species[0]; } + +enum monster_id GetMissionEnemyMinionGroup(s32 index) +{ + s32 i = index + 1; + + return DUNGEON_PTR->mission_destination.enemy_species[i]; +}