From 9306122359968579b27b9a41e3cfd082860a4231 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 11 Sep 2017 10:46:26 -0400 Subject: [PATCH] through sub_808F23C --- asm/field_map_obj.s | 50 --------------------------------------- include/global.fieldmap.h | 2 +- src/field_map_obj.c | 36 +++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 52 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5c8754ac0..243e96c75 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,56 +5,6 @@ .text - thumb_func_start sub_808F208 -@ void sub_808F208(struct npc_state *fieldObject) -sub_808F208: @ 808F208 - push {r4,lr} - adds r4, r0, 0 - bl sub_808F1B4 - adds r1, r0, 0 - cmp r1, 0 - beq _0808F222 - ldrh r0, [r4, 0x10] - subs r0, 0x7 - strh r0, [r1, 0x4] - ldrh r0, [r4, 0x12] - subs r0, 0x7 - strh r0, [r1, 0x6] -_0808F222: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808F208 - - thumb_func_start sub_808F228 -sub_808F228: @ 808F228 - push {r4,lr} - adds r4, r1, 0 - bl sub_808F1B4 - cmp r0, 0 - beq _0808F236 - str r4, [r0, 0x10] -_0808F236: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808F228 - - thumb_func_start sub_808F23C -sub_808F23C: @ 808F23C - push {r4,lr} - lsls r1, 24 - lsrs r4, r1, 24 - bl sub_808F1B4 - cmp r0, 0 - beq _0808F24C - strb r4, [r0, 0x9] -_0808F24C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808F23C - thumb_func_start sub_808F254 @ void sub_808F254(u8 localId, u8 mapId, u8 mapGroupId) sub_808F254: @ 808F254 diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 5a7a75ccb..f8955b9fd 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -86,7 +86,7 @@ struct MapObjectTemplate ///*0x0B*/ u8 fillerB[1]; /*0x0C*/ u16 unkC; /*0x0E*/ u16 unkE; - /*0x10*/ u8 *script; + /*0x10*/ const u8 *script; /*0x14*/ u16 flagId; /*0x16*/ u8 filler_16[2]; }; /*size = 0x18*/ diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 56c5dee85..59f8d35a1 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1578,7 +1578,7 @@ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, st return NULL; } -struct MapObjectTemplate *sub_808F1B4(struct MapObject *mapObject) +struct MapObjectTemplate *sub_808F1B4(const struct MapObject *mapObject) { int i; @@ -1595,3 +1595,37 @@ struct MapObjectTemplate *sub_808F1B4(struct MapObject *mapObject) } return NULL; } + +void sub_808F208(const struct MapObject *mapObject) +{ + struct MapObjectTemplate *mapObjectTemplate; + + mapObjectTemplate = sub_808F1B4(mapObject); + if (mapObjectTemplate != NULL) + { + mapObjectTemplate->x = mapObject->coords2.x - 7; + mapObjectTemplate->y = mapObject->coords2.y - 7; + } +} + +void sub_808F228(const struct MapObject *mapObject, const u8 *script) +{ + struct MapObjectTemplate *mapObjectTemplate; + + mapObjectTemplate = sub_808F1B4(mapObject); + if (mapObjectTemplate != NULL) + { + mapObjectTemplate->script = script; + } +} + +void sub_808F23C(const struct MapObject *mapObject, u8 movementType) +{ + struct MapObjectTemplate *mapObjectTemplate; + + mapObjectTemplate = sub_808F1B4(mapObject); + if (mapObjectTemplate != NULL) + { + mapObjectTemplate->movementType = movementType; + } +}