Functions for retrieving flag and script pointer given map object id

This commit is contained in:
scnorton 2017-09-10 17:11:03 -04:00
parent b263dcc7cf
commit 8456991837
2 changed files with 20 additions and 74 deletions

View file

@ -5,80 +5,6 @@
.text
thumb_func_start GetFieldObjectScriptPointerByLocalIdAndMap
@ u32 GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId)
GetFieldObjectScriptPointerByLocalIdAndMap: @ 808F004
push {lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 24
lsrs r1, 24
lsls r2, 24
lsrs r2, 24
bl GetFieldObjectTemplateByLocalIdAndMap
ldr r0, [r0, 0x10]
pop {r1}
bx r1
thumb_func_end GetFieldObjectScriptPointerByLocalIdAndMap
thumb_func_start GetFieldObjectScriptPointerByFieldObjectId
@ u32 GetFieldObjectScriptPointerByFieldObjectId(u8 fieldObjectId)
GetFieldObjectScriptPointerByFieldObjectId: @ 808F01C
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =gMapObjects
lsls r2, r0, 3
adds r2, r0
lsls r2, 2
adds r2, r1
ldrb r0, [r2, 0x8]
ldrb r1, [r2, 0x9]
ldrb r2, [r2, 0xA]
bl GetFieldObjectScriptPointerByLocalIdAndMap
pop {r1}
bx r1
.pool
thumb_func_end GetFieldObjectScriptPointerByFieldObjectId
thumb_func_start GetFieldObjectFlagIdByLocalIdAndMap
@ u16 GetFieldObjectFlagIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId)
GetFieldObjectFlagIdByLocalIdAndMap: @ 808F040
push {lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 24
lsrs r1, 24
lsls r2, 24
lsrs r2, 24
bl GetFieldObjectTemplateByLocalIdAndMap
ldrh r0, [r0, 0x14]
pop {r1}
bx r1
thumb_func_end GetFieldObjectFlagIdByLocalIdAndMap
thumb_func_start GetFieldObjectFlagIdByFieldObjectId
@ u16 GetFieldObjectFlagIdByFieldObjectId(u8 fieldObjectId)
GetFieldObjectFlagIdByFieldObjectId: @ 808F058
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =gMapObjects
lsls r2, r0, 3
adds r2, r0
lsls r2, 2
adds r2, r1
ldrb r0, [r2, 0x8]
ldrb r1, [r2, 0x9]
ldrb r2, [r2, 0xA]
bl GetFieldObjectFlagIdByLocalIdAndMap
lsls r0, 16
lsrs r0, 16
pop {r1}
bx r1
.pool
thumb_func_end GetFieldObjectFlagIdByFieldObjectId
thumb_func_start sub_808F080
sub_808F080: @ 808F080
push {lr}

View file

@ -1490,3 +1490,23 @@ void FieldObjectSetDirection(struct MapObject *mapObject, u8 direction)
}
mapObject->placeholder18 = direction;
}
static const u8 *GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
{
return GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->script;
}
const u8 *GetFieldObjectScriptPointerByFieldObjectId(u8 mapObjectId)
{
return GetFieldObjectScriptPointerByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup);
}
static u16 GetFieldObjectFlagIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
{
return GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->flagId;
}
u16 GetFieldObjectFlagIdByFieldObjectId(u8 mapObjectId)
{
return GetFieldObjectFlagIdByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup);
}