From f0cfc049da1046472e818d9c20900b196511eea4 Mon Sep 17 00:00:00 2001 From: Raymond Dodge Date: Mon, 16 Mar 2026 02:51:32 -0400 Subject: [PATCH] Extract GiveGiftRibbonToParty from file about size records --- include/give_gift_ribbon_to_party.h | 6 +++++ include/pokemon_size_record.h | 2 -- ld_script.ld | 2 ++ src/give_gift_ribbon_to_party.c | 38 +++++++++++++++++++++++++++++ src/mystery_event_script.c | 2 +- src/pokemon_size_record.c | 34 -------------------------- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 include/give_gift_ribbon_to_party.h create mode 100644 src/give_gift_ribbon_to_party.c diff --git a/include/give_gift_ribbon_to_party.h b/include/give_gift_ribbon_to_party.h new file mode 100644 index 0000000000..f4e0b1be96 --- /dev/null +++ b/include/give_gift_ribbon_to_party.h @@ -0,0 +1,6 @@ +#ifndef GUARD_GIVE_GIFT_RIBBON_TO_PARTY_H +#define GUARD_GIVE_GIFT_RIBBON_TO_PARTY_H + +void GiveGiftRibbonToParty(u8 index, u8 ribbonId); + +#endif // GUARD_GIVE_GIFT_RIBBON_TO_PARTY_H diff --git a/include/pokemon_size_record.h b/include/pokemon_size_record.h index f61286bd47..43cb505d6f 100644 --- a/include/pokemon_size_record.h +++ b/include/pokemon_size_record.h @@ -9,6 +9,4 @@ void InitLotadSizeRecord(void); void GetLotadSizeRecordInfo(void); void CompareLotadSize(void); -void GiveGiftRibbonToParty(u8 index, u8 ribbonId); - #endif // GUARD_POKEMON_SIZE_RECORD_H diff --git a/ld_script.ld b/ld_script.ld index 316b5fe20f..00972e6ae4 100644 --- a/ld_script.ld +++ b/ld_script.ld @@ -180,6 +180,7 @@ SECTIONS { src/script_pokemon_util.o(.text); src/field_poison.o(.text); src/pokemon_size_record.o(.text); + src/give_gift_ribbon_to_party.o(.text); src/fldeff_misc.o(.text); src/field_special_scene.o(.text); src/rotating_gate.o(.text); @@ -557,6 +558,7 @@ SECTIONS { src/contest_util.o(.rodata); src/script_pokemon_util.o(.rodata); src/pokemon_size_record.o(.rodata) + src/give_gift_ribbon_to_party.o(.rodata); src/fldeff_misc.o(.rodata); src/field_special_scene.o(.rodata); src/rotating_gate.o(.rodata); diff --git a/src/give_gift_ribbon_to_party.c b/src/give_gift_ribbon_to_party.c new file mode 100644 index 0000000000..de678cb81c --- /dev/null +++ b/src/give_gift_ribbon_to_party.c @@ -0,0 +1,38 @@ +#include "global.h" +#include "event_data.h" +#include "give_gift_ribbon_to_party.h" +#include "pokemon.h" + +// - 4 for unused gift ribbon bits in MON_DATA_UNUSED_RIBBONS +static const u8 sGiftRibbonsMonDataIds[GIFT_RIBBONS_COUNT - 4] = +{ + MON_DATA_MARINE_RIBBON, MON_DATA_LAND_RIBBON, MON_DATA_SKY_RIBBON, + MON_DATA_COUNTRY_RIBBON, MON_DATA_NATIONAL_RIBBON, MON_DATA_EARTH_RIBBON, + MON_DATA_WORLD_RIBBON +}; + +void GiveGiftRibbonToParty(u8 index, u8 ribbonId) +{ + s32 i; + bool32 gotRibbon = FALSE; + u8 data = 1; + u8 array[ARRAY_COUNT(sGiftRibbonsMonDataIds)]; + memcpy(array, sGiftRibbonsMonDataIds, sizeof(sGiftRibbonsMonDataIds)); + + if (index < GIFT_RIBBONS_COUNT && ribbonId <= MAX_GIFT_RIBBON) + { + gSaveBlock1Ptr->giftRibbons[index] = ribbonId; + for (i = 0; i < PARTY_SIZE; i++) + { + struct Pokemon *mon = &gPlayerParty[i]; + + if (GetMonData(mon, MON_DATA_SPECIES) != 0 && GetMonData(mon, MON_DATA_SANITY_IS_EGG) == 0) + { + SetMonData(mon, array[index], &data); + gotRibbon = TRUE; + } + } + if (gotRibbon) + FlagSet(FLAG_SYS_RIBBON_GET); + } +} diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index b146bbab39..a98bdb3ec8 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -7,7 +7,7 @@ #include "mystery_event_script.h" #include "pokedex.h" #include "pokemon.h" -#include "pokemon_size_record.h" +#include "give_gift_ribbon_to_party.h" #include "script.h" #include "strings.h" #include "string_util.h" diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index 7c88e5bf10..cb1ecf189f 100644 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -36,14 +36,6 @@ static const struct UnknownStruct sBigMonSizeTable[] = { 1700, 1, -26 }, }; -// - 4 for unused gift ribbon bits in MON_DATA_UNUSED_RIBBONS -static const u8 sGiftRibbonsMonDataIds[GIFT_RIBBONS_COUNT - 4] = -{ - MON_DATA_MARINE_RIBBON, MON_DATA_LAND_RIBBON, MON_DATA_SKY_RIBBON, - MON_DATA_COUNTRY_RIBBON, MON_DATA_NATIONAL_RIBBON, MON_DATA_EARTH_RIBBON, - MON_DATA_WORLD_RIBBON -}; - extern const u8 gText_DecimalPoint[]; extern const u8 gText_Marco[]; @@ -192,29 +184,3 @@ void CompareLotadSize(void) gSpecialVar_Result = CompareMonSize(SPECIES_LOTAD, sizeRecord); } - -void GiveGiftRibbonToParty(u8 index, u8 ribbonId) -{ - s32 i; - bool32 gotRibbon = FALSE; - u8 data = 1; - u8 array[ARRAY_COUNT(sGiftRibbonsMonDataIds)]; - memcpy(array, sGiftRibbonsMonDataIds, sizeof(sGiftRibbonsMonDataIds)); - - if (index < GIFT_RIBBONS_COUNT && ribbonId <= MAX_GIFT_RIBBON) - { - gSaveBlock1Ptr->giftRibbons[index] = ribbonId; - for (i = 0; i < PARTY_SIZE; i++) - { - struct Pokemon *mon = &gPlayerParty[i]; - - if (GetMonData(mon, MON_DATA_SPECIES) != 0 && GetMonData(mon, MON_DATA_SANITY_IS_EGG) == 0) - { - SetMonData(mon, array[index], &data); - gotRibbon = TRUE; - } - } - if (gotRibbon) - FlagSet(FLAG_SYS_RIBBON_GET); - } -}