made file better ?

This commit is contained in:
MCboy 2018-07-25 17:18:49 +04:30 committed by GitHub
parent 1b3d7a5bef
commit 94a5f8d529
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -162,9 +162,18 @@ void player_step(u8 direction, u16 newKeys, u16 heldKeys)
} }
} }
} }
#ifdef NONMATCHING
bool8 TryInterruptEventObjectSpecialAnim(struct EventObject *playerEventObj, u8 direction) bool8 TryInterruptEventObjectSpecialAnim(struct EventObject *playerEventObj, u8 direction)
{ {
#ifdef NONMATCHING
u8 r5 = direction;
u8 r6 = direction;
#else
u8 r5 = direction;
register u8 r6 asm("r6") = direction;
#endif
//a very bad HACK
if (EventObjectIsMovementOverridden(playerEventObj) if (EventObjectIsMovementOverridden(playerEventObj)
&& !EventObjectClearHeldMovementIfFinished(playerEventObj)) && !EventObjectClearHeldMovementIfFinished(playerEventObj))
{ {
@ -172,87 +181,28 @@ bool8 TryInterruptEventObjectSpecialAnim(struct EventObject *playerEventObj, u8
if (heldMovementActionId > 24 && heldMovementActionId < 29) if (heldMovementActionId > 24 && heldMovementActionId < 29)
{ {
if (direction == DIR_NONE) if (direction == DIR_NONE)
{
EventObjectClearHeldMovement(playerEventObj);
return FALSE;
}
else if(playerEventObj->movementDirection != direction)
{ {
return TRUE; return TRUE;
} }
else if(sub_808B028(direction) == FALSE)
if (playerEventObj->movementDirection != r5)
{ {
EventObjectClearHeldMovement(playerEventObj); EventObjectClearHeldMovement(playerEventObj);
return FALSE; return FALSE;
} }
else
if (!sub_808B028(r6))
{ {
return TRUE; EventObjectClearHeldMovement(playerEventObj);
}
}
else
{
return TRUE;
}
}
return FALSE; return FALSE;
} }
#else
NAKED
bool8 TryInterruptEventObjectSpecialAnim(struct EventObject *playerEventObj, u8 direction)
{
asm_unified("push {r4-r6,lr}\n\
adds r4, r0, 0\n\
lsls r1, 24\n\
lsrs r5, r1, 24\n\
adds r6, r5, 0\n\
bl EventObjectIsMovementOverridden\n\
lsls r0, 24\n\
cmp r0, 0\n\
beq _0808AA92\n\
adds r0, r4, 0\n\
bl EventObjectClearHeldMovementIfFinished\n\
lsls r0, 24\n\
cmp r0, 0\n\
bne _0808AA92\n\
adds r0, r4, 0\n\
bl EventObjectGetHeldMovementActionId\n\
lsls r0, 24\n\
movs r1, 0xE7\n\
lsls r1, 24\n\
adds r0, r1\n\
lsrs r0, 24\n\
cmp r0, 0x3\n\
bhi _0808AA70\n\
cmp r5, 0\n\
bne _0808AA74\n\
_0808AA70:\n\
movs r0, 0x1\n\
b _0808AA94\n\
_0808AA74:\n\
ldrb r0, [r4, 0x18]\n\
lsrs r0, 4\n\
cmp r0, r5\n\
beq _0808AA84\n\
_0808AA7C:\n\
adds r0, r4, 0\n\
bl EventObjectClearHeldMovement\n\
b _0808AA92\n\
_0808AA84:\n\
adds r0, r6, 0\n\
bl sub_808B028\n\
lsls r0, 24\n\
cmp r0, 0\n\
beq _0808AA7C\n\
b _0808AA70\n\
_0808AA92:\n\
movs r0, 0\n\
_0808AA94:\n\
pop {r4-r6}\n\
pop {r1}\n\
bx r1");
} }
#endif
return TRUE;
}
return FALSE;
}
void npc_clear_strange_bits(struct EventObject *eventObj) void npc_clear_strange_bits(struct EventObject *eventObj)
{ {
@ -605,20 +555,20 @@ bool8 sub_808B1BC(s16 x, s16 y, u8 direction)
&& GetEventObjectIdByXYZ(x, y, 3) == 16) && GetEventObjectIdByXYZ(x, y, 3) == 16)
{ {
sub_808C750(direction); sub_808C750(direction);
return 1; return TRUE;
} }
else else
{ {
return 0; return FALSE;
} }
} }
bool8 ShouldJumpLedge(s16 x, s16 y, u8 z) bool8 ShouldJumpLedge(s16 x, s16 y, u8 z)
{ {
if (GetLedgeJumpDirection(x, y, z) != 0) if (GetLedgeJumpDirection(x, y, z) != 0)
return 1; return TRUE;
else else
return 0; return FALSE;
} }
u8 sub_808B238(s16 x, s16 y, u8 direction) u8 sub_808B238(s16 x, s16 y, u8 direction)