FieldObjectTurn

This commit is contained in:
PikalaxALT 2017-09-08 13:41:55 -04:00
parent ad99377734
commit ddcce8c3bc
3 changed files with 23 additions and 77 deletions

View File

@ -5,82 +5,6 @@
.text
thumb_func_start FieldObjectTurn
@ void FieldObjectTurn(struct npc_state *fieldObject, u8 direction)
FieldObjectTurn: @ 808E544
push {r4-r6,lr}
adds r6, r0, 0
lsls r1, 24
lsrs r1, 24
bl FieldObjectSetDirection
ldrb r0, [r6, 0x1]
lsls r0, 27
cmp r0, 0
blt _0808E58A
ldrb r0, [r6, 0x4]
lsls r4, r0, 4
adds r4, r0
lsls r4, 2
ldr r5, =gSprites
adds r4, r5
ldrb r0, [r6, 0x18]
lsls r0, 28
lsrs r0, 28
bl FieldObjectDirectionToImageAnimId
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
bl StartSpriteAnim
ldrb r1, [r6, 0x4]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r5
movs r1, 0
bl SeekSpriteAnim
_0808E58A:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end FieldObjectTurn
thumb_func_start FieldObjectTurnByLocalIdAndMap
@ void FieldObjectTurnByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId)
FieldObjectTurnByLocalIdAndMap: @ 808E594
push {r4,lr}
sub sp, 0x4
lsls r0, 24
lsrs r0, 24
lsls r1, 24
lsrs r1, 24
lsls r2, 24
lsrs r2, 24
lsls r3, 24
lsrs r4, r3, 24
mov r3, sp
bl TryGetFieldObjectIdByLocalIdAndMap
lsls r0, 24
cmp r0, 0
bne _0808E5C8
mov r0, sp
ldrb r1, [r0]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r1, =gMapObjects
adds r0, r1
adds r1, r4, 0
bl FieldObjectTurn
_0808E5C8:
add sp, 0x4
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end FieldObjectTurnByLocalIdAndMap
thumb_func_start sub_808E5D4
sub_808E5D4: @ 808E5D4
push {lr}

View File

@ -34,6 +34,8 @@ u8 SpawnSpecialFieldObject(struct MapObjectTemplate *);
void sub_8093038(s16, s16, s16 *, s16 *);
void CameraObjectReset1(void);
void FieldObjectSetGraphicsId(struct MapObject *, u8);
void FieldObjectTurn(struct MapObject *, u8);
void FieldObjectTurnByLocalIdAndMap(u8, u8, u8);
// Exported data declarations

View File

@ -944,7 +944,7 @@ void FieldObjectSetGraphicsId(struct MapObject *mapObject, u8 graphicsId)
}
}
void unref_sub_808E504(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId)
void FieldObjectSetGraphicsIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId)
{
u8 mapObjectId;
@ -953,3 +953,23 @@ void unref_sub_808E504(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId)
FieldObjectSetGraphicsId(&gMapObjects[mapObjectId], graphicsId);
}
}
void FieldObjectTurn(struct MapObject *mapObject, u8 direction)
{
FieldObjectSetDirection(mapObject, direction);
if (!mapObject->mapobj_bit_12)
{
StartSpriteAnim(&gSprites[mapObject->spriteId], FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18));
SeekSpriteAnim(&gSprites[mapObject->spriteId], 0);
}
}
void FieldObjectTurnByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 direction)
{
u8 mapObjectId;
if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId))
{
FieldObjectTurn(&gMapObjects[mapObjectId], direction);
}
}