GetFieldObjectTemplateByLocalIdAndMap

This commit is contained in:
scnorton 2017-09-11 10:29:00 -04:00
parent bd9b81546f
commit 5ad282c82c
3 changed files with 22 additions and 42 deletions

View File

@ -5,48 +5,6 @@
.text
thumb_func_start GetFieldObjectTemplateByLocalIdAndMap
@ struct FieldObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId)
GetFieldObjectTemplateByLocalIdAndMap: @ 808F128
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
lsls r1, 24
lsrs r3, r1, 24
lsls r2, 24
lsrs r2, 24
ldr r0, =gSaveBlock1Ptr
ldr r1, [r0]
movs r0, 0x5
ldrsb r0, [r1, r0]
cmp r0, r3
bne _0808F160
movs r0, 0x4
ldrsb r0, [r1, r0]
cmp r0, r2
bne _0808F160
movs r0, 0xC7
lsls r0, 4
adds r1, r0
ldr r0, =gMapHeader
ldr r0, [r0, 0x4]
b _0808F16C
.pool
_0808F160:
adds r0, r2, 0
adds r1, r3, 0
bl get_mapheader_by_bank_and_number
ldr r0, [r0, 0x4]
ldr r1, [r0, 0x4]
_0808F16C:
ldrb r2, [r0]
adds r0, r4, 0
bl FindFieldObjectTemplateInArrayByLocalId
pop {r4}
pop {r1}
bx r1
thumb_func_end GetFieldObjectTemplateByLocalIdAndMap
thumb_func_start FindFieldObjectTemplateInArrayByLocalId
@ struct FieldObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct FieldObjectTemplate *templates, u8 numTemplates)
FindFieldObjectTemplateInArrayByLocalId: @ 808F17C

View File

@ -25,5 +25,6 @@ struct UCoords32
extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4];
void strange_npc_table_clear(void);
const struct MapHeader *get_mapheader_by_bank_and_number(u8, u8);
#endif //POKEEMERALD_ROM4_H

View File

@ -51,6 +51,7 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8);
//static void CameraObject_0(struct Sprite *);
/*static*/ void CameraObject_1(struct Sprite *);
//static void CameraObject_2(struct Sprite *);
/*static*/ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count);
// ROM data
@ -1543,3 +1544,23 @@ u8 FieldObjectGetBerryTreeId(u8 mapObjectId)
return gMapObjects[mapObjectId].trainerRange_berryTreeId;
}
struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
{
struct MapObjectTemplate *templates;
const struct MapHeader *mapHeader;
u8 count;
if (gSaveBlock1Ptr->location.mapNum == mapNum && gSaveBlock1Ptr->location.mapGroup == mapGroup)
{
templates = gSaveBlock1Ptr->mapObjectTemplates;
count = gMapHeader.events->mapObjectCount;
}
else
{
mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum);
templates = mapHeader->events->mapObjects;
count = mapHeader->events->mapObjectCount;
}
return FindFieldObjectTemplateInArrayByLocalId(localId, templates, count);
}