mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
npc_block_way
This commit is contained in:
parent
5812bc4ebe
commit
fedbcd7bb7
@ -5,108 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start npc_block_way
|
||||
@ u8 npc_block_way(struct npc_state *fieldObject, u16 x, u16 y, u8 direction)
|
||||
npc_block_way: @ 8092BC8
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5-r7}
|
||||
adds r6, r0, 0
|
||||
lsls r1, 16
|
||||
lsls r2, 16
|
||||
lsls r3, 24
|
||||
lsrs r7, r3, 24
|
||||
mov r8, r7
|
||||
lsrs r0, r1, 16
|
||||
mov r9, r0
|
||||
asrs r5, r1, 16
|
||||
lsrs r0, r2, 16
|
||||
mov r10, r0
|
||||
asrs r4, r2, 16
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
adds r2, r4, 0
|
||||
bl IsCoordOutsideFieldObjectMovementRect
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _08092BFE
|
||||
movs r0, 0x1
|
||||
b _08092C7E
|
||||
_08092BFE:
|
||||
adds r0, r5, 0
|
||||
adds r1, r4, 0
|
||||
bl MapGridIsImpassableAt
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08092C40
|
||||
adds r0, r5, 0
|
||||
adds r1, r4, 0
|
||||
bl GetMapBorderIdAt
|
||||
movs r1, 0x1
|
||||
negs r1, r1
|
||||
cmp r0, r1
|
||||
beq _08092C40
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
adds r2, r4, 0
|
||||
adds r3, r7, 0
|
||||
bl IsMetatileDirectionallyImpassable
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08092C40
|
||||
ldrb r0, [r6, 0x1]
|
||||
lsrs r0, 7
|
||||
cmp r0, 0
|
||||
beq _08092C44
|
||||
mov r0, r8
|
||||
bl CanCameraMoveInDirection
|
||||
cmp r0, 0
|
||||
bne _08092C44
|
||||
_08092C40:
|
||||
movs r0, 0x2
|
||||
b _08092C7E
|
||||
_08092C44:
|
||||
ldrb r0, [r6, 0xB]
|
||||
lsls r0, 28
|
||||
lsrs r0, 28
|
||||
mov r2, r9
|
||||
lsls r1, r2, 16
|
||||
asrs r5, r1, 16
|
||||
mov r2, r10
|
||||
lsls r1, r2, 16
|
||||
asrs r4, r1, 16
|
||||
adds r1, r5, 0
|
||||
adds r2, r4, 0
|
||||
bl IsZCoordMismatchAt
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _08092C68
|
||||
movs r0, 0x3
|
||||
b _08092C7E
|
||||
_08092C68:
|
||||
adds r0, r6, 0
|
||||
adds r1, r5, 0
|
||||
adds r2, r4, 0
|
||||
bl CheckForCollisionBetweenFieldObjects
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08092C7C
|
||||
movs r0, 0
|
||||
b _08092C7E
|
||||
_08092C7C:
|
||||
movs r0, 0x4
|
||||
_08092C7E:
|
||||
pop {r3-r5}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
mov r10, r5
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end npc_block_way
|
||||
|
||||
thumb_func_start sub_8092C8C
|
||||
sub_8092C8C: @ 8092C8C
|
||||
push {r4-r7,lr}
|
||||
|
@ -12,5 +12,6 @@
|
||||
// Exported ROM declarations
|
||||
void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8);
|
||||
void InitObjectPriorityByZCoord(struct Sprite *, u8);
|
||||
bool8 IsZCoordMismatchAt(u8, s16, s16);
|
||||
|
||||
#endif //GUARD_FIELD_GROUND_EFFECT_H
|
||||
|
@ -12,5 +12,8 @@
|
||||
// Exported ROM declarations
|
||||
u8 MapGridGetMetatileBehaviorAt(s16, s16);
|
||||
void GetCameraCoords(u16*, u16*);
|
||||
bool8 MapGridIsImpassableAt(s16, s16);
|
||||
s32 GetMapBorderIdAt(s16, s16);
|
||||
bool32 CanCameraMoveInDirection(u8);
|
||||
|
||||
#endif //GUARD_FIELDMAP_H
|
||||
|
@ -121,6 +121,10 @@ void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *);
|
||||
void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *);
|
||||
void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *);
|
||||
|
||||
bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *fieldObject, s16 x, s16 y);
|
||||
bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8);
|
||||
bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16);
|
||||
|
||||
// ROM data
|
||||
|
||||
void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *);
|
||||
@ -3637,7 +3641,7 @@ void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern)
|
||||
|
||||
dirn2anim(npc_running_behaviour_by_direction, gUnknown_0850DB53)
|
||||
|
||||
bool8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction)
|
||||
u8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction)
|
||||
{
|
||||
s16 x;
|
||||
s16 y;
|
||||
@ -3648,6 +3652,24 @@ bool8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction)
|
||||
return npc_block_way(mapObject, x, y, direction);
|
||||
}
|
||||
|
||||
u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = dirn;
|
||||
if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y))
|
||||
return 1;
|
||||
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction))
|
||||
return 2;
|
||||
else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction))
|
||||
return 2;
|
||||
else if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y))
|
||||
return 3;
|
||||
else if (CheckForCollisionBetweenFieldObjects(mapObject, x, y))
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
asm(".section .text.get_face_direction_anim_id");
|
||||
|
||||
void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *);
|
||||
|
Loading…
Reference in New Issue
Block a user