mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-18 01:14:19 +01:00
sub_808F8BC
This commit is contained in:
parent
c1f5183f40
commit
ddf712beac
@ -5,78 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_808F8BC
|
||||
sub_808F8BC: @ 808F8BC
|
||||
push {r4-r6,lr}
|
||||
sub sp, 0x4
|
||||
adds r4, r0, 0
|
||||
lsls r1, 24
|
||||
lsrs r6, r1, 24
|
||||
bl FieldObjectIsTrainerAndCloseToPlayer
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _0808F8D4
|
||||
movs r0, 0
|
||||
b _0808F938
|
||||
_0808F8D4:
|
||||
mov r5, sp
|
||||
adds r5, 0x2
|
||||
mov r0, sp
|
||||
adds r1, r5, 0
|
||||
bl PlayerGetDestCoords
|
||||
mov r2, sp
|
||||
mov r0, sp
|
||||
ldrh r0, [r0]
|
||||
ldrh r1, [r4, 0x10]
|
||||
subs r0, r1
|
||||
strh r0, [r2]
|
||||
ldrh r0, [r5]
|
||||
ldrh r1, [r4, 0x12]
|
||||
subs r0, r1
|
||||
strh r0, [r5]
|
||||
mov r0, sp
|
||||
ldrh r3, [r5]
|
||||
ldrh r2, [r0]
|
||||
movs r1, 0
|
||||
ldrsh r0, [r0, r1]
|
||||
cmp r0, 0
|
||||
bge _0808F908
|
||||
negs r0, r0
|
||||
lsls r0, 16
|
||||
lsrs r2, r0, 16
|
||||
_0808F908:
|
||||
lsls r0, r3, 16
|
||||
asrs r0, 16
|
||||
cmp r0, 0
|
||||
bge _0808F916
|
||||
negs r0, r0
|
||||
lsls r0, 16
|
||||
lsrs r3, r0, 16
|
||||
_0808F916:
|
||||
ldr r0, =gUnknown_0850D714
|
||||
lsls r4, r6, 2
|
||||
adds r4, r0
|
||||
mov r0, sp
|
||||
movs r6, 0
|
||||
ldrsh r0, [r0, r6]
|
||||
movs r6, 0
|
||||
ldrsh r1, [r5, r6]
|
||||
lsls r2, 16
|
||||
asrs r2, 16
|
||||
lsls r3, 16
|
||||
asrs r3, 16
|
||||
ldr r4, [r4]
|
||||
bl _call_via_r4
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
_0808F938:
|
||||
add sp, 0x4
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_808F8BC
|
||||
|
||||
thumb_func_start FieldObjectCB_LookRandomDirections
|
||||
FieldObjectCB_LookRandomDirections: @ 808F944
|
||||
push {lr}
|
||||
|
@ -93,6 +93,7 @@ const u8 gUnknown_0850557C[NUM_FIELD_MAP_OBJECT_TEMPLATES];
|
||||
const u8 gUnknown_085055CD[NUM_FIELD_MAP_OBJECT_TEMPLATES];
|
||||
const struct MapObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[7];
|
||||
const struct MapObjectGraphicsInfo *const gFieldObjectGraphicsInfoPointers[0xEF];
|
||||
u8 (*const gUnknown_0850D714[11])(s16, s16, s16, s16);
|
||||
|
||||
// Code
|
||||
|
||||
@ -1833,14 +1834,14 @@ bool8 FieldObjectIsTrainerAndCloseToPlayer(struct MapObject *mapObject)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u8 GetRegularRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetRegularRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
if (dx2 > dy2)
|
||||
if (absdx > absdy)
|
||||
{
|
||||
direction = DIR_EAST;
|
||||
if (dx1 < 0)
|
||||
if (dx < 0)
|
||||
{
|
||||
direction = DIR_WEST;
|
||||
}
|
||||
@ -1848,7 +1849,7 @@ u8 GetRegularRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
else
|
||||
{
|
||||
direction = DIR_SOUTH;
|
||||
if (dy1 < 0)
|
||||
if (dy < 0)
|
||||
{
|
||||
direction = DIR_NORTH;
|
||||
}
|
||||
@ -1856,38 +1857,38 @@ u8 GetRegularRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetNorthSouthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetNorthSouthRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = DIR_SOUTH;
|
||||
if (dy1 < 0)
|
||||
if (dy < 0)
|
||||
{
|
||||
direction = DIR_NORTH;
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetEastWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetEastWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = DIR_EAST;
|
||||
if (dx1 < 0)
|
||||
if (dx < 0)
|
||||
{
|
||||
direction = DIR_WEST;
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetNorthEastRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_SOUTH)
|
||||
{
|
||||
direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_EAST)
|
||||
{
|
||||
direction = DIR_NORTH;
|
||||
@ -1895,7 +1896,7 @@ u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
}
|
||||
else if (direction == DIR_EAST)
|
||||
{
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_SOUTH)
|
||||
{
|
||||
direction = DIR_NORTH;
|
||||
@ -1904,14 +1905,14 @@ u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetNorthWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_SOUTH)
|
||||
{
|
||||
direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_WEST)
|
||||
{
|
||||
direction = DIR_NORTH;
|
||||
@ -1919,7 +1920,7 @@ u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
}
|
||||
else if (direction == DIR_WEST)
|
||||
{
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_SOUTH)
|
||||
{
|
||||
direction = DIR_NORTH;
|
||||
@ -1928,14 +1929,14 @@ u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetSouthEastRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_NORTH)
|
||||
{
|
||||
direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_EAST)
|
||||
{
|
||||
direction = DIR_SOUTH;
|
||||
@ -1943,7 +1944,7 @@ u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
}
|
||||
else if (direction == DIR_EAST)
|
||||
{
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_NORTH)
|
||||
{
|
||||
direction = DIR_SOUTH;
|
||||
@ -1952,14 +1953,14 @@ u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetSouthWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_NORTH)
|
||||
{
|
||||
direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_WEST)
|
||||
{
|
||||
direction = DIR_SOUTH;
|
||||
@ -1967,7 +1968,7 @@ u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
}
|
||||
else if (direction == DIR_WEST)
|
||||
{
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_NORTH)
|
||||
{
|
||||
direction = DIR_SOUTH;
|
||||
@ -1976,50 +1977,77 @@ u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetNonEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetNonEastRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_EAST)
|
||||
{
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetNonWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetNonWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_WEST)
|
||||
{
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetNonSouthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetNonSouthRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_SOUTH)
|
||||
{
|
||||
direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 GetNonNorthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2)
|
||||
u8 GetNonNorthRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
||||
{
|
||||
u8 direction;
|
||||
|
||||
direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
if (direction == DIR_NORTH)
|
||||
{
|
||||
direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2);
|
||||
direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy);
|
||||
}
|
||||
return direction;
|
||||
}
|
||||
|
||||
u8 sub_808F8BC(struct MapObject *mapObject, u8 movementType)
|
||||
{
|
||||
s16 dx;
|
||||
s16 dy;
|
||||
s16 absdx;
|
||||
s16 absdy;
|
||||
|
||||
if (!FieldObjectIsTrainerAndCloseToPlayer(mapObject))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
PlayerGetDestCoords(&dx, &dy);
|
||||
dx -= mapObject->coords2.x;
|
||||
dy -= mapObject->coords2.y;
|
||||
absdx = dx;
|
||||
absdy = dy;
|
||||
if (absdx < 0)
|
||||
{
|
||||
absdx = -absdx;
|
||||
}
|
||||
if (absdy < 0)
|
||||
{
|
||||
absdy = -absdy;
|
||||
}
|
||||
return gUnknown_0850D714[movementType](dx, dy, absdx, absdy);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user