From 24ebfa50b2ce531854e380f4e8386193e399748d Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sun, 14 Sep 2025 00:12:22 -0400 Subject: [PATCH] Decomped GetEntityWeatherBallType --- ...rlay_29_0231AF0C.inc => overlay_29_0231AF24.inc} | 2 -- ...{overlay_29_0231AF0C.s => overlay_29_0231AF24.s} | 13 +------------ include/natural_gift.h | 8 -------- include/preprocessString.h | 4 +++- include/special_move_types.h | 11 +++++++++++ main.lsf | 4 ++-- src/dungeon_logic_5.c | 3 +-- src/overlay_31_02382820.c | 4 ++-- src/{natural_gift.c => special_move_types.c} | 10 +++++++++- 9 files changed, 29 insertions(+), 30 deletions(-) rename asm/include/{overlay_29_0231AF0C.inc => overlay_29_0231AF24.inc} (88%) rename asm/{overlay_29_0231AF0C.s => overlay_29_0231AF24.s} (92%) delete mode 100644 include/natural_gift.h create mode 100644 include/special_move_types.h rename src/{natural_gift.c => special_move_types.c} (81%) diff --git a/asm/include/overlay_29_0231AF0C.inc b/asm/include/overlay_29_0231AF24.inc similarity index 88% rename from asm/include/overlay_29_0231AF0C.inc rename to asm/include/overlay_29_0231AF24.inc index aa14647f..f05ba5fc 100644 --- a/asm/include/overlay_29_0231AF0C.inc +++ b/asm/include/overlay_29_0231AF24.inc @@ -2,7 +2,6 @@ .public BoostSpeedOneStage .public DUNGEON_PTR .public EntityIsValid__0231B194 -.public GetApparentWeather .public GetTreasureBoxChances .public IsMonster__0231A9D4 .public LogMessageByIdWithPopupCheckParticipants @@ -10,7 +9,6 @@ .public PrepareItemForPrinting__02345728 .public SetActionUseMoveAi .public SubstitutePlaceholderStringTags -.public WEATHER_BALL_TYPE_TABLE .public ov29_022E4110 .public ov29_022FB9E0 .public ov29_0232145C diff --git a/asm/overlay_29_0231AF0C.s b/asm/overlay_29_0231AF24.s similarity index 92% rename from asm/overlay_29_0231AF0C.s rename to asm/overlay_29_0231AF24.s index e4eef549..c67426c8 100644 --- a/asm/overlay_29_0231AF0C.s +++ b/asm/overlay_29_0231AF24.s @@ -1,19 +1,8 @@ .include "asm/macros.inc" - .include "overlay_29_0231AF0C.inc" + .include "overlay_29_0231AF24.inc" .text - arm_func_start GetEntityWeatherBallType -GetEntityWeatherBallType: ; 0x0231AF0C - stmdb sp!, {r3, lr} - bl GetApparentWeather - ldr r1, _0231AF20 ; =WEATHER_BALL_TYPE_TABLE - ldrb r0, [r1, r0] - ldmia sp!, {r3, pc} - .align 2, 0 -_0231AF20: .word WEATHER_BALL_TYPE_TABLE - arm_func_end GetEntityWeatherBallType - arm_func_start ov29_0231AF24 ov29_0231AF24: ; 0x0231AF24 #ifdef JAPAN diff --git a/include/natural_gift.h b/include/natural_gift.h deleted file mode 100644 index 2717af6f..00000000 --- a/include/natural_gift.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PMDSKY_NATURAL_GIFT_H -#define PMDSKY_NATURAL_GIFT_H - -#include "dungeon_mode.h" - -const struct natural_gift_item_info* GetEntityNaturalGiftInfo(struct entity* entity); - -#endif //PMDSKY_NATURAL_GIFT_H diff --git a/include/preprocessString.h b/include/preprocessString.h index bf3b974e..c9b8a5f6 100644 --- a/include/preprocessString.h +++ b/include/preprocessString.h @@ -1,8 +1,10 @@ #ifndef PREPROCESS_STRING_H #define PREPROCESS_STRING_H +#include "enums.h" + struct PPStrValues { - u8* weather_0; // 0x0 + u32 weather_0; // 0x0 u32 field_0x4; u32 field_0x8; u32 field_0xB; diff --git a/include/special_move_types.h b/include/special_move_types.h new file mode 100644 index 00000000..0e56cb1e --- /dev/null +++ b/include/special_move_types.h @@ -0,0 +1,11 @@ +#ifndef PMDSKY_SPECIAL_MOVE_TYPES_H +#define PMDSKY_SPECIAL_MOVE_TYPES_H + +#include "dungeon_mode.h" + +// Gets the relevant entry in NATURAL_GIFT_ITEM_TABLE based on the entity's held item, if possible. +const struct natural_gift_item_info* GetEntityNaturalGiftInfo(struct entity* entity); +// Gets the current Weather Ball type for the given entity, based on the apparent weather. +enum type_id GetEntityWeatherBallType(struct entity* entity); + +#endif //PMDSKY_SPECIAL_MOVE_TYPES_H diff --git a/main.lsf b/main.lsf index 3c1b2e16..6cd16c65 100644 --- a/main.lsf +++ b/main.lsf @@ -508,8 +508,8 @@ Overlay OVY_29 Object asm/overlay_29_0231A9F8.o Object src/overlay_29_0231ACAC.o Object asm/overlay_29_0231AD38.o - Object src/natural_gift.o - Object asm/overlay_29_0231AF0C.o + Object src/special_move_types.o + Object asm/overlay_29_0231AF24.o Object src/overlay_29_0231B194.o Object asm/overlay_29_0231B1B8.o Object src/overlay_29_0231B318.o diff --git a/src/dungeon_logic_5.c b/src/dungeon_logic_5.c index 3f7f9428..fd45f6ca 100644 --- a/src/dungeon_logic_5.c +++ b/src/dungeon_logic_5.c @@ -2,11 +2,10 @@ #include "dungeon_pokemon_attributes.h" #include "dungeon_util_static.h" #include "main_02014CEC.h" -#include "natural_gift.h" #include "natural_gift_data.h" #include "overlay_29_023000E4.h" +#include "special_move_types.h" -extern enum type_id GetEntityWeatherBallType(struct entity* entity); extern enum type_id GetMoveType(struct move* move); enum type_id GetMoveTypeForMonster(struct entity *entity, struct move *move) diff --git a/src/overlay_31_02382820.c b/src/overlay_31_02382820.c index 880ceafb..8b2c3b8e 100644 --- a/src/overlay_31_02382820.c +++ b/src/overlay_31_02382820.c @@ -2,6 +2,7 @@ #include "dungeon_ai_targeting.h" #include "dungeon_util_static.h" #include "number_util.h" +#include "weather.h" extern const u8 DUNGEON_MENU_SWITCH_STR1[];// = "[dungeon:0]"; @@ -23,7 +24,6 @@ extern void* MemAlloc(u32 size, u32 nmemb); extern struct entity* GetLeader(void); extern u32 GetMoneyCarried(void); -extern void* GetApparentWeather(u32); extern u32 sub_0204F9E0(void); extern void ov29_022E2A78(u8*, void*, u32); // The third argument isn't actually used in the // function (../asm/overlay_29_022E1A40.s#L1378) @@ -99,7 +99,7 @@ void DrawDungeonMenuStatusWindow(struct Window* window) PreprocessString(str_buff, DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE, str, 0, &str_values); DrawTextInWindow(window, X_OFFSET, LINE_HEIGHT, str_buff); - str_values.weather_0 = GetApparentWeather(0); + str_values.weather_0 = GetApparentWeather(NULL); str = StringFromId(DRAW_DUNGEON_MENU_STATUS_WINDOW_STR_ID_3); PreprocessString(str_buff, DRAW_DUNGEON_MENU_STATUS_WINDOW_BUFF_SIZE, str, 0, &str_values); DrawTextInWindow(window, X_OFFSET, LINE_HEIGHT * 2, str_buff); diff --git a/src/natural_gift.c b/src/special_move_types.c similarity index 81% rename from src/natural_gift.c rename to src/special_move_types.c index cf0452e5..6426f41c 100644 --- a/src/natural_gift.c +++ b/src/special_move_types.c @@ -1,7 +1,10 @@ -#include "natural_gift.h" +#include "special_move_types.h" #include "dungeon_util_static.h" #include "natural_gift_data.h" #include "overlay_29_0231A9D4.h" +#include "weather.h" + +extern enum type_id WEATHER_BALL_TYPE_TABLE[8]; const struct natural_gift_item_info* GetEntityNaturalGiftInfo(struct entity* entity) { @@ -31,3 +34,8 @@ const struct natural_gift_item_info* GetEntityNaturalGiftInfo(struct entity* ent } return NULL; } + +enum type_id GetEntityWeatherBallType(struct entity* entity) +{ + return WEATHER_BALL_TYPE_TABLE[GetApparentWeather(entity)]; +}