From df64c43ec653f63d6908188d7bcc85cc413ceee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Fetsch?= <121955157+soerenfetsch@users.noreply.github.com> Date: Tue, 13 Oct 2026 20:16:54 +0000 Subject: [PATCH] Decompile RunDungeon and make adjustments to dungeon and dungeon_init structs --- asm/include/overlay_29_022DEBA4.inc | 254 +--- asm/include/overlay_29_rodata_023510C8.inc | 1 + asm/overlay_29_022DEBA4.s | 1409 -------------------- asm/overlay_29_rodata_0234FD04.s | 171 --- asm/overlay_29_rodata_023510C8.s | 172 +++ include/dg.h | 4 + include/dungeon.h | 21 +- include/dungeon_init.h | 44 +- include/dungeon_location_seed.h | 28 + include/overlay_29_022E9FC0.h | 2 +- include/overlay_29_0234BA54.h | 6 +- main.lsf | 2 + src/deoxys_form_data.c | 4 + src/dg.c | 1257 ++++++++++++++++- src/overlay_29_022E9FC0.c | 2 +- src/overlay_29_0234BA54.c | 18 +- src/overlay_29_0234BBE8.c | 9 +- 17 files changed, 1514 insertions(+), 1890 deletions(-) create mode 100644 asm/include/overlay_29_rodata_023510C8.inc create mode 100644 asm/overlay_29_rodata_023510C8.s create mode 100644 include/dungeon_location_seed.h create mode 100644 src/deoxys_form_data.c diff --git a/asm/include/overlay_29_022DEBA4.inc b/asm/include/overlay_29_022DEBA4.inc index 16121af0..e31516c3 100644 --- a/asm/include/overlay_29_022DEBA4.inc +++ b/asm/include/overlay_29_022DEBA4.inc @@ -1,262 +1,18 @@ #pragma once -.public AllocTopScreenStatus -.public ChangeGiratinaFormIfSkyDungeon -.public ClearHiddenStairs -.public CloseFixedBin -.public CopySpawnEntriesOnce -.public CountItemsOnFloorForAcuteSniffer -.public CreateMonsterSummaryFromEntityOuter -.public Debug_Print0 -.public DeleteAllMonsterSpriteFiles -.public DetermineAllMonsterShadow -.public DetermineAllTilesWalkableNeighbors -.public DIRECTIONS_XY -.public DisplayFloorCard -.public DisplayFloorTip -.public DisplayMessage -.public DisplayMessage2 .public DUNGEON_PTR .public DungeonGoesUp -.public DungeonRandInt -.public DungeonRngUnsetSecondary -.public EnemyEvolution -.public EntityIsValid__022E0354 -.public FadeToBlack -.public FillMissionDestinationInfo .public FIXED_ROOM_REVISIT_OVERRIDES -.public FreeAlertBoxInfo -.public FreeLoadedAttackSpriteAndMore -.public FreeTopScreenStatus -.public GenerateDungeonRngSeed -.public GenerateFloor -.public GetApparentWeather -.public GetBgRegionArea +.public FillMissionDestinationInfo .public GetDungeonMode -.public GetDungeonRngPreseed -.public GetFloorType -.public GetForcedLossReason .public GetHiddenFloorField -.public GetLeader -.public GetMaxReachedFloor -.public GetMaxRescueAttempts -.public GetTopScreenOption -.public GetTurnLimit -.public HandleShopTransaction -.public IncrementNbSteals -.public InitAlertBoxInfo -.public InitDungeonRng -.public InitEnemySpawnStats -.public InitMessageLogPreprocessorArgs -.public IsBossFight -.public IsDungeonEndReasonFailure -.public IsFloorOver .public IsIqEnabled -.public IsLevelResetDungeon -.public IsRoomIlluminated -.public IsSecretBazaarVeneer .public IsTrapInvisibleWhenAttacking -.public LEADER_PTR -.public LoadActiveMonsterSprites -.public LoadMappaFileAttributes -.public LoadMonsterSprites .public LoadScriptVariableValue -.public LoadWeather3DFiles -.public MemZero -.public MtInit -.public MtNext -.public OpenFixedBin -.public ov10_022BDAB0 -.public ov10_022BDB54 -.public ov10_022BDB60 -.public ov10_022BDB80 -.public ov10_022BDBA4 -.public ov10_022BDBB0 -.public ov10_022BDC0C -.public ov10_022BFE6C -.public ov29_022DD5B4 -.public ov29_022DD7AC -.public ov29_022DDE00 -.public ov29_022DE15C -.public ov29_022DE4FC -.public ov29_022DE904 -.public ov29_022DE930 -.public ov29_022DEA34 -.public ov29_022DEADC -.public ov29_022DEB40 -.public ov29_022E0434 -.public ov29_022E081C -.public ov29_022E0DFC -.public ov29_022E0E44 -.public ov29_022E0F6C -.public ov29_022E12F8 -.public ov29_022E1304 -.public ov29_022E1550 -.public ov29_022E15C8 -.public ov29_022E1604 -.public ov29_022E1640 -.public ov29_022E2B68 -.public ov29_022E2DFC -.public ov29_022E34B0 -.public ov29_022E3A58 -.public ov29_022E5F20 -.public ov29_022E6E40 -.public ov29_022E6F94 -.public ov29_022E7CFC -.public ov29_022E7F7C -.public ov29_022E8104 -.public ov29_022E8708 -.public ov29_022E8BFC -.public ov29_022E9F18 -.public ov29_022E9FC0 -.public ov29_022EA370 -.public ov29_022EA3F8 -.public ov29_022EA418 -.public ov29_022EAD68 -.public ov29_022EAEAC -.public ov29_022EAF48 -.public ov29_022ECF78 -.public ov29_022ECFB8 -.public ov29_022ED030 -.public ov29_022ED0B0 -.public ov29_022EF738 -.public ov29_022EF8A4 -.public ov29_022EF9B8 -.public ov29_022F6E40 -.public ov29_022F6EF4 -.public ov29_022F7104 -.public ov29_022F7910 -.public ov29_022F7BF4 -.public ov29_022F7E34 -.public ov29_022F7EAC -.public ov29_022FA2F0 -.public ov29_022FA418 -.public ov29_022FA524 -.public ov29_022FA648 -.public ov29_022FA750 -.public ov29_022FBB1C -.public ov29_022FC9C0 -.public ov29_022FCD04 -.public ov29_022FDFA4 -.public ov29_022FE2E4 -.public ov29_022FE4A8 -.public ov29_02305814 -.public ov29_0231AFB4 -.public ov29_0231B39C -.public ov29_0231B460 -.public ov29_02334D58 -.public ov29_02334DA8 -.public ov29_02335044 -.public ov29_023350FC -.public ov29_023359F8 -.public ov29_023362EC -.public ov29_02336460 -.public ov29_023365B8 -.public ov29_023365E8 -.public ov29_0233665C -.public ov29_023369F8 -.public ov29_0233781C -.public ov29_0233785C -.public ov29_0233873C -.public ov29_023389C4 -.public ov29_02338A4C -.public ov29_02338D30 -.public ov29_02338F10 -.public ov29_02338F38 -.public ov29_02338F48 -.public ov29_02338F68 -.public ov29_02338FC8 -.public ov29_0233904C -.public ov29_02339F88 -.public ov29_02339FD0 -.public ov29_0233A0E8 -.public ov29_0233A15C -.public ov29_0233A1BC -.public ov29_0233A248 -.public ov29_02343980 -.public ov29_02344C4C -.public ov29_02345D84 -.public ov29_023469E0 -.public ov29_02346A64 -.public ov29_02346DA4 -.public ov29_02346E48 -.public ov29_023480FC -.public ov29_02348850 -.public ov29_02348894 -.public ov29_023488C8 -.public ov29_02348918 -.public ov29_02348994 -.public ov29_02349188 -.public ov29_02349658 -.public ov29_02349C84 -.public ov29_0234B010 -.public ov29_0234B1A4 -.public ov29_0234B4CC -.public ov29_0234BB10 -.public ov29_0234BB20 -.public ov29_0234BB2C -.public ov29_0234BB38 -.public ov29_0234C584 -.public ov29_0234C5EC -.public ov29_0234C654 -.public ov29_0234CA84 -.public ov29_0234CB34 -.public ov29_0234CB54 -.public ov29_023510C0 -.public ov29_023510C8 -.public ov29_02353563 -.public Rand16Bit -.public ReadMissionMtStateLower -.public ReevaluateSnatchMonster -.public RefillTeam -.public ResetGravity -.public ResetVictoryCounter -.public RunFractionalTurn -.public SetBaseStatsMovesGroundMonster -.public SetBothScreensWindowColorToDefault -.public SetDungeonRngPreseed -.public SetDungeonRngPreseed23Bit -.public SetEntityPixelPosXY .public SetForcedLossReason .public SetHiddenFloorField .public SetHiddenStairsField -.public SetMaxReachedFloor -.public SetMessageLogPreprocessorArgsFlagVal -.public SetMessageLogPreprocessorArgsNumberVal -.public SetMinimapDataE447 .public SetUnkMusicFlag -.public SpawnInitialMonsters -.public SpawnShopkeepers -.public SpawnTeam -.public SpawnTraps -.public StartFadeDungeonWrapper -.public sub_02001808 -.public sub_02009194 -.public sub_020091B0 -.public sub_02017B00 -.public sub_0204F1B4 -.public sub_02051DFC -.public sub_02051ED4 -.public sub_02057E90 -.public sub_02057EF4 -.public sub_02058644 -.public sub_0205B77C -.public TryActivateAcuteSniffer -.public TryActivateArtificialWeatherAbilities -.public TryActivateIqBooster -.public TryActivateNewFloorHpRestoration -.public TryActivateNewFloorPpRestoration -.public TryActivateSlowStart -.public TryActivateStairSensor -.public TryActivateWeather -.public TryForcedLoss -.public TryInflictBurnStatusWholeTeam -.public TrySpawnDoughSeedPoke -.public UnkMapRelatedFunc -.public UpdateMinimap -.public UpdateShouldBoostHiddenStairsSpawnChance -.public UpdateShouldBoostKecleonShopSpawnChance -.public UpdateTrapsVisibility -.public WaitUntilAlertBoxPauseIsOver -.public WaitUntilAlertBoxTextIsLoaded -.public WaitUntilFadeIsFinished -.public WriteMissionMtState +.public ov29_022DEADC +.public ov29_022DEB40 +.public ov29_02349188 +.public ov29_02349658 diff --git a/asm/include/overlay_29_rodata_023510C8.inc b/asm/include/overlay_29_rodata_023510C8.inc new file mode 100644 index 00000000..6f70f09b --- /dev/null +++ b/asm/include/overlay_29_rodata_023510C8.inc @@ -0,0 +1 @@ +#pragma once diff --git a/asm/overlay_29_022DEBA4.s b/asm/overlay_29_022DEBA4.s index 0922441b..3297badb 100644 --- a/asm/overlay_29_022DEBA4.s +++ b/asm/overlay_29_022DEBA4.s @@ -258,1412 +258,3 @@ _022DEF30: .word 0x000003E7 _022DEF34: .word FIXED_ROOM_REVISIT_OVERRIDES arm_func_end ov29_022DEBBC -; https://decomp.me/scratch/7xQSQ - arm_func_start RunDungeon -RunDungeon: ; 0x022DEF38 -#ifdef JAPAN -#define RUN_DUNGEON_OFFSET -0xA4 -#else -#define RUN_DUNGEON_OFFSET 0 -#endif - stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr} - sub sp, sp, #0xd0 - mov sl, r0 - ldrb r5, [sl, #4] - mov r8, #0 - mov sb, r1 - str r8, [sp] - cmp r5, #0 - moveq r0, #1 - movne r0, r8 - ldrsb r1, [sl, #0xe] - ldrb r6, [sl, #0x11] - ldrb fp, [sl, #0xf] - ldrb r7, [sl, #0x10] - and r0, r0, #0xff - cmp r1, #1 - str r0, [sp, #4] - mov r0, #0 - bne _022DEF90 - bl ov29_0234C5EC - mov r8, #1 - b _022DEF94 -_022DEF90: - bl ov29_0234C584 -_022DEF94: - mov r0, #1 - bl ov29_0234C584 - mov r0, #2 - bl ov29_022DDE00 - ldr r0, _022DFF3C ; =ov29_023510C8 - mov r1, #0x3e0 - bl Debug_Print0 - ldr r0, _022DFF40 ; =DUNGEON_PTR - cmp r5, #0 - str sb, [r0] - ldrb r1, [sl] - strb r1, [sb, #0x748] - ldrb r1, [sl, #1] - strb r1, [sb, #0x749] - bne _022DF0AC - ldrsb r2, [sl, #0xd] - ldr r1, [r0] - strb r2, [r1, #0x798] - ldr r2, [r0] - ldr r1, [sl, #0x14] - ldr r0, [sl, #0x18] - str r1, [r2, #0x750] - str r0, [r2, #0x754] - ldrb r0, [sl] - bl GetTurnLimit - ldr r2, _022DFF40 ; =DUNGEON_PTR - mov r3, #0 - ldr r1, [r2] - add r1, r1, #0x700 - strh r0, [r1, #0x84] - ldr r0, [r2] - strb r3, [r0, #0x79a] - ldrb r0, [sl] - bl GetMaxRescueAttempts - ldr r1, _022DFF40 ; =DUNGEON_PTR - ldr r2, [r1] - strb r0, [r2, #0x79b] - ldr r2, [sl, #0xac] - ldr r0, [r1] - str r2, [r0, #0x7cc] - ldrb r2, [sl, #5] - ldr r0, [r1] - strb r2, [r0, #0x75c] - ldrb r2, [sl, #8] - ldr r0, [r1] - strb r2, [r0, #0x75a] - ldrb r2, [sl, #6] - ldr r0, [r1] - strb r2, [r0, #0x759] - ldrb r2, [sl, #9] - ldr r0, [r1] - strb r2, [r0, #0x75b] - ldrb r2, [sl, #0xa] - ldr r0, [r1] - strb r2, [r0, #0x75d] - ldrb r2, [sl, #0xb] - ldr r0, [r1] - strb r2, [r0, #0x75e] - ldrb r2, [sl, #0xc] - ldr r0, [r1] - strb r2, [r0, #0x75f] - ldr r0, [r1] - ldrsh r2, [sl, #2] - add r0, r0, #0x700 - strh r2, [r0, #0x4c] - ldrb r0, [sl, #7] - cmp r0, #0 - ldrne r0, [r1] - movne r1, #0 - strneb r1, [r0, #0x759] -_022DF0AC: - ldr r0, _022DFF40 ; =DUNGEON_PTR - mov r3, #0 - ldr r2, [r0] - mov r1, #1 - strb r3, [r2, #0x7c8] - ldr r2, [r0] - strb r3, [r2, #0x7c9] - ldr r0, [r0] - strb r1, [r0, #0x75b] - bl ov29_022DE904 - bl ov29_022F6E40 - bl ov29_022ED030 - bl LoadWeather3DFiles - bl ov29_02338F10 - bl sub_02017B00 - mov r1, r5 - bl ov29_022EAF48 - bl AllocTopScreenStatus - bl ov29_022E6F94 - bl ov29_022E1640 - bl ov29_023362EC - bl OpenFixedBin - bl ov29_022E9F18 - bl ov29_02338F68 - mov r0, #0 - bl ov29_02338F38 - mov r0, #1 - bl ov29_022E2B68 - bl InitAlertBoxInfo - bl ov29_0234BB10 - bl DungeonRngUnsetSecondary - bl GetDungeonRngPreseed - ldr r2, _022DFF40 ; =DUNGEON_PTR - mov r1, #0x340 - ldr r3, [r2] - mov r2, #0 - str r0, [r3, #0x7ac] - mov r0, #0x200 - bl ov10_022BDAB0 - mov r0, #0 - bl ov10_022BDB54 - mov r0, #0 - bl sub_02051ED4 - mov r4, r0 - mov r0, #0 - mov r1, r0 - bl sub_02051DFC - str r0, [sp, #8] - mov r0, #0 - mov r1, r0 - mov r2, r0 - bl GetBgRegionArea - ldr r1, [sp, #8] - mov r2, r4 - mov r3, #0 - bl ov10_022BDB60 - mov r0, #1 - bl sub_02051ED4 - mov r4, r0 - mov r0, #0 - mov r1, #1 - bl sub_02051DFC - str r0, [sp, #0xc] - mov r0, #0 - mov r1, r0 - mov r2, #1 - bl GetBgRegionArea - ldr r1, [sp, #0xc] - mov r2, r4 - mov r3, #1 - bl ov10_022BDB60 - mov r0, #0xb000 - mov r1, #0xb - bl ov10_022BDB80 - mov r0, #0x2000 - mov r1, #0xa - bl ov10_022BDBA4 - bl ov29_022E0F6C - bl ov29_022E8104 - bl ov29_022E7F7C - bl ov29_022E1304 - bl ov29_022E6E40 - bl ov29_022FE4A8 - bl ov29_023480FC - mov r0, #2 - bl ov29_022DDE00 - ldrsb r0, [sl, #0xe] - cmp r0, #1 - beq _022DF214 - bl ov29_022DEADC -_022DF214: - cmp r5, #0 - beq _022DF22C - bl ov29_0234CB34 - bl ov29_0234CB54 - bl ov29_023365E8 -#ifndef JAPAN - bl ov29_02348850 -#endif -_022DF22C: - cmp r6, #0 - beq _022DF238 - bl ov29_022E0434 -_022DF238: - cmp r5, #0 - bne _022DF2D0 - add r0, sb, #0x1a000 - mov r2, #1 - strb r2, [r0, #0x23f + RUN_DUNGEON_OFFSET] - ldr r1, _022DFF40 ; =DUNGEON_PTR - strb r2, [r0, #0x240 + RUN_DUNGEON_OFFSET] - ldr r0, [r1] - add r0, r0, #0x7d0 - bl ov29_0231B39C - add r0, sb, #0x700 - ldrsb r0, [r0, #0x98] - cmp r0, #2 - ldreqb r1, [sl, #0x14] - moveq r0, #1 - streqb r1, [sb, #0x748] - streqb r0, [sb, #0x749] - ldrb r0, [sb, #0x748] - bl ChangeGiratinaFormIfSkyDungeon - bl ov29_022E081C - add r0, sb, #0x700 - ldrsb r0, [r0, #0x98] - cmp r0, #2 - ldreq r0, [sl, #0x18] - streq r0, [sb, #0x7a0] - beq _022DF2C4 - bl ReadMissionMtStateLower - mov r4, r0 - bl Rand16Bit - orr r0, r0, r4, lsl #16 - bl MtInit - bl MtNext - bic r0, r0, #0xff000000 - str r0, [sb, #0x7a0] - bl WriteMissionMtState -_022DF2C4: - ldr r0, [sb, #0x7a0] - bl SetDungeonRngPreseed23Bit - b _022DF2D8 -_022DF2D0: - ldr r0, [sb, #0x7ac] - bl SetDungeonRngPreseed -_022DF2D8: - cmp r6, #0 - beq _022DF31C - add r0, sb, #0x700 - ldrsb r1, [r0, #0x9b] - mov r0, #0 - bl SetMessageLogPreprocessorArgsNumberVal - add r0, sb, #0x700 - ldrsb r0, [r0, #0x9b] - mov r2, #1 - cmp r0, #0 - mov r0, #0 - beq _022DF314 - ldr r1, _022DFF44 ; =0x00000B6B - bl DisplayMessage2 - b _022DF31C -_022DF314: - ldr r1, _022DFF48 ; =0x00000B6C - bl DisplayMessage2 -_022DF31C: - cmp fp, #0 - beq _022DF3B0 - add r4, sl, #0x1c - ldrb r0, [r4, #2] - cmp r0, #0xfa - bne _022DF364 - ldrb r0, [sb, #0x748] - bl IsLevelResetDungeon - cmp r0, #0 - beq _022DF34C - mov r0, r4 - bl SetBaseStatsMovesGroundMonster -_022DF34C: - mov r0, r4 - bl ov29_022F7910 - cmp r0, #0 - moveq r0, #1 - streq r0, [sp] - b _022DF3A4 -_022DF364: - mov r6, #0 - mov fp, #0x44 -_022DF36C: - ldrb r0, [sb, #0x748] - bl IsLevelResetDungeon - cmp r0, #0 - beq _022DF384 - smlabb r0, r6, fp, r4 - bl SetBaseStatsMovesGroundMonster -_022DF384: - mov r0, #0x44 - smlabb r0, r6, r0, r4 - bl ov29_022F7BF4 - add r0, r6, #1 - mov r0, r0, lsl #0x10 - mov r6, r0, asr #0x10 - cmp r6, #2 - blt _022DF36C -_022DF3A4: - cmp r5, #0 - beq _022DF3B0 - bl ov29_022FC9C0 -_022DF3B0: - cmp r5, #0 - addeq r0, sb, #0x700 - ldreqsb r0, [r0, #0x98] - cmpeq r0, #2 - bne _022DF418 - add r0, sp, #0x10 - bl sub_0204F1B4 - cmp r0, #0 - beq _022DF418 - ldrsb r0, [sp, #0x10] - bl sub_0205B77C - ldrsb r0, [r0, #0xac] - cmp r0, #0 - beq _022DF408 - add r1, r0, #1 - mov r0, #0 - bl SetMessageLogPreprocessorArgsNumberVal - ldr r1, _022DFF4C ; =0x00000B6D - mov r0, #0 - mov r2, #1 - bl DisplayMessage2 - b _022DF418 -_022DF408: - ldr r1, _022DFF50 ; =0x00000B6E - mov r0, #0 - mov r2, #1 - bl DisplayMessage2 -_022DF418: - ldrsb r0, [sl, #0xe] - cmp r0, #1 - beq _022DF428 - bl ov29_022DEB40 -_022DF428: - mov r0, #2 - bl ov29_022DDE00 - mov r0, #0 - bl ov10_022BDBB0 - bl ov29_022F6EF4 - bl ov29_022E8104 - bl ov29_022E7F7C - bl InitMessageLogPreprocessorArgs - bl ov29_0234BB2C - bl ov29_022DE4FC - cmp r5, #0 - bne _022DF460 - bl ov29_022DEA34 - bl ov29_022E1640 -_022DF460: - ldr r0, _022DFF54 ; =LEADER_PTR - mov r1, #0 - str r1, [r0] - bl GetHiddenFloorField - mov r6, r0 - bl SetBothScreensWindowColorToDefault - ldr r1, _022DFF40 ; =DUNGEON_PTR - mov r2, #0 - ldr r0, [r1] - cmp r5, #0 - strb r2, [r0, #4] - ldr r0, [r1] - add r0, r0, #0x3000 - strb r2, [r0, #0xe28 + RUN_DUNGEON_OFFSET] - bne _022DF4E4 - ldr r0, [r1] - mov r1, #0xa - add r0, r0, #0x700 - strh r1, [r0, #0x88] - bl GetHiddenFloorField - cmp r0, #0 - bne _022DF4E4 - bl GenerateDungeonRngSeed - mov r4, r0 - bl GetDungeonRngPreseed - ldr r1, _022DFF40 ; =DUNGEON_PTR - ldr r2, [r1] - str r0, [r2, #0x7ac] - ldr r0, [r1] - str r4, [r0, #0x79c] - ldr r0, [r1] - ldr r0, [r0, #0x79c] - bl InitDungeonRng -_022DF4E4: - cmp r5, #0 - bne _022DF53C - ldr r0, _022DFF40 ; =DUNGEON_PTR - mov r2, #0 - ldr r1, [r0] - mov r0, #4 - add r1, r1, #0x3000 - strb r2, [r1, #0xe38 + RUN_DUNGEON_OFFSET] - bl DungeonRandInt - ldr r1, _022DFF40 ; =DUNGEON_PTR - ldr r2, _022DFF58 ; =ov29_023510C0 - mov r3, r0, lsl #1 - ldr r0, [r1] - ldrsh r3, [r2, r3] -#ifdef JAPAN - add r0, r0, #0x3d00 - mov r2, #0 - strh r3, [r0, #0x96] -#else - add r0, r0, #0x3e00 - mov r2, #0 - strh r3, [r0, #0x3a + RUN_DUNGEON_OFFSET] -#endif - ldr r0, [r1] - add r0, r0, #0x3000 - strb r2, [r0, #0xe39 + RUN_DUNGEON_OFFSET] - ldr r0, [r1] - strb r2, [r0, #0x78a] -_022DF53C: - cmp r6, #0 - movne r1, #1 - moveq r1, #0 - ldr r2, _022DFF5C ; =ov29_022DEBBC - mov r0, r5 - and r1, r1, #0xff - bl LoadMappaFileAttributes - mov r0, #0 - bl ov29_0234B4CC - bl ov29_0234BB38 - cmp r5, #0 - bne _022DF574 - mov r0, #0 - bl ov29_02334DA8 -_022DF574: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x4000 - ldrsh r0, [r0, #0xd4 + RUN_DUNGEON_OFFSET] - bl ov29_023389C4 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0xc000 - ldrb r0, [r0, #0xd38 + RUN_DUNGEON_OFFSET] - bl ov29_02338A4C - bl ov29_022E8708 - bl ov29_022DD5B4 - bl ov29_023369F8 - bl CopySpawnEntriesOnce - bl LoadMonsterSprites - cmp r5, #0 - bne _022DF5C4 - bl ov29_0231B460 - bl ov29_022F7104 - b _022DF5CC -_022DF5C4: - bl LoadActiveMonsterSprites - bl ov29_022FBB1C -_022DF5CC: - bl ov29_022FE2E4 - bl InitEnemySpawnStats - cmp r5, #0 - bne _022DF5E4 - bl ov29_022EAD68 - bl ov29_022EF738 -_022DF5E4: - bl ov29_023365E8 - bl ov29_022E1550 - mov r0, #0 - bl ov29_02338F38 - mov r0, #4 - mov r1, #0 - bl UnkMapRelatedFunc - mov r0, #0 - bl ov29_0234B1A4 - mov r0, r5 - bl ov29_022E2B68 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x4000 - ldrb r0, [r0, #0xda + RUN_DUNGEON_OFFSET] - bl IsRoomIlluminated - cmp r0, #0 - addne r0, sb, #0x1a000 - movne r1, #1 - strneb r1, [r0, #0x23f + RUN_DUNGEON_OFFSET] - strneb r1, [r0, #0x240 + RUN_DUNGEON_OFFSET] - bl IsSecretBazaarVeneer - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x4000 - ldrb r0, [r0, #0xda + RUN_DUNGEON_OFFSET] - bl IsBossFight - cmp r0, #0 - bne _022DF660 - mov r0, #0x3c - bl DisplayFloorCard -_022DF660: - bl ov29_022E12F8 - cmp r5, #0 - bne _022DF68C - bl ResetVictoryCounter - bl GenerateFloor - ldrb r0, [sb, #0x748] - bl GetTurnLimit - add r1, sb, #0x700 - strh r0, [r1, #0x84] - mov r0, #0 - strb r0, [sb, #0x79a] -_022DF68C: - bl ov29_0233785C - bl DetermineAllTilesWalkableNeighbors - bl ov29_02336460 - cmp r5, #0 - bne _022DF6C0 - ldr r0, [sp, #4] - bl SpawnTeam - mov r0, #0 - str r0, [sp, #4] - bl SpawnShopkeepers - bl SpawnInitialMonsters - bl ResetGravity - b _022DF6F8 -_022DF6C0: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x1a000 - ldrb r0, [r0, #0x245 + RUN_DUNGEON_OFFSET] - cmp r0, #0 - beq _022DF6F4 - bl GetLeader - cmp r0, #0 - ldrne r0, _022DFF40 ; =DUNGEON_PTR - movne r1, #1 - ldrne r0, [r0] - addne r0, r0, #0x2c000 - strneb r1, [r0, #0xb10 + RUN_DUNGEON_OFFSET] -_022DF6F4: - bl ov29_022FCD04 -_022DF6F8: - bl ov29_0231AFB4 - add r0, sb, #0x19000 - mov r1, #0 - str r1, [r0, #0x904 + RUN_DUNGEON_OFFSET] - str r1, [r0, #0x90c + RUN_DUNGEON_OFFSET] - str r1, [r0, #0x908 + RUN_DUNGEON_OFFSET] - str r1, [r0, #0x910 + RUN_DUNGEON_OFFSET] - cmp r5, #0 - bne _022DF74C - bl SpawnTraps - bl ov29_0233873C - bl ov29_02344C4C - bl TrySpawnDoughSeedPoke - ldr r1, [sb, #0x7bc] - mov r0, #0 - str r1, [sb, #0x7c4] - str r0, [sb, #0x7c0] - bl ov29_02343980 - bl ov29_0233781C - bl ClearHiddenStairs - b _022DF750 -_022DF74C: - bl ReevaluateSnatchMonster -_022DF750: - bl ov29_022F7EAC - bl ov29_0233665C - bl UpdateTrapsVisibility - cmp r5, #0 - bne _022DF778 - mov r1, #0 - mov r2, r1 - mov r0, #1 - bl ov29_022FA2F0 - b _022DF780 -_022DF778: - bl DetermineAllMonsterShadow - bl ov29_022FA524 -_022DF780: - mov r0, #1 - bl ov29_022E3A58 - cmp r5, #0 - bne _022DF798 - bl ov29_022EF8A4 - bl ov29_022FA418 -_022DF798: - ldr r0, _022DFF60 ; =ov29_02353563 - mov r1, #1 - strb r1, [r0] - cmp r5, #0 - beq _022DF7B4 - bl ov29_023350FC - bl ov29_022FA750 -_022DF7B4: - bl CountItemsOnFloorForAcuteSniffer - mov r0, r5 - bl ov29_0233904C - mov r0, #1 - mov r1, #0 - bl UnkMapRelatedFunc - mov r0, #1 - bl ov29_0233A15C - bl GetTopScreenOption - cmp r0, #3 - bne _022DF7EC - mov r0, #1 - bl ov29_0233A1BC - bl UpdateMinimap -_022DF7EC: - mov r0, #0 - bl ov29_022E34B0 - mov r0, #0 - mov r1, r0 - bl ov29_022EA3F8 - bl ov29_022E0DFC - cmp r8, #0 - mov r1, #0x1000 - mov r2, #0 - beq _022DF824 - mov r0, #4 - bl StartFadeDungeonWrapper - mov r8, #0 - b _022DF82C -_022DF824: - mov r0, #1 - bl StartFadeDungeonWrapper -_022DF82C: - mov r0, #1 - mov r2, r0 - mov r1, #0x1000 - bl StartFadeDungeonWrapper - mov r0, #0 - bl WaitUntilFadeIsFinished - bl ov29_022E0E44 - mov r0, #1 - bl ov29_022E8BFC - mov r0, #1 - bl ov29_022EA418 - mov r0, #0 - bl ov29_02339FD0 - mov r0, #0 - mov r1, r0 - bl ov29_0233A0E8 - mov r0, #0 - bl ov29_02338F48 - mov r0, #0 - mov r1, r0 - bl UnkMapRelatedFunc - ldr r0, [sp] - mov r1, #0 - str r1, [sb, #0xc4] - strb r1, [sb, #0x78b] - cmp r0, #0 - strb r1, [sb, #0x78c] - mov r0, #0x63 - strh r0, [sb, #0x1c] - mov r2, #1 - ldr r0, _022DFF54 ; =LEADER_PTR - strb r2, [sb, #4] - str r1, [r0] - beq _022DF8E4 - ldr r1, _022DFF40 ; =DUNGEON_PTR - mov r0, #4 - ldr r1, [r1] - strb r2, [r1, #8] - bl SetForcedLossReason - ldrsh r1, [sl, #0x20] - mov r0, #0 - bl SetMessageLogPreprocessorArgsFlagVal - ldr r1, _022DFF64 ; =0x00000B73 - mov r0, #0 - mov r2, #1 - bl DisplayMessage2 -_022DF8E4: - ldr r0, _022DFF40 ; =DUNGEON_PTR - mov r1, #0 - ldr r0, [r0] - cmp r5, #0 - strb r1, [r0, #9] - beq _022DF90C - bl TryActivateArtificialWeatherAbilities - mov r0, #1 - bl HandleShopTransaction - b _022DF9B0 -_022DF90C: - bl DisplayFloorTip - bl ov29_022EF9B8 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #8] - cmp r0, #0 - ldreqb r0, [r1, #6] - cmpeq r0, #0 - movne r0, #1 - strneb r0, [r1, #9] - bne _022DF944 - bl GetLeader - bl ov29_022E2DFC - bl UpdateMinimap -_022DF944: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #9] - cmp r0, #0 - bne _022DF974 - bl ov29_02334D58 - mov r0, #0 - bl GetApparentWeather - cmp r0, #0 - beq _022DF974 - mov r0, #1 - bl ov29_02335044 -_022DF974: - mov r0, #1 - bl TryActivateNewFloorHpRestoration - mov r0, #0 - bl TryActivateNewFloorPpRestoration - bl TryActivateIqBooster - mov r0, #0 - bl TryActivateAcuteSniffer - bl TryActivateSlowStart - bl ov29_02349C84 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x748] - cmp r0, #0xa4 - bne _022DF9B0 - bl TryInflictBurnStatusWholeTeam -_022DF9B0: - cmp r7, #0 - beq _022DFA78 - bl GetLeader - movs r4, r0 - beq _022DFA78 - mov r0, #8 - bl DungeonRandInt - and r0, r0, #0xff - and r3, r0, #7 - ldr r0, _022DFF68 ; =DIRECTIONS_XY - mov r1, r3, lsl #2 - ldrsh r2, [r0, r1] - add r0, r0, r3, lsl #2 - ldrsh r3, [r4, #4] - ldrsh r0, [r0, #2] - ldrsh r1, [r4, #6] - add r2, r3, r2 - strh r2, [sp, #0x12] - mov r2, #0 - add r0, r1, r0 - strh r0, [sp, #0x14] - ldrh r1, [sp, #0x14] - ldrh r0, [sp, #0x12] - strb r2, [sp, #0x3c] - strb r2, [sp, #0x3a] - add r2, sl, #0xa4 - str r2, [sp, #0xcc] - mov r2, #3 - str r2, [sp, #0x18] - mov r2, #1 - strb r2, [sp, #0x38] - strh r1, [sp, #0x1e] - strh r0, [sp, #0x1c] - ldrsh r2, [sp, #0x12] - mov r0, #0x18 - ldrsh r1, [sp, #0x14] - smulbb r2, r2, r0 - smulbb r0, r1, r0 - add r1, r2, #4 - add r2, r0, #4 - add r0, sp, #0x18 - mov r1, r1, lsl #8 - mov r2, r2, lsl #8 - bl SetEntityPixelPosXY - mov r3, #0 - mov r0, r4 - add r1, sp, #0x18 - add r2, sl, #0xa4 - strh r3, [sp, #0x3e] - bl ov29_02345D84 -_022DFA78: - mov r0, #0 - bl ov29_022EA418 - mov r0, #1 - bl ov29_02338F48 - mov r0, #1 - bl ov29_02339F88 - bl UpdateMinimap - cmp r5, #0 - bne _022DFAA4 - mov r0, #0 - bl TryActivateStairSensor -_022DFAA4: - mov r7, #0 - cmp r5, #0 - movne r5, r7 - bne _022DFAD4 - bl ov29_022E5F20 - bl GetLeader - add r1, sb, #0x4000 - ldrb r1, [r1, #0xc4 + RUN_DUNGEON_OFFSET] - bl ov29_02305814 - mov r0, #1 - mov r1, r7 - bl TryActivateWeather -_022DFAD4: -#ifdef JAPAN - mov r0, #0x14000 -#else - mov r0, #0x10c00 -#endif - bl ov10_022BFE6C - bl sub_02001808 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #9] - cmp r0, #0 - bne _022DFB2C - mov r4, #1 - mov r2, #0 - mov r0, r4 - strb r2, [sb, #0x758] - add r1, sb, #0x1a000 - strb r2, [r1, #0x24d + RUN_DUNGEON_OFFSET] - bl SetMinimapDataE447 - mov r6, #0 -_022DFB14: - mov r0, r4 - bl RunFractionalTurn - mov r4, r6 - bl IsFloorOver - cmp r0, #0 - beq _022DFB14 -_022DFB2C: - mov r0, #0 - bl ov29_0234B010 - mov r0, #0 - bl ov29_0234B1A4 - mov r0, #0 - bl ov29_022E8BFC - bl GetLeader - bl EntityIsValid__022E0354 - cmp r0, #0 - beq _022DFB5C - bl GetLeader - bl EnemyEvolution -_022DFB5C: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x758] - cmp r0, #1 - beq _022DFB8C - mov r0, #1 - bl TryForcedLoss - cmp r0, #0 - ldrne r0, _022DFF40 ; =DUNGEON_PTR - movne r1, #1 - ldrne r0, [r0] - strneb r1, [r0, #0x758] -_022DFB8C: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x758] - cmp r0, #1 - beq _022DFBAC - ldr r0, [r1, #0x18] - cmp r0, #0 - beq _022DFBC4 -_022DFBAC: - ldrb r0, [r1, #0xa] - cmp r0, #0 - ldreqb r0, [r1, #0x75f] - cmpeq r0, #0 - bne _022DFBC4 - bl ov29_022FA648 -_022DFBC4: - bl GetLeader - bl EntityIsValid__022E0354 - cmp r0, #0 - beq _022DFBE4 - mov r0, #0x4f - bl WaitUntilAlertBoxTextIsLoaded - mov r0, #0x4f - bl WaitUntilAlertBoxPauseIsOver -_022DFBE4: - mov r0, #0 - bl ov29_02338F38 - mov r0, #1 - mov r1, #0 - bl UnkMapRelatedFunc - mov r0, #0 - bl SetMinimapDataE447 - ldr r0, _022DFF40 ; =DUNGEON_PTR - mov r2, #1 - ldr r1, [r0] - mov r0, #4 - add r1, r1, #0x1a000 - strb r2, [r1, #0x24d + RUN_DUNGEON_OFFSET] - mov r1, #0x4f - bl ov29_022EA370 - bl ov29_022E9FC0 - cmp r0, #0 - beq _022DFC30 - bl FadeToBlack -_022DFC30: - mov r0, #2 - mov r1, #0 - bl sub_020091B0 - mov r0, #3 - mov r1, #0 - bl sub_020091B0 - bl GetForcedLossReason - cmp r0, #2 - beq _022DFC60 - bl GetForcedLossReason - cmp r0, #3 - bne _022DFDB0 -_022DFC60: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0xa] - cmp r0, #0 - beq _022DFDB0 - bl GetLeader - mov r4, r0 - mov r0, #0 - bl ov29_0233A248 - mov r0, #1 - bl ov29_023359F8 - mov r0, #0x20 - bl ov29_0234C654 - mov r0, #0 - mov r1, r0 - bl sub_020091B0 - mov r0, #1 - mov r1, #0 - bl sub_020091B0 - mov r0, #2 - mov r1, #0 - bl sub_02009194 - mov r0, #3 - mov r1, #0 - bl sub_02009194 - mov r0, #4 - mov r1, #0 - bl sub_02009194 - mov r0, #1 - mov r1, #0x4000 - mov r2, #0 - bl StartFadeDungeonWrapper - mov r0, #0 - bl WaitUntilFadeIsFinished - mov r0, #0 -#ifdef JAPAN - mov r1, #0x880 -#else - ldr r1, _022DFF6C ; =0x00000B6F -#endif - mov r2, #1 - bl DisplayMessage - mov r0, #2 - mov r1, #0x4000 - mov r2, #0 - bl StartFadeDungeonWrapper - mov r0, #0 - bl WaitUntilFadeIsFinished - mov r0, #1 - bl ov29_0234C654 - mov r0, #0 - bl ov29_023359F8 - mov r0, #0 - mov r1, r0 - bl sub_020091B0 - mov r0, #1 - mov r1, #0 - bl sub_020091B0 - mov r0, #2 - mov r1, #0 - bl sub_020091B0 - mov r0, #3 - mov r1, #0 - bl sub_020091B0 - mov r0, #4 - mov r1, #0 - bl sub_020091B0 - mov r1, #0 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - strb r1, [r0, #0xa] - bl GetForcedLossReason - cmp r0, #3 - bne _022DFD9C - ldr r1, _022DFF40 ; =DUNGEON_PTR - ldr r0, _022DFF70 ; =0x00000266 - ldr r2, [r1] - mov r1, r4 - add r3, r2, #0x248 - mov r2, r4 - add r3, r3, #0x400 - bl CreateMonsterSummaryFromEntityOuter - b _022DFDB0 -_022DFD9C: - ldr r0, _022DFF74 ; =0x00000261 - mov r1, r4 - mov r2, r4 - mov r3, #0 - bl CreateMonsterSummaryFromEntityOuter -_022DFDB0: - bl UpdateShouldBoostKecleonShopSpawnChance - bl UpdateShouldBoostHiddenStairsSpawnChance - bl DeleteAllMonsterSpriteFiles - bl ov29_023365B8 - bl ov29_022DD7AC - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, _022DFF60 ; =ov29_02353563 - mov r3, #0 - ldr r2, [r0] - strb r3, [r1] - ldrb r0, [r2, #7] - cmp r0, #0 - beq _022DFE0C - bl ov29_0234CA84 - mov r1, #3 - ldr r0, _022DFF40 ; =DUNGEON_PTR - str r1, [sl, #0xb0] - ldr r1, [r0] - ldrb r0, [r1, #0x748] - strb r0, [sl, #0xb4] - ldrb r0, [r1, #0x749] - strb r0, [sl, #0xb5] - b _022E026C -_022DFE0C: - ldrb r0, [r2, #0xa] - cmp r0, #0 - beq _022DFE1C - bl ov29_0234CA84 -_022DFE1C: - bl ov29_022FDFA4 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0xa] - cmp r0, #0 - bne _022DFE3C - mov r0, #2 - bl ov29_023469E0 -_022DFE3C: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x758] - cmp r0, #1 - bne _022DFE64 - ldrb r0, [r1, #0x790] - cmp r0, #0 - beq _022E00EC - bl ov29_02346A64 - b _022E00EC -_022DFE64: - ldr r0, [r1, #0x18] - mov r1, #0 - cmp r0, #1 - bne _022DFE94 - bl GetLeader - mov r2, r0 - mov r1, #0 - ldr r0, _022DFF78 ; =0x00000279 - mov r3, r1 - bl CreateMonsterSummaryFromEntityOuter - mov r1, #1 - b _022DFF8C -_022DFE94: - cmp r0, #2 - bne _022DFED4 - bl GetLeader - mov r1, #0 - mov r2, r0 - mov r3, r1 - mov r0, #0x27c - bl CreateMonsterSummaryFromEntityOuter - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x790] - cmp r0, #0 - beq _022DFECC - bl IncrementNbSteals -_022DFECC: - mov r1, #1 - b _022DFF8C -_022DFED4: - cmp r0, #3 - bne _022DFF14 - bl GetLeader - mov r2, r0 - mov r1, #0 - ldr r0, _022DFF7C ; =0x0000027D - mov r3, r1 - bl CreateMonsterSummaryFromEntityOuter - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x790] - cmp r0, #0 - beq _022DFF0C - bl IncrementNbSteals -_022DFF0C: - mov r1, #1 - b _022DFF8C -_022DFF14: - cmp r0, #4 - bne _022DFF84 - bl GetLeader - mov r2, r0 - mov r1, #0 - ldr r0, _022DFF80 ; =0x0000027A - mov r3, r1 - bl CreateMonsterSummaryFromEntityOuter - mov r1, #1 - b _022DFF8C - .align 2, 0 -#ifdef JAPAN -#define RUN_DUNGEON_DATA_OFFSET -0x2EF -#else -#define RUN_DUNGEON_DATA_OFFSET 0 -#endif -_022DFF3C: .word ov29_023510C8 -_022DFF40: .word DUNGEON_PTR -_022DFF44: .word 0x00000B6B + RUN_DUNGEON_DATA_OFFSET -_022DFF48: .word 0x00000B6C + RUN_DUNGEON_DATA_OFFSET -_022DFF4C: .word 0x00000B6D + RUN_DUNGEON_DATA_OFFSET -_022DFF50: .word 0x00000B6E + RUN_DUNGEON_DATA_OFFSET -_022DFF54: .word LEADER_PTR -_022DFF58: .word ov29_023510C0 -_022DFF5C: .word ov29_022DEBBC -_022DFF60: .word ov29_02353563 -_022DFF64: .word 0x00000B73 + RUN_DUNGEON_DATA_OFFSET -_022DFF68: .word DIRECTIONS_XY -#ifndef JAPAN -_022DFF6C: .word 0x00000B6F -#endif -_022DFF70: .word 0x00000266 -_022DFF74: .word 0x00000261 -_022DFF78: .word 0x00000279 -_022DFF7C: .word 0x0000027D -_022DFF80: .word 0x0000027A -_022DFF84: - cmp r0, #5 - moveq r1, #1 -_022DFF8C: - cmp r1, #0 - bne _022E00EC - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x700 - ldrsb r0, [r0, #0x98] - cmp r0, #2 - bne _022DFFFC - bl GetFloorType - cmp r0, #2 - ldreq r0, _022DFF40 ; =DUNGEON_PTR - ldreq r0, [r0] - ldreqb r0, [r0, #0x758] - cmpeq r0, #2 - bne _022DFFFC - bl GetLeader - mov r2, r0 - mov r1, #0 - ldr r0, _022E034C ; =0x0000027B - mov r3, r1 - bl CreateMonsterSummaryFromEntityOuter - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x790] - cmp r0, #0 - beq _022E00EC - bl IncrementNbSteals - b _022E00EC -_022DFFFC: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x790] - cmp r0, #0 - beq _022E0014 - bl IncrementNbSteals -_022E0014: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r4, [r0] - add r0, r4, #0x700 - ldrsb r0, [r0, #0x98] - cmp r0, #3 - bne _022E005C - ldrb r0, [r4, #0x748] - bl GetMaxReachedFloor - ldrb r1, [r4, #0x749] - cmp r0, r1 - bhi _022E005C - bl GetLeader - mov r2, r0 - mov r1, #0 - ldr r0, _022DFF80 ; =0x0000027A - mov r3, r1 - bl CreateMonsterSummaryFromEntityOuter - b _022E00EC -_022E005C: - ldr r1, _022DFF40 ; =DUNGEON_PTR - ldrb r0, [r4, #0x748] - ldr r4, [r1] - bl GetMaxReachedFloor - ldrb r1, [r4, #0x749] - cmp r1, r0 - bls _022E008C - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x748] - ldrb r1, [r1, #0x749] - bl SetMaxReachedFloor -_022E008C: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, [r0] - add r0, r1, #0x2c000 - ldrb r1, [r1, #0x749] - ldrb r0, [r0, #0xaf4 + RUN_DUNGEON_OFFSET] - add r1, r1, #1 - cmp r1, r0 - blt _022E00C8 - bl GetLeader - mov r2, r0 - mov r1, #0 - ldr r0, _022DFF80 ; =0x0000027A - mov r3, r1 - bl CreateMonsterSummaryFromEntityOuter - b _022E00EC -_022E00C8: - bl GetHiddenFloorField - cmp r0, #0 - bne _022DF428 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, [r0] - ldrb r0, [r1, #0x749] - add r0, r0, #1 - strb r0, [r1, #0x749] - b _022DF428 -_022E00EC: - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r1, _022DFF60 ; =ov29_02353563 - mov r2, #0 - ldr r0, [r0] - strb r2, [r1] - ldrb r0, [r0, #0xa] - cmp r0, #0 - bne _022E0150 - add r0, sl, #0xc0 - bl ov29_022ECFB8 - ldr r1, _022DFF40 ; =DUNGEON_PTR - mov r0, #0 - ldr r1, [r1] - strb r0, [r1, #0x791] - bl SetUnkMusicFlag - ldr r1, _022DFF40 ; =DUNGEON_PTR - mov r3, #0 - ldr r0, [r1] - ldr r2, _022E0350 ; =0x000003E7 - strb r3, [r0, #0x794] - ldr r0, [r1] - add r0, r0, #0x700 - strh r2, [r0, #0x96] - ldr r0, [r1] - strb r3, [r0, #0x7c9] -_022E0150: - cmp sl, #0 - beq _022E026C - bl IsDungeonEndReasonFailure - cmp r0, #0 - beq _022E01D8 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0xa] - cmp r0, #0 - beq _022E01C8 - mvn r2, #1 - add r0, sl, #0xb8 - mov r1, #8 - str r2, [sl, #0xb0] - bl MemZero - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r2, [r0] - ldrb r1, [r2, #0x748] - strb r1, [sl, #0xb4] - ldrb r1, [r2, #0x749] - strb r1, [sl, #0xb5] - ldr r2, [r0] - ldrb r1, [r2, #0x748] - strb r1, [sl, #0xb8] - ldrb r1, [r2, #0x749] - strb r1, [sl, #0xb9] - ldr r0, [r0] - ldr r0, [r0, #0x7a0] - str r0, [sl, #0xbc] - b _022E026C -_022E01C8: - mvn r0, #0 - str r0, [sl, #0xb0] - bl ov29_023488C8 - b _022E026C -_022E01D8: - bl ov29_022ECF78 - cmp r0, #0 - beq _022E0244 - ldr r0, _022DFF40 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x700 - ldrsb r0, [r0, #0x98] - cmp r0, #2 - moveq r0, #4 - streq r0, [sl, #0xb0] - beq _022E026C - cmp r0, #3 - moveq r0, #1 - streq r0, [sl, #0xb0] - beq _022E026C - cmp r0, #0 - bne _022E022C - mov r0, #1 - str r0, [sl, #0xb0] - bl ov29_02348894 - b _022E026C -_022E022C: - bl ov29_02348918 - bl ov29_02348994 - mov r0, #1 - str r0, [sl, #0xb0] - bl ov29_02348894 - b _022E026C -_022E0244: - mov r1, #2 - ldr r0, _022DFF40 ; =DUNGEON_PTR - str r1, [sl, #0xb0] - ldr r0, [r0] - add r0, r0, #0x700 - ldrsb r0, [r0, #0x98] - cmp r0, #1 - bne _022E0268 - bl ov29_02348994 -_022E0268: - bl ov29_02348894 -_022E026C: - bl SetBothScreensWindowColorToDefault - mov r0, #0x14 - bl ov29_022EAEAC - mov r0, #0x14 - bl ov29_022DDE00 - bl ov29_022E15C8 - bl ov29_022E1604 - bl ov29_02338FC8 - cmp sl, #0 - beq _022E030C - ldr r1, [sl, #0xb0] - mvn r0, #1 - cmp r1, r0 - cmpne r1, #3 - beq _022E02B4 - bl sub_02057E90 - mvn r0, #0 - bl sub_02058644 -_022E02B4: - ldr r1, [sl, #0xb0] - cmp r1, #1 - cmpne r1, #4 - cmpne r1, #2 - bne _022E02D4 - bl ov29_02346DA4 - bl RefillTeam - b _022E02EC -_022E02D4: - mvn r0, #0 - cmp r1, r0 - bne _022E02EC - bl ov29_02346E48 - bl ov29_022F7E34 - bl sub_02057EF4 -_022E02EC: - ldr r0, [sl, #0xb0] - cmp r0, #1 - cmpne r0, #4 - cmpne r0, #2 - moveq r0, #1 - streqb r0, [sl, #0x1a8] - movne r0, #0 - strneb r0, [sl, #0x1a8] -_022E030C: - bl ov10_022BDC0C - bl FreeTopScreenStatus - bl FreeAlertBoxInfo - bl ov29_0234BB20 - bl ov29_02338D30 - bl ov29_022ED0B0 - bl ov29_022DE930 - bl FreeLoadedAttackSpriteAndMore - ldr r0, _022DFF40 ; =DUNGEON_PTR - mov r1, #0 - str r1, [r0] - bl ov29_022DE15C - bl CloseFixedBin - mov r0, #1 - add sp, sp, #0xd0 - ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} - .align 2, 0 -_022E034C: .word 0x0000027B -_022E0350: .word 0x000003E7 - arm_func_end RunDungeon diff --git a/asm/overlay_29_rodata_0234FD04.s b/asm/overlay_29_rodata_0234FD04.s index 5229839f..2a5892ce 100644 --- a/asm/overlay_29_rodata_0234FD04.s +++ b/asm/overlay_29_rodata_0234FD04.s @@ -1524,174 +1524,3 @@ ov29_023510B8: .global ov29_023510BC ov29_023510BC: .byte 0x00, 0x00, 0x00, 0x00 - .global ov29_023510C0 -ov29_023510C0: - .byte 0xA2, 0x01, 0xA3, 0x01, 0xA4, 0x01, 0xA5, 0x01 - .global ov29_023510C8 -ov29_023510C8: - .byte 0x44, 0x47, 0x5F, 0x56 - .byte 0x52, 0x41, 0x4D, 0x5F, 0x53, 0x50, 0x52, 0x49, 0x54, 0x45, 0x5F, 0x4E, 0x41, 0x4D, 0x45, 0x3A - .byte 0x25, 0x64, 0x0A, 0x00 - .global ov29_023510E0 -ov29_023510E0: - .byte 0xD0, 0x01, 0x20, 0x00, 0xD1, 0x01, 0x40, 0x00, 0xD2, 0x01, 0x80, 0x00 - .byte 0xD4, 0x01, 0x20, 0x00, 0xD5, 0x01, 0x40, 0x00, 0xD6, 0x01, 0x00, 0x01, 0xDA, 0x01, 0x20, 0x00 - .byte 0xDB, 0x01, 0x20, 0x00, 0xDC, 0x01, 0x20, 0x00, 0xDD, 0x01, 0x20, 0x00, 0xDE, 0x01, 0x80, 0x00 - .global ov29_0235110C -ov29_0235110C: - .byte 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF - .byte 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF - .byte 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF - .byte 0x02, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xFF, 0xFF - .byte 0x03, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xFF, 0xFF - .byte 0x04, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF - .byte 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF - .byte 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF - .global ov29_0235118C -ov29_0235118C: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global ov29_02351194 -ov29_02351194: - .byte 0x0C, 0x00, 0x0D, 0x00, 0x0D, 0x00, 0x06, 0x03 - .global ov29_0235119C -ov29_0235119C: - .byte 0x0A, 0x00, 0x0B, 0x00, 0x0B, 0x00, 0x07, 0x03 - .global ov29_023511A4 -ov29_023511A4: - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x08 - .global ov29_023511B0 -ov29_023511B0: - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_MUZZLED -STATUS_ICON_ARRAY_MUZZLED: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_MAGNET_RISE -STATUS_ICON_ARRAY_MAGNET_RISE: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00 - .global ov29_023511DC -ov29_023511DC: - .byte 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x11, 0x03, 0x00, 0x3F, 0x00, 0x3F, 0x12, 0x03, 0x00, 0x3F - .global STATUS_ICON_ARRAY_MIRACLE_EYE -STATUS_ICON_ARRAY_MIRACLE_EYE: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_LEECH_SEED -STATUS_ICON_ARRAY_LEECH_SEED: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_LONG_TOSS -STATUS_ICON_ARRAY_LONG_TOSS: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global ov29_0235122C -ov29_0235122C: - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x4B, 0x01, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF - .byte 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0x00, 0x00, 0x00 - .global ov29_0235124C -ov29_0235124C: - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x4B, 0x01, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF - .byte 0xB8, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_BLINDED -STATUS_ICON_ARRAY_BLINDED: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_BURN -STATUS_ICON_ARRAY_BURN: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_SURE_SHOT -STATUS_ICON_ARRAY_SURE_SHOT: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_INVISIBLE -STATUS_ICON_ARRAY_INVISIBLE: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_SLEEP -STATUS_ICON_ARRAY_SLEEP: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 - .byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_CURSE -STATUS_ICON_ARRAY_CURSE: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_FREEZE -STATUS_ICON_ARRAY_FREEZE: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_CRINGE -STATUS_ICON_ARRAY_CRINGE: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_BIDE -STATUS_ICON_ARRAY_BIDE: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global ov29_02351464 -ov29_02351464: - .byte 0x78, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 - .byte 0x79, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x7A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7B, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 - .byte 0x7C, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7D, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 - .byte 0x7E, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x7F, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB9, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 - .byte 0xBA, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xBB, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global STATUS_ICON_ARRAY_REFLECT -STATUS_ICON_ARRAY_REFLECT: - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global ov29_02351584 -ov29_02351584: - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .global ov29_02351594 -ov29_02351594: - .byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x42, 0x41, 0x4C - .byte 0x41, 0x4E, 0x43, 0x45, 0x2F, 0x6D, 0x61, 0x70, 0x70, 0x61, 0x5F, 0x74, 0x2E, 0x62, 0x69, 0x6E - .byte 0x00, 0x00, 0x00, 0x00 - .global ov29_023515B0 -ov29_023515B0: - .byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x42, 0x41, 0x4C, 0x41, 0x4E, 0x43, 0x45 - .byte 0x2F, 0x6D, 0x61, 0x70, 0x70, 0x61, 0x5F, 0x79, 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00 - .global ov29_023515CC -ov29_023515CC: - .byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x42, 0x41, 0x4C, 0x41, 0x4E, 0x43, 0x45, 0x2F, 0x6D, 0x61, 0x70 - .byte 0x70, 0x61, 0x5F, 0x73, 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00 - .global ov29_023515E8 -ov29_023515E8: - .byte 0x02, 0x00, 0x01, 0x00 - .byte 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00 - .global DUNGEON_CONTROLS_MENU_WINDOW_PARAMS -DUNGEON_CONTROLS_MENU_WINDOW_PARAMS: - .byte 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x1C, 0x14 - .byte 0x01, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/asm/overlay_29_rodata_023510C8.s b/asm/overlay_29_rodata_023510C8.s new file mode 100644 index 00000000..cbc5bcc7 --- /dev/null +++ b/asm/overlay_29_rodata_023510C8.s @@ -0,0 +1,172 @@ + .include "asm/macros.inc" + .include "overlay_29_rodata_023510C8.inc" + + .rodata + .global ov29_023510C8 +ov29_023510C8: + .byte 0x44, 0x47, 0x5F, 0x56 + .byte 0x52, 0x41, 0x4D, 0x5F, 0x53, 0x50, 0x52, 0x49, 0x54, 0x45, 0x5F, 0x4E, 0x41, 0x4D, 0x45, 0x3A + .byte 0x25, 0x64, 0x0A, 0x00 + .global ov29_023510E0 +ov29_023510E0: + .byte 0xD0, 0x01, 0x20, 0x00, 0xD1, 0x01, 0x40, 0x00, 0xD2, 0x01, 0x80, 0x00 + .byte 0xD4, 0x01, 0x20, 0x00, 0xD5, 0x01, 0x40, 0x00, 0xD6, 0x01, 0x00, 0x01, 0xDA, 0x01, 0x20, 0x00 + .byte 0xDB, 0x01, 0x20, 0x00, 0xDC, 0x01, 0x20, 0x00, 0xDD, 0x01, 0x20, 0x00, 0xDE, 0x01, 0x80, 0x00 + .global ov29_0235110C +ov29_0235110C: + .byte 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF + .byte 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF + .byte 0x01, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF + .byte 0x02, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xFF, 0xFF + .byte 0x03, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFD, 0xFF, 0xFF, 0xFF + .byte 0x04, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF + .byte 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF + .byte 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0xFF, 0xFF + .global ov29_0235118C +ov29_0235118C: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global ov29_02351194 +ov29_02351194: + .byte 0x0C, 0x00, 0x0D, 0x00, 0x0D, 0x00, 0x06, 0x03 + .global ov29_0235119C +ov29_0235119C: + .byte 0x0A, 0x00, 0x0B, 0x00, 0x0B, 0x00, 0x07, 0x03 + .global ov29_023511A4 +ov29_023511A4: + .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x08 + .global ov29_023511B0 +ov29_023511B0: + .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_MUZZLED +STATUS_ICON_ARRAY_MUZZLED: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_MAGNET_RISE +STATUS_ICON_ARRAY_MAGNET_RISE: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00 + .global ov29_023511DC +ov29_023511DC: + .byte 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x11, 0x03, 0x00, 0x3F, 0x00, 0x3F, 0x12, 0x03, 0x00, 0x3F + .global STATUS_ICON_ARRAY_MIRACLE_EYE +STATUS_ICON_ARRAY_MIRACLE_EYE: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_LEECH_SEED +STATUS_ICON_ARRAY_LEECH_SEED: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_LONG_TOSS +STATUS_ICON_ARRAY_LONG_TOSS: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global ov29_0235122C +ov29_0235122C: + .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x4B, 0x01, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF + .byte 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0x00, 0x00, 0x00 + .global ov29_0235124C +ov29_0235124C: + .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x4B, 0x01, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF + .byte 0xB8, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_BLINDED +STATUS_ICON_ARRAY_BLINDED: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_BURN +STATUS_ICON_ARRAY_BURN: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_SURE_SHOT +STATUS_ICON_ARRAY_SURE_SHOT: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_INVISIBLE +STATUS_ICON_ARRAY_INVISIBLE: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_SLEEP +STATUS_ICON_ARRAY_SLEEP: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 + .byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_CURSE +STATUS_ICON_ARRAY_CURSE: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_FREEZE +STATUS_ICON_ARRAY_FREEZE: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_CRINGE +STATUS_ICON_ARRAY_CRINGE: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_BIDE +STATUS_ICON_ARRAY_BIDE: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global ov29_02351464 +ov29_02351464: + .byte 0x78, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 + .byte 0x79, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x7A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7B, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 + .byte 0x7C, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7D, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 + .byte 0x7E, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x7F, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB9, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 + .byte 0xBA, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xBB, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global STATUS_ICON_ARRAY_REFLECT +STATUS_ICON_ARRAY_REFLECT: + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global ov29_02351584 +ov29_02351584: + .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .global ov29_02351594 +ov29_02351594: + .byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x42, 0x41, 0x4C + .byte 0x41, 0x4E, 0x43, 0x45, 0x2F, 0x6D, 0x61, 0x70, 0x70, 0x61, 0x5F, 0x74, 0x2E, 0x62, 0x69, 0x6E + .byte 0x00, 0x00, 0x00, 0x00 + .global ov29_023515B0 +ov29_023515B0: + .byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x42, 0x41, 0x4C, 0x41, 0x4E, 0x43, 0x45 + .byte 0x2F, 0x6D, 0x61, 0x70, 0x70, 0x61, 0x5F, 0x79, 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00 + .global ov29_023515CC +ov29_023515CC: + .byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x42, 0x41, 0x4C, 0x41, 0x4E, 0x43, 0x45, 0x2F, 0x6D, 0x61, 0x70 + .byte 0x70, 0x61, 0x5F, 0x73, 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00 + .global ov29_023515E8 +ov29_023515E8: + .byte 0x02, 0x00, 0x01, 0x00 + .byte 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00 + .global DUNGEON_CONTROLS_MENU_WINDOW_PARAMS +DUNGEON_CONTROLS_MENU_WINDOW_PARAMS: + .byte 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x1C, 0x14 + .byte 0x01, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/include/dg.h b/include/dg.h index 1243ab65..4712ec6c 100644 --- a/include/dg.h +++ b/include/dg.h @@ -1,8 +1,12 @@ #ifndef PMDSKY_OVERLAY_29_022E0354_H #define PMDSKY_OVERLAY_29_022E0354_H +#include "dungeon_init.h" +#include "dungeon.h" #include "dungeon_mode.h" +// Runs the main dungeon gameplay loop (location 0x022DEF38) +s32 RunDungeon(struct dungeon_init *dungeon_init_data, struct dungeon *dungeon); // Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity). bool8 EntityIsValid__022E0354(struct entity *entity); diff --git a/include/dungeon.h b/include/dungeon.h index b743b6a5..c5041942 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -2,6 +2,7 @@ #define PMDSKY_DUNGEON_H #include "dungeon_mode.h" +#include "dungeon_location_seed.h" #include "enums.h" #include "item.h" @@ -663,19 +664,13 @@ struct dungeon { enum dungeon_group_id group_id; // 0x74A: Same for different segments of a dungeon u8 field_0x74b; // 0x74C: Used as an input to GetDungeonMode, and uses output to determine if the - // override fixed room should be loaded? - u16 field_0x74c; + // override fixed room should be loaded + s16 dungeon_idx; u8 field_0x74e; u8 field_0x74f; - // 0x750: A ldr instruction is used at this address? Maybe used for something else before - // the rescue floor number is set? - u8 field_0x750; - u8 rescue_floor; // 0x751: Floor number where the rescue point is, if applicable - u8 field_0x752; - u8 field_0x753; - // 0x754: Should also be prng_pressed_23_bit? dungeon_init::prng_preseed_23_bit gets copied - // here, but might not be used? - u32 prng_preseed_23_bit; + // 0x750: Rescue parameters copied from dungeon_init::rescue_location_seed. + // The seed at 0x754 is a redundant copy; the active seed is at 0x7A0. + dungeon_location_seed rescue_location_seed; // 0x758: Whether the current floor should continue or end and why enum floor_loop_status floor_loop_status; bool8 recruiting_enabled; // 0x759: Recruitment is allowed in this dungeon @@ -1512,9 +1507,7 @@ struct dungeon { // 0x1990C: Stores statuses::unique_id for the monster pointed to by dungeon::snatch_monster. u32 snatch_status_unique_id; // 0x19910: Spawn genid of the monster to be spawned by the effect of Illuminate - u16 illuminate_spawn_genid; - u8 field_0x19912; - u8 field_0x19913; + u32 illuminate_spawn_genid; // 0x19914: List that matches monster IDs with their sprite index on this floor enum monster_id sprite_indexes[1155]; u8 field_0x1a21a; diff --git a/include/dungeon_init.h b/include/dungeon_init.h index 3fa33a92..5105052d 100644 --- a/include/dungeon_init.h +++ b/include/dungeon_init.h @@ -2,7 +2,9 @@ #define PMDSKY_DUNGEON_INIT #include "common.h" +#include "dungeon_location_seed.h" #include "util.h" +#include "item.h" // Unknown struct used during dungeon initialisation struct unk { @@ -20,9 +22,9 @@ struct unk_dungeon_init { struct dungeon_init { u8 id; // 0x0: Copied into dungeon::id u8 floor; // 0x1: Copied into dungeon::floor - // Copied into dungeon::field_0x74C, might be related to the dungeon being conquered or + // Copied into dungeon::dungeon_idx, might be related to the dungeon being conquered or // the fixed room overrides. - u16 dungeon_idx; // 0x2 index of the dungeon. The index maps to the id in DUNGEON_SWAP_ID_TABLE + s16 dungeon_idx; // 0x2 index of the dungeon. The index maps to the id in DUNGEON_SWAP_ID_TABLE u8 field_0x4; bool8 nonstory_flag; // 0x5: Copied into dungeon::nonstory_flag bool8 recruiting_enabled; // 0x6: Copied into dungeon::recruiting_enabled @@ -37,8 +39,8 @@ struct dungeon_init { bool8 send_home_disabled; // 0xA: Copied into dungeon::send_home_disabled bool8 hidden_land_flag; // 0xB: Copied into dungeon::hidden_land_flag bool8 skip_faint_animation_flag; // 0xC: Copied into dungeon::skip_faint_animation_flag - // 0xD: Copied into dungeon::dungeon_objective. Read as a signed byte (?). - u8 dungeon_objective; + // 0xD: Copied into dungeon::dungeon_objective. + s8 dungeon_objective; s8 field_0xE; bool8 has_guest_pokemon; // 0xF: If true, a guest pokémon will be added to your team bool8 send_help_item; // 0x10: If true, you recive an item at the start of the dungeon @@ -46,43 +48,29 @@ struct dungeon_init { // have left s8 field_0x12; u8 field_0x13; - // 0x14 - // [EU]0x22DF920 loads this as a word - // [EU]0x22DFBAC loads this as a signed byte - // ??? - u32 field_0x14; // Copied into dungeon::field_0x750 - // 0x18: The dungeon PRNG preseed? Copied into dungeon::prng_preseed_23_bit and - // dungeon::rescue_prng_preseed_23_bit. - u32 prng_preseed_23_bit; + // 0x14: Copied as an eight-byte block into dungeon::rescue_location_seed. + // For rescues, the seed at 0x18 also initializes the active dungeon::rescue_prng_preseed_23_bit. + dungeon_location_seed rescue_location_seed; // 0x1C: Array containing the list of quest pokémon that will join the team in the dungeon // (max 2) struct ground_monster guest_pokemon[2]; - // 0xA4: Used as a base address at [EU]0x22E0354 and [EU]0x22E03AC. - // It's probably a separate struct. - u8 field_0xA4; - u8 field_0xA5; - u8 field_0xA6; - u8 field_0xA7; - // 0xA8: ID of the item to give to the player if send_help_item is true - /* struct item_id_16 */ u16 help_item; + // 0xA4: Item information for the help item, copied into the entity info of the item entity + struct item help_item; u8 field_0xAA; u8 field_0xAB; // 0xAC: Controls which version of the dungeon to load. Gets copied into // dungeon::dungeon_game_version_id. Uncertain when the game decides to load the // Time/Darkness version of dungeons. enum game_id dungeon_game_version_id; - u32 field_0xB0; + s32 field_0xB0; u8 field_0xB4; // Gets set to dungeon::id during dungeon init u8 field_0xB5; // Gets set to dungeon::floor during dungeon init u8 field_0xB6; u8 field_0xB7; - // 0xB8: Used as a base address at [EU]0x22E0ABC. - // It's probably a separate struct. - u8 field_0xB8; // Gets set to dungeon::id during dungeon init - u8 field_0xB9; // Gets set to dungeon::floor during dungeon init - u8 field_0xBA; - u8 field_0xBB; - u32 field_0xBC; + // 0xB8: Output location and seed populated by RunDungeon on failure when + // field_0xB0 is set to -2. Contains the current dungeon ID, floor, and + // rescue PRNG preseed (at 0xBC); the two remaining bytes are cleared. + dungeon_location_seed result_location_seed; // 0xC0: Used as a base address at [EU]0x22E0A4C struct unk_dungeon_init field_0xC0; u8 field_0x1A8; diff --git a/include/dungeon_location_seed.h b/include/dungeon_location_seed.h new file mode 100644 index 00000000..6a16dd6e --- /dev/null +++ b/include/dungeon_location_seed.h @@ -0,0 +1,28 @@ +#ifndef PMDSKY_DUNGEON_LOCATION_SEED_H +#define PMDSKY_DUNGEON_LOCATION_SEED_H + +#include +#include +#include "enums.h" + +// Eight-byte dungeon location and PRNG preseed. RunDungeon copies the input +// at dungeon_init + 0x14 to dungeon + 0x750, and populates a separate output +// at dungeon_init + 0xB8 on a failure path. +typedef struct dungeon_location_seed { + union { + u32 raw; + struct { + enum dungeon_id dungeon_id; // 0x0 + u8 floor; // 0x1: For rescue input, the target floor checked by GetFloorType + u8 field_0x2; // Unknown; cleared in the output block + u8 field_0x3; // Unknown, possibly padding; cleared in the output block + }; + }; + // 0x4: PRNG preseed. RunDungeon copies the rescue input directly from dungeon_init + // to dungeon::rescue_prng_preseed_23_bit; no independent use of the copy + // inside dungeon::rescue_location_seed has been identified. The output + // block receives dungeon::rescue_prng_preseed_23_bit. + u32 prng_preseed_23_bit; +} dungeon_location_seed; + +#endif // PMDSKY_DUNGEON_LOCATION_SEED_H diff --git a/include/overlay_29_022E9FC0.h b/include/overlay_29_022E9FC0.h index ad2f1427..010b50a7 100644 --- a/include/overlay_29_022E9FC0.h +++ b/include/overlay_29_022E9FC0.h @@ -11,7 +11,7 @@ void ov29_022EA2A4(u32 param_1); void ov29_022EA324(u32 param_1); void ov29_022EA370(s32 a, s32 b); void ov29_022EA3B4(s32 param_1); -void ov29_022EA3F8(void); +void ov29_022EA3F8(s32 unused0, s32 unused1); s32 ov29_022EA408(void); void ov29_022EA418(u8 param_1); void UnkMapRelatedFunc(s32 switch_case, u32 param_2); diff --git a/include/overlay_29_0234BA54.h b/include/overlay_29_0234BA54.h index 2b3108db..43aa4fed 100644 --- a/include/overlay_29_0234BA54.h +++ b/include/overlay_29_0234BA54.h @@ -6,9 +6,9 @@ void WaitUntilAlertBoxPauseIsOver(u32 param_1); void InitPortraitDungeon(portrait_params *portrait, enum monster_id monster_id, u8 emotion); void ov29_0234BB10(void); -void ov29_0234BB20(s32 a); -void ov29_0234BB2C(s32 a); -void ov29_0234BB38(s32 a); +void ov29_0234BB20(void); +void ov29_0234BB2C(void); +void ov29_0234BB38(void); void ov29_0234BB44(s32 a); void ov29_0234BB50(s32 a); s32 OpenMessageLog(s32 param_1, s32 param_2); diff --git a/main.lsf b/main.lsf index a83b07b4..77bbfb07 100644 --- a/main.lsf +++ b/main.lsf @@ -760,6 +760,8 @@ Overlay OVY_29 { After OVY_10 Object asm/overlay_29_rodata_0234FD04.o + Object src/deoxys_form_data.o + Object asm/overlay_29_rodata_023510C8.o Object asm/overlay_29_data_023534E0.o Object asm/overlay_29_bss_02353860.o Object src/poly_text.o diff --git a/src/deoxys_form_data.c b/src/deoxys_form_data.c new file mode 100644 index 00000000..44b1af8e --- /dev/null +++ b/src/deoxys_form_data.c @@ -0,0 +1,4 @@ +#include + +// Monster IDs of Deoxys's Normal, Attack, Defense, and Speed forms, respectively. +const s16 DEOXYS_FORMS[4] = {0x1A2, 0x1A3, 0x1A4, 0x1A5}; diff --git a/src/dg.c b/src/dg.c index dc4a8adb..806e7ea6 100644 --- a/src/dg.c +++ b/src/dg.c @@ -1,7 +1,1262 @@ #include "dg.h" +#include "spawn_1.h" +#include "options.h" +#include "overlay_29_023383A8.h" #include "dungeon_util_static.h" +#include "spawn_2.h" +#include "enums.h" +#include "overlay_29_02344088.h" +#include "debug.h" +#include "overlay_29_023047B8.h" +#include "dg_random.h" +#include "overlay_29_022EAC34.h" +#include "overlay_29_023026CC.h" +#include "overlay_29_022E869C.h" +#include "overlay_29_022EA968.h" +#include "weather.h" +#include "overlay_29_022EA9CC.h" +#include "overlay_29_022ED01C.h" +#include "overlay_29_02338850.h" +#include "dg_uty.h" +#include "main_0204D188.h" +#include "dungeon_recruitment_2.h" +#include "main_0204FB9C.h" +#include "dg_random.h" +#include "run_dungeon_1.h" +#include "overlay_29_022ECF44.h" +#include "overlay_29_022EC7E8.h" +#include "fixed_room_data.h" +#include "main_0200330C.h" +#include "number_util.h" +#include "main_0200224C.h" +#include "overlay_29_0233836C.h" +#include "common.h" +#include "dg_object.h" +#include "overlay_29_0234B024.h" +#include "overlay_29_0233A218.h" +#include "overlay_29_022EAEFC.h" +#include "overlay_29_022EFA6C.h" +#include "overlay_29_02338560.h" +#include "overlay_29_022E9FC0.h" +#include "overlay_29_02338604.h" +#include "overlay_29_02338548.h" +#include "overlay_29_02336F4C.h" +#include "overlay_29_0234BA54.h" +#include "overlay_10_022BFD58.h" +#include "overlay_29_022DEAB0.h" +#include "overlay_29_022DEAB0.h" +#include "dg_camera.h" +#include "overlay_29_022E563C.h" +#include "overlay_29_022E869C.h" +#include "overlay_29_022E9FC0.h" +#include "overlay_29_0230558C.h" +#include "special_move_types.h" +#include "overlay_29_023350D8.h" +#include "overlay_29_0234396C.h" +#include "overlay_29_0234AFFC.h" +#include "overlay_29_0234B104.h" +#include "main_0205B77C.h" -// file starts at 0x022dea5c +extern void SpawnTraps(void); +extern void LoadMonsterSprites(void); +extern void LoadActiveMonsterSprites(void); +extern void TryActivateNewFloorPpRestoration(bool8 param_1); +extern void TryActivateNewFloorHpRestoration(bool8 param_1); +extern void TryActivateAcuteSniffer(bool8 param_1); +extern void ChangeGiratinaFormIfSkyDungeon(enum dungeon_id dungeon_id); +extern void ClearHiddenStairs(void); +extern void CountItemsOnFloorForAcuteSniffer(void); +extern void CreateMonsterSummaryFromEntityOuter(s32 reason, struct entity *source, struct entity *target, const u8 *name); +extern void DeleteAllMonsterSpriteFiles(void); +extern void DetermineAllTilesWalkableNeighbors(void); +extern void DisplayFloorCard(int duration); +extern bool8 DisplayFloorTip(void); +extern void DisplayMessage(void* param_1, int param_2, bool8 param_3); +extern void DisplayMessage2(void* param_1, int param_2, bool8 param_3); +extern void FadeToBlack(void); +extern void FreeAlertBoxInfo(void); +extern void FreeLoadedAttackSpriteAndMore(void); +extern void GenerateFloor(void); +extern void *GetBgRegionArea(u32 offset, u32 subregion, u32 region); +extern u32 GetFloorType(void); +extern void HandleShopTransaction(s32 param_1); +extern void InitAlertBoxInfo(void); +extern void InitEnemySpawnStats(void); +extern bool8 IsSecretBazaarVeneer(void); +extern void LoadMappaFileAttributes(s32 param_1, bool8 param_2, void (*param_3)(u8)); +extern void LoadWeather3DFiles(void); +extern void OpenFixedBin(void); +extern u16 ReadMissionMtStateLower(void); +extern void ReevaluateSnatchMonster(void); +extern void RefillTeam(void); +extern void RunFractionalTurn(bool8 is_first_loop); +extern void SetBaseStatsMovesGroundMonster(struct ground_monster* ground_monster); +extern void SetBothScreensWindowColorToDefault(void); +extern void SpawnInitialMonsters(void); +extern void SpawnShopkeepers(void); +extern void SpawnTeam(u8 param_1); +extern void StartFadeDungeonWrapper(s32 param_1, s32 param_2, s32 param_3); +extern void TryActivateArtificialWeatherAbilities(void); +extern void TryActivateSlowStart(void); +extern void TryActivateStairSensor(bool8 param_1); +extern bool8 TryActivateWeather(bool8 param_1, bool8 param_2); +extern bool8 TryForcedLoss(bool8 param_1); +extern void TryInflictBurnStatusWholeTeam(void); +extern void UpdateMinimap(void); +extern void WaitUntilAlertBoxTextIsLoaded(u32 param_1); +extern void WaitUntilFadeIsFinished(s32 param_1); +extern void WriteMissionMtState(u32 value); +extern void ov10_022BDAB0(u32 param_1, u32 param_2, s16 param_3); +extern void ov10_022BDB54(u8 param_1); +extern void ov10_022BDB60(void *param_1, void *param_2, void *param_3, u32 param_4); +extern void ov10_022BDB80(u32 param_1, u16 param_2); +extern void ov10_022BDBA4(u32 param_1, u16 param_2); +extern void ov10_022BDBB0(u8 param_1); +extern void ov10_022BDC0C(void); +extern void ov29_022DD5B4(void); +extern void ov29_022DD7AC(void); +extern void ov29_022DDE00(s32 param_1); +extern void ov29_022DE15C(void); +extern void ov29_022DE4FC(void); +extern void ov29_022DE904(void); +extern void ov29_022DE930(void); +extern void ov29_022DEA34(void); +extern void ov29_022E0434(void); +extern void ov29_022E081C(void); +extern void ov29_022E0DFC(void); +extern void ov29_022E0E44(void); +extern void ov29_022E0F6C(void); +extern void ov29_022E12F8(void); +extern void ov29_022E1304(void); +extern void ov29_022E1550(void); +extern void ov29_022E15C8(void); +extern void ov29_022E1604(void); +extern void ov29_022E1640(void); +extern void ov29_022E2B68(bool8 param_1); +extern void ov29_022E2DFC(struct entity *entity); +extern void ov29_022E3A58(bool8 param_1); +extern void ov29_022E6E40(void); +extern void ov29_022E6F94(void); +extern void ov29_022E8708(void); +extern void ov29_022E8BFC(bool8 value); +extern void ov29_022E9F18(void); +extern void ov29_022EAD68(void); +extern void ov29_022EAEAC(s32 param_1); +extern void ov29_022EAF48(u16 param_1, bool8 param_2); +extern bool8 ov29_022ECF78(void); +extern void ov29_022ECFB8(struct unk_dungeon_init *summary); +extern void ov29_022ED030(void); +extern void ov29_022ED0B0(void); +extern void ov29_022EF738(void); +extern void ov29_022EF8A4(void); +extern void ov29_022EF9B8(void); +extern void ov29_022F6E40(void); +extern void ov29_022F6EF4(void); +extern void ov29_022F7104(void); +extern bool8 ov29_022F7910(struct ground_monster *guest); +extern void ov29_022F7BF4(struct ground_monster *guest); +extern void ov29_022F7E34(void); +extern void ov29_022F7EAC(void); +extern void ov29_022FA2F0(bool8 param_1, bool8 param_2, bool8 param_3); +extern void ov29_022FA418(void); +extern void ov29_022FA524(void); +extern void ov29_022FA648(void); +extern void ov29_022FA750(void); +extern void ov29_022FBB1C(void); +extern void ov29_022FC9C0(void); +extern void ov29_022FCD04(void); +extern void ov29_022FDFA4(void); +extern void ov29_022FE2E4(void); +extern void ov29_022FE4A8(void); +extern void ov29_0231B39C(void *param_1); +extern void ov29_0231B460(void); +extern void ov29_02334D58(void); +extern void ov29_02334DA8(enum weather_id weather); +extern void ov29_02335044(bool8 value); +extern void ov29_023359F8(bool8 value); +extern void ov29_023362EC(void); +extern void ov29_02336460(void); +extern void ov29_023365B8(void); +extern void ov29_023365E8(void); +extern void ov29_0233665C(void); +extern void ov29_023369F8(void); +extern void ov29_0233781C(void); +extern void ov29_0233785C(void); +extern void ov29_0233873C(void); +extern void ov29_023389C4(s16 tileset); +extern void ov29_02338A4C(enum weather_id weather); +extern void ov29_02338D30(void); +extern void ov29_02338F10(void); +extern void ov29_02338F38(bool8 value); +extern void ov29_02338F48(bool8 value); +extern void ov29_02338F68(void); +extern void ov29_02338FC8(void); +extern void ov29_0233904C(bool8 quick_saved); +extern void ov29_02339F88(bool8 value); +extern void ov29_02339FD0(bool8 value); +extern void ov29_0233A0E8(s32 param_1, s32 param_2); +extern void ov29_0233A15C(bool8 value); +extern void ov29_0233A1BC(s32 param_1); +extern void ov29_0233A248(s32 param_1); +extern void ov29_02344C4C(void); +extern bool8 ov29_02345D84(struct entity *unused, struct entity *item_entity, void *info, const struct position *offset); +extern void ov29_023469E0(u32 param_1); +extern void ov29_02346A64(void); +extern void ov29_02346DA4(void); +extern void ov29_02346E48(void); +extern void ov29_023480FC(void); +extern void ov29_02348850(void); +extern void ov29_02348894(void); +extern void ov29_023488C8(void); +extern void ov29_02348918(void); +extern void ov29_02348994(void); +extern bool8 ov29_02349C84(void); +extern void ov29_0234B4CC(bool8 val); +extern void ov29_0234C584(s32 screen); +extern void ov29_0234C5EC(s32 screen); +extern void ov29_0234C654(s32); +extern void ov29_0234CA84(void); +extern void ov29_0234CB34(void); +extern void ov29_0234CB54(void); +extern s32 sub_02001808(void); +extern void sub_02009194(s32, s32); +extern void sub_020091B0(s32, s32); +extern u16 sub_02017B00(void); +extern bool8 sub_0204F1B4(s8 *result); +extern void *sub_02051DFC(u32, u32); +extern void *sub_02051ED4(u32); +extern void sub_02057E90(void); +extern void sub_02057EF4(void); +extern void sub_02058644(s32 dungeon_id); +extern void ov29_022DEBBC(u8); + +extern const u8 ov29_023510C8[]; +// Declared as volatile to make matching easier +extern struct dungeon *volatile DUNGEON_PTR[]; +extern struct entity *LEADER_PTR; +extern u8 ov29_02353563; +#define NUM_DIRECTIONS 8 +extern const struct position DIRECTIONS_XY[NUM_DIRECTIONS]; +extern const s16 DEOXYS_FORMS[4]; + +#ifdef JAPAN +#define RUN_DUNGEON_DATA_OFFSET -0x2EF +#else +#define RUN_DUNGEON_DATA_OFFSET 0 +#endif + +s32 RunDungeon(struct dungeon_init *dungeon_init_data, struct dungeon *dungeon) +{ + // Use a struct here because it would not match otherwise + struct { u8 value; } some_flag_storage; + u8 init_field_0x4; + u8 some_bool; + bool8 guest_init_failure_flag; + s8 field_0xE; + bool8 show_rescues_left; + bool8 has_guest_pokemon; + bool8 send_help_item; + + some_flag_storage.value = 0; + guest_init_failure_flag = some_flag_storage.value; + init_field_0x4 = dungeon_init_data->field_0x4; + field_0xE = dungeon_init_data->field_0xE; + show_rescues_left = dungeon_init_data->show_rescues_left; + has_guest_pokemon = dungeon_init_data->has_guest_pokemon; + send_help_item = dungeon_init_data->send_help_item; + + some_bool = (init_field_0x4 == 0); + + if (field_0xE == 1) + { + // A function that uses the screen as inputs + // Could be something like fading dungeon from white or the other way around? + ov29_0234C5EC(0); + // This flag determines which StartFadeDungeonWrapper mode to use. + // otherwise skips this and then calls the StartFadeDungeonWrapper normally for input 1 + some_flag_storage.value = 1; + } + else + { + // Again a function that has to do with one of the DS screens as input, this time with opposite brightness + // Could be something like fading dungeon from black + ov29_0234C584(0); + } + + ov29_0234C584(1); // Now the same fading dungeon function with screen 1 + ov29_022DDE00(2); + // The string in ov29_023510C8 is "DG_VRAM_SPRITE_NAME:%d\n" so this would be "DG_VRAM_SPRITE_NAME:992\n" + Debug_Print0(ov29_023510C8, 0x3E0); + + DUNGEON_PTR[0] = dungeon; + + dungeon->id = (enum dungeon_id)dungeon_init_data->id; + dungeon->floor = dungeon_init_data->floor; // floor = 0x749 of dungeon and 0x1 of dungeon_init + + // This could mean that the field_0x4 signals some missing initialization + if (init_field_0x4 == 0) + { + DUNGEON_PTR[0]->dungeon_objective = (enum dungeon_objective)dungeon_init_data->dungeon_objective; + dungeon_location_seed init_rescue_location_seed = dungeon_init_data->rescue_location_seed; + DUNGEON_PTR[0]->rescue_location_seed = init_rescue_location_seed; + + s32 turn_limit = GetTurnLimit((enum dungeon_id)dungeon_init_data->id); + + DUNGEON_PTR[0]->wind_turns = turn_limit; + DUNGEON_PTR[0]->turn_limit_warning_tracker = 0; + + s8 max_rescue_attempts = GetMaxRescueAttempts((enum dungeon_id)dungeon_init_data->id); + DUNGEON_PTR[0]->rescue_attempts_left = max_rescue_attempts; + + DUNGEON_PTR[0]->dungeon_game_version_id = dungeon_init_data->dungeon_game_version_id; + DUNGEON_PTR[0]->nonstory_flag = dungeon_init_data->nonstory_flag; + DUNGEON_PTR[0]->field_0x75a = dungeon_init_data->show_potential_recruits; + DUNGEON_PTR[0]->recruiting_enabled = dungeon_init_data->recruiting_enabled; + DUNGEON_PTR[0]->bag_enabled = dungeon_init_data->show_team_name; + DUNGEON_PTR[0]->send_home_disabled = dungeon_init_data->send_home_disabled; + DUNGEON_PTR[0]->hidden_land_flag = dungeon_init_data->hidden_land_flag; + DUNGEON_PTR[0]->skip_faint_animation_flag = dungeon_init_data->skip_faint_animation_flag; + DUNGEON_PTR[0]->dungeon_idx = dungeon_init_data->dungeon_idx; + + if (dungeon_init_data->force_disable_recruiting) + { + DUNGEON_PTR[0]->recruiting_enabled = FALSE; + } + } + + DUNGEON_PTR[0]->leader_standing_in_kecleon_shop = FALSE; + DUNGEON_PTR[0]->standing_in_kecleon_shop = FALSE; + DUNGEON_PTR[0]->bag_enabled = TRUE; + + ov29_022DE904(); + ov29_022F6E40(); + ov29_022ED030(); + LoadWeather3DFiles(); + ov29_02338F10(); + u16 music_id = sub_02017B00(); + ov29_022EAF48(music_id, init_field_0x4); + AllocTopScreenStatus(); + ov29_022E6F94(); + ov29_022E1640(); // some entity initialization + ov29_023362EC(); // initialization of dungeon tile grid map state + OpenFixedBin(); + ov29_022E9F18(); + ov29_02338F68(); // load minimap resources + ov29_02338F38(FALSE); + ov29_022E2B68(TRUE); + InitAlertBoxInfo(); + ov29_0234BB10(); + DungeonRngUnsetSecondary(); + DUNGEON_PTR[0]->prng_preseed = GetDungeonRngPreseed(); + ov10_022BDAB0(0x200, 0x340, 0); + ov10_022BDB54(0); + void *unk0 = sub_02051ED4(0); + void *unk1 = sub_02051DFC(0, 0); + + void *unk2 = GetBgRegionArea(0, 0, 0); + ov10_022BDB60(unk2, unk1, unk0, 0); + + void *unk3 = sub_02051ED4(1); + void *unk4 = sub_02051DFC(0, 1); + + void *unk5 = GetBgRegionArea(0, 0, 1); + ov10_022BDB60(unk5, unk4, unk3, 1); + + // Now a bunch of function calls, probably some graphics initialization + ov10_022BDB80(0xb000, 0xb); + ov10_022BDBA4(0x2000, 0xa); + ov29_022E0F6C(); + ov29_022E8104(); + ov29_022E7F7C(); + ov29_022E1304(); + ov29_022E6E40(); + ov29_022FE4A8(); + ov29_023480FC(); + ov29_022DDE00(2); + + if (dungeon_init_data->field_0xE != 1) + { + ov29_022DEADC(); + } + + if (init_field_0x4 != 0) + { + ov29_0234CB34(); + ov29_0234CB54(); + ov29_023365E8(); +#ifndef JAPAN + ov29_02348850(); +#endif + } + + if (show_rescues_left) + { + ov29_022E0434(); // Probably show message how many rescues left + } + + if (init_field_0x4 == 0) + { + // The field_0x4 seems to only be set in floors that aren't naturally dark + dungeon->display_data.luminous = TRUE; + dungeon->display_data.natural_lighting = TRUE; + + ov29_0231B39C(&DUNGEON_PTR[0]->field_0x7d0); + + // We have to use this ugly cast to signed integer + // -> enum probably contained negative values or was signed byte + if (*(s8 *)&dungeon->dungeon_objective == OBJECTIVE_RESCUE) + { + // Id gets overwritten here which triggers some decisions + dungeon->id = dungeon_init_data->rescue_location_seed.dungeon_id; + dungeon->floor = 1; + } + + ChangeGiratinaFormIfSkyDungeon(dungeon->id); + ov29_022E081C(); + + if (*(s8 *)&dungeon->dungeon_objective == OBJECTIVE_RESCUE) + { + dungeon->rescue_prng_preseed_23_bit = dungeon_init_data->rescue_location_seed.prng_preseed_23_bit; + } + else + { + // Combine the lower half of the persistent Mt RNG state and a random 16 bit number as seed + // to initiate the new Mt state + u32 mission_mt_low = ReadMissionMtStateLower(); + u32 seed = Rand16Bit() | (mission_mt_low << 16); + MtInit(seed); + // Use the initialized Mt to generate the prng preseed for rescue + u32 value = MtNext(); + value &= 0x00FFFFFF; // We only need 23 bit (24 bit result here) + dungeon->rescue_prng_preseed_23_bit = value; + WriteMissionMtState(value); + } + + SetDungeonRngPreseed23Bit(dungeon->rescue_prng_preseed_23_bit); + } + else + { + SetDungeonRngPreseed(dungeon->prng_preseed); + } + + if (show_rescues_left) + { + SetMessageLogPreprocessorArgsNumberVal(0, dungeon->rescue_attempts_left); + if (dungeon->rescue_attempts_left != 0) + { + DisplayMessage2(0, 0xB6B + RUN_DUNGEON_DATA_OFFSET, 1); + } + else + { + DisplayMessage2(0, 0xB6C + RUN_DUNGEON_DATA_OFFSET, 1); + } + } + + if (has_guest_pokemon) + { + struct ground_monster *guest_pokemon_ptr = &dungeon_init_data->guest_pokemon[0]; + if (guest_pokemon_ptr->joined_at == 0xfa) + { + if (IsLevelResetDungeon(dungeon->id)) + { + SetBaseStatsMovesGroundMonster(guest_pokemon_ptr); + } + + if (ov29_022F7910(guest_pokemon_ptr) == FALSE) + { + guest_init_failure_flag = 1; + } + + } + else + { + for (s16 i = 0; i < 2; ++i) + { + if (IsLevelResetDungeon(dungeon->id)) + { + SetBaseStatsMovesGroundMonster(&dungeon_init_data->guest_pokemon[i]); + } + + ov29_022F7BF4(&dungeon_init_data->guest_pokemon[i]); + } + } + + if (init_field_0x4 != 0) + { + ov29_022FC9C0(); + } + } + + s8 loc_10; + + if (init_field_0x4 == 0 && + *(s8 *)&dungeon->dungeon_objective == OBJECTIVE_RESCUE && // OBJECTIVE_RESCUE = 2 + sub_0204F1B4(&loc_10)) + { + s8 value = *(s8 *)(sub_0205B77C(loc_10) + 0xAC); + + if (value != 0) + { + SetMessageLogPreprocessorArgsNumberVal(0, value + 1); + DisplayMessage2(0, 0xB6D + RUN_DUNGEON_DATA_OFFSET, 1); + } + else + { + DisplayMessage2(0, 0xB6E + RUN_DUNGEON_DATA_OFFSET, 1); + } + } + + if (dungeon_init_data->field_0xE != 1) + { + ov29_022DEB40(); // Again some dungeon fading + } + + // Use a loop for each floor, we assume the start here since a jump is used to this position + // later. The loop encompasses a large block and only finishes at a common end jump position + while (TRUE) + { + ov29_022DDE00(2); + ov10_022BDBB0(0); + ov29_022F6EF4(); + ov29_022E8104(); + ov29_022E7F7C(); + InitMessageLogPreprocessorArgs(); + ov29_0234BB2C(); + ov29_022DE4FC(); + + if (init_field_0x4 == 0) + { + ov29_022DEA34(); + ov29_022E1640(); + } + + LEADER_PTR = NULL; + enum hidden_stairs_type stairs_type = GetHiddenFloorField(); + SetBothScreensWindowColorToDefault(); + + DUNGEON_PTR[0]->field_0x4 = 0; + DUNGEON_PTR[0]->spawn_entries_copied = FALSE; + + if (init_field_0x4 == 0) + { + DUNGEON_PTR[0]->next_spawn_genid = 10; + if (GetHiddenFloorField() == HIDDEN_STAIRS_NONE) + { + u32 rng_seed = GenerateDungeonRngSeed(); + u32 rng_preseed = GetDungeonRngPreseed(); + + DUNGEON_PTR[0]->prng_preseed = rng_preseed; + DUNGEON_PTR[0]->prng_seed = rng_seed; + InitDungeonRng(DUNGEON_PTR[0]->prng_seed); + } + } + + if (init_field_0x4 == 0) + { + DUNGEON_PTR[0]->decoy_is_active = FALSE; + u32 rand_index = DungeonRandInt(4); + DUNGEON_PTR[0]->deoxys_floor_id = (enum monster_id)DEOXYS_FORMS[rand_index]; + DUNGEON_PTR[0]->mew_cannot_spawn = FALSE; + DUNGEON_PTR[0]->field_0x78a = 0; + } + + bool8 hidden_stairs_exist = stairs_type != HIDDEN_STAIRS_NONE; + + LoadMappaFileAttributes(init_field_0x4, hidden_stairs_exist, ov29_022DEBBC); + ov29_0234B4CC(0); + ov29_0234BB38(); + + if (init_field_0x4 == 0) + { + ov29_02334DA8(WEATHER_CLEAR); + } + + ov29_023389C4(DUNGEON_PTR[0]->gen_info.tileset_id); + + ov29_02338A4C(DUNGEON_PTR[0]->weather.weather); + ov29_022E8708(); + ov29_022DD5B4(); + ov29_023369F8(); + CopySpawnEntriesOnce(); + LoadMonsterSprites(); + + if (init_field_0x4 == 0) + { + ov29_0231B460(); + ov29_022F7104(); + } + else + { + LoadActiveMonsterSprites(); + ov29_022FBB1C(); + } + + ov29_022FE2E4(); + InitEnemySpawnStats(); + + if (init_field_0x4 == 0) + { + ov29_022EAD68(); + ov29_022EF738(); + } + + ov29_023365E8(); + ov29_022E1550(); + ov29_02338F38(0); + UnkMapRelatedFunc(4, 0); + ov29_0234B1A4(0); + ov29_022E2B68(init_field_0x4); + + if (IsRoomIlluminated(DUNGEON_PTR[0]->gen_info.fixed_room_id)) + { + + dungeon->display_data.luminous = TRUE; + dungeon->display_data.natural_lighting = TRUE; + } + + IsSecretBazaarVeneer(); // This result is never used?? + + if (IsBossFight(DUNGEON_PTR[0]->gen_info.fixed_room_id) == FALSE) + { + DisplayFloorCard(0x3c); + } + + ov29_022E12F8(); + + if (init_field_0x4 == 0) + { + ResetVictoryCounter(); + GenerateFloor(); + s32 turn_limit = GetTurnLimit(dungeon->id); + dungeon->wind_turns = turn_limit; + dungeon->turn_limit_warning_tracker = 0; + } + + ov29_0233785C(); + DetermineAllTilesWalkableNeighbors(); + ov29_02336460(); + + if (init_field_0x4 == 0) + { + SpawnTeam(some_bool); + some_bool = FALSE; + SpawnShopkeepers(); + SpawnInitialMonsters(); + ResetGravity(); + } + else + { + + if (DUNGEON_PTR[0]->display_data.hallucinating && GetLeader() != NULL) + { + DUNGEON_PTR[0]->unk_camera_tracker = TRUE; + } + ov29_022FCD04(); + } + + ov29_0231AFB4(); + dungeon->snatch_monster = NULL; + dungeon->snatch_status_unique_id = 0; + dungeon->illuminate_spawn_entity = NULL; + dungeon->illuminate_spawn_genid = 0; + + if (init_field_0x4 == 0) + { + SpawnTraps(); + ov29_0233873C(); + ov29_02344C4C(); + TrySpawnDoughSeedPoke(); + dungeon->unk_poke_kecleon_shop_tracker = dungeon->poke_buy_kecleon_shop; + dungeon->poke_sold_kecleon_shop = 0; + ov29_02343980(); + ov29_0233781C(); + ClearHiddenStairs(); + } + else + { + ReevaluateSnatchMonster(); + } + + ov29_022F7EAC(); + ov29_0233665C(); + UpdateTrapsVisibility(); + + if (init_field_0x4 == 0) + { + ov29_022FA2F0(1, 0, 0); + + } + else + { + DetermineAllMonsterShadow(); + ov29_022FA524(); + } + + ov29_022E3A58(1); + + if (init_field_0x4 == 0) + { + ov29_022EF8A4(); + ov29_022FA418(); + } + + ov29_02353563 = 1; + + if (init_field_0x4 != 0) + { + ov29_023350FC(); + ov29_022FA750(); + } + + CountItemsOnFloorForAcuteSniffer(); + ov29_0233904C(init_field_0x4); + UnkMapRelatedFunc(1, 0); + ov29_0233A15C(1); + + if (GetTopScreenOption() == 3) + { + ov29_0233A1BC(1); + UpdateMinimap(); + } + + ov29_022E34B0(0); + ov29_022EA3F8(0, 0); + ov29_022E0DFC(); + + if (some_flag_storage.value != 0) + { + StartFadeDungeonWrapper(4, 0x1000, 0); + some_flag_storage.value = 0; + } + else + { + StartFadeDungeonWrapper(1, 0x1000, 0); + } + + StartFadeDungeonWrapper(1, 0x1000, 1); + WaitUntilFadeIsFinished(0); + ov29_022E0E44(); + ov29_022E8BFC(1); + ov29_022EA418(1); + ov29_02339FD0(0); + ov29_0233A0E8(0, 0); + ov29_02338F48(0); + UnkMapRelatedFunc(0, 0); + + // Probably turn switch of some sorts + dungeon->current_active_entity = NULL; + dungeon->leader_running = FALSE; + dungeon->field_0x78c = 0; + dungeon->field_0x1c = 0x63; // 0x64 is the max value, possibly indicating that the leader is acting. + dungeon->field_0x4 = 1; + LEADER_PTR = NULL; + + if (guest_init_failure_flag != 0) + { + DUNGEON_PTR[0]->end_floor_no_death_check_flag = TRUE; + SetForcedLossReason(FORCED_LOSS_CLIENT_CANT_JOIN); // FORCED_LOSS_CLIENT_CANT_JOIN = 4 + SetMessageLogPreprocessorArgsFlagVal(0, dungeon_init_data->guest_pokemon[0].id); + DisplayMessage2(0, 0xB73 + RUN_DUNGEON_DATA_OFFSET, 1); + } + DUNGEON_PTR[0]->field_0x9 = 0; + + if (init_field_0x4 != 0) + { + TryActivateArtificialWeatherAbilities(); + HandleShopTransaction(1); + } + else + { + DisplayFloorTip(); + ov29_022EF9B8(); + struct dungeon *current_dungeon = DUNGEON_PTR[0]; + if (current_dungeon->end_floor_no_death_check_flag == FALSE && current_dungeon->end_floor_flag == FALSE) + { + ov29_022E2DFC(GetLeader()); + UpdateMinimap(); + } + else + { + current_dungeon->field_0x9 = TRUE; + } + + if (DUNGEON_PTR[0]->field_0x9 == FALSE) + { + ov29_02334D58(); + if (GetApparentWeather(0) != WEATHER_CLEAR) + { + ov29_02335044(1); + } + } + + TryActivateNewFloorHpRestoration(1); + TryActivateNewFloorPpRestoration(0); + TryActivateIqBooster(); + TryActivateAcuteSniffer(0); + TryActivateSlowStart(); + ov29_02349C84(); + + if (DUNGEON_PTR[0]->id == DUNGEON_SPRING_CAVE_PIT) + { + TryInflictBurnStatusWholeTeam(); + } + } + + struct entity *leader; + if (send_help_item && (leader = GetLeader()) != NULL) + { + u8 rand_int = DungeonRandInt(8); + u8 direction = rand_int & 7; + + struct position spawn_pos = { + leader->pos.x + DIRECTIONS_XY[direction].x, + leader->pos.y + DIRECTIONS_XY[direction].y + }; + + struct entity help_item; + + help_item.field_0x24 = 0; + help_item.transparent = 0; + help_item.info = &dungeon_init_data->help_item; + help_item.type = ENTITY_ITEM; + help_item.is_visible = 1; + help_item.pos = spawn_pos; + + // Now onto the pixel positions + u32 new_entity_pixel_posx = (spawn_pos.x * 24 + 4) << 8; + u32 new_entity_pixel_posy = (spawn_pos.y * 24 + 4) << 8; + + SetEntityPixelPosXY(&help_item, new_entity_pixel_posx, new_entity_pixel_posy); + help_item.spawn_genid = 0; + ov29_02345D84(leader, &help_item, &dungeon_init_data->help_item, NULL); + } + + ov29_022EA418(0); + ov29_02338F48(1); + ov29_02339F88(1); + UpdateMinimap(); + + if (init_field_0x4 == 0) + { + TryActivateStairSensor(0); + } + + send_help_item = 0; + + if (init_field_0x4 == 0) + { + ov29_022E5F20(); + ov29_02305814(GetLeader(), dungeon->gen_info.force_create_monster_house); + TryActivateWeather(1, 0); + } + else + { + init_field_0x4 = 0; + } + + #ifdef JAPAN + ov10_022BFE6C(0x14000); + #else + ov10_022BFE6C(0x10c00); + #endif + + sub_02001808(); + + if (DUNGEON_PTR[0]->field_0x9 == 0) + { + bool8 first_turn = 1; + dungeon->floor_loop_status = FLOOR_LOOP_CONTINUE; + // Set to 1 when loss, so FALSE means not yet dead + dungeon->display_data.unk_fade_to_black_tracker = FALSE; + SetMinimapDataE447(1); + + do + { + RunFractionalTurn(first_turn); + first_turn = 0; + } + while (IsFloorOver() == FALSE); + + } + + ov29_0234B010(0); + ov29_0234B1A4(0); + ov29_022E8BFC(0); + + if (EntityIsValid__022E0354(GetLeader())) + { + EnemyEvolution(GetLeader()); + } + + struct dungeon *current_dungeon = DUNGEON_PTR[0]; + + if (current_dungeon->floor_loop_status != FLOOR_LOOP_LEADER_FAINTED && TryForcedLoss(1)) + { + current_dungeon = DUNGEON_PTR[0]; + current_dungeon->floor_loop_status = FLOOR_LOOP_LEADER_FAINTED; // Update the flag when leader faints + } + + current_dungeon = DUNGEON_PTR[0]; + + if ((current_dungeon->floor_loop_status == FLOOR_LOOP_LEADER_FAINTED || current_dungeon->successful_exit_tracker != 0) + && + (current_dungeon->field_0xa == 0 && current_dungeon->skip_faint_animation_flag == FALSE)) + { + ov29_022FA648(); // Maybe to play the faint animation after defeat? + } + + if (EntityIsValid__022E0354(GetLeader())) + { + WaitUntilAlertBoxTextIsLoaded(0x4f); + WaitUntilAlertBoxPauseIsOver(0x4f); + } + + ov29_02338F38(0); + UnkMapRelatedFunc(1, 0); + SetMinimapDataE447(0); + + // This is documented to only be set to 1 when losing in a dungeon, why is it set here? + DUNGEON_PTR[0]->display_data.unk_fade_to_black_tracker = TRUE; + + ov29_022EA370(4, 0x4f); + if (ov29_022E9FC0() != 0) + { + FadeToBlack(); + } + + sub_020091B0(2, 0); + sub_020091B0(3, 0); + + if ((GetForcedLossReason() == FORCED_LOSS_CLIENT_FAINTED || + GetForcedLossReason() == FORCED_LOSS_ESCORT_FAINTED) && + DUNGEON_PTR[0]->field_0xa != 0) + { + struct entity *leader = GetLeader(); + ov29_0233A248(0); + ov29_023359F8(1); + ov29_0234C654(0x20); + sub_020091B0(0, 0); + sub_020091B0(1, 0); + sub_02009194(2, 0); + sub_02009194(3, 0); + sub_02009194(4, 0); + StartFadeDungeonWrapper(1, 0x4000, 0); + WaitUntilFadeIsFinished(0); + + #ifdef JAPAN + DisplayMessage(0, 0x880, 1); + #else + DisplayMessage(0, 0xB6F, 1); + #endif + + StartFadeDungeonWrapper(2, 0x4000, 0); + WaitUntilFadeIsFinished(0); + ov29_0234C654(1); + ov29_023359F8(0); + sub_020091B0(0, 0); + sub_020091B0(1, 0); + sub_020091B0(2, 0); + sub_020091B0(3, 0); + sub_020091B0(4, 0); + DUNGEON_PTR[0]->field_0xa = 0; + + if (GetForcedLossReason() == FORCED_LOSS_ESCORT_FAINTED) + { + CreateMonsterSummaryFromEntityOuter(0x266, leader, leader, DUNGEON_PTR[0]->unk_fainted_monster_name); + } + else + { + CreateMonsterSummaryFromEntityOuter(0x261, leader, leader, NULL); + } + } + + UpdateShouldBoostKecleonShopSpawnChance(); + UpdateShouldBoostHiddenStairsSpawnChance(); + DeleteAllMonsterSpriteFiles(); + ov29_023365B8(); + ov29_022DD7AC(); + + ov29_02353563 = 0; + + struct dungeon *dungeon_loc = DUNGEON_PTR[0]; + if (dungeon_loc->quicksave_flag) + { + ov29_0234CA84(); + dungeon_init_data->field_0xB0 = 3; + dungeon_loc = DUNGEON_PTR[0]; + dungeon_init_data->field_0xB4 = dungeon_loc->id; + dungeon_init_data->field_0xB5 = dungeon_loc->floor; + + break; + + } + + if (dungeon_loc->field_0xa != 0) + { + ov29_0234CA84(); + } + + ov29_022FDFA4(); + + if (DUNGEON_PTR[0]->field_0xa == 0) + { + ov29_023469E0(2); + } + + dungeon_loc = DUNGEON_PTR[0]; + if (dungeon_loc->floor_loop_status == FLOOR_LOOP_LEADER_FAINTED) + { + if (dungeon_loc->thief_alert) + { + ov29_02346A64(); + } + } + else + { + bool8 handled = FALSE; + u32 successful_exit_tracker = dungeon_loc->successful_exit_tracker; + + // Documented to be when using escape orb + if (successful_exit_tracker == 1) + { + CreateMonsterSummaryFromEntityOuter(0x279, NULL, GetLeader(), NULL); + handled = TRUE; + } + // Documented to be when completing a mission + else if (successful_exit_tracker == 2) + { + CreateMonsterSummaryFromEntityOuter(0x27c, NULL, GetLeader(), NULL); + if (DUNGEON_PTR[0]->thief_alert) + { + IncrementNbSteals(); + } + handled = TRUE; + } + else if (successful_exit_tracker == 3) + { + CreateMonsterSummaryFromEntityOuter(0x27d, NULL, GetLeader(), NULL); + if (DUNGEON_PTR[0]->thief_alert) + { + IncrementNbSteals(); + } + handled = TRUE; + } + else if (successful_exit_tracker == 4) + { + CreateMonsterSummaryFromEntityOuter(0x27a, NULL, GetLeader(), NULL); + handled = TRUE; + } + else if (successful_exit_tracker == 5) + { + handled = TRUE; + } + + if (handled == FALSE) + { + if ((s8)DUNGEON_PTR[0]->dungeon_objective == OBJECTIVE_RESCUE && // 2 = OBJECTIVE_RESCUE + GetFloorType() == 2 && + DUNGEON_PTR[0]->floor_loop_status == FLOOR_LOOP_NEXT_FLOOR) + { + CreateMonsterSummaryFromEntityOuter(0x27b, NULL, GetLeader(), NULL); + if (DUNGEON_PTR[0]->thief_alert) + { + IncrementNbSteals(); + } + } + else + { + if (DUNGEON_PTR[0]->thief_alert) + { + IncrementNbSteals(); + } + + struct dungeon *dungeon_loc = DUNGEON_PTR[0]; + if ((s8)dungeon_loc->dungeon_objective == OBJECTIVE_UNK_GAME_MODE_5 && + (u32)GetMaxReachedFloor(dungeon_loc->id) <= dungeon_loc->floor) + { + CreateMonsterSummaryFromEntityOuter(0x27a, NULL, GetLeader(), NULL); + } + else + { struct dungeon *current_dungeon = DUNGEON_PTR[0]; // Needed for compilation + if (current_dungeon->floor > (u32)GetMaxReachedFloor(dungeon_loc->id)) + { + current_dungeon = DUNGEON_PTR[0]; + SetMaxReachedFloor(current_dungeon->id, current_dungeon->floor); + } + + current_dungeon = DUNGEON_PTR[0]; + if (current_dungeon->floor + 1 >= current_dungeon->n_floors_plus_one) + { + CreateMonsterSummaryFromEntityOuter(0x27a, NULL, GetLeader(), NULL); + } + else + { + if (GetHiddenFloorField() == HIDDEN_STAIRS_NONE) // HIDDEN_STAIRS_NONE = 0 + { + struct dungeon *current_dungeon = DUNGEON_PTR[0]; + current_dungeon->floor = current_dungeon->floor + 1; + } + + continue; + } + } + } + } + + } + + ov29_02353563 = 0; + + if (DUNGEON_PTR[0]->field_0xa == 0) + { + ov29_022ECFB8(&dungeon_init_data->field_0xC0); + DUNGEON_PTR[0]->thief_alert_event = FALSE; + SetUnkMusicFlag(0); + DUNGEON_PTR[0]->monster_house_triggered_event = FALSE; + DUNGEON_PTR[0]->field_0x796 = 0x3e7; + DUNGEON_PTR[0]->standing_in_kecleon_shop = FALSE; + } + + if (dungeon_init_data == NULL) + { + break; + } + + if (IsDungeonEndReasonFailure()) + { + if (DUNGEON_PTR[0]->field_0xa != 0) + { + dungeon_init_data->field_0xB0 = -2; + MemZero((u8 *)&dungeon_init_data->result_location_seed, + sizeof(dungeon_init_data->result_location_seed)); + current_dungeon = DUNGEON_PTR[0]; + dungeon_init_data->field_0xB4 = current_dungeon->id; // Similar to dungeon init? + dungeon_init_data->field_0xB5 = current_dungeon->floor; + current_dungeon = DUNGEON_PTR[0]; + dungeon_init_data->result_location_seed.dungeon_id = current_dungeon->id; + dungeon_init_data->result_location_seed.floor = current_dungeon->floor; + dungeon_init_data->result_location_seed.prng_preseed_23_bit = DUNGEON_PTR[0]->rescue_prng_preseed_23_bit; + + break; + } + else + { + dungeon_init_data->field_0xB0 = -1; + ov29_023488C8(); + + break; + } + } + + if (ov29_022ECF78()) + { + s8 dungeon_objective = DUNGEON_PTR[0]->dungeon_objective; + + if (dungeon_objective == OBJECTIVE_RESCUE) + { + dungeon_init_data->field_0xB0 = 4; + + break; + } + + if (dungeon_objective == OBJECTIVE_UNK_GAME_MODE_5) + { + dungeon_init_data->field_0xB0 = 1; + + break; + } + + if (dungeon_objective == OBJECTIVE_STORY) + { + dungeon_init_data->field_0xB0 = 1; + ov29_02348894(); + + break; + } + + // default case + ov29_02348918(); + ov29_02348994(); + dungeon_init_data->field_0xB0 = 1; + ov29_02348894(); + + break; + } + else + { + dungeon_init_data->field_0xB0 = 2; + + if ((s8)DUNGEON_PTR[0]->dungeon_objective == OBJECTIVE_NORMAL) + { + ov29_02348994(); + } + + ov29_02348894(); + } + // This is just really ugly to avoid using gotos, but nothing makes much sense + // other than just terminating the while(TRUE) loop at almost every iteration + break; + } + + // The common exit point for the floor loop. + + SetBothScreensWindowColorToDefault(); + ov29_022EAEAC(0x14); + ov29_022DDE00(0x14); + ov29_022E15C8(); + ov29_022E1604(); + ov29_02338FC8(); + + if (dungeon_init_data != NULL) + { + if (dungeon_init_data->field_0xB0 != -2 && + dungeon_init_data->field_0xB0 != 3) + { + sub_02057E90(); + sub_02058644(-1); + } + + if (dungeon_init_data->field_0xB0 == 1 || + dungeon_init_data->field_0xB0 == 4 || + dungeon_init_data->field_0xB0 == 2) + { + ov29_02346DA4(); + RefillTeam(); + } + else if (dungeon_init_data->field_0xB0 == -1) + { + ov29_02346E48(); + ov29_022F7E34(); + sub_02057EF4(); + } + + if (dungeon_init_data->field_0xB0 == 1 || + dungeon_init_data->field_0xB0 == 4 || + dungeon_init_data->field_0xB0 == 2) + { + dungeon_init_data->field_0x1A8 = 1; + } + else + { + dungeon_init_data->field_0x1A8 = 0; + } + } + + ov10_022BDC0C(); + FreeTopScreenStatus(); + FreeAlertBoxInfo(); + ov29_0234BB20(); + ov29_02338D30(); + ov29_022ED0B0(); + ov29_022DE930(); + FreeLoadedAttackSpriteAndMore(); + + DUNGEON_PTR[0] = NULL; + ov29_022DE15C(); + CloseFixedBin(); + + return 1; +} bool8 EntityIsValid__022E0354(struct entity *entity) { diff --git a/src/overlay_29_022E9FC0.c b/src/overlay_29_022E9FC0.c index 02dcc368..c1c2fd79 100644 --- a/src/overlay_29_022E9FC0.c +++ b/src/overlay_29_022E9FC0.c @@ -236,7 +236,7 @@ void ov29_022EA3B4(s32 param_1) } while (DUNGEON_BUTTON_INPUT[0] & 0xF0); } -void ov29_022EA3F8(void) +void ov29_022EA3F8(s32 unused0, s32 unused1) { ov29_022DE638(0x100); } diff --git a/src/overlay_29_0234BA54.c b/src/overlay_29_0234BA54.c index e4568a3a..459dd854 100644 --- a/src/overlay_29_0234BA54.c +++ b/src/overlay_29_0234BA54.c @@ -11,9 +11,9 @@ extern void sub_0204833C(void); extern s32 sub_02048360(void); extern void sub_02048240(s32 a); extern void sub_02048150(s32 a); -extern void sub_02048134(s32 a); -extern void sub_020480CC(s32 a); -extern void sub_0204804C(s32 a); +extern void sub_02048134(void); +extern void sub_020480CC(void); +extern void sub_0204804C(void); extern void sub_02047FFC(s32 a); extern void InitPortraitParams(portrait_params *portrait); extern void AllowPortraitDefault(portrait_params *portrait, bool32 allow); @@ -62,19 +62,19 @@ void ov29_0234BB10(void) sub_02047FFC(0); } -void ov29_0234BB20(s32 a) +void ov29_0234BB20(void) { - sub_0204804C(a); + sub_0204804C(); } -void ov29_0234BB2C(s32 a) +void ov29_0234BB2C(void) { - sub_020480CC(a); + sub_020480CC(); } -void ov29_0234BB38(s32 a) +void ov29_0234BB38(void) { - sub_02048134(a); + sub_02048134(); } void ov29_0234BB44(s32 a) diff --git a/src/overlay_29_0234BBE8.c b/src/overlay_29_0234BBE8.c index cef4de2e..448e2761 100644 --- a/src/overlay_29_0234BBE8.c +++ b/src/overlay_29_0234BBE8.c @@ -3,6 +3,8 @@ #include "overlay_29_022DC61C.h" #include "overlay_29_0234CA68.h" #include "util.h" +#include "dg.h" +#include "overlay_29_022DEAB0.h" struct unk_ov29_023537DC { s32 v0; @@ -31,8 +33,6 @@ void sub_02051DD0(s32, s32); void sub_02051E60(s32, s32); void ov29_0234BEE0(s32); void ov29_0234BF04(s32); -s32 GetDungeonPtrMaster(); -void RunDungeon(void *, s32); s32 sub_0205BAB0(void *); void ov29_022DE418(); void sub_020091B0(s32, s32); @@ -54,6 +54,7 @@ void ov29_0234BBE8(void) s32 uVar4; s32 uVar5; s32 iVar6; + struct dungeon *dungeon; bool8 bVar1 = FALSE; struct unk_ov29_023537DC *iVar7 = ov29_023537D8.v4; ov29_022DC61C(); // mem init? @@ -106,8 +107,8 @@ void ov29_0234BBE8(void) ov29_0234BEE0(1); ov29_0234BF04(0); ov29_0234BF04(1); - uVar3 = GetDungeonPtrMaster(); - RunDungeon(&(ov29_023537D8.v4[1]), uVar3); + dungeon = GetDungeonPtrMaster(); + RunDungeon((struct dungeon_init *)&ov29_023537D8.v4[1], dungeon); bVar1 = TRUE; break; case 2: