FieldObjectSetGraphicsId

This commit is contained in:
PikalaxALT 2017-09-07 21:04:32 -04:00
parent f8e8adf82e
commit a87b35f9a7
3 changed files with 44 additions and 134 deletions

View File

@ -5,140 +5,6 @@
.text
thumb_func_start FieldObjectSetGraphicsId
@ void FieldObjectSetGraphicsId(npc_state *npcState, u8 graphicsId)
FieldObjectSetGraphicsId: @ 808E3F8
push {r4-r7,lr}
mov r7, r8
push {r7}
adds r7, r0, 0
lsls r1, 24
lsrs r1, 24
mov r8, r1
mov r0, r8
bl GetFieldObjectGraphicsInfo
adds r6, r0, 0
ldrb r1, [r7, 0x4]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
ldr r1, =gSprites
adds r4, r0, r1
ldrb r0, [r6, 0xC]
lsls r1, r0, 28
lsrs r5, r1, 28
cmp r5, 0
bne _0808E434
ldrh r0, [r6, 0x2]
adds r1, r5, 0
bl pal_patch_for_npc
b _0808E456
.pool
_0808E434:
cmp r5, 0xA
bne _0808E442
ldrh r0, [r6, 0x2]
lsrs r1, 28
bl npc_load_two_palettes__and_record
b _0808E456
_0808E442:
cmp r5, 0xF
bls _0808E456
adds r0, r5, 0
subs r0, 0x10
lsls r0, 24
lsrs r5, r0, 24
ldrh r0, [r6, 0x2]
adds r1, r5, 0
bl sub_808EAB0
_0808E456:
ldr r0, [r6, 0x10]
ldrb r2, [r0, 0x1]
lsrs r2, 6
lsls r2, 6
ldrb r3, [r4, 0x1]
movs r1, 0x3F
adds r0, r1, 0
ands r0, r3
orrs r0, r2
strb r0, [r4, 0x1]
ldr r0, [r6, 0x10]
ldrb r0, [r0, 0x3]
lsrs r0, 6
lsls r0, 6
ldrb r2, [r4, 0x3]
ands r1, r2
orrs r1, r0
strb r1, [r4, 0x3]
ldr r0, [r6, 0x1C]
str r0, [r4, 0xC]
ldr r0, [r6, 0x18]
str r0, [r4, 0x8]
ldr r0, [r6, 0x14]
str r0, [r4, 0x18]
lsls r2, r5, 4
ldrb r1, [r4, 0x5]
movs r0, 0xF
ands r0, r1
orrs r0, r2
strb r0, [r4, 0x5]
ldrb r1, [r6, 0xC]
lsls r1, 25
lsrs r1, 31
lsls r1, 4
ldrb r2, [r7, 0x1]
movs r0, 0x11
negs r0, r0
ands r0, r2
orrs r0, r1
strb r0, [r7, 0x1]
mov r0, r8
strb r0, [r7, 0x5]
movs r1, 0x10
ldrsh r0, [r7, r1]
movs r2, 0x12
ldrsh r1, [r7, r2]
adds r2, r4, 0
adds r2, 0x20
adds r3, r4, 0
adds r3, 0x22
bl sub_8093038
ldrh r0, [r6, 0x8]
lsls r0, 16
asrs r0, 17
negs r0, r0
adds r1, r4, 0
adds r1, 0x28
strb r0, [r1]
ldrh r0, [r6, 0xA]
lsls r0, 16
asrs r0, 17
negs r0, r0
adds r2, r4, 0
adds r2, 0x29
strb r0, [r2]
ldrh r0, [r4, 0x20]
adds r0, 0x8
strh r0, [r4, 0x20]
ldrh r1, [r4, 0x22]
adds r1, 0x10
movs r0, 0
ldrsb r0, [r2, r0]
adds r0, r1
strh r0, [r4, 0x22]
ldrb r0, [r7, 0x1]
lsrs r0, 7
cmp r0, 0
beq _0808E4F8
bl CameraObjectReset1
_0808E4F8:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end FieldObjectSetGraphicsId
thumb_func_start sub_808E504
sub_808E504: @ 808E504
push {r4,lr}

View File

@ -18,6 +18,7 @@ u8 sub_808D4F4(void);
void RemoveFieldObjectByLocalIdAndMap(u8, u8, u8);
void npc_load_two_palettes__no_record(u16, u8);
void npc_load_two_palettes__and_record(u16, u8);
void pal_patch_for_npc(u16, u8);
void sub_808E16C(s16, s16);
void sub_808EAB0(u16, u8);
void sub_8092FF0(s16, s16, s16 *, s16 *);
@ -30,6 +31,8 @@ u8 AddPseudoFieldObject(u16, void (*)(struct Sprite *), s16, s16, u8);
u8 show_sprite(u8, u8, u8);
u8 SpawnSpecialFieldObjectParametrized(u8, u8, u8, s16, s16, u8);
u8 SpawnSpecialFieldObject(struct MapObjectTemplate *);
void sub_8093038(s16, s16, s16 *, s16 *);
void CameraObjectReset1(void);
// Exported data declarations

View File

@ -902,3 +902,44 @@ static void SetPlayerAvatarFieldObjectIdAndObjectId(u8 mapObjectId, u8 spriteId)
gPlayerAvatar.gender = GetPlayerAvatarGenderByGraphicsId(gMapObjects[mapObjectId].graphicsId);
SetPlayerAvatarExtraStateTransition(gMapObjects[mapObjectId].graphicsId, 0x20);
}
void FieldObjectSetGraphicsId(struct MapObject *mapObject, u8 graphicsId)
{
const struct MapObjectGraphicsInfo *graphicsInfo;
struct Sprite *sprite;
u8 paletteSlot;
graphicsInfo = GetFieldObjectGraphicsInfo(graphicsId);
sprite = &gSprites[mapObject->spriteId];
paletteSlot = graphicsInfo->paletteSlot;
if (paletteSlot == 0)
{
pal_patch_for_npc(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot);
}
else if (paletteSlot == 10)
{
npc_load_two_palettes__and_record(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot);
}
else if (paletteSlot >= 16)
{
paletteSlot -= 16;
sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot);
}
sprite->oam.shape = graphicsInfo->oam->shape;
sprite->oam.size = graphicsInfo->oam->size;
sprite->images = graphicsInfo->images;
sprite->anims = graphicsInfo->anims;
sprite->subspriteTables = graphicsInfo->subspriteTables;
sprite->oam.paletteNum = paletteSlot;
mapObject->mapobj_bit_12 = graphicsInfo->inanimate;
mapObject->graphicsId = graphicsId;
sub_8093038(mapObject->coords2.x, mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y);
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
sprite->pos1.x += 8;
sprite->pos1.y += 16 + sprite->centerToCornerVecY;
if (mapObject->mapobj_bit_15)
{
CameraObjectReset1();
}
}