AddPseudoFieldObject
This commit is contained in:
parent
12562aa2d4
commit
f7742a68ae
3 changed files with 31 additions and 79 deletions
|
@ -5,85 +5,6 @@
|
|||
|
||||
.text
|
||||
|
||||
thumb_func_start AddPseudoFieldObject
|
||||
@ void AddPseudoFieldObject(u8 graphicsId, void ( *callback)(), u16 x, u16 y, u8 subpriority)
|
||||
AddPseudoFieldObject: @ 808DD68
|
||||
push {r4-r7,lr}
|
||||
mov r7, r9
|
||||
mov r6, r8
|
||||
push {r6,r7}
|
||||
sub sp, 0x4
|
||||
adds r4, r0, 0
|
||||
adds r5, r1, 0
|
||||
ldr r0, [sp, 0x20]
|
||||
lsls r4, 16
|
||||
lsrs r4, 16
|
||||
lsls r2, 16
|
||||
lsrs r2, 16
|
||||
mov r8, r2
|
||||
lsls r3, 16
|
||||
lsrs r7, r3, 16
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
mov r9, r0
|
||||
movs r0, 0x18
|
||||
bl Alloc
|
||||
adds r6, r0, 0
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
adds r2, r6, 0
|
||||
mov r3, sp
|
||||
bl MakeObjectTemplateFromFieldObjectGraphicsInfo
|
||||
ldrh r1, [r6, 0x2]
|
||||
ldr r0, =0x0000ffff
|
||||
cmp r1, r0
|
||||
beq _0808DDAE
|
||||
adds r0, r1, 0
|
||||
bl sub_808E894
|
||||
_0808DDAE:
|
||||
mov r0, r8
|
||||
lsls r1, r0, 16
|
||||
asrs r1, 16
|
||||
lsls r2, r7, 16
|
||||
asrs r2, 16
|
||||
adds r0, r6, 0
|
||||
mov r3, r9
|
||||
bl CreateSprite
|
||||
lsls r0, 24
|
||||
lsrs r5, r0, 24
|
||||
adds r0, r6, 0
|
||||
bl Free
|
||||
cmp r5, 0x40
|
||||
beq _0808DDF2
|
||||
ldr r1, [sp]
|
||||
cmp r1, 0
|
||||
beq _0808DDF2
|
||||
lsls r4, r5, 4
|
||||
adds r4, r5
|
||||
lsls r4, 2
|
||||
ldr r0, =gSprites
|
||||
adds r4, r0
|
||||
adds r0, r4, 0
|
||||
bl SetSubspriteTables
|
||||
adds r4, 0x42
|
||||
ldrb r1, [r4]
|
||||
movs r0, 0x3F
|
||||
ands r0, r1
|
||||
movs r1, 0x80
|
||||
orrs r0, r1
|
||||
strb r0, [r4]
|
||||
_0808DDF2:
|
||||
adds r0, r5, 0
|
||||
add sp, 0x4
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end AddPseudoFieldObject
|
||||
|
||||
thumb_func_start sprite_new
|
||||
sprite_new: @ 808DE0C
|
||||
push {r4-r7,lr}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#ifndef GUARD_MALLOC_H
|
||||
#define GUARD_MALLOC_H
|
||||
|
||||
#define malloc Alloc
|
||||
#define calloc AllocZeroed
|
||||
#define free Free
|
||||
|
||||
void *Alloc(u32 size);
|
||||
void *AllocZeroed(u32 size);
|
||||
void Free(void *pointer);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Includes
|
||||
|
||||
#include "global.h"
|
||||
#include "malloc.h"
|
||||
#include "sprite.h"
|
||||
#include "rom4.h"
|
||||
#include "field_player_avatar.h"
|
||||
|
@ -30,6 +31,7 @@ void sub_8096518(struct MapObject *, struct Sprite *);
|
|||
/*static*/ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **);
|
||||
/*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *);
|
||||
/*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8);
|
||||
/*static*/ void sub_808E894(u16);
|
||||
|
||||
// ROM data
|
||||
|
||||
|
@ -618,3 +620,28 @@ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *mapObje
|
|||
{
|
||||
MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObjectTemplate->graphicsId, mapObjectTemplate->movementType, spriteTemplate, subspriteTables);
|
||||
}
|
||||
|
||||
u8 AddPseudoFieldObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority)
|
||||
{
|
||||
struct SpriteTemplate *spriteTemplate;
|
||||
const struct SubspriteTable *subspriteTables;
|
||||
struct Sprite *sprite;
|
||||
u8 spriteIdx;
|
||||
|
||||
spriteTemplate = malloc(sizeof(struct SpriteTemplate));
|
||||
MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables);
|
||||
if (spriteTemplate->paletteTag != 0xffff)
|
||||
{
|
||||
sub_808E894(spriteTemplate->paletteTag);
|
||||
}
|
||||
spriteIdx = CreateSprite(spriteTemplate, x, y, subpriority);
|
||||
free(spriteTemplate);
|
||||
|
||||
if (spriteIdx != MAX_SPRITES && subspriteTables != NULL)
|
||||
{
|
||||
sprite = &gSprites[spriteIdx];
|
||||
SetSubspriteTables(sprite, subspriteTables);
|
||||
sprite->subspriteMode = 2;
|
||||
}
|
||||
return spriteIdx;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue