Merge pull request #237 from slaw-22/DungeonInit3

Decomp GetDungeonModeSpecial and IsNoLossPenaltyDungeon
This commit is contained in:
AnonymousRandomPerson 2026-01-01 17:42:04 -05:00 committed by GitHub
commit 44374b7673
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 50 additions and 58 deletions

View File

@ -3,30 +3,6 @@
.text
arm_func_start IsNoLossPenaltyDungeon
IsNoLossPenaltyDungeon: ; 0x0204EFE0
stmdb sp!, {r4, lr}
cmp r0, #0x1a
mov r4, #0
cmpne r0, #0x79
beq _0204F000
cmp r0, #0x7d
beq _0204F008
b _0204F01C
_0204F000:
mov r4, #1
b _0204F01C
_0204F008:
mov r0, r4
mov r1, #0x10
bl LoadScriptVariableValue
cmp r0, #0
moveq r4, #1
_0204F01C:
mov r0, r4
ldmia sp!, {r4, pc}
arm_func_end IsNoLossPenaltyDungeon
arm_func_start sub_0204F024
sub_0204F024: ; 0x0204F024
ldr r1, _0204F030 ; =PENDING_DUNGEON_ID

View File

@ -3,35 +3,6 @@
.text
arm_func_start GetDungeonModeSpecial
GetDungeonModeSpecial: ; 0x0206A76C
stmdb sp!, {r3, lr}
cmp r0, #0xd6
moveq r0, #4
ldmeqia sp!, {r3, pc}
cmp r0, #0xb4
blt _0206A790
cmp r0, #0xd3
movle r0, #3
ldmleia sp!, {r3, pc}
_0206A790:
cmp r0, #0xd7
moveq r0, #2
ldmeqia sp!, {r3, pc}
cmp r0, #0xd8
moveq r0, #3
ldmeqia sp!, {r3, pc}
bl GetDungeonMode
cmp r0, #1
moveq r0, #1
ldmeqia sp!, {r3, pc}
sub r0, r0, #2
cmp r0, #1
movls r0, #2
movhi r0, #1
ldmia sp!, {r3, pc}
arm_func_end GetDungeonModeSpecial
arm_func_start sub_0206A7CC
sub_0206A7CC: ; 0x0206A7CC
stmdb sp!, {r4, lr}

View File

@ -94,5 +94,6 @@ struct dungeon_init {
void sub_0204E974(s8 arg0);
void InitDungeonInit(struct dungeon_init* dg_init, s16 dungeon_idx);
s32 IsNoLossPenaltyDungeon(s16 dungeon_id);
#endif //PMDSKY_DUNGEON_INIT

View File

@ -3,5 +3,6 @@
s16 DungeonSwapIdToIdx(s16 id);
s16 DungeonSwapIdxToId(s16 idx);
s32 GetDungeonModeSpecial(s16 dungeon_id);
#endif //PMDSKY_MAIN_DUNGEON_INIT_2

View File

@ -1,4 +1,5 @@
#include "dungeon_init.h"
#include "dungeon_init_2.h"
#include "enums.h"
#include "game_mode.h"
#include "progression.h"
@ -30,10 +31,7 @@ extern u8* GUEST_MONSTER_SNOVER_2;
struct unk* sub_0205B77C();
void sub_0205BB7C(void*, s8);
void sub_0205BD14(void*, s8);
extern s32 GetDungeonModeSpecial(s16);
extern s8 IsNoLossPenaltyDungeon(s16);
extern void AddGuestMonster(void*, u8, void*);
extern s8 DungeonSwapIdxToId(s16);
// Appears to be initialising a dungeon for a special case not
// handled by InitDungeonInit
@ -261,3 +259,22 @@ void InitDungeonInit(struct dungeon_init* dg_init, s16 dungeon_idx)
dg_init->field_0x4 = 0;
dg_init->show_rescues_left = FALSE;
}
s32 IsNoLossPenaltyDungeon(s16 dungeon_id) {
s32 return_val = FALSE;
switch(dungeon_id) {
case DUNGEON_CRYSTAL_LAKE:
case DUNGEON_5TH_STATION_CLEARING:
return_val = TRUE;
break;
case DUNGEON_DEEP_STAR_CAVE_TEAM_ROGUE:
if(LoadScriptVariableValue(NULL, DUNGEON_STEAM_CAVE_PEAK) == 0) {
return_val = TRUE;
}
break;
default:
return_val = FALSE;
}
return return_val;
}

View File

@ -3,6 +3,8 @@
extern u8 DUNGEON_SWAP_ID_TABLE[];
extern s32 GetDungeonMode();
s16 DungeonSwapIdToIdx(s16 id)
{
for(s32 i = 0; i < 0xD5; i++) {
@ -20,3 +22,27 @@ s16 DungeonSwapIdxToId(s16 idx) {
return DUNGEON_SWAP_ID_TABLE[idx];
}
}
s32 GetDungeonModeSpecial(s16 dungeon_id) {
if (dungeon_id == DUNGEON_JOINED_AT_QUESTION_MARKS) {
return 4;
}
if ((dungeon_id >= DUNGEON_NORMAL_FLY_MAZE) && (dungeon_id <= DUNGEON_DOJO_0xD3)) {
return DMODE_OPEN_AND_REQUEST;
}
if (dungeon_id == DUNGEON_BEACH) {
return DMODE_REQUEST;
}
if (dungeon_id == DUNGEON_JOINED_AT_UNKNOWN) {
return DMODE_OPEN_AND_REQUEST;
}
u32 mode = GetDungeonMode();
if (mode == DMODE_OPEN) {
return DMODE_OPEN;
}
if ((mode - 2) <= 1) {
return DMODE_REQUEST;
}
return DMODE_OPEN;
}

View File

@ -1,15 +1,15 @@
#include "options.h"
#include "overlay_31_02383328.h"
extern u8 OVERLAY31_UNKNOWN_POINTER__NA_238A268[];
extern u8 ov31_0238A2A8;
extern u8 GetTopScreenOption(void (*f)(void));
extern void ov29_022E8708();
extern u32 ov29_022E87DC();
void ov31_02383328(void (*f)(void))
{
if (GetTopScreenOption(f) != ov31_0238A2A8) {
if (GetTopScreenOption() != ov31_0238A2A8) {
ov29_022E8708();
OVERLAY31_UNKNOWN_POINTER__NA_238A268[0] = 1;
}