From 12562aa2d42e1692aff319b091258d5c24a9e040 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 14:16:30 -0400 Subject: [PATCH] MakeObjectTemplateFromFieldObjectTemplate --- asm/field_map_obj.s | 16 ---------------- src/field_map_obj.c | 5 +++++ src/malloc.c | 5 +++-- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 34578ec5c3..571223ec33 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,22 +5,6 @@ .text - thumb_func_start MakeObjectTemplateFromFieldObjectTemplate -@ void MakeObjectTemplateFromFieldObjectTemplate(struct FieldObjectTemplate *fieldObjectTemplate, struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables) -MakeObjectTemplateFromFieldObjectTemplate: @ 808DD50 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r3, r2, 0 - ldrb r0, [r4, 0x1] - ldrb r1, [r4, 0x9] - adds r2, r5, 0 - bl MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end MakeObjectTemplateFromFieldObjectTemplate - thumb_func_start AddPseudoFieldObject @ void AddPseudoFieldObject(u8 graphicsId, void ( *callback)(), u16 x, u16 y, u8 subpriority) AddPseudoFieldObject: @ 808DD68 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index e3e0b7158b..8197217734 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -613,3 +613,8 @@ void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphics { MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, gUnknown_08505438[callbackIndex], sprTemplate, subspriteTables); } + +void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) +{ + MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObjectTemplate->graphicsId, mapObjectTemplate->movementType, spriteTemplate, subspriteTables); +} diff --git a/src/malloc.c b/src/malloc.c index 948303c6fe..5317565dc6 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -40,7 +40,7 @@ void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next void PutFirstMemBlockHeader(void *block, u32 size) { - PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - 16); + PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock)); } void *AllocInternal(void *heapStart, u32 size) @@ -50,6 +50,7 @@ void *AllocInternal(void *heapStart, u32 size) struct MemBlock *splitBlock; u32 foundBlockSize; + // Alignment if (size & 3) size = 4 * ((size / 4) + 1); @@ -60,7 +61,7 @@ void *AllocInternal(void *heapStart, u32 size) foundBlockSize = pos->size; if (foundBlockSize >= size) { - if (foundBlockSize - size <= 31) { + if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) { // The block isn't much bigger than the requested size, // so just use it. pos->flag = TRUE;