mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Some more functions, including some swiss-cheesing that got out of hand
This commit is contained in:
parent
86df6d1073
commit
ee3dc1edda
@ -5,175 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start FieldObjectCB_CopyPlayer1
|
||||
FieldObjectCB_CopyPlayer1: @ 8091E58
|
||||
push {lr}
|
||||
adds r1, r0, 0
|
||||
movs r0, 0x2E
|
||||
ldrsh r2, [r1, r0]
|
||||
lsls r0, r2, 3
|
||||
adds r0, r2
|
||||
lsls r0, 2
|
||||
ldr r2, =gMapObjects
|
||||
adds r0, r2
|
||||
ldr r2, =sub_8091E7C
|
||||
bl FieldObjectStep
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end FieldObjectCB_CopyPlayer1
|
||||
|
||||
thumb_func_start sub_8091E7C
|
||||
sub_8091E7C: @ 8091E7C
|
||||
push {r4,lr}
|
||||
ldr r3, =gUnknown_0850DA58
|
||||
movs r4, 0x30
|
||||
ldrsh r2, [r1, r4]
|
||||
lsls r2, 2
|
||||
adds r2, r3
|
||||
ldr r2, [r2]
|
||||
bl _call_via_r2
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8091E7C
|
||||
|
||||
thumb_func_start mss_npc_reset_oampriv3_1_unk2_unk3
|
||||
@ bool8 mss_npc_reset_oampriv3_1_unk2_unk3(struct npc_state *fieldObject, struct obj *object)
|
||||
mss_npc_reset_oampriv3_1_unk2_unk3: @ 8091E9C
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
adds r5, r1, 0
|
||||
bl npc_reset
|
||||
adds r4, 0x21
|
||||
ldrb r0, [r4]
|
||||
cmp r0, 0
|
||||
bne _08091EB4
|
||||
bl player_get_direction_lower_nybble
|
||||
strb r0, [r4]
|
||||
_08091EB4:
|
||||
movs r0, 0x1
|
||||
strh r0, [r5, 0x30]
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end mss_npc_reset_oampriv3_1_unk2_unk3
|
||||
|
||||
thumb_func_start sub_8091EC0
|
||||
@ bool8 sub_8091EC0(struct npc_state *fieldObject, struct obj *object)
|
||||
sub_8091EC0: @ 8091EC0
|
||||
push {r4-r7,lr}
|
||||
adds r6, r0, 0
|
||||
adds r7, r1, 0
|
||||
ldr r2, =gMapObjects
|
||||
ldr r3, =gPlayerAvatar
|
||||
ldrb r1, [r3, 0x5]
|
||||
lsls r0, r1, 3
|
||||
adds r0, r1
|
||||
lsls r0, 2
|
||||
adds r0, r2
|
||||
ldrb r0, [r0, 0x1C]
|
||||
cmp r0, 0xFF
|
||||
beq _08091EE0
|
||||
ldrb r0, [r3, 0x3]
|
||||
cmp r0, 0x2
|
||||
bne _08091EEC
|
||||
_08091EE0:
|
||||
movs r0, 0
|
||||
b _08091F14
|
||||
.pool
|
||||
_08091EEC:
|
||||
ldr r5, =gUnknown_0850DA64
|
||||
bl player_get_x22
|
||||
adds r4, r0, 0
|
||||
lsls r4, 24
|
||||
lsrs r4, 22
|
||||
adds r4, r5
|
||||
bl player_get_direction_upper_nybble
|
||||
adds r2, r0, 0
|
||||
lsls r2, 24
|
||||
lsrs r2, 24
|
||||
ldr r4, [r4]
|
||||
adds r0, r6, 0
|
||||
adds r1, r7, 0
|
||||
movs r3, 0
|
||||
bl _call_via_r4
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
_08091F14:
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8091EC0
|
||||
|
||||
thumb_func_start sub_8091F20
|
||||
sub_8091F20: @ 8091F20
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
adds r5, r1, 0
|
||||
bl FieldObjectExecRegularAnim
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _08091F3E
|
||||
ldrb r0, [r4]
|
||||
movs r1, 0x3
|
||||
negs r1, r1
|
||||
ands r1, r0
|
||||
strb r1, [r4]
|
||||
movs r0, 0x1
|
||||
strh r0, [r5, 0x30]
|
||||
_08091F3E:
|
||||
movs r0, 0
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8091F20
|
||||
|
||||
thumb_func_start sub_8091F48
|
||||
sub_8091F48: @ 8091F48
|
||||
movs r0, 0
|
||||
bx lr
|
||||
thumb_func_end sub_8091F48
|
||||
|
||||
thumb_func_start sub_8091F4C
|
||||
sub_8091F4C: @ 8091F4C
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
adds r5, r1, 0
|
||||
lsls r2, 24
|
||||
lsrs r2, 24
|
||||
ldr r1, =gUnknown_085055CD
|
||||
ldrb r0, [r4, 0x6]
|
||||
adds r0, r1
|
||||
ldrb r0, [r0]
|
||||
adds r1, r4, 0
|
||||
adds r1, 0x21
|
||||
ldrb r1, [r1]
|
||||
bl state_to_direction
|
||||
bl GetFaceDirectionAnimId
|
||||
adds r2, r0, 0
|
||||
lsls r2, 24
|
||||
lsrs r2, 24
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl FieldObjectSetRegularAnim
|
||||
ldrb r0, [r4]
|
||||
movs r1, 0x2
|
||||
orrs r0, r1
|
||||
strb r0, [r4]
|
||||
movs r0, 0x2
|
||||
strh r0, [r5, 0x30]
|
||||
movs r0, 0x1
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8091F4C
|
||||
|
||||
thumb_func_start sub_8091F94
|
||||
sub_8091F94: @ 8091F94
|
||||
push {r4-r7,lr}
|
||||
@ -2742,139 +2573,7 @@ FieldObjectClearAnim: @ 809323C
|
||||
.pool
|
||||
thumb_func_end FieldObjectClearAnim
|
||||
|
||||
thumb_func_start FieldObjectCheckIfSpecialAnimFinishedOrInactive
|
||||
@ u8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct npc_state *fieldObject)
|
||||
FieldObjectCheckIfSpecialAnimFinishedOrInactive: @ 8093270
|
||||
push {lr}
|
||||
ldrb r1, [r0]
|
||||
lsls r0, r1, 25
|
||||
cmp r0, 0
|
||||
blt _0809327E
|
||||
movs r0, 0x10
|
||||
b _08093280
|
||||
_0809327E:
|
||||
lsrs r0, r1, 7
|
||||
_08093280:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end FieldObjectCheckIfSpecialAnimFinishedOrInactive
|
||||
|
||||
thumb_func_start FieldObjectClearAnimIfSpecialAnimFinished
|
||||
@ u8 FieldObjectClearAnimIfSpecialAnimFinished(struct npc_state *fieldObject)
|
||||
FieldObjectClearAnimIfSpecialAnimFinished: @ 8093284
|
||||
push {r4,r5,lr}
|
||||
adds r5, r0, 0
|
||||
bl FieldObjectCheckIfSpecialAnimFinishedOrInactive
|
||||
lsls r0, 24
|
||||
lsrs r4, r0, 24
|
||||
cmp r4, 0
|
||||
beq _0809329E
|
||||
cmp r4, 0x10
|
||||
beq _0809329E
|
||||
adds r0, r5, 0
|
||||
bl FieldObjectClearAnimIfSpecialAnimActive
|
||||
_0809329E:
|
||||
adds r0, r4, 0
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end FieldObjectClearAnimIfSpecialAnimFinished
|
||||
|
||||
thumb_func_start FieldObjectGetSpecialAnim
|
||||
@ u8 FieldObjectGetSpecialAnim(struct npc_state *fieldObject)
|
||||
FieldObjectGetSpecialAnim: @ 80932A8
|
||||
push {lr}
|
||||
adds r1, r0, 0
|
||||
ldrb r0, [r1]
|
||||
lsls r0, 25
|
||||
cmp r0, 0
|
||||
blt _080932B8
|
||||
movs r0, 0xFF
|
||||
b _080932BA
|
||||
_080932B8:
|
||||
ldrb r0, [r1, 0x1C]
|
||||
_080932BA:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end FieldObjectGetSpecialAnim
|
||||
|
||||
thumb_func_start FieldObjectStep
|
||||
@ void FieldObjectStep(struct npc_state *fieldObject, struct obj *object, bool8 ( *callback)(struct npc_state *fieldObject, struct obj *object))
|
||||
FieldObjectStep: @ 80932C0
|
||||
push {r4-r6,lr}
|
||||
adds r4, r0, 0
|
||||
adds r5, r1, 0
|
||||
adds r6, r2, 0
|
||||
bl DoGroundEffects_OnSpawn
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl sub_80964E8
|
||||
adds r0, r4, 0
|
||||
bl FieldObjectIsSpecialAnimActive
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _080932EA
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl FieldObjectExecSpecialAnim
|
||||
b _08093300
|
||||
_080932EA:
|
||||
ldrb r0, [r4, 0x1]
|
||||
lsls r0, 31
|
||||
cmp r0, 0
|
||||
bne _08093300
|
||||
_080932F2:
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl _call_via_r6
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _080932F2
|
||||
_08093300:
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl DoGroundEffects_OnBeginStep
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl DoGroundEffects_OnFinishStep
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl npc_obj_transfer_image_anim_pause_flag
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl sub_8096518
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl FieldObjectUpdateSubpriority
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end FieldObjectStep
|
||||
|
||||
thumb_func_start GetFaceDirectionAnimId
|
||||
@ u8 GetFaceDirectionAnimId(u8 direction)
|
||||
GetFaceDirectionAnimId: @ 8093330
|
||||
push {r4,lr}
|
||||
sub sp, 0x8
|
||||
lsls r0, 24
|
||||
lsrs r4, r0, 24
|
||||
ldr r1, =gUnknown_0850DBA0
|
||||
mov r0, sp
|
||||
movs r2, 0x5
|
||||
bl memcpy
|
||||
cmp r4, 0x4
|
||||
bls _08093348
|
||||
movs r4, 0
|
||||
_08093348:
|
||||
mov r1, sp
|
||||
adds r0, r1, r4
|
||||
ldrb r0, [r0]
|
||||
add sp, 0x8
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end GetFaceDirectionAnimId
|
||||
.section .text.get_simple_go_anim_id
|
||||
|
||||
thumb_func_start GetSimpleGoAnimId
|
||||
@ u8 GetSimpleGoAnimId(u8 direction)
|
||||
|
@ -33,5 +33,9 @@ extern const u8 gUnknown_0850D898[4];
|
||||
extern const u8 gUnknown_0850D8AC[5];
|
||||
extern const u8 gUnknown_0850D8C4[5];
|
||||
extern const u8 gUnknown_0850D8E8[4];
|
||||
extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, u8);
|
||||
|
||||
|
||||
extern const u8 gUnknown_0850DBA0[5];
|
||||
|
||||
#endif //POKEEMERALD_DATA3_H
|
||||
|
@ -10,5 +10,8 @@ void SetPlayerAvatarExtraStateTransition(u8, u8);
|
||||
u8 GetPlayerAvatarGenderByGraphicsId(u8);
|
||||
bool8 TestPlayerAvatarFlags(u8);
|
||||
void PlayerGetDestCoords(s16 *, s16 *);
|
||||
u8 player_get_direction_lower_nybble(void);
|
||||
u8 player_get_direction_upper_nybble(void);
|
||||
u8 player_get_x22(void);
|
||||
|
||||
#endif //POKEEMERALD_FIELD_PLAYER_AVATAR_H
|
||||
|
@ -95,6 +95,8 @@ SECTIONS {
|
||||
asm/field_player_avatar.o(.text);
|
||||
src/field_map_obj.o(.text);
|
||||
asm/field_map_obj.o(.text);
|
||||
src/field_map_obj.o(.text.get_face_direction_anim_id);
|
||||
asm/field_map_obj.o(.text.get_simple_go_anim_id);
|
||||
asm/field_ground_effect.o(.text);
|
||||
asm/map_obj_8097404.o(.text);
|
||||
asm/field_message_box.o(.text);
|
||||
|
@ -94,12 +94,21 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8);
|
||||
/*static*/ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count);
|
||||
void npc_reset(struct MapObject *, struct Sprite *);
|
||||
void FieldObjectSetRegularAnim(struct MapObject *, struct Sprite *, u8);
|
||||
u8 GetFaceDirectionAnimId(u8);
|
||||
u8 GetFaceDirectionAnimId(u32);
|
||||
bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *);
|
||||
void SetFieldObjectStepTimer(struct Sprite *, s16);
|
||||
bool8 RunFieldObjectStepTimer(struct Sprite *);
|
||||
bool8 npc_block_way__next_tile(struct MapObject *, u8);
|
||||
u8 GetGoSpeed0AnimId(u8);
|
||||
u32 state_to_direction(u8, u8, u8);
|
||||
void DoGroundEffects_OnSpawn(struct MapObject *, struct Sprite *);
|
||||
void sub_80964E8(struct MapObject *, struct Sprite *);
|
||||
bool8 FieldObjectIsSpecialAnimActive(struct MapObject *);
|
||||
void FieldObjectExecSpecialAnim(struct MapObject *, struct Sprite *);
|
||||
void DoGroundEffects_OnBeginStep(struct MapObject *, struct Sprite *);
|
||||
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 *);
|
||||
|
||||
// ROM data
|
||||
|
||||
@ -3147,3 +3156,115 @@ field_object_path(21, gUnknown_0850DA18, sub_8091C6C, gUnknown_0850DA24, 2, y)
|
||||
field_object_path(22, gUnknown_0850DA28, sub_8091CF8, gUnknown_0850DA34, 2, y)
|
||||
field_object_path(23, gUnknown_0850DA38, sub_8091D84, gUnknown_0850DA44, 2, x)
|
||||
field_object_path(24, gUnknown_0850DA48, sub_8091E10, gUnknown_0850DA54, 2, x)
|
||||
|
||||
field_object_step(CopyPlayer1, gUnknown_0850DA58)
|
||||
|
||||
bool8 mss_npc_reset_oampriv3_1_unk2_unk3(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
npc_reset(mapObject, sprite);
|
||||
if (mapObject->mapobj_unk_21 == 0)
|
||||
{
|
||||
mapObject->mapobj_unk_21 = player_get_direction_lower_nybble();
|
||||
}
|
||||
sprite->data1 = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_8091EC0(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return gUnknown_0850DA64[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), 0);
|
||||
}
|
||||
|
||||
bool8 sub_8091F20(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
if (FieldObjectExecRegularAnim(mapObject, sprite))
|
||||
{
|
||||
mapObject->mapobj_bit_1 = FALSE;
|
||||
sprite->data1 = 1;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 sub_8091F48(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, u8 a3)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 sub_8091F4C(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, u8 a3)
|
||||
{
|
||||
FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, playerDirection)));
|
||||
mapObject->mapobj_bit_1 = TRUE;
|
||||
sprite->data1 = 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
asm(".section .text.get_face_direction_anim_id");
|
||||
|
||||
void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *);
|
||||
|
||||
u8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct MapObject *mapObject)
|
||||
{
|
||||
if (mapObject->mapobj_bit_6)
|
||||
{
|
||||
return mapObject->mapobj_bit_7;
|
||||
}
|
||||
return 0x10;
|
||||
}
|
||||
|
||||
u8 FieldObjectClearAnimIfSpecialAnimFinished(struct MapObject *mapObject)
|
||||
{
|
||||
u8 specialAnimState;
|
||||
|
||||
specialAnimState = FieldObjectCheckIfSpecialAnimFinishedOrInactive(mapObject);
|
||||
if (specialAnimState != 0 && specialAnimState != 16)
|
||||
{
|
||||
FieldObjectClearAnimIfSpecialAnimActive(mapObject);
|
||||
}
|
||||
return specialAnimState;
|
||||
}
|
||||
|
||||
u8 FieldObjectGetSpecialAnim(struct MapObject *mapObject)
|
||||
{
|
||||
if (mapObject->mapobj_bit_6)
|
||||
{
|
||||
return mapObject->mapobj_unk_1C;
|
||||
}
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void FieldObjectStep(struct MapObject *mapObject, struct Sprite *sprite, bool8 (*callback)(struct MapObject *, struct Sprite *))
|
||||
{
|
||||
DoGroundEffects_OnSpawn(mapObject, sprite);
|
||||
sub_80964E8(mapObject, sprite);
|
||||
if (FieldObjectIsSpecialAnimActive(mapObject))
|
||||
{
|
||||
FieldObjectExecSpecialAnim(mapObject, sprite);
|
||||
}
|
||||
else if (!mapObject->mapobj_bit_8)
|
||||
{
|
||||
while (callback(mapObject, sprite));
|
||||
}
|
||||
DoGroundEffects_OnBeginStep(mapObject, sprite);
|
||||
DoGroundEffects_OnFinishStep(mapObject, sprite);
|
||||
npc_obj_transfer_image_anim_pause_flag(mapObject, sprite);
|
||||
sub_8096518(mapObject, sprite);
|
||||
FieldObjectUpdateSubpriority(mapObject, sprite);
|
||||
}
|
||||
|
||||
u8 GetFaceDirectionAnimId(u32 direction)
|
||||
{
|
||||
u8 dirn2;
|
||||
u8 animIds[sizeof gUnknown_0850DBA0];
|
||||
|
||||
dirn2 = direction;
|
||||
memcpy(animIds, gUnknown_0850DBA0, sizeof gUnknown_0850DBA0);
|
||||
if (dirn2 > DIR_EAST)
|
||||
{
|
||||
dirn2 = 0;
|
||||
}
|
||||
return animIds[dirn2];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user