decomp some dungeon weather stuff

This commit is contained in:
Seth Barberee 2022-04-03 17:52:19 -07:00
parent a1692a1aa0
commit 7289155f83
8 changed files with 152 additions and 319 deletions

View File

@ -5,86 +5,6 @@
.text
thumb_func_start sub_801DAC0
sub_801DAC0:
ldr r0, _0801DAD8
ldr r1, [r0]
ldrh r2, [r1, 0x1E]
ldrh r0, [r1, 0x1C]
adds r3, r0, 0
muls r3, r2
adds r0, r3, 0
ldrh r1, [r1, 0x18]
adds r0, r1
lsls r0, 16
asrs r0, 16
bx lr
.align 2, 0
_0801DAD8: .4byte gUnknown_203B258
thumb_func_end sub_801DAC0
thumb_func_start sub_801DADC
sub_801DADC:
push {r4,r5,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r5, _0801DB08
ldr r0, [r5]
movs r1, 0xE5
strh r1, [r0, 0x22]
bl sub_8013984
bl sub_801DB54
bl sub_801DBD4
cmp r4, 0
beq _0801DB02
ldr r0, [r5]
bl AddMenuCursorSprite
_0801DB02:
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_0801DB08: .4byte gUnknown_203B258
thumb_func_end sub_801DADC
thumb_func_start sub_801DB0C
sub_801DB0C:
push {r4,r5,lr}
ldr r4, _0801DB4C
ldr r2, [r4]
cmp r2, 0
beq _0801DB46
ldr r0, [r2, 0x34]
lsls r1, r0, 1
adds r1, r0
lsls r1, 3
adds r1, r2, r1
adds r1, 0x3C
ldr r0, _0801DB50
ldm r0!, {r2,r3,r5}
stm r1!, {r2,r3,r5}
ldm r0!, {r2,r3,r5}
stm r1!, {r2,r3,r5}
bl ResetUnusedInputStruct
ldr r0, [r4]
adds r0, 0x3C
movs r1, 0x1
movs r2, 0x1
bl sub_800641C
ldr r0, [r4]
bl MemoryFree
movs r0, 0
str r0, [r4]
_0801DB46:
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_0801DB4C: .4byte gUnknown_203B258
_0801DB50: .4byte gUnknown_80DBF70
thumb_func_end sub_801DB0C
thumb_func_start sub_801DB54
sub_801DB54:
push {r4,lr}

View File

@ -192,120 +192,4 @@ _08071380:
bx r1
thumb_func_end CanMoveForward
thumb_func_start IsAtJunction
IsAtJunction:
push {r4,r5,lr}
adds r4, r0, 0
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r5, r0, 24
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _080713E2
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _080713E0
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
bne _080713E0
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080713D2
movs r5, 0x2
b _080713E2
_080713D2:
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _080713E2
_080713E0:
movs r5, 0x3
_080713E2:
cmp r5, 0x3
bne _08071408
ldr r4, [r4, 0x70]
movs r0, 0x64
bl DungeonRandomCapped
movs r1, 0xFD
lsls r1, 1
adds r2, r4, r1
ldrh r1, [r2]
adds r1, r0
strh r1, [r2]
lsls r1, 16
asrs r1, 16
cmp r1, 0xC7
ble _08071458
movs r0, 0
strh r0, [r2]
b _08071468
_08071408:
ldr r1, _0807145C
ldr r0, _08071460
ldr r0, [r0]
ldr r2, _08071464
adds r0, r2
movs r2, 0
ldrsh r0, [r0, r2]
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
bne _08071432
cmp r5, 0x1
bne _08071432
adds r0, r4, 0
movs r1, 0x14
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071432
movs r5, 0
_08071432:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTile_1
adds r0, 0xA
adds r0, r5
ldrb r0, [r0]
cmp r0, 0x54
beq _08071468
cmp r0, 0x51
beq _08071468
cmp r0, 0x45
beq _08071468
cmp r0, 0x15
beq _08071468
cmp r0, 0x55
beq _08071468
_08071458:
movs r0, 0
b _0807146A
.align 2, 0
_0807145C: .4byte gDungeonWaterType
_08071460: .4byte gDungeonGlobalData
_08071464: .4byte 0x00003a0e
_08071468:
movs r0, 0x1
_0807146A:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end IsAtJunction
.align 2, 0

View File

@ -4,120 +4,6 @@
.syntax unified
.text
thumb_func_start sub_807E5AC
sub_807E5AC:
push {lr}
ldr r0, _0807E5DC
ldr r0, [r0]
ldr r1, _0807E5E0
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x8
bne _0807E5C6
movs r0, 0x8
bl DungeonRandomCapped
lsls r0, 24
lsrs r0, 24
_0807E5C6:
bl sub_807E5E4
bl TriggerWeatherAbilities
movs r0, 0
movs r1, 0x1
bl sub_807EAA0
pop {r0}
bx r0
.align 2, 0
_0807E5DC: .4byte gDungeonGlobalData
_0807E5E0: .4byte 0x0001c578
thumb_func_end sub_807E5AC
thumb_func_start sub_807E5E4
sub_807E5E4:
push {r4-r6,lr}
ldr r3, _0807E674
ldr r1, [r3]
ldr r2, _0807E678
adds r1, r2
movs r4, 0
strb r0, [r1]
ldr r0, [r3]
adds r2, r0, r2
ldrb r1, [r2]
ldr r2, _0807E67C
adds r0, r2
strb r1, [r0]
ldr r0, [r3]
ldr r1, _0807E680
adds r0, r1
strb r4, [r0]
movs r2, 0
adds r4, r3, 0
ldr r6, _0807E684
movs r1, 0
ldr r5, _0807E688
_0807E610:
ldr r0, [r4]
adds r0, r6
adds r0, r2
strb r1, [r0]
ldr r0, [r4]
adds r0, r5
adds r0, r2
strb r1, [r0]
adds r2, 0x1
cmp r2, 0x7
ble _0807E610
ldr r0, [r3]
ldr r2, _0807E68C
adds r0, r2
movs r2, 0
movs r1, 0x9
strb r1, [r0]
ldr r0, [r3]
ldr r1, _0807E690
adds r0, r1
strb r2, [r0]
ldr r0, [r3]
adds r1, 0x1
adds r0, r1
strb r2, [r0]
movs r6, 0xBE
lsls r6, 1
ldr r5, _0807E694
movs r4, 0xBF
lsls r4, 1
_0807E64C:
ldr r0, [r3]
lsls r1, r2, 2
adds r0, r1
adds r0, r6
strb r2, [r0]
ldr r0, [r3]
adds r0, r1
adds r0, r5
strb r2, [r0]
ldr r0, [r3]
adds r0, r1
adds r0, r4
strb r2, [r0]
adds r2, 0x1
cmp r2, 0xFF
ble _0807E64C
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_0807E674: .4byte gDungeonGlobalData
_0807E678: .4byte 0x0000e265
_0807E67C: .4byte 0x0000e264
_0807E680: .4byte 0x0000e279
_0807E684: .4byte 0x0000e267
_0807E688: .4byte 0x0000e26f
_0807E68C: .4byte 0x0000e266
_0807E690: .4byte 0x0000e277
_0807E694: .4byte 0x0000017d
thumb_func_end sub_807E5E4
thumb_func_start sub_807E698
sub_807E698:
@ -2886,4 +2772,4 @@ _0807FC78: .4byte 0x00013576
_0807FC7C: .4byte 0x00013579
thumb_func_end sub_807FC3C
.align 2, 0
.align 2, 0

View File

@ -217,7 +217,7 @@ struct DungeonEntityData
u8 fill1F5;
/* 0x1F6 */ bool8 notMoving;
u8 fill1F7[0x1FA - 0x1F7];
/* 0x1FA */ u8 mobileTurnTimer; // When a Pokémon can pass through walls in a hallway, this counts up to 200 before the Pokémon turns in a random direction.
/* 0x1FA */ s16 mobileTurnTimer; // When a Pokémon can pass through walls in a hallway, this counts up to 200 before the Pokémon turns in a random direction.
/* 0x1FC */ u16 expGainedInTurn; // Used to accumulate experience when multiple enemies are defeated in one turn.
/* 0x200 */ u32 statusSprites;
u32 unk204;

View File

@ -14,6 +14,13 @@
extern struct DungeonGlobalData *gDungeonGlobalData;
struct DungeonGlobalData_sub
{
u8 unk0;
u8 unk1;
u8 unk2;
};
struct DungeonGlobalData
{
u8 unk0;
@ -31,7 +38,9 @@ struct DungeonGlobalData
u8 unk16D;
u8 fill16E[0x179 - 0x16E];
/* 0x179 */ bool8 pokemonExposed; // True if a Pokémon on the floor has the Exposed status.
u8 fill17A[0x645 - 0x17A];
u8 fill17A[0x17C - 0x17A];
struct DungeonGlobalData_sub unk17C[0x100];
/* 0x57C */ u8 fill57C[0x645 - 0x57c];
/* 0x645 */ u8 floorNumber;
u8 fill646[0x65C - 0x646];
u8 unk65C;
@ -61,15 +70,15 @@ struct DungeonGlobalData
/* 0xE264 */ u8 weather; // Uses the weather constants in weather.h.
u8 unkE265;
/* 0xE266 */ u8 weatherDamageTimer; // Timer for applying sandstorm/hail damage periodically.
u8 fillE266[0xE26B - 0xE267];
u8 unkE267[0xE26B - 0xE267];
u8 unkE26B;
u8 weatherTurnsLeft;
u8 fillE26D[0xE270 - 0xE26D];
/* 0xE270 */ u8 startingWeather; // The weather at the start of the floor. If the weather changes, then expires, revert back to the starting weather.
u8 fillE271[0xE277 - 0xE271];
u8 fillE26D[0xE26F - 0xE26D];
/* 0xE26F */ u8 unkE26F[8]; // The weather at the start of the floor. If the weather changes, then expires, revert back to the starting weather.
/* 0xE277 */ u8 mudSportTurnsLeft;
/* 0xE278 */ u8 waterSportTurnsLeft;
u8 fillE279[0xE8C0 - 0xE279];
/* 0xE279 */ u8 unkE279;
u8 fillE27A[0xE8C0 - 0xE27A];
/* 0xE8C0 */ struct MapTile* mapTilePointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
u8 fill104C0[0x104C4 - 0x104C0];
/* 0x104C4 */ struct MapRoom roomData[MAX_ROOM_COUNT];
@ -101,6 +110,8 @@ struct DungeonGlobalData
/* 0x18210 */ bool8 displayCrossEyed; // Displays Substitute and flower sprites when the player has the Cross-Eyed status.
u8 fill18211[0x18217 - 0x18211];
u8 unk18217;
u8 fill18218[0x1C578 - 0x18218];
u8 unk1C578;
};
#endif

View File

@ -15,7 +15,13 @@ struct unkStruct_203B258
// size: 0xA0
u8 fill0[0x14];
u32 unk14;
u8 fill18[0x34 - 0x18];
u16 unk18;
u16 unk1A;
u16 unk1C;
u16 unk1E;
u16 unk20;
u16 unk22;
u8 unk24[0x34 - 0x24];
u32 unk34;
struct UnkTextStruct2 *unk38;
struct UnkTextStruct2 unk3C[4];
@ -24,6 +30,7 @@ struct unkStruct_203B258
extern struct unkStruct_203B258 *gUnknown_203B258;
extern struct UnkTextStruct2 gUnknown_80DBF88;
extern struct UnkTextStruct2 gUnknown_80DBF70;
extern void sub_8013818(void *, u32, u32, u32);
extern void sub_8013878(void *, s32);
@ -32,6 +39,8 @@ extern u32 GetKeyPress(void *);
extern void PlayMenuSoundEffect(u32);
extern void sub_801DB54();
extern void sub_801DBD4();
extern void sub_8013984(void *);
extern void AddMenuCursorSprite(void *);
extern u32 sub_801BF48(void);
extern void sub_801BF98(void);
@ -403,3 +412,33 @@ u32 sub_801DA78(void)
}
}
}
s16 sub_801DAC0(void)
{
return (gUnknown_203B258->unk1E * gUnknown_203B258->unk1C) + gUnknown_203B258->unk18;
}
void sub_801DADC(u32 r0)
{
u8 r0_u8;
r0_u8 = r0;
gUnknown_203B258->unk22 = 0xE5;
sub_8013984(gUnknown_203B258);
sub_801DB54();
sub_801DBD4();
if(r0_u8)
AddMenuCursorSprite(gUnknown_203B258);
}
void sub_801DB0C(void)
{
if(gUnknown_203B258 != NULL)
{
gUnknown_203B258->unk3C[gUnknown_203B258->unk34] = gUnknown_80DBF70;
ResetUnusedInputStruct();
sub_800641C(gUnknown_203B258->unk3C, 1, 1);
MemoryFree(gUnknown_203B258);
gUnknown_203B258 = NULL;
}
}

View File

@ -2,11 +2,63 @@
#include "dungeon_ai_targeting_1.h"
#include "constants/ability.h"
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "constants/tactic.h"
#include "dungeon_engine.h"
#include "dungeon_global_data.h"
#include "dungeon_items.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "tile_types.h"
extern void CheckRunAwayVisualFlag(struct DungeonEntity *, bool8 showRunAwayEffect);
extern u8 gDungeonWaterType[];
bool8 IsAtJunction(struct DungeonEntity *param_1)
{
char cVar2;
u32 crossableTerrain;
struct MapTile *mapTile;
struct DungeonEntityData *iVar7;
crossableTerrain = GetCrossableTerrain(param_1->entityData->entityID);
if (!IsFixedDungeon()) {
if ((param_1->entityData->transformStatus == TRANSFORM_STATUS_MOBILE) || (HasItem(param_1, ITEM_ID_MOBILE_SCARF))) {
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
else if (HasIQSkill(param_1, IQ_SKILL_ALL_TERRAIN_HIKER)) {
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
}
else if (HasIQSkill(param_1, IQ_SKILL_SUPER_MOBILE)) {
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
}
if (crossableTerrain == CROSSABLE_TERRAIN_WALL) {
iVar7 = param_1->entityData;
iVar7->mobileTurnTimer += DungeonRandomCapped(100);
if (iVar7->mobileTurnTimer < 200) {
return FALSE;
}
else
iVar7->mobileTurnTimer = 0;
}
else {
if ((gDungeonWaterType[gDungeonGlobalData->tileset] == DUNGEON_WATER_TYPE_LAVA)
&& (crossableTerrain == CROSSABLE_TERRAIN_LIQUID)
&& (HasIQSkill(param_1, IQ_SKILL_LAVA_EVADER))) {
crossableTerrain = CROSSABLE_TERRAIN_REGULAR;
}
mapTile = GetMapTile_1(param_1->posWorld.x, param_1->posWorld.y);
cVar2 = mapTile->canMoveAdjacent[crossableTerrain];
if ((cVar2 != 0x54) && (cVar2 != 0x51) && (cVar2 != 0x45) && (cVar2 != 0x15) && (cVar2 != 0x55)) return FALSE;
}
return TRUE;
}
bool8 ShouldAvoidFirstHit(struct DungeonEntity *pokemon, bool8 forceAvoid)
{

View File

@ -5,6 +5,11 @@
#include "constants/weather.h"
#include "dungeon_global_data.h"
#include "dungeon_items.h"
#include "dungeon_random.h"
extern void TriggerWeatherAbilities(void);
extern void sub_807EAA0(u32, u32);
void sub_807E5E4(u8);
u8 GetWeather(struct DungeonEntity* pokemon)
{
@ -14,3 +19,39 @@ u8 GetWeather(struct DungeonEntity* pokemon)
}
return gDungeonGlobalData->weather;
}
void sub_807E5AC(void)
{
u8 weather;
weather = gDungeonGlobalData->unk1C578;
if(weather == WEATHER_RANDOM)
weather = DungeonRandomCapped(WEATHER_RANDOM);
sub_807E5E4(weather);
TriggerWeatherAbilities();
sub_807EAA0(0, 1);
}
void sub_807E5E4(u8 weather)
{
int index;
u8 *preload;
gDungeonGlobalData->unkE265 = weather;
gDungeonGlobalData->weather = gDungeonGlobalData->unkE265;
gDungeonGlobalData->unkE279 = 0;
for(index = 0; index < 8; index++) {
gDungeonGlobalData->unkE267[index] = 0;
gDungeonGlobalData->unkE26F[index] = 0;
}
preload = &gDungeonGlobalData->weatherDamageTimer;
index = 0;
*preload = 9;
gDungeonGlobalData->mudSportTurnsLeft = 0;
gDungeonGlobalData->waterSportTurnsLeft = 0;
for(index = 0; index < 0x100; index++)
{
gDungeonGlobalData->unk17C[index].unk0 = index;
gDungeonGlobalData->unk17C[index].unk1 = index;
gDungeonGlobalData->unk17C[index].unk2 = index;
}
}