mirror of https://github.com/pret/pokeemerald.git
Document some faraway_island code
This commit is contained in:
parent
462b196abc
commit
d13563b174
|
@ -0,0 +1,3 @@
|
|||
sPlayerToMewDeltaX
|
||||
sPlayerToMewDeltaY
|
||||
sMewDirectionCandidates
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef GUARD_FARAWAY_ISLAND_H
|
||||
#define GUARD_FARAWAY_ISLAND_H
|
||||
|
||||
u32 sub_81D427C(void);
|
||||
u32 GetMewMoveDirection(void);
|
||||
bool8 sub_81D4A58(struct EventObject*);
|
||||
void UpdateFarawayIslandStepCounter(void);
|
||||
bool8 EventObjectIsFarawayIslandMew(struct EventObject *);
|
||||
|
|
|
@ -4414,8 +4414,8 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct EventObject *eventObject, struct Sp
|
|||
direction = playerDirection;
|
||||
if (EventObjectIsFarawayIslandMew(eventObject))
|
||||
{
|
||||
direction = sub_81D427C();
|
||||
if (direction == 0)
|
||||
direction = GetMewMoveDirection();
|
||||
if (direction == DIR_NONE)
|
||||
{
|
||||
direction = playerDirection;
|
||||
direction = state_to_direction(gInitialMovementTypeFacingDirections[eventObject->movementType], eventObject->directionSequenceIndex, direction);
|
||||
|
|
|
@ -17,12 +17,13 @@ static u8 sub_81D4C9C(struct EventObject*, u8);
|
|||
static u8 sub_81D4C58(struct EventObject*, u8);
|
||||
static u8 sub_81D4CE0(struct EventObject*, u8);
|
||||
static u8 sub_81D4D24(u8);
|
||||
static bool8 sub_81D4834(s16, s16);
|
||||
static bool8 CanMewWalkToCoords(s16, s16);
|
||||
|
||||
extern u8 gUnknown_0203CF50;
|
||||
extern s16 gUnknown_030012F8;
|
||||
extern s16 gUnknown_030012FA;
|
||||
extern u8 gUnknown_030012FC[4];
|
||||
static EWRAM_DATA u8 sUnknown_0203CF50 = 0;
|
||||
|
||||
static s16 sPlayerToMewDeltaX;
|
||||
static s16 sPlayerToMewDeltaY;
|
||||
static u8 sMewDirectionCandidates[4];
|
||||
|
||||
extern const struct SpritePalette gFieldEffectObjectPaletteInfo1;
|
||||
extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
|
||||
|
@ -35,23 +36,23 @@ static const s16 sFarawayIslandRockCoords[4][2] =
|
|||
{20, 20},
|
||||
};
|
||||
|
||||
static u8 sub_81D4258(void)
|
||||
static u8 GetMewEventObjectId(void)
|
||||
{
|
||||
u8 eventObjectId;
|
||||
TryGetEventObjectIdByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &eventObjectId);
|
||||
return eventObjectId;
|
||||
}
|
||||
|
||||
u32 sub_81D427C(void)
|
||||
u32 GetMewMoveDirection(void)
|
||||
{
|
||||
u8 i;
|
||||
int skip;
|
||||
struct EventObject *mew = &gEventObjects[sub_81D4258()];
|
||||
struct EventObject *mew = &gEventObjects[GetMewEventObjectId()];
|
||||
|
||||
gUnknown_030012F8 = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x - mew->currentCoords.x;
|
||||
gUnknown_030012FA = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y - mew->currentCoords.y;
|
||||
for (i = 0; i < ARRAY_COUNT(gUnknown_030012FC); i++)
|
||||
gUnknown_030012FC[i] = DIR_NONE;
|
||||
sPlayerToMewDeltaX = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x - mew->currentCoords.x;
|
||||
sPlayerToMewDeltaY = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y - mew->currentCoords.y;
|
||||
for (i = 0; i < ARRAY_COUNT(sMewDirectionCandidates); i++)
|
||||
sMewDirectionCandidates[i] = DIR_NONE;
|
||||
|
||||
if (gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x == gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x
|
||||
&& gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y == gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y)
|
||||
|
@ -85,33 +86,33 @@ u32 sub_81D427C(void)
|
|||
|
||||
if (!skip)
|
||||
{
|
||||
if (gUnknown_030012F8 > 0)
|
||||
if (sPlayerToMewDeltaX > 0)
|
||||
{
|
||||
if (mew->currentCoords.x + 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
return DIR_EAST;
|
||||
}
|
||||
}
|
||||
else if (gUnknown_030012F8 < 0)
|
||||
else if (sPlayerToMewDeltaX < 0)
|
||||
{
|
||||
if (mew->currentCoords.x - 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
return DIR_WEST;
|
||||
}
|
||||
}
|
||||
|
||||
if (mew->currentCoords.x == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x)
|
||||
{
|
||||
if (gUnknown_030012FA > 0)
|
||||
if (sPlayerToMewDeltaY > 0)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
return DIR_NORTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
return DIR_SOUTH;
|
||||
}
|
||||
}
|
||||
|
@ -134,33 +135,33 @@ u32 sub_81D427C(void)
|
|||
|
||||
if (!skip)
|
||||
{
|
||||
if (gUnknown_030012FA > 0)
|
||||
if (sPlayerToMewDeltaY > 0)
|
||||
{
|
||||
if (mew->currentCoords.y + 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
return DIR_SOUTH;
|
||||
}
|
||||
}
|
||||
else if (gUnknown_030012FA < 0)
|
||||
else if (sPlayerToMewDeltaY < 0)
|
||||
{
|
||||
if (mew->currentCoords.y - 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
return DIR_NORTH;
|
||||
}
|
||||
}
|
||||
|
||||
if (mew->currentCoords.y == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y)
|
||||
{
|
||||
if (gUnknown_030012F8 > 0)
|
||||
if (sPlayerToMewDeltaX > 0)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
return DIR_WEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
return DIR_EAST;
|
||||
}
|
||||
}
|
||||
|
@ -208,52 +209,52 @@ u32 sub_81D427C(void)
|
|||
return DIR_WEST;
|
||||
}
|
||||
|
||||
if (gUnknown_030012FA == 0)
|
||||
if (sPlayerToMewDeltaY == 0)
|
||||
{
|
||||
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y > mew->currentCoords.y)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
return DIR_NORTH;
|
||||
}
|
||||
|
||||
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y < mew->currentCoords.y)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
return DIR_SOUTH;
|
||||
}
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
return DIR_NORTH;
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
return DIR_SOUTH;
|
||||
}
|
||||
|
||||
if (gUnknown_030012F8 == 0)
|
||||
if (sPlayerToMewDeltaX == 0)
|
||||
{
|
||||
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x > mew->currentCoords.x)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
return DIR_WEST;
|
||||
}
|
||||
|
||||
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x < mew->currentCoords.x)
|
||||
{
|
||||
if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
return DIR_EAST;
|
||||
}
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
return DIR_EAST;
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
return DIR_WEST;
|
||||
}
|
||||
|
||||
return sub_81D4890(DIR_NONE);
|
||||
}
|
||||
|
||||
static bool8 sub_81D4834(s16 x, s16 y)
|
||||
static bool8 CanMewWalkToCoords(s16 x, s16 y)
|
||||
{
|
||||
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x == x
|
||||
&& gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y == y)
|
||||
|
@ -268,39 +269,39 @@ static u8 sub_81D4890(u8 ignoredDir)
|
|||
{
|
||||
u8 i;
|
||||
u8 count = 0;
|
||||
struct EventObject *mew = &gEventObjects[sub_81D4258()];
|
||||
struct EventObject *mew = &gEventObjects[GetMewEventObjectId()];
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gUnknown_030012FC); i++)
|
||||
gUnknown_030012FC[i] = DIR_NONE;
|
||||
for (i = 0; i < ARRAY_COUNT(sMewDirectionCandidates); i++)
|
||||
sMewDirectionCandidates[i] = DIR_NONE;
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1) == TRUE && ignoredDir != DIR_NORTH)
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1) == TRUE && ignoredDir != DIR_NORTH)
|
||||
{
|
||||
gUnknown_030012FC[count] = DIR_NORTH;
|
||||
sMewDirectionCandidates[count] = DIR_NORTH;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_EAST)
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_EAST)
|
||||
{
|
||||
gUnknown_030012FC[count] = DIR_EAST;
|
||||
sMewDirectionCandidates[count] = DIR_EAST;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1) == TRUE && ignoredDir != DIR_SOUTH)
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1) == TRUE && ignoredDir != DIR_SOUTH)
|
||||
{
|
||||
gUnknown_030012FC[count] = DIR_SOUTH;
|
||||
sMewDirectionCandidates[count] = DIR_SOUTH;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_WEST)
|
||||
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_WEST)
|
||||
{
|
||||
gUnknown_030012FC[count] = DIR_WEST;
|
||||
sMewDirectionCandidates[count] = DIR_WEST;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count > 1)
|
||||
return gUnknown_030012FC[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % count];
|
||||
return sMewDirectionCandidates[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % count];
|
||||
else
|
||||
return gUnknown_030012FC[0];
|
||||
return sMewDirectionCandidates[0];
|
||||
}
|
||||
|
||||
void UpdateFarawayIslandStepCounter(void)
|
||||
|
@ -355,7 +356,7 @@ void sub_81D4A90(void)
|
|||
s16 x;
|
||||
s16 y;
|
||||
u8 spriteId;
|
||||
struct EventObject *mew = &gEventObjects[sub_81D4258()];
|
||||
struct EventObject *mew = &gEventObjects[GetMewEventObjectId()];
|
||||
|
||||
mew->invisible = 0;
|
||||
if (gSpecialVar_0x8004 == 1)
|
||||
|
@ -378,10 +379,10 @@ void sub_81D4A90(void)
|
|||
x = mew->currentCoords.x;
|
||||
y = mew->currentCoords.y;
|
||||
sub_80930E0(&x, &y, 8, 8);
|
||||
gUnknown_0203CF50 = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[15], x, y, gSprites[mew->spriteId].subpriority - 1);
|
||||
if (gUnknown_0203CF50 != MAX_SPRITES)
|
||||
sUnknown_0203CF50 = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[15], x, y, gSprites[mew->spriteId].subpriority - 1);
|
||||
if (sUnknown_0203CF50 != MAX_SPRITES)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[gUnknown_0203CF50];
|
||||
struct Sprite *sprite = &gSprites[sUnknown_0203CF50];
|
||||
sprite->coordOffsetEnabled = 1;
|
||||
sprite->oam.priority = 2;
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
|
@ -391,15 +392,15 @@ void sub_81D4A90(void)
|
|||
|
||||
void sub_81D4BEC(void)
|
||||
{
|
||||
if (gUnknown_0203CF50 != MAX_SPRITES)
|
||||
DestroySprite(&gSprites[gUnknown_0203CF50]);
|
||||
if (sUnknown_0203CF50 != MAX_SPRITES)
|
||||
DestroySprite(&gSprites[sUnknown_0203CF50]);
|
||||
}
|
||||
|
||||
static bool8 sub_81D4C14(struct EventObject *mew, u8 index)
|
||||
{
|
||||
if (gUnknown_030012FA > 0 && sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
if (sPlayerToMewDeltaY > 0 && CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
|
||||
{
|
||||
gUnknown_030012FC[index] = DIR_NORTH;
|
||||
sMewDirectionCandidates[index] = DIR_NORTH;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -408,9 +409,9 @@ static bool8 sub_81D4C14(struct EventObject *mew, u8 index)
|
|||
|
||||
static u8 sub_81D4C58(struct EventObject *mew, u8 index)
|
||||
{
|
||||
if (gUnknown_030012F8 < 0 && sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
if (sPlayerToMewDeltaX < 0 && CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
|
||||
{
|
||||
gUnknown_030012FC[index] = DIR_EAST;
|
||||
sMewDirectionCandidates[index] = DIR_EAST;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -419,9 +420,9 @@ static u8 sub_81D4C58(struct EventObject *mew, u8 index)
|
|||
|
||||
static u8 sub_81D4C9C(struct EventObject *mew, u8 index)
|
||||
{
|
||||
if (gUnknown_030012FA < 0 && sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
if (sPlayerToMewDeltaY < 0 && CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
|
||||
{
|
||||
gUnknown_030012FC[index] = DIR_SOUTH;
|
||||
sMewDirectionCandidates[index] = DIR_SOUTH;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -430,9 +431,9 @@ static u8 sub_81D4C9C(struct EventObject *mew, u8 index)
|
|||
|
||||
static u8 sub_81D4CE0(struct EventObject *mew, u8 index)
|
||||
{
|
||||
if (gUnknown_030012F8 > 0 && sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
if (sPlayerToMewDeltaX > 0 && CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
|
||||
{
|
||||
gUnknown_030012FC[index] = DIR_WEST;
|
||||
sMewDirectionCandidates[index] = DIR_WEST;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -441,5 +442,5 @@ static u8 sub_81D4CE0(struct EventObject *mew, u8 index)
|
|||
|
||||
static u8 sub_81D4D24(u8 mod)
|
||||
{
|
||||
return gUnknown_030012FC[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % mod];
|
||||
return sMewDirectionCandidates[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % mod];
|
||||
}
|
||||
|
|
|
@ -88,14 +88,7 @@ gUnknown_030012F2: @ 30012F2
|
|||
gUnknown_030012F4: @ 30012F4
|
||||
.space 0x4
|
||||
|
||||
gUnknown_030012F8: @ 30012F8
|
||||
.space 0x2
|
||||
|
||||
gUnknown_030012FA: @ 30012FA
|
||||
.space 0x2
|
||||
|
||||
gUnknown_030012FC: @ 30012FC
|
||||
.space 0x4
|
||||
.include "src/faraway_island.o"
|
||||
|
||||
gUnknown_03001300: @ 3001300
|
||||
.space 0x40
|
||||
|
|
|
@ -214,9 +214,6 @@ gUnknown_0203CF44: @ 203CF44
|
|||
.space 0x4
|
||||
|
||||
.include "src/menu_specialized.o"
|
||||
|
||||
gUnknown_0203CF50: @ 203CF50
|
||||
.space 0x4
|
||||
|
||||
.include "src/faraway_island.o"
|
||||
.include "src/trainer_hill.o"
|
||||
.include "src/rayquaza_scene.o"
|
||||
|
|
Loading…
Reference in New Issue