From fa436fca4dd0878eb1fdd905dec48e8c2cd310d2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 17:41:46 -0400 Subject: [PATCH] a block of direction-based anim num fns --- asm/field_map_obj.s | 186 -------------------------------------------- src/field_map_obj.c | 36 ++++++++- 2 files changed, 34 insertions(+), 188 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8ea5a8b76..0a043682b 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,192 +5,6 @@ .text - thumb_func_start npc_reset -@ void npc_reset(struct npc_state *fieldObject, struct obj *object) -npc_reset: @ 809293C - ldrb r3, [r0] - movs r2, 0x3 - negs r2, r2 - ands r2, r3 - movs r3, 0x41 - negs r3, r3 - ands r2, r3 - movs r3, 0x7F - ands r2, r3 - strb r2, [r0] - movs r2, 0xFF - strb r2, [r0, 0x1C] - movs r0, 0 - strh r0, [r1, 0x30] - bx lr - thumb_func_end npc_reset - - thumb_func_start FieldObjectDirectionToImageAnimId -@ u8 FieldObjectDirectionToImageAnimId(u8 direction) -FieldObjectDirectionToImageAnimId: @ 809295C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DACC - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end FieldObjectDirectionToImageAnimId - - thumb_func_start get_go_image_anim_num -get_go_image_anim_num: @ 809296C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAD5 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_image_anim_num - - thumb_func_start get_go_fast_image_anim_num -get_go_fast_image_anim_num: @ 809297C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DADE - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_fast_image_anim_num - - thumb_func_start get_go_faster_image_anim_num -get_go_faster_image_anim_num: @ 809298C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAE7 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_faster_image_anim_num - - thumb_func_start get_go_fastest_image_anim_num -get_go_fastest_image_anim_num: @ 809299C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAF0 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_fastest_image_anim_num - - thumb_func_start sub_80929AC -sub_80929AC: @ 80929AC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAF9 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929AC - - thumb_func_start sub_80929BC -sub_80929BC: @ 80929BC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB02 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929BC - - thumb_func_start sub_80929CC -sub_80929CC: @ 80929CC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB0B - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929CC - - thumb_func_start sub_80929DC -sub_80929DC: @ 80929DC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB14 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929DC - - thumb_func_start sub_80929EC -sub_80929EC: @ 80929EC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB1D - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929EC - - thumb_func_start sub_80929FC -sub_80929FC: @ 80929FC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB26 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929FC - - thumb_func_start sub_8092A0C -sub_8092A0C: @ 8092A0C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB2F - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_8092A0C - - thumb_func_start sub_8092A1C -sub_8092A1C: @ 8092A1C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB38 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_8092A1C - - thumb_func_start sub_8092A2C -sub_8092A2C: @ 8092A2C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB41 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_8092A2C - - thumb_func_start get_run_image_anim_num -get_run_image_anim_num: @ 8092A3C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB4A - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_run_image_anim_num - thumb_func_start sub_8092A4C sub_8092A4C: @ 8092A4C push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5d5747be9..8bb20abb4 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3507,6 +3507,38 @@ bool8 sub_809292C(struct MapObject *mapObject, struct Sprite *sprite) return FALSE; } +void npc_reset(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = FALSE; + mapObject->mapobj_bit_6 = FALSE; + mapObject->mapobj_bit_7 = FALSE; + mapObject->mapobj_unk_1C = 0xFF; + sprite->data1 = 0; +} + +#define dirn2anim(name, table)\ +extern const u8 table[4];\ +u8 name(u8 direction)\ +{\ + return table[direction];\ +} + +dirn2anim(FieldObjectDirectionToImageAnimId, gUnknown_0850DACC) +dirn2anim(get_go_image_anim_num, gUnknown_0850DAD5) +dirn2anim(get_go_fast_image_anim_num, gUnknown_0850DADE) +dirn2anim(get_go_faster_image_anim_num, gUnknown_0850DAE7) +dirn2anim(get_go_fastest_image_anim_num, gUnknown_0850DAF0) +dirn2anim(sub_80929AC, gUnknown_0850DAF9) +dirn2anim(sub_80929BC, gUnknown_0850DB02) +dirn2anim(sub_80929CC, gUnknown_0850DB0B) +dirn2anim(sub_80929DC, gUnknown_0850DB14) +dirn2anim(sub_80929EC, gUnknown_0850DB1D) +dirn2anim(sub_80929FC, gUnknown_0850DB26) +dirn2anim(sub_8092A0C, gUnknown_0850DB2F) +dirn2anim(sub_8092A1C, gUnknown_0850DB38) +dirn2anim(sub_8092A2C, gUnknown_0850DB41) +dirn2anim(get_run_image_anim_num, gUnknown_0850DB4A) + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); @@ -3560,7 +3592,7 @@ void FieldObjectStep(struct MapObject *mapObject, struct Sprite *sprite, bool8 ( FieldObjectUpdateSubpriority(mapObject, sprite); } -#define dirn2anim(name, table) \ +#define dirn2anim_2(name, table) \ extern const u8 table[5]; \ u8 name(u32 direction) \ { \ @@ -3575,4 +3607,4 @@ u8 name(u32 direction) \ return animIds[dirn2]; \ } -dirn2anim(GetFaceDirectionAnimId, gUnknown_0850DBA0); +dirn2anim_2(GetFaceDirectionAnimId, gUnknown_0850DBA0);