diff options
Diffstat (limited to 'src/field_map_obj.c')
-rw-r--r-- | src/field_map_obj.c | 564 |
1 files changed, 223 insertions, 341 deletions
diff --git a/src/field_map_obj.c b/src/field_map_obj.c index f60b1b233..59319a16e 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -11,7 +11,7 @@ #include "fieldmap.h" #include "palette.h" #include "rng.h" -#include "rom4.h" +#include "overworld.h" #include "sprite.h" #include "metatile_behavior.h" #include "map_constants.h" @@ -1901,7 +1901,7 @@ extern void CameraObjectReset1(void); extern struct LinkPlayerMapObject gLinkPlayerMapObjects[]; extern u8 gReservedSpritePaletteCount; -extern struct Camera gUnknown_0202E844; +extern struct Camera gCamera; static u8 gUnknown_030005A4; static u16 gUnknown_030005A6; @@ -2986,24 +2986,21 @@ void UpdateFieldObjectCoordsForCameraUpdate(void) s16 deltaX; s16 deltaY; -#ifndef NONMATCHING - asm(""::"r"(i)); //makes the compiler store i in r3 -#endif - - if (gUnknown_0202E844.field_0) + if (gCamera.field_0) { - for (i = 0, deltaX = gUnknown_0202E844.x, deltaY = gUnknown_0202E844.y; i < 16; i++) + deltaX = gCamera.x; + deltaY = gCamera.y; + for (i = 0; i < 16; i++) { - struct MapObject *mapObject = &gMapObjects[i]; - if (mapObject->active) + if (gMapObjects[i].active) { - mapObject->coords1.x -= deltaX; - mapObject->coords1.y -= deltaY; - mapObject->coords2.x -= deltaX; - mapObject->coords2.y -= deltaY; - mapObject->coords3.x -= deltaX; - mapObject->coords3.y -= deltaY; + gMapObjects[i].coords1.x -= deltaX; + gMapObjects[i].coords1.y -= deltaY; + gMapObjects[i].coords2.x -= deltaX; + gMapObjects[i].coords2.y -= deltaY; + gMapObjects[i].coords3.x -= deltaX; + gMapObjects[i].coords3.y -= deltaY; } } } @@ -3244,7 +3241,7 @@ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 m return FindFieldObjectTemplateInArrayByLocalId(localId, gSaveBlock1.mapObjectTemplates, gMapHeader.events->mapObjectCount); else { - struct MapHeader *mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum); + struct MapHeader *mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum); return FindFieldObjectTemplateInArrayByLocalId(localId, mapHeader->events->mapObjects, mapHeader->events->mapObjectCount); } @@ -3895,11 +3892,11 @@ u8 do_berry_tree_growth_sparkle_1(struct MapObject *mapObject, struct Sprite *sp { if (!(sprite->data7 & 4) && sprite->animNum == 4) { - gUnknown_0202FF84[0] = mapObject->coords2.x; - gUnknown_0202FF84[1] = mapObject->coords2.y; - gUnknown_0202FF84[2] = sprite->subpriority - 1; - gUnknown_0202FF84[3] = sprite->oam.priority; - FieldEffectStart(0x17); + gFieldEffectArguments[0] = mapObject->coords2.x; + gFieldEffectArguments[1] = mapObject->coords2.y; + gFieldEffectArguments[2] = sprite->subpriority - 1; + gFieldEffectArguments[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_BERRY_TREE_GROWTH_SPARKLE); sprite->animNum = 0; } return 0; @@ -3934,11 +3931,11 @@ u8 do_berry_tree_growth_sparkle_2(struct MapObject *mapObject, struct Sprite *sp sprite->data1 = 3; sprite->data2 = 0; sprite->data7 |= 2; - gUnknown_0202FF84[0] = mapObject->coords2.x; - gUnknown_0202FF84[1] = mapObject->coords2.y; - gUnknown_0202FF84[2] = sprite->subpriority - 1; - gUnknown_0202FF84[3] = sprite->oam.priority; - FieldEffectStart(0x17); + gFieldEffectArguments[0] = mapObject->coords2.x; + gFieldEffectArguments[1] = mapObject->coords2.y; + gFieldEffectArguments[2] = sprite->subpriority - 1; + gFieldEffectArguments[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_BERRY_TREE_GROWTH_SPARKLE); return 1; } @@ -5030,32 +5027,30 @@ u8 sub_805F3C4(struct MapObject *mapObject, struct Sprite *sprite) return 0; } -#ifdef NONMATCHING - -u8 sub_805F3EC(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, u8 *a3(u8)) +bool8 sub_805F3EC(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, bool8 a3(u8)) { return 0; } -u8 sub_805F3F0(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, u8 *a3(u8)) +bool8 sub_805F3F0(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, bool8 a3(u8)) { - int direction; - direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, a2); - FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, a2))); mapObject->mapobj_bit_1 = 1; sprite->data1 = 2; return 1; } -u8 sub_805F438(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, u8 *a3(u8)) +bool8 sub_805F438(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, bool8 a3(u8)) { + u32 direction; s16 x; s16 y; - int direction; - direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, a2); + + direction = a2; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, direction); FieldObjectMoveDestCoords(mapObject, direction, &x, &y); FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(direction)); - if (!npc_block_way(mapObject, x, y, direction) || (a3 != NULL && !a3(MapGridGetMetatileBehaviorAt(x, y)))) + if (npc_block_way(mapObject, x, y, direction) || (a3 != NULL && !a3(MapGridGetMetatileBehaviorAt(x, y)))) { FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); } @@ -5063,9 +5058,115 @@ u8 sub_805F438(struct MapObject *mapObject, struct Sprite *sprite, u8 a2, u8 *a3 sprite->data1 = 2; return 1; } -#endif -asm(".section .text_fmocb2_c\n"); +bool8 sub_805F4F0(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, sub_8060744(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_805F5A8(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, sub_806079C(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_805F660(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, sub_80607C8(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 cph_IM_DIFFERENT(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + + direction = playerDirection; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectSetRegularAnim(mapObject, sprite, sub_806084C(direction)); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_805F760(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, sub_80608A4(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 oac_hopping(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_0836DC09[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + x = mapObject->coords2.x; + y = mapObject->coords2.y; + sub_8060320(direction, &x, &y, 2, 2); + FieldObjectSetRegularAnim(mapObject, sprite, GetJumpLedgeAnimId(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} fieldmap_object_cb(sub_805F8E0, sub_805F904, gUnknown_083755C0); @@ -5086,8 +5187,8 @@ void FieldObjectCB_TreeDisguise(struct Sprite *sprite) mapObject = &gMapObjects[sprite->data0]; if (mapObject->mapobj_unk_21 == 0 || (mapObject->mapobj_unk_21 == 1 && sprite->data7 == 0)) { - FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); - mapObject->mapobj_unk_1A = FieldEffectStart(0x1c); + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]); + mapObject->mapobj_unk_1A = FieldEffectStart(FLDEFF_TREE_DISGUISE); mapObject->mapobj_unk_21 = 1; sprite->data7 ++; } @@ -5106,8 +5207,8 @@ void FieldObjectCB_MountainDisguise(struct Sprite *sprite) mapObject = &gMapObjects[sprite->data0]; if (mapObject->mapobj_unk_21 == 0 || (mapObject->mapobj_unk_21 == 1 && sprite->data7 == 0)) { - FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); - mapObject->mapobj_unk_1A = FieldEffectStart(0x1d); + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]); + mapObject->mapobj_unk_1A = FieldEffectStart(FLDEFF_MOUNTAIN_DISGUISE); mapObject->mapobj_unk_21 = 1; sprite->data7 ++; } @@ -5364,53 +5465,38 @@ u8 sub_805FF20(struct MapObject *mapObject, u8 direction) } bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y); -bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y); +static bool8 DoesObjectCollideWithObjectAt(struct MapObject *mapObject, s16 x, s16 y); bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction); -u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn) { + u8 direction; + direction = dirn; if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) - { return 1; - } - if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) - { + else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) return 2; - } else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) - { + else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) return 2; - } - if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) - { + else if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) return 3; - } - if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) - { + else if (DoesObjectCollideWithObjectAt(mapObject, x, y)) return 4; - } return 0; } u8 sub_8060024(struct MapObject *mapObject, s16 x, s16 y, u8 direction) { - u8 flags; - flags = 0; + u8 flags = 0; + if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) - { flags |= 1; - } if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction) || (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction))) - { flags |= 2; - } if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) - { flags |= 4; - } - if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) - { + if (DoesObjectCollideWithObjectAt(mapObject, x, y)) flags |= 8; - } return flags; } @@ -5418,25 +5504,22 @@ bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, { s16 minv; s16 maxv; + if (mapObject->mapobj_unk_19 != 0) { minv = mapObject->coords1.x - (mapObject->mapobj_unk_19); maxv = mapObject->coords1.x + (mapObject->mapobj_unk_19); if (minv > x || maxv < x) - { - return 1; - } + return TRUE; } if (mapObject->mapobj_unk_19b != 0) { minv = mapObject->coords1.y - (mapObject->mapobj_unk_19b); maxv = mapObject->coords1.y + (mapObject->mapobj_unk_19b); if (minv > y || maxv < y) - { - return 1; - } + return TRUE; } - return 0; + return FALSE; } bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction) @@ -5448,23 +5531,19 @@ bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 return 0; } -bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y) +static bool8 DoesObjectCollideWithObjectAt(struct MapObject *mapObject, s16 x, s16 y) { - struct MapObject *mapObject2; u8 i; - for (i=0; i<16; i++) + + for (i = 0; i < 16; i++) { - mapObject2 = &gMapObjects[i]; + struct MapObject *mapObject2 = &gMapObjects[i]; + if (mapObject2->active && mapObject2 != mapObject) { - if ((mapObject2->coords2.x != x || mapObject2->coords2.y != y) && (mapObject2->coords3.x != x || mapObject2->coords3.y != y)) - { - continue; - } - if (AreZCoordsCompatible(mapObject->mapobj_unk_0B_0, mapObject2->mapobj_unk_0B_0)) - { - return 1; - } + if (((mapObject2->coords2.x == x && mapObject2->coords2.y == y) || (mapObject2->coords3.x == x && mapObject2->coords3.y == y)) + && AreZCoordsCompatible(mapObject->mapobj_unk_0B_0, mapObject2->mapobj_unk_0B_0)) + return TRUE; } } return 0; @@ -5504,23 +5583,26 @@ void unref_sub_80602F8(u8 direction, s16 *x, s16 *y) *y += gDirectionToVector[direction].y << 4; } -void sub_8060320(u8 direction, s16 *x, s16 *y, s16 deltaX, s16 deltaY) +void sub_8060320(u32 dirn, s16 *x, s16 *y, s16 deltaX, s16 deltaY) { + u8 direction = dirn; + s16 dx2 = deltaX; + s16 dy2 = deltaY; if (gDirectionToVector[direction].x > 0) { - *x += deltaX; + *x += dx2; } if (gDirectionToVector[direction].x < 0) { - *x -= deltaX; + *x -= dx2; } if (gDirectionToVector[direction].y > 0) { - *y += deltaY; + *y += dy2; } if (gDirectionToVector[direction].y < 0) { - *y -= deltaY; + *y -= dy2; } } @@ -5587,11 +5669,12 @@ void GetFieldObjectMovingCameraOffset(s16 *x, s16 *y) } } -void FieldObjectMoveDestCoords(struct MapObject *mapObject, u8 direction, s16 *x, s16 *y) +void FieldObjectMoveDestCoords(struct MapObject *mapObject, u32 direction, s16 *x, s16 *y) { + u8 newDirn = direction; *x = mapObject->coords2.x; *y = mapObject->coords2.y; - MoveCoords(direction, x, y); + MoveCoords(newDirn, x, y); } bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct MapObject *mapObject) @@ -5705,193 +5788,34 @@ void meta_step(struct MapObject *mapObject, struct Sprite *sprite, u8 (*callback FieldObjectUpdateSubpriority(mapObject, sprite); } - -u8 GetFaceDirectionAnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756C8, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 GetSimpleGoAnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756CD, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 GetGoSpeed0AnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756D2, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_8060744(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756D7, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 d2s_08064034(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756DC, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_806079C(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756E1, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_80607C8(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756E6, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_80607F4(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756EB, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 GetJumpLedgeAnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756F0, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_806084C(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756F5, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_8060878(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756FA, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_80608A4(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_083756FF, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 sub_80608D0(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_08375704, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 GetStepInPlaceDelay32AnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_08375709, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 GetStepInPlaceDelay16AnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_0837570E, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 GetStepInPlaceDelay8AnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_08375713, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} - -u8 GetStepInPlaceDelay4AnimId(u8 index) -{ - u8 directions[5]; - memcpy(directions, gUnknown_08375718, 5); - if (index >= 5) - { - index = 0; - } - return directions[index]; -} +#define dirn_to_anim(name, table)\ +u8 name(u32 idx)\ +{\ + u8 direction;\ + u8 animIds[sizeof(table)];\ + direction = idx;\ + memcpy(animIds, (table), sizeof(table));\ + if (direction > DIR_EAST) direction = 0;\ + return animIds[direction];\ +} + +dirn_to_anim(GetFaceDirectionAnimId, gUnknown_083756C8) +dirn_to_anim(GetSimpleGoAnimId, gUnknown_083756CD) +dirn_to_anim(GetGoSpeed0AnimId, gUnknown_083756D2) +dirn_to_anim(sub_8060744, gUnknown_083756D7) +dirn_to_anim(d2s_08064034, gUnknown_083756DC) +dirn_to_anim(sub_806079C, gUnknown_083756E1) +dirn_to_anim(sub_80607C8, gUnknown_083756E6) +dirn_to_anim(sub_80607F4, gUnknown_083756EB) +dirn_to_anim(GetJumpLedgeAnimId, gUnknown_083756F0) +dirn_to_anim(sub_806084C, gUnknown_083756F5) +dirn_to_anim(sub_8060878, gUnknown_083756FA) +dirn_to_anim(sub_80608A4, gUnknown_083756FF) +dirn_to_anim(sub_80608D0, gUnknown_08375704) +dirn_to_anim(GetStepInPlaceDelay32AnimId, gUnknown_08375709) +dirn_to_anim(GetStepInPlaceDelay16AnimId, gUnknown_0837570E) +dirn_to_anim(GetStepInPlaceDelay8AnimId, gUnknown_08375713) +dirn_to_anim(GetStepInPlaceDelay4AnimId, gUnknown_08375718) u8 FieldObjectFaceOppositeDirection(struct MapObject *mapObject, u8 direction) { @@ -6019,65 +5943,23 @@ u8 GetOppositeDirection(u8 direction) return directions[direction - 1]; } -int zffu_offset_calc(u8 a0, u8 a1) +u32 zffu_offset_calc(u8 a0, u8 a1) { return gUnknown_08375757[a0 - 1][a1 - 1]; } -#ifdef NONMATCHING -int state_to_direction(u8 a0, u8 a1, u8 a2) +u32 state_to_direction(u8 a0, u32 a1, u32 a2) { - int zffuOffset; - asm_comment("For some reason, r2 is being backed up to r3 and restored ahead of the zffu call."); - if (a1 == 0 || a2 == 0 || a1 > 4 || a2 > 4) + u32 zffuOffset; + u8 a1_2 = a1; + u8 a2_2 = a2; + if (a1_2 == 0 || a2_2 == 0 || a1_2 > DIR_EAST || a2_2 > DIR_EAST) { return 0; } - zffuOffset = zffu_offset_calc(a1, a2); + zffuOffset = zffu_offset_calc(a1_2, a2); return gUnknown_08375767[a0 - 1][zffuOffset - 1]; } -#else -__attribute__((naked)) -int state_to_direction(u8 a0, u8 a1, u8 a2) -{ - asm(".syntax unified\n\ - push {r4,lr}\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - adds r0, r1, 0\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - cmp r1, 0\n\ - beq _08060BFC\n\ - cmp r2, 0\n\ - beq _08060BFC\n\ - cmp r1, 0x4\n\ - bhi _08060BFC\n\ - cmp r2, 0x4\n\ - bls _08060C00\n\ -_08060BFC:\n\ - movs r0, 0\n\ - b _08060C12\n\ -_08060C00:\n\ - adds r1, r2, 0\n\ - bl zffu_offset_calc\n\ - ldr r2, _08060C18 @ =gUnknown_08375767\n\ - lsls r1, r4, 2\n\ - subs r1, 0x5\n\ - adds r0, r1\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ -_08060C12:\n\ - pop {r4}\n\ - pop {r1}\n\ - bx r1\n\ - .align 2, 0\n\ -_08060C18: .4byte gUnknown_08375767\n\ -.syntax divided\n"); -} -#endif void FieldObjectExecSpecialAnim(struct MapObject *mapObject, struct Sprite *sprite) { @@ -7490,24 +7372,24 @@ bool8 sub_8062644(struct MapObject *mapObject, struct Sprite *sprite) bool8 do_exclamation_mark_bubble_1(struct MapObject *mapObject, struct Sprite *sprite) { - FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); - FieldEffectStart(0x0); + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]); + FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON_1); sprite->data2 = 1; return TRUE; } bool8 do_exclamation_mark_bubble_2(struct MapObject *mapObject, struct Sprite *sprite) { - FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); - FieldEffectStart(0x21); + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]); + FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON_2); sprite->data2 = 1; return TRUE; } bool8 do_heart_bubble(struct MapObject *mapObject, struct Sprite *sprite) { - FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); - FieldEffectStart(0x2e); + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]); + FieldEffectStart(FLDEFF_HEART_ICON); sprite->data2 = 1; return TRUE; } @@ -8303,12 +8185,12 @@ void sub_80634A0(struct MapObject *mapObject, struct Sprite *sprite) } void sub_80634E8(struct MapObject *, struct Sprite *); -void npc_update_obj_anim_flag(struct MapObject *, struct Sprite *); +static void UpdateMapObjSpriteVisibility(struct MapObject *, struct Sprite *); void sub_80634D0(struct MapObject *mapObject, struct Sprite *sprite) { sub_80634E8(mapObject, sprite); - npc_update_obj_anim_flag(mapObject, sprite); + UpdateMapObjSpriteVisibility(mapObject, sprite); } #ifdef NONMATCHING @@ -8464,7 +8346,7 @@ _080635C0:\n\ } #endif -void npc_update_obj_anim_flag(struct MapObject *mapObject, struct Sprite *sprite) +void UpdateMapObjSpriteVisibility(struct MapObject *mapObject, struct Sprite *sprite) { sprite->invisible = 0; if (mapObject->mapobj_bit_13 || mapObject->mapobj_bit_14) |