sub_808E1B8

This commit is contained in:
PikalaxALT 2017-09-07 19:28:46 -04:00
parent 113482a7cc
commit de8ef5e125
3 changed files with 95 additions and 225 deletions

View File

@ -5,229 +5,6 @@
.text
thumb_func_start sub_808E1B8
sub_808E1B8: @ 808E1B8
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x28
lsls r0, 24
lsrs r0, 24
mov r9, r0
lsls r1, 16
lsrs r1, 16
mov r10, r1
lsls r2, 16
lsrs r2, 16
str r2, [sp, 0x24]
movs r7, 0
ldr r2, =gLinkPlayerMapObjects
_0808E1DA:
lsls r0, r7, 2
adds r1, r0, r2
ldrb r0, [r1]
cmp r0, 0
beq _0808E1EC
ldrb r1, [r1, 0x2]
cmp r9, r1
bne _0808E1EC
b _0808E374
_0808E1EC:
adds r0, r7, 0x1
lsls r0, 24
lsrs r7, r0, 24
cmp r7, 0x3
bls _0808E1DA
mov r1, r9
lsls r0, r1, 3
add r0, r9
lsls r0, 2
ldr r1, =gMapObjects
adds r6, r0, r1
movs r0, 0
str r0, [sp, 0x20]
ldrb r0, [r6, 0x5]
bl GetFieldObjectGraphicsInfo
adds r5, r0, 0
ldrh r2, [r5, 0x6]
ldr r1, =0xffff0000
add r4, sp, 0x18
ldr r0, [r4, 0x4]
ands r0, r1
orrs r0, r2
str r0, [r4, 0x4]
ldrb r0, [r6, 0x5]
ldrb r1, [r6, 0x6]
add r3, sp, 0x20
mov r2, sp
bl MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex
str r4, [sp, 0xC]
mov r1, sp
ldr r2, =0x0000ffff
adds r0, r2, 0
strh r0, [r1, 0x2]
ldrb r0, [r5, 0xC]
lsls r1, r0, 28
lsrs r0, r1, 28
mov r8, r0
cmp r0, 0
bne _0808E258
ldrh r0, [r5, 0x2]
lsrs r1, 28
bl npc_load_two_palettes__no_record
b _0808E27E
.pool
_0808E258:
mov r2, r8
cmp r2, 0xA
bne _0808E268
ldrh r0, [r5, 0x2]
lsrs r1, 28
bl npc_load_two_palettes__and_record
b _0808E27E
_0808E268:
mov r0, r8
cmp r0, 0xF
bls _0808E27E
subs r0, 0x10
lsls r0, 24
lsrs r0, 24
mov r8, r0
ldrh r0, [r5, 0x2]
mov r1, r8
bl sub_808EAB0
_0808E27E:
mov r1, sp
ldr r2, =0x0000ffff
adds r0, r2, 0
strh r0, [r1, 0x2]
mov r0, sp
movs r1, 0
movs r2, 0
movs r3, 0
bl CreateSprite
lsls r0, 24
lsrs r7, r0, 24
cmp r7, 0x40
beq _0808E374
lsls r0, r7, 4
adds r0, r7
lsls r0, 2
ldr r1, =gSprites
adds r4, r0, r1
mov r1, r10
lsls r0, r1, 16
asrs r0, 16
ldrh r2, [r6, 0x10]
adds r0, r2
lsls r0, 16
asrs r0, 16
ldr r2, [sp, 0x24]
lsls r1, r2, 16
asrs r1, 16
ldrh r2, [r6, 0x12]
adds r1, r2
lsls r1, 16
asrs r1, 16
adds r2, r4, 0
adds r2, 0x20
adds r3, r4, 0
adds r3, 0x22
bl sub_8092FF0
ldrh r0, [r5, 0x8]
lsls r0, 16
asrs r0, 17
negs r0, r0
adds r1, r4, 0
adds r1, 0x28
strb r0, [r1]
ldrh r0, [r5, 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]
ldr r0, [r5, 0x1C]
str r0, [r4, 0xC]
ldrb r0, [r6, 0x6]
cmp r0, 0xB
bne _0808E312
mov r0, r9
adds r1, r7, 0
bl SetPlayerAvatarFieldObjectIdAndObjectId
bl sub_8154228
strb r0, [r6, 0x1B]
_0808E312:
ldr r1, [sp, 0x20]
cmp r1, 0
beq _0808E31E
adds r0, r4, 0
bl SetSubspriteTables
_0808E31E:
mov r0, r8
lsls r2, r0, 4
ldrb r1, [r4, 0x5]
movs r0, 0xF
ands r0, r1
orrs r0, r2
strb r0, [r4, 0x5]
adds r2, r4, 0
adds r2, 0x3E
ldrb r0, [r2]
movs r1, 0x2
orrs r0, r1
strb r0, [r2]
mov r1, r9
strh r1, [r4, 0x2E]
strb r7, [r6, 0x4]
ldrb r0, [r6, 0x1]
lsls r0, 27
cmp r0, 0
blt _0808E362
ldrb r0, [r6, 0x6]
cmp r0, 0xB
beq _0808E362
ldrb r0, [r6, 0x18]
lsls r0, 28
lsrs r0, 28
bl FieldObjectDirectionToImageAnimId
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
bl StartSpriteAnim
_0808E362:
adds r0, r6, 0
bl sub_808E38C
ldrb r0, [r6, 0xB]
lsrs r0, 4
adds r1, r4, 0
movs r2, 0x1
bl SetObjectSubpriorityByZCoord
_0808E374:
add sp, 0x28
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_808E1B8
thumb_func_start sub_808E38C
@ void sub_808E38C(struct npc_state *fieldObject)
sub_808E38C: @ 808E38C

View File

@ -0,0 +1,15 @@
//
// Created by scott on 9/7/2017.
//
#ifndef POKEEMERALD_FIELD_EFFECT_HELPERS_H
#define POKEEMERALD_FIELD_EFFECT_HELPERS_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
u8 sub_8154228(void);
#endif //POKEEMERALD_FIELD_EFFECT_HELPERS_H

View File

@ -10,6 +10,7 @@
#include "rom_81BE66C.h"
#include "field_ground_effect.h"
#include "map_obj_8097404.h"
#include "field_effect_helpers.h"
#include "field_map_obj.h"
#define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51
@ -33,8 +34,10 @@ void sub_8096518(struct MapObject *, struct Sprite *);
/*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *);
/*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8);
/*static*/ void sub_808E894(u16);
/*static*/ void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject);
/*static*/ void sub_808E1B8(u8, s16, s16);
/*static*/ void RemoveFieldObjectIfOutsideView(struct MapObject *);
static void sub_808E1B8(u8, s16, s16);
/*static*/ void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8);
/*static*/ void sub_808E38C(struct MapObject *);
// ROM data
@ -801,3 +804,78 @@ void sub_808E16C(s16 x, s16 y)
}
sub_808D450();
}
static void sub_808E1B8(u8 mapObjectId, s16 x, s16 y)
{
u8 spriteId;
u8 paletteSlot;
struct MapObject *mapObject;
const struct SubspriteTable *subspriteTables;
const struct MapObjectGraphicsInfo *graphicsInfo;
struct SpriteFrameImage spriteFrameImage;
struct SpriteTemplate spriteTemplate;
struct Sprite *sprite;
#define i spriteId
for (i = 0; i < ARRAY_COUNT(gLinkPlayerMapObjects); i ++)
{
if (gLinkPlayerMapObjects[i].active && mapObjectId == gLinkPlayerMapObjects[i].mapObjId)
{
return;
}
}
#undef i
mapObject = &gMapObjects[mapObjectId];
subspriteTables = NULL;
graphicsInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId);
spriteFrameImage.size = graphicsInfo->size;
MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObject->graphicsId, mapObject->animPattern, &spriteTemplate, &subspriteTables);
spriteTemplate.images = &spriteFrameImage;
*(u16 *)&spriteTemplate.paletteTag = 0xffff;
paletteSlot = graphicsInfo->paletteSlot;
if (paletteSlot == 0)
{
npc_load_two_palettes__no_record(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);
}
*(u16 *)&spriteTemplate.paletteTag = 0xffff;
spriteId = CreateSprite(&spriteTemplate, 0, 0, 0);
if (spriteId != MAX_SPRITES)
{
sprite = &gSprites[spriteId];
sub_8092FF0(x + mapObject->coords2.x, y + 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;
sprite->images = graphicsInfo->images;
if (mapObject->animPattern == 0x0b)
{
SetPlayerAvatarFieldObjectIdAndObjectId(mapObjectId, spriteId);
mapObject->mapobj_unk_1B = sub_8154228();
}
if (subspriteTables != NULL)
{
SetSubspriteTables(sprite, subspriteTables);
}
sprite->oam.paletteNum = paletteSlot;
sprite->coordOffsetEnabled = TRUE;
sprite->data0 = mapObjectId;
mapObject->spriteId = spriteId;
if (!mapObject->mapobj_bit_12 && mapObject->animPattern != 0x0b)
{
StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18));
}
sub_808E38C(mapObject);
SetObjectSubpriorityByZCoord(mapObject->elevation, sprite, 1);
}
}