diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5be423e0a..436350899 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,80 +5,6 @@ .text - thumb_func_start RemoveFieldObjectByLocalIdAndMap -@ void RemoveFieldObjectByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapBank) -RemoveFieldObjectByLocalIdAndMap: @ 808D8C4 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808D902 - mov r0, sp - ldrb r0, [r0] - bl GetFieldObjectFlagIdByFieldObjectId - lsls r0, 16 - lsrs r0, 16 - bl FlagSet - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - bl RemoveFieldObject -_0808D902: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end RemoveFieldObjectByLocalIdAndMap - - thumb_func_start RemoveFieldObjectInternal -@ void RemoveFieldObjectInternal(npc_state *fieldObject) -RemoveFieldObjectInternal: @ 808D90C - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - ldrb r0, [r4, 0x5] - bl GetFieldObjectGraphicsInfo - ldrh r2, [r0, 0x6] - ldr r1, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r1 - orrs r0, r2 - str r0, [sp, 0x4] - ldr r2, =gSprites - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r2, 0 - adds r1, 0xC - adds r0, r1 - mov r1, sp - str r1, [r0] - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - bl DestroySprite - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end RemoveFieldObjectInternal - thumb_func_start sub_808D958 sub_808D958: @ 808D958 push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7420895ab..52f798f9b 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -21,6 +21,8 @@ static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); /*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); /*static*/ void RemoveFieldObjectInternal (struct MapObject *); +/*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); +/*static*/ struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); // ROM data @@ -422,3 +424,21 @@ void RemoveFieldObject(struct MapObject *mapObject) mapObject->active = FALSE; RemoveFieldObjectInternal(mapObject); } + +void RemoveFieldObjectByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 index; + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &index)) + { + FlagSet(GetFieldObjectFlagIdByFieldObjectId(index)); + RemoveFieldObject(&gMapObjects[index]); + } +} + +void RemoveFieldObjectInternal(struct MapObject *mapObject) +{ + struct SpriteFrameImage image; + image.size = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->size; + gSprites[mapObject->spriteId].images = ℑ + DestroySprite(&gSprites[mapObject->spriteId]); +}