mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
start decompiling field_map_obj_helpers
This commit is contained in:
parent
10037ac0e1
commit
3eaaa59c04
@ -31433,7 +31433,7 @@ _08019B84:
|
||||
b _08019B9C
|
||||
_08019B96:
|
||||
adds r0, r4, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
_08019B9C:
|
||||
movs r0, 0x1
|
||||
_08019B9E:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -109,7 +109,7 @@ _0809842A:
|
||||
cmp r0, 0
|
||||
blt _08098452
|
||||
adds r0, r1, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
movs r0, 0x1
|
||||
strh r0, [r5, 0xA]
|
||||
_08098452:
|
||||
@ -154,7 +154,7 @@ LockSelectedMapObject: @ 80984A0
|
||||
push {r4,r5,lr}
|
||||
ldr r4, =gSelectedMapObject
|
||||
ldrb r0, [r4]
|
||||
bl sub_80974D0
|
||||
bl FreezeMapObjectsExceptOne
|
||||
ldr r0, =sub_8098400
|
||||
movs r1, 0x50
|
||||
bl CreateTask
|
||||
@ -171,7 +171,7 @@ LockSelectedMapObject: @ 80984A0
|
||||
cmp r0, 0
|
||||
blt _080984DE
|
||||
adds r0, r1, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
ldr r0, =gTasks
|
||||
lsls r1, r5, 2
|
||||
adds r1, r5
|
||||
@ -317,7 +317,7 @@ _080985E8:
|
||||
cmp r0, 0
|
||||
blt _0809860C
|
||||
adds r0, r1, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
movs r0, 0x1
|
||||
strh r0, [r5, 0xA]
|
||||
_0809860C:
|
||||
@ -385,7 +385,7 @@ sub_8098630: @ 8098630
|
||||
cmp r0, 0
|
||||
blt _0809869A
|
||||
adds r0, r1, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
movs r0, 0x1
|
||||
strh r0, [r6, 0xA]
|
||||
_0809869A:
|
||||
@ -410,14 +410,14 @@ _0809869A:
|
||||
cmp r0, 0
|
||||
blt _0809871A
|
||||
adds r0, r1, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
movs r0, 0x1
|
||||
strh r0, [r4, 0xA]
|
||||
b _0809871A
|
||||
.pool
|
||||
_080986E0:
|
||||
adds r0, r4, 0
|
||||
bl sub_80974D0
|
||||
bl FreezeMapObjectsExceptOne
|
||||
ldr r0, =sub_80985BC
|
||||
movs r1, 0x50
|
||||
bl CreateTask
|
||||
@ -439,7 +439,7 @@ _080986E0:
|
||||
cmp r0, 0
|
||||
blt _0809871A
|
||||
adds r0, r1, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
movs r0, 0x1
|
||||
strh r0, [r5, 0xA]
|
||||
_0809871A:
|
||||
|
@ -553,7 +553,7 @@ _080D36DC:
|
||||
adds r1, r6, 0
|
||||
bl sub_80D355C
|
||||
adds r0, r4, 0
|
||||
bl sub_8097404
|
||||
bl FreezeMapObject
|
||||
b _080D370E
|
||||
.pool
|
||||
_080D36F8:
|
||||
|
@ -29,6 +29,6 @@ bool8 sub_8097758(struct Sprite *);
|
||||
void sub_8097FA4(struct MapObject *);
|
||||
void sub_8098044(u8);
|
||||
void UnfreezeMapObjects(void);
|
||||
void sub_80974D0(u8 mapObjectId);
|
||||
void FreezeMapObjectsExceptOne(u8 mapObjectId);
|
||||
|
||||
#endif //GUARD_MAP_OBJ_8097404_H
|
||||
|
@ -97,6 +97,7 @@ SECTIONS {
|
||||
asm/field_player_avatar.o(.text);
|
||||
src/field_map_obj.o(.text);
|
||||
asm/field_ground_effect.o(.text);
|
||||
src/field_map_obj_helpers.o(.text);
|
||||
asm/map_obj_8097404.o(.text);
|
||||
asm/field_message_box.o(.text);
|
||||
asm/map_obj_lock.o(.text);
|
||||
|
371
src/field_map_obj_helpers.c
Executable file
371
src/field_map_obj_helpers.c
Executable file
@ -0,0 +1,371 @@
|
||||
#include "global.h"
|
||||
#include "field_ground_effect.h"
|
||||
#include "field_map_obj.h"
|
||||
|
||||
typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 dir);
|
||||
|
||||
extern const s8 gUnknown_0850E7BA[];
|
||||
extern const s8 gUnknown_0850E772[];
|
||||
|
||||
extern s16 gUnknown_0850E768[];
|
||||
extern SpriteStepFunc *const gUnknown_0850E754[];
|
||||
extern const struct Coords16 gUnknown_0850DB7C[4];
|
||||
|
||||
bool8 FreezeMapObject(struct MapObject *mapObject)
|
||||
{
|
||||
if (mapObject->mapobj_bit_6 || mapObject->mapobj_bit_8)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapObject->mapobj_bit_8 = 1;
|
||||
mapObject->mapobj_bit_23 = gSprites[mapObject->spriteId].animPaused;
|
||||
mapObject->mapobj_bit_24 = gSprites[mapObject->spriteId].affineAnimPaused;
|
||||
gSprites[mapObject->spriteId].animPaused = 1;
|
||||
gSprites[mapObject->spriteId].affineAnimPaused = 1;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void FreezeMapObjects(void)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < 16; i++)
|
||||
if (gMapObjects[i].active && i != gPlayerAvatar.mapObjectId)
|
||||
FreezeMapObject(&gMapObjects[i]);
|
||||
}
|
||||
|
||||
void FreezeMapObjectsExceptOne(u8 a1)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < 16; i++)
|
||||
if (i != a1 && gMapObjects[i].active && i != gPlayerAvatar.mapObjectId)
|
||||
FreezeMapObject(&gMapObjects[i]);
|
||||
}
|
||||
|
||||
void npc_sync_anim_pause_bits(struct MapObject *mapObject)
|
||||
{
|
||||
if (mapObject->active && mapObject->mapobj_bit_8)
|
||||
{
|
||||
mapObject->mapobj_bit_8 = 0;
|
||||
gSprites[mapObject->spriteId].animPaused = mapObject->mapobj_bit_23;
|
||||
gSprites[mapObject->spriteId].affineAnimPaused = mapObject->mapobj_bit_24;
|
||||
}
|
||||
}
|
||||
|
||||
void UnfreezeMapObjects(void)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < 16; i++)
|
||||
if (gMapObjects[i].active)
|
||||
npc_sync_anim_pause_bits(&gMapObjects[i]);
|
||||
}
|
||||
|
||||
void little_step(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void double_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 2 * (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 2 * (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void triple_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 2 * (u16) gUnknown_0850DB7C[dir].x + (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 2 * (u16) gUnknown_0850DB7C[dir].y + (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void quad_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 4 * (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 4 * (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void oct_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 8 * (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 8 * (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3)
|
||||
{
|
||||
sprite->data[3] = a2;
|
||||
sprite->data[4] = a3;
|
||||
sprite->data[5] = 0;
|
||||
}
|
||||
|
||||
bool8 obj_npc_ministep(struct Sprite *sprite)
|
||||
{
|
||||
if (sprite->data[5] >= gUnknown_0850E768[sprite->data[4]])
|
||||
return FALSE;
|
||||
|
||||
gUnknown_0850E754[sprite->data[4]][sprite->data[5]](sprite, sprite->data[3]);
|
||||
|
||||
sprite->data[5]++;
|
||||
|
||||
if (sprite->data[5] < gUnknown_0850E768[sprite->data[4]])
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_80976DC(struct Sprite *sprite, u8 a2)
|
||||
{
|
||||
sprite->data[3] = a2;
|
||||
sprite->data[4] = 0;
|
||||
sprite->data[5] = 0;
|
||||
}
|
||||
|
||||
bool8 sub_80976EC(struct Sprite *sprite)
|
||||
{
|
||||
if (!(sprite->data[4] & 1))
|
||||
{
|
||||
little_step(sprite, sprite->data[3]);
|
||||
sprite->data[5]++;
|
||||
}
|
||||
|
||||
sprite->data[4]++;
|
||||
|
||||
if (sprite->data[5] > 15)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// new helper added here in the middle. Perhaps Game Freak kept these organized in alphebetical order or some other heirarchy?
|
||||
|
||||
s16 sub_8097728(s16 a1)
|
||||
{
|
||||
return gUnknown_0850E7BA[a1];
|
||||
}
|
||||
|
||||
s16 sub_809773C(s16 a1)
|
||||
{
|
||||
return gUnknown_0850E772[a1];
|
||||
}
|
||||
|
||||
void sub_8097750(struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[6] = 0;
|
||||
sprite->data[7] = 0;
|
||||
}
|
||||
|
||||
bool8 sub_8097758(struct Sprite *sprite)
|
||||
{
|
||||
bool8 result = FALSE;
|
||||
|
||||
switch(sprite->data[7])
|
||||
{
|
||||
case 0:
|
||||
sprite->pos2.x += sub_809773C(sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(sprite->data[6]);
|
||||
break;
|
||||
case 1:
|
||||
sprite->pos2.x -= sub_809773C(0x47 - sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]);
|
||||
break;
|
||||
case 2:
|
||||
sprite->pos2.x -= sub_809773C(sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(sprite->data[6]);
|
||||
break;
|
||||
case 3:
|
||||
sprite->pos2.x += sub_809773C(0x47 - sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]);
|
||||
break;
|
||||
}
|
||||
if(++sprite->data[6] == 0x48)
|
||||
{
|
||||
sprite->data[6] = 0;
|
||||
sprite->data[7]++;
|
||||
}
|
||||
if(sprite->data[7] == 0x4)
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
sprite->pos2.x = 0;
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern const s8 *const gUnknown_0850E834[];
|
||||
extern s16 gUnknown_0850E840[];
|
||||
extern u8 gUnknown_0850E846[];
|
||||
|
||||
s16 sub_8097820(s16 a1, u8 a2)
|
||||
{
|
||||
return gUnknown_0850E834[a2][a1];
|
||||
}
|
||||
|
||||
void sub_809783C(struct Sprite *sprite, u8 a2, u8 a3, u8 a4)
|
||||
{
|
||||
sprite->data[3] = a2;
|
||||
sprite->data[4] = a3;
|
||||
sprite->data[5] = a4;
|
||||
sprite->data[6] = 0;
|
||||
}
|
||||
|
||||
u8 sub_809785C(struct Sprite *sprite)
|
||||
{
|
||||
s16 v5[3];
|
||||
u8 v6[3];
|
||||
u8 v2;
|
||||
|
||||
memcpy(v5, gUnknown_0850E840, 6); // TODO: get rid of memcpy
|
||||
memcpy(v6, gUnknown_0850E846, 3);
|
||||
v2 = 0;
|
||||
|
||||
if (sprite->data[4])
|
||||
little_step(sprite, sprite->data[3]);
|
||||
|
||||
sprite->pos2.y = sub_8097820(sprite->data[6] >> v6[sprite->data[4]], sprite->data[5]);
|
||||
|
||||
sprite->data[6]++;
|
||||
|
||||
if (sprite->data[6] == (v5[sprite->data[4]] >> 1))
|
||||
v2 = 1;
|
||||
|
||||
if (sprite->data[6] >= v5[sprite->data[4]])
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
v2 = -1;
|
||||
}
|
||||
|
||||
return v2;
|
||||
}
|
||||
|
||||
extern s16 gUnknown_0850E84A[];
|
||||
extern u8 gUnknown_0850E850[];
|
||||
|
||||
u8 sub_80978E4(struct Sprite *sprite)
|
||||
{
|
||||
s16 v5[3];
|
||||
u8 v6[3];
|
||||
u8 v2;
|
||||
|
||||
memcpy(v5, gUnknown_0850E84A, 6);
|
||||
memcpy(v6, gUnknown_0850E850, 3);
|
||||
v2 = 0;
|
||||
|
||||
if (sprite->data[4] && !(sprite->data[6] & 1))
|
||||
little_step(sprite, sprite->data[3]);
|
||||
|
||||
sprite->pos2.y = sub_8097820(sprite->data[6] >> v6[sprite->data[4]], sprite->data[5]);
|
||||
|
||||
sprite->data[6]++;
|
||||
|
||||
if (sprite->data[6] == (v5[sprite->data[4]] >> 1))
|
||||
v2 = 1;
|
||||
|
||||
if (sprite->data[6] >= v5[sprite->data[4]])
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
v2 = -1;
|
||||
}
|
||||
|
||||
return v2;
|
||||
}
|
||||
|
||||
void SetFieldObjectStepTimer(struct Sprite *sprite, u16 timer)
|
||||
{
|
||||
sprite->data[3] = timer;
|
||||
}
|
||||
|
||||
|
||||
bool8 RunFieldObjectStepTimer(struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[3]--;
|
||||
|
||||
if (sprite->data[3] == 0)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void obj_anim_image_set_and_seek(struct Sprite *sprite, u8 a2, u8 a3)
|
||||
{
|
||||
sprite->animNum = a2;
|
||||
sprite->animPaused = 0 ;
|
||||
SeekSpriteAnim(sprite, a3);
|
||||
}
|
||||
|
||||
bool8 sub_80979BC(struct Sprite *sprite)
|
||||
{
|
||||
if (sprite->animEnded)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_80979D4(struct Sprite *sprite, bool8 invisible)
|
||||
{
|
||||
u16 x, y;
|
||||
s16 x2, y2;
|
||||
|
||||
sprite->invisible = invisible;
|
||||
|
||||
if (sprite->coordOffsetEnabled)
|
||||
{
|
||||
x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
|
||||
y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX;
|
||||
y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY;
|
||||
}
|
||||
|
||||
x2 = x - (sprite->centerToCornerVecX >> 1);
|
||||
y2 = y - (sprite->centerToCornerVecY >> 1);
|
||||
|
||||
if ((s16)x > 255 || x2 < -16)
|
||||
sprite->invisible = 1;
|
||||
if ((s16)y > 175 || y2 < -16)
|
||||
sprite->invisible = 1;
|
||||
}
|
||||
|
||||
extern void sub_8097D68(struct Sprite *sprite);
|
||||
|
||||
void sub_8097AC8(struct Sprite *sprite)
|
||||
{
|
||||
sub_8097D68(sprite);
|
||||
SetObjectSubpriorityByZCoord(sprite->data[1], sprite, 1);
|
||||
sub_80979D4(sprite, sprite->data[2]);
|
||||
}
|
||||
|
||||
void sub_8097AF0(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAX_SPRITES; i++)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[i];
|
||||
if(sprite->inUse && sprite->callback == sub_8097AC8)
|
||||
DestroySprite(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
int sub_8097B2C(u8 var) // this should return a u8, because all that call this shifts to u8, but it wont match because it doesnt shift u8 at the end.
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAX_SPRITES; i++)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[i];
|
||||
if(sprite->inUse && sprite->callback == sub_8097AC8 && (u8)sprite->data[0] == var)
|
||||
return i;
|
||||
}
|
||||
return MAX_SPRITES;
|
||||
}
|
||||
|
||||
void sub_8097B78(u8 var1, u8 var2)
|
||||
{
|
||||
u8 spriteId = sub_8097B2C(var1);
|
||||
|
||||
if(spriteId != MAX_SPRITES)
|
||||
StartSpriteAnim(&gSprites[spriteId], FieldObjectDirectionToImageAnimId(var2));
|
||||
}
|
@ -639,7 +639,7 @@ void sub_80B45D0(void)
|
||||
gApproachingTrainerId++;
|
||||
gSpecialVar_Result = 1;
|
||||
UnfreezeMapObjects();
|
||||
sub_80974D0(gApproachingTrainers[1].mapObjectId);
|
||||
FreezeMapObjectsExceptOne(gApproachingTrainers[1].mapObjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user