Through MakeObjectTemplateFromFieldObjectGraphicsInfo
This commit is contained in:
parent
22c8367956
commit
1f83a2885e
2 changed files with 55 additions and 132 deletions
|
@ -5,133 +5,6 @@
|
|||
|
||||
.text
|
||||
|
||||
thumb_func_start SpawnSpecialFieldObjectParametrized
|
||||
@ u8 SpawnSpecialFieldObjectParametrized(u8 graphicsId, u8 movementBehavior, u8 localId, u16 x, u16 y, u8 z)
|
||||
SpawnSpecialFieldObjectParametrized: @ 808DC44
|
||||
push {r4-r6,lr}
|
||||
mov r6, r8
|
||||
push {r6}
|
||||
sub sp, 0x18
|
||||
ldr r4, [sp, 0x2C]
|
||||
ldr r5, [sp, 0x30]
|
||||
mov r8, r5
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
lsls r3, 16
|
||||
ldr r5, =0xfff90000
|
||||
adds r3, r5
|
||||
lsrs r3, 16
|
||||
lsls r4, 16
|
||||
adds r4, r5
|
||||
lsrs r4, 16
|
||||
mov r5, sp
|
||||
movs r6, 0
|
||||
strb r2, [r5]
|
||||
mov r2, sp
|
||||
strb r0, [r2, 0x1]
|
||||
mov r0, sp
|
||||
strb r6, [r0, 0x2]
|
||||
movs r5, 0
|
||||
strh r3, [r0, 0x4]
|
||||
strh r4, [r0, 0x6]
|
||||
mov r2, r8
|
||||
strb r2, [r0, 0x8]
|
||||
strb r1, [r0, 0x9]
|
||||
mov r2, sp
|
||||
ldrb r1, [r2, 0xA]
|
||||
movs r0, 0x10
|
||||
negs r0, r0
|
||||
ands r0, r1
|
||||
strb r0, [r2, 0xA]
|
||||
mov r0, sp
|
||||
strb r5, [r0, 0xA]
|
||||
strh r6, [r0, 0xC]
|
||||
strh r6, [r0, 0xE]
|
||||
bl SpawnSpecialFieldObject
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
add sp, 0x18
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end SpawnSpecialFieldObjectParametrized
|
||||
|
||||
thumb_func_start show_sprite
|
||||
show_sprite: @ 808DCAC
|
||||
push {r4-r7,lr}
|
||||
sub sp, 0x8
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
lsls r1, 24
|
||||
lsrs r7, r1, 24
|
||||
lsls r2, 24
|
||||
lsrs r6, r2, 24
|
||||
adds r1, r7, 0
|
||||
adds r2, r6, 0
|
||||
bl GetFieldObjectTemplateByLocalIdAndMap
|
||||
adds r5, r0, 0
|
||||
cmp r5, 0
|
||||
beq _0808DCF2
|
||||
mov r4, sp
|
||||
adds r4, 0x6
|
||||
add r0, sp, 0x4
|
||||
adds r1, r4, 0
|
||||
bl GetFieldObjectMovingCameraOffset
|
||||
add r0, sp, 0x4
|
||||
movs r1, 0
|
||||
ldrsh r3, [r0, r1]
|
||||
movs r1, 0
|
||||
ldrsh r0, [r4, r1]
|
||||
str r0, [sp]
|
||||
adds r0, r5, 0
|
||||
adds r1, r7, 0
|
||||
adds r2, r6, 0
|
||||
bl SpawnFieldObject
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
b _0808DCF4
|
||||
_0808DCF2:
|
||||
movs r0, 0x10
|
||||
_0808DCF4:
|
||||
add sp, 0x8
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end show_sprite
|
||||
|
||||
thumb_func_start MakeObjectTemplateFromFieldObjectGraphicsInfo
|
||||
@ void MakeObjectTemplateFromFieldObjectGraphicsInfo(u8 graphicsId, void ( *callback)(), struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables)
|
||||
MakeObjectTemplateFromFieldObjectGraphicsInfo: @ 808DCFC
|
||||
push {r4-r6,lr}
|
||||
adds r5, r1, 0
|
||||
adds r4, r2, 0
|
||||
adds r6, r3, 0
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
bl GetFieldObjectGraphicsInfo
|
||||
ldrh r1, [r0]
|
||||
strh r1, [r4]
|
||||
ldrh r1, [r0, 0x2]
|
||||
strh r1, [r4, 0x2]
|
||||
ldr r1, [r0, 0x10]
|
||||
str r1, [r4, 0x4]
|
||||
ldr r1, [r0, 0x18]
|
||||
str r1, [r4, 0x8]
|
||||
ldr r1, [r0, 0x1C]
|
||||
str r1, [r4, 0xC]
|
||||
ldr r1, [r0, 0x20]
|
||||
str r1, [r4, 0x10]
|
||||
str r5, [r4, 0x14]
|
||||
ldr r0, [r0, 0x14]
|
||||
str r0, [r6]
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end MakeObjectTemplateFromFieldObjectGraphicsInfo
|
||||
|
||||
thumb_func_start MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex
|
||||
@ void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables)
|
||||
MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex: @ 808DD30
|
||||
|
|
|
@ -27,6 +27,7 @@ static void RemoveFieldObjectInternal (struct MapObject *);
|
|||
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);
|
||||
|
||||
// ROM data
|
||||
|
||||
|
@ -525,13 +526,13 @@ u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 m
|
|||
{
|
||||
const struct MapObjectGraphicsInfo *graphicsInfo;
|
||||
struct SpriteTemplate spriteTemplate;
|
||||
const struct SubspriteTable *subspriteTable;
|
||||
const struct SubspriteTable *subspriteTables;
|
||||
struct SpriteFrameImage spriteFrameImage;
|
||||
u8 mapObjectId;
|
||||
|
||||
subspriteTable = NULL;
|
||||
subspriteTables = NULL;
|
||||
graphicsInfo = GetFieldObjectGraphicsInfo(mapObjectTemplate->graphicsId);
|
||||
MakeObjectTemplateFromFieldObjectTemplate(mapObjectTemplate, &spriteTemplate, &subspriteTable);
|
||||
MakeObjectTemplateFromFieldObjectTemplate(mapObjectTemplate, &spriteTemplate, &subspriteTables);
|
||||
spriteFrameImage.size = graphicsInfo->size;
|
||||
spriteTemplate.images = &spriteFrameImage;
|
||||
mapObjectId = SpawnFieldObjectInternal(mapObjectTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY);
|
||||
|
@ -540,9 +541,9 @@ u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 m
|
|||
return ARRAY_COUNT(gMapObjects);
|
||||
}
|
||||
gSprites[gMapObjects[mapObjectId].spriteId].images = graphicsInfo->images;
|
||||
if (subspriteTable != NULL)
|
||||
if (subspriteTables != NULL)
|
||||
{
|
||||
SetSubspriteTables(&gSprites[gMapObjects[mapObjectId].spriteId], subspriteTable);
|
||||
SetSubspriteTables(&gSprites[gMapObjects[mapObjectId].spriteId], subspriteTables);
|
||||
}
|
||||
return mapObjectId;
|
||||
}
|
||||
|
@ -555,3 +556,52 @@ u8 SpawnSpecialFieldObject(struct MapObjectTemplate *mapObjectTemplate)
|
|||
GetFieldObjectMovingCameraOffset(&cameraX, &cameraY);
|
||||
return SpawnFieldObject(mapObjectTemplate, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY);
|
||||
}
|
||||
|
||||
u8 SpawnSpecialFieldObjectParametrized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z)
|
||||
{
|
||||
struct MapObjectTemplate mapObjectTemplate;
|
||||
|
||||
x -= 7;
|
||||
y -= 7;
|
||||
mapObjectTemplate.localId = localId;
|
||||
mapObjectTemplate.graphicsId = graphicsId;
|
||||
mapObjectTemplate.unk2 = 0;
|
||||
mapObjectTemplate.x = x;
|
||||
mapObjectTemplate.y = y;
|
||||
mapObjectTemplate.elevation = z;
|
||||
mapObjectTemplate.movementType = movementBehavior;
|
||||
mapObjectTemplate.unkA_0 = 0;
|
||||
mapObjectTemplate.unkA_4 = 0;
|
||||
mapObjectTemplate.unkC = 0;
|
||||
mapObjectTemplate.unkE = 0;
|
||||
return SpawnSpecialFieldObject(&mapObjectTemplate);
|
||||
}
|
||||
|
||||
u8 show_sprite(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
{
|
||||
struct MapObjectTemplate *mapObjectTemplate;
|
||||
s16 cameraX;
|
||||
s16 cameraY;
|
||||
|
||||
mapObjectTemplate = GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup);
|
||||
if (mapObjectTemplate == NULL)
|
||||
{
|
||||
return ARRAY_COUNT(gMapObjects);
|
||||
}
|
||||
GetFieldObjectMovingCameraOffset(&cameraX, &cameraY);
|
||||
return SpawnFieldObject(mapObjectTemplate, mapNum, mapGroup, cameraX, cameraY);
|
||||
}
|
||||
|
||||
void MakeObjectTemplateFromFieldObjectGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables)
|
||||
{
|
||||
const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(graphicsId);
|
||||
|
||||
sprTemplate->tileTag = gfxInfo->tileTag;
|
||||
sprTemplate->paletteTag = gfxInfo->paletteTag1;
|
||||
sprTemplate->oam = gfxInfo->oam;
|
||||
sprTemplate->anims = gfxInfo->anims;
|
||||
sprTemplate->images = gfxInfo->images;
|
||||
sprTemplate->affineAnims = gfxInfo->affineAnims;
|
||||
sprTemplate->callback = callback;
|
||||
*subspriteTables = gfxInfo->subspriteTables;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue