From 1e6628b78dbd87a5b0507ea4d656181f238ec755 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 21 Dec 2024 10:49:59 -0300 Subject: [PATCH] Address Review comments Pt2 --- data/maps/DewfordTown/map.json | 2 +- data/maps/EverGrandeCity/map.json | 2 +- data/maps/LilycoveCity/map.json | 2 +- data/maps/MauvilleCity/map.json | 4 ++-- data/maps/MossdeepCity/map.json | 4 ++-- data/maps/PacifidlogTown/map.json | 2 +- data/maps/PetalburgCity/map.json | 4 ++-- data/maps/Route102/map.json | 2 +- data/maps/RustboroCity/map.json | 34 +++++++++++++++---------------- data/maps/SlateportCity/map.json | 4 ++-- data/maps/VerdanturfTown/map.json | 4 ++-- include/constants/event_objects.h | 4 ++++ include/palette.h | 34 ++++++++++++++++--------------- include/rtc.h | 2 +- src/event_object_movement.c | 34 ++++++++++++++++++------------- src/field_effect.c | 2 +- 16 files changed, 76 insertions(+), 64 deletions(-) diff --git a/data/maps/DewfordTown/map.json b/data/maps/DewfordTown/map.json index 114dc72995..4ad6364593 100644 --- a/data/maps/DewfordTown/map.json +++ b/data/maps/DewfordTown/map.json @@ -99,7 +99,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/EverGrandeCity/map.json b/data/maps/EverGrandeCity/map.json index 80b681021e..86ad3a91b3 100644 --- a/data/maps/EverGrandeCity/map.json +++ b/data/maps/EverGrandeCity/map.json @@ -29,7 +29,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/LilycoveCity/map.json b/data/maps/LilycoveCity/map.json index 72cbce4553..1b9004eaa5 100644 --- a/data/maps/LilycoveCity/map.json +++ b/data/maps/LilycoveCity/map.json @@ -320,7 +320,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/MauvilleCity/map.json b/data/maps/MauvilleCity/map.json index b2a3238d1b..1ebe629476 100644 --- a/data/maps/MauvilleCity/map.json +++ b/data/maps/MauvilleCity/map.json @@ -187,7 +187,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" }, @@ -200,7 +200,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "2", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_POKE_MART_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/MossdeepCity/map.json b/data/maps/MossdeepCity/map.json index 9574ab4398..4891f9968a 100644 --- a/data/maps/MossdeepCity/map.json +++ b/data/maps/MossdeepCity/map.json @@ -260,7 +260,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" }, @@ -273,7 +273,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "2", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_POKE_MART_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/PacifidlogTown/map.json b/data/maps/PacifidlogTown/map.json index e6a1d06c73..2a06e4aca7 100644 --- a/data/maps/PacifidlogTown/map.json +++ b/data/maps/PacifidlogTown/map.json @@ -73,7 +73,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/PetalburgCity/map.json b/data/maps/PetalburgCity/map.json index 902f53bce4..54bae3539c 100644 --- a/data/maps/PetalburgCity/map.json +++ b/data/maps/PetalburgCity/map.json @@ -151,7 +151,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" }, @@ -164,7 +164,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "2", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_POKE_MART_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/Route102/map.json b/data/maps/Route102/map.json index 8e3d206c76..3a1726751b 100644 --- a/data/maps/Route102/map.json +++ b/data/maps/Route102/map.json @@ -151,7 +151,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "2", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_POKE_MART_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/RustboroCity/map.json b/data/maps/RustboroCity/map.json index 40d4f6f8fa..a32ce7d610 100644 --- a/data/maps/RustboroCity/map.json +++ b/data/maps/RustboroCity/map.json @@ -247,7 +247,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -260,7 +260,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -273,7 +273,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -286,7 +286,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -299,7 +299,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -312,7 +312,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -325,7 +325,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -338,7 +338,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -351,7 +351,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -364,7 +364,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -377,7 +377,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -390,7 +390,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -403,7 +403,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -416,7 +416,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -429,7 +429,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -442,7 +442,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" }, @@ -455,7 +455,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "0", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_BALL", "script": "NULL", "flag": "0" } diff --git a/data/maps/SlateportCity/map.json b/data/maps/SlateportCity/map.json index 7b002d2d9e..e2b6d47c67 100644 --- a/data/maps/SlateportCity/map.json +++ b/data/maps/SlateportCity/map.json @@ -494,7 +494,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" }, @@ -507,7 +507,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "2", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_POKE_MART_SIGN", "script": "NULL", "flag": "0" } diff --git a/data/maps/VerdanturfTown/map.json b/data/maps/VerdanturfTown/map.json index 6e0b81cd7a..d2522517ab 100644 --- a/data/maps/VerdanturfTown/map.json +++ b/data/maps/VerdanturfTown/map.json @@ -86,7 +86,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "1", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_PKMN_CENTER_SIGN", "script": "NULL", "flag": "0" }, @@ -99,7 +99,7 @@ "movement_range_x": 0, "movement_range_y": 0, "trainer_type": "TRAINER_TYPE_NONE", - "trainer_sight_or_berry_tree_id": "2", + "trainer_sight_or_berry_tree_id": "LIGHT_TYPE_POKE_MART_SIGN", "script": "NULL", "flag": "0" } diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h index 4005a253b1..7f2adbaae6 100644 --- a/include/constants/event_objects.h +++ b/include/constants/event_objects.h @@ -302,6 +302,10 @@ #define TRACKS_SPOT 4 #define TRACKS_BUG 5 +#define LIGHT_TYPE_BALL 0 +#define LIGHT_TYPE_PKMN_CENTER_SIGN 1 +#define LIGHT_TYPE_POKE_MART_SIGN 2 + #define FIRST_DECORATION_SPRITE_GFX OBJ_EVENT_GFX_PICHU_DOLL #define OBJ_KIND_NORMAL 0 diff --git a/include/palette.h b/include/palette.h index ba32c30344..e127d7fe65 100644 --- a/include/palette.h +++ b/include/palette.h @@ -52,22 +52,24 @@ struct PaletteFadeControl // These three are only used for TOD blending struct BlendSettings *bld0; struct BlendSettings *bld1; - u16 weight:9; // [0, 256], so must be 9 bits - u8 delayCounter:6; - u16 y:5; // blend coefficient - u16 targetY:5; // target blend coefficient - u16 blendColor:15; - bool16 active:1; - u16 multipurpose2:6; - bool16 yDec:1; // whether blend coefficient is decreasing - bool16 bufferTransferDisabled:1; - u16 mode:2; - bool16 shouldResetBlendRegisters:1; - bool16 hardwareFadeFinishing:1; - u16 softwareFadeFinishingCounter:5; - bool16 softwareFadeFinishing:1; - bool16 objPaletteToggle:1; - u8 deltaY:4; // rate of change of blend coefficient + u32 weight:9; // [0, 256], so must be 9 bits + u32 delayCounter:6; + u32 y:5; // blend coefficient + u32 targetY:5; // target blend coefficient + u32 multipurpose2:6; + bool32 active:1; + u32 blendColor:15; + // end of word + bool32 yDec:1; // whether blend coefficient is decreasing + bool32 bufferTransferDisabled:1; + u32 mode:2; + bool32 shouldResetBlendRegisters:1; + bool32 hardwareFadeFinishing:1; + u32 softwareFadeFinishingCounter:5; + bool32 softwareFadeFinishing:1; + bool32 objPaletteToggle:1; + u32 deltaY:4; // rate of change of blend coefficient + u32 padding:15; }; extern const struct BlendSettings gTimeOfDayBlend[]; diff --git a/include/rtc.h b/include/rtc.h index c60e63deb1..bf8ff9aa93 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -18,7 +18,7 @@ #define RTC_ERR_FLAG_MASK 0x0FF0 //Morning and evening don't exist in Gen 3 -#if OW_TIMES_OF_DAY <= GEN_3 +#if OW_TIMES_OF_DAY == GEN_3 #define MORNING_HOUR_BEGIN 0 #define MORNING_HOUR_END 0 diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 8c6856fcfa..01b393aa76 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1870,7 +1870,9 @@ u8 CreateObjectGraphicsSpriteWithTag(u16 graphicsId, void (*callback)(struct Spr else if (spriteTemplate->paletteTag != TAG_NONE) { if (paletteTag == TAG_NONE) + { LoadObjectEventPalette(spriteTemplate->paletteTag); + } else { LoadObjectEventPaletteWithTag(spriteTemplate->paletteTag, paletteTag); @@ -2111,7 +2113,6 @@ static u8 LoadDynamicFollowerPalette(u16 species, u8 form, bool32 shiny) if (gWeatherPtr->currWeather != WEATHER_FOG_HORIZONTAL) // don't want to weather blend in fog UpdateSpritePaletteWithWeather(paletteNum, FALSE); - return paletteNum; } @@ -2624,7 +2625,6 @@ void UpdateLightSprite(struct Sprite *sprite) s16 y = sprite->data[7]; u16 sheetTileStart; u32 paletteNum; - // Ripped from RemoveObjectEventIfOutsideView if (!(x >= left && x <= right && y >= top && y <= bottom)) { sheetTileStart = sprite->sheetTileStart; @@ -2644,7 +2644,8 @@ void UpdateLightSprite(struct Sprite *sprite) switch (sprite->data[5]) // lightType { - case 0: + default: + case LIGHT_TYPE_BALL: if (gPaletteFade.active) // if palette fade is active, don't flicker since the timer won't be updated { Weather_SetBlendCoeffs(7, BASE_SHADOW_INTENSITY); @@ -2664,7 +2665,8 @@ void UpdateLightSprite(struct Sprite *sprite) LoadSpritePaletteInSlot(&sObjectEventSpritePalettes[FindObjectEventPaletteIndexByTag(OBJ_EVENT_PAL_TAG_LIGHT_2)], sprite->oam.paletteNum); } break; - case 1 ... 2: + case LIGHT_TYPE_PKMN_CENTER_SIGN: + case LIGHT_TYPE_POKE_MART_SIGN: Weather_SetBlendCoeffs(12, BASE_SHADOW_INTENSITY); sprite->invisible = FALSE; break; @@ -2676,7 +2678,7 @@ static void SpawnLightSprite(s16 x, s16 y, s16 camX, s16 camY, u32 lightType) { struct Sprite *sprite; const struct SpriteTemplate *template; - u8 i; + u32 i; for (i = 0; i < MAX_SPRITES; i++) { sprite = &gSprites[i]; @@ -2700,27 +2702,29 @@ static void SpawnLightSprite(s16 x, s16 y, s16 camX, s16 camY, u32 lightType) sprite->coordOffsetEnabled = TRUE; switch (lightType) { - case 0: // Rustboro lanterns + default: + case LIGHT_TYPE_BALL: sprite->centerToCornerVecX = -(32 >> 1); sprite->centerToCornerVecY = -(32 >> 1); sprite->oam.priority = 1; - sprite->oam.objMode = 1; // BLEND + sprite->oam.objMode = ST_OAM_OBJ_BLEND; sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL; sprite->x += 8; sprite->y += 22 + sprite->centerToCornerVecY; break; - case 1 ... 2: // Pokemon Center & mart + case LIGHT_TYPE_PKMN_CENTER_SIGN: + case LIGHT_TYPE_POKE_MART_SIGN: sprite->centerToCornerVecX = -(16 >> 1); sprite->centerToCornerVecY = -(16 >> 1); sprite->oam.priority = 2; sprite->subpriority = 0xFF; - sprite->oam.objMode = 1; // BLEND + sprite->oam.objMode = ST_OAM_OBJ_BLEND; } } void TrySpawnLightSprites(s16 camX, s16 camY) { - u8 i; + u32 i; u8 objectCount; s16 left = gSaveBlock1Ptr->pos.x - 2; s16 right = gSaveBlock1Ptr->pos.x + MAP_OFFSET_W + 2; @@ -2741,9 +2745,11 @@ void TrySpawnLightSprites(s16 camX, s16 camY) struct ObjectEventTemplate *template = &gSaveBlock1Ptr->objectEventTemplates[i]; s16 npcX = template->x + MAP_OFFSET; s16 npcY = template->y + MAP_OFFSET; - if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX && !FlagGet(template->flagId)) - if (template->graphicsId == OBJ_EVENT_GFX_LIGHT_SPRITE) // event is light sprite instead - SpawnLightSprite(npcX, npcY, camX, camY, template->trainerRange_berryTreeId); + if (top <= npcY && bottom >= npcY + && left <= npcX && right >= npcX + && !FlagGet(template->flagId) + && template->graphicsId == OBJ_EVENT_GFX_LIGHT_SPRITE) // event is light sprite instead + SpawnLightSprite(npcX, npcY, camX, camY, template->trainerRange_berryTreeId); } } @@ -10203,7 +10209,7 @@ static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite * if (flags & 1) sGroundEffectFuncs[i](objEvent, sprite); if (!(gWeatherPtr->noShadows || objEvent->inHotSprings || objEvent->inSandPile || MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior))) - GroundEffect_Shadow(objEvent, sprite); + GroundEffect_Shadow(objEvent, sprite); } void filters_out_some_ground_effects(struct ObjectEvent *objEvent, u32 *flags) diff --git a/src/field_effect.c b/src/field_effect.c index dbec7df119..cbe311753a 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -3302,7 +3302,7 @@ static void FlyOutFieldEffect_FlyOffWithBird(struct Task *task) struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; ObjectEventClearHeldMovementIfActive(objectEvent); objectEvent->inanimate = FALSE; - objectEvent->noShadow = TRUE; // TODO: Make shadow smaller instead of disappearing completely ? + objectEvent->noShadow = TRUE; SetFlyBirdPlayerSpriteId(task->tBirdSpriteId, objectEvent->spriteId); CameraObjectFreeze(); task->tState++;