From 03a47933243c9eb9d6d1faa2998c364fa2a81360 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 18 Jun 2023 01:53:48 -0400 Subject: [PATCH] Added LoadPlayerObjectEventPalette to load gender pals --- include/event_object_movement.h | 1 + src/event_object_movement.c | 16 ++++++++++++++++ src/field_effect.c | 4 ++-- src/field_effect_helpers.c | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 3edfd36ecb..8a31bdb957 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -144,6 +144,7 @@ const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u16 graphicsId) void SetObjectInvisibility(u8 localId, u8 mapNum, u8 mapGroup, bool8 invisible); void FreeAndReserveObjectSpritePalettes(void); u8 LoadObjectEventPalette(u16 paletteTag); +u8 LoadPlayerObjectEventPalette(u8 gender); void SetObjectEventSpritePosByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y); void ResetObjectSubpriority(u8 localId, u8 mapNum, u8 mapGroup); void SetObjectSubpriority(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index c2258448bf..7822966c08 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2664,6 +2664,22 @@ u8 LoadObjectEventPalette(u16 paletteTag) return LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]); } +u8 LoadPlayerObjectEventPalette(u8 gender) +{ + u16 paletteTag; + switch (gender) + { + default: + case MALE: + paletteTag = FLDEFF_PAL_TAG_BRENDAN; + break; + case FEMALE: + paletteTag = FLDEFF_PAL_TAG_MAY; + break; + } + LoadObjectEventPalette(paletteTag); +} + // Unused static void LoadObjectEventPaletteSet(u16 *paletteTags) { diff --git a/src/field_effect.c b/src/field_effect.c index dd5e35df3c..24ef472bf3 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -3137,7 +3137,7 @@ u8 FldEff_NPCFlyOut(void) u8 spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BIRD], 0x78, 0, 1); struct Sprite *sprite = &gSprites[spriteId]; - sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); + sprite->oam.paletteNum = LoadPlayerObjectEventPalette(gSaveBlock2Ptr->playerGender); sprite->oam.priority = 1; sprite->callback = SpriteCB_NPCFlyOut; sprite->data[1] = gFieldEffectArguments[0]; @@ -3319,7 +3319,7 @@ static u8 CreateFlyBirdSprite(void) struct Sprite *sprite; spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BIRD], 0xff, 0xb4, 0x1); sprite = &gSprites[spriteId]; - sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); + sprite->oam.paletteNum = LoadPlayerObjectEventPalette(gSaveBlock2Ptr->playerGender); sprite->oam.priority = 1; sprite->callback = SpriteCB_FlyBirdLeaveBall; return spriteId; diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index ac9026b377..1217426e5c 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -269,7 +269,7 @@ u8 CreateWarpArrowSprite(void) { sprite = &gSprites[spriteId]; // Can use either gender's palette, so try to use the one that should be loaded - sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); + sprite->oam.paletteNum = LoadPlayerObjectEventPalette(gSaveBlock2Ptr->playerGender); sprite->oam.priority = 1; sprite->coordOffsetEnabled = TRUE; sprite->invisible = TRUE; @@ -1168,7 +1168,7 @@ u32 FldEff_SurfBlob(void) sprite->coordOffsetEnabled = TRUE; sprite->tPlayerObjId = gFieldEffectArguments[2]; // Can use either gender's palette, so try to use the one that should be loaded - sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); + sprite->oam.paletteNum = LoadPlayerObjectEventPalette(gSaveBlock2Ptr->playerGender); sprite->data[3] = -1; sprite->data[6] = -1; sprite->data[7] = -1;