diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 11e93a4ea..6571f40bc 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,80 +5,6 @@ .text - thumb_func_start GetFieldObjectScriptPointerByLocalIdAndMap -@ u32 GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) -GetFieldObjectScriptPointerByLocalIdAndMap: @ 808F004 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - bl GetFieldObjectTemplateByLocalIdAndMap - ldr r0, [r0, 0x10] - pop {r1} - bx r1 - thumb_func_end GetFieldObjectScriptPointerByLocalIdAndMap - - thumb_func_start GetFieldObjectScriptPointerByFieldObjectId -@ u32 GetFieldObjectScriptPointerByFieldObjectId(u8 fieldObjectId) -GetFieldObjectScriptPointerByFieldObjectId: @ 808F01C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gMapObjects - lsls r2, r0, 3 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - ldrb r0, [r2, 0x8] - ldrb r1, [r2, 0x9] - ldrb r2, [r2, 0xA] - bl GetFieldObjectScriptPointerByLocalIdAndMap - pop {r1} - bx r1 - .pool - thumb_func_end GetFieldObjectScriptPointerByFieldObjectId - - thumb_func_start GetFieldObjectFlagIdByLocalIdAndMap -@ u16 GetFieldObjectFlagIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) -GetFieldObjectFlagIdByLocalIdAndMap: @ 808F040 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - bl GetFieldObjectTemplateByLocalIdAndMap - ldrh r0, [r0, 0x14] - pop {r1} - bx r1 - thumb_func_end GetFieldObjectFlagIdByLocalIdAndMap - - thumb_func_start GetFieldObjectFlagIdByFieldObjectId -@ u16 GetFieldObjectFlagIdByFieldObjectId(u8 fieldObjectId) -GetFieldObjectFlagIdByFieldObjectId: @ 808F058 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gMapObjects - lsls r2, r0, 3 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - ldrb r0, [r2, 0x8] - ldrb r1, [r2, 0x9] - ldrb r2, [r2, 0xA] - bl GetFieldObjectFlagIdByLocalIdAndMap - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end GetFieldObjectFlagIdByFieldObjectId - thumb_func_start sub_808F080 sub_808F080: @ 808F080 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d5481c573..42769ed13 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1490,3 +1490,23 @@ void FieldObjectSetDirection(struct MapObject *mapObject, u8 direction) } mapObject->placeholder18 = direction; } + +static const u8 *GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + return GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->script; +} + +const u8 *GetFieldObjectScriptPointerByFieldObjectId(u8 mapObjectId) +{ + return GetFieldObjectScriptPointerByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup); +} + +static u16 GetFieldObjectFlagIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + return GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->flagId; +} + +u16 GetFieldObjectFlagIdByFieldObjectId(u8 mapObjectId) +{ + return GetFieldObjectFlagIdByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup); +}