From 7a072d4527387cf21a019142caf67ce516be861d Mon Sep 17 00:00:00 2001 From: Slawter666 <38655737+Slawter666@users.noreply.github.com> Date: Sat, 20 Oct 2018 21:01:45 +0100 Subject: [PATCH] Continue synchronising --- include/event_object_movement.h | 2 - src/event_object_movement.c | 276 +++++++++++++++----------------- 2 files changed, 132 insertions(+), 146 deletions(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 98395593b..0fabcf95a 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -162,9 +162,7 @@ u8 ZCoordToPriority(u8); void EventObjectUpdateZCoord(struct EventObject *pObject); void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); bool8 IsZCoordMismatchAt(u8, s16, s16); -void UpdateEventObjectSpriteSubpriorityAndVisibility(struct Sprite *); void UnfreezeEventObject(struct EventObject *); -void oamt_npc_ministep_reset(struct Sprite *, u8, u8); u8 FindLockedEventObjectIndex(struct EventObject *); bool8 obj_npc_ministep(struct Sprite *sprite); bool8 sub_80976EC(struct Sprite *sprite); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index d97bdbcd1..d3c8da3b5 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -43,7 +43,7 @@ static bool8 IsCoordOutsideEventObjectMovementRange(struct EventObject *, s16, s static bool8 IsMetatileDirectionallyImpassable(struct EventObject *, s16, s16, u8); static bool8 DoesObjectCollideWithObjectAt(struct EventObject *, s16, s16); static void sub_8096530(struct EventObject *, struct Sprite *); -static void npc_update_obj_anim_flag(struct EventObject *, struct Sprite *); +static void UpdateEventObjSpriteVisibility(struct EventObject *, struct Sprite *); static void EventObjectUpdateMetatileBehaviors(struct EventObject*); static void GetGroundEffectFlags_Reflection(struct EventObject*, u32*); static void GetGroundEffectFlags_TallGrassOnSpawn(struct EventObject*, u32*); @@ -101,6 +101,8 @@ static void CameraObject_2(struct Sprite *); static struct EventObjectTemplate *FindEventObjectTemplateByLocalId(u8 localId, struct EventObjectTemplate *templates, u8 count); static void ClearEventObjectMovement(struct EventObject *, struct Sprite *); static void EventObjectSetSingleMovement(struct EventObject *, struct Sprite *, u8); +static void oamt_npc_ministep_reset(struct Sprite *, u8, u8); +static void UpdateEventObjectSpriteSubpriorityAndVisibility(struct Sprite *); const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0}; @@ -626,7 +628,6 @@ const u16 gObjectPaletteTags3[] = { EVENT_OBJ_PAL_TAG_7, }; - const u16 *const gObjectPaletteTagSets[] = { gObjectPaletteTags0, gObjectPaletteTags1, @@ -1120,7 +1121,7 @@ u8 GetFirstInactiveEventObjectId(void) u8 GetEventObjectIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId) { - if (localId < 0xff) + if (localId < 0xFF) { return GetEventObjectIdByLocalIdAndMapInternal(localId, mapNum, mapGroupId); } @@ -1388,24 +1389,24 @@ static NAKED u8 InitEventObjectStateFromTemplate(struct EventObjectTemplate *tem u8 Unref_TryInitLocalEventObject(u8 localId) { u8 i; - u8 nObjects; + u8 eventObjectCount; struct EventObjectTemplate *template; if (gMapHeader.events != NULL) { if (InBattlePyramid()) { - nObjects = sub_81AAA40(); + eventObjectCount = sub_81AAA40(); } else if (InTrainerHill()) { - nObjects = 2; + eventObjectCount = 2; } else { - nObjects = gMapHeader.events->eventObjectCount; + eventObjectCount = gMapHeader.events->eventObjectCount; } - for (i = 0; i < nObjects; i++) + for (i = 0; i < eventObjectCount; i++) { template = &gSaveBlock1Ptr->eventObjectTemplates[i]; if (template->localId == localId && !FlagGet(template->flagId)) @@ -1482,12 +1483,12 @@ void RemoveAllEventObjectsExceptPlayer(void) static u8 TrySetupEventObjectSprite(struct EventObjectTemplate *eventObjectTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { + u8 spriteId; + u8 paletteSlot; + u8 eventObjectId; + struct Sprite *sprite; struct EventObject *eventObject; const struct EventObjectGraphicsInfo *graphicsInfo; - struct Sprite *sprite; - u8 eventObjectId; - u8 paletteSlot; - u8 spriteId; eventObjectId = InitEventObjectStateFromTemplate(eventObjectTemplate, mapNum, mapGroup); if (eventObjectId == EVENT_OBJECTS_COUNT) @@ -1542,13 +1543,12 @@ static u8 TrySetupEventObjectSprite(struct EventObjectTemplate *eventObjectTempl static u8 TrySpawnEventObject(struct EventObjectTemplate *eventObjectTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { - const struct EventObjectGraphicsInfo *graphicsInfo; - struct SpriteTemplate spriteTemplate; - const struct SubspriteTable *subspriteTables; - struct SpriteFrameImage spriteFrameImage; u8 eventObjectId; + struct SpriteTemplate spriteTemplate; + struct SpriteFrameImage spriteFrameImage; + const struct EventObjectGraphicsInfo *graphicsInfo; + const struct SubspriteTable *subspriteTables = NULL; - subspriteTables = NULL; graphicsInfo = GetEventObjectGraphicsInfo(eventObjectTemplate->graphicsId); MakeObjectTemplateFromEventObjectTemplate(eventObjectTemplate, &spriteTemplate, &subspriteTables); spriteFrameImage.size = graphicsInfo->size; @@ -1610,23 +1610,23 @@ u8 show_sprite(u8 localId, u8 mapNum, u8 mapGroup) return TrySpawnEventObject(eventObjectTemplate, mapNum, mapGroup, cameraX, cameraY); } -static void MakeObjectTemplateFromEventObjectGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +static void MakeObjectTemplateFromEventObjectGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) { - const struct EventObjectGraphicsInfo *gfxInfo = GetEventObjectGraphicsInfo(graphicsId); + const struct EventObjectGraphicsInfo *graphicsInfo = GetEventObjectGraphicsInfo(graphicsId); - sprTemplate->tileTag = gfxInfo->tileTag; - sprTemplate->paletteTag = gfxInfo->paletteTag1; - sprTemplate->oam = gfxInfo->oam; - sprTemplate->anims = gfxInfo->anims; - sprTemplate->images = gfxInfo->images; - sprTemplate->affineAnims = gfxInfo->affineAnims; - sprTemplate->callback = callback; - *subspriteTables = gfxInfo->subspriteTables; + spriteTemplate->tileTag = graphicsInfo->tileTag; + spriteTemplate->paletteTag = graphicsInfo->paletteTag1; + spriteTemplate->oam = graphicsInfo->oam; + spriteTemplate->anims = graphicsInfo->anims; + spriteTemplate->images = graphicsInfo->images; + spriteTemplate->affineAnims = graphicsInfo->affineAnims; + spriteTemplate->callback = callback; + *subspriteTables = graphicsInfo->subspriteTables; } -static void MakeObjectTemplateFromEventObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +static void MakeObjectTemplateFromEventObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) { - MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, sMovementTypeCallbacks[callbackIndex], sprTemplate, subspriteTables); + MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, sMovementTypeCallbacks[callbackIndex], spriteTemplate, subspriteTables); } static void MakeObjectTemplateFromEventObjectTemplate(struct EventObjectTemplate *eventObjectTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) @@ -1639,37 +1639,37 @@ u8 AddPseudoEventObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 x struct SpriteTemplate *spriteTemplate; const struct SubspriteTable *subspriteTables; struct Sprite *sprite; - u8 spriteIdx; + u8 spriteId; spriteTemplate = malloc(sizeof(struct SpriteTemplate)); MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables); - if (spriteTemplate->paletteTag != 0xffff) + if (spriteTemplate->paletteTag != 0xFFFF) { sub_808E894(spriteTemplate->paletteTag); } - spriteIdx = CreateSprite(spriteTemplate, x, y, subpriority); + spriteId = CreateSprite(spriteTemplate, x, y, subpriority); free(spriteTemplate); - if (spriteIdx != MAX_SPRITES && subspriteTables != NULL) + if (spriteId != MAX_SPRITES && subspriteTables != NULL) { - sprite = &gSprites[spriteIdx]; + sprite = &gSprites[spriteId]; SetSubspriteTables(sprite, subspriteTables); sprite->subspriteMode = 2; } - return spriteIdx; + return spriteId; } u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction) { - const struct EventObjectGraphicsInfo *graphicsInfo; - struct SpriteTemplate spriteTemplate; - const struct SubspriteTable *subspriteTables; u8 spriteId; struct Sprite *sprite; + struct SpriteTemplate spriteTemplate; + const struct SubspriteTable *subspriteTables; + const struct EventObjectGraphicsInfo *graphicsInfo; graphicsInfo = GetEventObjectGraphicsInfo(graphicsId); MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, UpdateEventObjectSpriteSubpriorityAndVisibility, &spriteTemplate, &subspriteTables); - *(u16 *)&spriteTemplate.paletteTag = 0xffff; + *(u16 *)&spriteTemplate.paletteTag = 0xFFFF; x += 7; y += 7; sub_80930E0(&x, &y, 8, 16); @@ -1711,20 +1711,14 @@ u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction) void TrySpawnEventObjects(s16 cameraX, s16 cameraY) { u8 i; - s16 left; - s16 right; - s16 top; - s16 bottom; u8 objectCount; - s16 npcX; - s16 npcY; if (gMapHeader.events != NULL) { - left = gSaveBlock1Ptr->pos.x - 2; - right = gSaveBlock1Ptr->pos.x + 17; - top = gSaveBlock1Ptr->pos.y; - bottom = gSaveBlock1Ptr->pos.y + 16; + s16 left = gSaveBlock1Ptr->pos.x - 2; + s16 right = gSaveBlock1Ptr->pos.x + 17; + s16 top = gSaveBlock1Ptr->pos.y; + s16 bottom = gSaveBlock1Ptr->pos.y + 16; if (InBattlePyramid()) { @@ -1742,8 +1736,8 @@ void TrySpawnEventObjects(s16 cameraX, s16 cameraY) for (i = 0; i < objectCount; i++) { struct EventObjectTemplate *template = &gSaveBlock1Ptr->eventObjectTemplates[i]; - npcX = template->x + 7; - npcY = template->y + 7; + s16 npcX = template->x + 7; + s16 npcY = template->y + 7; if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX && !FlagGet(template->flagId)) @@ -1754,10 +1748,8 @@ void TrySpawnEventObjects(s16 cameraX, s16 cameraY) void RemoveEventObjectsOutsideView(void) { - u8 i; - u8 j; + u8 i, j; bool8 isActiveLinkPlayer; - struct EventObject *eventObject; for (i = 0; i < EVENT_OBJECTS_COUNT; i++) { @@ -1768,7 +1760,7 @@ void RemoveEventObjectsOutsideView(void) } if (!isActiveLinkPlayer) { - eventObject = &gEventObjects[i]; + struct EventObject *eventObject = &gEventObjects[i]; if (eventObject->active && !eventObject->isPlayer) RemoveEventObjectIfOutsideView(eventObject); @@ -1811,12 +1803,12 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y) { u8 spriteId; u8 paletteSlot; + struct Sprite *sprite; struct EventObject *eventObject; + struct SpriteTemplate spriteTemplate; + struct SpriteFrameImage spriteFrameImage; const struct SubspriteTable *subspriteTables; const struct EventObjectGraphicsInfo *graphicsInfo; - struct SpriteFrameImage spriteFrameImage; - struct SpriteTemplate spriteTemplate; - struct Sprite *sprite; #define i spriteId for (i = 0; i < ARRAY_COUNT(gLinkPlayerEventObjects); i++) @@ -1834,7 +1826,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y) spriteFrameImage.size = graphicsInfo->size; MakeObjectTemplateFromEventObjectGraphicsInfoWithCallbackIndex(eventObject->graphicsId, eventObject->movementType, &spriteTemplate, &subspriteTables); spriteTemplate.images = &spriteFrameImage; - *(u16 *)&spriteTemplate.paletteTag = 0xffff; + *(u16 *)&spriteTemplate.paletteTag = 0xFFFF; paletteSlot = graphicsInfo->paletteSlot; if (paletteSlot == 0) { @@ -1849,7 +1841,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y) paletteSlot -= 16; sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot); } - *(u16 *)&spriteTemplate.paletteTag = 0xffff; + *(u16 *)&spriteTemplate.paletteTag = 0xFFFF; spriteId = CreateSprite(&spriteTemplate, 0, 0, 0); if (spriteId != MAX_SPRITES) { @@ -1860,7 +1852,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y) sprite->pos1.x += 8; sprite->pos1.y += 16 + sprite->centerToCornerVecY; sprite->images = graphicsInfo->images; - if (eventObject->movementType == 0x0b) + if (eventObject->movementType == MOVEMENT_TYPE_PLAYER) { SetPlayerAvatarEventObjectIdAndObjectId(eventObjectId, spriteId); eventObject->warpArrowSpriteId = CreateWarpArrowSprite(); @@ -1873,7 +1865,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y) sprite->coordOffsetEnabled = TRUE; sprite->data[0] = eventObjectId; eventObject->spriteId = spriteId; - if (!eventObject->inanimate && eventObject->movementType != 0x0b) + if (!eventObject->inanimate && eventObject->movementType != MOVEMENT_TYPE_PLAYER) { StartSpriteAnim(sprite, GetFaceDirectionAnimNum(eventObject->facingDirection)); } @@ -1884,7 +1876,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y) static void sub_808E38C(struct EventObject *eventObject) { - eventObject->singleMovementActive = 0; + eventObject->singleMovementActive = FALSE; eventObject->triggerGroundEffectsOnMove = TRUE; eventObject->hasShadow = FALSE; eventObject->hasReflection = FALSE; @@ -1979,7 +1971,7 @@ void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction) EventObjectTurn(&gEventObjects[playerAvatar->eventObjectId], direction); } -/*static*/ void get_berry_tree_graphics(struct EventObject *eventObject, struct Sprite *sprite) +static void get_berry_tree_graphics(struct EventObject *eventObject, struct Sprite *sprite) { u8 berryStage; u8 berryId; @@ -1992,7 +1984,7 @@ void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction) eventObject->invisible = FALSE; sprite->invisible = FALSE; berryId = GetBerryTypeByBerryTreeId(eventObject->trainerRange_berryTreeId) - 1; - berryStage -= 1; + berryStage--; if (berryId >= NUM_BERRIES) { berryId = 0; @@ -2111,9 +2103,8 @@ void FreeAndReserveObjectSpritePalettes(void) static void sub_808E894(u16 paletteTag) { - u16 paletteSlot; + u16 paletteSlot = FindEventObjectPaletteIndexByTag(paletteTag); - paletteSlot = FindEventObjectPaletteIndexByTag(paletteTag); if (paletteSlot != EVENT_OBJ_PAL_TAG_NONE) // always true { sub_808E8F4(&sEventObjectSpritePalettes[paletteSlot]); @@ -2132,19 +2123,18 @@ void sub_808E8C0(u16 *paletteTags) static u8 sub_808E8F4(const struct SpritePalette *spritePalette) { - if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xff) + if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xFF) { - return 0xff; + return 0xFF; } return LoadSpritePalette(spritePalette); } void PatchObjectPalette(u16 paletteTag, u8 paletteSlot) { - u16 paletteIdx; + u8 paletteIndex = FindEventObjectPaletteIndexByTag(paletteTag); - paletteIdx = FindEventObjectPaletteIndexByTag(paletteTag); - LoadPalette(sEventObjectSpritePalettes[paletteIdx].data, 16 * paletteSlot + 256, 0x20); + LoadPalette(sEventObjectSpritePalettes[paletteIndex].data, 16 * paletteSlot + 0x100, 0x20); } void PatchObjectPaletteRange(const u16 *paletteTags, u8 minSlot, u8 maxSlot) @@ -2168,7 +2158,7 @@ static u8 FindEventObjectPaletteIndexByTag(u16 tag) return i; } } - return 0xff; + return 0xFF; } void LoadPlayerObjectReflectionPalette(u16 tag, u8 slot) @@ -2223,7 +2213,7 @@ void ShiftEventObjectCoords(struct EventObject *eventObject, s16 x, s16 y) eventObject->currentCoords.y = y; } -/*static*/ void SetEventObjectCoords(struct EventObject *eventObject, s16 x, s16 y) +static void SetEventObjectCoords(struct EventObject *eventObject, s16 x, s16 y) { eventObject->previousCoords.x = x; eventObject->previousCoords.y = y; @@ -2296,6 +2286,7 @@ void UpdateEventObjectCoordsForCameraUpdate(void) u8 GetEventObjectIdByXYZ(u16 x, u16 y, u8 z) { u8 i; + for (i = 0; i < EVENT_OBJECTS_COUNT; i++) { if (gEventObjects[i].active) @@ -2327,9 +2318,8 @@ void UpdateEventObjectsForCameraUpdate(s16 x, s16 y) u8 AddCameraObject(u8 linkedSpriteId) { - u8 spriteId; + u8 spriteId = CreateSprite(&gCameraSpriteTemplate, 0, 0, 4); - spriteId = CreateSprite(&gCameraSpriteTemplate, 0, 0, 4); gSprites[spriteId].invisible = TRUE; gSprites[spriteId].data[0] = linkedSpriteId; return spriteId; @@ -2354,11 +2344,9 @@ static void CameraObject_0(struct Sprite *sprite) static void CameraObject_1(struct Sprite *sprite) { - s16 x; - s16 y; + s16 x = gSprites[sprite->data[0]].pos1.x; + s16 y = gSprites[sprite->data[0]].pos1.y; - y = gSprites[sprite->data[0]].pos1.y; - x = gSprites[sprite->data[0]].pos1.x; sprite->data[2] = x - sprite->pos1.x; sprite->data[3] = y - sprite->pos1.y; sprite->pos1.x = x; @@ -2375,13 +2363,13 @@ static void CameraObject_2(struct Sprite *sprite) static struct Sprite *FindCameraObject(void) { - u8 spriteId; + u8 i; - for (spriteId = 0; spriteId < MAX_SPRITES; spriteId++) + for (i = 0; i < MAX_SPRITES; i++) { - if (gSprites[spriteId].inUse && gSprites[spriteId].callback == ObjectCB_CameraObject) + if (gSprites[i].inUse && gSprites[i].callback == ObjectCB_CameraObject) { - return &gSprites[spriteId]; + return &gSprites[i]; } } return NULL; @@ -2450,7 +2438,7 @@ u8 CreateCopySpriteAt(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) { s16 i; - for (i = MAX_SPRITES - 1; i > -1; i --) + for (i = MAX_SPRITES - 1; i > -1; i--) { if (!gSprites[i].inUse) { @@ -2974,10 +2962,8 @@ u8 GetLimitedVectorDirection_SouthWestEast(s16 dx, s16 dy, s16 absdx, s16 absdy) u8 TryGetTrainerEncounterDirection(struct EventObject *eventObject, u8 movementType) { - s16 dx; - s16 dy; - s16 absdx; - s16 absdy; + s16 dx, dy; + s16 absdx, absdy; if (!EventObjectIsTrainerAndCloseToPlayer(eventObject)) { @@ -4445,7 +4431,7 @@ bool8 CopyablePlayerMovement_GoSpeed1(struct EventObject *eventObject, struct Sp { EventObjectSetSingleMovement(eventObject, sprite, GetFaceDirectionMovementAction(direction)); } - eventObject->singleMovementActive = 1; + eventObject->singleMovementActive = TRUE; sprite->data[1] = 2; return TRUE; } @@ -4464,7 +4450,7 @@ bool8 CopyablePlayerMovement_GoSpeed2(struct EventObject *eventObject, struct Sp { EventObjectSetSingleMovement(eventObject, sprite, GetFaceDirectionMovementAction(direction)); } - eventObject->singleMovementActive = 1; + eventObject->singleMovementActive = TRUE; sprite->data[1] = 2; return TRUE; } @@ -4483,7 +4469,7 @@ bool8 CopyablePlayerMovement_Slide(struct EventObject *eventObject, struct Sprit { EventObjectSetSingleMovement(eventObject, sprite, GetFaceDirectionMovementAction(direction)); } - eventObject->singleMovementActive = 1; + eventObject->singleMovementActive = TRUE; sprite->data[1] = 2; return TRUE; } @@ -4495,7 +4481,7 @@ bool8 cph_IM_DIFFERENT(struct EventObject *eventObject, struct Sprite *sprite, u direction = playerDirection; direction = state_to_direction(gInitialMovementTypeFacingDirections[eventObject->movementType], eventObject->directionSequenceIndex, direction); EventObjectSetSingleMovement(eventObject, sprite, GetJumpInPlaceMovementAction(direction)); - eventObject->singleMovementActive = 1; + eventObject->singleMovementActive = TRUE; sprite->data[1] = 2; return TRUE; } @@ -4514,7 +4500,7 @@ bool8 CopyablePlayerMovement_GoSpeed4(struct EventObject *eventObject, struct Sp { EventObjectSetSingleMovement(eventObject, sprite, GetFaceDirectionMovementAction(direction)); } - eventObject->singleMovementActive = 1; + eventObject->singleMovementActive = TRUE; sprite->data[1] = 2; return TRUE; } @@ -4535,7 +4521,7 @@ bool8 CopyablePlayerMovement_Jump(struct EventObject *eventObject, struct Sprite { EventObjectSetSingleMovement(eventObject, sprite, GetFaceDirectionMovementAction(direction)); } - eventObject->singleMovementActive = 1; + eventObject->singleMovementActive = TRUE; sprite->data[1] = 2; return TRUE; } @@ -7431,7 +7417,7 @@ bool8 MovementAction_AcroWheelieMoveLeft_Step1(struct EventObject *eventObject, bool8 MovementAction_AcroWheelieMoveRight_Step0(struct EventObject *eventObject, struct Sprite *sprite) { - sub_8096200(eventObject, sprite, DIR_EAST, 1); + sub_8096200(eventObject, sprite, DIR_EAST, 1); return MovementAction_AcroWheelieMoveRight_Step1(eventObject, sprite); } @@ -7486,7 +7472,7 @@ bool8 MovementAction_AcroEndWheelieMoveUp_Step1(struct EventObject *eventObject, bool8 MovementAction_AcroEndWheelieMoveLeft_Step0(struct EventObject *eventObject, struct Sprite *sprite) { - sub_8096330(eventObject, sprite, DIR_WEST, 1); + sub_8096330(eventObject, sprite, DIR_WEST, 1); return MovementAction_AcroEndWheelieMoveLeft_Step1(eventObject, sprite); } @@ -7502,7 +7488,7 @@ bool8 MovementAction_AcroEndWheelieMoveLeft_Step1(struct EventObject *eventObjec bool8 MovementAction_AcroEndWheelieMoveRight_Step0(struct EventObject *eventObject, struct Sprite *sprite) { - sub_8096330(eventObject, sprite, DIR_EAST, 1); + sub_8096330(eventObject, sprite, DIR_EAST, 1); return MovementAction_AcroEndWheelieMoveRight_Step1(eventObject, sprite); } @@ -7574,15 +7560,13 @@ static void TryEnableEventObjectAnim(struct EventObject *eventObject, struct Spr static void UpdateEventObjectVisibility(struct EventObject *eventObject, struct Sprite *sprite) { sub_8096530(eventObject, sprite); - npc_update_obj_anim_flag(eventObject, sprite); + UpdateEventObjSpriteVisibility(eventObject, sprite); } static void sub_8096530(struct EventObject *eventObject, struct Sprite *sprite) { - u16 x; - u16 y; - u16 x2; - u16 y2; + u16 x, y; + u16 x2, y2; const struct EventObjectGraphicsInfo *graphicsInfo; eventObject->offScreen = FALSE; @@ -7611,7 +7595,7 @@ static void sub_8096530(struct EventObject *eventObject, struct Sprite *sprite) } } -static void npc_update_obj_anim_flag(struct EventObject *eventObject, struct Sprite *sprite) +static void UpdateEventObjSpriteVisibility(struct EventObject *eventObject, struct Sprite *sprite) { sprite->invisible = FALSE; if (eventObject->invisible || eventObject->offScreen) @@ -7620,7 +7604,7 @@ static void npc_update_obj_anim_flag(struct EventObject *eventObject, struct Spr } } -/*static*/ void GetAllGroundEffectFlags_OnSpawn(struct EventObject *eventObj, u32 *flags) +static void GetAllGroundEffectFlags_OnSpawn(struct EventObject *eventObj, u32 *flags) { EventObjectUpdateMetatileBehaviors(eventObj); GetGroundEffectFlags_Reflection(eventObj, flags); @@ -7646,7 +7630,7 @@ static void GetAllGroundEffectFlags_OnBeginStep(struct EventObject *eventObj, u3 GetGroundEffectFlags_HotSprings(eventObj, flags); } -/*static*/ void GetAllGroundEffectFlags_OnFinishStep(struct EventObject *eventObj, u32 *flags) +static void GetAllGroundEffectFlags_OnFinishStep(struct EventObject *eventObj, u32 *flags) { EventObjectUpdateMetatileBehaviors(eventObj); GetGroundEffectFlags_ShallowFlowingWater(eventObj, flags); @@ -7926,7 +7910,7 @@ u8 GetLedgeJumpDirection(s16 x, s16 y, u8 z) return 0; } -void EventObjectSetSpriteOamTableForLongGrass(struct EventObject *eventObj, struct Sprite *sprite) +static void SetEventObjectSpriteOamTableForLongGrass(struct EventObject *eventObj, struct Sprite *sprite) { if (eventObj->disableCoveringGroundEffects) return; @@ -7979,7 +7963,7 @@ static const u8 sEventObjectPriorities_08376070[] = { 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 1, }; -void EventObjectUpdateZCoordAndPriority(struct EventObject *eventObj, struct Sprite *sprite) +void UpdateEventObjectZCoordAndPriority(struct EventObject *eventObj, struct Sprite *sprite) { if (eventObj->fixedPriority) return; @@ -8202,7 +8186,11 @@ void GroundEffect_JumpOnTallGrass(struct EventObject *eventObj, struct Sprite *s FieldEffectStart(FLDEFF_JUMP_TALL_GRASS); spriteId = FindTallGrassFieldEffectSpriteId( - eventObj->localId, eventObj->mapNum, eventObj->mapGroup, eventObj->currentCoords.x, eventObj->currentCoords.y); + eventObj->localId, + eventObj->mapNum, + eventObj->mapGroup, + eventObj->currentCoords.x, + eventObj->currentCoords.y); if (spriteId == MAX_SPRITES) GroundEffect_SpawnOnTallGrass(eventObj, sprite); @@ -8284,7 +8272,7 @@ static void (*const sGroundEffectFuncs[])(struct EventObject *eventObj, struct S GroundEffect_Seaweed }; -/*static*/ void DoFlaggedGroundEffects(struct EventObject *eventObj, struct Sprite *sprite, u32 flags) +static void DoFlaggedGroundEffects(struct EventObject *eventObj, struct Sprite *sprite, u32 flags) { u8 i; @@ -8325,9 +8313,9 @@ static void DoGroundEffects_OnSpawn(struct EventObject *eventObj, struct Sprite if (eventObj->triggerGroundEffectsOnMove) { flags = 0; - EventObjectUpdateZCoordAndPriority(eventObj, sprite); + UpdateEventObjectZCoordAndPriority(eventObj, sprite); GetAllGroundEffectFlags_OnSpawn(eventObj, &flags); - EventObjectSetSpriteOamTableForLongGrass(eventObj, sprite); + SetEventObjectSpriteOamTableForLongGrass(eventObj, sprite); DoFlaggedGroundEffects(eventObj, sprite, flags); eventObj->triggerGroundEffectsOnMove = 0; eventObj->disableCoveringGroundEffects = 0; @@ -8341,9 +8329,9 @@ static void DoGroundEffects_OnBeginStep(struct EventObject *eventObj, struct Spr if (eventObj->triggerGroundEffectsOnMove) { flags = 0; - EventObjectUpdateZCoordAndPriority(eventObj, sprite); + UpdateEventObjectZCoordAndPriority(eventObj, sprite); GetAllGroundEffectFlags_OnBeginStep(eventObj, &flags); - EventObjectSetSpriteOamTableForLongGrass(eventObj, sprite); + SetEventObjectSpriteOamTableForLongGrass(eventObj, sprite); filters_out_some_ground_effects(eventObj, &flags); DoFlaggedGroundEffects(eventObj, sprite, flags); eventObj->triggerGroundEffectsOnMove = 0; @@ -8358,9 +8346,9 @@ static void DoGroundEffects_OnFinishStep(struct EventObject *eventObj, struct Sp if (eventObj->triggerGroundEffectsOnStop) { flags = 0; - EventObjectUpdateZCoordAndPriority(eventObj, sprite); + UpdateEventObjectZCoordAndPriority(eventObj, sprite); GetAllGroundEffectFlags_OnFinishStep(eventObj, &flags); - EventObjectSetSpriteOamTableForLongGrass(eventObj, sprite); + SetEventObjectSpriteOamTableForLongGrass(eventObj, sprite); FilterOutStepOnPuddleGroundEffectIfJumping(eventObj, &flags); DoFlaggedGroundEffects(eventObj, sprite, flags); eventObj->triggerGroundEffectsOnStop = 0; @@ -8393,11 +8381,11 @@ void FreezeEventObjects(void) FreezeEventObject(&gEventObjects[i]); } -void FreezeEventObjectsExceptOne(u8 a1) +void FreezeEventObjectsExceptOne(u8 eventObjectId) { u8 i; for (i = 0; i < EVENT_OBJECTS_COUNT; i++) - if (i != a1 && gEventObjects[i].active && i != gPlayerAvatar.eventObjectId) + if (i != eventObjectId && gEventObjects[i].active && i != gPlayerAvatar.eventObjectId) FreezeEventObject(&gEventObjects[i]); } @@ -8419,44 +8407,44 @@ void UnfreezeEventObjects(void) UnfreezeEventObject(&gEventObjects[i]); } -void Step1(struct Sprite *sprite, u8 dir) +static void Step1(struct Sprite *sprite, u8 dir) { sprite->pos1.x += sDirectionToVectors[dir].x; sprite->pos1.y += sDirectionToVectors[dir].y; } -void Step2(struct Sprite *sprite, u8 dir) +static void Step2(struct Sprite *sprite, u8 dir) { sprite->pos1.x += 2 * (u16) sDirectionToVectors[dir].x; sprite->pos1.y += 2 * (u16) sDirectionToVectors[dir].y; } -void Step3(struct Sprite *sprite, u8 dir) +static void Step3(struct Sprite *sprite, u8 dir) { sprite->pos1.x += 2 * (u16) sDirectionToVectors[dir].x + (u16) sDirectionToVectors[dir].x; sprite->pos1.y += 2 * (u16) sDirectionToVectors[dir].y + (u16) sDirectionToVectors[dir].y; } -void Step4(struct Sprite *sprite, u8 dir) +static void Step4(struct Sprite *sprite, u8 dir) { sprite->pos1.x += 4 * (u16) sDirectionToVectors[dir].x; sprite->pos1.y += 4 * (u16) sDirectionToVectors[dir].y; } -void Step8(struct Sprite *sprite, u8 dir) +static void Step8(struct Sprite *sprite, u8 dir) { sprite->pos1.x += 8 * (u16) sDirectionToVectors[dir].x; sprite->pos1.y += 8 * (u16) sDirectionToVectors[dir].y; } -void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3) +static void oamt_npc_ministep_reset(struct Sprite *sprite, u8 direction, u8 a3) { - sprite->data[3] = a2; + sprite->data[3] = direction; sprite->data[4] = a3; sprite->data[5] = 0; } -typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 dir); +typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 direction); static const SpriteStepFunc gUnknown_0850E6C4[] = { Step1, @@ -8536,9 +8524,9 @@ bool8 obj_npc_ministep(struct Sprite *sprite) return TRUE; } -void sub_80976DC(struct Sprite *sprite, u8 a2) +void sub_80976DC(struct Sprite *sprite, u8 direction) { - sprite->data[3] = a2; + sprite->data[3] = direction; sprite->data[4] = 0; sprite->data[5] = 0; } @@ -8559,7 +8547,7 @@ bool8 sub_80976EC(struct Sprite *sprite) return FALSE; } -const s8 gUnknown_0850E772[] = { +static const s8 gUnknown_0850E772[] = { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, @@ -8571,7 +8559,7 @@ const s8 gUnknown_0850E772[] = { 0, 1, 0, 0, 0, 0, 0, 0, }; -const s8 gUnknown_0850E7BA[] = { +static const s8 gUnknown_0850E7BA[] = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, @@ -8741,7 +8729,7 @@ u8 sub_80978E4(struct Sprite *sprite) return v2; } -void SetMovementDelay(struct Sprite *sprite, s16 timer) +static void SetMovementDelay(struct Sprite *sprite, s16 timer) { sprite->data[3] = timer; } @@ -8756,11 +8744,11 @@ static bool8 WaitForMovementDelay(struct Sprite *sprite) return FALSE; } -void SetAndStartSpriteAnim(struct Sprite *sprite, u8 a2, u8 a3) +void SetAndStartSpriteAnim(struct Sprite *sprite, u8 animNum, u8 animCmdIndex) { - sprite->animNum = a2; - sprite->animPaused = 0 ; - SeekSpriteAnim(sprite, a3); + sprite->animNum = animNum; + sprite->animPaused = FALSE; + SeekSpriteAnim(sprite, animCmdIndex); } bool8 SpriteAnimEnded(struct Sprite *sprite) @@ -8798,7 +8786,7 @@ void UpdateEventObjectSpriteVisibility(struct Sprite *sprite, bool8 invisible) sprite->invisible = TRUE; } -void UpdateEventObjectSpriteSubpriorityAndVisibility(struct Sprite *sprite) +static void UpdateEventObjectSpriteSubpriorityAndVisibility(struct Sprite *sprite) { sub_8097D68(sprite); SetObjectSubpriorityByZCoord(sprite->data[1], sprite, 1); @@ -8845,15 +8833,15 @@ void sub_8097BB4(u8 var1, u8 graphicsId) if(spriteId != MAX_SPRITES) { struct Sprite *sprite = &gSprites[spriteId]; - const struct EventObjectGraphicsInfo *gfxInfo = GetEventObjectGraphicsInfo(graphicsId); + const struct EventObjectGraphicsInfo *graphicsInfo = GetEventObjectGraphicsInfo(graphicsId); u16 tileNum = sprite->oam.tileNum; - sprite->oam = *gfxInfo->oam; + sprite->oam = *graphicsInfo->oam; sprite->oam.tileNum = tileNum; - sprite->oam.paletteNum = gfxInfo->paletteSlot; - sprite->images = gfxInfo->images; + sprite->oam.paletteNum = graphicsInfo->paletteSlot; + sprite->images = graphicsInfo->images; - if(gfxInfo->subspriteTables == NULL) + if(graphicsInfo->subspriteTables == NULL) { sprite->subspriteTables = NULL; sprite->subspriteTableNum = 0; @@ -8861,7 +8849,7 @@ void sub_8097BB4(u8 var1, u8 graphicsId) } else { - SetSubspriteTables(sprite, gfxInfo->subspriteTables); + SetSubspriteTables(sprite, graphicsInfo->subspriteTables); sprite->subspriteMode = 2; } StartSpriteAnim(sprite, 0); @@ -8986,9 +8974,9 @@ void DoShadowFieldEffect(struct EventObject *eventObject) static void DoRippleFieldEffect(struct EventObject *eventObject, struct Sprite *sprite) { - const struct EventObjectGraphicsInfo *gfxInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); + const struct EventObjectGraphicsInfo *graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); gFieldEffectArguments[0] = sprite->pos1.x; - gFieldEffectArguments[1] = sprite->pos1.y + (gfxInfo->height >> 1) - 2; + gFieldEffectArguments[1] = sprite->pos1.y + (graphicsInfo->height >> 1) - 2; gFieldEffectArguments[2] = 151; gFieldEffectArguments[3] = 3; FieldEffectStart(FLDEFF_RIPPLE);